diff --git a/code/REDALERT/CDATA.CPP b/code/REDALERT/CDATA.CPP index cad7202..a1ff7a9 100644 --- a/code/REDALERT/CDATA.CPP +++ b/code/REDALERT/CDATA.CPP @@ -3198,23 +3198,10 @@ void TemplateTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp for (index = 0; index < w*h; index++) { if (map[index] != 0xFF) { -// jmarshall - even if using legacy data, always use hdimage. - HidPage.Draw_Stamp(Get_HDImage_Data(), index, 0, 0, NULL, WINDOW_MAIN); - // Disabled legacy blit code. - //Buffer_Enable_HD_Texture(true); // At this point, Draw_Stamp creates a 32bit image. - //if (scale) { - // HidPage.Scale((*LogicPage), 0, 0, - // x + ((index % w)*(ICON_PIXEL_W/2)), - // y + ((index / w)*(ICON_PIXEL_H/2)), - // ICON_PIXEL_W, ICON_PIXEL_H, - // ICON_PIXEL_W/2, ICON_PIXEL_H/2, (char *)NULL); - // - //} else { - // HidPage.Blit((*LogicPage), 0, 0, x + ((index % w)*(ICON_PIXEL_W)), - // y + ((index / w)*(ICON_PIXEL_H)), ICON_PIXEL_W, ICON_PIXEL_H); - //} - //Buffer_Enable_HD_Texture(false); -// jmarshall end + Image_t* image = Get_HDImage_Data(); + int stamp_index = Stamp_GetIconIndex(image, index); + + GL_RenderForeGroundImage(image, x + ((index % w) * (ICON_PIXEL_W / 2)), y + ((index / w) * (ICON_PIXEL_H / 2)), ICON_PIXEL_W / 2, ICON_PIXEL_H / 2, 0, stamp_index); } } } diff --git a/code/REDALERT/MAPEDPLC.CPP b/code/REDALERT/MAPEDPLC.CPP index 1c53cc3..5f9644a 100644 --- a/code/REDALERT/MAPEDPLC.CPP +++ b/code/REDALERT/MAPEDPLC.CPP @@ -53,6 +53,7 @@ #include "imgui.h" #include "function.h" +#include "image.h" #ifdef SCENARIO_EDITOR int placementeditor_faction = 0; @@ -454,18 +455,10 @@ int MapEditClass::Placement_Dialog(void) WindowList[WINDOW_EDITOR][WINDOWHEIGHT] = D_PICTURE_H; Change_Window((int)WINDOW_EDITOR); // Draw_Box(D_PICTURE_X, D_PICTURE_Y, D_PICTURE_W, D_PICTURE_H, BOXSTYLE_DOWN, false); - //curobj->Display(WinW/2, WinH>>1, WINDOW_EDITOR, LastHouse); + GL_ForceForegroundRender(true); + curobj->Display((WinW/2) + 10, (WinH>>1) + 30, WINDOW_EDITOR, LastHouse); + GL_ForceForegroundRender(false); // curobj->Display(WinW<<2, WinH>>1, WINDOW_EDITOR, LastHouse); - - Image_t* image = NULL; - if (curobj->Get_HDImage_Data()) { - image = curobj->Get_HDImage_Data(); - GL_RenderForeGroundImage(image, 30, 100, 75, 75); - } - //else { - // image = (Image_t *)curobj->Get_Image_Data(); - //} - /* diff --git a/code/REDALERT/NEWBLIT.CPP b/code/REDALERT/NEWBLIT.CPP index 3917d16..0bd4f78 100644 --- a/code/REDALERT/NEWBLIT.CPP +++ b/code/REDALERT/NEWBLIT.CPP @@ -8,6 +8,12 @@ extern byte backbuffer_palette[768]; extern uint8_t g_ColorXlat[16]; +bool forceForgegroundRender = false; + +void GL_ForceForegroundRender(bool force) { + forceForgegroundRender = force; +} + void GL_SetClipRect(int x, int y, int width, int height) { ImVec2 mi(x, y); ImVec2 ma(x + width, y + height); @@ -22,6 +28,11 @@ void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int col ImVec2 mi(x, y); ImVec2 ma(x + width, y + height); + if (forceForgegroundRender) { + GL_RenderForeGroundImage(image, x, y, width, height, colorRemap, shapeId); + return; + } + if (image->numFrames > 0) { if(image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames] == 0) ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma); diff --git a/code/REDALERT/NEWBLIT.H b/code/REDALERT/NEWBLIT.H index 4e0f57c..4e96d36 100644 --- a/code/REDALERT/NEWBLIT.H +++ b/code/REDALERT/NEWBLIT.H @@ -8,4 +8,5 @@ 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_ResetClipRect(void); -void GL_SetClipRect(int x, int y, int width, int height); \ No newline at end of file +void GL_SetClipRect(int x, int y, int width, int height); +void GL_ForceForegroundRender(bool force); \ No newline at end of file diff --git a/code/REDALERT/TILESET.CPP b/code/REDALERT/TILESET.CPP index f794d90..b24846d 100644 --- a/code/REDALERT/TILESET.CPP +++ b/code/REDALERT/TILESET.CPP @@ -319,6 +319,11 @@ Image_t * Load_Stamp(const char *name, const void* icondata) return image; } +int Stamp_GetIconIndex(Image_t* iconImage, int icon) { + uint8_t* MapPtr = (uint8_t*)iconImage->IconMapPtr; + return MapPtr != nullptr ? MapPtr[icon] : icon; +} + void __cdecl Buffer_Draw_Stamp_Clip2(GraphicViewPortClass& viewport, const void *icondata, int icon, int x, int y, const void* remapper, int left, int top, int right, int bottom) { Image_t* iconImage = (Image_t*)icondata; diff --git a/code/REDALERT/WIN32LIB/DRAWBUFF.H b/code/REDALERT/WIN32LIB/DRAWBUFF.H index 8f5ff9e..67ba5fe 100644 --- a/code/REDALERT/WIN32LIB/DRAWBUFF.H +++ b/code/REDALERT/WIN32LIB/DRAWBUFF.H @@ -64,6 +64,7 @@ extern "C" { struct Image_t; Image_t* Load_Stamp(const char* name, const void* icondata); +int Stamp_GetIconIndex(Image_t* iconImage, int icon); void Get_Stamp_Size(const void* icondata, int *width, int *height); Image_t* Load_StampHD(int theater, const char* iconName, const void *icondata);