1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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", 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(0, 0, 0, 0)
.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
|