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/frontend | |
parent | 93a8e3213287a1aab47a0a1e36925fc679f12f1d (diff) |
make clipboard available when handling user-invoked chat commands
Diffstat (limited to 'source/frontend')
-rw-r--r-- | source/frontend/StarClientCommandProcessor.cpp | 6 | ||||
-rw-r--r-- | source/frontend/StarClientCommandProcessor.hpp | 2 | ||||
-rw-r--r-- | source/frontend/StarClipboardLuaBindings.cpp | 2 | ||||
-rw-r--r-- | source/frontend/StarMainInterface.cpp | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/source/frontend/StarClientCommandProcessor.cpp b/source/frontend/StarClientCommandProcessor.cpp index ec8d743..d0afb0c 100644 --- a/source/frontend/StarClientCommandProcessor.cpp +++ b/source/frontend/StarClientCommandProcessor.cpp @@ -11,6 +11,7 @@ #include "StarQuestInterface.hpp" #include "StarStatistics.hpp" #include "StarInterfaceLuaBindings.hpp" +#include "StarInput.hpp" namespace Star { @@ -74,7 +75,10 @@ String ClientCommandProcessor::previewQuestPane(StringList const& arguments, fun return "No such quest"; } -StringList ClientCommandProcessor::handleCommand(String const& commandLine) { +StringList ClientCommandProcessor::handleCommand(String const& commandLine, bool userInput) { + Maybe<Input::ClipboardUnlock> unlock; + if (userInput) // allow clipboard usage during this code + unlock = Input::singleton().unlockClipboard(); try { if (!commandLine.beginsWith("/")) throw StarException("ClientCommandProcessor expected command, does not start with '/'"); diff --git a/source/frontend/StarClientCommandProcessor.hpp b/source/frontend/StarClientCommandProcessor.hpp index df60b96..b8bb7e5 100644 --- a/source/frontend/StarClientCommandProcessor.hpp +++ b/source/frontend/StarClientCommandProcessor.hpp @@ -15,7 +15,7 @@ public: ClientCommandProcessor(UniverseClientPtr universeClient, CinematicPtr cinematicOverlay, MainInterfacePaneManager* paneManager, StringMap<StringList> macroCommands); - StringList handleCommand(String const& commandLine); + StringList handleCommand(String const& commandLine, bool userInput = false); bool debugDisplayEnabled() const; bool debugHudEnabled() const; diff --git a/source/frontend/StarClipboardLuaBindings.cpp b/source/frontend/StarClipboardLuaBindings.cpp index bfd461a..2c623e1 100644 --- a/source/frontend/StarClipboardLuaBindings.cpp +++ b/source/frontend/StarClipboardLuaBindings.cpp @@ -7,7 +7,7 @@ namespace Star { LuaCallbacks LuaBindings::makeClipboardCallbacks(ApplicationControllerPtr appController, bool alwaysAllow) { LuaCallbacks callbacks; - auto available = [=]() { return alwaysAllow || (appController->isFocused() && Input::singleton().getTag("clipboard") > 0); }; + auto available = [=]() { return alwaysAllow || (appController->isFocused() && Input::singleton().clipboardAllowed()); }; callbacks.registerCallback("available", [=]() -> bool { return available(); diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index e3b1860..572b39f 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -878,7 +878,7 @@ void MainInterface::doChat(String const& chat, bool addToHistory) { if (chat.beginsWith("/")) { m_lastCommand = chat; - for (auto const& result : m_clientCommandProcessor->handleCommand(chat)) + for (auto const& result : m_clientCommandProcessor->handleCommand(chat, true)) m_chat->addLine(result); } else { m_client->sendChat(chat, m_chat->sendMode()); |