From c74ba4652d497ddbdec4342029d94bc77387a705 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 25 Jul 2016 16:37:44 +0600 Subject: GUI: Add "Paste" button in StorageWizardDialog It pastes clipboard contents as code into 8 fields of that dialog. (Clipboard support works with SDL2 only.) "Open URL" and "Paste" buttons are placed in the left column under the picture (because there is no room for 4 buttons in the bottom row). Commit also adds "dropbox.bmp", which is just a square 115x115 picture. Such pictures are would be used as Storages logos in that dialog. In lowres there is no left column, so all 4 buttons are in the same row. None of them are visible, because they are overflowed. Container has to be added to continue working on them. --- gui/ThemeEngine.cpp | 1 + gui/ThemeEngine.h | 1 + gui/storagewizarddialog.cpp | 55 ++++++++++++++++++++- gui/storagewizarddialog.h | 1 + gui/themes/scummclassic.zip | Bin 124903 -> 129092 bytes gui/themes/scummclassic/classic_layout.stx | 19 ++++--- gui/themes/scummclassic/classic_layout_lowres.stx | 4 ++ gui/themes/scummmodern.zip | Bin 1500676 -> 1545339 bytes gui/themes/scummmodern/dropbox.bmp | Bin 0 -> 40074 bytes gui/themes/scummmodern/scummmodern_gfx.stx | 1 + gui/themes/scummmodern/scummmodern_layout.stx | 19 ++++--- .../scummmodern/scummmodern_layout_lowres.stx | 4 ++ 12 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 gui/themes/scummmodern/dropbox.bmp diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index ac209d60a2..e400e695db 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -61,6 +61,7 @@ const char *const ThemeEngine::kImageStopSmallButton = "stopbtn_small.bmp"; const char *const ThemeEngine::kImageEditSmallButton = "editbtn_small.bmp"; const char *const ThemeEngine::kImageSwitchModeSmallButton = "switchbtn_small.bmp"; const char *const ThemeEngine::kImageFastReplaySmallButton = "fastreplay_small.bmp"; +const char *const ThemeEngine::kImageDropboxLogo = "dropbox.bmp"; struct TextDrawData { const Graphics::Font *_fontPtr; diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 91f82b1122..eb9b7daefa 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -250,6 +250,7 @@ public: static const char *const kImageEditSmallButton; ///< Edit recording metadata in recorder onscreen dialog (for 320xY) static const char *const kImageSwitchModeSmallButton; ///< Switch mode button in recorder onscreen dialog (for 320xY) static const char *const kImageFastReplaySmallButton; ///< Fast playback mode button in recorder onscreen dialog (for 320xY) + static const char *const kImageDropboxLogo; ///< Dropbox logo used in the StorageWizardDialog /** * Graphics mode enumeration. diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp index 9e522fb2de..e04ca0255e 100644 --- a/gui/storagewizarddialog.cpp +++ b/gui/storagewizarddialog.cpp @@ -20,6 +20,13 @@ * */ +#ifdef USE_SDL2 +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include +#include +#endif + #include "gui/storagewizarddialog.h" #include "gui/gui-manager.h" #include "gui/message.h" @@ -37,7 +44,8 @@ namespace GUI { enum { kConnectCmd = 'Cnnt', kCodeBoxCmd = 'CdBx', - kOpenUrlCmd = 'OpUr' + kOpenUrlCmd = 'OpUr', + kPasteCodeCmd = 'PsCd' }; StorageWizardDialog::StorageWizardDialog(uint32 storageId): @@ -62,6 +70,7 @@ StorageWizardDialog::StorageWizardDialog(uint32 storageId): // Buttons new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.CancelButton", _("Cancel"), 0, kCloseCmd); new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.OpenUrlButton", _("Open URL"), 0, kOpenUrlCmd); + _pasteCodeWidget = new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.PasteCodeButton", _("Paste"), _("Pastes clipboard contents into fields"), kPasteCodeCmd); _connectWidget = new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.ConnectButton", _("Connect"), 0, kConnectCmd); if (Cloud::CloudManager::couldUseLocalServer()) { @@ -72,7 +81,20 @@ StorageWizardDialog::StorageWizardDialog(uint32 storageId): _codeWidget[i]->setVisible(false); _messageWidget->setVisible(false); _connectWidget->setVisible(false); + _pasteCodeWidget->setVisible(false); } + +#ifndef USE_SDL2 + _pasteCodeWidget->setVisible(false); +#endif + +#ifndef DISABLE_FANCY_THEMES + if (g_gui.theme()->supportsImages() && g_system->getOverlayWidth() > 320) { // picture only in high-res + GraphicsWidget *gfx = new GraphicsWidget(this, "GlobalOptions_Cloud_ConnectionWizard.Picture"); + gfx->useThemeTransparency(true); + gfx->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageDropboxLogo)); + } +#endif } void StorageWizardDialog::open() { @@ -162,7 +184,7 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 //the last 3 chars must be an encoded crc16 if (code.size() > 3) { uint32 size = code.size(); - uint32 gotcrc = decodeHashchar(code[size-3]) | (decodeHashchar(code[size-2]) << 6) | (decodeHashchar(code[size-1]) << 12); + uint32 gotcrc = decodeHashchar(code[size - 3]) | (decodeHashchar(code[size - 2]) << 6) | (decodeHashchar(code[size - 1]) << 12); code.erase(size - 3); uint32 crc = crc16(code); ok = (crc == gotcrc); @@ -183,6 +205,35 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 } break; } + case kPasteCodeCmd: { +#ifdef USE_SDL2 + if (SDL_HasClipboardText() == SDL_TRUE) { + char *text = SDL_GetClipboardText(); + if (text != nullptr) { + Common::String message = text; + for (uint32 i = 0; i < CODE_FIELDS; ++i) { + if (message.empty()) break; + Common::String subcode = ""; + for (uint32 j = 0; j < message.size(); ++j) { + if (message[j] == ' ') { + message.erase(0, j+1); + break; + } + subcode += message[j]; + if (j+1 == message.size()) { + message = ""; + break; + } + } + _codeWidget[i]->setEditString(subcode); + } + handleCommand(sender, kCodeBoxCmd, data); + draw(); + } + } +#endif + break; + } case kConnectCmd: { Common::String code; for (uint32 i = 0; i < CODE_FIELDS; ++i) { diff --git a/gui/storagewizarddialog.h b/gui/storagewizarddialog.h index cc70f86278..b0d099957e 100644 --- a/gui/storagewizarddialog.h +++ b/gui/storagewizarddialog.h @@ -44,6 +44,7 @@ class StorageWizardDialog : public Dialog { uint32 _storageId; EditTextWidget *_codeWidget[CODE_FIELDS]; StaticTextWidget *_messageWidget; + ButtonWidget *_pasteCodeWidget; ButtonWidget *_connectWidget; bool _close; #ifdef USE_SDL_NET diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index 4a36e7db99..42c6b10b73 100644 Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index 2e37b00c91..3284f7d565 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -637,9 +637,18 @@ - + + + + + - + diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 06ce6f6003..7666aeb585 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -709,6 +709,7 @@ height = 'Globals.Line.Height' /> + + diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index fcf35d97e2..b433aaae7a 100644 Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ diff --git a/gui/themes/scummmodern/dropbox.bmp b/gui/themes/scummmodern/dropbox.bmp new file mode 100644 index 0000000000..bfb9e90792 Binary files /dev/null and b/gui/themes/scummmodern/dropbox.bmp differ diff --git a/gui/themes/scummmodern/scummmodern_gfx.stx b/gui/themes/scummmodern/scummmodern_gfx.stx index 31b194d174..d7b35b10b9 100644 --- a/gui/themes/scummmodern/scummmodern_gfx.stx +++ b/gui/themes/scummmodern/scummmodern_gfx.stx @@ -119,6 +119,7 @@ + diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 49876be18b..a242229dff 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -651,9 +651,18 @@ - + + + + + - + diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index e10ce4a6c2..26f7fab465 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -707,6 +707,7 @@ height = 'Globals.Line.Height' /> + + -- cgit v1.2.3