diff --git a/tiberiandawn/credits.cpp b/tiberiandawn/credits.cpp index b05b8371..977c84c5 100644 --- a/tiberiandawn/credits.cpp +++ b/tiberiandawn/credits.cpp @@ -79,7 +79,6 @@ CreditClass::CreditClass(void) * HISTORY: * * 03/13/1995 JLB : Created. * *=============================================================================================*/ -#define XX (320 - 120) #define WW 50 void CreditClass::Graphic_Logic(bool forced) { diff --git a/tiberiandawn/power.cpp b/tiberiandawn/power.cpp index 5a5ecc2c..001a1c21 100644 --- a/tiberiandawn/power.cpp +++ b/tiberiandawn/power.cpp @@ -110,6 +110,26 @@ void PowerClass::Init_Clear(void) PowerDir = 0; } +void PowerClass::Recalculate_Offsets(void) +{ + int factor = Get_Resolution_Factor(); + PowX = SeenBuff.Get_Width() - Map.RadWidth; + if (factor) { + PowY = Map.RadY + Map.RadHeight + (13 << factor) - 4; + } else { + PowY = Map.RadY + Map.RadHeight + (13 << factor); + } + PowWidth = 8 << factor; + PowHeight = SeenBuff.Get_Height() - PowY; + PowLineSpace = 5 << factor; + PowLineWidth = PowWidth - 4; + + PowerButton.X = PowX; + PowerButton.Y = PowY; + PowerButton.Width = PowWidth - 1; + PowerButton.Height = PowHeight; +} + /*********************************************************************************************** * PowerClass::One_Time -- One time processing for the power bar. * * * @@ -127,24 +147,9 @@ void PowerClass::Init_Clear(void) void PowerClass::One_Time(void) { RadarClass::One_Time(); + Recalculate_Offsets(); int factor = Get_Resolution_Factor(); - PowX = SeenBuff.Get_Width() - Map.RadWidth; - if (factor) { - PowY = Map.RadY + Map.RadHeight + (13 << factor) - 4; - } else { - PowY = Map.RadY + Map.RadHeight + (13 << factor); - } - PowWidth = 8 << factor; - PowHeight = SeenBuff.Get_Height() - PowY; - PowLineSpace = 5 << factor; - PowLineWidth = PowWidth - 4; - - PowerButton.X = PowX; - PowerButton.Y = PowY; - PowerButton.Width = PowWidth - 1; - PowerButton.Height = PowHeight; - PowerShape = MFCD::Retrieve((factor) ? "HPOWER.SHP" : "POWER.SHP"); PowerBarShape = Hires_Retrieve("PWRBAR.SHP"); } @@ -172,6 +177,7 @@ void PowerClass::Draw_It(bool complete) int factor = Get_Resolution_Factor(); if (complete || IsToRedraw) { + Recalculate_Offsets(); // PowX = TacPixelX + TacWidth*ICON_PIXEL_W; // X position of upper left corner of power bar. if (LogicPage->Lock()) { diff --git a/tiberiandawn/power.h b/tiberiandawn/power.h index 6a01524f..0f622eb5 100644 --- a/tiberiandawn/power.h +++ b/tiberiandawn/power.h @@ -103,6 +103,7 @@ class PowerClass : public RadarClass }; private: + void Recalculate_Offsets(void); int Power_Height(int value); unsigned IsActive : 1; diff --git a/tiberiandawn/radar.cpp b/tiberiandawn/radar.cpp index b0f40db0..8aacdb29 100644 --- a/tiberiandawn/radar.cpp +++ b/tiberiandawn/radar.cpp @@ -105,24 +105,7 @@ RadarClass::RadarClass(void) IsPlayerNames = false; } -/*********************************************************************************************** - * RadarClass::One_Time -- Handles one time processing for the radar map. * - * * - * This routine handles any one time processing required in order for the radar map to * - * function. This actually only requires an allocation of the radar staging buffer. This * - * buffer is needed for those cases where the radar area of the page is being destroyed * - * and it needs to be destroyed. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure to call this routine only ONCE. * - * * - * HISTORY: * - * 12/22/1994 JLB : Created. * - *=============================================================================================*/ -void RadarClass::One_Time(void) +void RadarClass::Recalculate_Offsets(void) { int factor = Get_Resolution_Factor(); RadWidth = 80 << factor; @@ -144,13 +127,35 @@ void RadarClass::One_Time(void) RadIHeight = 69 << factor; } - DisplayClass::One_Time(); RadarButton.X = RadX + RadOffX; RadarButton.Y = RadY + RadOffY; RadarButton.Width = RadIWidth; RadarButton.Height = RadIHeight; } +/*********************************************************************************************** + * RadarClass::One_Time -- Handles one time processing for the radar map. * + * * + * This routine handles any one time processing required in order for the radar map to * + * function. This actually only requires an allocation of the radar staging buffer. This * + * buffer is needed for those cases where the radar area of the page is being destroyed * + * and it needs to be destroyed. * + * * + * INPUT: none * + * * + * OUTPUT: none * + * * + * WARNINGS: Be sure to call this routine only ONCE. * + * * + * HISTORY: * + * 12/22/1994 JLB : Created. * + *=============================================================================================*/ +void RadarClass::One_Time(void) +{ + Recalculate_Offsets(); + DisplayClass::One_Time(); +} + /*********************************************************************************************** * RadarClass::Init_Clear -- Sets the radar map to a known state. * * * @@ -338,6 +343,8 @@ void RadarClass::Draw_It(bool forced) if (!forced && !IsToRedraw && !FullRedraw) return; + Recalculate_Offsets(); + static HousesType _house = HOUSE_NONE; if (PlayerPtr->ActLike != _house) { char name[_MAX_NAME + _MAX_EXT]; diff --git a/tiberiandawn/radar.h b/tiberiandawn/radar.h index d693e3f8..4e479471 100644 --- a/tiberiandawn/radar.h +++ b/tiberiandawn/radar.h @@ -186,6 +186,8 @@ class RadarClass : public DisplayClass static TacticalClass RadarButton; private: + void Recalculate_Offsets(void); + /* ** The current radar position as the upper left corner cell for the ** radar map display. The width and height is controlled by the diff --git a/tiberiandawn/sidebar.cpp b/tiberiandawn/sidebar.cpp index f76e29cd..ddabb015 100644 --- a/tiberiandawn/sidebar.cpp +++ b/tiberiandawn/sidebar.cpp @@ -153,24 +153,8 @@ SidebarClass::SidebarClass(void) new (&Column[1]) StripClass(InitClass()); } -/*********************************************************************************************** - * SidebarClass::One_Time -- Handles the one time game initializations. * - * * - * This routine is used to load the graphic data that is needed by the sidebar display. It * - * should only be called ONCE. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: Only call this routine once when the game first starts. * - * * - * HISTORY: * - * 10/28/94 JLB : Created. * - *=============================================================================================*/ -void SidebarClass::One_Time(void) +void SidebarClass::Recalculate_Offsets(void) { - PowerClass::One_Time(); /* ** Set up the pixel offsets and widths and heights used to render the ** sidebar. They are now variables because we need to change them for @@ -216,6 +200,50 @@ void SidebarClass::One_Time(void) Column[1].X = Column[0].X + (StripClass::STRIP_WIDTH * factor) + spacing - 1; Column[1].Y = SideY + TopHeight + 1; + if (Get_Resolution_Factor()) { + if (!Repair) + Repair = new ShapeButtonClass(); + if (!Upgrade) + Upgrade = new ShapeButtonClass(); + if (!Zoom) + Zoom = new ShapeButtonClass(); + Repair->X = SideX + 4; + Upgrade->X = SideX + 57; + Zoom->X = SideX + 110; + } else { + if (!Repair) + Repair = new TextButtonClass(); + if (!Upgrade) + Upgrade = new TextButtonClass(); + if (!Zoom) + Zoom = new TextButtonClass(); + Repair->X = SideX + 2; + Upgrade->X = Repair->X + Repair->Width + 2; + Zoom->X = Upgrade->X + Upgrade->Width + 2; + } +} + +/*********************************************************************************************** + * SidebarClass::One_Time -- Handles the one time game initializations. * + * * + * This routine is used to load the graphic data that is needed by the sidebar display. It * + * should only be called ONCE. * + * * + * INPUT: none * + * * + * OUTPUT: none * + * * + * WARNINGS: Only call this routine once when the game first starts. * + * * + * HISTORY: * + * 10/28/94 JLB : Created. * + *=============================================================================================*/ +void SidebarClass::One_Time(void) +{ + PowerClass::One_Time(); + + Recalculate_Offsets(); + Column[0].One_Time(0); Column[1].One_Time(1); @@ -341,17 +369,14 @@ void SidebarClass::Init_IO(void) ShapeButtonClass* SBCUpgrade = (ShapeButtonClass*)Upgrade; ShapeButtonClass* SBCZoom = (ShapeButtonClass*)Zoom; - Repair->X = 484; Repair->Y = 160; SBCRepair->ReflectButtonState = true; SBCRepair->Set_Shape(Hires_Retrieve(repair_shp)); - Upgrade->X = 480 + 57; Upgrade->Y = 160; SBCUpgrade->ReflectButtonState = true; SBCUpgrade->Set_Shape(Hires_Retrieve(sell_shp)); - Zoom->X = 480 + 110; Zoom->Y = 160; SBCZoom->Set_Shape(Hires_Retrieve(map_shp)); } else { @@ -368,17 +393,14 @@ void SidebarClass::Init_IO(void) TBCZoom->Set_Text("Map"); TBCZoom->Set_Style(TPF_6POINT | TPF_NOSHADOW | TPF_CENTER); - Repair->X = 242; Repair->Y = 80; Repair->Width = 32; Repair->Height = 9; - Upgrade->X = Repair->X + Repair->Width + 2; Upgrade->Y = Repair->Y; Upgrade->Width = 20; Upgrade->Height = Repair->Height; - Zoom->X = Upgrade->X + Upgrade->Width + 2; Zoom->Y = Upgrade->Y; Zoom->Width = 20; Zoom->Height = Upgrade->Height; @@ -766,6 +788,8 @@ void SidebarClass::Draw_It(bool complete) if (IsSidebarActive && (IsToRedraw || complete) && !Debug_Map) { IsToRedraw = false; + Recalculate_Offsets(); + if (LogicPage->Lock()) { /* ** Draw the outline box around the sidebar buttons. @@ -1225,6 +1249,14 @@ void SidebarClass::StripClass::Init_Clear(void) } } +void SidebarClass::StripClass::Recalculate_Offsets(void) +{ + for (int i = 0; i < COLUMNS; i++) { + UpButton[i].X = X + ButtonSpacingOffset + 1; + DownButton[i].X = UpButton[i].X + UpButton[i].Width + ButtonSpacingOffset - 2; + } +} + /*********************************************************************************************** * SidebarClass::StripClass::Init_IO -- Initializes the strip's buttons * * * @@ -1757,6 +1789,7 @@ bool SidebarClass::StripClass::AI(KeyNumType& input, int, int) void SidebarClass::StripClass::Draw_It(bool complete) { if (IsToRedraw || complete) { + Recalculate_Offsets(); IsToRedraw = false; int factor = Get_Resolution_Factor(); diff --git a/tiberiandawn/sidebar.h b/tiberiandawn/sidebar.h index b633a44e..ef9a3b76 100644 --- a/tiberiandawn/sidebar.h +++ b/tiberiandawn/sidebar.h @@ -367,6 +367,9 @@ class SidebarClass : public PowerClass */ static char ClockTranslucentTable[(1 + 1) * 256]; + private: + void Recalculate_Offsets(void); + } Column[COLUMNS]; /* @@ -408,6 +411,7 @@ class SidebarClass : public PowerClass static void const* SidebarShape2; private: + void Recalculate_Offsets(void); bool Activate_Repair(int control); bool Activate_Upgrade(int control); bool Activate_Demolish(int control); diff --git a/tiberiandawn/tab.cpp b/tiberiandawn/tab.cpp index d8d8a537..52c2d9fb 100644 --- a/tiberiandawn/tab.cpp +++ b/tiberiandawn/tab.cpp @@ -127,7 +127,7 @@ void TabClass::Draw_It(bool complete) void TabClass::Draw_Credits_Tab(void) { - unsigned x = Get_Resolution_Factor() ? 320 : 160; + unsigned x = SeenBuff.Get_Width() - (Get_Resolution_Factor() ? 320 : 160); CC_Draw_Shape(TabShape, 0, x, 0, WINDOW_MAIN, SHAPE_NORMAL); }