Skip to content

Commit

Permalink
Merge pull request #859 from criezy/gui-apply
Browse files Browse the repository at this point in the history
GUI: apply changes functionality
  • Loading branch information
sev- committed Nov 3, 2016
2 parents 42ebd5a + 0f9655b commit e2f58be
Show file tree
Hide file tree
Showing 19 changed files with 554 additions and 409 deletions.
2 changes: 1 addition & 1 deletion gui/ThemeEngine.h
Expand Up @@ -37,7 +37,7 @@
#include "graphics/pixelformat.h"


#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.22"
#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.23"

class OSystem;

Expand Down
74 changes: 36 additions & 38 deletions gui/editgamedialog.cpp
Expand Up @@ -381,45 +381,43 @@ void EditGameDialog::open() {
_platformPopUp->setSelected(sel);
}


void EditGameDialog::close() {
if (getResult()) {
ConfMan.set("description", _descriptionWidget->getEditString(), _domain);

Common::Language lang = (Common::Language)_langPopUp->getSelectedTag();
if (lang < 0)
ConfMan.removeKey("language", _domain);
else
ConfMan.set("language", Common::getLanguageCode(lang), _domain);

String gamePath(_gamePathWidget->getLabel());
if (!gamePath.empty())
ConfMan.set("path", gamePath, _domain);

String extraPath(_extraPathWidget->getLabel());
if (!extraPath.empty() && (extraPath != _c("None", "path")))
ConfMan.set("extrapath", extraPath, _domain);
else
ConfMan.removeKey("extrapath", _domain);

String savePath(_savePathWidget->getLabel());
if (!savePath.empty() && (savePath != _("Default")))
ConfMan.set("savepath", savePath, _domain);
else
ConfMan.removeKey("savepath", _domain);

Common::Platform platform = (Common::Platform)_platformPopUp->getSelectedTag();
if (platform < 0)
ConfMan.removeKey("platform", _domain);
else
ConfMan.set("platform", Common::getPlatformCode(platform), _domain);

// Set the state of engine-specific checkboxes
for (uint i = 0; i < _engineOptions.size(); i++) {
ConfMan.setBool(_engineOptions[i].configOption, _engineCheckboxes[i]->getState(), _domain);
}
void EditGameDialog::apply() {
ConfMan.set("description", _descriptionWidget->getEditString(), _domain);

Common::Language lang = (Common::Language)_langPopUp->getSelectedTag();
if (lang < 0)
ConfMan.removeKey("language", _domain);
else
ConfMan.set("language", Common::getLanguageCode(lang), _domain);

String gamePath(_gamePathWidget->getLabel());
if (!gamePath.empty())
ConfMan.set("path", gamePath, _domain);

String extraPath(_extraPathWidget->getLabel());
if (!extraPath.empty() && (extraPath != _c("None", "path")))
ConfMan.set("extrapath", extraPath, _domain);
else
ConfMan.removeKey("extrapath", _domain);

String savePath(_savePathWidget->getLabel());
if (!savePath.empty() && (savePath != _("Default")))
ConfMan.set("savepath", savePath, _domain);
else
ConfMan.removeKey("savepath", _domain);

Common::Platform platform = (Common::Platform)_platformPopUp->getSelectedTag();
if (platform < 0)
ConfMan.removeKey("platform", _domain);
else
ConfMan.set("platform", Common::getPlatformCode(platform), _domain);

// Set the state of engine-specific checkboxes
for (uint i = 0; i < _engineOptions.size(); i++) {
ConfMan.setBool(_engineOptions[i].configOption, _engineCheckboxes[i]->getState(), _domain);
}
OptionsDialog::close();

OptionsDialog::apply();
}

void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
Expand Down
2 changes: 1 addition & 1 deletion gui/editgamedialog.h
Expand Up @@ -65,7 +65,7 @@ class EditGameDialog : public OptionsDialog {
EditGameDialog(const String &domain, const String &desc);

void open();
void close();
virtual void apply();
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);

protected:
Expand Down
51 changes: 36 additions & 15 deletions gui/launcher.cpp
Expand Up @@ -99,6 +99,30 @@ LauncherDialog::LauncherDialog()
_w = screenW;
_h = screenH;

build();

GUI::GuiManager::instance()._launched = true;
}

void LauncherDialog::selectTarget(const String &target) {
if (!target.empty()) {
int itemToSelect = 0;
StringArray::const_iterator iter;
for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) {
if (target == *iter) {
_list->setSelected(itemToSelect);
break;
}
}
}
}

LauncherDialog::~LauncherDialog() {
delete _browser;
delete _loadDialog;
}

void LauncherDialog::build() {
#ifndef DISABLE_FANCY_THEMES
_logo = 0;
if (g_gui.xmlEval()->getVar("Globals.ShowLauncherLogo") == 1 && g_gui.theme()->supportsImages()) {
Expand Down Expand Up @@ -174,28 +198,25 @@ LauncherDialog::LauncherDialog()

// Create Load dialog
_loadDialog = new SaveLoadChooser(_("Load game:"), _("Load"), false);

GUI::GuiManager::instance()._launched = true;
}

void LauncherDialog::selectTarget(const String &target) {
if (!target.empty()) {
int itemToSelect = 0;
StringArray::const_iterator iter;
for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) {
if (target == *iter) {
_list->setSelected(itemToSelect);
break;
}
}
void LauncherDialog::clean() {
while (_firstWidget) {
Widget* w = _firstWidget;
removeWidget(w);
delete w;
}
}

LauncherDialog::~LauncherDialog() {
delete _browser;
delete _loadDialog;
}

void LauncherDialog::rebuild() {
clean();
build();
reflowLayout();
setFocusWidget(_firstWidget);
}

void LauncherDialog::open() {
// Clear the active domain, in case we return to the dialog from a
// failure to launch a game. Otherwise, pressing ESC will attempt to
Expand Down
5 changes: 5 additions & 0 deletions gui/launcher.h
Expand Up @@ -47,6 +47,8 @@ class LauncherDialog : public Dialog {
LauncherDialog();
~LauncherDialog();

void rebuild();

virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);

virtual void handleKeyDown(Common::KeyState state);
Expand Down Expand Up @@ -83,6 +85,9 @@ class LauncherDialog : public Dialog {
void updateButtons();
void switchButtonsText(ButtonWidget *button, const char *normalText, const char *shiftedText);

void build();
void clean();

void open();
void close();

Expand Down

0 comments on commit e2f58be

Please sign in to comment.