Make 'guest' translatable again, fixed chicken-and-egg issue with initialisation order

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7446 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-01-16 16:56:21 +00:00
parent 6726fbe47a
commit 66e5d396bf
3 changed files with 14 additions and 12 deletions

View File

@ -393,11 +393,7 @@ UserConfig::UserConfig()
m_filename = "config.xml";
m_warning = "";
//m_blacklist_res.clear();
if(!loadConfig() || UserConfigParams::m_all_players.size() == 0)
{
addDefaultPlayer();
saveConfig();
}
} // UserConfig
// -----------------------------------------------------------------------------
@ -423,7 +419,7 @@ void UserConfig::addDefaultPlayer()
class GuestPlayerProfile : public PlayerProfile
{
public:
GuestPlayerProfile() : PlayerProfile(L"Guest")
GuestPlayerProfile() : PlayerProfile(_("Guest"))
{
m_is_guest_account = true;
}

View File

@ -395,8 +395,8 @@ private:
std::string m_filename;
irr::core::stringw m_warning;
void addDefaultPlayer();
public:
/** Create the user config object; does not actually load it, UserConfig::loadConfig needs to be called */
UserConfig();
~UserConfig();
@ -407,6 +407,8 @@ public:
void resetWarning() { m_warning=""; }
void setWarning(irr::core::stringw& warning) { m_warning=warning; }
void addDefaultPlayer();
}; // UserConfig

View File

@ -717,12 +717,9 @@ int handleCmdLine(int argc, char **argv)
void initUserConfig(char *argv[])
{
file_manager = new FileManager(argv);
// FIXME: in which order do we call those? -.-
// the translation manager needs the user config to know if a language preference is set
// the user config needs the translation to translate "Guest"
user_config = new UserConfig(); // needs file_manager
const bool config_ok = user_config->loadConfig();
if (UserConfigParams::m_language.toString() != "system")
{
char buffer[1024];
@ -733,6 +730,13 @@ void initUserConfig(char *argv[])
translations = new Translations(); // needs file_manager
stk_config = new STKConfig(); // in case of --stk-config
// command line parameters
if (!config_ok || UserConfigParams::m_all_players.size() == 0)
{
user_config->addDefaultPlayer();
user_config->saveConfig();
}
} // initUserConfig
//=============================================================================