Skip to content

Commit ea06e0c

Browse files
committed
Merge branch 'optionsmenuworking!' into main
2 parents 2e0bc98 + fdba69f commit ea06e0c

17 files changed

Lines changed: 390 additions & 79 deletions

File tree

Core/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -435,23 +435,30 @@ void Win32Mouse::capture()
435435
{
436436

437437
RECT rect;
438-
::GetClientRect(ApplicationHWnd, &rect);
438+
if (TheGlobalData && TheGlobalData->m_windowed)
439+
{
440+
::GetWindowRect(ApplicationHWnd, &rect);
441+
}
442+
else
443+
{
444+
::GetClientRect(ApplicationHWnd, &rect);
439445

440-
POINT leftTop;
441-
leftTop.x = rect.left;
442-
leftTop.y = rect.top;
446+
POINT leftTop;
447+
leftTop.x = rect.left;
448+
leftTop.y = rect.top;
443449

444-
POINT rightBottom;
445-
rightBottom.x = rect.right;
446-
rightBottom.y = rect.bottom;
450+
POINT rightBottom;
451+
rightBottom.x = rect.right;
452+
rightBottom.y = rect.bottom;
447453

448-
::ClientToScreen(ApplicationHWnd, &leftTop);
449-
::ClientToScreen(ApplicationHWnd, &rightBottom);
454+
::ClientToScreen(ApplicationHWnd, &leftTop);
455+
::ClientToScreen(ApplicationHWnd, &rightBottom);
450456

451-
rect.left = leftTop.x;
452-
rect.top = leftTop.y;
453-
rect.right = rightBottom.x;
454-
rect.bottom = rightBottom.y;
457+
rect.left = leftTop.x;
458+
rect.top = leftTop.y;
459+
rect.right = rightBottom.x;
460+
rect.bottom = rightBottom.y;
461+
}
455462

456463
if (::ClipCursor(&rect))
457464
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class Shell : public SubsystemInterface
196196
WindowLayout *m_saveLoadMenuLayout; ///< save/load menu layout
197197
WindowLayout *m_popupReplayLayout; ///< replay save menu layout
198198
WindowLayout *m_optionsLayout; ///< options menu layout
199+
Bool m_isRecreatingLayouts;
199200

200201
};
201202

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static GameWindow *theWindow = nullptr;
9999
static AnimateWindowManager *theAnimateWindowManager = nullptr;
100100
static GameWindow *prevWindow = nullptr;
101101
static Bool useAnimation = FALSE;
102+
static ICoord2D g_lastTooltipOffset = { 0, 0 };
102103
void ControlBarPopupDescriptionUpdateFunc( WindowLayout *layout, void *param )
103104
{
104105
if(TheScriptEngine->isGameEnding())
@@ -558,7 +559,6 @@ void ControlBar::populateBuildTooltipLayout( const CommandButton *commandButton,
558559
{
559560

560561
static NameKeyType winNamekey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:BackgroundMarker" );
561-
static ICoord2D lastOffset = { 0, 0 };
562562

563563
ICoord2D size, newSize, pos;
564564
Int diffSize;
@@ -593,7 +593,7 @@ void ControlBar::populateBuildTooltipLayout( const CommandButton *commandButton,
593593
// heightChange = controlBarPos.y - m_defaultControlBarPosition.y;
594594

595595
GameWindow *marker = TheWindowManager->winGetWindowFromId(nullptr,winNamekey);
596-
static ICoord2D basePos;
596+
ICoord2D basePos;
597597
if(!marker)
598598
{
599599
return;
@@ -605,10 +605,10 @@ void ControlBar::populateBuildTooltipLayout( const CommandButton *commandButton,
605605
offset.x = curPos.x - basePos.x;
606606
offset.y = curPos.y - basePos.y;
607607

608-
parent->winSetPosition(pos.x, (pos.y - diffSize) + (offset.y - lastOffset.y));
608+
parent->winSetPosition(pos.x, (pos.y - diffSize) + (offset.y - g_lastTooltipOffset.y));
609609

610-
lastOffset.x = offset.x;
611-
lastOffset.y = offset.y;
610+
g_lastTooltipOffset.x = offset.x;
611+
g_lastTooltipOffset.y = offset.y;
612612

613613
win->winGetSize(&size.x, &size.y);
614614
win->winSetSize(size.x, size.y + diffSize);
@@ -633,6 +633,8 @@ void ControlBar::hideBuildTooltipLayout()
633633

634634
void ControlBar::deleteBuildTooltipLayout()
635635
{
636+
g_lastTooltipOffset.x = 0;
637+
g_lastTooltipOffset.y = 0;
636638
m_showBuildToolTipLayout = FALSE;
637639
prevWindow= nullptr;
638640
m_buildToolTipLayout->hide(TRUE);

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,6 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
13691369
if (comboBoxDetail)
13701370
comboBoxDetail->winEnable(FALSE);
13711371

1372-
if (comboBoxResolution)
1373-
comboBoxResolution->winEnable(FALSE);
1374-
13751372
if (textEntryFirewallPortOverride)
13761373
textEntryFirewallPortOverride->winEnable(FALSE);
13771374

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ static Bool isVisible = FALSE;
6565

6666
static GameWindow *quitConfirmationWindow = nullptr;
6767

68-
//external declarations of the Gadgets the callbacks can use
69-
static WindowLayout *saveLoadMenuLayout = nullptr;
68+
// Antigravity @bugfix 20/05/2026 Make saveLoadMenuLayout non-static for resolution recreation
69+
WindowLayout *saveLoadMenuLayout = nullptr;
7070

7171
static GameWindow *buttonRestartWin = nullptr;
7272
static GameWindow *buttonSaveLoadWin = nullptr;

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

Lines changed: 87 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#include "Common/RandomValue.h"
3434
#include "GameClient/Shell.h"
35+
#include "GameClient/InGameUI.h"
36+
#include "GameClient/GUICallbacks.h"
3537
#include "GameClient/WindowLayout.h"
3638
#include "GameClient/GameWindowManager.h"
3739
#include "GameClient/GameWindowTransitions.h"
@@ -85,6 +87,7 @@ void Shell::construct()
8587
m_popupReplayLayout = nullptr;
8688
m_optionsLayout = nullptr;
8789
m_screenCount = 0;
90+
m_isRecreatingLayouts = FALSE;
8891
}
8992

9093
//-------------------------------------------------------------------------------------------------
@@ -113,28 +116,30 @@ void Shell::deconstruct()
113116
// delete the save/load menu if present
114117
if( m_saveLoadMenuLayout )
115118
{
116-
117119
m_saveLoadMenuLayout->destroyWindows();
118120
deleteInstance(m_saveLoadMenuLayout);
119121
m_saveLoadMenuLayout = nullptr;
120122

123+
extern WindowLayout *saveLoadMenuLayout;
124+
saveLoadMenuLayout = nullptr;
121125
}
122126

123127
// delete the replay save menu if present
124128
if( m_popupReplayLayout )
125129
{
126-
127130
m_popupReplayLayout->destroyWindows();
128131
deleteInstance(m_popupReplayLayout);
129132
m_popupReplayLayout = nullptr;
130-
131133
}
132134

133135
// delete the options menu if present.
134136
if (m_optionsLayout != nullptr) {
135137
m_optionsLayout->destroyWindows();
136138
deleteInstance(m_optionsLayout);
137139
m_optionsLayout = nullptr;
140+
141+
extern WindowLayout *OptionsLayout;
142+
OptionsLayout = nullptr;
138143
}
139144
}
140145

@@ -231,7 +236,22 @@ namespace
231236
//-------------------------------------------------------------------------------------------------
232237
void Shell::recreateWindowLayouts()
233238
{
234-
// collect state of the current shell
239+
// 1. Query the states of Quit Menu, Options Layout, and Save/Load Layout BEFORE deconstruction
240+
Bool wasQuitVisible = TheInGameUI ? TheInGameUI->isQuitMenuVisible() : FALSE;
241+
Bool wasOptionsVisible = (m_optionsLayout != nullptr && !m_optionsLayout->isHidden());
242+
Bool wasSaveLoadVisible = (m_saveLoadMenuLayout != nullptr && !m_saveLoadMenuLayout->isHidden());
243+
244+
// Preserve shell active status and shell map state
245+
Bool wasShellActive = m_isShellActive;
246+
Bool wasShellMapOn = m_shellMapOn;
247+
248+
// If the quit menu was visible, we MUST destroy it cleanly so its static layouts are freed
249+
if (wasQuitVisible)
250+
{
251+
destroyQuitMenu();
252+
}
253+
254+
// collect state of the current shell
235255
const Int screenCount = getScreenCount();
236256
std::vector<ScreenInfo> screenStackInfos;
237257

@@ -247,21 +267,75 @@ void Shell::recreateWindowLayouts()
247267
}
248268
}
249269

270+
m_isRecreatingLayouts = TRUE;
271+
250272
// reconstruct the shell now
251273
deconstruct();
252274
construct();
253275
init();
254276

277+
m_isShellActive = wasShellActive;
278+
m_shellMapOn = wasShellMapOn;
279+
255280
// restore the screen stack
256281
Int screenIndex = 0;
257282
for (; screenIndex < screenCount; ++screenIndex)
258283
{
259284
const ScreenInfo& screenInfo = screenStackInfos[screenIndex];
260-
push(screenInfo.filename);
285+
286+
WindowLayout *newScreen = TheWindowManager->winCreateLayout( screenInfo.filename );
287+
DEBUG_ASSERTCRASH( newScreen != nullptr, ("Shell unable to load pending push layout") );
288+
289+
linkScreen( newScreen );
290+
291+
if (TheIMEManager)
292+
TheIMEManager->detach();
293+
294+
if (!screenInfo.isHidden)
295+
{
296+
newScreen->runInit( nullptr );
297+
newScreen->bringForward();
298+
}
299+
300+
newScreen->hide(screenInfo.isHidden);
301+
}
261302

262-
WindowLayout* layout = getScreenLayout(screenIndex);
263-
layout->hide(screenInfo.isHidden);
303+
// 3. Restore the standalone layouts if they were visible
304+
if (wasQuitVisible)
305+
{
306+
// ToggleQuitMenu will reload the .wnd layout and cleanly recreate the Quit Menu at the new resolution
307+
ToggleQuitMenu();
264308
}
309+
310+
if (wasOptionsVisible)
311+
{
312+
WindowLayout *optLayout = getOptionsLayout(TRUE);
313+
if (optLayout)
314+
{
315+
optLayout->runInit();
316+
optLayout->hide(FALSE);
317+
optLayout->bringForward();
318+
319+
extern WindowLayout *OptionsLayout;
320+
OptionsLayout = optLayout;
321+
}
322+
}
323+
324+
if (wasSaveLoadVisible)
325+
{
326+
WindowLayout *slLayout = getSaveLoadMenuLayout();
327+
if (slLayout)
328+
{
329+
slLayout->runInit();
330+
slLayout->hide(FALSE);
331+
slLayout->bringForward();
332+
333+
extern WindowLayout *saveLoadMenuLayout;
334+
saveLoadMenuLayout = slLayout;
335+
}
336+
}
337+
338+
m_isRecreatingLayouts = FALSE;
265339
}
266340

267341
//-------------------------------------------------------------------------------------------------
@@ -445,8 +519,11 @@ void Shell::popImmediate()
445519
m_pendingPop = FALSE;
446520

447521
// run the shutdown
448-
Bool immediatePop = TRUE;
449-
screen->runShutdown( &immediatePop );
522+
if (!m_isRecreatingLayouts)
523+
{
524+
Bool immediatePop = TRUE;
525+
screen->runShutdown( &immediatePop );
526+
}
450527

451528
// pop the screen of the stack
452529
doPop( FALSE );
@@ -702,7 +779,7 @@ void Shell::doPop( Bool impendingPush )
702779

703780
// run the init for the new top of the stack if present
704781
WindowLayout *newTop = top();
705-
if( newTop && !impendingPush )
782+
if( newTop && !impendingPush && !m_isRecreatingLayouts )
706783
{
707784
newTop->runInit( nullptr );
708785
//newTop->bringForward();

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5822,8 +5822,18 @@ void InGameUI::resetIdleWorker()
58225822

58235823
void InGameUI::recreateControlBar()
58245824
{
5825-
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd"));
5826-
deleteInstance(win);
5825+
Bool wasVisible = FALSE;
5826+
GameWindow *parent = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ControlBarParent"));
5827+
if (parent)
5828+
{
5829+
wasVisible = !parent->winIsHidden();
5830+
}
5831+
5832+
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ControlBarParent"));
5833+
if (win)
5834+
{
5835+
TheWindowManager->winDestroy(win);
5836+
}
58275837

58285838
m_idleWorkerWin = nullptr;
58295839

@@ -5832,6 +5842,17 @@ void InGameUI::recreateControlBar()
58325842
delete TheControlBar;
58335843
TheControlBar = NEW ControlBar;
58345844
TheControlBar->init();
5845+
5846+
if (ThePlayerList && ThePlayerList->getLocalPlayer())
5847+
{
5848+
TheControlBar->setControlBarSchemeByPlayer(ThePlayerList->getLocalPlayer());
5849+
TheControlBar->initSpecialPowershortcutBar(ThePlayerList->getLocalPlayer());
5850+
}
5851+
5852+
if (wasVisible)
5853+
{
5854+
ShowControlBar(TRUE);
5855+
}
58355856
}
58365857

58375858
void InGameUI::refreshCustomUiResources()

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void W3DPowerDraw( GameWindow *window, WinInstanceData *instData )
138138
window->winGetScreenPosition( &pos.x, &pos.y );
139139
window->winGetSize( &size.x, &size.y );
140140

141-
static Real pixelsPerInterval = size.x / TheGlobalData->m_powerBarIntervals;
141+
//Real pixelsPerInterval = size.x / TheGlobalData->m_powerBarIntervals;
142142
Int delta = TheGlobalData->m_powerBarYellowRange;
143143

144144
if((consumption > energy->getProduction() - delta) && (consumption <= energy->getProduction()))
@@ -297,7 +297,7 @@ void W3DPowerDrawA( GameWindow *window, WinInstanceData *instData )
297297
window->winGetScreenPosition( &pos.x, &pos.y );
298298
window->winGetSize( &size.x, &size.y );
299299

300-
static Real pixelsPerInterval = size.x / TheGlobalData->m_powerBarIntervals;
300+
//Real pixelsPerInterval = size.x / TheGlobalData->m_powerBarIntervals;
301301
Int delta = TheGlobalData->m_powerBarYellowRange;
302302

303303
if((consumption > energy->getProduction() - delta) && (consumption <= energy->getProduction()))
@@ -627,7 +627,7 @@ void W3DCommandBarBackgroundDraw( GameWindow *window, WinInstanceData *instData
627627
return;
628628
static NameKeyType winNamekey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:BackgroundMarker" );
629629
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr,winNamekey);
630-
static ICoord2D basePos;
630+
ICoord2D basePos;
631631
if(!win)
632632
{
633633
return;
@@ -652,7 +652,7 @@ void W3DCommandBarForegroundDraw( GameWindow *window, WinInstanceData *instData
652652

653653
static NameKeyType winNamekey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:BackgroundMarker" );
654654
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr,winNamekey);
655-
static ICoord2D basePos;
655+
ICoord2D basePos;
656656
if(!win)
657657
{
658658
return;

0 commit comments

Comments
 (0)