Skip to content

Commit 18d7286

Browse files
authored
Merge pull request #211 from cortex-command-community/misc-fixes
Miscellaneous Fixes
2 parents 18acd48 + 951e848 commit 18d7286

File tree

8 files changed

+45
-24
lines changed

8 files changed

+45
-24
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
237237
- Fixed the palette being mangled to 6bit/color on load.
238238

239239
- Fixed allegro not loading alpha of image with alpha by using SDL_image instead.
240+
240241
- Fixed `MOSprite:UnRotateOffset()` giving the wrong results on HFLipped sprites.
241242

242243
- Various fixes and improvements to inventory management when dual-wielding or carrying a shield, to stop situations where the actor unexpectedly puts their items away.
@@ -247,6 +248,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
247248

248249
- Fixed several issues with the way pie menus and aiming interacts between players, such as opening the pie menu always resetting the M&KB player's aim and pie selection, as well as another issue where the pie menu would fail to appear entirely for some players.
249250

251+
- Fixed an issue where pie menu selection could become unresponsive at low framerates.
252+
250253
- Fixed issue where scripts applied to `MovableObject`s could become disordered in certain circumstances.
251254

252255
- Fixed a minor inconsistency where `ACDropShip`s were frequently referred to as `ACDropship`s in Lua, the lower case 's' invalidating keywords where the typo occured.

Source/Entities/PieMenu.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,6 @@ void PieMenu::Update() {
541541
SetPos(affectedObjectAsActor ? affectedObjectAsActor->GetCPUPos() : m_AffectedObject->GetPos());
542542
}
543543

544-
if (m_MenuMode == MenuMode::Wobble) {
545-
UpdateWobbling();
546-
} else if (m_MenuMode == MenuMode::Freeze) {
547-
m_EnabledState = EnabledState::Enabling;
548-
} else if (m_EnabledState == EnabledState::Enabling || m_EnabledState == EnabledState::Disabling) {
549-
UpdateEnablingAndDisablingProgress();
550-
}
551-
552544
if (controller->IsDisabled()) {
553545
SetEnabled(false);
554546
return;
@@ -566,13 +558,16 @@ void PieMenu::Update() {
566558

567559
bool anyInput = false;
568560
bool skipInputBecauseActiveSubPieMenuWasJustDisabled = false;
561+
569562
if (m_ActiveSubPieMenu) {
570563
m_CursorAngle = m_HoveredPieSlice->GetMidAngle() + GetRotAngle();
571564
m_CursorInVisiblePosition = false;
572565
m_HoverTimer.Reset();
566+
573567
if (m_ActiveSubPieMenu->IsVisible()) {
574568
m_ActiveSubPieMenu->Update();
575569
}
570+
576571
if (!m_ActiveSubPieMenu->IsEnabled()) {
577572
m_ActivatedPieSlice = m_ActiveSubPieMenu->m_ActivatedPieSlice;
578573
Directions activeSubPieMenuDirection = m_ActiveSubPieMenu->m_DirectionIfSubPieMenu;
@@ -584,6 +579,7 @@ void PieMenu::Update() {
584579
m_CursorInVisiblePosition = true;
585580
} else {
586581
bool shouldClearHoveredSlice = controller->IsState(ControlState::PIE_MENU_ACTIVE_ANALOG);
582+
587583
// If a keyboard-only sub-PieMenu is exited by going off the sides, the parent PieMenu should handle input so the next PieSlice can be naturally stepped to.
588584
if (activeSubPieMenuDirection != Directions::None) {
589585
for (const auto& [controlState, controlStateDirection]: c_ControlStateDirections) {
@@ -593,13 +589,15 @@ void PieMenu::Update() {
593589
}
594590
}
595591
}
592+
596593
if (shouldClearHoveredSlice) {
597594
SetHoveredPieSlice(nullptr);
598595
skipInputBecauseActiveSubPieMenuWasJustDisabled = true;
599596
}
600597
}
601598
}
602599
}
600+
603601
if (!m_ActiveSubPieMenu && !skipInputBecauseActiveSubPieMenuWasJustDisabled) {
604602
if (controller->IsState(PIE_MENU_ACTIVE_ANALOG)) {
605603
anyInput = HandleAnalogInput(controller->GetAnalogCursor());
@@ -611,10 +609,6 @@ void PieMenu::Update() {
611609
if (anyInput) {
612610
m_HoverTimer.Reset();
613611
}
614-
615-
if (!IsSubPieMenu() && m_HoverTimer.IsPastRealTimeLimit()) {
616-
SetHoveredPieSlice(nullptr);
617-
}
618612
}
619613

620614
if (m_HoveredPieSlice && m_EnabledState != EnabledState::Disabled && !m_ActiveSubPieMenu) {
@@ -623,9 +617,21 @@ void PieMenu::Update() {
623617

624618
if (!IsSubPieMenu()) {
625619
SetEnabled(controller->IsState(ControlState::PIE_MENU_ACTIVE));
620+
621+
if (m_HoverTimer.IsPastRealTimeLimit()) {
622+
SetHoveredPieSlice(nullptr);
623+
}
626624
}
627625
}
628626

627+
if (m_MenuMode == MenuMode::Wobble) {
628+
UpdateWobbling();
629+
} else if (m_MenuMode == MenuMode::Freeze) {
630+
m_EnabledState = EnabledState::Enabling;
631+
} else if (m_EnabledState == EnabledState::Enabling || m_EnabledState == EnabledState::Disabling) {
632+
UpdateEnablingAndDisablingProgress();
633+
}
634+
629635
if (m_BGBitmapNeedsRedrawing && m_EnabledState != EnabledState::Disabled) {
630636
UpdatePredrawnMenuBackgroundBitmap();
631637
}

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: 3 additions & 3 deletions
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"
@@ -72,7 +73,6 @@ int UInputMan::Initialize() {
7273

7374
m_MouseStates[0] = {};
7475

75-
7676
int controllerIndex = 0;
7777
int joystickCount = 0;
7878
SDL_JoystickID* joysticks = SDL_GetGamepads(&joystickCount);
@@ -1049,7 +1049,7 @@ void UInputMan::EndFrame() {
10491049
}
10501050

10511051
m_TextInput.clear();
1052-
for (auto& [mouseID, mouse]: m_MouseStates) {
1052+
for (auto& [mouseID, mouse] : m_MouseStates) {
10531053
mouse.wheelChange = 0;
10541054
mouse.relativeMotion.Reset();
10551055
mouse.change.fill(false);
@@ -1178,7 +1178,7 @@ void UInputMan::UpdateMouseInput() {
11781178
// 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
11791179
for (int player = PlayerOne; player < MaxPlayerCount; player++) {
11801180
if (m_ControlScheme[player].GetDevice() == InputDevice::DEVICE_MOUSE_KEYB) {
1181-
ForceMouseWithinPlayerScreen(g_ActivityMan.IsInActivity(), player);
1181+
ForceMouseWithinPlayerScreen(g_ActivityMan.IsInActivity() && !g_MenuMan.GetIsInMenuScreen(), player);
11821182
}
11831183
}
11841184
}

Source/Menus/BuyMenuGUI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ void BuyMenuGUI::SetEnabled(bool enable) {
487487
g_UInputMan.SetMousePos(mousePos, m_pController->GetPlayer());
488488

489489
// Default focus to the menu button
490+
m_LastHoveredMouseIndex = 0;
490491
m_MenuFocus = OK;
491492
m_FocusChange = true;
492493
UpdateTotalCostLabel(m_pController->GetTeam());

Source/System/Controller.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,15 @@ void Controller::UpdatePlayerPieMenuInput(std::array<bool, ControlState::CONTROL
370370
}
371371

372372
// PIE MENU ACTIVE
373-
if (g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_ANALOG) || g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_DIGITAL)) {
373+
const bool activeAnalog = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_ANALOG) || g_UInputMan.ElementReleased(m_Player, InputElements::INPUT_PIEMENU_ANALOG);
374+
const bool activeDigital = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_DIGITAL) || g_UInputMan.ElementReleased(m_Player, InputElements::INPUT_PIEMENU_DIGITAL);
375+
if (activeAnalog || activeDigital) {
374376
if (m_ControlledActor && m_ControlledActor->GetPieMenu()->IsInNormalAnimationMode() && !m_ControlledActor->GetPieMenu()->IsVisible()) {
375377
m_ControlStates[ControlState::PIE_MENU_OPENED] = true;
376378
}
377379
m_ControlStates[ControlState::PIE_MENU_ACTIVE] = true;
378-
m_ControlStates[ControlState::PIE_MENU_ACTIVE_ANALOG] = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_ANALOG);
379-
m_ControlStates[ControlState::PIE_MENU_ACTIVE_DIGITAL] = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_DIGITAL);
380+
m_ControlStates[ControlState::PIE_MENU_ACTIVE_ANALOG] = activeAnalog;
381+
m_ControlStates[ControlState::PIE_MENU_ACTIVE_DIGITAL] = activeDigital;
380382

381383
// Make sure that firing and aiming are ignored while the pie menu is open, since it consumes those inputs.
382384
m_ControlStates[ControlState::WEAPON_FIRE] = false;

0 commit comments

Comments
 (0)