diff options
author | Bastien Bouclet | 2019-11-07 11:02:00 +0100 |
---|---|---|
committer | Bastien Bouclet | 2019-11-07 11:02:00 +0100 |
commit | 6901ee0242c128d3b6026f83a10da4ca90e265e0 (patch) | |
tree | aa901fd36658b97bae8f3e83c21aafa37a2b1595 | |
parent | e34d27c1bdc7b58368767d250494ad5946a0bf67 (diff) | |
download | scummvm-rg350-6901ee0242c128d3b6026f83a10da4ca90e265e0.tar.gz scummvm-rg350-6901ee0242c128d3b6026f83a10da4ca90e265e0.tar.bz2 scummvm-rg350-6901ee0242c128d3b6026f83a10da4ca90e265e0.zip |
3DS: Use the full resolution for the overlay on the top screen
-rw-r--r-- | backends/platform/3ds/gui.cpp | 46 | ||||
-rw-r--r-- | backends/platform/3ds/gui.h | 41 | ||||
-rw-r--r-- | backends/platform/3ds/module.mk | 1 | ||||
-rw-r--r-- | backends/platform/3ds/options-dialog.cpp | 41 | ||||
-rw-r--r-- | backends/platform/3ds/options-dialog.h | 11 | ||||
-rw-r--r-- | backends/platform/3ds/osystem-events.cpp | 77 | ||||
-rw-r--r-- | backends/platform/3ds/osystem-graphics.cpp | 8 | ||||
-rw-r--r-- | backends/platform/3ds/osystem.cpp | 1 | ||||
-rw-r--r-- | backends/platform/3ds/osystem.h | 5 | ||||
-rw-r--r-- | po/POTFILES | 2 |
10 files changed, 104 insertions, 129 deletions
diff --git a/backends/platform/3ds/gui.cpp b/backends/platform/3ds/gui.cpp deleted file mode 100644 index 0883d5a102..0000000000 --- a/backends/platform/3ds/gui.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "backends/platform/3ds/gui.h" -#include "common/system.h" - -StatusMessageDialog* StatusMessageDialog::_opened = 0; - -StatusMessageDialog::StatusMessageDialog(const Common::String &message, uint32 duration) - : MessageDialog(message, 0, 0) { - _timer = g_system->getMillis() + duration; - if (_opened) - _opened->close(); - _opened = this; -} - -void StatusMessageDialog::handleTickle() { - MessageDialog::handleTickle(); - if (g_system->getMillis() > _timer) - close(); -} - -void StatusMessageDialog::close() { - GUI::Dialog::close(); - if (_opened) - _opened = 0; -} diff --git a/backends/platform/3ds/gui.h b/backends/platform/3ds/gui.h deleted file mode 100644 index 8e82c6c851..0000000000 --- a/backends/platform/3ds/gui.h +++ /dev/null @@ -1,41 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef GUI_3DS_H -#define GUI_3DS_H - -#include "gui/message.h" - -class StatusMessageDialog : public GUI::MessageDialog { -public: - StatusMessageDialog(const Common::String &message, uint32 duration); - - void handleTickle(); - -protected: - virtual void close(); - - uint32 _timer; - static StatusMessageDialog* _opened; -}; - -#endif // GUI_3DS_H diff --git a/backends/platform/3ds/module.mk b/backends/platform/3ds/module.mk index 3eb15aef81..16fbd5fbca 100644 --- a/backends/platform/3ds/module.mk +++ b/backends/platform/3ds/module.mk @@ -4,7 +4,6 @@ MODULE_OBJS := \ main.o \ shader.shbin.o \ sprite.o \ - gui.o \ config.o \ options-dialog.o \ osystem.o \ diff --git a/backends/platform/3ds/options-dialog.cpp b/backends/platform/3ds/options-dialog.cpp index a6be649ac0..d57daa7cdc 100644 --- a/backends/platform/3ds/options-dialog.cpp +++ b/backends/platform/3ds/options-dialog.cpp @@ -61,7 +61,7 @@ OptionsDialog::OptionsDialog() : GUI::Dialog(20, 20, 280, 200) { _screenRadioGroup->setValue(config.screen); new GUI::StaticTextWidget(this, 0, 100, 110, 15, _("C-Pad Sensitivity:"), Graphics::kTextAlignRight); - _sensitivity = new GUI::SliderWidget(this, 115, 100, 160, 15, "TODO: Add tooltip", 1); + _sensitivity = new GUI::SliderWidget(this, 115, 100, 160, 15); _sensitivity->setMinValue(-15); _sensitivity->setMaxValue(30); _sensitivity->setValue(config.sensitivity); @@ -72,20 +72,41 @@ OptionsDialog::~OptionsDialog() { optionMenuOpened = false; } -void OptionsDialog::updateConfigManager() { - config.showCursor = _showCursorCheckbox->getState(); - config.snapToBorder = _snapToBorderCheckbox->getState(); - config.stretchToFit = _stretchToFitCheckbox->getState(); - config.sensitivity = _sensitivity->getValue(); - config.screen = _screenRadioGroup->getValue(); - saveConfig(); - loadConfig(); +bool OptionsDialog::getShowCursor() const { + return _showCursorCheckbox->getState(); +} + +bool OptionsDialog::getSnapToBorder() const { + return _snapToBorderCheckbox->getState(); +} + +bool OptionsDialog::getStretchToFit() const { + return _stretchToFitCheckbox->getState(); +} + +int OptionsDialog::getSensitivity() const { + return _sensitivity->getValue(); +} + +int OptionsDialog::getScreen() const { + return _screenRadioGroup->getValue(); +} + +void OptionsDialog::reflowLayout() { + const int screenW = g_system->getOverlayWidth(); + const int screenH = g_system->getOverlayHeight(); + + // Center the dialog + _x = (screenW - getWidth()) / 2; + _y = (screenH - getHeight()) / 2; + + GUI::Dialog::reflowLayout(); } void OptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { switch(cmd) { case GUI::kOKCmd: - updateConfigManager(); + setResult(1); // Fall through case GUI::kCloseCmd: close(); diff --git a/backends/platform/3ds/options-dialog.h b/backends/platform/3ds/options-dialog.h index d8c0d7bc7d..68ff75e242 100644 --- a/backends/platform/3ds/options-dialog.h +++ b/backends/platform/3ds/options-dialog.h @@ -50,9 +50,16 @@ public: OptionsDialog(); ~OptionsDialog(); + // GuiObject API + void reflowLayout() override; + + bool getShowCursor() const; + bool getSnapToBorder() const; + bool getStretchToFit() const; + int getSensitivity() const; + int getScreen() const; protected: - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - void updateConfigManager(); + void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override; GUI::SliderWidget *_sensitivity; GUI::CheckboxWidget *_showCursorCheckbox; diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp index 8c06187b09..fb30d665a0 100644 --- a/backends/platform/3ds/osystem-events.cpp +++ b/backends/platform/3ds/osystem-events.cpp @@ -22,13 +22,14 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_time_h -#include "osystem.h" +#include "backends/platform/3ds/osystem.h" + +#include "backends/platform/3ds/config.h" +#include "backends/platform/3ds/options-dialog.h" #include "backends/timer/default/default-timer.h" -#include "gui/gui-manager.h" +#include "common/translation.h" #include "engines/engine.h" -#include "gui.h" -#include "options-dialog.h" -#include "config.h" +#include "gui/gui-manager.h" namespace _3DS { @@ -149,29 +150,29 @@ static void eventThreadFunc(void *arg) { if (keysPressed & KEY_L) { if (g_gui.isActive()) { // TODO: Prevent the magnify effect from updating while the GUI is active - osys->displayMessageOnOSD("Magnify Mode cannot be activated in menus."); + osys->displayMessageOnOSD(_("Magnify Mode cannot be activated in menus.")); } else if (config.screen != kScreenBoth && osys->getMagnifyMode() == MODE_MAGOFF) { // TODO: Automatically enable both screens while magnify mode is on - osys->displayMessageOnOSD("Magnify Mode can only be activated\n when both screens are enabled."); + osys->displayMessageOnOSD(_("Magnify Mode can only be activated\n when both screens are enabled.")); } else if (osys->getWidth() <= 400 && osys->getHeight() <= 240) { - osys->displayMessageOnOSD("In-game resolution too small to magnify."); + osys->displayMessageOnOSD(_("In-game resolution too small to magnify.")); } else { if (osys->getMagnifyMode() == MODE_MAGOFF) { osys->setMagnifyMode(MODE_MAGON); if (inputMode == MODE_DRAG) { inputMode = MODE_HOVER; - osys->displayMessageOnOSD("Magnify Mode On. Switching to Hover Mode..."); + osys->displayMessageOnOSD(_("Magnify Mode On. Switching to Hover Mode...")); } else { - osys->displayMessageOnOSD("Magnify Mode On"); + osys->displayMessageOnOSD(_("Magnify Mode On")); } } else { osys->setMagnifyMode(MODE_MAGOFF); osys->updateSize(); if (savedInputMode == MODE_DRAG) { inputMode = savedInputMode; - osys->displayMessageOnOSD("Magnify Mode Off. Reactivating Drag Mode..."); + osys->displayMessageOnOSD(_("Magnify Mode Off. Reactivating Drag Mode...")); } else { - osys->displayMessageOnOSD("Magnify Mode Off"); + osys->displayMessageOnOSD(_("Magnify Mode Off")); } } } @@ -179,13 +180,13 @@ static void eventThreadFunc(void *arg) { if (keysPressed & KEY_R) { if (inputMode == MODE_DRAG) { inputMode = savedInputMode = MODE_HOVER; - osys->displayMessageOnOSD("Hover Mode"); + osys->displayMessageOnOSD(_("Hover Mode")); } else { if (osys->getMagnifyMode() == MODE_MAGOFF) { inputMode = savedInputMode = MODE_DRAG; - osys->displayMessageOnOSD("Drag Mode"); + osys->displayMessageOnOSD(_("Drag Mode")); } else - osys->displayMessageOnOSD("Cannot Switch to Drag Mode while Magnify Mode is On"); + osys->displayMessageOnOSD(_("Cannot Switch to Drag Mode while Magnify Mode is On")); } } if (keysPressed & KEY_A || keysPressed & KEY_DLEFT || keysReleased & KEY_A || keysReleased & KEY_DLEFT) { @@ -238,9 +239,9 @@ static void eventThreadFunc(void *arg) { osys->updateSize(); if (savedInputMode == MODE_DRAG) { inputMode = savedInputMode; - osys->displayMessageOnOSD("Magnify Mode Off. Reactivating Drag Mode.\nReturning to Launcher..."); + osys->displayMessageOnOSD(_("Magnify Mode Off. Reactivating Drag Mode.\nReturning to Launcher...")); } else - osys->displayMessageOnOSD("Magnify Mode Off. Returning to Launcher..."); + osys->displayMessageOnOSD(_("Magnify Mode Off. Returning to Launcher...")); } } @@ -309,8 +310,12 @@ void OSystem_3DS::destroyEvents() { void OSystem_3DS::transformPoint(touchPosition &point) { if (!_overlayVisible) { - point.px = static_cast<float>(point.px) / _gameBottomTexture.getScaleX() - _gameBottomX; - point.py = static_cast<float>(point.py) / _gameBottomTexture.getScaleY() - _gameBottomY; + point.px = static_cast<float>(point.px) / _gameBottomTexture.getScaleX() - _gameBottomTexture.getPosX(); + point.py = static_cast<float>(point.py) / _gameBottomTexture.getScaleY() - _gameBottomTexture.getPosY(); + } else { + if (config.screen == kScreenTop) { + point.px = (uint32) point.px * 400 / 320; // TODO: Fix horizontal speed + } } } @@ -323,12 +328,7 @@ bool OSystem_3DS::pollEvent(Common::Event &event) { if (optionMenuOpening) { optionMenuOpening = false; - OptionsDialog dialog; - if (g_engine) - g_engine->pauseEngine(true); - dialog.runModal(); - if (g_engine) - g_engine->pauseEngine(false); + runOptionsDialog(); } Common::StackLock lock(*eventMutex); @@ -340,4 +340,31 @@ bool OSystem_3DS::pollEvent(Common::Event &event) { return true; } +void OSystem_3DS::runOptionsDialog() { + OptionsDialog dialog; + if (g_engine) + g_engine->pauseEngine(true); + int result = dialog.runModal(); + if (g_engine) + g_engine->pauseEngine(false); + + if (result > 0) { + int oldScreen = config.screen; + + config.showCursor = dialog.getShowCursor(); + config.snapToBorder = dialog.getSnapToBorder(); + config.stretchToFit = dialog.getStretchToFit(); + config.sensitivity = dialog.getSensitivity(); + config.screen = dialog.getScreen(); + + saveConfig(); + loadConfig(); + + if (config.screen != oldScreen) { + _screenChangeId++; + g_gui.checkScreenChange(); + } + } +} + } // namespace _3DS diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp index 5c65cac648..8fb92f4d48 100644 --- a/backends/platform/3ds/osystem-graphics.cpp +++ b/backends/platform/3ds/osystem-graphics.cpp @@ -146,12 +146,16 @@ int OSystem_3DS::getGraphicsMode() const { void OSystem_3DS::initSize(uint width, uint height, const Graphics::PixelFormat *format) { debug("3ds initsize w:%d h:%d", width, height); + int oldScreen = config.screen; loadConfig(); + if (config.screen != oldScreen) { + _screenChangeId++; + } _gameWidth = width; _gameHeight = height; _gameTopTexture.create(width, height, _pfGameTexture); - _overlay.create(getOverlayWidth(), getOverlayHeight(), _pfGameTexture); + _overlay.create(400, 320, _pfGameTexture); _topHalfWidth = _topWidth / 2; _topHalfHeight = _topHeight / 2; @@ -560,7 +564,7 @@ int16 OSystem_3DS::getOverlayHeight() { } int16 OSystem_3DS::getOverlayWidth() { - return 320; + return config.screen == kScreenTop ? 400 : 320; } bool OSystem_3DS::showMouse(bool visible) { diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp index aa0b3a7503..2003795077 100644 --- a/backends/platform/3ds/osystem.cpp +++ b/backends/platform/3ds/osystem.cpp @@ -77,6 +77,7 @@ OSystem_3DS::OSystem_3DS(): _topWidth(400), _topHeight(240), _overlayVisible(false), + _screenChangeId(0), _magnifyMode(MODE_MAGOFF), exiting(false), sleeping(false) diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h index 51aa40ae83..70cd475cf9 100644 --- a/backends/platform/3ds/osystem.h +++ b/backends/platform/3ds/osystem.h @@ -105,7 +105,7 @@ public: virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const; void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL); - virtual int getScreenChangeID() const { return 0; }; + virtual int getScreenChangeID() const { return _screenChangeId; }; void beginGFXTransaction(); OSystem::TransactionError endGFXTransaction(); @@ -152,7 +152,6 @@ public: void setMagnifyMode(MagnifyMode mode); MagnifyMode getMagnifyMode(){ return _magnifyMode; } - private: void initGraphics(); void destroyGraphics(); @@ -160,6 +159,7 @@ private: void destroyAudio(); void initEvents(); void destroyEvents(); + void runOptionsDialog(); void flushGameScreen(); void flushCursor(); @@ -199,6 +199,7 @@ private: int _screenShakeOffset; bool _overlayVisible; + int _screenChangeId; DVLB_s *_dvlb; shaderProgram_s _program; diff --git a/po/POTFILES b/po/POTFILES index 94b14e723a..dcce351b76 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -75,6 +75,8 @@ backends/networking/sdl_net/handlers/uploadfilehandler.cpp backends/networking/sdl_net/handlerutils.cpp backends/networking/sdl_net/localwebserver.cpp backends/networking/sdl_net/uploadfileclienthandler.cpp +backends/platform/3ds/options-dialog.cpp +backends/platform/3ds/osystem-events.cpp backends/platform/ds/arm9/source/dsoptions.cpp backends/platform/ios7/ios7_osys_events.cpp backends/platform/iphone/osys_events.cpp |