mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 06:41:51 +00:00
COMMON: Cleanup ConfigManager code
* get rid of ConfigManager::_emptyString * get rid of ConfigManager::Domain::get (use getVal instead) * remove some dead code svn-id: r48417
This commit is contained in:
parent
2872f197d8
commit
4bac9e1b75
@ -584,7 +584,7 @@ static void listTargets() {
|
||||
ConfigManager::DomainMap::const_iterator iter;
|
||||
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
||||
Common::String name(iter->_key);
|
||||
Common::String description(iter->_value.get("description"));
|
||||
Common::String description(iter->_value.getVal("description"));
|
||||
|
||||
if (description.empty()) {
|
||||
// FIXME: At this point, we should check for a "gameid" override
|
||||
@ -617,7 +617,7 @@ static void listSaves(const char *target) {
|
||||
// Grab the gameid from the domain resp. use the target as gameid
|
||||
Common::String gameid;
|
||||
if (domain)
|
||||
gameid = domain->get("gameid");
|
||||
gameid = domain->getVal("gameid");
|
||||
if (gameid.empty())
|
||||
gameid = target;
|
||||
gameid.toLowercase(); // Normalize it to lower case
|
||||
@ -674,8 +674,8 @@ static void runDetectorTest() {
|
||||
int success = 0, failure = 0;
|
||||
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
||||
Common::String name(iter->_key);
|
||||
Common::String gameid(iter->_value.get("gameid"));
|
||||
Common::String path(iter->_value.get("path"));
|
||||
Common::String gameid(iter->_value.getVal("gameid"));
|
||||
Common::String path(iter->_value.getVal("path"));
|
||||
printf("Looking at target '%s', gameid '%s', path '%s' ...\n",
|
||||
name.c_str(), gameid.c_str(), path.c_str());
|
||||
if (path.empty()) {
|
||||
@ -748,8 +748,8 @@ void upgradeTargets() {
|
||||
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
||||
Common::ConfigManager::Domain &dom = iter->_value;
|
||||
Common::String name(iter->_key);
|
||||
Common::String gameid(dom.get("gameid"));
|
||||
Common::String path(dom.get("path"));
|
||||
Common::String gameid(dom.getVal("gameid"));
|
||||
Common::String path(dom.getVal("path"));
|
||||
printf("Looking at target '%s', gameid '%s' ...\n",
|
||||
name.c_str(), gameid.c_str());
|
||||
if (path.empty()) {
|
||||
@ -768,9 +768,9 @@ void upgradeTargets() {
|
||||
continue;
|
||||
}
|
||||
|
||||
Common::Language lang = Common::parseLanguage(dom.get("language"));
|
||||
Common::Platform plat = Common::parsePlatform(dom.get("platform"));
|
||||
Common::String desc(dom.get("description"));
|
||||
Common::Language lang = Common::parseLanguage(dom.getVal("language"));
|
||||
Common::Platform plat = Common::parsePlatform(dom.getVal("platform"));
|
||||
Common::String desc(dom.getVal("description"));
|
||||
|
||||
GameList candidates(EngineMan.detectGames(files));
|
||||
GameDescriptor *g = 0;
|
||||
|
@ -390,10 +390,8 @@ const String & ConfigManager::get(const String &key) const {
|
||||
return (*_activeDomain)[key];
|
||||
else if (_appDomain.contains(key))
|
||||
return _appDomain[key];
|
||||
else if (_defaultsDomain.contains(key))
|
||||
return _defaultsDomain[key];
|
||||
|
||||
return _emptyString;
|
||||
return _defaultsDomain.getVal(key);
|
||||
}
|
||||
|
||||
const String & ConfigManager::get(const String &key, const String &domName) const {
|
||||
@ -412,18 +410,7 @@ const String & ConfigManager::get(const String &key, const String &domName) cons
|
||||
if (domain->contains(key))
|
||||
return (*domain)[key];
|
||||
|
||||
return _defaultsDomain.get(key);
|
||||
|
||||
if (!domain->contains(key)) {
|
||||
#if 1
|
||||
return _emptyString;
|
||||
#else
|
||||
error("ConfigManager::get(%s,%s) called on non-existent key",
|
||||
key.c_str(), domName.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
return (*domain)[key];
|
||||
return _defaultsDomain.getVal(key);
|
||||
}
|
||||
|
||||
int ConfigManager::getInt(const String &key, const String &domName) const {
|
||||
@ -614,14 +601,6 @@ bool ConfigManager::hasGameDomain(const String &domName) const {
|
||||
#pragma mark -
|
||||
|
||||
|
||||
const String &ConfigManager::Domain::get(const String &key) const {
|
||||
const_iterator iter(find(key));
|
||||
if (iter != end())
|
||||
return iter->_value;
|
||||
|
||||
return ConfMan._emptyString;
|
||||
}
|
||||
|
||||
void ConfigManager::Domain::setDomainComment(const String &comment) {
|
||||
_domainComment = comment;
|
||||
}
|
||||
|
@ -56,8 +56,6 @@ public:
|
||||
String _domainComment;
|
||||
|
||||
public:
|
||||
const String &get(const String &key) const;
|
||||
|
||||
void setDomainComment(const String &comment);
|
||||
const String &getDomainComment() const;
|
||||
|
||||
@ -165,8 +163,6 @@ private:
|
||||
Domain * _activeDomain;
|
||||
|
||||
String _filename;
|
||||
|
||||
const String _emptyString;
|
||||
};
|
||||
|
||||
} // End of namespace Common
|
||||
|
@ -123,8 +123,8 @@ void initCommonGFX(bool defaultTo1XScaler) {
|
||||
(
|
||||
!gameDomain ||
|
||||
!gameDomain->contains("gfx_mode") ||
|
||||
!scumm_stricmp(gameDomain->get("gfx_mode").c_str(), "normal") ||
|
||||
!scumm_stricmp(gameDomain->get("gfx_mode").c_str(), "default")
|
||||
!scumm_stricmp(gameDomain->getVal("gfx_mode").c_str(), "normal") ||
|
||||
!scumm_stricmp(gameDomain->getVal("gfx_mode").c_str(), "default")
|
||||
);
|
||||
|
||||
// See if the game should default to 1x scaler
|
||||
|
@ -1355,7 +1355,7 @@ void KyraMetaEngine::removeSaveState(const char *target, int slot) const {
|
||||
// In Kyra games slot 0 can't be deleted, it's for restarting the game(s).
|
||||
// An exception makes Lands of Lore here, it does not have any way to restart the
|
||||
// game except via its main menu.
|
||||
if (slot == 0 && !ConfMan.getDomain(target)->get("gameid").equalsIgnoreCase("lol"))
|
||||
if (slot == 0 && !ConfMan.getDomain(target)->getVal("gameid").equalsIgnoreCase("lol"))
|
||||
return;
|
||||
|
||||
Common::String filename = Kyra::KyraEngine_v1::getSavegameFilename(target, slot);
|
||||
@ -1376,7 +1376,7 @@ SaveStateDescriptor KyraMetaEngine::querySaveMetaInfos(const char *target, int s
|
||||
if (error == Kyra::KyraEngine_v1::kRSHENoError) {
|
||||
SaveStateDescriptor desc(slot, header.description);
|
||||
|
||||
bool lolGame = ConfMan.getDomain(target)->get("gameid").equalsIgnoreCase("lol");
|
||||
bool lolGame = ConfMan.getDomain(target)->getVal("gameid").equalsIgnoreCase("lol");
|
||||
|
||||
// Slot 0 is used for the 'restart game' save in all three Kyrandia games, thus
|
||||
// we prevent it from being deleted.
|
||||
|
@ -489,7 +489,7 @@ void KyraEngine_v1::registerDefaultSettings() {
|
||||
// the global subtitles settings, we're using this hack to enable subtitles
|
||||
// for fan translations
|
||||
const Common::ConfigManager::Domain *cur = ConfMan.getActiveDomain();
|
||||
if (!cur || (cur && cur->get("subtitles").empty()))
|
||||
if (!cur || (cur && cur->getVal("subtitles").empty()))
|
||||
ConfMan.setBool("subtitles", true);
|
||||
}
|
||||
}
|
||||
|
@ -608,8 +608,8 @@ void LauncherDialog::updateListing() {
|
||||
}
|
||||
#endif
|
||||
|
||||
String gameid(iter->_value.get("gameid"));
|
||||
String description(iter->_value.get("description"));
|
||||
String gameid(iter->_value.getVal("gameid"));
|
||||
String description(iter->_value.getVal("description"));
|
||||
|
||||
if (gameid.empty())
|
||||
gameid = iter->_key;
|
||||
|
@ -106,7 +106,7 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
|
||||
}
|
||||
#endif
|
||||
|
||||
Common::String path(iter->_value.get("path"));
|
||||
Common::String path(iter->_value.getVal("path"));
|
||||
// Remove trailing slash, so that "/foo" and "/foo/" match.
|
||||
// This works around a bug in the POSIX FS code (and others?)
|
||||
// where paths are not normalized (so FSNodes refering to identical
|
||||
|
Loading…
x
Reference in New Issue
Block a user