mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-04 08:17:40 +00:00
ALL: add support for --config and refactor code
This commit is contained in:
parent
d6dbf721b6
commit
7b53202a9e
@ -1668,6 +1668,10 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
|
||||
|
||||
#endif // DISABLE_COMMAND_LINE
|
||||
|
||||
void storeSessionSetting(const Common::String &command, const Common::String &settingName, const Common::StringMap &settings) {
|
||||
if (settings.contains(command))
|
||||
ConfMan.set(settingName, settings[command], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
|
||||
bool processSettings(Common::String &command, Common::StringMap &settings, Common::Error &err) {
|
||||
err = Common::kNoError;
|
||||
@ -1830,72 +1834,29 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
|
||||
}
|
||||
|
||||
// store all session related settings
|
||||
if (settings.contains("savepath")) {
|
||||
ConfMan.set("savepath", settings["savepath"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("themepath")) {
|
||||
ConfMan.set("themepath", settings["themepath"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("extrapath")) {
|
||||
ConfMan.set("extrapath", settings["extrapath"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("gui-theme")) {
|
||||
ConfMan.set("gui_theme", settings["gui-theme"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("gfx-mode")) {
|
||||
ConfMan.set("gfx_mode", settings["gfx-mode"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("stretch-mode")) {
|
||||
ConfMan.set("stretch_mode", settings["stretch-mode"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("render-mode")) {
|
||||
ConfMan.set("render_mode", settings["render-mode"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("music-volume")) {
|
||||
ConfMan.set("music_volume", settings["music-volume"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("sfx-volume")) {
|
||||
ConfMan.set("sfx_volume", settings["sfx-volume"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("speech-volume")) {
|
||||
ConfMan.set("speech_volume", settings["speech-volume"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("fullscreen")) {
|
||||
ConfMan.set("fullscreen", settings["fullscreen"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("enable-gs")) {
|
||||
ConfMan.set("enable_gs", settings["enable-gs"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("native-mt32")) {
|
||||
ConfMan.set("native_mt32", settings["native-mt32"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("filtering")) {
|
||||
ConfMan.set("filtering", settings["filtering"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("multi-midi")) {
|
||||
ConfMan.set("multi_midi", settings["multi-midi"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("midi-gain")) {
|
||||
ConfMan.set("midi_gain", settings["midi-gain"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("soundfont")) {
|
||||
ConfMan.set("soundfont", settings["soundfont"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("scaler")) {
|
||||
ConfMan.set("scaler", settings["scaler"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("scale-factor")) {
|
||||
ConfMan.set("scale_factor", settings["scale-factor"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("opl-driver")) {
|
||||
ConfMan.set("opl_driver", settings["opl-driver"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("talkspeed")) {
|
||||
ConfMan.set("talkspeed", settings["talkspeed"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
if (settings.contains("subtitles")) {
|
||||
ConfMan.set("subtitles", settings["subtitles"], Common::ConfigManager::kSessionDomain);
|
||||
}
|
||||
storeSessionSetting("config", "config", settings);
|
||||
storeSessionSetting("fullscreen", "fullscreen", settings);
|
||||
storeSessionSetting("gfx-mode", "gfx_mode", settings);
|
||||
storeSessionSetting("stretch-mode", "stretch_mode", settings);
|
||||
storeSessionSetting("scaler", "scaler", settings);
|
||||
storeSessionSetting("scale-factor", "scale_factor", settings);
|
||||
storeSessionSetting("filtering", "filtering", settings);
|
||||
storeSessionSetting("gui-theme", "gui_theme", settings);
|
||||
storeSessionSetting("themepath", "themepath", settings);
|
||||
storeSessionSetting("music-volume", "music_volume", settings);
|
||||
storeSessionSetting("sfx-volume", "sfx_volume", settings);
|
||||
storeSessionSetting("speech-volume", "speech_volume", settings);
|
||||
storeSessionSetting("midi-gain", "midi_gain", settings);
|
||||
storeSessionSetting("subtitles", "subtitles", settings);
|
||||
storeSessionSetting("savepath", "savepath", settings);
|
||||
storeSessionSetting("extrapath", "extrapath", settings);
|
||||
storeSessionSetting("soundfont", "soundfont", settings);
|
||||
storeSessionSetting("multi-midi", "multi_midi", settings);
|
||||
storeSessionSetting("native-mt32", "native-mt32", settings);
|
||||
storeSessionSetting("enable-gs", "enable_gs", settings);
|
||||
storeSessionSetting("opl-driver", "opl_driver", settings);
|
||||
storeSessionSetting("talkspeed", "talkspeed", settings);
|
||||
storeSessionSetting("render-mode", "render_mode", settings);
|
||||
|
||||
// Finally, store the command line settings into the config manager.
|
||||
for (Common::StringMap::const_iterator x = settings.begin(); x != settings.end(); ++x) {
|
||||
|
@ -416,7 +416,6 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
|
||||
// Load the config file (possibly overridden via command line):
|
||||
if (settings.contains("config")) {
|
||||
ConfMan.loadConfigFile(settings["config"]);
|
||||
settings.erase("config");
|
||||
} else {
|
||||
ConfMan.loadDefaultConfigFile();
|
||||
}
|
||||
|
@ -1058,7 +1058,7 @@ void ThemeEngine::drawLineSeparator(const Common::Rect &r) {
|
||||
}
|
||||
|
||||
void ThemeEngine::drawCheckbox(const Common::Rect &r, int spacing, const Common::U32String &str, bool checked,
|
||||
WidgetStateInfo state, bool override, bool rtl) {
|
||||
WidgetStateInfo state, bool overrideText, bool rtl) {
|
||||
if (!ready())
|
||||
return;
|
||||
|
||||
@ -1088,7 +1088,7 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, int spacing, const Common:
|
||||
}
|
||||
|
||||
if (r2.right > r2.left) {
|
||||
TextColor color = override ? GUI::TextColor::kTextColorOverride : getTextColor(dd);
|
||||
TextColor color = overrideText ? GUI::TextColor::kTextColorOverride : getTextColor(dd);
|
||||
drawDDText(getTextData(dd), color, r2, str, true, false, convertTextAlignH(_widgets[dd]->_textAlignH, rtl),
|
||||
_widgets[dd]->_textAlignV);
|
||||
}
|
||||
@ -1359,69 +1359,72 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::U32String &str,
|
||||
case kFontColorNormal:
|
||||
if (inverted) {
|
||||
colorId = kTextColorNormalInverted;
|
||||
} else {
|
||||
switch (state) {
|
||||
case kStateDisabled:
|
||||
colorId = kTextColorNormalDisabled;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case kStateHighlight:
|
||||
colorId = kTextColorNormalHover;
|
||||
break;
|
||||
switch (state) {
|
||||
case kStateDisabled:
|
||||
colorId = kTextColorNormalDisabled;
|
||||
break;
|
||||
|
||||
default:
|
||||
// fallthrough intended
|
||||
case kStateEnabled:
|
||||
case kStatePressed:
|
||||
colorId = kTextColorNormal;
|
||||
break;
|
||||
}
|
||||
case kStateHighlight:
|
||||
colorId = kTextColorNormalHover;
|
||||
break;
|
||||
|
||||
default:
|
||||
// fallthrough intended
|
||||
case kStateEnabled:
|
||||
case kStatePressed:
|
||||
colorId = kTextColorNormal;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case kFontColorAlternate:
|
||||
if (inverted) {
|
||||
colorId = kTextColorAlternativeInverted;
|
||||
} else {
|
||||
switch (state) {
|
||||
case kStateDisabled:
|
||||
colorId = kTextColorAlternativeDisabled;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case kStateHighlight:
|
||||
colorId = kTextColorAlternativeHover;
|
||||
break;
|
||||
switch (state) {
|
||||
case kStateDisabled:
|
||||
colorId = kTextColorAlternativeDisabled;
|
||||
break;
|
||||
|
||||
default:
|
||||
// fallthrough intended
|
||||
case kStateEnabled:
|
||||
case kStatePressed:
|
||||
colorId = kTextColorAlternative;
|
||||
break;
|
||||
}
|
||||
case kStateHighlight:
|
||||
colorId = kTextColorAlternativeHover;
|
||||
break;
|
||||
|
||||
default:
|
||||
// fallthrough intended
|
||||
case kStateEnabled:
|
||||
case kStatePressed:
|
||||
colorId = kTextColorAlternative;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case kFontColorOverride:
|
||||
if (inverted) {
|
||||
colorId = kTextColorOverrideInverted;
|
||||
} else {
|
||||
switch (state) {
|
||||
case kStateDisabled:
|
||||
colorId = kTextColorAlternativeDisabled;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case kStateDisabled:
|
||||
colorId = kTextColorAlternativeDisabled;
|
||||
break;
|
||||
|
||||
case kStateHighlight:
|
||||
colorId = kTextColorOverrideHover;
|
||||
break;
|
||||
case kStateHighlight:
|
||||
colorId = kTextColorOverrideHover;
|
||||
break;
|
||||
|
||||
default:
|
||||
// fallthrough intended
|
||||
case kStateEnabled:
|
||||
case kStatePressed:
|
||||
colorId = kTextColorOverride;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// fallthrough intended
|
||||
case kStateEnabled:
|
||||
case kStatePressed:
|
||||
colorId = kTextColorOverride;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2202,7 +2202,7 @@ void GlobalOptionsDialog::build() {
|
||||
|
||||
#if !defined(__DC__)
|
||||
const auto setPath =
|
||||
[&](GUI::StaticTextWidget *const widget, const Common::String& pathType, const Common::U32String &defaultLabel) {
|
||||
[&](GUI::StaticTextWidget *const widget, const Common::String &pathType, const Common::U32String &defaultLabel) {
|
||||
Common::String path(ConfMan.get(pathType));
|
||||
if (ConfMan.isKeyTemporary(pathType)) {
|
||||
widget->setFontColor(ThemeEngine::FontColor::kFontColorOverride);
|
||||
@ -2330,7 +2330,10 @@ void GlobalOptionsDialog::addPathsControls(GuiObject *boss, const Common::String
|
||||
Common::U32String confPath = ConfMan.getCustomConfigFileName();
|
||||
if (confPath.empty())
|
||||
confPath = g_system->getDefaultConfigFileName();
|
||||
new StaticTextWidget(boss, prefix + "ConfigPath", _("ScummVM config path: ") + confPath, confPath);
|
||||
StaticTextWidget* configPathWidget = new StaticTextWidget(boss, prefix + "ConfigPath", _("ScummVM config path: ") + confPath, confPath);
|
||||
if (ConfMan.isKeyTemporary("config"))
|
||||
configPathWidget->setFontColor(ThemeEngine::FontColor::kFontColorOverride);
|
||||
|
||||
|
||||
Common::U32String browserPath = _("<default>");
|
||||
if (ConfMan.hasKey("browser_lastpath"))
|
||||
@ -2693,7 +2696,7 @@ void GlobalOptionsDialog::apply() {
|
||||
bool isRebuildNeeded = false;
|
||||
|
||||
const auto changePath =
|
||||
[&](GUI::StaticTextWidget *const widget, const Common::String& pathType, const Common::U32String &defaultLabel){
|
||||
[&](GUI::StaticTextWidget *const widget, const Common::String &pathType, const Common::U32String &defaultLabel) {
|
||||
Common::U32String label(widget->getLabel());
|
||||
if (label != ConfMan.get(pathType)) {
|
||||
widget->setFontColor(ThemeEngine::FontColor::kFontColorNormal);
|
||||
|
@ -707,14 +707,14 @@ void PicButtonWidget::drawWidget() {
|
||||
#pragma mark -
|
||||
|
||||
CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &label, const Common::U32String &tooltip, uint32 cmd, uint8 hotkey)
|
||||
: ButtonWidget(boss, x, y, w, h, label, tooltip, cmd, hotkey), _state(false), _override(false) {
|
||||
: ButtonWidget(boss, x, y, w, h, label, tooltip, cmd, hotkey), _state(false), _overrideText(false) {
|
||||
setFlags(WIDGET_ENABLED);
|
||||
_type = kCheckboxWidget;
|
||||
_spacing = g_gui.xmlEval()->getVar("Globals.Checkbox.Spacing", 15);
|
||||
}
|
||||
|
||||
CheckboxWidget::CheckboxWidget(GuiObject *boss, const Common::String &name, const Common::U32String &label, const Common::U32String &tooltip, uint32 cmd, uint8 hotkey)
|
||||
: ButtonWidget(boss, name, label, tooltip, cmd, hotkey), _state(false), _override(false) {
|
||||
: ButtonWidget(boss, name, label, tooltip, cmd, hotkey), _state(false), _overrideText(false) {
|
||||
setFlags(WIDGET_ENABLED);
|
||||
_type = kCheckboxWidget;
|
||||
_spacing = g_gui.xmlEval()->getVar("Globals.Checkbox.Spacing", 15);
|
||||
@ -737,12 +737,12 @@ void CheckboxWidget::setState(bool state) {
|
||||
sendCommand(_cmd, _state);
|
||||
}
|
||||
|
||||
void CheckboxWidget::setOverride(bool override) {
|
||||
_override = override;
|
||||
void CheckboxWidget::setOverride(bool enable) {
|
||||
_overrideText = enable;
|
||||
}
|
||||
|
||||
void CheckboxWidget::drawWidget() {
|
||||
g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x + _w, _y + _h), _spacing, getLabel(), _state, Widget::_state, _override, (g_gui.useRTL() && _useRTL));
|
||||
g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x + _w, _y + _h), _spacing, getLabel(), _state, Widget::_state, _overrideText, (g_gui.useRTL() && _useRTL));
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
@ -321,7 +321,7 @@ protected:
|
||||
class CheckboxWidget : public ButtonWidget {
|
||||
protected:
|
||||
bool _state;
|
||||
bool _override;
|
||||
bool _overrideText;
|
||||
int _spacing;
|
||||
public:
|
||||
CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
||||
@ -335,7 +335,7 @@ public:
|
||||
void toggleState() { setState(!_state); }
|
||||
bool getState() const { return _state; }
|
||||
|
||||
void setOverride(bool override);
|
||||
void setOverride(bool enable);
|
||||
|
||||
protected:
|
||||
void drawWidget() override;
|
||||
|
Loading…
Reference in New Issue
Block a user