Skip to content

Commit 1029368

Browse files
past-duepull[bot]
authored andcommitted
Add UI Help Screen overlay
1 parent 2bf1ca8 commit 1029368

File tree

7 files changed

+1107
-3
lines changed

7 files changed

+1107
-3
lines changed

src/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ if(ENABLE_NLS)
6868
find_package (Intl REQUIRED)
6969
endif()
7070

71-
file(GLOB HEADERS "*.h" "3rdparty/*.h" "titleui/*.h" "hci/*.h" "input/*.h")
72-
file(GLOB SRC "*.cpp" "3rdparty/*.cpp" "titleui/*.cpp" "hci/*.cpp" "input/*.cpp")
71+
file(GLOB HEADERS "*.h" "3rdparty/*.h" "titleui/*.h" "hci/*.h" "input/*.h" "screens/*.h")
72+
file(GLOB SRC "*.cpp" "3rdparty/*.cpp" "titleui/*.cpp" "hci/*.cpp" "input/*.cpp" "screens/*.cpp")
7373

7474
set(_additionalSourceFiles)
7575
if(CMAKE_SYSTEM_NAME MATCHES "Windows")

src/cheat.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ bool _attemptCheatCode(const char *cheat_name)
116116
return true;
117117
}
118118

119+
if (!strcasecmp("help", cheat_name))
120+
{
121+
intShowWidgetHelp();
122+
return true;
123+
}
124+
119125
const DebugInputManager& dbgInputManager = gInputManager.debugManager();
120126
if (strcmp(cheat_name, "cheat on") == 0 || strcmp(cheat_name, "debug") == 0)
121127
{

src/hci.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "lib/widget/bar.h"
4848
#include "lib/widget/button.h"
4949
#include "lib/widget/editbox.h"
50+
#include "screens/helpscreen.h"
5051
#include "cheat.h"
5152
#include "console.h"
5253
#include "design.h"
@@ -164,6 +165,7 @@ static bool Refreshing = false;
164165

165166
/* The widget screen */
166167
std::shared_ptr<W_SCREEN> psWScreen = nullptr;
168+
std::shared_ptr<W_HELP_OVERLAY_SCREEN> psUIHelpOverlayScreen = nullptr;
167169

168170
INTMODE intMode;
169171

@@ -1979,6 +1981,64 @@ void intDisplayWidgets()
19791981
}
19801982
}
19811983

1984+
void intShowWidgetHelp()
1985+
{
1986+
ASSERT_OR_RETURN(, psWScreen != nullptr, "psWScreen is null?");
1987+
1988+
if (!psUIHelpOverlayScreen)
1989+
{
1990+
// Initialize the help overlay screen
1991+
psUIHelpOverlayScreen = W_HELP_OVERLAY_SCREEN::make(
1992+
// close handler
1993+
[](std::shared_ptr<W_HELP_OVERLAY_SCREEN>){
1994+
psUIHelpOverlayScreen.reset();
1995+
1996+
if (!bMultiPlayer || !NetPlay.bComms)
1997+
{
1998+
if (gamePaused())
1999+
{
2000+
// unpause game
2001+
2002+
/* Get it going again */
2003+
setGamePauseStatus(false);
2004+
setConsolePause(false);
2005+
setScriptPause(false);
2006+
setAudioPause(false);
2007+
setScrollPause(false);
2008+
2009+
/* And start the clock again */
2010+
gameTimeStart();
2011+
}
2012+
}
2013+
}
2014+
);
2015+
}
2016+
2017+
if (!bMultiPlayer || !NetPlay.bComms)
2018+
{
2019+
if (!gamePaused())
2020+
{
2021+
// pause game
2022+
setGamePauseStatus(true);
2023+
setConsolePause(true);
2024+
setScriptPause(true);
2025+
setAudioPause(true);
2026+
setScrollPause(true);
2027+
2028+
/* And stop the clock */
2029+
gameTimeStop();
2030+
}
2031+
}
2032+
2033+
psUIHelpOverlayScreen->setHelpFromWidgets(psWScreen->psForm);
2034+
widgRegisterOverlayScreenOnTopOfScreen(psUIHelpOverlayScreen, psWScreen);
2035+
}
2036+
2037+
bool intHelpOverlayIsUp()
2038+
{
2039+
return psUIHelpOverlayScreen != nullptr;
2040+
}
2041+
19822042
/* Tell the interface when the screen has been resized */
19832043
void intScreenSizeDidChange(int oldWidth, int oldHeight, int newWidth, int newHeight)
19842044
{

src/hci.h

+3
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ INT_RETVAL intRunWidgets();
289289
/* Display the widgets for the in game interface */
290290
void intDisplayWidgets();
291291

292+
void intShowWidgetHelp();
293+
bool intHelpOverlayIsUp();
294+
292295
/* Add the reticule widgets to the widget screen */
293296
bool intAddReticule();
294297
bool intShowGroupSelectionMenu();

src/loop.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static GAMECODE renderLoop()
222222
displayRenderLoop();
223223
}
224224

225-
if (InGameOpUp || isInGamePopupUp) // ingame options menu up, run it!
225+
if (InGameOpUp || isInGamePopupUp || intHelpOverlayIsUp()) // ingame options menu up, run it!
226226
{
227227
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
228228
unsigned widgval = triggers.empty() ? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.

0 commit comments

Comments
 (0)