Big refactor : move a lot of strings and config files to use wide strings. For instance to be able to cope with foreign characters in player names
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7174 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
fb8c9edf5e
commit
5bd9afdd7f
@ -140,7 +140,7 @@ void NetworkHttp::checkNewServer()
|
||||
if(UserConfigParams::m_verbosity>=4)
|
||||
{
|
||||
std::cout << "[Addons] Current server: "
|
||||
<< UserConfigParams::m_server_addons.toString()
|
||||
<< (std::string)UserConfigParams::m_server_addons
|
||||
<< std::endl
|
||||
<< "[Addons] New server: " << newserver << std::endl;
|
||||
}
|
||||
@ -197,7 +197,7 @@ std::string NetworkHttp::downloadToStr(std::string url)
|
||||
{
|
||||
CURL *session = curl_easy_init();
|
||||
|
||||
std::string full_url=UserConfigParams::m_server_addons.toString()+"/"+url;
|
||||
std::string full_url = (std::string)UserConfigParams::m_server_addons + "/" + url;
|
||||
curl_easy_setopt(session, CURLOPT_URL, full_url.c_str());
|
||||
|
||||
std::string fout;
|
||||
@ -223,7 +223,7 @@ std::string NetworkHttp::downloadToStr(std::string url)
|
||||
bool download(std::string file, const std::string &save, int * progress_data)
|
||||
{
|
||||
CURL *session = curl_easy_init();
|
||||
std::string full_url=UserConfigParams::m_server_addons.toString()+"/"+file;
|
||||
std::string full_url = (std::string)UserConfigParams::m_server_addons + "/" + file;
|
||||
curl_easy_setopt(session, CURLOPT_URL, full_url.c_str());
|
||||
FILE * fout;
|
||||
if(save != "")
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <string>
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
/**
|
||||
* \brief Class for managing player profiles (name, control configuration, etc.)
|
||||
@ -37,7 +39,7 @@ protected:
|
||||
/** For saving to config file. */
|
||||
GroupUserConfigParam m_player_group;
|
||||
|
||||
StringUserConfigParam m_name;
|
||||
WStringUserConfigParam m_name;
|
||||
|
||||
BoolUserConfigParam m_is_guest_account;
|
||||
|
||||
@ -52,10 +54,10 @@ public:
|
||||
/**
|
||||
* Constructor to create a new player that didn't exist before
|
||||
*/
|
||||
PlayerProfile(const char* name) : m_player_group("Player", "Represents one human player"),
|
||||
m_name(name, "name", &m_player_group), //, m_last_kart_id(-1)
|
||||
m_is_guest_account(false, "guest", &m_player_group),
|
||||
m_use_frequency(0, "use_frequency", &m_player_group)
|
||||
PlayerProfile(const core::stringw& name) : m_player_group("Player", "Represents one human player"),
|
||||
m_name(name, "name", &m_player_group), //, m_last_kart_id(-1)
|
||||
m_is_guest_account(false, "guest", &m_player_group),
|
||||
m_use_frequency(0, "use_frequency", &m_player_group)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xABCD1234;
|
||||
@ -77,36 +79,42 @@ public:
|
||||
m_is_guest_account.findYourDataInAnAttributeOf(node);
|
||||
m_use_frequency.findYourDataInAnAttributeOf(node);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xABCD1234;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
~PlayerProfile()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xDEADBEEF;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void setName(const std::string &name_) {
|
||||
#ifdef DEBUG
|
||||
void setName(const core::stringw& name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
m_name = name_; }
|
||||
#endif
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
const char* getName() const {
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_name.c_str(); }
|
||||
core::stringw getName() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
bool isGuestAccount() const {
|
||||
#ifdef DEBUG
|
||||
bool isGuestAccount() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_is_guest_account; }
|
||||
#endif
|
||||
return m_is_guest_account;
|
||||
}
|
||||
|
||||
//int getLastKartId(){ return m_last_kart_id; }
|
||||
//void setLastKartId(int newLastKartId){ m_last_kart_id = newLastKartId; }
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
class UserConfigParam;
|
||||
@ -61,7 +62,7 @@ GroupUserConfigParam::GroupUserConfigParam(const char* groupName, const char* co
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
void GroupUserConfigParam::write(std::ofstream& stream) const
|
||||
void GroupUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
const int children_amount = m_children.size();
|
||||
|
||||
@ -70,18 +71,18 @@ void GroupUserConfigParam::write(std::ofstream& stream) const
|
||||
for(int n=0; n<children_amount; n++)
|
||||
{
|
||||
if(m_children[n]->comment.size() > 0)
|
||||
stream << "\n " << m_children[n]->paramName << " : " << m_children[n]->comment.c_str();
|
||||
stream << L"\n " << m_children[n]->paramName.c_str() << L" : " << m_children[n]->comment.c_str();
|
||||
}
|
||||
|
||||
|
||||
stream << " -->\n <" << paramName << "\n";
|
||||
stream << L" -->\n <" << paramName.c_str() << "\n";
|
||||
|
||||
// actual values
|
||||
for(int n=0; n<children_amount; n++)
|
||||
for (int n=0; n<children_amount; n++)
|
||||
{
|
||||
stream << " " << m_children[n]->paramName << "=\"" << m_children[n]->toString() << "\"\n";
|
||||
stream << L" " << m_children[n]->paramName.c_str() << L"=\"" << m_children[n]->toString() << L"\"\n";
|
||||
}
|
||||
stream << " />\n\n";
|
||||
stream << L" />\n\n";
|
||||
}
|
||||
|
||||
void GroupUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
@ -103,7 +104,7 @@ void GroupUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
void GroupUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
}
|
||||
std::string GroupUserConfigParam::toString() const
|
||||
irr::core::stringw GroupUserConfigParam::toString() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@ -137,17 +138,17 @@ IntUserConfigParam::IntUserConfigParam(int defaultValue, const char* paramName,
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
|
||||
void IntUserConfigParam::write(std::ofstream& stream) const
|
||||
void IntUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << " <!-- " << comment.c_str() << " -->\n";
|
||||
stream << " <" << paramName << " value=\"" << m_value << "\" />\n\n";
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value << L"\" />\n\n";
|
||||
}
|
||||
|
||||
std::string IntUserConfigParam::toString() const
|
||||
irr::core::stringw IntUserConfigParam::toString() const
|
||||
{
|
||||
char buffer[16];
|
||||
sprintf(buffer, "%i", m_value);
|
||||
return buffer;
|
||||
irr::core::stringw tmp;
|
||||
tmp += m_value;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void IntUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
@ -190,12 +191,12 @@ StringUserConfigParam::StringUserConfigParam(const char* defaultValue, const cha
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
|
||||
|
||||
void StringUserConfigParam::write(std::ofstream& stream) const
|
||||
void StringUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << " <!-- " << comment.c_str() << " -->\n";
|
||||
stream << " <" << paramName << " value=\"" << m_value << "\" />\n\n";
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value.c_str() << L"\" />\n\n";
|
||||
}
|
||||
|
||||
void StringUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
@ -208,11 +209,51 @@ void StringUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
|
||||
std::string StringUserConfigParam::toString() const
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
WStringUserConfigParam::WStringUserConfigParam(const core::stringw& defaultValue, const char* paramName, const char* comment)
|
||||
{
|
||||
return m_value;
|
||||
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
|
||||
this->paramName = paramName;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
|
||||
WStringUserConfigParam::WStringUserConfigParam(const core::stringw& defaultValue, const char* paramName,
|
||||
GroupUserConfigParam* group, const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
|
||||
this->paramName = paramName;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
|
||||
|
||||
void WStringUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value << L"\" />\n\n";
|
||||
}
|
||||
|
||||
void WStringUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
if(child == NULL) return;
|
||||
|
||||
child->get( "value", &m_value );
|
||||
}
|
||||
|
||||
void WStringUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
BoolUserConfigParam::BoolUserConfigParam(bool defaultValue, const char* paramName, const char* comment)
|
||||
@ -236,10 +277,10 @@ BoolUserConfigParam::BoolUserConfigParam(bool defaultValue, const char* paramNam
|
||||
}
|
||||
|
||||
|
||||
void BoolUserConfigParam::write(std::ofstream& stream) const
|
||||
void BoolUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << " <!-- " << comment.c_str() << " -->\n";
|
||||
stream << " <" << paramName << " value=\"" << (m_value ? "true" : "false" ) << "\" />\n\n";
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << (m_value ? L"true" : L"false" ) << L"\" />\n\n";
|
||||
}
|
||||
void BoolUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
@ -282,9 +323,9 @@ void BoolUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
}
|
||||
}
|
||||
|
||||
std::string BoolUserConfigParam::toString() const
|
||||
irr::core::stringw BoolUserConfigParam::toString() const
|
||||
{
|
||||
return (m_value ? "true" : "false" );
|
||||
return (m_value ? L"true" : L"false" );
|
||||
}
|
||||
|
||||
|
||||
@ -311,10 +352,10 @@ FloatUserConfigParam::FloatUserConfigParam(float defaultValue, const char* param
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
|
||||
void FloatUserConfigParam::write(std::ofstream& stream) const
|
||||
void FloatUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << " <!-- " << comment.c_str() << " -->\n";
|
||||
stream << " <" << paramName << " value=\"" << m_value << "\" />\n\n";
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value << L"\" />\n\n";
|
||||
}
|
||||
|
||||
void FloatUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
@ -330,11 +371,11 @@ void FloatUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
|
||||
std::string FloatUserConfigParam::toString() const
|
||||
irr::core::stringw FloatUserConfigParam::toString() const
|
||||
{
|
||||
char buffer[16];
|
||||
sprintf(buffer, "%f", m_value);
|
||||
return buffer;
|
||||
irr::core::stringw tmp;
|
||||
tmp += m_value;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// =====================================================================================
|
||||
@ -486,26 +527,27 @@ void UserConfig::saveConfig()
|
||||
|
||||
const std::string filename = dir + "/" + m_filename;
|
||||
|
||||
std::ofstream configfile;
|
||||
configfile.open (filename.c_str());
|
||||
|
||||
if(!configfile.is_open())
|
||||
try
|
||||
{
|
||||
std::cerr << "Failed to open " << filename.c_str() << " for writing, user config won't be saved\n";
|
||||
return;
|
||||
XMLWriter configfile(filename.c_str());
|
||||
|
||||
configfile << L"<?xml version=\"1.0\"?>\n";
|
||||
configfile << L"<stkconfig version=\"" << CURRENT_CONFIG_VERSION << L"\" >\n\n";
|
||||
|
||||
const int paramAmount = all_params.size();
|
||||
for(int i=0; i<paramAmount; i++)
|
||||
{
|
||||
//std::cout << "saving parameter " << i << " to file\n";
|
||||
all_params[i].write(configfile);
|
||||
}
|
||||
|
||||
configfile << L"</stkconfig>\n";
|
||||
configfile.close();
|
||||
}
|
||||
|
||||
configfile << "<?xml version=\"1.0\"?>\n";
|
||||
configfile << "<stkconfig version=\"" << CURRENT_CONFIG_VERSION << "\" >\n\n";
|
||||
|
||||
const int paramAmount = all_params.size();
|
||||
for(int i=0; i<paramAmount; i++)
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
//std::cout << "saving parameter " << i << " to file\n";
|
||||
all_params[i].write(configfile);
|
||||
std::cerr << "[UserConfig::saveConfig] ERROR: Failed to write config to " << filename.c_str()
|
||||
<< "; cause : " << e.what() << "\n";
|
||||
}
|
||||
|
||||
configfile << "</stkconfig>\n";
|
||||
configfile.close();
|
||||
|
||||
} // saveConfig
|
||||
|
@ -46,12 +46,15 @@ const int CURRENT_CONFIG_VERSION = 8;
|
||||
#include <fstream>
|
||||
|
||||
#include "irrlicht.h"
|
||||
using irr::core::stringc;
|
||||
using irr::core::stringw;
|
||||
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
class XMLNode;
|
||||
class XMLWriter;
|
||||
class PlayerProfile;
|
||||
|
||||
/**
|
||||
@ -64,10 +67,10 @@ protected:
|
||||
std::string paramName, comment;
|
||||
public:
|
||||
virtual ~UserConfigParam();
|
||||
virtual void write(std::ofstream& stream) const = 0;
|
||||
virtual void write(XMLWriter& stream) const = 0;
|
||||
virtual void findYourDataInAChildOf(const XMLNode* node) = 0;
|
||||
virtual void findYourDataInAnAttributeOf(const XMLNode* node) = 0;
|
||||
virtual std::string toString() const = 0;
|
||||
virtual irr::core::stringw toString() const = 0;
|
||||
};
|
||||
|
||||
class GroupUserConfigParam : public UserConfigParam
|
||||
@ -75,12 +78,12 @@ class GroupUserConfigParam : public UserConfigParam
|
||||
std::vector<UserConfigParam*> m_children;
|
||||
public:
|
||||
GroupUserConfigParam(const char* name, const char* comment=NULL);
|
||||
void write(std::ofstream& stream) const;
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
void addChild(UserConfigParam* child);
|
||||
std::string toString() const;
|
||||
irr::core::stringw toString() const;
|
||||
};
|
||||
|
||||
class IntUserConfigParam : public UserConfigParam
|
||||
@ -93,11 +96,11 @@ public:
|
||||
IntUserConfigParam(int defaultValue, const char* paramName, const char* comment = NULL);
|
||||
IntUserConfigParam(int defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
|
||||
void write(std::ofstream& stream) const;
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
std::string toString() const;
|
||||
irr::core::stringw toString() const;
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
|
||||
operator int() const { return m_value; }
|
||||
@ -117,13 +120,13 @@ public:
|
||||
StringUserConfigParam(const char* defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
|
||||
|
||||
void write(std::ofstream& stream) const;
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
|
||||
std::string toString() const;
|
||||
irr::core::stringw toString() const { return m_value.c_str(); }
|
||||
|
||||
operator std::string() const { return m_value; }
|
||||
std::string& operator=(const std::string& v) { m_value = v; return m_value; }
|
||||
@ -132,6 +135,32 @@ public:
|
||||
const char* c_str() const { return m_value.c_str(); }
|
||||
};
|
||||
|
||||
class WStringUserConfigParam : public UserConfigParam
|
||||
{
|
||||
stringw m_value;
|
||||
stringw m_default_value;
|
||||
|
||||
public:
|
||||
|
||||
WStringUserConfigParam(const stringw& defaultValue, const char* paramName, const char* comment = NULL);
|
||||
WStringUserConfigParam(const stringw& defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
|
||||
irr::core::stringw toString() const { return m_value; }
|
||||
|
||||
operator stringw() const { return m_value; }
|
||||
stringw& operator=(const stringw& v) { m_value = v; return m_value; }
|
||||
stringw& operator=(const WStringUserConfigParam& v) { m_value = (stringw)v; return m_value; }
|
||||
|
||||
const wchar_t* c_str() const { return m_value.c_str(); }
|
||||
};
|
||||
|
||||
class BoolUserConfigParam : public UserConfigParam
|
||||
{
|
||||
bool m_value;
|
||||
@ -142,11 +171,11 @@ public:
|
||||
BoolUserConfigParam(bool defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
|
||||
|
||||
void write(std::ofstream& stream) const;
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
std::string toString() const;
|
||||
irr::core::stringw toString() const;
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
|
||||
operator bool() const { return m_value; }
|
||||
@ -163,11 +192,11 @@ public:
|
||||
FloatUserConfigParam(float defaultValue, const char* paramName, const char* comment = NULL);
|
||||
FloatUserConfigParam(float defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
|
||||
void write(std::ofstream& stream) const;
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
std::string toString() const;
|
||||
irr::core::stringw toString() const;
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
|
||||
operator float() const { return m_value; }
|
||||
|
@ -15,6 +15,7 @@
|
||||
950D448C118DEE3C006CFC41 /* CGUISpriteBank.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 950D448A118DEE3C006CFC41 /* CGUISpriteBank.cpp */; };
|
||||
950D45D1118E040E006CFC41 /* options_screen_input2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 950D45CF118E040E006CFC41 /* options_screen_input2.cpp */; };
|
||||
9516B07E12629C4E005F9493 /* sfx_buffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9516B07C12629C4E005F9493 /* sfx_buffer.cpp */; };
|
||||
951B50AE12C9698B004F6993 /* xml_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951B50AD12C9698B004F6993 /* xml_writer.cpp */; };
|
||||
951B7D19108E52C900BC03AE /* challenges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951B7D18108E52C900BC03AE /* challenges.cpp */; };
|
||||
951BC65E0FFAF290006B5FF1 /* ipo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951BC65C0FFAF290006B5FF1 /* ipo.cpp */; };
|
||||
9522F125107948AD0067ECF5 /* main_menu_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9522F124107948AD0067ECF5 /* main_menu_screen.cpp */; };
|
||||
@ -343,6 +344,8 @@
|
||||
950D45D0118E040E006CFC41 /* options_screen_input2.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = options_screen_input2.hpp; path = ../../states_screens/options_screen_input2.hpp; sourceTree = SOURCE_ROOT; };
|
||||
9516B07C12629C4E005F9493 /* sfx_buffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sfx_buffer.cpp; path = ../../audio/sfx_buffer.cpp; sourceTree = SOURCE_ROOT; };
|
||||
9516B07D12629C4E005F9493 /* sfx_buffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = sfx_buffer.hpp; path = ../../audio/sfx_buffer.hpp; sourceTree = SOURCE_ROOT; };
|
||||
951B50AD12C9698B004F6993 /* xml_writer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = xml_writer.cpp; path = ../../io/xml_writer.cpp; sourceTree = SOURCE_ROOT; };
|
||||
951B50AF12C96A13004F6993 /* xml_writer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = xml_writer.hpp; path = ../../io/xml_writer.hpp; sourceTree = SOURCE_ROOT; };
|
||||
951B7D17108E52C900BC03AE /* challenges.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = challenges.hpp; path = ../../states_screens/challenges.hpp; sourceTree = SOURCE_ROOT; };
|
||||
951B7D18108E52C900BC03AE /* challenges.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = challenges.cpp; path = ../../states_screens/challenges.cpp; sourceTree = SOURCE_ROOT; };
|
||||
951BC65C0FFAF290006B5FF1 /* ipo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ipo.cpp; path = ../../animations/ipo.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@ -2133,6 +2136,8 @@
|
||||
9505570F0F6963790056E88C /* file_manager.hpp */,
|
||||
95C65D760F532F7D00BE7BA7 /* xml_node.cpp */,
|
||||
95C65D770F532F7D00BE7BA7 /* xml_node.hpp */,
|
||||
951B50AD12C9698B004F6993 /* xml_writer.cpp */,
|
||||
951B50AF12C96A13004F6993 /* xml_writer.hpp */,
|
||||
);
|
||||
name = io;
|
||||
path = ../../io;
|
||||
@ -2720,6 +2725,7 @@
|
||||
953C304E12BEF384005BB4CD /* tutorial_data.cpp in Sources */,
|
||||
9538E2B912C25D6800172896 /* addons_manager.cpp in Sources */,
|
||||
9538E2BA12C25D6800172896 /* network_http.cpp in Sources */,
|
||||
951B50AE12C9698B004F6993 /* xml_writer.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -165,7 +165,16 @@ int XMLNode::get(const std::string &attribute, std::string *value) const
|
||||
*value=core::stringc(o->second).c_str();
|
||||
return 1;
|
||||
} // get
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
int XMLNode::get(const std::string &attribute, core::stringw *value) const
|
||||
{
|
||||
if(m_attributes.size()==0) return 0;
|
||||
std::map<std::string, core::stringw>::const_iterator o;
|
||||
o = m_attributes.find(attribute);
|
||||
if(o==m_attributes.end()) return 0;
|
||||
*value = o->second;
|
||||
return 1;
|
||||
} // get
|
||||
// ----------------------------------------------------------------------------
|
||||
int XMLNode::get(const std::string &attribute, core::vector2df *value) const
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
const XMLNode *getNode(unsigned int i) const;
|
||||
unsigned int getNumNodes() const {return m_nodes.size(); }
|
||||
int get(const std::string &attribute, std::string *value) const;
|
||||
int get(const std::string &attribute, core::stringw *value) const;
|
||||
int get(const std::string &attribute, int *value) const;
|
||||
int get(const std::string &attribute, unsigned int *value) const;
|
||||
int get(const std::string &attribute, float *value) const;
|
||||
|
65
src/io/xml_writer.cpp
Normal file
65
src/io/xml_writer.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "io/xml_writer.hpp"
|
||||
#include <wchar.h>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter::XMLWriter(const char* dest) : m_base(dest, std::ios::out | std::ios::binary)
|
||||
{
|
||||
if (!m_base.is_open())
|
||||
{
|
||||
throw std::runtime_error("Failed to open file for writing : " + std::string(dest));
|
||||
}
|
||||
|
||||
// FIXME: make sure the BOM makes sense on platforms where sizeof(wchar_t) is 32 bits
|
||||
// FIXME: make sure to properly handle endianness
|
||||
wchar_t BOM = 0xFEFF;
|
||||
|
||||
m_base.write((char *) &BOM, sizeof(wchar_t));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter& XMLWriter::operator<< (const irr::core::stringw& txt)
|
||||
{
|
||||
m_base.write((char *) txt.c_str(), txt.size() * sizeof(wchar_t));
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter& XMLWriter::operator<< (const wchar_t*txt)
|
||||
{
|
||||
m_base.write((char *) txt, wcslen(txt) * sizeof(wchar_t));
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void XMLWriter::close()
|
||||
{
|
||||
m_base.close();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
54
src/io/xml_writer.hpp
Normal file
54
src/io/xml_writer.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_XML_WRITER_HPP
|
||||
#define HEADER_XML_WRITER_HPP
|
||||
|
||||
#include <fstream>
|
||||
#include <irrlicht.h>
|
||||
|
||||
/**
|
||||
* \brief utility class used to write wide (UTF-16 or UTF-32, depending of size of wchar_t) XML files
|
||||
* \note the inner base class (ofstream) is not public because it will take in any kind of data, and
|
||||
* we only want to accept arrays of wchar_t to make sure we get reasonable files out
|
||||
* \ingroup io
|
||||
*/
|
||||
class XMLWriter
|
||||
{
|
||||
std::ofstream m_base;
|
||||
public:
|
||||
|
||||
XMLWriter(const char* dest);
|
||||
|
||||
XMLWriter& operator<< (const irr::core::stringw& txt);
|
||||
XMLWriter& operator<< (const wchar_t* txt);
|
||||
|
||||
template<typename T>
|
||||
XMLWriter& operator<< (const T t)
|
||||
{
|
||||
irr::core::stringw tmp;
|
||||
tmp += t;
|
||||
(*this) << tmp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void close();
|
||||
};
|
||||
|
||||
#endif
|
@ -63,11 +63,11 @@ public:
|
||||
|
||||
allocate(getCharLength() // m_kart_info.getLocalPlayerId())
|
||||
+getStringLength(m_kart_info.getKartName())
|
||||
+getStringLength(m_kart_info.getPlayerName())
|
||||
+m_kart_info.getPlayerName().size() + 1 // FIXME: encoding issues
|
||||
+getCharLength()); // m_num_local_players)
|
||||
addChar(m_kart_info.getLocalPlayerId());
|
||||
addString(m_kart_info.getKartName());
|
||||
addString(m_kart_info.getPlayerName());
|
||||
addString(core::stringc(m_kart_info.getPlayerName().c_str()).c_str()); // FIXME: encoding issues
|
||||
// Piggy backing this information saves sending it as a separate
|
||||
// message. It is actually only required in the first message
|
||||
if(host_id>-1)
|
||||
@ -86,7 +86,7 @@ public:
|
||||
{
|
||||
m_kart_info.setLocalPlayerId(getChar());
|
||||
m_kart_info.setKartName(getString());
|
||||
m_kart_info.setPlayerName(getString());
|
||||
m_kart_info.setPlayerName(core::stringw(getString().c_str())); // FIXME: encoding issues
|
||||
m_num_local_players = getChar();
|
||||
} // CharacterSelectedMessage(EnetPacket)
|
||||
|
||||
|
@ -72,7 +72,7 @@ void ConnectMessage::setId()
|
||||
{
|
||||
char hostname[256];
|
||||
gethostname(hostname, 255);
|
||||
const std::string& id = StateManager::get()->getActivePlayerProfile(0)->getName();
|
||||
const std::string& id = core::stringc(StateManager::get()->getActivePlayerProfile(0)->getName()).c_str();
|
||||
std::ostringstream o;
|
||||
o << id << '@' << hostname;
|
||||
m_id = o.str();
|
||||
|
@ -46,7 +46,7 @@ RaceInfoMessage::RaceInfoMessage(const std::vector<RemoteKartInfo>& kart_info)
|
||||
+ getCharLength() // kart_info[i].getHostId())
|
||||
+ getStringLength(kart_info[i].getKartName())
|
||||
+ getCharLength() // kart_info[i].getLocalPlayerId())
|
||||
+ getStringLength(kart_info[i].getPlayerName());
|
||||
+ kart_info[i].getPlayerName().size() + 1; // FIXME: encoding issues
|
||||
}
|
||||
const std::vector<std::string>& rkl=race_manager->getAIKartList();
|
||||
len += getStringVectorLength(rkl);
|
||||
@ -71,7 +71,7 @@ RaceInfoMessage::RaceInfoMessage(const std::vector<RemoteKartInfo>& kart_info)
|
||||
addChar(kart_info[i].getHostId());
|
||||
addString(kart_info[i].getKartName());
|
||||
addChar(kart_info[i].getLocalPlayerId());
|
||||
addString(kart_info[i].getPlayerName());
|
||||
addString( core::stringc(kart_info[i].getPlayerName().c_str()).c_str()); // FIXME: encoding issues
|
||||
}
|
||||
addStringVector(rkl);
|
||||
} // RaceInfoMessage
|
||||
@ -103,7 +103,7 @@ RaceInfoMessage::RaceInfoMessage(ENetPacket* pkt):Message(pkt, MT_RACE_INFO)
|
||||
kart_info[i].setHostId(getChar());
|
||||
kart_info[i].setKartName(getString());
|
||||
kart_info[i].setLocalPlayerId(getChar());
|
||||
kart_info[i].setPlayerName(getString());
|
||||
kart_info[i].setPlayerName( core::stringw(getString().c_str()) );
|
||||
}
|
||||
|
||||
// Set the player kart information
|
||||
|
@ -21,18 +21,19 @@
|
||||
#define HEADER_REMOTE_KART_INFO_HPP
|
||||
|
||||
#include <string>
|
||||
#include "irrlicht.h"
|
||||
|
||||
class RemoteKartInfo
|
||||
{
|
||||
std::string m_kart_name;
|
||||
std::string m_user_name;
|
||||
int m_local_player_id;
|
||||
int m_global_player_id;
|
||||
int m_host_id;
|
||||
std::string m_kart_name;
|
||||
irr::core::stringw m_user_name;
|
||||
int m_local_player_id;
|
||||
int m_global_player_id;
|
||||
int m_host_id;
|
||||
|
||||
public:
|
||||
RemoteKartInfo(int player_id, const std::string& kart_name,
|
||||
const std::string& user_name, int host_id)
|
||||
const irr::core::stringw& user_name, int host_id)
|
||||
: m_kart_name(kart_name), m_user_name(user_name),
|
||||
m_local_player_id(player_id), m_host_id(host_id)
|
||||
{};
|
||||
@ -42,7 +43,7 @@ public:
|
||||
RemoteKartInfo() {m_kart_name=""; m_user_name="";
|
||||
m_host_id=-1; m_local_player_id=-1;}
|
||||
void setKartName(const std::string& n) { m_kart_name = n; }
|
||||
void setPlayerName(const std::string& u) { m_user_name = u; }
|
||||
void setPlayerName(const irr::core::stringw& u) { m_user_name = u; }
|
||||
void setHostId(int id) { m_host_id = id; }
|
||||
void setLocalPlayerId(int id) { m_local_player_id = id; }
|
||||
void setGlobalPlayerId(int id) { m_global_player_id = id; }
|
||||
@ -50,7 +51,7 @@ public:
|
||||
int getLocalPlayerId() const { return m_local_player_id; }
|
||||
int getGlobalPlayerId() const { return m_global_player_id; }
|
||||
const std::string& getKartName() const { return m_kart_name; }
|
||||
const std::string& getPlayerName() const { return m_user_name; }
|
||||
const irr::core::stringw& getPlayerName() const { return m_user_name; }
|
||||
bool operator<(const RemoteKartInfo& other) const
|
||||
{
|
||||
return ((m_host_id<other.m_host_id) ||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -142,16 +143,15 @@ void HighscoreManager::saveHighscores()
|
||||
|
||||
try
|
||||
{
|
||||
std::ofstream highscore_file;
|
||||
highscore_file.open(m_filename.c_str());
|
||||
highscore_file << "<?xml version=\"1.0\"?>\n";
|
||||
highscore_file << "<highscores version=\"" << CURRENT_HSCORE_FILE_VERSION<< "\">\n";
|
||||
XMLWriter highscore_file(m_filename.c_str());
|
||||
highscore_file << L"<?xml version=\"1.0\"?>\n";
|
||||
highscore_file << L"<highscores version=\"" << CURRENT_HSCORE_FILE_VERSION << "\">\n";
|
||||
|
||||
for(unsigned int i=0; i<m_all_scores.size(); i++)
|
||||
{
|
||||
m_all_scores[i]->writeEntry(highscore_file);
|
||||
}
|
||||
highscore_file << "</highscores>\n";
|
||||
highscore_file << L"</highscores>\n";
|
||||
highscore_file.close();
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "io/xml_node.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -101,7 +102,7 @@ void Highscores::readEntry(const XMLNode &node)
|
||||
* resulting in empty entries here.
|
||||
* \param writer The file stream to write the data to.
|
||||
*/
|
||||
void Highscores::writeEntry(std::ofstream &writer)
|
||||
void Highscores::writeEntry(XMLWriter &writer)
|
||||
{
|
||||
// Only
|
||||
bool one_is_set = false;
|
||||
@ -109,24 +110,24 @@ void Highscores::writeEntry(std::ofstream &writer)
|
||||
one_is_set |= m_time[i]>=0;
|
||||
if(!one_is_set) return;
|
||||
|
||||
writer << " <highscore track-name =\"" <<m_track <<"\"\n";
|
||||
writer << " number-karts =\"" <<m_number_of_karts<<"\"\n";
|
||||
writer << " difficulty =\"" <<m_difficulty <<"\"\n";
|
||||
writer << " hscore-type =\"" <<m_highscore_type <<"\"\n";
|
||||
writer << " number-of-laps=\"" <<m_number_of_laps <<"\">\n";
|
||||
writer << L" <highscore track-name =\"" << m_track.c_str() << "\"\n";
|
||||
writer << L" number-karts =\"" << m_number_of_karts << "\"\n";
|
||||
writer << L" difficulty =\"" << m_difficulty << "\"\n";
|
||||
writer << L" hscore-type =\"" << m_highscore_type.c_str() << "\"\n";
|
||||
writer << L" number-of-laps=\"" << m_number_of_laps << "\">\n";
|
||||
|
||||
for(int i=0; i<HIGHSCORE_LEN; i++)
|
||||
{
|
||||
if (m_time[i] > 0.0f)
|
||||
{
|
||||
assert(m_kart_name[i].size() > 0);
|
||||
writer << " <entry time =\""<<m_time[i]<<"\"\n";
|
||||
writer << " name =\""<<m_name[i]<<"\"\n";
|
||||
writer << " kartname=\""<<m_kart_name[i]
|
||||
<< "\"/>\n";
|
||||
writer << L" <entry time =\"" << m_time[i] << L"\"\n";
|
||||
writer << L" name =\"" << m_name[i] << L"\"\n";
|
||||
writer << L" kartname=\"" << m_kart_name[i].c_str()
|
||||
<< L"\"/>\n";
|
||||
}
|
||||
} // for i
|
||||
writer << " </highscore>\n";
|
||||
writer << L" </highscore>\n";
|
||||
} // writeEntry
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -148,7 +149,7 @@ int Highscores::matches(HighscoreType highscore_type,
|
||||
* otherwise a 0.
|
||||
*/
|
||||
int Highscores::addData(const std::string& kart_name,
|
||||
const std::string& name, const float time)
|
||||
const core::stringw& name, const float time)
|
||||
{
|
||||
int position=-1;
|
||||
for(int i=0; i<HIGHSCORE_LEN; i++)
|
||||
@ -200,7 +201,7 @@ int Highscores::getNumberEntries() const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void Highscores::getEntry(int number, std::string &kart_name,
|
||||
std::string &name, float *const time) const
|
||||
core::stringw &name, float *const time) const
|
||||
{
|
||||
if(number<0 || number>getNumberEntries())
|
||||
{
|
||||
|
@ -22,11 +22,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
#include "irrlicht.h"
|
||||
|
||||
class XMLNode;
|
||||
class XMLWriter;
|
||||
|
||||
/**
|
||||
* Represents one highscore entry, i.e. the (atm up to three) highscores
|
||||
@ -46,7 +48,7 @@ private:
|
||||
int m_difficulty;
|
||||
int m_number_of_laps;
|
||||
std::string m_kart_name[HIGHSCORE_LEN];
|
||||
std::string m_name[HIGHSCORE_LEN];
|
||||
irr::core::stringw m_name[HIGHSCORE_LEN];
|
||||
float m_time[HIGHSCORE_LEN];
|
||||
public:
|
||||
/** Creates a new entry
|
||||
@ -59,15 +61,15 @@ public:
|
||||
Highscores (const XMLNode &node);
|
||||
|
||||
void readEntry (const XMLNode &node);
|
||||
void writeEntry(std::ofstream &writer);
|
||||
void writeEntry(XMLWriter &writer);
|
||||
int matches (HighscoreType highscore_type, int num_karts,
|
||||
const RaceManager::Difficulty difficulty,
|
||||
const std::string track, const int number_of_laps);
|
||||
int addData (const std::string& kart_name,
|
||||
const std::string& name, const float time);
|
||||
const irr::core::stringw& name, const float time);
|
||||
int getNumberEntries() const;
|
||||
void getEntry (int number, std::string &kart_name,
|
||||
std::string &name, float *const time) const;
|
||||
irr::core::stringw &name, float *const time) const;
|
||||
}; // Highscores
|
||||
|
||||
#endif
|
||||
|
@ -225,15 +225,14 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
|
||||
std::string timebuffer;
|
||||
for (unsigned int i=0; i<num_scores; i++)
|
||||
{
|
||||
std::string kart_name, name;
|
||||
std::string kart_name;
|
||||
core::stringw playerName;
|
||||
float T;
|
||||
hs->getEntry(i, kart_name, name, &T);
|
||||
hs->getEntry(i, kart_name, playerName, &T);
|
||||
timebuffer = StringUtils::timeToString(T);
|
||||
|
||||
const int line_from = lines_from_y + text_height*(i*3);
|
||||
|
||||
stringw playerName = name.c_str();
|
||||
|
||||
|
||||
core::rect< s32 > linearea(m_area.getWidth()*2/3, line_from,
|
||||
m_area.getWidth(), line_from + text_height);
|
||||
GUIEngine::getGUIEnv()->addStaticText( playerName.c_str(),
|
||||
|
@ -230,7 +230,7 @@ void TrackInfoDialog::updateHighScores()
|
||||
const int amount = highscores->getNumberEntries();
|
||||
|
||||
std::string kart_name;
|
||||
std::string name;
|
||||
core::stringw name;
|
||||
float time;
|
||||
|
||||
// fill highscore entries
|
||||
@ -244,7 +244,8 @@ void TrackInfoDialog::updateHighScores()
|
||||
char buffer[256];
|
||||
|
||||
highscores->getEntry(n, kart_name, name, &time);
|
||||
sprintf(buffer, "%s : %.2f s\n", name.c_str(), time);
|
||||
|
||||
sprintf(buffer, " : %.2f s\n", time);
|
||||
|
||||
const KartProperties* prop = kart_properties_manager->getKart(kart_name);
|
||||
if (prop != NULL)
|
||||
@ -254,7 +255,7 @@ void TrackInfoDialog::updateHighScores()
|
||||
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
|
||||
m_kart_icons[n]->setImage(kart_icon_texture);
|
||||
}
|
||||
line = buffer;
|
||||
line = name + buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ public:
|
||||
m_children.push_back(m_model_view);
|
||||
|
||||
// Init kart model
|
||||
const std::string default_kart = UserConfigParams::m_default_kart.toString();
|
||||
const std::string default_kart = UserConfigParams::m_default_kart;
|
||||
const KartProperties* props = kart_properties_manager->getKart(default_kart);
|
||||
if(!props)
|
||||
{
|
||||
@ -1147,8 +1147,8 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
|
||||
const std::string& selectedKart = selections[m_kart_widgets.get(n)];
|
||||
if (selectedKart.size() > 0)
|
||||
{
|
||||
std::cout << m_kart_widgets[n].getAssociatedPlayer()->getProfile()->getName() << " selected "
|
||||
<< selectedKart.c_str() << "\n";
|
||||
//std::cout << m_kart_widgets[n].getAssociatedPlayer()->getProfile()->getName() << " selected "
|
||||
// << selectedKart.c_str() << "\n";
|
||||
const bool success = w->setSelection(selectedKart.c_str(), n, true);
|
||||
if (!success)
|
||||
{
|
||||
@ -1375,7 +1375,7 @@ void KartSelectionScreen::allPlayersDone()
|
||||
std::cout << "[KartSelectionScreen] " << players.size() << " players :\n";
|
||||
for (int n=0; n<players.size(); n++)
|
||||
{
|
||||
std::cout << " Player " << n << " is " << players[n].getConstProfile()->getName()
|
||||
std::cout << " Player " << n << " is " << core::stringc(players[n].getConstProfile()->getName().c_str()).c_str()
|
||||
<< " on " << players[n].getDevice()->m_name << std::endl;
|
||||
}
|
||||
}
|
||||
@ -1491,15 +1491,6 @@ bool KartSelectionScreen::validateIdentChoices()
|
||||
if (m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
|
||||
m_kart_widgets[m].getAssociatedPlayer()->getProfile())
|
||||
{
|
||||
if (UserConfigParams::m_verbosity >= 5)
|
||||
{
|
||||
printf("[KartSelectionScreen] Identity conflict!!\n");
|
||||
std::cout << " Player " << n << " chose "
|
||||
<< m_kart_widgets[n].getAssociatedPlayer()->getProfile()->getName() << std::endl;
|
||||
std::cout << " Player " << m << " chose "
|
||||
<< m_kart_widgets[m].getAssociatedPlayer()->getProfile()->getName() << std::endl;
|
||||
}
|
||||
|
||||
// two players took the same name. check if one is ready
|
||||
if (!m_kart_widgets[n].isReady() && m_kart_widgets[m].isReady())
|
||||
{
|
||||
|
@ -69,7 +69,8 @@ void OptionsScreenPlayers::init()
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for(int n=0; n<playerAmount; n++)
|
||||
{
|
||||
players->addItem( UserConfigParams::m_all_players[n].getName(),
|
||||
// FIXME: encoding issues
|
||||
players->addItem( core::stringc(UserConfigParams::m_all_players[n].getName().c_str()).c_str(),
|
||||
UserConfigParams::m_all_players[n].getName() );
|
||||
}
|
||||
} // init
|
||||
@ -106,7 +107,8 @@ bool OptionsScreenPlayers::gotNewPlayerName(const stringw& newName, PlayerProfil
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for(int n=0; n<playerAmount; n++)
|
||||
{
|
||||
players->addItem(UserConfigParams::m_all_players[n].getName(),
|
||||
// FIXME: encoding issues
|
||||
players->addItem(core::stringc(UserConfigParams::m_all_players[n].getName().c_str()).c_str(),
|
||||
UserConfigParams::m_all_players[n].getName());
|
||||
}
|
||||
|
||||
@ -128,7 +130,7 @@ void OptionsScreenPlayers::deletePlayer(PlayerProfile* player)
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for(int n=0; n<playerAmount; n++)
|
||||
{
|
||||
players->addItem(UserConfigParams::m_all_players[n].getName(),
|
||||
players->addItem(core::stringc(UserConfigParams::m_all_players[n].getName().c_str()).c_str(),
|
||||
UserConfigParams::m_all_players[n].getName());
|
||||
}
|
||||
} // deletePlayer
|
||||
@ -168,7 +170,7 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name
|
||||
ListWidget* players = this->getWidget<ListWidget>("players");
|
||||
assert(players != NULL);
|
||||
|
||||
std::string selectedPlayer = stringc( players->getSelectionLabel().c_str() ).c_str();
|
||||
core::stringw selectedPlayer = players->getSelectionLabel();
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for (int n=0; n<playerAmount; n++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user