diff options
author | Eugene Sandulenko | 2017-02-21 23:29:51 +0100 |
---|---|---|
committer | GitHub | 2017-02-21 23:29:51 +0100 |
commit | 8458e3deb7d76358b41f6e0b7f39cec9db358413 (patch) | |
tree | ba69d4b382270968305ffed8ff985d83d37fe2c5 | |
parent | 98bbb92a8e04dfb31ca942805a8ac36e1aafbcf8 (diff) | |
parent | cdda943c8a3089551843be3dedaaddb6c5348555 (diff) | |
download | scummvm-rg350-8458e3deb7d76358b41f6e0b7f39cec9db358413.tar.gz scummvm-rg350-8458e3deb7d76358b41f6e0b7f39cec9db358413.tar.bz2 scummvm-rg350-8458e3deb7d76358b41f6e0b7f39cec9db358413.zip |
Merge pull request #905 from lubomyr/master
ANDROIDSDL: added tab Control in main Options menu for switching some features
-rw-r--r-- | backends/events/androidsdl/androidsdl-events.cpp | 13 | ||||
-rw-r--r-- | backends/platform/androidsdl/androidsdl-sdl.cpp | 96 | ||||
-rw-r--r-- | backends/platform/androidsdl/androidsdl-sdl.h | 8 | ||||
-rw-r--r-- | common/system.h | 17 | ||||
-rw-r--r-- | gui/options.cpp | 76 | ||||
-rw-r--r-- | gui/options.h | 12 | ||||
-rw-r--r-- | gui/themes/default.inc | 26 | ||||
-rw-r--r-- | gui/themes/scummclassic.zip | bin | 126739 -> 127529 bytes | |||
-rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 14 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 14 | ||||
-rw-r--r-- | gui/themes/scummmodern.zip | bin | 1646279 -> 1647069 bytes | |||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 14 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 14 |
13 files changed, 290 insertions, 14 deletions
diff --git a/backends/events/androidsdl/androidsdl-events.cpp b/backends/events/androidsdl/androidsdl-events.cpp index 0adcff817e..125f411289 100644 --- a/backends/events/androidsdl/androidsdl-events.cpp +++ b/backends/events/androidsdl/androidsdl-events.cpp @@ -26,7 +26,6 @@ #include "backends/events/androidsdl/androidsdl-events.h" #include "backends/platform/androidsdl/androidsdl-sdl.h" -#include <SDL_screenkeyboard.h> bool AndroidSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { if (ev.button.button == SDL_BUTTON_LEFT) @@ -43,16 +42,8 @@ bool AndroidSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event & else if (ev.button.button == SDL_BUTTON_MIDDLE) { event.type = Common::EVENT_MBUTTONDOWN; - static int show_onscreen = 0; - if (show_onscreen == 0) { - SDL_ANDROID_SetScreenKeyboardShown(0); - show_onscreen++; - } else if (show_onscreen==1) { - SDL_ANDROID_SetScreenKeyboardShown(1); - show_onscreen++; - } - if (show_onscreen == 2) - show_onscreen = 0; + const bool show_onscreen = g_system->getFeatureState(OSystem::kFeatureOnScreenControl); + g_system->setFeatureState(OSystem::kFeatureOnScreenControl, !show_onscreen); } #endif else diff --git a/backends/platform/androidsdl/androidsdl-sdl.cpp b/backends/platform/androidsdl/androidsdl-sdl.cpp index d04512475a..920dad2234 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.cpp +++ b/backends/platform/androidsdl/androidsdl-sdl.cpp @@ -27,6 +27,8 @@ #include "backends/platform/androidsdl/androidsdl-sdl.h" #include "backends/events/androidsdl/androidsdl-events.h" #include "backends/graphics/androidsdl/androidsdl-graphics.h" +#include <SDL_android.h> +#include <SDL_screenkeyboard.h> void OSystem_ANDROIDSDL::initBackend() { // Create the backend custom managers @@ -42,7 +44,101 @@ void OSystem_ANDROIDSDL::initBackend() { if (!ConfMan.hasKey("gfx_mode")) ConfMan.set("gfx_mode", "2x"); + + if (!ConfMan.hasKey("swap_menu_and_back_buttons")) + ConfMan.setBool("swap_menu_and_back_buttons", true); + else + swapMenuAndBackButtons(ConfMan.getBool("swap_menu_and_back_buttons")); + + if (!ConfMan.hasKey("touchpad_mouse_mode")) { + const bool enable = SDL_ANDROID_GetMouseEmulationMode(); + ConfMan.setBool("touchpad_mouse_mode", enable); + } else + touchpadMode(ConfMan.getBool("touchpad_mouse_mode")); + + if (!ConfMan.hasKey("onscreen_control")) { + const bool enable = SDL_ANDROID_GetScreenKeyboardShown(); + ConfMan.setBool("onscreen_control", enable); + } else + showOnScreenControl(ConfMan.getBool("onscreen_control")); // Call parent implementation of this method OSystem_POSIX::initBackend(); } + +void OSystem_ANDROIDSDL::showOnScreenControl(bool enable) { + if (enable) + SDL_ANDROID_SetScreenKeyboardShown(1); + else + SDL_ANDROID_SetScreenKeyboardShown(0); +} + +void OSystem_ANDROIDSDL::touchpadMode(bool enable) { + if (enable) + switchToRelativeMouseMode(); + else + switchToDirectMouseMode(); +} + +void OSystem_ANDROIDSDL::swapMenuAndBackButtons(bool enable) { + static int KEYCODE_MENU = 82; + static int KEYCODE_BACK = 4; + if (enable) { + SDL_ANDROID_SetAndroidKeycode(KEYCODE_BACK, SDLK_F13); + SDL_ANDROID_SetAndroidKeycode(KEYCODE_MENU, SDLK_ESCAPE); + } else { + SDL_ANDROID_SetAndroidKeycode(KEYCODE_BACK, SDLK_ESCAPE); + SDL_ANDROID_SetAndroidKeycode(KEYCODE_MENU, SDLK_F13); + } +} + +void OSystem_ANDROIDSDL::switchToDirectMouseMode() { + SDL_ANDROID_SetMouseEmulationMode(0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); +} + +void OSystem_ANDROIDSDL::switchToRelativeMouseMode() { + SDL_ANDROID_SetMouseEmulationMode(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); +} + +void OSystem_ANDROIDSDL::setFeatureState(Feature f, bool enable) { + switch (f) { + case kFeatureTouchpadMode: + ConfMan.setBool("touchpad_mouse_mode", enable); + touchpadMode(enable); + break; + case kFeatureOnScreenControl: + ConfMan.setBool("onscreen_control", enable); + showOnScreenControl(enable); + break; + case kFeatureSwapMenuAndBackButtons: + ConfMan.setBool("swap_menu_and_back_buttons", enable); + swapMenuAndBackButtons(enable); + break; + } + + OSystem_POSIX::setFeatureState(f, enable); +} + +bool OSystem_ANDROIDSDL::getFeatureState(Feature f) { + switch (f) { + case kFeatureTouchpadMode: + return ConfMan.getBool("touchpad_mouse_mode"); + break; + case kFeatureOnScreenControl: + return ConfMan.getBool("onscreen_control"); + break; + case kFeatureSwapMenuAndBackButtons: + return ConfMan.getBool("swap_menu_and_back_buttons"); + break; + default: + return OSystem_POSIX::getFeatureState(f); + break; + } +} + +bool OSystem_ANDROIDSDL::hasFeature(Feature f) { + return (f == kFeatureTouchpadMode || + f == kFeatureOnScreenControl || + f == kFeatureSwapMenuAndBackButtons || + f == OSystem_POSIX::getFeatureState(f)); +} diff --git a/backends/platform/androidsdl/androidsdl-sdl.h b/backends/platform/androidsdl/androidsdl-sdl.h index 6ebe5022eb..e83f610d10 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.h +++ b/backends/platform/androidsdl/androidsdl-sdl.h @@ -28,6 +28,14 @@ class OSystem_ANDROIDSDL : public OSystem_POSIX { public: virtual void initBackend(); + virtual void setFeatureState(Feature f, bool enable); + virtual bool getFeatureState(Feature f); + virtual bool hasFeature(Feature f); + void touchpadMode(bool enable); + void swapMenuAndBackButtons(bool enable); + void switchToDirectMouseMode(); + void switchToRelativeMouseMode(); + void showOnScreenControl(bool enable); #ifdef ENABLE_KEYMAPPER // FIXME: This just calls parent methods, is it needed? diff --git a/common/system.h b/common/system.h index 41f217fc0b..1b03fb0a15 100644 --- a/common/system.h +++ b/common/system.h @@ -336,7 +336,22 @@ public: * * This feature has no associated state. */ - kFeatureOpenUrl + kFeatureOpenUrl , + + /** + * show on-screen control + */ + kFeatureOnScreenControl, + + /** + * mouse emulation mode + */ + kFeatureTouchpadMode, + + /** + * swap menu and back buttons + */ + kFeatureSwapMenuAndBackButtons }; /** diff --git a/gui/options.cpp b/gui/options.cpp index 8b459b2739..53fba2f371 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -136,6 +136,10 @@ OptionsDialog::~OptionsDialog() { } void OptionsDialog::init() { + _enableControlSettings = false; + _onscreenCheckbox = 0; + _touchpadCheckbox = 0; + _swapMenuAndBackBtnsCheckbox = 0; _enableGraphicSettings = false; _gfxPopUp = 0; _gfxPopUpDesc = 0; @@ -202,6 +206,29 @@ void OptionsDialog::build() { _guioptionsString = ConfMan.get("guioptions", _domain); _guioptions = parseGameGUIOptions(_guioptionsString); } + + // Control options + if (g_system->hasFeature(OSystem::kFeatureOnScreenControl)) { + if (ConfMan.hasKey("onscreen_control", _domain)) { + bool onscreenState = g_system->getFeatureState(OSystem::kFeatureOnScreenControl); + if (_onscreenCheckbox != 0) + _onscreenCheckbox->setState(onscreenState); + } + } + if (g_system->hasFeature(OSystem::kFeatureTouchpadMode)) { + if (ConfMan.hasKey("touchpad_mouse_mode", _domain)) { + bool touchpadState = g_system->getFeatureState(OSystem::kFeatureTouchpadMode); + if (_touchpadCheckbox != 0) + _touchpadCheckbox->setState(touchpadState); + } + } + if (g_system->hasFeature(OSystem::kFeatureSwapMenuAndBackButtons)) { + if (ConfMan.hasKey("swap_menu_and_back_buttons", _domain)) { + bool state = g_system->getFeatureState(OSystem::kFeatureSwapMenuAndBackButtons); + if (_swapMenuAndBackBtnsCheckbox != 0) + _swapMenuAndBackBtnsCheckbox->setState(state); + } + } // Graphic options if (_fullscreenCheckbox) { @@ -380,6 +407,25 @@ void OptionsDialog::open() { } void OptionsDialog::apply() { + // Control options + if (_enableControlSettings) { + if (g_system->hasFeature(OSystem::kFeatureOnScreenControl)) { + if (ConfMan.getBool("onscreen_control", _domain) != _onscreenCheckbox->getState()) { + g_system->setFeatureState(OSystem::kFeatureOnScreenControl, _onscreenCheckbox->getState()); + } + } + if (g_system->hasFeature(OSystem::kFeatureTouchpadMode)) { + if (ConfMan.getBool("touchpad_mouse_mode", _domain) != _touchpadCheckbox->getState()) { + g_system->setFeatureState(OSystem::kFeatureTouchpadMode, _touchpadCheckbox->getState()); + } + } + if (g_system->hasFeature(OSystem::kFeatureSwapMenuAndBackButtons)) { + if (ConfMan.getBool("swap_menu_and_back_buttons", _domain) != _swapMenuAndBackBtnsCheckbox->getState()) { + g_system->setFeatureState(OSystem::kFeatureSwapMenuAndBackButtons, _swapMenuAndBackBtnsCheckbox->getState()); + } + } + } + // Graphic options bool graphicsModeChanged = false; if (_fullscreenCheckbox) { @@ -705,7 +751,7 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data Dialog::handleCommand(sender, cmd, data); } } - + void OptionsDialog::setGraphicSettingsState(bool enabled) { _enableGraphicSettings = enabled; @@ -831,6 +877,22 @@ void OptionsDialog::setSubtitleSettingsState(bool enabled) { _subSpeedSlider->setEnabled(ena); _subSpeedLabel->setEnabled(ena); } + + void OptionsDialog::addControlControls(GuiObject *boss, const Common::String &prefix) { + // Show On-Screen control + if (g_system->hasFeature(OSystem::kFeatureOnScreenControl)) + _onscreenCheckbox = new CheckboxWidget(boss, prefix + "grOnScreenCheckbox", _("Show On-screen control")); + + // Touchpad Mouse mode + if (g_system->hasFeature(OSystem::kFeatureTouchpadMode)) + _touchpadCheckbox = new CheckboxWidget(boss, prefix + "grTouchpadCheckbox", _("Touchpad mouse mode")); + + // Swap menu and back buttons + if (g_system->hasFeature(OSystem::kFeatureSwapMenuAndBackButtons)) + _swapMenuAndBackBtnsCheckbox = new CheckboxWidget(boss, prefix + "grSwapMenuAndBackBtnsCheckbox", _("Swap Menu and Back buttons")); + + _enableControlSettings = true; + } void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &prefix) { const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes(); @@ -1279,7 +1341,17 @@ GlobalOptionsDialog::~GlobalOptionsDialog() { void GlobalOptionsDialog::build() { // The tab widget TabWidget *tab = new TabWidget(this, "GlobalOptions.TabWidget"); - + + // + // The control tab (currently visible only for AndroidSDL platform, visibility checking by features + // + if (g_system->hasFeature(OSystem::kFeatureTouchpadMode) || + g_system->hasFeature(OSystem::kFeatureOnScreenControl) || + g_system->hasFeature(OSystem::kFeatureSwapMenuAndBackButtons)) { + tab->addTab(_("Control")); + addControlControls(tab, "GlobalOptions_Control."); + } + // // 1) The graphics tab // diff --git a/gui/options.h b/gui/options.h index 1b15258ab5..6b6cb92378 100644 --- a/gui/options.h +++ b/gui/options.h @@ -86,6 +86,8 @@ protected: virtual void clean(); void rebuild(); + + void addControlControls(GuiObject *boss, const Common::String &prefix); void addGraphicControls(GuiObject *boss, const Common::String &prefix); void addAudioControls(GuiObject *boss, const Common::String &prefix); void addMIDIControls(GuiObject *boss, const Common::String &prefix); @@ -112,6 +114,16 @@ protected: int _pathsTabId; private: + + // + // Control controls + // + bool _enableControlSettings; + + CheckboxWidget *_touchpadCheckbox; + CheckboxWidget *_onscreenCheckbox; + CheckboxWidget *_swapMenuAndBackBtnsCheckbox; + // // Graphics controls // diff --git a/gui/themes/default.inc b/gui/themes/default.inc index a83fd788ad..d8baae8d0e 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -813,6 +813,19 @@ const char *defaultXML1 = "<?xml version = '1.0'?>" "</layout>" "</layout>" "</dialog>" +"<dialog name='GlobalOptions_Control' overlays='Dialog.GlobalOptions.TabWidget'>" +"<layout type='vertical' padding='16,16,16,16' spacing='8'>" +"<widget name='grOnScreenCheckbox' " +"type='Checkbox' " +"/>" +"<widget name='grTouchpadCheckbox' " +"type='Checkbox' " +"/>" +"<widget name='grSwapMenuAndBackBtnsCheckbox' " +"type='Checkbox' " +"/>" +"</layout>" +"</dialog>" "<dialog name='GlobalOptions_Graphics' overlays='Dialog.GlobalOptions.TabWidget'>" "<layout type='vertical' padding='16,16,16,16' spacing='8'>" "<layout type='horizontal' padding='0,0,0,0' spacing='10' center='true'>" @@ -2355,6 +2368,19 @@ const char *defaultXML1 = "<?xml version = '1.0'?>" "</layout>" "</layout>" "</dialog>" +"<dialog name='GlobalOptions_Control' overlays='Dialog.GlobalOptions.TabWidget'>" +"<layout type='vertical' padding='16,16,16,16' spacing='6'>" +"<widget name='grOnScreenCheckbox' " +"type='Checkbox' " +"/>" +"<widget name='grTouchpadCheckbox' " +"type='Checkbox' " +"/>" +"<widget name='grSwapMenuAndBackBtnsCheckbox' " +"type='Checkbox' " +"/>" +"</layout>" +"</dialog>" "<dialog name='GlobalOptions_Graphics' overlays='Dialog.GlobalOptions.TabWidget'>" "<layout type='vertical' padding='16,16,16,16' spacing='8'>" "<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'>" diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex 400b997b93..d90289a4be 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index b3100d4b92..aa91cdb35f 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -237,6 +237,20 @@ </layout> </layout> </dialog> + + <dialog name = 'GlobalOptions_Control' overlays = 'Dialog.GlobalOptions.TabWidget'> + <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> + <widget name = 'grOnScreenCheckbox' + type = 'Checkbox' + /> + <widget name = 'grTouchpadCheckbox' + type = 'Checkbox' + /> + <widget name = 'grSwapMenuAndBackBtnsCheckbox' + type = 'Checkbox' + /> + </layout> + </dialog> <dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'> <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 7879e05a97..c925a39d18 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -234,6 +234,20 @@ </layout> </layout> </dialog> + + <dialog name = 'GlobalOptions_Control' overlays = 'Dialog.GlobalOptions.TabWidget'> + <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> + <widget name = 'grOnScreenCheckbox' + type = 'Checkbox' + /> + <widget name = 'grTouchpadCheckbox' + type = 'Checkbox' + /> + <widget name = 'grSwapMenuAndBackBtnsCheckbox' + type = 'Checkbox' + /> + </layout> + </dialog> <dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'> <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip Binary files differindex 673d67ed87..f10102503e 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 9cadc11e13..80b913a3a4 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -251,6 +251,20 @@ </layout> </layout> </dialog> + + <dialog name = 'GlobalOptions_Control' overlays = 'Dialog.GlobalOptions.TabWidget'> + <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> + <widget name = 'grOnScreenCheckbox' + type = 'Checkbox' + /> + <widget name = 'grTouchpadCheckbox' + type = 'Checkbox' + /> + <widget name = 'grSwapMenuAndBackBtnsCheckbox' + type = 'Checkbox' + /> + </layout> + </dialog> <dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'> <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 7ef5fc5ee1..308ba44b7e 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -232,6 +232,20 @@ </layout> </layout> </dialog> + + <dialog name = 'GlobalOptions_Control' overlays = 'Dialog.GlobalOptions.TabWidget'> + <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> + <widget name = 'grOnScreenCheckbox' + type = 'Checkbox' + /> + <widget name = 'grTouchpadCheckbox' + type = 'Checkbox' + /> + <widget name = 'grSwapMenuAndBackBtnsCheckbox' + type = 'Checkbox' + /> + </layout> + </dialog> <dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'> <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> |