Skip to content

Commit

Permalink
Add UI Help Screen overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due authored and pull[bot] committed Jun 28, 2024
1 parent 2bf1ca8 commit 1029368
Show file tree
Hide file tree
Showing 7 changed files with 1,107 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ if(ENABLE_NLS)
find_package (Intl REQUIRED)
endif()

file(GLOB HEADERS "*.h" "3rdparty/*.h" "titleui/*.h" "hci/*.h" "input/*.h")
file(GLOB SRC "*.cpp" "3rdparty/*.cpp" "titleui/*.cpp" "hci/*.cpp" "input/*.cpp")
file(GLOB HEADERS "*.h" "3rdparty/*.h" "titleui/*.h" "hci/*.h" "input/*.h" "screens/*.h")
file(GLOB SRC "*.cpp" "3rdparty/*.cpp" "titleui/*.cpp" "hci/*.cpp" "input/*.cpp" "screens/*.cpp")

set(_additionalSourceFiles)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
Expand Down
6 changes: 6 additions & 0 deletions src/cheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ bool _attemptCheatCode(const char *cheat_name)
return true;
}

if (!strcasecmp("help", cheat_name))
{
intShowWidgetHelp();
return true;
}

const DebugInputManager& dbgInputManager = gInputManager.debugManager();
if (strcmp(cheat_name, "cheat on") == 0 || strcmp(cheat_name, "debug") == 0)
{
Expand Down
60 changes: 60 additions & 0 deletions src/hci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "lib/widget/bar.h"
#include "lib/widget/button.h"
#include "lib/widget/editbox.h"
#include "screens/helpscreen.h"
#include "cheat.h"
#include "console.h"
#include "design.h"
Expand Down Expand Up @@ -164,6 +165,7 @@ static bool Refreshing = false;

/* The widget screen */
std::shared_ptr<W_SCREEN> psWScreen = nullptr;
std::shared_ptr<W_HELP_OVERLAY_SCREEN> psUIHelpOverlayScreen = nullptr;

INTMODE intMode;

Expand Down Expand Up @@ -1979,6 +1981,64 @@ void intDisplayWidgets()
}
}

void intShowWidgetHelp()
{
ASSERT_OR_RETURN(, psWScreen != nullptr, "psWScreen is null?");

if (!psUIHelpOverlayScreen)
{
// Initialize the help overlay screen
psUIHelpOverlayScreen = W_HELP_OVERLAY_SCREEN::make(
// close handler
[](std::shared_ptr<W_HELP_OVERLAY_SCREEN>){
psUIHelpOverlayScreen.reset();

if (!bMultiPlayer || !NetPlay.bComms)
{
if (gamePaused())
{
// unpause game

/* Get it going again */
setGamePauseStatus(false);
setConsolePause(false);
setScriptPause(false);
setAudioPause(false);
setScrollPause(false);

/* And start the clock again */
gameTimeStart();
}
}
}
);
}

if (!bMultiPlayer || !NetPlay.bComms)
{
if (!gamePaused())
{
// pause game
setGamePauseStatus(true);
setConsolePause(true);
setScriptPause(true);
setAudioPause(true);
setScrollPause(true);

/* And stop the clock */
gameTimeStop();
}
}

psUIHelpOverlayScreen->setHelpFromWidgets(psWScreen->psForm);
widgRegisterOverlayScreenOnTopOfScreen(psUIHelpOverlayScreen, psWScreen);
}

bool intHelpOverlayIsUp()
{
return psUIHelpOverlayScreen != nullptr;
}

/* Tell the interface when the screen has been resized */
void intScreenSizeDidChange(int oldWidth, int oldHeight, int newWidth, int newHeight)
{
Expand Down
3 changes: 3 additions & 0 deletions src/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ INT_RETVAL intRunWidgets();
/* Display the widgets for the in game interface */
void intDisplayWidgets();

void intShowWidgetHelp();
bool intHelpOverlayIsUp();

/* Add the reticule widgets to the widget screen */
bool intAddReticule();
bool intShowGroupSelectionMenu();
Expand Down
2 changes: 1 addition & 1 deletion src/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static GAMECODE renderLoop()
displayRenderLoop();
}

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

0 comments on commit 1029368

Please sign in to comment.