mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +01:00
custom_titles.ini allowing to group same aliases for several plugins.
This commit is contained in:
parent
9350f51c3b
commit
149e25ebe3
@ -1,5 +1,6 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "gecko/gecko.hpp"
|
||||
@ -196,6 +197,7 @@ void Config::unload(void)
|
||||
m_changed = false;
|
||||
m_filename = emptyString;
|
||||
m_domains.clear();
|
||||
m_groupCustomTitles.clear();
|
||||
}
|
||||
|
||||
void Config::save(bool unload)
|
||||
@ -225,6 +227,18 @@ bool Config::has(const std::string &domain, const std::string &key) const
|
||||
return i->second.find(lowerCase(key)) != i->second.end();
|
||||
}
|
||||
|
||||
void Config::groupCustomTitles(void)
|
||||
{
|
||||
for (Config::DomainMap::iterator k = m_domains.begin(); k != m_domains.end(); ++k)
|
||||
{
|
||||
string uc_domain(upperCase(k->first));
|
||||
istringstream f(uc_domain);
|
||||
string s;
|
||||
while (getline(f, s, ','))
|
||||
m_groupCustomTitles[s] = uc_domain;
|
||||
}
|
||||
}
|
||||
|
||||
void Config::setWString(const string &domain, const string &key, const wstringEx &val)
|
||||
{
|
||||
if (domain.empty() || key.empty()) return;
|
||||
@ -345,6 +359,22 @@ string Config::getString(const string &domain, const string &key, const string &
|
||||
return data;
|
||||
}
|
||||
|
||||
string Config::getStringCustomTitles(const string &domain, const string &key, const string &defVal)
|
||||
{
|
||||
if(domain.empty() || key.empty())
|
||||
return defVal;
|
||||
KeyMap::iterator i = m_groupCustomTitles.find(upperCase(domain));
|
||||
if (i == m_groupCustomTitles.end()) return defVal;
|
||||
string &data = m_domains[i->second][lowerCase(key)];
|
||||
if(data.empty())
|
||||
{
|
||||
data = defVal;
|
||||
//gprintf("setString %s\n", defVal.c_str());
|
||||
m_changed = true;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
vector<string> Config::getStrings(const string &domain, const string &key, char seperator, const string &defVal)
|
||||
{
|
||||
vector<string> retval;
|
||||
|
@ -13,8 +13,9 @@ class Config
|
||||
{
|
||||
public:
|
||||
Config(void);
|
||||
void clear(void) { m_domains.clear(); }
|
||||
void clear(void) { m_domains.clear(); m_groupCustomTitles.clear();}
|
||||
bool load(const char *filename = 0);
|
||||
void groupCustomTitles(void);
|
||||
void unload(void);
|
||||
void save(bool unload = false);
|
||||
bool loaded(void) const { return m_loaded; }
|
||||
@ -32,6 +33,7 @@ public:
|
||||
// Get
|
||||
wstringEx getWString(const std::string &domain, const std::string &key, const wstringEx &defVal = wstringEx());
|
||||
std::string getString(const std::string &domain, const std::string &key, const std::string &defVal = std::string());
|
||||
std::string getStringCustomTitles(const std::string &domain, const std::string &key, const std::string &defVal = std::string());
|
||||
vector<std::string> getStrings(const std::string &domain, const std::string &key, char seperator = ',', const std::string &defval = std::string());
|
||||
bool getBool(const std::string &domain, const std::string &key, bool defVal = false);
|
||||
int getOptBool(const std::string &domain, const std::string &key, int defVal = 2);
|
||||
@ -60,6 +62,7 @@ private:
|
||||
DomainMap m_domains;
|
||||
std::string m_filename;
|
||||
DomainMap::iterator m_iter;
|
||||
KeyMap m_groupCustomTitles;
|
||||
static const std::string emptyString;
|
||||
private:
|
||||
Config(const Config &);
|
||||
|
@ -56,6 +56,7 @@ void ListGenerator::OpenConfigs()
|
||||
if(gameTDB.IsLoaded())
|
||||
gameTDB.SetLanguageCode(gameTDB_Language.c_str());
|
||||
CustomTitles.load(CustomTitlesPath.c_str());
|
||||
CustomTitles.groupCustomTitles();
|
||||
}
|
||||
|
||||
void ListGenerator::CloseConfigs()
|
||||
@ -275,7 +276,7 @@ static void Add_Plugin_Game(char *FullPath)
|
||||
const char *RomFilename = strrchr(FullPath, '/') + 1;
|
||||
*strrchr(RomFilename, '.') = '\0';
|
||||
|
||||
string customTitle = CustomTitles.getString(m_plugin.PluginMagicWord, RomFilename, "");
|
||||
string customTitle = CustomTitles.getStringCustomTitles(m_plugin.PluginMagicWord, RomFilename, "");
|
||||
|
||||
const char *gameTDB_Title = NULL;
|
||||
if(gameTDB.IsLoaded() && customTitle.empty() && m_cacheList.usePluginDBTitles)
|
||||
@ -410,6 +411,7 @@ void ListGenerator::CreateRomList(Config &platform_cfg, const string& romsDir, c
|
||||
}
|
||||
}
|
||||
CustomTitles.load(CustomTitlesPath.c_str());
|
||||
CustomTitles.groupCustomTitles();
|
||||
GetFiles(romsDir.c_str(), FileTypes, Add_Plugin_Game, false, 30);//wow 30 subfolders! really?
|
||||
CloseConfigs();
|
||||
romNamesDB.unload();
|
||||
|
Loading…
Reference in New Issue
Block a user