mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
Switched menu render over to OGL.
This commit is contained in:
@@ -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
|
||||
/*
|
||||
|
||||
+67
-29
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -658,7 +658,6 @@ bool Select_Game(bool fade)
|
||||
#endif
|
||||
|
||||
while (process) {
|
||||
|
||||
/*
|
||||
** Redraw the title page if needed
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//
|
||||
|
||||
struct Image_t {
|
||||
char name[512];
|
||||
unsigned int image;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
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);
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
#include <imgui.h>
|
||||
#include <examples/imgui_impl_opengl3.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
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<Image_t *> 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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user