mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 04:33:09 +00:00
Make use of HashMap::getVal/setVal, and some cleanup
svn-id: r25138
This commit is contained in:
parent
baaedb1651
commit
f30f00aedc
@ -550,8 +550,8 @@ static void listTargets() {
|
||||
// be taken into account, too.
|
||||
Common::String gameid(name);
|
||||
GameDescriptor g = Base::findGame(gameid);
|
||||
if (g["description"].size() > 0)
|
||||
description = g["description"];
|
||||
if (g.description().size() > 0)
|
||||
description = g.description();
|
||||
}
|
||||
|
||||
printf("%-20s %s\n", name.c_str(), description.c_str());
|
||||
|
@ -28,21 +28,21 @@ void GameDescriptor::updateDesc(const char *extra) {
|
||||
// TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone.
|
||||
// We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or
|
||||
// the seperator (instead of '/' use ', ' or ' ').
|
||||
const bool hasCustomLanguage = (this->contains("language") && (this->language() != Common::UNK_LANG));
|
||||
const bool hasCustomPlatform = (this->contains("platform") && (this->platform() != Common::kPlatformUnknown));
|
||||
const bool hasCustomLanguage = (language() != Common::UNK_LANG);
|
||||
const bool hasCustomPlatform = (platform() != Common::kPlatformUnknown);
|
||||
const bool hasExtraDesc = (extra && extra[0]);
|
||||
|
||||
// Adapt the description string if custom platform/language is set.
|
||||
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
|
||||
Common::String descr = this->description();
|
||||
Common::String descr = description();
|
||||
|
||||
descr += " (";
|
||||
if (hasCustomLanguage)
|
||||
descr += Common::getLanguageDescription(this->language());
|
||||
descr += Common::getLanguageDescription(language());
|
||||
if (hasCustomPlatform) {
|
||||
if (hasCustomLanguage)
|
||||
descr += "/";
|
||||
descr += Common::getPlatformDescription(this->platform());
|
||||
descr += Common::getPlatformDescription(platform());
|
||||
}
|
||||
if (hasExtraDesc) {
|
||||
if (hasCustomPlatform || hasCustomLanguage)
|
||||
@ -50,7 +50,7 @@ void GameDescriptor::updateDesc(const char *extra) {
|
||||
descr += extra;
|
||||
}
|
||||
descr += ")";
|
||||
this->operator []("description") = descr;
|
||||
setVal("description", descr);
|
||||
}
|
||||
}
|
||||
|
||||
|
21
base/game.h
21
base/game.h
@ -24,6 +24,7 @@
|
||||
#ifndef BASE_GAME_H
|
||||
#define BASE_GAME_H
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
#include "common/hash-str.h"
|
||||
@ -38,18 +39,18 @@ public:
|
||||
GameDescriptor() {}
|
||||
|
||||
GameDescriptor(const PlainGameDescriptor &pgd) {
|
||||
this->operator []("gameid") = pgd.gameid;
|
||||
this->operator []("description") = pgd.description;
|
||||
setVal("gameid", pgd.gameid);
|
||||
setVal("description", pgd.description);
|
||||
}
|
||||
|
||||
GameDescriptor(Common::String g, Common::String d, Common::Language l = Common::UNK_LANG,
|
||||
Common::Platform p = Common::kPlatformUnknown) {
|
||||
this->operator []("gameid") = g;
|
||||
this->operator []("description") = d;
|
||||
setVal("gameid", g);
|
||||
setVal("description", d);
|
||||
if (l != Common::UNK_LANG)
|
||||
this->operator []("language") = Common::getLanguageCode(l);
|
||||
setVal("language", Common::getLanguageCode(l));
|
||||
if (p != Common::kPlatformUnknown)
|
||||
this->operator []("platform") = Common::getPlatformCode(p);
|
||||
setVal("platform", Common::getPlatformCode(p));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,10 +58,10 @@ public:
|
||||
*/
|
||||
void updateDesc(const char *extra = 0);
|
||||
|
||||
Common::String &gameid() { return this->operator []("gameid"); }
|
||||
Common::String &description() { return this->operator []("description"); }
|
||||
Common::Language language() { return Common::parseLanguage(this->operator []("language")); }
|
||||
Common::Platform platform() { return Common::parsePlatform(this->operator []("platform")); }
|
||||
Common::String &gameid() { return getVal("gameid"); }
|
||||
Common::String &description() { return getVal("description"); }
|
||||
Common::Language language() const { return Common::parseLanguage(getVal("language")); }
|
||||
Common::Platform platform() const { return Common::parsePlatform(getVal("platform")); }
|
||||
};
|
||||
|
||||
/** List of games. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user