ALL: Move Clipboard support to OSystem
Commit adds kFeatureClipboardSupport. hasTextInClipboard() and getTextFromClipboard(). OSystem_SDL has this feature if SDL2 is used. EditableWidget and StorageWizardDialog use g_system to access clipboard now.
This commit is contained in:
parent
527ab4cdf6
commit
b9bba9bd4b
5 changed files with 99 additions and 58 deletions
|
@ -64,6 +64,11 @@
|
|||
#include <SDL/SDL_net.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_clipboard.h>
|
||||
#endif
|
||||
|
||||
OSystem_SDL::OSystem_SDL()
|
||||
:
|
||||
#ifdef USE_OPENGL
|
||||
|
@ -171,6 +176,13 @@ void OSystem_SDL::init() {
|
|||
|
||||
}
|
||||
|
||||
bool OSystem_SDL::hasFeature(Feature f) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
if (f == kFeatureClipboardSupport) return true;
|
||||
#endif
|
||||
return ModularBackend::hasFeature(f);
|
||||
}
|
||||
|
||||
void OSystem_SDL::initBackend() {
|
||||
// Check if backend has not been initialized
|
||||
assert(!_inited);
|
||||
|
@ -453,6 +465,26 @@ Common::String OSystem_SDL::getSystemLanguage() const {
|
|||
#endif // USE_DETECTLANG
|
||||
}
|
||||
|
||||
bool OSystem_SDL::hasTextInClipboard() {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
return SDL_HasClipboardText() == SDL_TRUE;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Common::String OSystem_SDL::getTextFromClipboard() {
|
||||
if (!hasTextInClipboard()) return "";
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
char *text = SDL_GetClipboardText();
|
||||
if (text == nullptr) return "";
|
||||
return text;
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32 OSystem_SDL::getMillis(bool skipRecord) {
|
||||
uint32 millis = SDL_GetTicks();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue