From ede9d518bf213908f63013515e8a7e6240d5c946 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 1 Jul 2020 14:13:28 -0700 Subject: [PATCH] Isometric tiles will no longer render on top of each other. --- code/redalert/cell.cpp | 13 +++++++++++-- code/redalert/newblit.cpp | 11 +++++++++++ code/redalert/newblit.h | 3 ++- code/redalert/tileset.cpp | 5 +++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/code/redalert/cell.cpp b/code/redalert/cell.cpp index 5ed9874..0de5995 100644 --- a/code/redalert/cell.cpp +++ b/code/redalert/cell.cpp @@ -999,13 +999,14 @@ bool CellClass::Get_Template_Info(char *template_name, int &icon, void *&image_d } void CellClass::ConvertCoordsToIsometric(int& x, int& y) { + y = y * 2; int tileWidth = CELL_PIXEL_W; int tileHeight = CELL_PIXEL_H; int sx = (x / CELL_PIXEL_W) * (tileWidth / 2) - (y / CELL_PIXEL_W) * (tileWidth / 2); int sy = (x / CELL_PIXEL_W) * (tileHeight / 2) + (y / CELL_PIXEL_W) * (tileHeight / 2); - x = sx + (CELL_PIXEL_W / 2); - y = sy + (CELL_PIXEL_W / 2); + x = sx;// + (CELL_PIXEL_W / 2); + y = sy;// + (CELL_PIXEL_W / 2); x = x + (ScreenWidth / 2); } @@ -1306,6 +1307,14 @@ void CellClass::Draw_It(int x, int y, bool objects) #ifdef CHEAT_KEYS } #endif + //{ + // int isox = x, isoy = y; + // ConvertCoordsToIsometric(isox, isoy); + // char tmp[12]; + // sprintf(tmp, "%d", cell); + // GL_DrawText(6, isox, isoy, tmp); + //} + BEnd(BENCH_CELL); } diff --git a/code/redalert/newblit.cpp b/code/redalert/newblit.cpp index 0bd4f78..10b090d 100644 --- a/code/redalert/newblit.cpp +++ b/code/redalert/newblit.cpp @@ -81,6 +81,17 @@ void GL_DrawText(int color, int x, int y, char* text) { ImGui::GetBackgroundDrawList()->AddText(pos, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1)), text); } +void GL_DrawForegroundText(int color, int x, int y, char* text) { + ImVec2 pos(x, y); + if (color == 0 || color == 160) { // This is a hack! + color = g_ColorXlat[color % 15]; + } + float r = backbuffer_palette[(color * 3) + 0] / 255.0f; + float g = backbuffer_palette[(color * 3) + 1] / 255.0f; + float b = backbuffer_palette[(color * 3) + 2] / 255.0f; + ImGui::GetForegroundDrawList()->AddText(pos, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1)), text); +} + void GL_DrawLine(int color, int x, int y, int dx, int dy) { ImVec2 pos(x, y); ImVec2 pos2(dx, dy); diff --git a/code/redalert/newblit.h b/code/redalert/newblit.h index 4e96d36..9989725 100644 --- a/code/redalert/newblit.h +++ b/code/redalert/newblit.h @@ -9,4 +9,5 @@ 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_ForceForegroundRender(bool force); \ No newline at end of file +void GL_ForceForegroundRender(bool force); +void GL_DrawForegroundText(int color, int x, int y, char* text); \ No newline at end of file diff --git a/code/redalert/tileset.cpp b/code/redalert/tileset.cpp index 006111c..c0365c0 100644 --- a/code/redalert/tileset.cpp +++ b/code/redalert/tileset.cpp @@ -267,8 +267,9 @@ void __cdecl Buffer_Draw_Stamp_Clip2(GraphicViewPortClass& viewport, const void // src += IconWidth; //} - if (iconImage->HouseImages[0].image[icon_index] == 0) - return; + if (iconImage->HouseImages[0].image[icon_index][0] == 0) { + icon_index = 0; + } GL_SetClipRect(xstart, ystart, blit_width, blit_height); GL_RenderImage(iconImage, xstart, ystart, blit_width, blit_height, 0, icon_index);