Move InputManager to UiContext

This commit is contained in:
Ted John 2021-01-20 22:49:11 +00:00
parent 80662d72a4
commit 59b4be6a12
4 changed files with 18 additions and 20 deletions

View file

@ -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());

View file

@ -380,10 +380,3 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const
}
return false;
}
static InputManager _inputManager;
InputManager& OpenRCT2::Ui::GetInputManager()
{
return _inputManager;
}

View file

@ -77,7 +77,4 @@ namespace OpenRCT2::Ui
void QueueInputEvent(InputEvent&& e);
void Process();
};
InputManager& GetInputManager();
} // namespace OpenRCT2::Ui

View file

@ -139,5 +139,6 @@ namespace OpenRCT2::Ui
static std::string_view GetLegacyShortcutId(size_t index);
};
InputManager& GetInputManager();
ShortcutManager& GetShortcutManager();
} // namespace OpenRCT2::Ui