diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-05-10 10:52:34 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-05-10 10:52:34 +1000 |
commit | 9d30cbd22a3f78efb6984a347630d8d601002bc1 (patch) | |
tree | 060888673996fe54cb34578e24f888f211882b8a /source/game | |
parent | 93a8e3213287a1aab47a0a1e36925fc679f12f1d (diff) |
make clipboard available when handling user-invoked chat commands
Diffstat (limited to 'source/game')
-rw-r--r-- | source/game/StarInput.cpp | 20 | ||||
-rw-r--r-- | source/game/StarInput.hpp | 16 |
2 files changed, 33 insertions, 3 deletions
diff --git a/source/game/StarInput.cpp b/source/game/StarInput.cpp index 7577936..d47045d 100644 --- a/source/game/StarInput.cpp +++ b/source/game/StarInput.cpp @@ -678,8 +678,24 @@ void Input::setBinds(String const& categoryId, String const& bindId, Json const& entry.updated(); } -unsigned Input::getTag(String const& tag) { - return m_activeTags.maybe(tag).value(0); +unsigned Input::getTag(String const& tagName) const { + if (auto tag = m_activeTags.ptr(tagName)) + return *tag; + else + return 0; +} + +Input::ClipboardUnlock::ClipboardUnlock(Input& input) + : m_input(&input) { ++m_input->m_clipboardAllowed; }; + +Input::ClipboardUnlock::~ClipboardUnlock() { --m_input->m_clipboardAllowed; }; + +Input::ClipboardUnlock Input::unlockClipboard() { + return Input::ClipboardUnlock(*this); +} + +bool Input::clipboardAllowed() const { + return m_clipboardAllowed > 0 ? true : getTag("clipboard") > 0; } }
\ No newline at end of file diff --git a/source/game/StarInput.hpp b/source/game/StarInput.hpp index f13885c..1746739 100644 --- a/source/game/StarInput.hpp +++ b/source/game/StarInput.hpp @@ -178,8 +178,20 @@ public: void setBinds(String const& categoryId, String const& bindId, Json const& binds); Json getDefaultBinds(String const& categoryId, String const& bindId); Json getBinds(String const& categoryId, String const& bindId); - unsigned getTag(String const& tag); + unsigned getTag(String const& tagName) const; + + class ClipboardUnlock { + public: + ClipboardUnlock(Input& input); + ~ClipboardUnlock(); + + private: + Input* m_input; + }; + + ClipboardUnlock unlockClipboard(); + bool clipboardAllowed() const; private: List<BindEntry*> filterBindEntries(List<BindRef> const& binds, KeyMod mods) const; @@ -214,6 +226,8 @@ private: KeyMod m_pressedMods; bool m_textInputActive; Vec2I m_mousePosition; + + unsigned m_clipboardAllowed = 0; }; } |