Store global keymaps into a separate section

svn-id: r40427
This commit is contained in:
Eugene Sandulenko 2009-05-10 17:33:31 +00:00
parent 978758190e
commit 7d79a092b5
3 changed files with 53 additions and 1 deletions

View File

@ -58,7 +58,7 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) {
Keymapper::Keymapper(EventManager *evtMgr)
: _eventMan(evtMgr), _enabled(true), _hardwareKeys(0) {
ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kApplicationDomain);
ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain);
_globalDomain.setConfigDomain(confDom);
}

View File

@ -45,11 +45,19 @@ namespace Common {
const String ConfigManager::kApplicationDomain("scummvm");
const String ConfigManager::kTransientDomain("__TRANSIENT");
#ifdef ENABLE_KEYMAPPER
const String ConfigManager::kKeymapperDomain("keymapper");
#endif
#else
const char *ConfigManager::kApplicationDomain = "scummvm";
const char *ConfigManager::kTransientDomain = "__TRANSIENT";
#ifdef ENABLE_KEYMAPPER
const char *ConfigManager::kKeymapperDomain = "keymapper";
#endif
#endif
#pragma mark -
@ -99,6 +107,10 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
_transientDomain.clear();
_domainSaveOrder.clear();
#ifdef ENABLE_KEYMAPPER
_keymapperDomain.clear();
#endif
// TODO: Detect if a domain occurs multiple times (or likewise, if
// a key occurs multiple times inside one domain).
@ -135,6 +147,10 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
// Store domain comment
if (domain == kApplicationDomain) {
_appDomain.setDomainComment(comment);
#ifdef ENABLE_KEYMAPPER
} else if (domain == kKeymapperDomain) {
_keymapperDomain.setDomainComment(comment);
#endif
} else {
_gameDomains[domain].setDomainComment(comment);
}
@ -177,6 +193,10 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
// Store comment
if (domain == kApplicationDomain) {
_appDomain.setKVComment(key, comment);
#ifdef ENABLE_KEYMAPPER
} else if (domain == kKeymapperDomain) {
_keymapperDomain.setKVComment(key, comment);
#endif
} else {
_gameDomains[domain].setKVComment(key, comment);
}
@ -215,6 +235,10 @@ void ConfigManager::flushToDisk() {
for (i = _domainSaveOrder.begin(); i != _domainSaveOrder.end(); ++i) {
if (kApplicationDomain == *i) {
writeDomain(*stream, *i, _appDomain);
#ifdef ENABLE_KEYMAPPER
} else if (kKeymapperDomain == *i) {
writeDomain(*stream, *i, _keymapperDomain);
#endif
} else if (_gameDomains.contains(*i)) {
writeDomain(*stream, *i, _gameDomains[*i]);
}
@ -226,6 +250,10 @@ void ConfigManager::flushToDisk() {
// Now write the domains which haven't been written yet
if (find(_domainSaveOrder.begin(), _domainSaveOrder.end(), kApplicationDomain) == _domainSaveOrder.end())
writeDomain(*stream, kApplicationDomain, _appDomain);
#ifdef ENABLE_KEYMAPPER
if (find(_domainSaveOrder.begin(), _domainSaveOrder.end(), kKeymapperDomain) == _domainSaveOrder.end())
writeDomain(*stream, kKeymapperDomain, _keymapperDomain);
#endif
for (d = _gameDomains.begin(); d != _gameDomains.end(); ++d) {
if (find(_domainSaveOrder.begin(), _domainSaveOrder.end(), d->_key) == _domainSaveOrder.end())
writeDomain(*stream, d->_key, d->_value);
@ -290,6 +318,10 @@ const ConfigManager::Domain *ConfigManager::getDomain(const String &domName) con
return &_transientDomain;
if (domName == kApplicationDomain)
return &_appDomain;
#ifdef ENABLE_KEYMAPPER
if (domName == kKeymapperDomain)
return &_keymapperDomain;
#endif
if (_gameDomains.contains(domName))
return &_gameDomains[domName];
@ -304,6 +336,10 @@ ConfigManager::Domain *ConfigManager::getDomain(const String &domName) {
return &_transientDomain;
if (domName == kApplicationDomain)
return &_appDomain;
#ifdef ENABLE_KEYMAPPER
if (domName == kKeymapperDomain)
return &_keymapperDomain;
#endif
if (_gameDomains.contains(domName))
return &_gameDomains[domName];

View File

@ -74,11 +74,23 @@ public:
/** The transient (pseudo) domain. */
static const String kTransientDomain;
#ifdef ENABLE_KEYMAPPER
/** The name of keymapper domain used to store the key maps */
static const String kKeymapperDomain;
#endif
#else
static const char *kApplicationDomain;
static const char *kTransientDomain;
const String _emptyString;
#ifdef ENABLE_KEYMAPPER
/** The name of keymapper domain used to store the key maps */
static const char *kKeymapperDomain;
#endif
#endif
void loadDefaultConfigFile();
@ -156,6 +168,10 @@ private:
Domain _appDomain;
Domain _defaultsDomain;
#ifdef ENABLE_KEYMAPPER
Domain _keymapperDomain;
#endif
StringList _domainSaveOrder;
String _activeDomainName;