From 463205c09cc393e92ae2f51b9bc8f61c4e368dea Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sun, 17 Mar 2024 01:52:34 +1100 Subject: [PATCH] remove unnecessary SDL2 include [skip ci] --- source/application/StarApplicationController.hpp | 1 + source/application/StarMainApplication_sdl.cpp | 4 ++++ source/client/StarClientApplication.cpp | 2 +- source/frontend/StarClipboardLuaBindings.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/application/StarApplicationController.hpp b/source/application/StarApplicationController.hpp index 341e15e..0e288d2 100644 --- a/source/application/StarApplicationController.hpp +++ b/source/application/StarApplicationController.hpp @@ -54,6 +54,7 @@ public: virtual bool openAudioInputDevice(const char* name, int freq, int channels, void* userdata, AudioCallback callback) = 0; virtual bool closeAudioInputDevice() = 0; + virtual bool hasClipboard() = 0; virtual void setClipboard(String text) = 0; virtual Maybe getClipboard() = 0; diff --git a/source/application/StarMainApplication_sdl.cpp b/source/application/StarMainApplication_sdl.cpp index 7b1601f..1b5a1f4 100644 --- a/source/application/StarMainApplication_sdl.cpp +++ b/source/application/StarMainApplication_sdl.cpp @@ -481,6 +481,10 @@ private: Controller(SdlPlatform* parent) : parent(parent) {} + bool hasClipboard() override { + return SDL_HasClipboardText(); + } + Maybe getClipboard() override { Maybe string; if (SDL_HasClipboardText()) { diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index e5cf601..6df7916 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -517,7 +517,7 @@ void ClientApplication::changeState(MainAppState newState) { m_universeClient->setLuaCallbacks("input", LuaBindings::makeInputCallbacks()); m_universeClient->setLuaCallbacks("voice", LuaBindings::makeVoiceCallbacks()); - if(!m_root->configuration()->get("safeScripts").toBool()) + if (!m_root->configuration()->get("safeScripts").toBool()) m_universeClient->setLuaCallbacks("clipboard", LuaBindings::makeClipboardCallbacks(appController())); auto heldScriptPanes = make_shared>(); diff --git a/source/frontend/StarClipboardLuaBindings.cpp b/source/frontend/StarClipboardLuaBindings.cpp index c4fbc41..c8a8dfe 100644 --- a/source/frontend/StarClipboardLuaBindings.cpp +++ b/source/frontend/StarClipboardLuaBindings.cpp @@ -1,14 +1,14 @@ #include "StarClipboardLuaBindings.hpp" #include "StarLuaConverters.hpp" -#include "SDL2/SDL.h" - namespace Star { LuaCallbacks LuaBindings::makeClipboardCallbacks(ApplicationControllerPtr appController) { LuaCallbacks callbacks; - callbacks.registerCallback("hasText", []() -> bool { return SDL_HasClipboardText() == SDL_TRUE;}); + callbacks.registerCallback("hasText", [appController]() -> bool { + return appController->hasClipboard(); + }); callbacks.registerCallback("getText", [appController]() -> Maybe { return appController->getClipboard(); @@ -21,4 +21,4 @@ LuaCallbacks LuaBindings::makeClipboardCallbacks(ApplicationControllerPtr appCon return callbacks; }; -}// namespace Star +}