Merge pull request #40 from ErodeesFleurs/clipboard
Add ClipboardLuaBindings and make them available only when "safeScripts" is false.
This commit is contained in:
commit
8f8741bcb2
@ -21,6 +21,7 @@
|
||||
#include "StarInterfaceLuaBindings.hpp"
|
||||
#include "StarInputLuaBindings.hpp"
|
||||
#include "StarVoiceLuaBindings.hpp"
|
||||
#include "StarClipboardLuaBindings.hpp"
|
||||
|
||||
#if defined STAR_SYSTEM_WINDOWS
|
||||
#include <windows.h>
|
||||
@ -516,6 +517,8 @@ void ClientApplication::changeState(MainAppState newState) {
|
||||
|
||||
m_universeClient->setLuaCallbacks("input", LuaBindings::makeInputCallbacks());
|
||||
m_universeClient->setLuaCallbacks("voice", LuaBindings::makeVoiceCallbacks());
|
||||
if(!m_root->configuration()->get("safeScripts").toBool())
|
||||
m_universeClient->setLuaCallbacks("clipboard", LuaBindings::makeClipboardCallbacks(appController()));
|
||||
|
||||
auto heldScriptPanes = make_shared<List<MainInterface::ScriptPaneInfo>>();
|
||||
|
||||
|
@ -23,6 +23,7 @@ SET (star_frontend_HEADERS
|
||||
StarChatBubbleManager.hpp
|
||||
StarCinematic.hpp
|
||||
StarClientCommandProcessor.hpp
|
||||
StarClipboardLuaBindings.hpp
|
||||
StarCodexInterface.hpp
|
||||
StarConfirmationDialog.hpp
|
||||
StarContainerInterface.hpp
|
||||
@ -74,6 +75,7 @@ SET (star_frontend_SOURCES
|
||||
StarChatBubbleManager.cpp
|
||||
StarCinematic.cpp
|
||||
StarClientCommandProcessor.cpp
|
||||
StarClipboardLuaBindings.cpp
|
||||
StarCodexInterface.cpp
|
||||
StarConfirmationDialog.cpp
|
||||
StarContainerInterface.cpp
|
||||
|
24
source/frontend/StarClipboardLuaBindings.cpp
Normal file
24
source/frontend/StarClipboardLuaBindings.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#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("getText", [appController]() -> Maybe<String> {
|
||||
return appController->getClipboard();
|
||||
});
|
||||
|
||||
callbacks.registerCallback("setText", [appController](String const& text) {
|
||||
appController->setClipboard(text);
|
||||
});
|
||||
|
||||
return callbacks;
|
||||
};
|
||||
|
||||
}// namespace Star
|
12
source/frontend/StarClipboardLuaBindings.hpp
Normal file
12
source/frontend/StarClipboardLuaBindings.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "StarLua.hpp"
|
||||
#include "StarApplicationController.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
namespace LuaBindings {
|
||||
LuaCallbacks makeClipboardCallbacks(ApplicationControllerPtr appController);
|
||||
}
|
||||
|
||||
}// namespace Star
|
Loading…
Reference in New Issue
Block a user