From 96bc8e95ffd71d92239724e2c3fa4f22ac1ba8b5 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Tue, 23 Jun 2020 19:23:21 -0700 Subject: [PATCH 1/8] In editor builds the intro & sneak peak will open the scenario editor. --- DEFAULTMAP.INI | 57 ++++++++++++++++++++++++++++++++++++++ code/REDALERT/EXTERNS.H | 1 + code/REDALERT/GLOBALS.CPP | 1 + code/REDALERT/INIT.CPP | 31 ++++++++++++++++++++- code/REDALERT/MENUS.CPP | 7 ++++- code/REDALERT/SCENARIO.CPP | 38 +++++++++++++------------ code/REDALERT/VORTEX.CPP | 3 ++ 7 files changed, 119 insertions(+), 19 deletions(-) create mode 100644 DEFAULTMAP.INI diff --git a/DEFAULTMAP.INI b/DEFAULTMAP.INI new file mode 100644 index 0000000..7ed02f6 --- /dev/null +++ b/DEFAULTMAP.INI @@ -0,0 +1,57 @@ +[Basic] +Name=In the thick of it +Intro= +Brief= +Win= +Lose= +Action= +Player=Greece +Theme=No theme +CarryOverMoney=0 +ToCarryOver=no +ToInherit=no +TimerInherit=no +CivEvac=no +NewINIFormat=3 +CarryOverCap=0 +EndOfGame=no +NoSpyPlane=no +SkipScore=no +OneTimeOnly=no +SkipMapSelect=no +Official=yes +FillSilos=no +TruckCrate=no +Percent=0 + +[Map] +Theater=SNOW +X=49 +Y=49 +Width=30 +Height=30 + +[Waypoints] +98=8256 +99=8256 + +[MapPack] +1=BwAAIIH//v8f/4AHAAAggf/+/x//gAcAACCB//7/H/+ABwAAIIH//v8f/4AHAAAggQD+/x +2=8AgAcAACCBAP7/HwCA + +[Base] +Player=USSR +Count=0 + +[OverlayPack] +1=BwAAIIH//v8f/4AHAAAggf/+/x//gA== + +[Briefing] +1=Rescue Einstein from the Headquarters inside this Soviet complex. Once +2=found, evacuate him via the helicopter at the signal flare. Einstein and +3=Tanya must be kept alive at all costs. Beware the Soviet's Tesla Coils. +4=Direct Tanya to destroy the westmost power plants to take them off-line. + +[Digest] +1=bUa2F8EZhneJpy9AdS3S50JUrJE= + diff --git a/code/REDALERT/EXTERNS.H b/code/REDALERT/EXTERNS.H index 4f926cb..da7f00a 100644 --- a/code/REDALERT/EXTERNS.H +++ b/code/REDALERT/EXTERNS.H @@ -70,6 +70,7 @@ extern bool Debug_Cheat; extern bool Debug_Remap; extern bool Debug_Flag; extern bool Debug_Lose; +extern bool Debug_SkipBriefing; extern bool Debug_Map; extern bool Debug_Win; extern bool Debug_Icon; diff --git a/code/REDALERT/GLOBALS.CPP b/code/REDALERT/GLOBALS.CPP index 0728d89..1c04133 100644 --- a/code/REDALERT/GLOBALS.CPP +++ b/code/REDALERT/GLOBALS.CPP @@ -43,6 +43,7 @@ bool Debug_Remap = false; bool Debug_Icon = false; bool Debug_Flag = true; bool Debug_Lose = false; +bool Debug_SkipBriefing = false; bool Debug_Win = false; bool Debug_Map = false; // true = map editor mode bool Debug_Passable = false; // true = show passable/impassable terrain diff --git a/code/REDALERT/INIT.CPP b/code/REDALERT/INIT.CPP index 9146244..f596eb9 100644 --- a/code/REDALERT/INIT.CPP +++ b/code/REDALERT/INIT.CPP @@ -1294,6 +1294,34 @@ bool Select_Game(bool fade) ** Play a VQ */ case SEL_INTRO: +// jmarshall +#ifdef SCENARIO_EDITOR + Debug_Map = true; + Clear_Scenario(); + //Scen.Set_Scenario_Name(1, SCEN_PLAYER_SPAIN, SCEN_DIR_EAST, SCEN_VAR_A); + strcpy(Scen.ScenarioName, "DEFAULTMAP.INI"); + /* + ** Create houses + */ + for (HousesType house = HOUSE_FIRST; house < HOUSE_COUNT; house++) { + new HouseClass(house); + } + + PlayerPtr = HouseClass::As_Pointer(HOUSE_SPAIN); + PlayerPtr->IsHuman = true; + Base.House = HOUSE_USSR; + //LastHouse = HOUSE_GOOD; + Fill_In_Data(); + //Size_Map(-1, -1, 30, 30); + Scen.Waypoint[WAYPT_REINF] = XY_Cell(Map.MapCellX + Map.MapCellWidth / 2, Map.MapCellY + Map.MapCellHeight / 2); + Scen.Waypoint[WAYPT_HOME] = XY_Cell(Map.MapCellX + Map.MapCellWidth / 2, Map.MapCellY + Map.MapCellHeight / 2); +// (*this)[TacticalCoord].IsWaypoint = 1; + Map.Flag_Cell(Coord_Cell(Map.TacticalCoord)); + Map.Set_Tactical_Position(Cell_Coord(Scen.Waypoint[WAYPT_HOME] - (MAP_CELL_W * 4 * RESFACTOR) - (5 * RESFACTOR))); + Go_Editor(true); + process = false; + Debug_SkipBriefing = true; +#else Theme.Fade_Out(); if (Debug_Flag) { @@ -1313,7 +1341,8 @@ bool Select_Game(bool fade) display = true; fade = true; selection = SEL_NONE; - +#endif +// jmarshall end break; /* diff --git a/code/REDALERT/MENUS.CPP b/code/REDALERT/MENUS.CPP index a292a87..8a09c3f 100644 --- a/code/REDALERT/MENUS.CPP +++ b/code/REDALERT/MENUS.CPP @@ -549,8 +549,13 @@ int Main_Menu(unsigned long ) TextButtonClass multibtn(BUTTON_MULTI, TXT_MULTIPLAYER_GAME, TPF_BUTTON, d_button_x, d_button_y, d_button_w, d_button_h); d_button_y += d_button_dy; - +// jmarshall - Intro button is going to be the scenario editor button. +#ifdef SCENARIO_EDITOR + TextButtonClass introbtn(BUTTON_INTRO, "Scenario Editor", TPF_BUTTON, d_button_x, d_button_y, d_button_w, d_button_h); +#else TextButtonClass introbtn(BUTTON_INTRO, TXT_INTRO, TPF_BUTTON, d_button_x, d_button_y, d_button_w, d_button_h); +#endif +// jmarshall end d_button_y += d_button_dy; TextButtonClass exitbtn(BUTTON_EXIT, TXT_EXIT_GAME, TPF_BUTTON, d_button_x, d_button_y, d_button_w, d_button_h); diff --git a/code/REDALERT/SCENARIO.CPP b/code/REDALERT/SCENARIO.CPP index fa38995..b700ee3 100644 --- a/code/REDALERT/SCENARIO.CPP +++ b/code/REDALERT/SCENARIO.CPP @@ -399,26 +399,30 @@ bool Start_Scenario(char * name, bool briefing) /* ** If there's no briefing movie, restate the mission at the beginning. */ - char buffer[25]; - if (Scen.BriefMovie != VQ_NONE) { - sprintf(buffer, "%s.VQA", VQName[Scen.BriefMovie]); - } - if (Session.Type == GAME_NORMAL && ( Scen.BriefMovie == VQ_NONE || !CCFileClass(buffer).Is_Available() ) ) { - /* - ** Make sure the mouse is visible before showing the restatement. - */ - while(Get_Mouse_State()) { - Show_Mouse(); + if (!Debug_SkipBriefing) + { + char buffer[25]; + if (Scen.BriefMovie != VQ_NONE) { + sprintf(buffer, "%s.VQA", VQName[Scen.BriefMovie]); + } + if (Session.Type == GAME_NORMAL && (Scen.BriefMovie == VQ_NONE || !CCFileClass(buffer).Is_Available())) { + /* + ** Make sure the mouse is visible before showing the restatement. + */ + while (Get_Mouse_State()) { + Show_Mouse(); + } + Restate_Mission(Scen.ScenarioName, TXT_OK, TXT_NONE); } - Restate_Mission(Scen.ScenarioName, TXT_OK, TXT_NONE); - } - if (briefing) { - Hide_Mouse(); - VisiblePage.Clear(); - Show_Mouse(); - Play_Movie(Scen.ActionMovie, Scen.TransitTheme); + if (briefing) { + Hide_Mouse(); + VisiblePage.Clear(); + Show_Mouse(); + Play_Movie(Scen.ActionMovie, Scen.TransitTheme); + } } + Debug_SkipBriefing = false; if (Scen.TransitTheme == THEME_NONE) { Theme.Queue_Song(THEME_FIRST); diff --git a/code/REDALERT/VORTEX.CPP b/code/REDALERT/VORTEX.CPP index da3dbe9..259ad88 100644 --- a/code/REDALERT/VORTEX.CPP +++ b/code/REDALERT/VORTEX.CPP @@ -764,6 +764,9 @@ void ChronalVortexClass::Zap_Target (void) void ChronalVortexClass::Coordinate_Remap ( GraphicViewPortClass *inbuffer, int x, int y, int width, int height, unsigned char *remap_table) { unsigned char getx,gety, remap_color, pixel_color; +// jmarshall - todo fix ChronalVortexClass + return; +// jmarshall end BufferClass destbuf (width * height); From e76e8ed82842bcf965d3d42b30de8ea1bbc97249 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Tue, 23 Jun 2020 20:31:18 -0700 Subject: [PATCH 2/8] Right click mouse context menu in editor will close the editor menu if in root editor menu. Scenario Editor button workflow will no longer play music initially. Fixes to map placement dialog. --- code/REDALERT/MAPEDIT.CPP | 3 +++ code/REDALERT/MAPEDPLC.CPP | 7 +------ code/REDALERT/SCENARIO.CPP | 12 ++++++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/code/REDALERT/MAPEDIT.CPP b/code/REDALERT/MAPEDIT.CPP index ab87f0e..9752e61 100644 --- a/code/REDALERT/MAPEDIT.CPP +++ b/code/REDALERT/MAPEDIT.CPP @@ -1594,6 +1594,9 @@ void MapEditClass::Main_Menu(void) Show_Mouse(); if (UnknownKey==KN_ESC || g_globalKeyNumType == KN_RMOUSE) { +// jmarshall - consume the RMOUSE DOWN + Buttons->Input(); +// jmarshall end break; } diff --git a/code/REDALERT/MAPEDPLC.CPP b/code/REDALERT/MAPEDPLC.CPP index 6016eae..3a4931c 100644 --- a/code/REDALERT/MAPEDPLC.CPP +++ b/code/REDALERT/MAPEDPLC.CPP @@ -70,7 +70,7 @@ void ImGui_Placement_Editor(void) { ImGuiStyle& style = ImGui::GetStyle(); style.FramePadding = ImVec2(0, 0); ImGui::SetNextWindowSize(ImVec2(480, 220)); - ImGui::SetNextWindowPos(ImVec2(0, 150)); + ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::Begin("Place Object", &toolActive, ImGuiWindowFlags_AlwaysAutoResize /*| ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBackground*/); ImGui::Columns(3, "outer", true); ImGui::LabelText("Test", "Object Name"); @@ -429,8 +429,6 @@ int MapEditClass::Placement_Dialog(void) g_globalKeyFlags = 0; UserInput.Process_Input(); - Device_Present(); - /* ** Refresh display if needed */ @@ -442,9 +440,6 @@ int MapEditClass::Placement_Dialog(void) Hide_Mouse(); // Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H); // Draw_Caption(TXT_PLACE_OBJECT, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W); -// jmarshall - temp render a black background here so the tool works. - LogicPage->Fill_Rect(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_X + D_DIALOG_W, D_DIALOG_Y + D_DIALOG_H, 0); -// jamrshall end /* ** Display the current object: diff --git a/code/REDALERT/SCENARIO.CPP b/code/REDALERT/SCENARIO.CPP index b700ee3..aa6c41d 100644 --- a/code/REDALERT/SCENARIO.CPP +++ b/code/REDALERT/SCENARIO.CPP @@ -63,6 +63,7 @@ #ifdef WIN32 #include "tcpip.h" #include "ccdde.h" +#include "audiomix.h" extern bool SpawnedFromWChat; #endif @@ -421,12 +422,19 @@ bool Start_Scenario(char * name, bool briefing) Show_Mouse(); Play_Movie(Scen.ActionMovie, Scen.TransitTheme); } - } - Debug_SkipBriefing = false; + } if (Scen.TransitTheme == THEME_NONE) { Theme.Queue_Song(THEME_FIRST); } +// jmarshall + // If we are skipping the briefing, pausing the music(assuming in editor mode). + if (Debug_SkipBriefing) { + AudMix_SetMusicState(false); + } +// jmarshall end + + Debug_SkipBriefing = false; /* ** Set the options values, since the palette has been initialized by Read_Scenario From 61ca0cfa5aefce3af535b31bfee08421b459a13a Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Tue, 23 Jun 2020 20:44:47 -0700 Subject: [PATCH 3/8] Fixed a bug were black squares would render in the world after switching to a new level. --- code/REDALERT/TILESET.CPP | 9 ++++++++- code/REDALERT/WINSTUB.CPP | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/code/REDALERT/TILESET.CPP b/code/REDALERT/TILESET.CPP index 0929f67..f794d90 100644 --- a/code/REDALERT/TILESET.CPP +++ b/code/REDALERT/TILESET.CPP @@ -194,7 +194,7 @@ Image_t* Load_StampHD(int theater, const char* iconName, const void* icondata) { char filename[2048]; Image_t* image = NULL; - IconControlType* tileset = (IconControlType*)icondata; + IconControlType* tileset = (IconControlType*)icondata; if (!tileset) { return NULL; @@ -222,6 +222,13 @@ Image_t* Load_StampHD(int theater, const char* iconName, const void* icondata) { COM_SetExtension(filename, sizeof(filename), ".dds"); if (image == NULL) { + // If the image is already loaded, then we are done. + image = Find_Image(filename); + if (image) { + return image; + } + + // Load the initial terrain image. image = Image_LoadImage(filename); if (image != NULL && i != 0) { diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index ea0d42b..673b4b7 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -158,7 +158,19 @@ static bool Image_LoadFromCache(Image_t* image, const char* name, int houseid, i return true; } -static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int animid, int frameId, int64_t hash) { +static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int animid, int frameId, int64_t hash) { + // Don't load the image if its already loaded. + if (houseid == -1) { + if (image->HouseImages[0].image[animid][frameId] != 0) { + return true; + } + } + else { + if (image->HouseImages[houseid].image[animid][frameId] != 0) { + return true; + } + } + const char* generatedName = Image_GetGeneratedName(image, name, houseid, animid, frameId, hash); hash = generateHashValue(generatedName, strlen(generatedName)); From cc449351d25c37076a1a09d5ae737fc017720e88 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 24 Jun 2020 08:21:50 -0700 Subject: [PATCH 4/8] War Factory renders more correctly. --- code/REDALERT/BDATA.CPP | 110 ++++++++++++++++++++++--------------- code/REDALERT/BUILDING.CPP | 30 ++++++---- code/REDALERT/TYPE.H | 3 + 3 files changed, 89 insertions(+), 54 deletions(-) diff --git a/code/REDALERT/BDATA.CPP b/code/REDALERT/BDATA.CPP index 0c21468..d469bd9 100644 --- a/code/REDALERT/BDATA.CPP +++ b/code/REDALERT/BDATA.CPP @@ -2759,6 +2759,7 @@ static BuildingTypeClass const ClassLarva2( ); #endif void const * BuildingTypeClass::WarFactoryOverlay; +Image_t* BuildingTypeClass::WarFactoryHDOverlay; void const * LightningShapes; @@ -3034,6 +3035,47 @@ void BuildingTypeClass::Init_Heap(void) #endif } +Image_t* BuildingTypeClass::LoadHDImage(const char* fullname, int& numHDShapes) { + const char* imageFileName = Buildings_FindHDTexture(fullname, 0, 0); + Image_t* image = NULL; + + numHDShapes = -1; + + if (imageFileName) { + image = Image_LoadImage(imageFileName, true, true); + int numBuildingAnims = Buildings_GetNumFramesForTile(fullname, 0); + int shapeId = 1; + + // Load the old school animation pipeline. + { + while (true) { + imageFileName = Buildings_FindHDTexture(fullname, shapeId, 0); + if (imageFileName == NULL) + break; + + for (int d = 0; d < MAX_MPLAYER_COLORS; d++) { + Image_Add32BitImage(imageFileName, image, d, shapeId, 0); + } + shapeId++; + } + } + + if (numBuildingAnims > 0) + { + for (int i = 1; i < numBuildingAnims; i++) { + imageFileName = Buildings_FindHDTexture(fullname, 0, i); + for (int d = 0; d < MAX_MPLAYER_COLORS; d++) { + Image_Add32BitImage(imageFileName, image, d, 0, i); + } + } + } + image->numFrames = numBuildingAnims; + numHDShapes = shapeId; + } + + + return image; +} /*********************************************************************************************** * BuildingTypeClass::One_Time -- Performs special one time action for buildings. * @@ -3135,63 +3177,45 @@ void BuildingTypeClass::One_Time(void) building.Init_Anim(BSTATE_CONSTRUCTION, 0, count, timedelay); } + int numhdimages = 0; + /* ** Fetch the normal game shape for this building. */ _makepath(fullname, NULL, NULL, building.Graphic_Name(), ".SHP"); ((void const *&)building.ImageData) = MFCD::Retrieve(fullname); - { - const char* imageFileName = Buildings_FindHDTexture(fullname, 0, 0); + ((void const*&)building.HDImageData) = LoadHDImage(fullname, numhdimages); - if (imageFileName) { - Image_t *image = Image_LoadImage(imageFileName, true, true); - int numBuildingAnims = Buildings_GetNumFramesForTile(fullname, 0); - int shapeId = 1; + if (building.ImageData != NULL && building.HDImageData != NULL) { + int width = Get_Build_Frame_Width(building.ImageData); + int height = Get_Build_Frame_Height(building.ImageData); - // Load the old school animation pipeline. - { - while (true) { - imageFileName = Buildings_FindHDTexture(fullname, shapeId, 0); - if (imageFileName == NULL) - break; - - for (int d = 0; d < MAX_MPLAYER_COLORS; d++) { - Image_Add32BitImage(imageFileName, image, d, shapeId, 0); - } - shapeId++; - } - } - - if (numBuildingAnims > 0) - { - for (int i = 1; i < numBuildingAnims; i++) { - imageFileName = Buildings_FindHDTexture(fullname, 0, i); - for (int d = 0; d < MAX_MPLAYER_COLORS; d++) { - Image_Add32BitImage(imageFileName, image, d, 0, i); - } - } - } - image->numFrames = numBuildingAnims; - ((void const*&)building.HDImageData) = image; - - if (building.ImageData != NULL && building.HDImageData != NULL) { - int width = Get_Build_Frame_Width(building.ImageData); - int height = Get_Build_Frame_Height(building.ImageData); - - for (int d = 0; d < shapeId; d++) - { - building.HDImageData->renderwidth[d] = width; - building.HDImageData->renderheight[d] = height; - } - } - } + for (int d = 0; d < numhdimages; d++) + { + building.HDImageData->renderwidth[d] = width; + building.HDImageData->renderheight[d] = height; + } } } + int specialNumHDImages = 0; + // Try to load weap2.shp and tesla coil's lightning shapes char fullname[_MAX_FNAME+_MAX_EXT]; _makepath(fullname, NULL, NULL, (char const *)"WEAP2",".SHP"); WarFactoryOverlay = MFCD::Retrieve(fullname); + WarFactoryHDOverlay = LoadHDImage(fullname, specialNumHDImages); + if (WarFactoryOverlay != NULL && WarFactoryHDOverlay != NULL) { + int width = Get_Build_Frame_Width(WarFactoryOverlay); + int height = Get_Build_Frame_Height(WarFactoryOverlay); + + for (int d = 0; d < specialNumHDImages; d++) + { + WarFactoryHDOverlay->renderwidth[d] = width; + WarFactoryHDOverlay->renderheight[d] = height; + } + } + _makepath(fullname, NULL, NULL, (char const *)"LITNING",".SHP"); LightningShapes = MFCD::Retrieve(fullname); diff --git a/code/REDALERT/BUILDING.CPP b/code/REDALERT/BUILDING.CPP index bc3f005..db626c2 100644 --- a/code/REDALERT/BUILDING.CPP +++ b/code/REDALERT/BUILDING.CPP @@ -454,14 +454,8 @@ void BuildingClass::Draw_It(int x, int y, WindowNumberType window) const { assert(Buildings.ID(this) == ID); assert(IsActive); -// jmarshall + Image_t* hdimage = Get_HDImage_Data(); - if (hdimage != NULL) { - Techno_Draw_Object_HD(hdimage, Shape_Number(), x, y, window); - TechnoClass::Draw_It(x, y, window); - return; - } -// jmarshall end /* ** The shape file to use for rendering depends on whether the building @@ -474,7 +468,14 @@ void BuildingClass::Draw_It(int x, int y, WindowNumberType window) const ** Actually draw the building shape. */ IsTheaterShape = Class->IsTheater; //Let Build_Frame know if this is a theater specific shape - Techno_Draw_Object(shapefile, Shape_Number(), x, y, window); +// jmarshall - added HD support + if (hdimage != NULL) { + Techno_Draw_Object_HD(hdimage, Shape_Number(), x, y, window); + } + else { + Techno_Draw_Object(shapefile, Shape_Number(), x, y, window); + } +// jmarshall end IsTheaterShape = false; /* @@ -504,9 +505,16 @@ void BuildingClass::Draw_It(int x, int y, WindowNumberType window) const if ( (*this == STRUCT_WEAP || *this == STRUCT_FAKEWEAP)) { int shapenum = Door_Stage(); if (Health_Ratio() <= Rule.ConditionYellow) shapenum += 4; - // Added override shape file name. ST - 8/1/2019 5:24PM - //Techno_Draw_Object(Class->WarFactoryOverlay, shapenum, x, y, window); - Techno_Draw_Object_Virtual(Class->WarFactoryOverlay, shapenum, x, y, window, DIR_N, 0x0100, "WEAP2"); +// jmarshall - added HD support. + if (Class->WarFactoryHDOverlay) + { + Techno_Draw_Object_HD(Class->WarFactoryHDOverlay, shapenum, x, y, window, DIR_N, 0x0100); + } + else + { + Techno_Draw_Object_Virtual(Class->WarFactoryOverlay, shapenum, x, y, window, DIR_N, 0x0100, "WEAP2"); + } +// jmarshall end } /* diff --git a/code/REDALERT/TYPE.H b/code/REDALERT/TYPE.H index 8b06c6e..ff20c13 100644 --- a/code/REDALERT/TYPE.H +++ b/code/REDALERT/TYPE.H @@ -41,6 +41,7 @@ class MapEditClass; class HouseClass; class WeaponTypeClass; +struct Image_t; /*************************************************************************** ** This is the abstract type class. It holds information common to all @@ -815,6 +816,7 @@ class BuildingTypeClass : public TechnoTypeClass { ** Special overlay for the weapons factory. */ static void const * WarFactoryOverlay; + static Image_t* WarFactoryHDOverlay; private: @@ -839,6 +841,7 @@ class BuildingTypeClass : public TechnoTypeClass { void const * BuildupData; void Init_Anim(BStateType state, int start, int count, int rate) const; + static Image_t* LoadHDImage(const char* fullname, int &numHDShapes); }; From 1f534ed2690000d6d5b88a206744706e8688a943 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 24 Jun 2020 09:39:47 -0700 Subject: [PATCH 5/8] Moved NEWBLIT to imgui background cmdlist, console now renders again. Level now draws in editor mode dialogs. --- code/REDALERT/NEWBLIT.CPP | 16 ++++++++-------- code/REDALERT/WINSTUB.CPP | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/code/REDALERT/NEWBLIT.CPP b/code/REDALERT/NEWBLIT.CPP index 52633cd..6892b08 100644 --- a/code/REDALERT/NEWBLIT.CPP +++ b/code/REDALERT/NEWBLIT.CPP @@ -11,11 +11,11 @@ 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); + ImGui::GetBackgroundDrawList()->PushClipRect(mi, ma); } void GL_ResetClipRect(void) { - ImGui::GetForegroundDrawList()->PopClipRect(); + ImGui::GetBackgroundDrawList()->PopClipRect(); } void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap, int shapeId) { @@ -24,12 +24,12 @@ void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int col if (image->numFrames > 0) { if(image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames] == 0) - ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma); + ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma); else - ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames], mi, ma); + ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames], mi, ma); } else { - ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma); + ImGui::GetBackgroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma); } } @@ -40,7 +40,7 @@ void GL_FillRect(int color, int x, int y, int width, int height) { 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()->AddRectFilled(mi, ma, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1))); + ImGui::GetBackgroundDrawList()->AddRectFilled(mi, ma, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1))); } void GL_DrawText(int color, int x, int y, char* text) { @@ -51,7 +51,7 @@ void GL_DrawText(int color, int x, int y, char* text) { 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); + ImGui::GetBackgroundDrawList()->AddText(pos, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1)), text); } void GL_DrawLine(int color, int x, int y, int dx, int dy) { @@ -60,5 +60,5 @@ void GL_DrawLine(int color, int x, int y, int dx, int dy) { 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()->AddLine(pos, pos2, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1))); + ImGui::GetBackgroundDrawList()->AddLine(pos, pos2, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1))); } \ No newline at end of file diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index 673b4b7..4acc475 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -586,8 +586,9 @@ void Device_Present(void) { //ImGui::End(); // jmarshall end - if (Imgui_Dialog_Function) { - Imgui_Dialog_Function(); + if (Imgui_Dialog_Function) { + Map.Render(); + Imgui_Dialog_Function(); } if (renderConsole) { From 4ff7c5df989d7d0105097bc0b7fc12aaa60c777d Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 24 Jun 2020 11:23:57 -0700 Subject: [PATCH 6/8] Fixed a bug were mouse clicks flags were getting stomped when more then one click event was processed. --- code/REDALERT/io/UserInput.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/REDALERT/io/UserInput.cpp b/code/REDALERT/io/UserInput.cpp index 7c602f3..6d661bb 100644 --- a/code/REDALERT/io/UserInput.cpp +++ b/code/REDALERT/io/UserInput.cpp @@ -11,6 +11,8 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) Keyboard->MouseQX = Mouse.X; Keyboard->MouseQY = Mouse.Y; + flags = 0; + static SDL_Event event; memset(&event, 0, sizeof(SDL_Event)); @@ -51,7 +53,7 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_DOWN; key = KN_LMOUSE; - flags = GadgetClass::LEFTPRESS; + flags |= GadgetClass::LEFTPRESS; Keyboard->Put_Element(KN_LMOUSE); @@ -64,7 +66,7 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) Keyboard->Put_Element(KN_RMOUSE); key = KN_RMOUSE; - flags = GadgetClass::RIGHTPRESS; + flags |= GadgetClass::RIGHTPRESS; numFramesLMouse = 0; } @@ -74,13 +76,13 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) if (event.button.button == SDL_BUTTON_LEFT) { Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_RELEASE; - flags = GadgetClass::LEFTRELEASE; + flags |= GadgetClass::LEFTRELEASE; numFramesLMouse = 0; } else if (event.button.button == SDL_BUTTON_RIGHT) { Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_RELEASE; - flags = GadgetClass::RIGHTRELEASE; + flags |= GadgetClass::RIGHTRELEASE; numFramesLMouse = 0; } break; From e5a55f777e6340c1a472efe9a2ce75b41e2a373f Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 24 Jun 2020 12:10:08 -0700 Subject: [PATCH 7/8] Removed unneeded input consume, HD remaster images now work in the placement editor. --- code/REDALERT/MAPEDIT.CPP | 2 +- code/REDALERT/MAPEDPLC.CPP | 13 ++++++++++++- code/REDALERT/NEWBLIT.CPP | 16 ++++++++++++++++ code/REDALERT/NEWBLIT.H | 1 + 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/code/REDALERT/MAPEDIT.CPP b/code/REDALERT/MAPEDIT.CPP index 9752e61..7f3a478 100644 --- a/code/REDALERT/MAPEDIT.CPP +++ b/code/REDALERT/MAPEDIT.CPP @@ -1594,7 +1594,7 @@ void MapEditClass::Main_Menu(void) Show_Mouse(); if (UnknownKey==KN_ESC || g_globalKeyNumType == KN_RMOUSE) { -// jmarshall - consume the RMOUSE DOWN +// jmarshall - consume the RMOUSE DOWN so it doesn't bring up the context menu again. Buttons->Input(); // jmarshall end break; diff --git a/code/REDALERT/MAPEDPLC.CPP b/code/REDALERT/MAPEDPLC.CPP index 3a4931c..1c53cc3 100644 --- a/code/REDALERT/MAPEDPLC.CPP +++ b/code/REDALERT/MAPEDPLC.CPP @@ -454,9 +454,20 @@ 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); + //curobj->Display(WinW/2, WinH>>1, WINDOW_EDITOR, LastHouse); // 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(); + //} + + + /* ** Erase the grid */ diff --git a/code/REDALERT/NEWBLIT.CPP b/code/REDALERT/NEWBLIT.CPP index 6892b08..3917d16 100644 --- a/code/REDALERT/NEWBLIT.CPP +++ b/code/REDALERT/NEWBLIT.CPP @@ -34,6 +34,22 @@ void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int col } +void GL_RenderForeGroundImage(Image_t* image, int x, int y, int width, int height, int colorRemap, int shapeId) { + ImVec2 mi(x, y); + ImVec2 ma(x + width, y + height); + + if (image->numFrames > 0) { + if (image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames] == 0) + ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma); + else + ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][((int)animFrameNum) % image->numFrames], mi, ma); + } + else { + ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->HouseImages[colorRemap].image[shapeId][0], mi, ma); + } + +} + void GL_FillRect(int color, 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 36cab3a..4e0f57c 100644 --- a/code/REDALERT/NEWBLIT.H +++ b/code/REDALERT/NEWBLIT.H @@ -3,6 +3,7 @@ struct Image_t; void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap = 0, int shapeId = 0); +void GL_RenderForeGroundImage(Image_t* image, int x, int y, int width, int height, int colorRemap = 0, int shapeId = 0); 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); From 84bedab2759dff5846832b11780f11bb5e3c99c6 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 24 Jun 2020 19:53:54 -0700 Subject: [PATCH 8/8] HD Remaster Terrain tiles now go into the cache. --- code/REDALERT/TEXCACHE.CPP | 4 ++-- code/REDALERT/WINSTUB.CPP | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/code/REDALERT/TEXCACHE.CPP b/code/REDALERT/TEXCACHE.CPP index c4d8924..440d0da 100644 --- a/code/REDALERT/TEXCACHE.CPP +++ b/code/REDALERT/TEXCACHE.CPP @@ -4,8 +4,8 @@ #include "FUNCTION.H" #include "TEXCACHE.H" -#define CACHE_HEADER_FILENAME "cache/cache_header_v1.vhdr" -#define CACHE_DATA_FILERNAME "cache/cache_data_v1.vdata" +#define CACHE_HEADER_FILENAME "cache/cache_header_v2.vhdr" +#define CACHE_DATA_FILERNAME "cache/cache_data_v2.vdata" TexCache texCache; diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index 4acc475..35cb38e 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -176,7 +176,7 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int // Check to see if we can load a generated image first. // We only generate images that need a houseid - if (houseid >= 0) { + { if (Image_LoadFromCache(image, generatedName, houseid, animid, frameId, hash)) { return true; } @@ -191,10 +191,8 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int return false; } - bool swapBGR = false; if (strstr(name, ".TGA") || strstr(name, ".tga")) { iluFlipImage(); - swapBGR = true; } ILuint Width, Height, Bpp; @@ -213,18 +211,20 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int RenderTeamPalette(&Data[i * 4], *houseColors[houseid]); } } + else if (Bpp == 4) { + for (int i = 0; i < Width * Height; i++) { + byte b = Data[(i * 4) + 2]; + Data[(i * 4) + 2] = Data[(i * 4) + 0]; + Data[(i * 4) + 0] = b; + } + } GLuint texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); if (Bpp == 4) { - if (swapBGR) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, Data); - } - else { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data); - } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, Data); } else if (Bpp == 3) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Data); @@ -252,7 +252,7 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int //image->buffer[houseid][animid] = new unsigned char[Width * Height * Bpp]; //memcpy(image->buffer[houseid][animid], Data, Width * Height * Bpp); - if (Bpp == 4 && houseid >= 0) { + if (Bpp == 4) { texCache.AddImage(generatedName, Width, Height, Bpp, Data); Console_Printf("Writing %s to cache %s\n", image->name, name); Sleep(0);