mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Move InputManager to UiContext
This commit is contained in:
parent
80662d72a4
commit
59b4be6a12
4 changed files with 18 additions and 20 deletions
|
@ -79,6 +79,7 @@ private:
|
|||
bool _steamOverlayActive = false;
|
||||
|
||||
// Input
|
||||
InputManager _inputManager;
|
||||
ShortcutManager _shortcutManager;
|
||||
TextComposition _textComposition;
|
||||
CursorState _cursorState = {};
|
||||
|
@ -97,6 +98,11 @@ public:
|
|||
return _inGameConsole;
|
||||
}
|
||||
|
||||
InputManager& GetInputManager()
|
||||
{
|
||||
return _inputManager;
|
||||
}
|
||||
|
||||
ShortcutManager& GetShortcutManager()
|
||||
{
|
||||
return _shortcutManager;
|
||||
|
@ -426,8 +432,7 @@ public:
|
|||
ie.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.button.button;
|
||||
ie.State = InputEventState::Down;
|
||||
auto& inputManager = GetInputManager();
|
||||
inputManager.QueueInputEvent(std::move(ie));
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -463,8 +468,7 @@ public:
|
|||
ie.Modifiers = SDL_GetModState();
|
||||
ie.Button = e.button.button;
|
||||
ie.State = InputEventState::Release;
|
||||
auto& inputManager = GetInputManager();
|
||||
inputManager.QueueInputEvent(std::move(ie));
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -528,8 +532,7 @@ public:
|
|||
ie.Modifiers = e.key.keysym.mod;
|
||||
ie.Button = e.key.keysym.sym;
|
||||
ie.State = InputEventState::Down;
|
||||
auto& inputManager = GetInputManager();
|
||||
inputManager.QueueInputEvent(std::move(ie));
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
|
@ -539,8 +542,7 @@ public:
|
|||
ie.Modifiers = e.key.keysym.mod;
|
||||
ie.Button = e.key.keysym.sym;
|
||||
ie.State = InputEventState::Release;
|
||||
auto& inputManager = GetInputManager();
|
||||
inputManager.QueueInputEvent(std::move(ie));
|
||||
_inputManager.QueueInputEvent(std::move(ie));
|
||||
}
|
||||
break;
|
||||
case SDL_MULTIGESTURE:
|
||||
|
@ -571,8 +573,7 @@ public:
|
|||
break;
|
||||
default:
|
||||
{
|
||||
auto& inputManager = GetInputManager();
|
||||
inputManager.QueueInputEvent(e);
|
||||
_inputManager.QueueInputEvent(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -960,6 +961,12 @@ InGameConsole& OpenRCT2::Ui::GetInGameConsole()
|
|||
return uiContext->GetInGameConsole();
|
||||
}
|
||||
|
||||
InputManager& OpenRCT2::Ui::GetInputManager()
|
||||
{
|
||||
auto uiContext = std::static_pointer_cast<UiContext>(GetContext()->GetUiContext());
|
||||
return uiContext->GetInputManager();
|
||||
}
|
||||
|
||||
ShortcutManager& OpenRCT2::Ui::GetShortcutManager()
|
||||
{
|
||||
auto uiContext = std::static_pointer_cast<UiContext>(GetContext()->GetUiContext());
|
||||
|
|
|
@ -380,10 +380,3 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static InputManager _inputManager;
|
||||
|
||||
InputManager& OpenRCT2::Ui::GetInputManager()
|
||||
{
|
||||
return _inputManager;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,4 @@ namespace OpenRCT2::Ui
|
|||
void QueueInputEvent(InputEvent&& e);
|
||||
void Process();
|
||||
};
|
||||
|
||||
InputManager& GetInputManager();
|
||||
|
||||
} // namespace OpenRCT2::Ui
|
||||
|
|
|
@ -139,5 +139,6 @@ namespace OpenRCT2::Ui
|
|||
static std::string_view GetLegacyShortcutId(size_t index);
|
||||
};
|
||||
|
||||
InputManager& GetInputManager();
|
||||
ShortcutManager& GetShortcutManager();
|
||||
} // namespace OpenRCT2::Ui
|
||||
|
|
Loading…
Reference in a new issue