diff --git a/SCU01EA.INI b/SCU01EA.INI index 254704d..103b163 100644 --- a/SCU01EA.INI +++ b/SCU01EA.INI @@ -200,6 +200,7 @@ X=2 Y=13 Width=77 Height=66 +HomeCell=2742 [Waypoints] 98=8256 @@ -432,7 +433,6 @@ Height=66 13=Greece,2TNK,256,6320,0,Area Guard,None 14=Greece,2TNK,256,6449,0,Area Guard,None - [INFANTRY] 0=Greece,C1,256,5821,4,Area Guard,0,None 1=Greece,C2,256,5692,0,Guard,0,None diff --git a/code/redalert/display.cpp b/code/redalert/display.cpp index d27d87c..9a86871 100644 --- a/code/redalert/display.cpp +++ b/code/redalert/display.cpp @@ -567,16 +567,33 @@ void DisplayClass::Set_View_Dimensions(int x, int y, int width, int height) if (height == -1) height = SeenBuff.Get_Height(); TacLeptonHeight = Pixel_To_Lepton(height - y) * 4; + // Set our min/max viewport rectangle. + TacViewportRect.Clear(); + TacViewportRect.AddPoint(0, 0); // Top Corner + TacViewportRect.AddPoint(TacLeptonWidth, TacLeptonHeight / 4); + TacViewportRect.AddPoint(-TacLeptonWidth, TacLeptonHeight / 4); + TacViewportRect.AddPoint(0, TacLeptonHeight / 2); + { + int iso_x_offset = (ScreenWidth / 2); + int iso_y_offset = (ScreenWidth / 4); + TacViewportRect.X -= Pixel_To_Lepton(iso_x_offset); + TacViewportRect.Y -= Pixel_To_Lepton(iso_y_offset); + TacViewportRect.X2 -= Pixel_To_Lepton(iso_x_offset); + TacViewportRect.Y2 -= Pixel_To_Lepton(iso_y_offset); + } + /* ** Adjust the tactical cell if it is now in an invalid position ** because of the changed dimensions. */ +// jmarshall - todo, this was a great feature, if the designer clampped the map and the starting point was outside, this essentially fixed that. int xx = Coord_X(TacticalCoord) - (MapCellX * CELL_LEPTON_W); int yy = Coord_Y(TacticalCoord) - (MapCellY * CELL_LEPTON_H); - - Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, MapCellWidth * CELL_LEPTON_W, MapCellHeight * CELL_LEPTON_H); - + // + //Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, MapCellWidth * CELL_LEPTON_W, MapCellHeight * CELL_LEPTON_H); + // Set_Tactical_Position(XY_Coord(xx + (MapCellX * CELL_LEPTON_W), yy + (MapCellY * CELL_LEPTON_H))); +// jmarshall end TacPixelX = x; TacPixelY = y; @@ -1224,7 +1241,11 @@ bool DisplayClass::Scroll_Map(DirType facing, int & distance, bool really) */ int xx = (int)(short)Coord_X(coord) - (short)Cell_To_Lepton(MapCellX); int yy = (int)(short)Coord_Y(coord) - (short)Cell_To_Lepton(MapCellY); - bool shifted = Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, Cell_To_Lepton(MapCellWidth)*1.25, Cell_To_Lepton(MapCellHeight)*1.25); + if (!TacViewportRect.ContainsPoint(xx, yy)) { + return false; + } + + bool shifted = true; // Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, Cell_To_Lepton(MapCellWidth) * 1.25, Cell_To_Lepton(MapCellHeight) * 1.25); if (xx < 0) { xx = 0; shifted = true; @@ -4819,9 +4840,7 @@ void DisplayClass::Read_INI(CCINIClass & ini) ** Set the starting position (do this after Init(), which clears the cells' ** IsWaypoint flags). */ - if (Scen.Waypoint[WAYPT_HOME] == -1) { - Scen.Waypoint[WAYPT_HOME] = XY_Cell(MapCellX + 5*RESFACTOR, MapCellY + 4*RESFACTOR); - } + Scen.Waypoint[WAYPT_HOME] = ini.Get_Int(name, "HomeCell"); Scen.Views[0] = Scen.Views[1] = Scen.Views[2] = Scen.Views[3] = Scen.Waypoint[WAYPT_HOME]; Set_Tactical_Position(Cell_Coord((Scen.Waypoint[WAYPT_HOME] - (MAP_CELL_W * 4 * RESFACTOR)) - (5*RESFACTOR))); @@ -4889,6 +4908,7 @@ void DisplayClass::Write_INI(CCINIClass & ini) ini.Put_Int(NAME, "Y", MapCellY); ini.Put_Int(NAME, "Width", MapCellWidth); ini.Put_Int(NAME, "Height", MapCellHeight); + ini.Put_Int(NAME, "HomeCell", Scen.Waypoint[WAYPT_HOME]); /* ** Save the Waypoint entries. diff --git a/code/redalert/display.h b/code/redalert/display.h index e1cf10f..01d17c7 100644 --- a/code/redalert/display.h +++ b/code/redalert/display.h @@ -79,6 +79,8 @@ class DisplayClass: public MapClass LEPTON TacLeptonWidth; LEPTON TacLeptonHeight; + Rect TacViewportRect; + /* ** These layer control elements are used to group the displayable objects ** so that proper overlap can be obtained. diff --git a/code/redalert/externs.h b/code/redalert/externs.h index da7f00a..f6bdbf1 100644 --- a/code/redalert/externs.h +++ b/code/redalert/externs.h @@ -72,6 +72,7 @@ extern bool Debug_Flag; extern bool Debug_Lose; extern bool Debug_SkipBriefing; extern bool Debug_Map; +extern bool Debug_RenderEditorSplash; extern bool Debug_Win; extern bool Debug_Icon; extern bool Debug_Passable; diff --git a/code/redalert/globals.cpp b/code/redalert/globals.cpp index 1c04133..5d80730 100644 --- a/code/redalert/globals.cpp +++ b/code/redalert/globals.cpp @@ -44,6 +44,7 @@ bool Debug_Icon = false; bool Debug_Flag = true; bool Debug_Lose = false; bool Debug_SkipBriefing = false; +bool Debug_RenderEditorSplash = 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 203c383..ef0341a 100644 --- a/code/redalert/init.cpp +++ b/code/redalert/init.cpp @@ -1309,17 +1309,11 @@ bool Select_Game(bool fade) 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; + Debug_RenderEditorSplash = true; #else Theme.Fade_Out(); diff --git a/code/redalert/mapedit.cpp b/code/redalert/mapedit.cpp index 539337f..b5aad6b 100644 --- a/code/redalert/mapedit.cpp +++ b/code/redalert/mapedit.cpp @@ -1605,7 +1605,8 @@ void MapEditClass::Main_Menu(void) if (New_Scenario()==0) { Scen.CarryOverMoney = 0; Changed = 1; - } + Debug_RenderEditorSplash = false; + } process = false; break; @@ -1629,7 +1630,8 @@ void MapEditClass::Main_Menu(void) if (Load_Scenario()==0) { Scen.CarryOverMoney = 0; Changed = 0; - } + Debug_RenderEditorSplash = false; + } process = false; break; @@ -1637,8 +1639,11 @@ void MapEditClass::Main_Menu(void) ** Save scenario */ case 2: - if (Save_Scenario() == 0) { - Changed = 0; + if (!Debug_RenderEditorSplash) + { + if (Save_Scenario() == 0) { + Changed = 0; + } } process = false; break; diff --git a/code/redalert/mapedsel.cpp b/code/redalert/mapedsel.cpp index 829f83d..2cd3baa 100644 --- a/code/redalert/mapedsel.cpp +++ b/code/redalert/mapedsel.cpp @@ -77,6 +77,9 @@ int MapEditClass::Select_Object(void) ** Get cell for x,y */ cell = Click_Cell_Calc(x, y); + if(cell == -1) { + return -1; + } /* ** Convert x,y to offset from cell upper-left diff --git a/code/redalert/rect.cpp b/code/redalert/rect.cpp index d51f42a..beaf183 100644 --- a/code/redalert/rect.cpp +++ b/code/redalert/rect.cpp @@ -35,9 +35,9 @@ * Rect::Intersect -- Find the intersection between two rectangles. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - +#include "function.h" #include "rect.h" - +#include /*********************************************************************************************** * Rect::Rect -- Constructs a rectangle object. * @@ -168,6 +168,48 @@ Rect const Rect::Intersect(Rect const & rectangle, int * x, int * y) const return(r); } +void Rect::Clear(void) +{ + X = INT_MAX; + Y = INT_MAX; + X2 = -INT_MAX; + Y2 = -INT_MAX; + Width = INT_MAX; + Height = INT_MAX; +} + +void Rect::AddPoint(int xin, int yin) +{ + if(xin < X) { + X = xin; + } + if(xin > X2) { + X2 = xin; + } + if (yin < Y) { + Y = yin; + } + if (yin > Y2) { + Y2 = yin; + } + + Width = X2 - X; + Height = Y2 - Y; +} + +bool Rect::ContainsPoint(int x, int y) +{ + if (x < X || y < Y || x > X2 || y > Y2) { + return false; + } + return true; +} + +void Rect::AddIsoPoint(int x, int y) +{ + CellClass::ConvertCoordsToIsometric(x, y); + AddPoint(x, y); +} Rect const Union(Rect const & rect1, Rect const & rect2) { diff --git a/code/redalert/rect.h b/code/redalert/rect.h index 8f1a77b..222f974 100644 --- a/code/redalert/rect.h +++ b/code/redalert/rect.h @@ -61,14 +61,22 @@ class Rect bool Is_Valid(void) const; int Size(void) const {return(Width*Height);} + void Clear(void); + void AddPoint(int x, int y); + void AddIsoPoint(int x, int y); + bool ContainsPoint(int x, int y); // private: int X; int Y; + int X2; + int Y2; int Width; int Height; }; + + #endif diff --git a/code/redalert/sidebareditor.cpp b/code/redalert/sidebareditor.cpp index 9df29f0..dd24422 100644 --- a/code/redalert/sidebareditor.cpp +++ b/code/redalert/sidebareditor.cpp @@ -38,6 +38,12 @@ void SidebarEditor::draw_it(void) { ImGuiStyle& style = ImGui::GetStyle(); style.FramePadding = ImVec2(0, 0); + if (Debug_RenderEditorSplash) + { + static Image_t* edwinBackground = Image_LoadImage("ui/edwin/eng_edhi.png"); + GL_RenderImage(edwinBackground, 0, 0, ScreenWidth, ScreenHeight); + } + Debug_LockScroll = false; if (ImGui::BeginMainMenuBar()) { diff --git a/ui/edwin/eng_edhi.png b/ui/edwin/eng_edhi.png new file mode 100644 index 0000000..725e174 Binary files /dev/null and b/ui/edwin/eng_edhi.png differ