Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fixed the palette being mangled to 6bit/color on load.

- Fixed allegro not loading alpha of image with alpha by using SDL_image instead.

- Fixed `MOSprite:UnRotateOffset()` giving the wrong results on HFLipped sprites.

- 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.
Expand All @@ -247,6 +248,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- 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.

- Fixed an issue where pie menu selection could become unresponsive at low framerates.

- Fixed issue where scripts applied to `MovableObject`s could become disordered in certain circumstances.

- 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.
Expand Down
30 changes: 18 additions & 12 deletions Source/Entities/PieMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,6 @@ void PieMenu::Update() {
SetPos(affectedObjectAsActor ? affectedObjectAsActor->GetCPUPos() : m_AffectedObject->GetPos());
}

if (m_MenuMode == MenuMode::Wobble) {
UpdateWobbling();
} else if (m_MenuMode == MenuMode::Freeze) {
m_EnabledState = EnabledState::Enabling;
} else if (m_EnabledState == EnabledState::Enabling || m_EnabledState == EnabledState::Disabling) {
UpdateEnablingAndDisablingProgress();
}

if (controller->IsDisabled()) {
SetEnabled(false);
return;
Expand All @@ -566,13 +558,16 @@ void PieMenu::Update() {

bool anyInput = false;
bool skipInputBecauseActiveSubPieMenuWasJustDisabled = false;

if (m_ActiveSubPieMenu) {
m_CursorAngle = m_HoveredPieSlice->GetMidAngle() + GetRotAngle();
m_CursorInVisiblePosition = false;
m_HoverTimer.Reset();

if (m_ActiveSubPieMenu->IsVisible()) {
m_ActiveSubPieMenu->Update();
}

if (!m_ActiveSubPieMenu->IsEnabled()) {
m_ActivatedPieSlice = m_ActiveSubPieMenu->m_ActivatedPieSlice;
Directions activeSubPieMenuDirection = m_ActiveSubPieMenu->m_DirectionIfSubPieMenu;
Expand All @@ -584,6 +579,7 @@ void PieMenu::Update() {
m_CursorInVisiblePosition = true;
} else {
bool shouldClearHoveredSlice = controller->IsState(ControlState::PIE_MENU_ACTIVE_ANALOG);

// 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.
if (activeSubPieMenuDirection != Directions::None) {
for (const auto& [controlState, controlStateDirection]: c_ControlStateDirections) {
Expand All @@ -593,13 +589,15 @@ void PieMenu::Update() {
}
}
}

if (shouldClearHoveredSlice) {
SetHoveredPieSlice(nullptr);
skipInputBecauseActiveSubPieMenuWasJustDisabled = true;
}
}
}
}

if (!m_ActiveSubPieMenu && !skipInputBecauseActiveSubPieMenuWasJustDisabled) {
if (controller->IsState(PIE_MENU_ACTIVE_ANALOG)) {
anyInput = HandleAnalogInput(controller->GetAnalogCursor());
Expand All @@ -611,10 +609,6 @@ void PieMenu::Update() {
if (anyInput) {
m_HoverTimer.Reset();
}

if (!IsSubPieMenu() && m_HoverTimer.IsPastRealTimeLimit()) {
SetHoveredPieSlice(nullptr);
}
}

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

if (!IsSubPieMenu()) {
SetEnabled(controller->IsState(ControlState::PIE_MENU_ACTIVE));

if (m_HoverTimer.IsPastRealTimeLimit()) {
SetHoveredPieSlice(nullptr);
}
}
}

if (m_MenuMode == MenuMode::Wobble) {
UpdateWobbling();
} else if (m_MenuMode == MenuMode::Freeze) {
m_EnabledState = EnabledState::Enabling;
} else if (m_EnabledState == EnabledState::Enabling || m_EnabledState == EnabledState::Disabling) {
UpdateEnablingAndDisablingProgress();
}

if (m_BGBitmapNeedsRedrawing && m_EnabledState != EnabledState::Disabled) {
UpdatePredrawnMenuBackgroundBitmap();
}
Expand Down
3 changes: 3 additions & 0 deletions Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ void PollSDLEvents() {
/// Game menus loop.
/// </summary>
void RunMenuLoop() {
g_MenuMan.SetIsInMenuScreen(true);
g_UInputMan.DisableKeys(false);
g_UInputMan.TrapMousePos(false);

Expand Down Expand Up @@ -282,6 +283,8 @@ void RunMenuLoop() {
g_WindowMan.GetScreenBuffer()->End();
g_WindowMan.UploadFrame();
}

g_MenuMan.SetIsInMenuScreen(false);
}

/// <summary>
Expand Down
7 changes: 1 addition & 6 deletions Source/Managers/MenuMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void MenuMan::Initialize(bool firstTimeInit) {
m_GUIInput = std::make_unique<GUIInputWrapper>(-1, g_UInputMan.GetJoystickCount() > 0);

if (firstTimeInit) {
m_IsInMenuScreen = false;
g_LoadingScreen.Create(m_GUIScreen.get(), m_GUIInput.get(), g_SettingsMan.GetLoadingScreenProgressReportDisabled());
}

Expand Down Expand Up @@ -129,12 +130,6 @@ void MenuMan::HandleTransitionIntoMenuLoop() {
}

bool MenuMan::Update() {
// If we're in the menu but the activity isn't set as paused, then exit
// This can mismatch sometimes like when loading a saved game
if (m_ActiveMenu != ActiveMenu::MenusDisabled && !g_ActivityMan.ActivityPaused()) {
return true;
}

m_TitleScreen->Update();
SetActiveMenu();

Expand Down
11 changes: 11 additions & 0 deletions Source/Managers/MenuMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ namespace RTE {
void Draw() const;
#pragma endregion

#pragma region Getters/Setters
/// Checks if we're currently in a menu screen.
/// @return True if in a menu screen; false otherwise.
bool GetIsInMenuScreen() const { return m_IsInMenuScreen; }

/// Sets if we're currently in a menu screen.
/// @param isInMenuScreen Whether we're in any menu screen.
void SetIsInMenuScreen(bool isInMenuScreen) { m_IsInMenuScreen = isInMenuScreen; }
#pragma endregion

private:
/// Enumeration for the different menu screens that are active based on transition states.
enum ActiveMenu {
Expand All @@ -54,6 +64,7 @@ namespace RTE {
PauseMenuActive,
};

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

std::unique_ptr<GUIInputWrapper> m_GUIInput; //!< The GUIInput interface of this MenuMan.
Expand Down
6 changes: 3 additions & 3 deletions Source/Managers/UInputMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ConsoleMan.h"
#include "PresetMan.h"
#include "PerformanceMan.h"
#include "MenuMan.h"
#include "Icon.h"
#include "GameActivity.h"
#include "System.h"
Expand Down Expand Up @@ -72,7 +73,6 @@ int UInputMan::Initialize() {

m_MouseStates[0] = {};


int controllerIndex = 0;
int joystickCount = 0;
SDL_JoystickID* joysticks = SDL_GetGamepads(&joystickCount);
Expand Down Expand Up @@ -1049,7 +1049,7 @@ void UInputMan::EndFrame() {
}

m_TextInput.clear();
for (auto& [mouseID, mouse]: m_MouseStates) {
for (auto& [mouseID, mouse] : m_MouseStates) {
mouse.wheelChange = 0;
mouse.relativeMotion.Reset();
mouse.change.fill(false);
Expand Down Expand Up @@ -1178,7 +1178,7 @@ void UInputMan::UpdateMouseInput() {
// 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
for (int player = PlayerOne; player < MaxPlayerCount; player++) {
if (m_ControlScheme[player].GetDevice() == InputDevice::DEVICE_MOUSE_KEYB) {
ForceMouseWithinPlayerScreen(g_ActivityMan.IsInActivity(), player);
ForceMouseWithinPlayerScreen(g_ActivityMan.IsInActivity() && !g_MenuMan.GetIsInMenuScreen(), player);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Source/Menus/BuyMenuGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ void BuyMenuGUI::SetEnabled(bool enable) {
g_UInputMan.SetMousePos(mousePos, m_pController->GetPlayer());

// Default focus to the menu button
m_LastHoveredMouseIndex = 0;
m_MenuFocus = OK;
m_FocusChange = true;
UpdateTotalCostLabel(m_pController->GetTeam());
Expand Down
8 changes: 5 additions & 3 deletions Source/System/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,15 @@ void Controller::UpdatePlayerPieMenuInput(std::array<bool, ControlState::CONTROL
}

// PIE MENU ACTIVE
if (g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_ANALOG) || g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_DIGITAL)) {
const bool activeAnalog = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_ANALOG) || g_UInputMan.ElementReleased(m_Player, InputElements::INPUT_PIEMENU_ANALOG);
const bool activeDigital = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_DIGITAL) || g_UInputMan.ElementReleased(m_Player, InputElements::INPUT_PIEMENU_DIGITAL);
if (activeAnalog || activeDigital) {
if (m_ControlledActor && m_ControlledActor->GetPieMenu()->IsInNormalAnimationMode() && !m_ControlledActor->GetPieMenu()->IsVisible()) {
m_ControlStates[ControlState::PIE_MENU_OPENED] = true;
}
m_ControlStates[ControlState::PIE_MENU_ACTIVE] = true;
m_ControlStates[ControlState::PIE_MENU_ACTIVE_ANALOG] = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_ANALOG);
m_ControlStates[ControlState::PIE_MENU_ACTIVE_DIGITAL] = g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_PIEMENU_DIGITAL);
m_ControlStates[ControlState::PIE_MENU_ACTIVE_ANALOG] = activeAnalog;
m_ControlStates[ControlState::PIE_MENU_ACTIVE_DIGITAL] = activeDigital;

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