[Scummvm-git-logs] scummvm master -> 7e0309b175dab744f72e4e8454fa6afa38ab7e9b
sev-
noreply at scummvm.org
Tue Apr 23 19:09:22 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a1cb48c888 3DS: Rewrite the options dialog to use OptionsContainerWidget
7e0309b175 3DS: Update the documentation to reflect the options changes
Commit: a1cb48c8887f51b3da9678e4feb45357b71bdad3
https://github.com/scummvm/scummvm/commit/a1cb48c8887f51b3da9678e4feb45357b71bdad3
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-04-23T21:09:17+02:00
Commit Message:
3DS: Rewrite the options dialog to use OptionsContainerWidget
Changed paths:
A backends/platform/3ds/options.cpp
R backends/platform/3ds/config.cpp
R backends/platform/3ds/config.h
R backends/platform/3ds/options-dialog.cpp
R backends/platform/3ds/options-dialog.h
backends/platform/3ds/module.mk
backends/platform/3ds/osystem-events.cpp
backends/platform/3ds/osystem-graphics.cpp
backends/platform/3ds/osystem.cpp
backends/platform/3ds/osystem.h
po/POTFILES
diff --git a/backends/platform/3ds/config.cpp b/backends/platform/3ds/config.cpp
deleted file mode 100644
index d2bb551f408..00000000000
--- a/backends/platform/3ds/config.cpp
+++ /dev/null
@@ -1,88 +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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-#include "backends/platform/3ds/config.h"
-#include "backends/platform/3ds/osystem.h"
-#include "backends/platform/3ds/options-dialog.h"
-#include "common/config-manager.h"
-
-namespace N3DS {
-
-Config config;
-static Common::String prefix = "3ds_";
-
-static bool confGetBool(Common::String key, bool defaultVal) {
- if (ConfMan.hasKey(prefix + key)) {
- return ConfMan.getBool(prefix + key);
- }
- return defaultVal;
-}
-
-static void confSetBool(Common::String key, bool val) {
- ConfMan.setBool(prefix + key, val);
-}
-
-static int confGetInt(Common::String key, int defaultVal) {
- if (ConfMan.hasKey(prefix + key)) {
- return ConfMan.getInt(prefix + key);
- }
- return defaultVal;
-}
-
-static void confSetInt(Common::String key, int val) {
- ConfMan.setInt(prefix + key, val);
-}
-
-void loadConfig() {
- config.showCursor = confGetBool("showcursor", true);
- config.snapToBorder = confGetBool("snaptoborder", true);
- config.stretchToFit = confGetBool("stretchtofit", false);
- config.screen = confGetInt("screen", kScreenBoth);
-
- // Turn off the backlight of any screen not used
- if (R_SUCCEEDED(gspLcdInit())) {
- if (config.screen == kScreenTop) {
- GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_TOP);
- GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_BOTTOM);
- } else if (config.screen == kScreenBottom) {
- GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTTOM);
- GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_TOP);
- } else {
- GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTH);
- }
- gspLcdExit();
- }
-
- OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
- osys->updateConfig();
-}
-
-void saveConfig() {
- confSetBool("showcursor", config.showCursor);
- confSetBool("snaptoborder", config.snapToBorder);
- confSetBool("stretchtofit", config.stretchToFit);
- confSetInt("screen", config.screen);
- ConfMan.flushToDisk();
-}
-
-} // namespace N3DS
diff --git a/backends/platform/3ds/config.h b/backends/platform/3ds/config.h
deleted file mode 100644
index b860b5b43a5..00000000000
--- a/backends/platform/3ds/config.h
+++ /dev/null
@@ -1,43 +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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef CONFIG_3DS_H
-#define CONFIG_3DS_H
-
-#include "common/str.h"
-
-namespace N3DS {
-
-struct Config {
- bool showCursor;
- bool snapToBorder;
- bool stretchToFit;
- int screen;
-};
-
-extern Config config;
-
-void loadConfig();
-void saveConfig();
-
-} // namespace N3DS
-
-#endif // CONFIG_3DS_H
diff --git a/backends/platform/3ds/module.mk b/backends/platform/3ds/module.mk
index 16fbd5fbca6..ee08fa66ec7 100644
--- a/backends/platform/3ds/module.mk
+++ b/backends/platform/3ds/module.mk
@@ -4,8 +4,7 @@ MODULE_OBJS := \
main.o \
shader.shbin.o \
sprite.o \
- config.o \
- options-dialog.o \
+ options.o \
osystem.o \
osystem-graphics.o \
osystem-audio.o \
diff --git a/backends/platform/3ds/options-dialog.cpp b/backends/platform/3ds/options-dialog.cpp
deleted file mode 100644
index 721764e9a4c..00000000000
--- a/backends/platform/3ds/options-dialog.cpp
+++ /dev/null
@@ -1,109 +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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-#include "options-dialog.h"
-#include "config.h"
-#include "gui/dialog.h"
-#include "gui/gui-manager.h"
-#include "gui/widgets/list.h"
-#include "gui/widgets/tab.h"
-#include "osystem.h"
-#include "gui/widgets/popup.h"
-
-#include "common/translation.h"
-#include "common/ustr.h"
-
-namespace N3DS {
-
-bool optionMenuOpened = false;
-
-OptionsDialog::OptionsDialog() : GUI::Dialog(20, 20, 280, 200) {
-
- optionMenuOpened = true;
-
- new GUI::ButtonWidget(this, 120, 180, 72, 16, _("~C~lose"), Common::U32String(), GUI::kCloseCmd);
- new GUI::ButtonWidget(this, 200, 180, 72, 16, _("~S~ave"), Common::U32String(), GUI::kOKCmd);
-
- _showCursorCheckbox = new GUI::CheckboxWidget(this, 5, 5, 130, 20, _("Show mouse cursor"), Common::U32String(), 0, 'T');
- _showCursorCheckbox->setState(config.showCursor);
-
- _snapToBorderCheckbox = new GUI::CheckboxWidget(this, 5, 22, 130, 20, _("Snap to edges"), Common::U32String(), 0, 'T');
- _snapToBorderCheckbox->setState(config.snapToBorder);
-
- _stretchToFitCheckbox = new GUI::CheckboxWidget(this, 140, 5, 130, 20, _("Stretch to fit"), Common::U32String(), 0, 'T');
- _stretchToFitCheckbox->setState(config.stretchToFit);
-
- new GUI::StaticTextWidget(this, 0, 60, 110, 15, _("Use Screen:"), Graphics::kTextAlignRight);
- _screenRadioGroup = new GUI::RadiobuttonGroup(this, kScreenRadioGroup);
- _screenTopRadioWidget = new GUI::RadiobuttonWidget(this, 120, 50, 60, 20, _screenRadioGroup, kScreenTop, _c("Top", "3ds-screen"));
- _screenBottomRadioWidget = new GUI::RadiobuttonWidget(this, 190, 50, 80, 20, _screenRadioGroup, kScreenBottom, _c("Bottom", "3ds-screen"));
- _screenBothRadioWidget = new GUI::RadiobuttonWidget(this, 155, 70, 80, 20, _screenRadioGroup, kScreenBoth, _c("Both", "3ds-screen"));
- _screenRadioGroup->setValue(config.screen);
-}
-
-OptionsDialog::~OptionsDialog() {
- optionMenuOpened = false;
-}
-
-bool OptionsDialog::getShowCursor() const {
- return _showCursorCheckbox->getState();
-}
-
-bool OptionsDialog::getSnapToBorder() const {
- return _snapToBorderCheckbox->getState();
-}
-
-bool OptionsDialog::getStretchToFit() const {
- return _stretchToFitCheckbox->getState();
-}
-
-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:
- setResult(1);
- // Fall through
- case GUI::kCloseCmd:
- close();
- break;
- default:
- Dialog::handleCommand(sender, cmd, data);
- break;
- }
-}
-
-} // namespace N3DS
diff --git a/backends/platform/3ds/options-dialog.h b/backends/platform/3ds/options-dialog.h
deleted file mode 100644
index f5a2e4eeee1..00000000000
--- a/backends/platform/3ds/options-dialog.h
+++ /dev/null
@@ -1,75 +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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef OPTIONS_DIALOG_3DS_H
-#define OPTIONS_DIALOG_3DS_H
-
-
-#include "common/scummsys.h"
-#include "common/str.h"
-#include "gui/object.h"
-#include "gui/widget.h"
-#include "gui/dialog.h"
-#include "gui/widgets/tab.h"
-#include "scumm/dialogs.h"
-
-namespace N3DS {
-
-enum {
- kSave = 0x10000000,
- kScreenRadioGroup,
- kScreenTop,
- kScreenBottom,
- kScreenBoth,
-};
-
-extern bool optionMenuOpened;
-
-class OptionsDialog : public GUI::Dialog {
-
-public:
- OptionsDialog();
- ~OptionsDialog();
-
- // GuiObject API
- void reflowLayout() override;
-
- bool getShowCursor() const;
- bool getSnapToBorder() const;
- bool getStretchToFit() const;
- int getSensitivity() const;
- int getScreen() const;
-protected:
- void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
-
- GUI::CheckboxWidget *_showCursorCheckbox;
- GUI::CheckboxWidget *_snapToBorderCheckbox;
- GUI::CheckboxWidget *_stretchToFitCheckbox;
-
- GUI::RadiobuttonGroup *_screenRadioGroup;
- GUI::RadiobuttonWidget *_screenTopRadioWidget;
- GUI::RadiobuttonWidget *_screenBottomRadioWidget;
- GUI::RadiobuttonWidget *_screenBothRadioWidget;
-};
-
-} // namespace N3DS
-
-#endif // OPTIONS_DIALOG_3DS_H
diff --git a/backends/platform/3ds/options.cpp b/backends/platform/3ds/options.cpp
new file mode 100644
index 00000000000..d5c99b41393
--- /dev/null
+++ b/backends/platform/3ds/options.cpp
@@ -0,0 +1,163 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
+#include "backends/platform/3ds/osystem.h"
+
+#include "gui/gui-manager.h"
+#include "gui/ThemeEval.h"
+#include "gui/widget.h"
+#include "gui/widgets/list.h"
+#include "gui/widgets/popup.h"
+
+#include "common/translation.h"
+
+namespace N3DS {
+
+class N3DSOptionsWidget : public GUI::OptionsContainerWidget {
+public:
+ explicit N3DSOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain);
+ ~N3DSOptionsWidget() override;
+
+ // OptionsContainerWidget API
+ void load() override;
+ bool save() override;
+ bool hasKeys() override;
+ void setEnabled(bool e) override;
+
+private:
+ // OptionsContainerWidget API
+ void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
+
+ GUI::CheckboxWidget *_showCursorCheckbox;
+ GUI::CheckboxWidget *_snapToBorderCheckbox;
+ GUI::CheckboxWidget *_stretchToFitCheckbox;
+
+ GUI::StaticTextWidget *_screenDesc;
+ GUI::PopUpWidget *_screenPopUp;
+
+ bool _enabled;
+};
+
+N3DSOptionsWidget::N3DSOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
+ OptionsContainerWidget(boss, name, "N3DSOptionsDialog", false, domain), _enabled(true) {
+
+ _showCursorCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "N3DSOptionsDialog.ShowCursor", _("Show mouse cursor"), Common::U32String(), 0, 'T');
+ _snapToBorderCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "N3DSOptionsDialog.SnapToBorder", _("Snap to edges"), Common::U32String(), 0, 'T');
+ _stretchToFitCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "N3DSOptionsDialog.StretchToFit", _("Stretch to fit"), Common::U32String(), 0, 'T');
+
+ _screenDesc = new GUI::StaticTextWidget(widgetsBoss(), "N3DSOptionsDialog.ScreenText", _("Use Screen:"));
+ _screenPopUp = new GUI::PopUpWidget(widgetsBoss(), "N3DSOptionsDialog.Screen");
+ _screenPopUp->appendEntry(_c("Top", "3ds-screen"), kScreenTop);
+ _screenPopUp->appendEntry(_c("Bottom", "3ds-screen"), kScreenBottom);
+ _screenPopUp->appendEntry(_c("Both", "3ds-screen"), kScreenBoth);
+}
+
+N3DSOptionsWidget::~N3DSOptionsWidget() {
+}
+
+void N3DSOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
+ layouts.addDialog(layoutName, overlayedLayout)
+ .addLayout(GUI::ThemeLayout::kLayoutVertical)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("ShowCursor", "Checkbox")
+ .addWidget("SnapToBorder", "Checkbox")
+ .addWidget("StretchToFit", "Checkbox")
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(16, 16, 0, 0)
+ .addWidget("ScreenText", "OptionsLabel")
+ .addWidget("Screen", "PopUp")
+ .closeLayout()
+ .closeLayout()
+ .closeDialog();
+}
+
+void N3DSOptionsWidget::load() {
+ _showCursorCheckbox->setState(ConfMan.getBool("3ds_showcursor", _domain));
+ _snapToBorderCheckbox->setState(ConfMan.getBool("3ds_snaptoborder", _domain));
+ _stretchToFitCheckbox->setState(ConfMan.getBool("3ds_stretchtofit", _domain));
+ _screenPopUp->setSelectedTag(ConfMan.getInt("3ds_screen", _domain));
+}
+
+bool N3DSOptionsWidget::save() {
+ if (_enabled) {
+ ConfMan.setBool("3ds_showcursor", _showCursorCheckbox->getState(), _domain);
+ ConfMan.setBool("3ds_snaptoborder", _snapToBorderCheckbox->getState(), _domain);
+ ConfMan.setBool("3ds_stretchtofit", _stretchToFitCheckbox->getState(), _domain);
+ ConfMan.setInt("3ds_screen", _screenPopUp->getSelectedTag(), _domain);
+ } else {
+ ConfMan.removeKey("3ds_showcursor", _domain);
+ ConfMan.removeKey("3ds_snaptoborder", _domain);
+ ConfMan.removeKey("3ds_stretchtofit", _domain);
+ ConfMan.removeKey("3ds_screen", _domain);
+ }
+
+ return true;
+}
+
+bool N3DSOptionsWidget::hasKeys() {
+ return ConfMan.hasKey("3ds_showcursor", _domain) ||
+ ConfMan.hasKey("3ds_snaptoborder", _domain) ||
+ ConfMan.hasKey("3ds_stretchtofit", _domain) ||
+ ConfMan.hasKey("3ds_screen", _domain);
+}
+
+void N3DSOptionsWidget::setEnabled(bool e) {
+ _enabled = e;
+
+ _showCursorCheckbox->setEnabled(e);
+ _snapToBorderCheckbox->setEnabled(e);
+ _stretchToFitCheckbox->setEnabled(e);
+ _screenDesc->setEnabled(e);
+ _screenPopUp->setEnabled(e);
+}
+
+
+GUI::OptionsContainerWidget *OSystem_3DS::buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
+ return new N3DSOptionsWidget(boss, name, target);
+}
+
+void OSystem_3DS::registerDefaultSettings(const Common::String &target) const {
+ ConfMan.registerDefault("3ds_showcursor", true);
+ ConfMan.registerDefault("3ds_snaptoborder", true);
+ ConfMan.registerDefault("3ds_stretchtofit", false);
+ ConfMan.registerDefault("3ds_screen", kScreenBoth);
+}
+
+void OSystem_3DS::applyBackendSettings() {
+ int oldScreen = _screen;
+
+ _showCursor = ConfMan.getBool("3ds_showcursor");
+ _snapToBorder = ConfMan.getBool("3ds_snaptoborder");
+ _stretchToFit = ConfMan.getBool("3ds_stretchtofit");
+ _screen = (Screen)ConfMan.getInt("3ds_screen");
+
+ updateBacklight();
+ updateConfig();
+
+ if (_screen != oldScreen) {
+ _screenChangeId++;
+ g_gui.checkScreenChange();
+ }
+}
+
+} // namespace N3DS
diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
index 64c59337926..a911d6e5c08 100644
--- a/backends/platform/3ds/osystem-events.cpp
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -29,8 +29,6 @@
#include "backends/keymapper/keymap.h"
#include "backends/keymapper/keymapper.h"
#include "backends/keymapper/standard-actions.h"
-#include "backends/platform/3ds/config.h"
-#include "backends/platform/3ds/options-dialog.h"
#include "backends/timer/default/default-timer.h"
#include "common/translation.h"
#include "engines/engine.h"
@@ -113,7 +111,7 @@ static void eventThreadFunc(void *arg) {
if (held & KEY_TOUCH) {
touchPosition touch;
hidTouchRead(&touch);
- if (config.snapToBorder) {
+ if (osys->_snapToBorder) {
if (touch.px < borderSnapZone) {
touch.px = 0;
}
@@ -225,7 +223,8 @@ static void aptHookFunc(APT_HookType hookType, void *param) {
osys->_sleepPauseToken.clear();
}
osys->sleeping = false;
- loadConfig();
+ osys->updateBacklight();
+ osys->updateConfig();
break;
case APTHOOK_ONEXIT:
break;
@@ -297,8 +296,7 @@ void OSystem_3DS::clipPoint(touchPosition &point) {
enum _3DSCustomEvent {
k3DSEventToggleDragMode,
- k3DSEventToggleMagnifyMode,
- k3DSEventOpenSettings
+ k3DSEventToggleMagnifyMode
};
Common::KeymapArray OSystem_3DS::getGlobalKeymaps() {
@@ -318,20 +316,12 @@ Common::KeymapArray OSystem_3DS::getGlobalKeymaps() {
act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
keymap->addAction(act);
- act = new Action("OPTS", _("Open 3DS Settings"));
- act->setCustomBackendActionEvent(k3DSEventOpenSettings);
- act->addDefaultInputMapping("JOY_BACK");
- keymap->addAction(act);
-
return Keymap::arrayOf(keymap);
}
Common::KeymapperDefaultBindings *OSystem_3DS::getKeymapperDefaultBindings() {
Common::KeymapperDefaultBindings *keymapperDefaultBindings = new Common::KeymapperDefaultBindings();
- // Bind the virtual keyboard to X so SELECT can be used for the 3DS options dialog
- keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VIRT", "JOY_X");
-
// Unmap the main menu standard action so LEFT_SHOULDER can be used for drag mode
keymapperDefaultBindings->setDefaultBinding("engine-default", Common::kStandardActionOpenMainMenu, "");
@@ -406,7 +396,7 @@ bool OSystem_3DS::notifyEvent(const Common::Event &event) {
case k3DSEventToggleMagnifyMode:
if (_overlayVisible) {
displayMessageOnOSD(_("Magnify Mode cannot be activated in menus."));
- } else if (config.screen != kScreenBoth && _magnifyMode == MODE_MAGOFF) {
+ } else if (_screen != kScreenBoth && _magnifyMode == MODE_MAGOFF) {
// TODO: Automatically enable both screens while magnify mode is on
displayMessageOnOSD(_("Magnify Mode can only be activated\n when both screens are enabled."));
} else if (_gameWidth <= 400 && _gameHeight <= 240) {
@@ -432,53 +422,9 @@ bool OSystem_3DS::notifyEvent(const Common::Event &event) {
}
}
return true;
-
- case k3DSEventOpenSettings:
- runOptionsDialog();
- return true;
}
return false;
}
-void OSystem_3DS::runOptionsDialog() {
- static bool optionsDialogRunning = false;
-
- // Prevent opening the options dialog multiple times
- if (optionsDialogRunning) {
- return;
- }
-
- optionsDialogRunning = true;
-
- PauseToken pauseToken;
- OptionsDialog dialog;
- if (g_engine) {
- pauseToken = g_engine->pauseEngine();
- }
- int result = dialog.runModal();
- if (g_engine) {
- pauseToken.clear();
- }
-
- if (result > 0) {
- int oldScreen = config.screen;
-
- config.showCursor = dialog.getShowCursor();
- config.snapToBorder = dialog.getSnapToBorder();
- config.stretchToFit = dialog.getStretchToFit();
- config.screen = dialog.getScreen();
-
- saveConfig();
- loadConfig();
-
- if (config.screen != oldScreen) {
- _screenChangeId++;
- g_gui.checkScreenChange();
- }
- }
-
- optionsDialogRunning = false;
-}
-
} // namespace N3DS
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 1c279aa3522..6dfd1777c08 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -23,8 +23,6 @@
#include "backends/platform/3ds/osystem.h"
#include "backends/platform/3ds/shader_shbin.h"
-#include "backends/platform/3ds/options-dialog.h"
-#include "backends/platform/3ds/config.h"
#include "common/rect.h"
#include "graphics/blit.h"
#include "graphics/fontman.h"
@@ -191,11 +189,8 @@ bool OSystem_3DS::setGraphicsMode(GraphicsModeID modeID) {
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++;
- }
+ updateBacklight();
+ updateConfig();
_gameWidth = width;
_gameHeight = height;
@@ -230,7 +225,7 @@ void OSystem_3DS::initSize(uint width, uint height,
}
void OSystem_3DS::updateSize() {
- if (config.stretchToFit) {
+ if (_stretchToFit) {
_gameTopX = _gameTopY = _gameBottomX = _gameBottomY = 0;
_gameTopTexture.setScale(400.f / _gameWidth, 240.f / _gameHeight);
_gameBottomTexture.setScale(320.f / _gameWidth, 240.f / _gameHeight);
@@ -266,7 +261,7 @@ void OSystem_3DS::updateSize() {
_gameBottomTexture.setOffset(0, 0);
if (_overlayInGUI) {
_cursorTexture.setScale(1.f, 1.f);
- } else if (config.screen == kScreenTop) {
+ } else if (_screen == kScreenTop) {
_cursorTexture.setScale(_gameTopTexture.getScaleX(), _gameTopTexture.getScaleY());
} else {
_cursorTexture.setScale(_gameBottomTexture.getScaleX(), _gameBottomTexture.getScaleY());
@@ -335,7 +330,7 @@ OSystem::TransactionError OSystem_3DS::endGFXTransaction() {
float OSystem_3DS::getScaleRatio() const {
if (_overlayInGUI) {
return 1.0;
- } else if (config.screen == kScreenTop) {
+ } else if (_screen == kScreenTop) {
return _gameTopTexture.getScaleX();
} else {
return _gameBottomTexture.getScaleX();
@@ -438,7 +433,7 @@ void OSystem_3DS::updateScreen() {
if (_overlayVisible) {
_overlay.transfer();
}
- if (_cursorVisible && config.showCursor) {
+ if (_cursorVisible && _showCursor) {
_cursorTexture.transfer();
}
_osdMessage.transfer();
@@ -449,26 +444,26 @@ void OSystem_3DS::updateScreen() {
// Render top screen
C3D_RenderTargetClear(_renderTargetTop, C3D_CLEAR_ALL, 0x00000000, 0);
C3D_FrameDrawOn(_renderTargetTop);
- if (config.screen == kScreenTop || config.screen == kScreenBoth) {
+ if (_screen == kScreenTop || _screen == kScreenBoth) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _projectionLocation, &_projectionTop);
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _gameTopTexture.getMatrix());
_gameTopTexture.setFilteringMode(_magnifyMode != MODE_MAGON && _filteringEnabled);
_gameTopTexture.render();
- if (_overlayVisible && config.screen == kScreenTop) {
+ if (_overlayVisible && _screen == kScreenTop) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _overlay.getMatrix());
_overlay.render();
}
- if (_activityIcon.getPixels() && config.screen == kScreenTop) {
+ if (_activityIcon.getPixels() && _screen == kScreenTop) {
_activityIcon.setPosition(400 - _activityIcon.actualWidth, 0);
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _activityIcon.getMatrix());
_activityIcon.render();
}
- if (_osdMessage.getPixels() && config.screen == kScreenTop) {
+ if (_osdMessage.getPixels() && _screen == kScreenTop) {
_osdMessage.setPosition((400 - _osdMessage.actualWidth) / 2, (240 - _osdMessage.actualHeight) / 2);
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _osdMessage.getMatrix());
_osdMessage.render();
}
- if (_cursorVisible && config.showCursor && config.screen == kScreenTop) {
+ if (_cursorVisible && _showCursor && _screen == kScreenTop) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
_cursorTexture.setFilteringMode(!_overlayInGUI && _filteringEnabled);
_cursorTexture.render();
@@ -478,7 +473,7 @@ void OSystem_3DS::updateScreen() {
// Render bottom screen
C3D_RenderTargetClear(_renderTargetBottom, C3D_CLEAR_ALL, 0x00000000, 0);
C3D_FrameDrawOn(_renderTargetBottom);
- if (config.screen == kScreenBottom || config.screen == kScreenBoth) {
+ if (_screen == kScreenBottom || _screen == kScreenBoth) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _projectionLocation, &_projectionBottom);
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _gameBottomTexture.getMatrix());
_gameTopTexture.setFilteringMode(_filteringEnabled);
@@ -497,7 +492,7 @@ void OSystem_3DS::updateScreen() {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _osdMessage.getMatrix());
_osdMessage.render();
}
- if (_cursorVisible && config.showCursor) {
+ if (_cursorVisible && _showCursor) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
_cursorTexture.setFilteringMode(!_overlayInGUI && _filteringEnabled);
_cursorTexture.render();
@@ -602,7 +597,7 @@ void OSystem_3DS::updateFocus() {
}
void OSystem_3DS::updateMagnify() {
- if (_magnifyMode == MODE_MAGON && config.screen != kScreenBoth) {
+ if (_magnifyMode == MODE_MAGON && _screen != kScreenBoth) {
// Only allow to magnify when both screens are enabled
_magnifyMode = MODE_MAGOFF;
}
@@ -740,7 +735,7 @@ int16 OSystem_3DS::getOverlayHeight() {
}
int16 OSystem_3DS::getOverlayWidth() {
- return config.screen == kScreenTop ? 400 : 320;
+ return _screen == kScreenTop ? 400 : 320;
}
bool OSystem_3DS::showMouse(bool visible) {
@@ -765,8 +760,8 @@ void OSystem_3DS::warpMouse(int x, int y) {
int offsetx = 0;
int offsety = 0;
if (!_overlayVisible) {
- offsetx = config.screen == kScreenTop ? _gameTopTexture.getPosX() : _gameBottomTexture.getPosX();
- offsety = config.screen == kScreenTop ? _gameTopTexture.getPosY() : _gameBottomTexture.getPosY();
+ offsetx = _screen == kScreenTop ? _gameTopTexture.getPosX() : _gameBottomTexture.getPosX();
+ offsety = _screen == kScreenTop ? _gameTopTexture.getPosY() : _gameBottomTexture.getPosY();
}
_cursorTexture.setPosition(x + offsetx, y + offsety);
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index 724527eb389..1f6d42be820 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -26,7 +26,6 @@
#include <3ds.h>
#include "osystem.h"
-#include "backends/platform/3ds/config.h"
#include "backends/mutex/3ds/3ds-mutex.h"
#include "backends/saves/default/default-saves.h"
#include "backends/timer/default/default-timer.h"
@@ -86,7 +85,11 @@ OSystem_3DS::OSystem_3DS():
_magnifyMode(MODE_MAGOFF),
exiting(false),
sleeping(false),
- _logger(0)
+ _logger(0),
+ _showCursor(true),
+ _snapToBorder(true),
+ _stretchToFit(false),
+ _screen(kScreenBoth)
{
chdir("sdmc:/");
@@ -139,7 +142,8 @@ void OSystem_3DS::initBackend() {
_logger->open(logFile);
}
- loadConfig();
+ updateBacklight();
+ updateConfig();
ConfMan.registerDefault("fullscreen", true);
ConfMan.registerDefault("aspect_ratio", true);
ConfMan.registerDefault("filtering", true);
@@ -159,6 +163,22 @@ void OSystem_3DS::initBackend() {
initEvents();
}
+void OSystem_3DS::updateBacklight() {
+ // Turn off the backlight of any screen not used
+ if (R_SUCCEEDED(gspLcdInit())) {
+ if (_screen == kScreenTop) {
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_TOP);
+ GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_BOTTOM);
+ } else if (_screen == kScreenBottom) {
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTTOM);
+ GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_TOP);
+ } else {
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTH);
+ }
+ gspLcdExit();
+ }
+}
+
void OSystem_3DS::updateConfig() {
if (_gameScreen.getPixels()) {
updateSize();
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index f8673f80721..dd715799a6a 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -58,6 +58,12 @@ enum GraphicsModeID {
CLUT8
};
+enum Screen {
+ kScreenTop = 0x10000002,
+ kScreenBottom,
+ kScreenBoth,
+};
+
enum TransactionState {
kTransactionNone = 0,
kTransactionActive = 1,
@@ -112,6 +118,10 @@ public:
Common::KeymapArray getGlobalKeymaps() override;
Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() override;
+ void registerDefaultSettings(const Common::String &target) const override;
+ GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
+ void applyBackendSettings() override;
+
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
@@ -182,6 +192,7 @@ public:
void updateFocus();
void updateMagnify();
+ void updateBacklight();
void updateConfig();
void updateSize();
@@ -192,7 +203,6 @@ private:
void destroyAudio();
void initEvents();
void destroyEvents();
- void runOptionsDialog();
void flushGameScreen();
void flushCursor();
@@ -294,6 +304,11 @@ private:
public:
// Pause
PauseToken _sleepPauseToken;
+
+ bool _showCursor;
+ bool _snapToBorder;
+ bool _stretchToFit;
+ Screen _screen;
};
} // namespace N3DS
diff --git a/po/POTFILES b/po/POTFILES
index 7605d851015..16b7e04d9e2 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -102,7 +102,7 @@ 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/options.cpp
backends/platform/3ds/osystem-events.cpp
backends/platform/android/android.cpp
backends/platform/android/options.cpp
Commit: 7e0309b175dab744f72e4e8454fa6afa38ab7e9b
https://github.com/scummvm/scummvm/commit/7e0309b175dab744f72e4e8454fa6afa38ab7e9b
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-04-23T21:09:17+02:00
Commit Message:
3DS: Update the documentation to reflect the options changes
Changed paths:
backends/platform/3ds/README.md
doc/docportal/images/3ds/config.png
doc/docportal/other_platforms/nintendo_3ds.rst
diff --git a/backends/platform/3ds/README.md b/backends/platform/3ds/README.md
index 86df02019bf..c679ad5b900 100644
--- a/backends/platform/3ds/README.md
+++ b/backends/platform/3ds/README.md
@@ -66,12 +66,12 @@ The default keymap is:
|------------|--------------------------------|
| A | Left-click |
| B | Right-click |
+| X | . (skips the current line) |
| Y | ESC (skips cutscenes and such) |
-| X | Use virtual keyboard |
| L | Toggle magnify mode on/off |
| R | Toggle hover/drag modes |
| Start | Open global main menu |
-| Select | Open 3DS config menu |
+| Select | Use virtual keyboard |
| Circle Pad | Move the cursor |
2.2) Hover mode
@@ -104,7 +104,7 @@ be reactivated upon exiting magnify mode), as well as restore the top screen's p
scale factor.
Currently magnify mode can only be used when the following conditions are met:
- - In the 3DS config menu, "Use Screen" is set to "Both"
+ - In the Backend tab in the options dialog, "Use Screen" is set to "Both"
- A game is currently being played
- The horizontal and/or vertical resolution in-game is greater than that of the top screen
diff --git a/doc/docportal/images/3ds/config.png b/doc/docportal/images/3ds/config.png
index 98c65b0cac9..a4043fe2aca 100644
Binary files a/doc/docportal/images/3ds/config.png and b/doc/docportal/images/3ds/config.png differ
diff --git a/doc/docportal/other_platforms/nintendo_3ds.rst b/doc/docportal/other_platforms/nintendo_3ds.rst
index d3b821277f5..261006fd49f 100644
--- a/doc/docportal/other_platforms/nintendo_3ds.rst
+++ b/doc/docportal/other_platforms/nintendo_3ds.rst
@@ -58,13 +58,13 @@ Controls can also be manually configured in the :doc:`Keymaps tab <../settings/k
R + Circle Pad,Slow Mouse
â¶,Left mouse button
â·,Right mouse button
- â,Opens the virtual keyboard
- â,ESC
+ â,Period (.)
+ â,Escape
Control Pad,Keypad cursor keys
L Button,Toggles magnify mode on/off
R Button,Toggles between hover/drag modes
START,Opens global main menu
- SELECT,Opens 3DS config menu
+ SELECT,Opens the virtual keyboard
.. _hover:
@@ -88,7 +88,7 @@ When activating magnify mode, touchscreen controls are automatically switched to
Magnify mode can only be used when the following conditions are met:
-- In the 3DS config menu, the **Use Screen** option is set to **Both**.
+- In the Backend tab in the options dialog, the **Use Screen** option is set to **Both**.
- The horizontal and/or vertical in-game resolution is greater than that of the top screen.
- You're playing a game.
@@ -113,12 +113,12 @@ Settings
For more information about Settings, see the Settings section of the documentation. Only platform-specific differences are listed here.
-The 3DS config menu
-*********************
+Backend-specific options
+**************************
.. figure:: ../images/3ds/config.png
- The 3DS config menu.
+ These options are specific to the 3DS port, and can be set in the :doc:`Backend tab <../settings/backend>`.
Show mouse cursor
Toggles a visible mouse cursor on/off.
@@ -132,9 +132,6 @@ Snap to edges
Use Screen:
Sets whether ScummVM uses the **Top**, **Bottom** or **Both** screens.
-C-Pad Sensitivity
- Sets the sensitivity of the Circle Pad.
-
Audio
******
More information about the Scummvm-git-logs
mailing list