Skip to content

Commit 9f0a55e

Browse files
authored
feat(controlbar): Implement full viewport support for 'Control Bar Pro' Addons (#1412)
Adds a -forcefullviewport command line argument and a ViewportHeightScale=0..1 field for GameData.ini
1 parent d2573a7 commit 9f0a55e

File tree

16 files changed

+123
-33
lines changed

16 files changed

+123
-33
lines changed

Generals/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class GlobalData : public SubsystemInterface
9191
Bool setTimeOfDay( TimeOfDay tod ); ///< Use this function to set the Time of day;
9292

9393
static void parseGameDataDefinition( INI* ini );
94+
void parseCustomDefinition();
9495

9596
//-----------------------------------------------------------------------------------------------
9697
struct TerrainLighting
@@ -178,6 +179,7 @@ class GlobalData : public SubsystemInterface
178179
Real m_skyBoxPositionZ;
179180
Real m_drawSkyBox;
180181
Real m_skyBoxScale;
182+
Real m_viewportHeightScale; // The height scale of the tactical view ranging 0..1. Used to hide the world behind the Control Bar.
181183
Real m_cameraPitch;
182184
Real m_cameraYaw;
183185
Real m_cameraHeight;

Generals/Code/GameEngine/Include/GameClient/ControlBar.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,9 @@ class ControlBar : public SubsystemInterface
690690
void showSpecialPowerShortcut( void );
691691
void hideSpecialPowerShortcut( void );
692692
void animateSpecialPowerShortcut( Bool isOn );
693-
693+
694+
void setFullViewportHeight();
695+
void setScaledViewportHeight();
694696

695697
/// set the control bar to the proper scheme based off a player template that's passed in
696698
ControlBarSchemeManager *getControlBarSchemeManager( void ) { return m_controlBarSchemeManager; }

Generals/Code/GameEngine/Source/Common/CommandLine.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ Int parseUseWaveEditor(char *args[], int num)
161161
return 1;
162162
}
163163

164+
//=============================================================================
165+
//=============================================================================
166+
Int parseFullViewport(char *args[], int num)
167+
{
168+
TheWritableGlobalData->m_viewportHeightScale = 1.0f;
169+
170+
return 1;
171+
}
172+
164173
#if defined(RTS_DEBUG)
165174

166175
//=============================================================================
@@ -1171,6 +1180,9 @@ static CommandLineParam paramsForEngineInit[] =
11711180
{ "-quickstart", parseQuickStart },
11721181
{ "-useWaveEditor", parseUseWaveEditor },
11731182

1183+
// TheSuperHackers @feature xezon 03/08/2025 Force full viewport for 'Control Bar Pro' Addons like GenTool did it.
1184+
{ "-forcefullviewport", parseFullViewport },
1185+
11741186
#if defined(RTS_DEBUG)
11751187
{ "-noaudio", parseNoAudio },
11761188
{ "-map", parseMapName },

Generals/Code/GameEngine/Source/Common/GameEngine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ void GameEngine::init()
364364

365365
DEBUG_ASSERTCRASH(TheWritableGlobalData,("TheWritableGlobalData expected to be created"));
366366
initSubsystem(TheWritableGlobalData, "TheWritableGlobalData", TheWritableGlobalData, &xferCRC, "Data\\INI\\Default\\GameData.ini", "Data\\INI\\GameData.ini");
367-
367+
TheWritableGlobalData->parseCustomDefinition();
368+
368369
// TheSuperHackers @bugfix helmutbuhler 14/04/2025
369370
// Pump messages during startup to ensure that the application window is correctly
370371
// positioned on slower computers and in debug builds by a later call to SetWindowPos.

Generals/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ GlobalData* GlobalData::m_theOriginal = NULL;
176176
{ "SkyBoxPositionZ", INI::parseReal, NULL, offsetof( GlobalData, m_skyBoxPositionZ ) },
177177
{ "SkyBoxScale", INI::parseReal, NULL, offsetof( GlobalData, m_skyBoxScale ) },
178178
{ "DrawSkyBox", INI::parseBool, NULL, offsetof( GlobalData, m_drawSkyBox ) },
179+
{ "ViewportHeightScale", INI::parseReal, NULL, offsetof( GlobalData, m_viewportHeightScale ) },
179180
{ "CameraPitch", INI::parseReal, NULL, offsetof( GlobalData, m_cameraPitch ) },
180181
{ "CameraYaw", INI::parseReal, NULL, offsetof( GlobalData, m_cameraYaw ) },
181182
{ "CameraHeight", INI::parseReal, NULL, offsetof( GlobalData, m_cameraHeight ) },
@@ -824,6 +825,8 @@ GlobalData::GlobalData()
824825

825826
m_particleEdit = FALSE;
826827

828+
m_viewportHeightScale = 0.80f; // Default value for the original Control Bar.
829+
827830
m_cameraPitch = 0.0f;
828831
m_cameraYaw = 0.0f;
829832
m_cameraHeight = 0.0f;
@@ -1193,6 +1196,22 @@ void GlobalData::parseGameDataDefinition( INI* ini )
11931196
TheWritableGlobalData->m_yResolution = yres;
11941197
}
11951198

1199+
void GlobalData::parseCustomDefinition()
1200+
{
1201+
{
1202+
// TheSuperHackers @feature xezon 03/08/2025 Force full viewport for 'Control Bar Pro' Addons like GenTool did it.
1203+
File* file = TheFileSystem->openFile("GenTool/fullviewport.dat", File::READ | File::BINARY);
1204+
if (file != NULL)
1205+
{
1206+
Char value = '0';
1207+
file->read(&value, 1);
1208+
if (value != '0')
1209+
{
1210+
m_viewportHeightScale = 1.0f;
1211+
}
1212+
}
1213+
}
1214+
}
11961215

11971216
UnsignedInt GlobalData::generateExeCRC()
11981217
{

Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,7 +3008,7 @@ void ControlBar::setDefaultControlBarConfig( void )
30083008
// m_controlBarSchemeManager->setControlBarSchemeByPlayerTemplate(ThePlayerList->getLocalPlayer()->getPlayerTemplate(), FALSE);
30093009
// }
30103010
m_currentControlBarStage = CONTROL_BAR_STAGE_DEFAULT;
3011-
TheTacticalView->setHeight((Int)(TheDisplay->getHeight() * 0.80f));
3011+
setScaledViewportHeight();
30123012
m_contextParent[ CP_MASTER ]->winSetPosition(m_defaultControlBarPosition.x, m_defaultControlBarPosition.y);
30133013
m_contextParent[ CP_MASTER ]->winHide(FALSE);
30143014
repopulateBuildTooltipLayout();
@@ -3025,7 +3025,7 @@ void ControlBar::setSquishedControlBarConfig( void )
30253025

30263026
// m_controlBarResizer->sizeWindowsAlt();
30273027
repopulateBuildTooltipLayout();
3028-
TheTacticalView->setHeight((Int)(TheDisplay->getHeight()));
3028+
setFullViewportHeight();
30293029
m_controlBarSchemeManager->setControlBarSchemeByPlayerTemplate(ThePlayerList->getLocalPlayer()->getPlayerTemplate(), TRUE);
30303030
}
30313031

@@ -3041,7 +3041,7 @@ void ControlBar::setLowControlBarConfig( void )
30413041
ICoord2D pos;
30423042
pos.x = m_defaultControlBarPosition.x;
30433043
pos.y = TheDisplay->getHeight() - .1 * TheDisplay->getHeight();
3044-
TheTacticalView->setHeight((Int)(TheDisplay->getHeight()));
3044+
setFullViewportHeight();
30453045
m_contextParent[ CP_MASTER ]->winSetPosition(pos.x, pos.y);
30463046
m_contextParent[ CP_MASTER ]->winHide(FALSE);
30473047
setUpDownImages();
@@ -3506,3 +3506,13 @@ void ControlBar::hideSpecialPowerShortcut( void )
35063506
m_specialPowerShortcutParent->winHide(TRUE);
35073507

35083508
}
3509+
3510+
void ControlBar::setFullViewportHeight()
3511+
{
3512+
TheTacticalView->setHeight(TheDisplay->getHeight());
3513+
}
3514+
3515+
void ControlBar::setScaledViewportHeight()
3516+
{
3517+
TheTacticalView->setHeight(TheDisplay->getHeight() * TheGlobalData->m_viewportHeightScale);
3518+
}

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ extern void toggleReplayControls( void );
501501
//-------------------------------------------------------------------------------------------------
502502
void ShowControlBar( Bool immediate )
503503
{
504-
if (!TheWindowManager || !TheControlBar || !TheTacticalView)
504+
if (!TheWindowManager || !TheControlBar)
505505
return;
506506

507507
showReplayControls();
@@ -514,7 +514,7 @@ void ShowControlBar( Bool immediate )
514514
if (window)
515515
{
516516
TheControlBar->switchControlBarStage(CONTROL_BAR_STAGE_DEFAULT);
517-
TheTacticalView->setHeight((Int)(TheDisplay->getHeight() * 0.80f));
517+
TheControlBar->setScaledViewportHeight();
518518

519519
if (TheControlBar->m_animateWindowManager && !immediate)
520520
{
@@ -536,7 +536,7 @@ void ShowControlBar( Bool immediate )
536536
//-------------------------------------------------------------------------------------------------
537537
void HideControlBar( Bool immediate )
538538
{
539-
if (!TheWindowManager || !TheControlBar || !TheTacticalView)
539+
if (!TheWindowManager || !TheControlBar)
540540
return;
541541

542542
hideReplayControls();
@@ -549,9 +549,9 @@ void HideControlBar( Bool immediate )
549549
if (window)
550550
{
551551
#ifdef SLIDE_LETTERBOX
552-
TheTacticalView->setHeight((Int)(TheDisplay->getHeight() * 0.80f));
552+
TheControlBar->setScaledViewportHeight();
553553
#else
554-
TheTacticalView->setHeight(TheDisplay->getHeight());
554+
TheControlBar->setFullViewportHeight();
555555
#endif
556556
if (immediate)
557557
{
@@ -574,7 +574,7 @@ void HideControlBar( Bool immediate )
574574
//-------------------------------------------------------------------------------------------------
575575
void ToggleControlBar( Bool immediate )
576576
{
577-
if (!TheWindowManager || !TheControlBar || !TheTacticalView)
577+
if (!TheWindowManager || !TheControlBar)
578578
return;
579579

580580
toggleReplayControls();
@@ -589,7 +589,7 @@ void ToggleControlBar( Bool immediate )
589589
TheControlBar->showSpecialPowerShortcut();
590590

591591
//now hidden, we're making it visible again so shrink viewport under the window
592-
TheTacticalView->setHeight((Int)(TheDisplay->getHeight() * 0.80f));
592+
TheControlBar->setScaledViewportHeight();
593593
window->winHide(FALSE);
594594
TheControlBar->switchControlBarStage(CONTROL_BAR_STAGE_DEFAULT);
595595

@@ -604,7 +604,7 @@ void ToggleControlBar( Bool immediate )
604604
else
605605
{
606606
TheControlBar->hideSpecialPowerShortcut();
607-
TheTacticalView->setHeight(TheDisplay->getHeight());
607+
TheControlBar->setFullViewportHeight();
608608
window->winHide(TRUE);
609609
}
610610
}

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,9 @@ void InGameUI::init( void )
11661166
TheTacticalView->init();
11671167
TheDisplay->attachView( TheTacticalView );
11681168

1169-
// make the tactical display the full screen width for now
1170-
TheTacticalView->setWidth( TheDisplay->getWidth());
1171-
// make the tactical display 0.76 of full screen so no drawing under GUI.
1172-
TheTacticalView->setHeight( TheDisplay->getHeight() * 0.77f);
1169+
// make the tactical display the full screen width and height
1170+
TheTacticalView->setWidth( TheDisplay->getWidth() );
1171+
TheTacticalView->setHeight( TheDisplay->getHeight() );
11731172
}
11741173
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
11751174

GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class GlobalData : public SubsystemInterface
9393
Bool setTimeOfDay( TimeOfDay tod ); ///< Use this function to set the Time of day;
9494

9595
static void parseGameDataDefinition( INI* ini );
96+
void parseCustomDefinition();
9697

9798
//-----------------------------------------------------------------------------------------------
9899
struct TerrainLighting
@@ -184,6 +185,7 @@ class GlobalData : public SubsystemInterface
184185
Real m_skyBoxPositionZ;
185186
Real m_drawSkyBox;
186187
Real m_skyBoxScale;
188+
Real m_viewportHeightScale; // The height scale of the tactical view ranging 0..1. Used to hide the world behind the Control Bar.
187189
Real m_cameraPitch;
188190
Real m_cameraYaw;
189191
Real m_cameraHeight;

GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,9 @@ class ControlBar : public SubsystemInterface
704704
void showSpecialPowerShortcut( void );
705705
void hideSpecialPowerShortcut( void );
706706
void animateSpecialPowerShortcut( Bool isOn );
707-
707+
708+
void setFullViewportHeight();
709+
void setScaledViewportHeight();
708710

709711
/// set the control bar to the proper scheme based off a player template that's passed in
710712
ControlBarSchemeManager *getControlBarSchemeManager( void ) { return m_controlBarSchemeManager; }

0 commit comments

Comments
 (0)