mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Cache view scroll shortcuts
This commit is contained in:
@@ -291,18 +291,22 @@ void InputManager::ProcessHoldEvents()
|
||||
auto& shortcutManager = GetShortcutManager();
|
||||
if (!shortcutManager.IsPendingShortcutChange())
|
||||
{
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollUp, { 0, -1 });
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollDown, { 0, 1 });
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollLeft, { -1, 0 });
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollRight, { 1, 0 });
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollUp, _scrollUpShortcut, { 0, -1 });
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollDown, _scrollDownShortcut, { 0, 1 });
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollLeft, _scrollLeftShortcut, { -1, 0 });
|
||||
ProcessViewScrollEvent(ShortcutId::ScrollRight, _scrollRightShortcut, { 1, 0 });
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::ProcessViewScrollEvent(std::string_view shortcutId, const ScreenCoordsXY& delta)
|
||||
void InputManager::ProcessViewScrollEvent(
|
||||
std::string_view shortcutId, RegisteredShortcut*& shortcut, const ScreenCoordsXY& delta)
|
||||
{
|
||||
auto& shortcutManager = GetShortcutManager();
|
||||
auto s = shortcutManager.GetShortcut(shortcutId);
|
||||
if (s != nullptr && GetState(*s))
|
||||
if (shortcut == nullptr)
|
||||
{
|
||||
auto& shortcutManager = GetShortcutManager();
|
||||
shortcut = shortcutManager.GetShortcut(shortcutId);
|
||||
}
|
||||
if (shortcut != nullptr && GetState(*shortcut))
|
||||
{
|
||||
_viewScroll.x += delta.x;
|
||||
_viewScroll.y += delta.y;
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace OpenRCT2::Ui
|
||||
uint32_t _mouseState;
|
||||
std::vector<uint8_t> _keyboardState;
|
||||
|
||||
RegisteredShortcut* _scrollLeftShortcut{};
|
||||
RegisteredShortcut* _scrollUpShortcut{};
|
||||
RegisteredShortcut* _scrollRightShortcut{};
|
||||
RegisteredShortcut* _scrollDownShortcut{};
|
||||
|
||||
void CheckJoysticks();
|
||||
|
||||
void HandleViewScrolling();
|
||||
@@ -62,7 +67,7 @@ namespace OpenRCT2::Ui
|
||||
void ProcessInGameConsole(const InputEvent& e);
|
||||
void ProcessChat(const InputEvent& e);
|
||||
void ProcessHoldEvents();
|
||||
void ProcessViewScrollEvent(std::string_view shortcutId, const ScreenCoordsXY& delta);
|
||||
void ProcessViewScrollEvent(std::string_view shortcutId, RegisteredShortcut*& shortcut, const ScreenCoordsXY& delta);
|
||||
|
||||
bool GetState(const RegisteredShortcut& shortcut) const;
|
||||
bool GetState(const ShortcutInput& shortcut) const;
|
||||
|
||||
Reference in New Issue
Block a user