Terrain and classic tiles now render properly in the scenario placement dialog.

This commit is contained in:
Justin Marshall
2020-06-25 09:56:40 -07:00
parent 79036cbeff
commit 995b794cd8
6 changed files with 27 additions and 29 deletions
+4 -17
View File
@@ -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);
}
}
}
+4 -11
View File
@@ -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();
//}
/*
+11
View File
@@ -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);
+2 -1
View File
@@ -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);
void GL_SetClipRect(int x, int y, int width, int height);
void GL_ForceForegroundRender(bool force);
+5
View File
@@ -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;
+1
View File
@@ -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);