remove unnecessary SDL2 include

[skip ci]
This commit is contained in:
Kae 2024-03-17 01:52:34 +11:00
parent d577a98980
commit 463205c09c
4 changed files with 10 additions and 5 deletions

View File

@ -54,6 +54,7 @@ public:
virtual bool openAudioInputDevice(const char* name, int freq, int channels, void* userdata, AudioCallback callback) = 0; virtual bool openAudioInputDevice(const char* name, int freq, int channels, void* userdata, AudioCallback callback) = 0;
virtual bool closeAudioInputDevice() = 0; virtual bool closeAudioInputDevice() = 0;
virtual bool hasClipboard() = 0;
virtual void setClipboard(String text) = 0; virtual void setClipboard(String text) = 0;
virtual Maybe<String> getClipboard() = 0; virtual Maybe<String> getClipboard() = 0;

View File

@ -481,6 +481,10 @@ private:
Controller(SdlPlatform* parent) Controller(SdlPlatform* parent)
: parent(parent) {} : parent(parent) {}
bool hasClipboard() override {
return SDL_HasClipboardText();
}
Maybe<String> getClipboard() override { Maybe<String> getClipboard() override {
Maybe<String> string; Maybe<String> string;
if (SDL_HasClipboardText()) { if (SDL_HasClipboardText()) {

View File

@ -517,7 +517,7 @@ void ClientApplication::changeState(MainAppState newState) {
m_universeClient->setLuaCallbacks("input", LuaBindings::makeInputCallbacks()); m_universeClient->setLuaCallbacks("input", LuaBindings::makeInputCallbacks());
m_universeClient->setLuaCallbacks("voice", LuaBindings::makeVoiceCallbacks()); 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())); m_universeClient->setLuaCallbacks("clipboard", LuaBindings::makeClipboardCallbacks(appController()));
auto heldScriptPanes = make_shared<List<MainInterface::ScriptPaneInfo>>(); auto heldScriptPanes = make_shared<List<MainInterface::ScriptPaneInfo>>();

View File

@ -1,14 +1,14 @@
#include "StarClipboardLuaBindings.hpp" #include "StarClipboardLuaBindings.hpp"
#include "StarLuaConverters.hpp" #include "StarLuaConverters.hpp"
#include "SDL2/SDL.h"
namespace Star { namespace Star {
LuaCallbacks LuaBindings::makeClipboardCallbacks(ApplicationControllerPtr appController) { LuaCallbacks LuaBindings::makeClipboardCallbacks(ApplicationControllerPtr appController) {
LuaCallbacks callbacks; LuaCallbacks callbacks;
callbacks.registerCallback("hasText", []() -> bool { return SDL_HasClipboardText() == SDL_TRUE;}); callbacks.registerCallback("hasText", [appController]() -> bool {
return appController->hasClipboard();
});
callbacks.registerCallback("getText", [appController]() -> Maybe<String> { callbacks.registerCallback("getText", [appController]() -> Maybe<String> {
return appController->getClipboard(); return appController->getClipboard();
@ -21,4 +21,4 @@ LuaCallbacks LuaBindings::makeClipboardCallbacks(ApplicationControllerPtr appCon
return callbacks; return callbacks;
}; };
}// namespace Star }