mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
Refactored scroll dimensions, fixed a crash were you would click on non existent tiles, editor now displays splash initially until you do new scenario or load a existing one.
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -1605,6 +1605,7 @@ void MapEditClass::Main_Menu(void)
|
||||
if (New_Scenario()==0) {
|
||||
Scen.CarryOverMoney = 0;
|
||||
Changed = 1;
|
||||
Debug_RenderEditorSplash = false;
|
||||
}
|
||||
process = false;
|
||||
break;
|
||||
@@ -1629,6 +1630,7 @@ void MapEditClass::Main_Menu(void)
|
||||
if (Load_Scenario()==0) {
|
||||
Scen.CarryOverMoney = 0;
|
||||
Changed = 0;
|
||||
Debug_RenderEditorSplash = false;
|
||||
}
|
||||
process = false;
|
||||
break;
|
||||
@@ -1637,9 +1639,12 @@ void MapEditClass::Main_Menu(void)
|
||||
** Save scenario
|
||||
*/
|
||||
case 2:
|
||||
if (!Debug_RenderEditorSplash)
|
||||
{
|
||||
if (Save_Scenario() == 0) {
|
||||
Changed = 0;
|
||||
}
|
||||
}
|
||||
process = false;
|
||||
break;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+44
-2
@@ -35,9 +35,9 @@
|
||||
* Rect::Intersect -- Find the intersection between two rectangles. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
#include "function.h"
|
||||
#include "rect.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/***********************************************************************************************
|
||||
* 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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 194 KiB |
Reference in New Issue
Block a user