Skip to content

Commit eedd803

Browse files
committed
Stopped game freezing after activity end
1 parent 40627c2 commit eedd803

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

Source/Main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ void PollSDLEvents() {
245245
/// Game menus loop.
246246
/// </summary>
247247
void RunMenuLoop() {
248+
g_MenuMan.SetIsInMenuScreen(true);
248249
g_UInputMan.DisableKeys(false);
249250
g_UInputMan.TrapMousePos(false);
250251

@@ -282,6 +283,8 @@ void RunMenuLoop() {
282283
g_WindowMan.GetScreenBuffer()->End();
283284
g_WindowMan.UploadFrame();
284285
}
286+
287+
g_MenuMan.SetIsInMenuScreen(false);
285288
}
286289

287290
/// <summary>

Source/Managers/MenuMan.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void MenuMan::Initialize(bool firstTimeInit) {
2929
m_GUIInput = std::make_unique<GUIInputWrapper>(-1, g_UInputMan.GetJoystickCount() > 0);
3030

3131
if (firstTimeInit) {
32+
m_IsInMenuScreen = false;
3233
g_LoadingScreen.Create(m_GUIScreen.get(), m_GUIInput.get(), g_SettingsMan.GetLoadingScreenProgressReportDisabled());
3334
}
3435

@@ -129,12 +130,6 @@ void MenuMan::HandleTransitionIntoMenuLoop() {
129130
}
130131

131132
bool MenuMan::Update() {
132-
// If we're in the menu but the activity isn't set as paused, then exit
133-
// This can mismatch sometimes like when loading a saved game
134-
if (m_ActiveMenu != ActiveMenu::MenusDisabled && !g_ActivityMan.ActivityPaused()) {
135-
return true;
136-
}
137-
138133
m_TitleScreen->Update();
139134
SetActiveMenu();
140135

Source/Managers/MenuMan.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ namespace RTE {
4444
void Draw() const;
4545
#pragma endregion
4646

47+
#pragma region Getters/Setters
48+
/// Checks if we're currently in a menu screen.
49+
/// @return True if in a menu screen; false otherwise.
50+
bool GetIsInMenuScreen() const { return m_IsInMenuScreen; }
51+
52+
/// Sets if we're currently in a menu screen.
53+
/// @param isInMenuScreen Whether we're in any menu screen.
54+
void SetIsInMenuScreen(bool isInMenuScreen) { m_IsInMenuScreen = isInMenuScreen; }
55+
#pragma endregion
56+
4757
private:
4858
/// Enumeration for the different menu screens that are active based on transition states.
4959
enum ActiveMenu {
@@ -54,6 +64,7 @@ namespace RTE {
5464
PauseMenuActive,
5565
};
5666

67+
bool m_IsInMenuScreen; //!< Whether we're currently in a menu screen.
5768
ActiveMenu m_ActiveMenu; //!< The currently active menu screen that is being updated and drawn. See ActiveMenu enumeration.
5869

5970
std::unique_ptr<GUIInputWrapper> m_GUIInput; //!< The GUIInput interface of this MenuMan.

Source/Managers/UInputMan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "ConsoleMan.h"
99
#include "PresetMan.h"
1010
#include "PerformanceMan.h"
11+
#include "MenuMan.h"
1112
#include "Icon.h"
1213
#include "GameActivity.h"
1314
#include "System.h"
@@ -1177,7 +1178,7 @@ void UInputMan::UpdateMouseInput() {
11771178
// The mouse cursor is visible and can move about the screen/window, but it should still be contained within the mouse player's part of the window
11781179
for (int player = PlayerOne; player < MaxPlayerCount; player++) {
11791180
if (m_ControlScheme[player].GetDevice() == InputDevice::DEVICE_MOUSE_KEYB) {
1180-
ForceMouseWithinPlayerScreen(g_ActivityMan.IsInActivity(), player);
1181+
ForceMouseWithinPlayerScreen(g_ActivityMan.IsInActivity() && !g_MenuMan.GetIsInMenuScreen(), player);
11811182
}
11821183
}
11831184
}

0 commit comments

Comments
 (0)