diff --git a/code/REDALERT/CONQUER.CPP b/code/REDALERT/CONQUER.CPP index a0ae38f..b79337e 100644 --- a/code/REDALERT/CONQUER.CPP +++ b/code/REDALERT/CONQUER.CPP @@ -174,6 +174,9 @@ char TeamEvent = 0; // 0 = no event, 1,2,3 = team event type char TeamNumber = 0; // which team was selected? (1-9) char FormationEvent = 0; // 0 = no event, 1 = formation was toggled +bool g_inMainMenu = false; + + /* -----------------10/14/96 7:29PM------------------ @@ -229,6 +232,7 @@ void Main_Game(int argc, char * argv[]) ** 2) Invoke either the main-loop routine, or the editor-loop routine, ** until they indicate that the user wants to exit the scenario. */ + g_inMainMenu = true; while (Select_Game(fade)) { // ST 5/14/2019 @@ -278,6 +282,7 @@ void Main_Game(int argc, char * argv[]) #endif // !WOLAPI_INTEGRATION } #endif //WIN32 + g_inMainMenu = false; #ifdef SCENARIO_EDITOR /* diff --git a/code/REDALERT/DIALOG.CPP b/code/REDALERT/DIALOG.CPP index fa15f3e..aa29da6 100644 --- a/code/REDALERT/DIALOG.CPP +++ b/code/REDALERT/DIALOG.CPP @@ -46,7 +46,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "function.h" - +#include "Image.h" #include "defines.h" //VG 10/17/96 unsigned char * Font_Palette(int color); @@ -98,55 +98,91 @@ void Dialog_Box(int x, int y, int w, int h) */ int cx = w/2; int cy = h/2; +// jmarshall void const * shapedata = MFCD::Retrieve("DD-BKGND.SHP"); -#ifdef WIN32 - CC_Draw_Shape(shapedata, 0, cx-312, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 1, cx, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 2, cx-312, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 3, cx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); -#else - CC_Draw_Shape(shapedata, 0, cx-156, cy-96, WINDOW_PARTIAL, SHAPE_WIN_REL); -#endif +//#ifdef WIN32 +// CC_Draw_Shape(shapedata, 0, cx-312, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL); +// CC_Draw_Shape(shapedata, 1, cx, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL); +// CC_Draw_Shape(shapedata, 2, cx-312, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); +// CC_Draw_Shape(shapedata, 3, cx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); +//#else +// CC_Draw_Shape(shapedata, 0, cx-156, cy-96, WINDOW_PARTIAL, SHAPE_WIN_REL); +//#endif + GL_SetClipRect(x, y, w, h); + + Image_t* ddbkgrnd = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0000.png"); + Image_t* ddbkgrnd_1 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0001.png"); + Image_t* ddbkgrnd_2 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0002.png"); + Image_t* ddbkgrnd_3 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0003.png"); + GL_RenderImage(ddbkgrnd, x, y, ddbkgrnd->width, ddbkgrnd->height); + GL_RenderImage(ddbkgrnd_1, x + 312, y, ddbkgrnd->width, ddbkgrnd->height); + GL_RenderImage(ddbkgrnd_2, x, y + 192, ddbkgrnd->width, ddbkgrnd->height); + GL_RenderImage(ddbkgrnd_3, x + 312, y + 192, ddbkgrnd->width, ddbkgrnd->height); +// jmarshall end /* ** Draw the side strips. */ - shapedata = MFCD::Retrieve("DD-EDGE.SHP"); + //shapedata = MFCD::Retrieve("DD-EDGE.SHP"); + Image_t* ddedge = Image_LoadImage("ui/dd-edge/dd-edge-0000.png"); + Image_t* ddedge_1 = Image_LoadImage("ui/dd-edge/dd-edge-0001.png"); for (int yy = 0; yy < h; yy += 6) { - CC_Draw_Shape(shapedata, 0, 7*RESFACTOR, yy, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 1, w-((7+8)*RESFACTOR), yy, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 0, 7*RESFACTOR, yy, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 1, w-((7+8)*RESFACTOR), yy, WINDOW_PARTIAL, SHAPE_WIN_REL); + GL_RenderImage(ddedge, x + (7 * RESFACTOR), y + yy, ddedge->width, ddedge->height); + GL_RenderImage(ddedge_1, x + (w - ((7 + 8) * RESFACTOR)), y + yy, ddedge->width, ddedge->height); } /* ** Draw the border bars. */ - shapedata = MFCD::Retrieve("DD-LEFT.SHP"); - CC_Draw_Shape(shapedata, 0, 0, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 0, 0, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); + //shapedata = MFCD::Retrieve("DD-LEFT.SHP"); + Image_t* ddleft = Image_LoadImage("ui/dd-edge/dd-left-0000.png"); + GL_RenderImage(ddleft, x, y + (cy - 100 * RESFACTOR), ddleft->width * 0.5, ddleft->height * 0.5); + GL_RenderImage(ddleft, x, y + cy, ddleft->width * 0.5, ddleft->height * 0.5); + //CC_Draw_Shape(shapedata, 0, 0, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 0, 0, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); - shapedata = MFCD::Retrieve("DD-RIGHT.SHP"); + //shapedata = MFCD::Retrieve("DD-RIGHT.SHP"); + Image_t* ddright = Image_LoadImage("ui/dd-edge/dd-right-0000.png"); int rightx = w - (7*RESFACTOR); #ifndef WIN32 rightx--; #endif - CC_Draw_Shape(shapedata, 0, rightx, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 0, rightx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); + GL_RenderImage(ddright, x + rightx, y + (cy - 100 * RESFACTOR), ddleft->width * 0.5, ddleft->height * 0.5); + GL_RenderImage(ddright, x + rightx, y + cy, ddleft->width * 0.5, ddleft->height * 0.5); + //CC_Draw_Shape(shapedata, 0, rightx, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 0, rightx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL); - shapedata = MFCD::Retrieve("DD-BOTM.SHP"); - CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 0, cx, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); + //shapedata = MFCD::Retrieve("DD-BOTM.SHP"); + Image_t* ddbotm = Image_LoadImage("ui/dd-edge/dd-botm-0000.png"); + GL_RenderImage(ddbotm, x + (cx - 160 * RESFACTOR), y + (h - 8 * RESFACTOR), ddbotm->width / 2, ddbotm->height / 2); + GL_RenderImage(ddbotm, x + (cx), y + (h - 8 * RESFACTOR), ddbotm->width / 2, ddbotm->height / 2); + //CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 0, cx, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL); - shapedata = MFCD::Retrieve("DD-TOP.SHP"); - CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, 0, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 0, cx, 0, WINDOW_PARTIAL, SHAPE_WIN_REL); + Image_t* ddtop = Image_LoadImage("ui/dd-edge/dd-top-0000.png"); + //CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, 0, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 0, cx, 0, WINDOW_PARTIAL, SHAPE_WIN_REL); + GL_RenderImage(ddtop, x + (cx - 160 * RESFACTOR), y, ddtop->width / 2, ddtop->height / 2); + GL_RenderImage(ddtop, x + (cx), y, ddtop->width / 2, ddtop->height / 2); /* ** Draw the corner caps. */ - shapedata = MFCD::Retrieve("DD-CRNR.SHP"); - CC_Draw_Shape(shapedata, 0, 0, 0, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 1, w-(12*RESFACTOR-1), 0, WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 2, 0, h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL); - CC_Draw_Shape(shapedata, 3, w-(12*RESFACTOR-1), h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL); + //shapedata = MFCD::Retrieve("DD-CRNR.SHP"); + Image_t* ddcrnr0 = Image_LoadImage("ui/dd-edge/dd-crnr-0000.png"); + Image_t* ddcrnr1 = Image_LoadImage("ui/dd-edge/dd-crnr-0001.png"); + Image_t* ddcrnr2 = Image_LoadImage("ui/dd-edge/dd-crnr-0002.png"); + Image_t* ddcrnr3 = Image_LoadImage("ui/dd-edge/dd-crnr-0003.png"); + GL_RenderImage(ddcrnr0, x, y, 23, 24); + GL_RenderImage(ddcrnr1, x + (w - (12 * RESFACTOR - 1)), y, 23, 24); + GL_RenderImage(ddcrnr2, x, y + (h - (12 * RESFACTOR)), 23, 24); + GL_RenderImage(ddcrnr3, x + (w - (12 * RESFACTOR - 1)), y + (h - (12 * RESFACTOR)), 23, 24); + + //CC_Draw_Shape(shapedata, 0, 0, 0, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 1, w-(12*RESFACTOR-1), 0, WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 2, 0, h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL); + //CC_Draw_Shape(shapedata, 3, w-(12*RESFACTOR-1), h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL); #ifdef WIN32 WWMouse->Draw_Mouse(&HidPage); @@ -160,6 +196,8 @@ void Dialog_Box(int x, int y, int w, int h) // Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, ((GraphicBufferClass*)Map.Shadow_Address())->Get_Buffer()); #endif Set_Logic_Page(oldpage); + + GL_ResetClipRect(); } diff --git a/code/REDALERT/FUNCTION.H b/code/REDALERT/FUNCTION.H index e8bc46e..8fc3573 100644 --- a/code/REDALERT/FUNCTION.H +++ b/code/REDALERT/FUNCTION.H @@ -1154,4 +1154,33 @@ extern const int NUM_EDIT_MISSIONS; extern void (*Imgui_Dialog_Function)(void); +/* +================== +COM_SetExtension +================== +*/ +__forceinline void COM_SetExtension(char* path, int maxSize, const char* extension) { + char oldPath[2048]; + char* src; + + // + // if path doesn't have a .EXT, append extension + // (extension should include the .) + // + src = path + strlen(path) - 1; + + while (*src != '/' && src != path) { + if (*src == '.') { + *src = 0; + break; + } + src--; + } + + strcpy(oldPath, path); + sprintf(path, "%s%s", oldPath, extension); +} + +extern bool g_inMainMenu; + #endif \ No newline at end of file diff --git a/code/REDALERT/INIT.CPP b/code/REDALERT/INIT.CPP index 92fc577..49ca69d 100644 --- a/code/REDALERT/INIT.CPP +++ b/code/REDALERT/INIT.CPP @@ -658,7 +658,6 @@ bool Select_Game(bool fade) #endif while (process) { - /* ** Redraw the title page if needed */ diff --git a/code/REDALERT/Image.h b/code/REDALERT/Image.h index 144c1e6..b41b602 100644 --- a/code/REDALERT/Image.h +++ b/code/REDALERT/Image.h @@ -2,6 +2,7 @@ // struct Image_t { + char name[512]; unsigned int image; int width; int height; diff --git a/code/REDALERT/MPLAYER.CPP b/code/REDALERT/MPLAYER.CPP index e71da39..71558c3 100644 --- a/code/REDALERT/MPLAYER.CPP +++ b/code/REDALERT/MPLAYER.CPP @@ -293,7 +293,7 @@ GameType Select_MPlayer_Game (void) // Redraw buttons //.................................................................. { - commands->Flag_List_To_Redraw(); + commands->Draw_All(); // jmarshall: force redraw everything. } Show_Mouse(); display = REDRAW_NONE; diff --git a/code/REDALERT/MSGBOX.CPP b/code/REDALERT/MSGBOX.CPP index fa0a29d..e686bec 100644 --- a/code/REDALERT/MSGBOX.CPP +++ b/code/REDALERT/MSGBOX.CPP @@ -258,6 +258,13 @@ int WWMessageBox::Process(const char * msg, const char * b1txt, const char * b2t process = true; pressed = false; while (process) { +// jmarshall + // If not in game, display the title screen. + if (g_inMainMenu) { + Load_Title_Screen("TITLE.PCX", NULL, NULL); + } +// jmarshall end + #ifdef WIN32 /* ** If we have just received input focus again after running in the background then diff --git a/code/REDALERT/NEWBLIT.CPP b/code/REDALERT/NEWBLIT.CPP index 653884d..0e92de6 100644 --- a/code/REDALERT/NEWBLIT.CPP +++ b/code/REDALERT/NEWBLIT.CPP @@ -8,6 +8,16 @@ extern byte backbuffer_palette[768]; extern uint8_t g_ColorXlat[16]; +void GL_SetClipRect(int x, int y, int width, int height) { + ImVec2 mi(x, y); + ImVec2 ma(x + width, y + height); + ImGui::GetForegroundDrawList()->PushClipRect(mi, ma); +} + +void GL_ResetClipRect(void) { + ImGui::GetForegroundDrawList()->PopClipRect(); +} + void GL_RenderImage(Image_t* image, int x, int y, int width, int height) { ImVec2 mi(x, y); ImVec2 ma(x + width, y + height); diff --git a/code/REDALERT/NEWBLIT.H b/code/REDALERT/NEWBLIT.H index 67aa378..84eba03 100644 --- a/code/REDALERT/NEWBLIT.H +++ b/code/REDALERT/NEWBLIT.H @@ -5,4 +5,6 @@ struct Image_t; void GL_RenderImage(Image_t* image, int x, int y, int width, int height); void GL_DrawText(int color, int x, int y, char* text); void GL_FillRect(int color, int x, int y, int width, int height); -void GL_DrawLine(int color, int x, int y, int dx, int dy); \ No newline at end of file +void GL_DrawLine(int color, int x, int y, int dx, int dy); +void GL_ResetClipRect(void); +void GL_SetClipRect(int x, int y, int width, int height); \ No newline at end of file diff --git a/code/REDALERT/SPECIAL.CPP b/code/REDALERT/SPECIAL.CPP index e28e8e6..c841948 100644 --- a/code/REDALERT/SPECIAL.CPP +++ b/code/REDALERT/SPECIAL.CPP @@ -532,8 +532,10 @@ int Fetch_Difficulty(void) while (process) { { +// jmarshall // redraw = false; - + Load_Title_Screen("TITLE.PCX", NULL, NULL); +// jmarshall end /* ** Draw the background of the dialog. */ diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index 6ce3e70..8e1192f 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -61,6 +61,8 @@ #include #include +#include + GLuint backbuffer_texture = -1; byte* backbuffer_data; unsigned char* backbuffer_data_raw; @@ -78,7 +80,16 @@ void (*Misc_Focus_Restore_Function)(void) = nullptr; void (*Imgui_Dialog_Function)(void) = nullptr; +std::vector loaded_images; + Image_t* Image_LoadImage(const char* name) { + // Check to see if the image is already loaded. + for (int i = 0; i < loaded_images.size(); i++) { + if (!strcmp(loaded_images[i]->name, name)) { + return loaded_images[i]; + } + } + ILuint ImageName; ilGenImages(1, &ImageName); ilBindImage(ImageName); @@ -112,12 +123,14 @@ Image_t* Image_LoadImage(const char* name) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - ilDeleteImages(1, &ImageName); + ilDeleteImages(1, &ImageName); Image_t* image = new Image_t(); + strcpy(image->name, name); image->image = texture; image->width = Width; image->height = Height; + loaded_images.push_back(image); return image; } @@ -851,17 +864,23 @@ void Memory_Error_Handler(void) GraphicBufferClass* Read_PCX_File(char* name, char* Palette, void *Buff, long Size); -void Load_Title_Screen(char *name, GraphicViewPortClass *video_page, unsigned char *palette) -{ +void Load_Title_Screen(char *name, GraphicViewPortClass *video_page, unsigned char *palette) { + char filename[512]; + sprintf(filename, "ui/%s", name); + COM_SetExtension(filename, sizeof(filename), ".png"); + Image_t* image = Image_LoadImage(filename); - GraphicBufferClass *load_buffer; + GL_RenderImage(image, 0, 0, ScreenWidth, ScreenHeight); - - load_buffer = Read_PCX_File (name, (char*)palette, NULL, 0); - - if (load_buffer) { - load_buffer->Scale(*video_page, 0, 0, 0, 0, load_buffer->Get_Width(), load_buffer->Get_Height(), ScreenWidth, ScreenHeight, NULL); + // We still have to do this for palette reasons. + { + GraphicBufferClass* load_buffer; + load_buffer = Read_PCX_File(name, (char*)palette, NULL, 0); delete load_buffer; + //if (load_buffer) { + // load_buffer->Scale(*video_page, 0, 0, 0, 0, load_buffer->Get_Width(), load_buffer->Get_Height(), ScreenWidth, ScreenHeight, NULL); + // delete load_buffer; + //} } } diff --git a/ui/dd-bkgrnd/dd-bkgnd-0000.png b/ui/dd-bkgrnd/dd-bkgnd-0000.png new file mode 100644 index 0000000..3bd82f1 Binary files /dev/null and b/ui/dd-bkgrnd/dd-bkgnd-0000.png differ diff --git a/ui/dd-bkgrnd/dd-bkgnd-0001.png b/ui/dd-bkgrnd/dd-bkgnd-0001.png new file mode 100644 index 0000000..954bdf6 Binary files /dev/null and b/ui/dd-bkgrnd/dd-bkgnd-0001.png differ diff --git a/ui/dd-bkgrnd/dd-bkgnd-0002.png b/ui/dd-bkgrnd/dd-bkgnd-0002.png new file mode 100644 index 0000000..82826bb Binary files /dev/null and b/ui/dd-bkgrnd/dd-bkgnd-0002.png differ diff --git a/ui/dd-bkgrnd/dd-bkgnd-0003.png b/ui/dd-bkgrnd/dd-bkgnd-0003.png new file mode 100644 index 0000000..7222c1f Binary files /dev/null and b/ui/dd-bkgrnd/dd-bkgnd-0003.png differ diff --git a/ui/dd-edge/dd-botm-0000.png b/ui/dd-edge/dd-botm-0000.png new file mode 100644 index 0000000..3bd8105 Binary files /dev/null and b/ui/dd-edge/dd-botm-0000.png differ diff --git a/ui/dd-edge/dd-crnr-0000.png b/ui/dd-edge/dd-crnr-0000.png new file mode 100644 index 0000000..d46e31f Binary files /dev/null and b/ui/dd-edge/dd-crnr-0000.png differ diff --git a/ui/dd-edge/dd-crnr-0001.png b/ui/dd-edge/dd-crnr-0001.png new file mode 100644 index 0000000..ebb6a97 Binary files /dev/null and b/ui/dd-edge/dd-crnr-0001.png differ diff --git a/ui/dd-edge/dd-crnr-0002.png b/ui/dd-edge/dd-crnr-0002.png new file mode 100644 index 0000000..ffaf924 Binary files /dev/null and b/ui/dd-edge/dd-crnr-0002.png differ diff --git a/ui/dd-edge/dd-crnr-0003.png b/ui/dd-edge/dd-crnr-0003.png new file mode 100644 index 0000000..f7cd699 Binary files /dev/null and b/ui/dd-edge/dd-crnr-0003.png differ diff --git a/ui/dd-edge/dd-edge-0000.png b/ui/dd-edge/dd-edge-0000.png new file mode 100644 index 0000000..0b2d0cf Binary files /dev/null and b/ui/dd-edge/dd-edge-0000.png differ diff --git a/ui/dd-edge/dd-edge-0001.png b/ui/dd-edge/dd-edge-0001.png new file mode 100644 index 0000000..9462c4c Binary files /dev/null and b/ui/dd-edge/dd-edge-0001.png differ diff --git a/ui/dd-edge/dd-left-0000.png b/ui/dd-edge/dd-left-0000.png new file mode 100644 index 0000000..2eea9aa Binary files /dev/null and b/ui/dd-edge/dd-left-0000.png differ diff --git a/ui/dd-edge/dd-right-0000.png b/ui/dd-edge/dd-right-0000.png new file mode 100644 index 0000000..43e1c91 Binary files /dev/null and b/ui/dd-edge/dd-right-0000.png differ diff --git a/ui/dd-edge/dd-top-0000.png b/ui/dd-edge/dd-top-0000.png new file mode 100644 index 0000000..453ce08 Binary files /dev/null and b/ui/dd-edge/dd-top-0000.png differ diff --git a/ui/title.png b/ui/title.png new file mode 100644 index 0000000..5fc62b5 Binary files /dev/null and b/ui/title.png differ diff --git a/ui/title.tga b/ui/title.tga deleted file mode 100644 index ab58f6f..0000000 Binary files a/ui/title.tga and /dev/null differ