mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-28 03:40:36 +00:00
enhanced Config::rename_domain; added the ability to change the domain name in EditGameDialog
svn-id: r5673
This commit is contained in:
parent
3ceee2fc42
commit
293c6cc461
@ -201,22 +201,22 @@ void Config::flush() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::rename_domain(const String &d)
|
void Config::rename_domain(const String &oldD, const String &newD)
|
||||||
{
|
{
|
||||||
String domain(d);
|
String oldDomain(oldD);
|
||||||
domain.toLowercase();
|
String newDomain(newD);
|
||||||
|
oldDomain.toLowercase();
|
||||||
|
newDomain.toLowercase();
|
||||||
|
|
||||||
if (domain == defaultDomain)
|
if (oldDomain == newDomain)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StringMap &oldHash = domains[defaultDomain];
|
StringMap &oldHash = domains[oldDomain];
|
||||||
StringMap &newHash = domains[domain];
|
StringMap &newHash = domains[newDomain];
|
||||||
|
|
||||||
newHash.merge(oldHash);
|
newHash.merge(oldHash);
|
||||||
|
|
||||||
domains.remove(defaultDomain);
|
domains.remove(oldDomain);
|
||||||
|
|
||||||
defaultDomain = domain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::delete_domain(const String &d)
|
void Config::delete_domain(const String &d)
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
void set_domain(const String &d);
|
void set_domain(const String &d);
|
||||||
void flush() const;
|
void flush() const;
|
||||||
void rename_domain(const String &d);
|
void rename_domain(const String &oldD, const String &newD);
|
||||||
void delete_domain(const String &d);
|
void delete_domain(const String &d);
|
||||||
bool has_domain(const String &d) const;
|
bool has_domain(const String &d) const;
|
||||||
void set_filename(const String &);
|
void set_filename(const String &);
|
||||||
|
@ -360,8 +360,8 @@ void GameDetector::setGame(const String &name)
|
|||||||
{
|
{
|
||||||
_gameFileName = name;
|
_gameFileName = name;
|
||||||
g_config->set_domain(name);
|
g_config->set_domain(name);
|
||||||
g_config->rename_domain("game-specific");
|
g_config->rename_domain(name, "game-specific");
|
||||||
g_config->rename_domain(name);
|
g_config->rename_domain("game-specific", name);
|
||||||
updateconfig();
|
updateconfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,20 +80,21 @@ protected:
|
|||||||
Config &_config;
|
Config &_config;
|
||||||
const String &_domain;
|
const String &_domain;
|
||||||
EditTextWidget *_descriptionWidget;
|
EditTextWidget *_descriptionWidget;
|
||||||
|
EditTextWidget *_domainWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
EditGameDialog::EditGameDialog(NewGui *gui, Config &config, const String &domain)
|
EditGameDialog::EditGameDialog(NewGui *gui, Config &config, const String &domain)
|
||||||
: Dialog(gui, 10, 40, 320-2*10, 200-2*40), _config(config), _domain(domain)
|
: Dialog(gui, 8, 50, 320-2*8, 200-2*40), _config(config), _domain(domain)
|
||||||
{
|
{
|
||||||
// Determine the description string
|
// Determine the description string
|
||||||
String name(_config.get("gameid", _domain));
|
String gameid(_config.get("gameid", _domain));
|
||||||
String description(_config.get("description", _domain));
|
String description(_config.get("description", _domain));
|
||||||
if (name.isEmpty())
|
if (gameid.isEmpty())
|
||||||
name = _domain;
|
gameid = _domain;
|
||||||
if (description.isEmpty()) {
|
if (description.isEmpty()) {
|
||||||
const VersionSettings *v = version_settings;
|
const VersionSettings *v = version_settings;
|
||||||
while (v->filename) {
|
while (v->filename) {
|
||||||
if (!scumm_stricmp(v->filename, name.c_str())) {
|
if (!scumm_stricmp(v->filename, gameid.c_str())) {
|
||||||
description = v->gamename;
|
description = v->gamename;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -101,15 +102,20 @@ EditGameDialog::EditGameDialog(NewGui *gui, Config &config, const String &domain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Label & edit widget for the game ID
|
||||||
|
new StaticTextWidget(this, 10, 10, 40, kLineHeight, "ID: ", kTextAlignRight);
|
||||||
|
_domainWidget =
|
||||||
|
new EditTextWidget(this, 50, 10, _w-50-10, kLineHeight, _domain);
|
||||||
|
|
||||||
// Label & edit widget for the description
|
// Label & edit widget for the description
|
||||||
new StaticTextWidget(this, 10, 10, 40, kLineHeight, "Name: ", kTextAlignRight);
|
new StaticTextWidget(this, 10, 26, 40, kLineHeight, "Name: ", kTextAlignRight);
|
||||||
_descriptionWidget =
|
_descriptionWidget =
|
||||||
new EditTextWidget(this, 50, 10, _w-50-10, kLineHeight, description);
|
new EditTextWidget(this, 50, 26, _w-50-10, kLineHeight, description);
|
||||||
|
|
||||||
// Path to game data (view only)
|
// Path to game data (view only)
|
||||||
String path(_config.get("path", _domain));
|
String path(_config.get("path", _domain));
|
||||||
new StaticTextWidget(this, 10, 24, 40, kLineHeight, "Path: ", kTextAlignRight);
|
new StaticTextWidget(this, 10, 42, 40, kLineHeight, "Path: ", kTextAlignRight);
|
||||||
new StaticTextWidget(this, 50, 24, _w-50-10, kLineHeight, path, kTextAlignLeft);
|
new StaticTextWidget(this, 50, 42, _w-50-10, kLineHeight, path, kTextAlignLeft);
|
||||||
|
|
||||||
// TODO - insert more widgets here; see comments before the class
|
// TODO - insert more widgets here; see comments before the class
|
||||||
|
|
||||||
@ -121,11 +127,21 @@ EditGameDialog::EditGameDialog(NewGui *gui, Config &config, const String &domain
|
|||||||
void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
|
void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
|
||||||
{
|
{
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case kOKCmd:
|
case kOKCmd: {
|
||||||
// Write back changes made to config object
|
// Write back changes made to config object
|
||||||
_config.set("description", _descriptionWidget->getLabel(), _domain);
|
String newDomain(_domainWidget->getLabel());
|
||||||
|
if (newDomain != _domain) {
|
||||||
|
if (newDomain.isEmpty() || _config.has_domain(newDomain)) {
|
||||||
|
MessageDialog alert(_gui, "This game ID is already taken. Please choose another one.");
|
||||||
|
alert.runModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_config.rename_domain(_domain, newDomain);
|
||||||
|
}
|
||||||
|
_config.set("description", _descriptionWidget->getLabel(), newDomain);
|
||||||
setResult(1);
|
setResult(1);
|
||||||
close();
|
close();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Dialog::handleCommand(sender, cmd, data);
|
Dialog::handleCommand(sender, cmd, data);
|
||||||
|
Loading…
Reference in New Issue
Block a user