mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +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.
|
// be taken into account, too.
|
||||||
Common::String gameid(name);
|
Common::String gameid(name);
|
||||||
GameDescriptor g = Base::findGame(gameid);
|
GameDescriptor g = Base::findGame(gameid);
|
||||||
if (g["description"].size() > 0)
|
if (g.description().size() > 0)
|
||||||
description = g["description"];
|
description = g.description();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%-20s %s\n", name.c_str(), description.c_str());
|
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.
|
// 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
|
// We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or
|
||||||
// the seperator (instead of '/' use ', ' or ' ').
|
// the seperator (instead of '/' use ', ' or ' ').
|
||||||
const bool hasCustomLanguage = (this->contains("language") && (this->language() != Common::UNK_LANG));
|
const bool hasCustomLanguage = (language() != Common::UNK_LANG);
|
||||||
const bool hasCustomPlatform = (this->contains("platform") && (this->platform() != Common::kPlatformUnknown));
|
const bool hasCustomPlatform = (platform() != Common::kPlatformUnknown);
|
||||||
const bool hasExtraDesc = (extra && extra[0]);
|
const bool hasExtraDesc = (extra && extra[0]);
|
||||||
|
|
||||||
// Adapt the description string if custom platform/language is set.
|
// Adapt the description string if custom platform/language is set.
|
||||||
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
|
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
|
||||||
Common::String descr = this->description();
|
Common::String descr = description();
|
||||||
|
|
||||||
descr += " (";
|
descr += " (";
|
||||||
if (hasCustomLanguage)
|
if (hasCustomLanguage)
|
||||||
descr += Common::getLanguageDescription(this->language());
|
descr += Common::getLanguageDescription(language());
|
||||||
if (hasCustomPlatform) {
|
if (hasCustomPlatform) {
|
||||||
if (hasCustomLanguage)
|
if (hasCustomLanguage)
|
||||||
descr += "/";
|
descr += "/";
|
||||||
descr += Common::getPlatformDescription(this->platform());
|
descr += Common::getPlatformDescription(platform());
|
||||||
}
|
}
|
||||||
if (hasExtraDesc) {
|
if (hasExtraDesc) {
|
||||||
if (hasCustomPlatform || hasCustomLanguage)
|
if (hasCustomPlatform || hasCustomLanguage)
|
||||||
@ -50,7 +50,7 @@ void GameDescriptor::updateDesc(const char *extra) {
|
|||||||
descr += extra;
|
descr += extra;
|
||||||
}
|
}
|
||||||
descr += ")";
|
descr += ")";
|
||||||
this->operator []("description") = descr;
|
setVal("description", descr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
base/game.h
21
base/game.h
@ -24,6 +24,7 @@
|
|||||||
#ifndef BASE_GAME_H
|
#ifndef BASE_GAME_H
|
||||||
#define BASE_GAME_H
|
#define BASE_GAME_H
|
||||||
|
|
||||||
|
#include "common/stdafx.h"
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/hash-str.h"
|
#include "common/hash-str.h"
|
||||||
@ -38,18 +39,18 @@ public:
|
|||||||
GameDescriptor() {}
|
GameDescriptor() {}
|
||||||
|
|
||||||
GameDescriptor(const PlainGameDescriptor &pgd) {
|
GameDescriptor(const PlainGameDescriptor &pgd) {
|
||||||
this->operator []("gameid") = pgd.gameid;
|
setVal("gameid", pgd.gameid);
|
||||||
this->operator []("description") = pgd.description;
|
setVal("description", pgd.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameDescriptor(Common::String g, Common::String d, Common::Language l = Common::UNK_LANG,
|
GameDescriptor(Common::String g, Common::String d, Common::Language l = Common::UNK_LANG,
|
||||||
Common::Platform p = Common::kPlatformUnknown) {
|
Common::Platform p = Common::kPlatformUnknown) {
|
||||||
this->operator []("gameid") = g;
|
setVal("gameid", g);
|
||||||
this->operator []("description") = d;
|
setVal("description", d);
|
||||||
if (l != Common::UNK_LANG)
|
if (l != Common::UNK_LANG)
|
||||||
this->operator []("language") = Common::getLanguageCode(l);
|
setVal("language", Common::getLanguageCode(l));
|
||||||
if (p != Common::kPlatformUnknown)
|
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);
|
void updateDesc(const char *extra = 0);
|
||||||
|
|
||||||
Common::String &gameid() { return this->operator []("gameid"); }
|
Common::String &gameid() { return getVal("gameid"); }
|
||||||
Common::String &description() { return this->operator []("description"); }
|
Common::String &description() { return getVal("description"); }
|
||||||
Common::Language language() { return Common::parseLanguage(this->operator []("language")); }
|
Common::Language language() const { return Common::parseLanguage(getVal("language")); }
|
||||||
Common::Platform platform() { return Common::parsePlatform(this->operator []("platform")); }
|
Common::Platform platform() const { return Common::parsePlatform(getVal("platform")); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** List of games. */
|
/** List of games. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user