Skip to content

Commit eccb0ce

Browse files
committed
Fix Main Menu Control Bar Glitch: Symmetrical zero-guard sibling window destruction and propagation
1 parent c3281c4 commit eccb0ce

4 files changed

Lines changed: 294 additions & 2 deletions

File tree

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

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,18 +510,43 @@ void ShowControlBar( Bool immediate )
510510
{
511511
TheControlBar->switchControlBarStage(CONTROL_BAR_STAGE_DEFAULT);
512512
TheControlBar->setScaledViewportHeight();
513-
513+
514514
if (TheControlBar->m_animateWindowManager && !immediate)
515515
{
516516
TheControlBar->m_animateWindowManager->reset();
517517
//TheControlBar->m_animateWindowManager->registerGameWindow(window, WIN_ANIMATION_SLIDE_BOTTOM_TIMED, TRUE, 1000, 0);
518518
TheControlBar->m_animateWindowManager->registerGameWindow(window, WIN_ANIMATION_SLIDE_BOTTOM, TRUE, 500, 0);
519519
TheControlBar->animateSpecialPowerShortcut(TRUE);
520520
}
521-
521+
522522
window->winHide(FALSE);
523523
}
524524

525+
const char* siblingNames[] = {
526+
"ControlBar.wnd:RightHUD",
527+
"ControlBar.wnd:WinUnitSelected",
528+
"ControlBar.wnd:CameoWindow",
529+
"ControlBar.wnd:PopupCommunicator",
530+
"ControlBar.wnd:ButtonOptions",
531+
"ControlBar.wnd:ButtonIdleWorker",
532+
"ControlBar.wnd:ButtonPlaceBeacon",
533+
"ControlBar.wnd:ButtonGeneral",
534+
"ControlBar.wnd:ButtonLarge",
535+
"ControlBar.wnd:PowerWindow",
536+
"ControlBar.wnd:MoneyDisplay",
537+
"ControlBar.wnd:GeneralsExp",
538+
"ControlBar.wnd:WinUAttack",
539+
"ControlBar.wnd:BackgroundMarker"
540+
};
541+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
542+
{
543+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
544+
if (sibling)
545+
{
546+
sibling->winHide(FALSE);
547+
}
548+
}
549+
525550
// We want to get everything recalced since this is a major state change.
526551
TheControlBar->markUIDirty();
527552
}
@@ -554,6 +579,38 @@ void HideControlBar( Bool immediate )
554579
}
555580
}
556581

582+
const char* siblingNames[] = {
583+
"ControlBar.wnd:RightHUD",
584+
"ControlBar.wnd:WinUnitSelected",
585+
"ControlBar.wnd:CameoWindow",
586+
"ControlBar.wnd:PopupCommunicator",
587+
"ControlBar.wnd:ButtonOptions",
588+
"ControlBar.wnd:ButtonIdleWorker",
589+
"ControlBar.wnd:ButtonPlaceBeacon",
590+
"ControlBar.wnd:ButtonGeneral",
591+
"ControlBar.wnd:ButtonLarge",
592+
"ControlBar.wnd:PowerWindow",
593+
"ControlBar.wnd:MoneyDisplay",
594+
"ControlBar.wnd:GeneralsExp",
595+
"ControlBar.wnd:WinUAttack",
596+
"ControlBar.wnd:BackgroundMarker",
597+
"ControlBar.wnd:UnderConstructionWindow",
598+
"ControlBar.wnd:OCLTimerWindow",
599+
"ControlBar.wnd:BeaconWindow",
600+
"ControlBar.wnd:CommandWindow",
601+
"ControlBar.wnd:ProductionQueueWindow",
602+
"ControlBar.wnd:ObserverPlayerListWindow",
603+
"ControlBar.wnd:ObserverPlayerInfoWindow"
604+
};
605+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
606+
{
607+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
608+
if (sibling)
609+
{
610+
sibling->winHide(TRUE);
611+
}
612+
}
613+
557614
if (TheControlBar->m_animateWindowManager && !immediate)
558615
{
559616
TheControlBar->m_animateWindowManager->reverseAnimateWindow();
@@ -595,12 +652,69 @@ void ToggleControlBar( Bool immediate )
595652
TheControlBar->m_animateWindowManager->registerGameWindow(window, WIN_ANIMATION_SLIDE_BOTTOM, TRUE, 500, 0);
596653
TheControlBar->animateSpecialPowerShortcut(TRUE);
597654
}
655+
656+
const char* siblingNames[] = {
657+
"ControlBar.wnd:RightHUD",
658+
"ControlBar.wnd:WinUnitSelected",
659+
"ControlBar.wnd:CameoWindow",
660+
"ControlBar.wnd:PopupCommunicator",
661+
"ControlBar.wnd:ButtonOptions",
662+
"ControlBar.wnd:ButtonIdleWorker",
663+
"ControlBar.wnd:ButtonPlaceBeacon",
664+
"ControlBar.wnd:ButtonGeneral",
665+
"ControlBar.wnd:ButtonLarge",
666+
"ControlBar.wnd:PowerWindow",
667+
"ControlBar.wnd:MoneyDisplay",
668+
"ControlBar.wnd:GeneralsExp",
669+
"ControlBar.wnd:WinUAttack",
670+
"ControlBar.wnd:BackgroundMarker"
671+
};
672+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
673+
{
674+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
675+
if (sibling)
676+
{
677+
sibling->winHide(FALSE);
678+
}
679+
}
598680
}
599681
else
600682
{
601683
TheControlBar->hideSpecialPowerShortcut();
602684
TheControlBar->setFullViewportHeight();
603685
window->winHide(TRUE);
686+
687+
const char* siblingNames[] = {
688+
"ControlBar.wnd:RightHUD",
689+
"ControlBar.wnd:WinUnitSelected",
690+
"ControlBar.wnd:CameoWindow",
691+
"ControlBar.wnd:PopupCommunicator",
692+
"ControlBar.wnd:ButtonOptions",
693+
"ControlBar.wnd:ButtonIdleWorker",
694+
"ControlBar.wnd:ButtonPlaceBeacon",
695+
"ControlBar.wnd:ButtonGeneral",
696+
"ControlBar.wnd:ButtonLarge",
697+
"ControlBar.wnd:PowerWindow",
698+
"ControlBar.wnd:MoneyDisplay",
699+
"ControlBar.wnd:GeneralsExp",
700+
"ControlBar.wnd:WinUAttack",
701+
"ControlBar.wnd:BackgroundMarker",
702+
"ControlBar.wnd:UnderConstructionWindow",
703+
"ControlBar.wnd:OCLTimerWindow",
704+
"ControlBar.wnd:BeaconWindow",
705+
"ControlBar.wnd:CommandWindow",
706+
"ControlBar.wnd:ProductionQueueWindow",
707+
"ControlBar.wnd:ObserverPlayerListWindow",
708+
"ControlBar.wnd:ObserverPlayerInfoWindow"
709+
};
710+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
711+
{
712+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
713+
if (sibling)
714+
{
715+
sibling->winHide(TRUE);
716+
}
717+
}
604718
}
605719
}
606720
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5830,6 +5830,38 @@ void InGameUI::recreateControlBar()
58305830
TheWindowManager->winDestroy(parent);
58315831
}
58325832

5833+
const char* siblingNames[] = {
5834+
"ControlBar.wnd:RightHUD",
5835+
"ControlBar.wnd:WinUnitSelected",
5836+
"ControlBar.wnd:CameoWindow",
5837+
"ControlBar.wnd:PopupCommunicator",
5838+
"ControlBar.wnd:ButtonOptions",
5839+
"ControlBar.wnd:ButtonIdleWorker",
5840+
"ControlBar.wnd:ButtonPlaceBeacon",
5841+
"ControlBar.wnd:ButtonGeneral",
5842+
"ControlBar.wnd:ButtonLarge",
5843+
"ControlBar.wnd:PowerWindow",
5844+
"ControlBar.wnd:MoneyDisplay",
5845+
"ControlBar.wnd:GeneralsExp",
5846+
"ControlBar.wnd:WinUAttack",
5847+
"ControlBar.wnd:BackgroundMarker",
5848+
"ControlBar.wnd:UnderConstructionWindow",
5849+
"ControlBar.wnd:OCLTimerWindow",
5850+
"ControlBar.wnd:BeaconWindow",
5851+
"ControlBar.wnd:CommandWindow",
5852+
"ControlBar.wnd:ProductionQueueWindow",
5853+
"ControlBar.wnd:ObserverPlayerListWindow",
5854+
"ControlBar.wnd:ObserverPlayerInfoWindow"
5855+
};
5856+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
5857+
{
5858+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
5859+
if (sibling)
5860+
{
5861+
TheWindowManager->winDestroy(sibling);
5862+
}
5863+
}
5864+
58335865
m_idleWorkerWin = nullptr;
58345866

58355867
createControlBar();

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

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,31 @@ void ShowControlBar( Bool immediate )
521521
window->winHide(FALSE);
522522
}
523523

524+
const char* siblingNames[] = {
525+
"ControlBar.wnd:RightHUD",
526+
"ControlBar.wnd:WinUnitSelected",
527+
"ControlBar.wnd:CameoWindow",
528+
"ControlBar.wnd:PopupCommunicator",
529+
"ControlBar.wnd:ButtonOptions",
530+
"ControlBar.wnd:ButtonIdleWorker",
531+
"ControlBar.wnd:ButtonPlaceBeacon",
532+
"ControlBar.wnd:ButtonGeneral",
533+
"ControlBar.wnd:ButtonLarge",
534+
"ControlBar.wnd:PowerWindow",
535+
"ControlBar.wnd:MoneyDisplay",
536+
"ControlBar.wnd:GeneralsExp",
537+
"ControlBar.wnd:WinUAttack",
538+
"ControlBar.wnd:BackgroundMarker"
539+
};
540+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
541+
{
542+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
543+
if (sibling)
544+
{
545+
sibling->winHide(FALSE);
546+
}
547+
}
548+
524549
// We want to get everything recalced since this is a major state change.
525550
TheControlBar->markUIDirty();
526551
}
@@ -553,6 +578,38 @@ void HideControlBar( Bool immediate )
553578
}
554579
}
555580

581+
const char* siblingNames[] = {
582+
"ControlBar.wnd:RightHUD",
583+
"ControlBar.wnd:WinUnitSelected",
584+
"ControlBar.wnd:CameoWindow",
585+
"ControlBar.wnd:PopupCommunicator",
586+
"ControlBar.wnd:ButtonOptions",
587+
"ControlBar.wnd:ButtonIdleWorker",
588+
"ControlBar.wnd:ButtonPlaceBeacon",
589+
"ControlBar.wnd:ButtonGeneral",
590+
"ControlBar.wnd:ButtonLarge",
591+
"ControlBar.wnd:PowerWindow",
592+
"ControlBar.wnd:MoneyDisplay",
593+
"ControlBar.wnd:GeneralsExp",
594+
"ControlBar.wnd:WinUAttack",
595+
"ControlBar.wnd:BackgroundMarker",
596+
"ControlBar.wnd:UnderConstructionWindow",
597+
"ControlBar.wnd:OCLTimerWindow",
598+
"ControlBar.wnd:BeaconWindow",
599+
"ControlBar.wnd:CommandWindow",
600+
"ControlBar.wnd:ProductionQueueWindow",
601+
"ControlBar.wnd:ObserverPlayerListWindow",
602+
"ControlBar.wnd:ObserverPlayerInfoWindow"
603+
};
604+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
605+
{
606+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
607+
if (sibling)
608+
{
609+
sibling->winHide(TRUE);
610+
}
611+
}
612+
556613
if (TheControlBar->m_animateWindowManager && !immediate)
557614
{
558615
TheControlBar->m_animateWindowManager->reverseAnimateWindow();
@@ -594,12 +651,69 @@ void ToggleControlBar( Bool immediate )
594651
TheControlBar->m_animateWindowManager->registerGameWindow(window, WIN_ANIMATION_SLIDE_BOTTOM, TRUE, 500, 0);
595652
TheControlBar->animateSpecialPowerShortcut(TRUE);
596653
}
654+
655+
const char* siblingNames[] = {
656+
"ControlBar.wnd:RightHUD",
657+
"ControlBar.wnd:WinUnitSelected",
658+
"ControlBar.wnd:CameoWindow",
659+
"ControlBar.wnd:PopupCommunicator",
660+
"ControlBar.wnd:ButtonOptions",
661+
"ControlBar.wnd:ButtonIdleWorker",
662+
"ControlBar.wnd:ButtonPlaceBeacon",
663+
"ControlBar.wnd:ButtonGeneral",
664+
"ControlBar.wnd:ButtonLarge",
665+
"ControlBar.wnd:PowerWindow",
666+
"ControlBar.wnd:MoneyDisplay",
667+
"ControlBar.wnd:GeneralsExp",
668+
"ControlBar.wnd:WinUAttack",
669+
"ControlBar.wnd:BackgroundMarker"
670+
};
671+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
672+
{
673+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
674+
if (sibling)
675+
{
676+
sibling->winHide(FALSE);
677+
}
678+
}
597679
}
598680
else
599681
{
600682
TheControlBar->hideSpecialPowerShortcut();
601683
TheControlBar->setFullViewportHeight();
602684
window->winHide(TRUE);
685+
686+
const char* siblingNames[] = {
687+
"ControlBar.wnd:RightHUD",
688+
"ControlBar.wnd:WinUnitSelected",
689+
"ControlBar.wnd:CameoWindow",
690+
"ControlBar.wnd:PopupCommunicator",
691+
"ControlBar.wnd:ButtonOptions",
692+
"ControlBar.wnd:ButtonIdleWorker",
693+
"ControlBar.wnd:ButtonPlaceBeacon",
694+
"ControlBar.wnd:ButtonGeneral",
695+
"ControlBar.wnd:ButtonLarge",
696+
"ControlBar.wnd:PowerWindow",
697+
"ControlBar.wnd:MoneyDisplay",
698+
"ControlBar.wnd:GeneralsExp",
699+
"ControlBar.wnd:WinUAttack",
700+
"ControlBar.wnd:BackgroundMarker",
701+
"ControlBar.wnd:UnderConstructionWindow",
702+
"ControlBar.wnd:OCLTimerWindow",
703+
"ControlBar.wnd:BeaconWindow",
704+
"ControlBar.wnd:CommandWindow",
705+
"ControlBar.wnd:ProductionQueueWindow",
706+
"ControlBar.wnd:ObserverPlayerListWindow",
707+
"ControlBar.wnd:ObserverPlayerInfoWindow"
708+
};
709+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
710+
{
711+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
712+
if (sibling)
713+
{
714+
sibling->winHide(TRUE);
715+
}
716+
}
603717
}
604718
}
605719
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6003,6 +6003,38 @@ void InGameUI::recreateControlBar()
60036003
TheWindowManager->winDestroy(parent);
60046004
}
60056005

6006+
const char* siblingNames[] = {
6007+
"ControlBar.wnd:RightHUD",
6008+
"ControlBar.wnd:WinUnitSelected",
6009+
"ControlBar.wnd:CameoWindow",
6010+
"ControlBar.wnd:PopupCommunicator",
6011+
"ControlBar.wnd:ButtonOptions",
6012+
"ControlBar.wnd:ButtonIdleWorker",
6013+
"ControlBar.wnd:ButtonPlaceBeacon",
6014+
"ControlBar.wnd:ButtonGeneral",
6015+
"ControlBar.wnd:ButtonLarge",
6016+
"ControlBar.wnd:PowerWindow",
6017+
"ControlBar.wnd:MoneyDisplay",
6018+
"ControlBar.wnd:GeneralsExp",
6019+
"ControlBar.wnd:WinUAttack",
6020+
"ControlBar.wnd:BackgroundMarker",
6021+
"ControlBar.wnd:UnderConstructionWindow",
6022+
"ControlBar.wnd:OCLTimerWindow",
6023+
"ControlBar.wnd:BeaconWindow",
6024+
"ControlBar.wnd:CommandWindow",
6025+
"ControlBar.wnd:ProductionQueueWindow",
6026+
"ControlBar.wnd:ObserverPlayerListWindow",
6027+
"ControlBar.wnd:ObserverPlayerInfoWindow"
6028+
};
6029+
for (int i = 0; i < sizeof(siblingNames)/sizeof(siblingNames[0]); ++i)
6030+
{
6031+
GameWindow *sibling = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(siblingNames[i]));
6032+
if (sibling)
6033+
{
6034+
TheWindowManager->winDestroy(sibling);
6035+
}
6036+
}
6037+
60066038
m_idleWorkerWin = nullptr;
60076039

60086040
createControlBar();

0 commit comments

Comments
 (0)