aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2003-10-08 21:59:23 +0000
committerMax Horn2003-10-08 21:59:23 +0000
commitd1773647159f9ef1393d7a1d33204de5886edce5 (patch)
treed31f1a3689fa34a525671f21d7a858fe8570762f /gui
parent3c78c0929c553fd67016f87c6cdc38d3f50d7ca2 (diff)
downloadscummvm-rg350-d1773647159f9ef1393d7a1d33204de5886edce5.tar.gz
scummvm-rg350-d1773647159f9ef1393d7a1d33204de5886edce5.tar.bz2
scummvm-rg350-d1773647159f9ef1393d7a1d33204de5886edce5.zip
new config manager. not everything is completed, and some things will still be changed, but it seems to work well enough to put it into CVS
svn-id: r10687
Diffstat (limited to 'gui')
-rw-r--r--gui/launcher.cpp74
-rw-r--r--gui/options.cpp30
-rw-r--r--gui/options.h2
3 files changed, 54 insertions, 52 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 91866a8ad0..743e37bb09 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -32,11 +32,13 @@
#include "backends/fs/fs.h"
+#include "base/engine.h"
#include "base/gameDetector.h"
#include "base/plugins.h"
-#include "common/config-file.h"
-#include "base/engine.h"
+#include "common/config-manager.h"
+
+using Common::ConfigManager;
enum {
kStartCmd = 'STRT',
@@ -83,7 +85,6 @@ public:
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
protected:
- Config &_config;
const String &_domain;
EditTextWidget *_descriptionWidget;
EditTextWidget *_domainWidget;
@@ -92,10 +93,11 @@ protected:
};
EditGameDialog::EditGameDialog(NewGui *gui, const String &domain, const TargetSettings *target)
- : Dialog(gui, 8, 50, 320 - 2 * 8, 200 - 2 * 40), _config(*g_config), _domain(domain) {
+ : Dialog(gui, 8, 50, 320 - 2 * 8, 200 - 2 * 40),
+ _domain(domain) {
// Determine the description string
- String description(_config.get("description", _domain));
+ String description(ConfMan.get("description", domain));
if (description.isEmpty()) {
description = target->description;
}
@@ -116,18 +118,18 @@ EditGameDialog::EditGameDialog(NewGui *gui, const String &domain, const TargetSe
new EditTextWidget(this, 50, 26, _w - 50 - 10, kLineHeight, description);
// Path to game data (view only)
- String path(_config.get("path", _domain));
+ String path(ConfMan.get("path", _domain));
new StaticTextWidget(this, 10, 42, 40, kLineHeight, "Path: ", kTextAlignRight);
new StaticTextWidget(this, 50, 42, _w - 50 - 10, kLineHeight, path, kTextAlignLeft);
// Full screen checkbox
_fullscreenCheckbox = new CheckboxWidget(this, 15, 62, 200, 16, "Use Fullscreen Mode", 0, 'F');
- _fullscreenCheckbox->setState(_config.getBool("fullscreen", false, _domain));
+ _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
// Display 'Amiga' checkbox, but only for Scumm games.
if (isScumm) {
_amigaCheckbox = new CheckboxWidget(this, 15, 82, 200, 16, "Amiga Version", 0, 'A');
- _amigaCheckbox->setState(_config.getBool("amiga", false, _domain));
+ _amigaCheckbox->setState(ConfMan.getBool("amiga", _domain));
} else {
_amigaCheckbox = 0;
}
@@ -142,17 +144,17 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// Write back changes made to config object
String newDomain(_domainWidget->getLabel());
if (newDomain != _domain) {
- if (newDomain.isEmpty() || _config.has_domain(newDomain)) {
+ if (newDomain.isEmpty() || ConfMan.hasGameDomain(newDomain)) {
MessageDialog alert(_gui, "This game ID is already taken. Please choose another one.");
alert.runModal();
return;
}
- _config.rename_domain(_domain, newDomain);
+ ConfMan.renameGameDomain(_domain, newDomain);
}
- _config.set("description", _descriptionWidget->getLabel(), newDomain);
+ ConfMan.set("description", _descriptionWidget->getLabel(), newDomain);
if (_amigaCheckbox)
- _config.setBool("amiga", _amigaCheckbox->getState(), newDomain);
- _config.setBool("fullscreen", _fullscreenCheckbox->getState(), newDomain);
+ ConfMan.set("amiga", _amigaCheckbox->getState(), newDomain);
+ ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), newDomain);
setResult(1);
close();
} else {
@@ -218,12 +220,16 @@ LauncherDialog::~LauncherDialog() {
void LauncherDialog::open() {
Dialog::open();
+/* FIXME / TODO: config rewrite
g_config->set_writing(true);
+*/
}
void LauncherDialog::close() {
- g_config->flush();
+ ConfMan.flushToDisk();
+/* FIXME / TODO: config rewrite
g_config->set_writing(false);
+*/
Dialog::close();
}
@@ -232,16 +238,16 @@ void LauncherDialog::updateListing() {
// Retrieve a list of all games defined in the config file
_domains.clear();
- StringList domains = g_config->get_domains();
- StringList::ConstIterator iter = domains.begin();
+ const ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
+ ConfigManager::DomainMap::ConstIterator iter = domains.begin();
for (iter = domains.begin(); iter != domains.end(); ++iter) {
- String name(g_config->get("gameid", *iter));
- String description(g_config->get("description", *iter));
+ String name(iter->_value.get("gameid"));
+ String description(iter->_value.get("description"));
if (name.isEmpty())
- name = *iter;
+ name = iter->_key;
if (description.isEmpty()) {
- const TargetSettings *v = _detector.findTarget(name.c_str());
+ const TargetSettings *v = _detector.findTarget(name);
if (v && v->description)
description = v->description;
}
@@ -253,7 +259,7 @@ void LauncherDialog::updateListing() {
while (pos < size && (description > l[pos]))
pos++;
l.insert_at(pos, description);
- _domains.insert_at(pos, *iter);
+ _domains.insert_at(pos, iter->_key);
}
}
@@ -372,18 +378,18 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// Pick a domain name which does not yet exist (after all, we
// are *adding* a game to the config, not replacing).
String domain(v->targetName);
- if (g_config->has_domain(domain)) {
+ if (ConfMan.hasGameDomain(domain)) {
char suffix = 'a';
domain += suffix;
- while (g_config->has_domain(domain)) {
+ while (ConfMan.hasGameDomain(domain)) {
domain.deleteLastChar();
suffix++;
domain += suffix;
}
- g_config->set("gameid", v->targetName, domain);
- g_config->set("description", v->description, domain);
+ ConfMan.set("gameid", v->targetName, domain);
+ ConfMan.set("description", v->description, domain);
}
- g_config->set("path", dir->path(), domain);
+ ConfMan.set("path", dir->path(), domain);
// Display edit dialog for the new entry
EditGameDialog editDialog(_gui, domain, v);
@@ -391,14 +397,14 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// User pressed OK, so make changes permanent
// Write config to disk
- g_config->flush();
+ ConfMan.flushToDisk();
// Update the ListWidget and force a redraw
updateListing();
draw();
} else {
// User aborted, remove the the new domain again
- g_config->delete_domain(domain);
+ ConfMan.removeGameDomain(domain);
}
}
}
@@ -406,10 +412,10 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kRemoveGameCmd:
// Remove the currently selected game from the list
assert(item >= 0);
- g_config->delete_domain(_domains[item]);
+ ConfMan.removeGameDomain(_domains[item]);
// Write config to disk
- g_config->flush();
+ ConfMan.flushToDisk();
// Update the ListWidget and force a redraw
updateListing();
@@ -423,15 +429,15 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// This is useful because e.g. MonkeyVGA needs Adlib music to have decent
// music support etc.
assert(item >= 0);
- const char *gameId = g_config->get("gameid", _domains[item]);
- if (!gameId)
- gameId = _domains[item].c_str();
+ String gameId(ConfMan.get("gameid", _domains[item]));
+ if (gameId.isEmpty())
+ gameId = _domains[item];
EditGameDialog editDialog(_gui, _domains[item], _detector.findTarget(gameId));
if (editDialog.runModal()) {
// User pressed OK, so make changes permanent
// Write config to disk
- g_config->flush();
+ ConfMan.flushToDisk();
// Update the ListWidget and force a redraw
updateListing();
diff --git a/gui/options.cpp b/gui/options.cpp
index 0e3bc0ea73..475e478ce5 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -27,7 +27,7 @@
#include "backends/fs/fs.h"
#include "base/gameDetector.h"
-#include "common/config-file.h"
+#include "common/config-manager.h"
#include "sound/mididrv.h"
#if (!( defined(__DC__) || defined(__GP32__)) && !defined(_MSC_VER))
@@ -61,7 +61,7 @@ enum {
};
GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector)
- : Dialog(gui, 10, 15, 320 - 2 * 10, 200 - 2 * 15), _detector(detector) {
+ : Dialog(gui, 10, 15, 320 - 2 * 10, 200 - 2 * 15) {
// The GFX mode popup & a label
// TODO - add an API to query the list of available GFX modes, and to get/set the mode
new StaticTextWidget(this, 5, 10+1, 100, kLineHeight, "Graphics mode: ", kTextAlignRight);
@@ -94,7 +94,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector)
const MidiDriverDescription *md = getAvailableMidiDrivers();
while (md->name) {
_midiPopUp->appendEntry(md->description, md->id);
- if (md->id == _detector._midi_driver)
+ if (md->id == detector._midi_driver)
midiSelected = i;
i++;
md++;
@@ -134,10 +134,9 @@ GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector)
_savePath = new StaticTextWidget(this, 105, 106, 180, kLineHeight, "/foo/bar", kTextAlignLeft);
new ButtonWidget(this, 105, 120, 64, 16, "Choose...", kChooseSaveDirCmd, 0);
-// TODO: set _savePath to the current save path, i.e. as obtained via
- const char *dir = NULL;
- dir = g_config->get("savepath", "scummvm");
- if (dir) {
+// TODO: set _savePath to the current save path
+ Common::String dir(ConfMan.get("savepath"));
+ if (!dir.isEmpty()) {
_savePath->setLabel(dir);
} else {
// Default to the current directory...
@@ -164,9 +163,9 @@ GlobalOptionsDialog::~GlobalOptionsDialog() {
void GlobalOptionsDialog::open() {
Dialog::open();
- _soundVolumeMaster = _detector._master_volume;
- _soundVolumeMusic = _detector._music_volume;
- _soundVolumeSfx = _detector._sfx_volume;
+ _soundVolumeMaster = ConfMan.getInt("master_volume");
+ _soundVolumeMusic = ConfMan.getInt("music_volume");
+ _soundVolumeSfx = ConfMan.getInt("sfx_volume");
_masterVolumeSlider->setValue(_soundVolumeMaster);
_musicVolumeSlider->setValue(_soundVolumeMusic);
@@ -184,7 +183,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
// User made his choice...
FilesystemNode *dir = _browser->getResult();
_savePath->setLabel(dir->path());
- // TODO - we should check if the director is writeable before accepting it
+ // TODO - we should check if the directory is writeable before accepting it
}
break;
case kMasterVolumeChanged:
@@ -207,18 +206,17 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
const MidiDriverDescription *md = getAvailableMidiDrivers();
for (; md->name; md++) {
if (md->id == (int) data) {
- g_config->set ("music_driver", md->name, "_USER_OVERRIDES");
+ ConfMan.set("music_driver", md->name);
break;
}
}
}
break;
case kOKCmd:
- // TODO Write back changes made to config object
setResult(1);
- _detector._master_volume = _soundVolumeMaster;
- _detector._music_volume = _soundVolumeMusic;
- _detector._sfx_volume = _soundVolumeSfx;
+ ConfMan.set("master_volume", _soundVolumeMaster);
+ ConfMan.set("music_volume", _soundVolumeMusic);
+ ConfMan.set("sfx_volume", _soundVolumeSfx);
close();
break;
default:
diff --git a/gui/options.h b/gui/options.h
index db25eee8a8..71f3011c8c 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -40,8 +40,6 @@ public:
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
protected:
- GameDetector &_detector;
-
BrowserDialog *_browser;
StaticTextWidget*_savePath;