Merge branch 'hiker/new_login'

This commit is contained in:
hiker 2014-02-17 08:23:48 +11:00
commit a3f3613e1e
12 changed files with 93 additions and 111 deletions

View File

@ -20,8 +20,6 @@
#include "utils/log.hpp"
#include "utils/translation.hpp"
#include "io/xml_writer.hpp"
#include <sstream>
#include <stdlib.h>

View File

@ -21,7 +21,6 @@
#include "utils/log.hpp"
#include "utils/translation.hpp"
#include "io/file_manager.hpp"
#include "io/xml_writer.hpp"
#include "config/player.hpp"
#include "config/user_config.hpp"
#include "online/current_user.hpp"

View File

@ -24,12 +24,13 @@
#include "utils/log.hpp"
#include "utils/ptr_vector.hpp"
#include "utils/translation.hpp"
#include "io/xml_writer.hpp"
#include "online/current_user.hpp"
#include <sstream>
#include <fstream>
#include <stdlib.h>
#include <assert.h>
// ============================================================================
AchievementsSlot::AchievementsSlot(const XMLNode * input)
{

View File

@ -27,11 +27,10 @@
#include "achievements/achievements_manager.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "challenges/challenge_data.hpp"
#include "config/player.hpp"
#include "config/user_config.hpp"
#include "challenges/challenge_data.hpp"
#include "io/file_manager.hpp"
#include "io/xml_writer.hpp"
#include "karts/kart_properties_manager.hpp"
#include "race/race_manager.hpp"
#include "tracks/track_manager.hpp"

View File

@ -18,34 +18,33 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include "io/xml_writer.hpp"
#include "utils/ptr_vector.hpp"
class UserConfigParam;
static PtrVector<UserConfigParam, REF> all_params;
// X-macros
#define PARAM_PREFIX
#define PARAM_DEFAULT(X) = X
#include "config/user_config.hpp"
#include "config/saved_grand_prix.hpp"
#include "config/player.hpp"
#include "config/saved_grand_prix.hpp"
#include "config/stk_config.hpp"
#include "guiengine/engine.hpp"
#include "io/file_manager.hpp"
#include "io/utf_writer.hpp"
#include "io/xml_node.hpp"
#include "race/race_manager.hpp"
#include "utils/ptr_vector.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
class UserConfigParam;
static PtrVector<UserConfigParam, REF> all_params;
const int UserConfig::m_current_config_version = 8;
@ -60,7 +59,7 @@ UserConfigParam::~UserConfigParam()
* \param stream the xml writer.
* \param level determines indentation level.
*/
void UserConfigParam::writeInner(XMLWriter& stream, int level) const
void UserConfigParam::writeInner(UTFWriter& stream, int level) const
{
std::string tab(level * 4,' ');
stream << L" " << tab.c_str() << m_param_name.c_str() << L"=\""
@ -87,7 +86,7 @@ GroupUserConfigParam::GroupUserConfigParam(const char* group_name,
} // GroupUserConfigParam
// ----------------------------------------------------------------------------
void GroupUserConfigParam::write(XMLWriter& stream) const
void GroupUserConfigParam::write(UTFWriter& stream) const
{
const int attr_amount = m_attributes.size();
@ -117,7 +116,7 @@ void GroupUserConfigParam::write(XMLWriter& stream) const
} // write
// ----------------------------------------------------------------------------
void GroupUserConfigParam::writeInner(XMLWriter& stream, int level) const
void GroupUserConfigParam::writeInner(UTFWriter& stream, int level) const
{
std::string tab(level * 4,' ');
for(int i = 0; i < level; i++) tab =+ " ";
@ -244,7 +243,7 @@ ListUserConfigParam<T, U>::ListUserConfigParam(const char* param_name,
// ----------------------------------------------------------------------------
template<typename T, typename U>
void ListUserConfigParam<T, U>::write(XMLWriter& stream) const
void ListUserConfigParam<T, U>::write(UTFWriter& stream) const
{
const int elts_amount = m_elements.size();
@ -350,7 +349,7 @@ IntUserConfigParam::IntUserConfigParam(int default_value,
} // IntUserConfigParam
// ----------------------------------------------------------------------------
void IntUserConfigParam::write(XMLWriter& stream) const
void IntUserConfigParam::write(UTFWriter& stream) const
{
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
<< L" -->\n";
@ -412,7 +411,7 @@ TimeUserConfigParam::TimeUserConfigParam(StkTime::TimeType default_value,
} // TimeUserConfigParam
// ----------------------------------------------------------------------------
void TimeUserConfigParam::write(XMLWriter& stream) const
void TimeUserConfigParam::write(UTFWriter& stream) const
{
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
<< L" -->\n";
@ -483,7 +482,7 @@ StringUserConfigParam::StringUserConfigParam(const char* default_value,
} // StringUserConfigParam
// ----------------------------------------------------------------------------
void StringUserConfigParam::write(XMLWriter& stream) const
void StringUserConfigParam::write(UTFWriter& stream) const
{
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
<< L" -->\n";
@ -535,7 +534,7 @@ WStringUserConfigParam::WStringUserConfigParam(const core::stringw& default_valu
} // WStringUserConfigParam
// ----------------------------------------------------------------------------
void WStringUserConfigParam::write(XMLWriter& stream) const
void WStringUserConfigParam::write(UTFWriter& stream) const
{
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
<< L" -->\n";
@ -586,7 +585,7 @@ BoolUserConfigParam::BoolUserConfigParam(bool default_value,
// ----------------------------------------------------------------------------
void BoolUserConfigParam::write(XMLWriter& stream) const
void BoolUserConfigParam::write(UTFWriter& stream) const
{
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
<< L" -->\n";
@ -673,7 +672,7 @@ FloatUserConfigParam::FloatUserConfigParam(float default_value,
} // FloatUserConfigParam
// ----------------------------------------------------------------------------
void FloatUserConfigParam::write(XMLWriter& stream) const
void FloatUserConfigParam::write(UTFWriter& stream) const
{
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
<< L" -->\n";
@ -878,7 +877,7 @@ void UserConfig::saveConfig()
try
{
XMLWriter configfile(filename.c_str());
UTFWriter configfile(filename.c_str());
configfile << L"<?xml version=\"1.0\"?>\n";
configfile << L"<stkconfig version=\"" << m_current_config_version

View File

@ -46,7 +46,6 @@
using irr::core::stringc;
using irr::core::stringw;
#include "io/xml_writer.hpp"
#include "utils/constants.hpp"
#include "utils/no_copy.hpp"
#include "utils/ptr_vector.hpp"
@ -55,7 +54,7 @@ using irr::core::stringw;
class PlayerProfile;
class SavedGrandPrix;
class XMLNode;
class XMLWriter;
class UTFWriter;
/**
* The base of a set of small utilities to enable quickly adding/removing
@ -69,8 +68,8 @@ protected:
std::string m_comment;
public:
virtual ~UserConfigParam();
virtual void write(XMLWriter& stream) const = 0;
virtual void writeInner(XMLWriter& stream, int level = 0) const;
virtual void write(UTFWriter& stream) const = 0;
virtual void writeInner(UTFWriter& stream, int level = 0) const;
virtual void findYourDataInAChildOf(const XMLNode* node) = 0;
virtual void findYourDataInAnAttributeOf(const XMLNode* node) = 0;
virtual irr::core::stringw toString() const = 0;
@ -86,8 +85,8 @@ public:
GroupUserConfigParam(const char* param_name,
GroupUserConfigParam* group,
const char* comment = NULL);
void write(XMLWriter& stream) const;
void writeInner(XMLWriter& stream, int level = 0) const;
void write(UTFWriter& stream) const;
void writeInner(UTFWriter& stream, int level = 0) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);
@ -120,7 +119,7 @@ public:
int nb_elts,
...);
void write(XMLWriter& stream) const;
void write(UTFWriter& stream) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);
@ -151,7 +150,7 @@ public:
GroupUserConfigParam* group,
const char* comment = NULL);
void write(XMLWriter& stream) const;
void write(UTFWriter& stream) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);
@ -178,7 +177,7 @@ public:
TimeUserConfigParam(StkTime::TimeType default_value, const char* param_name,
GroupUserConfigParam* group, const char* comment=NULL);
void write(XMLWriter& stream) const;
void write(UTFWriter& stream) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);
@ -205,7 +204,7 @@ public:
GroupUserConfigParam* group,
const char* comment = NULL);
void write(XMLWriter& stream) const;
void write(UTFWriter& stream) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);
@ -240,7 +239,7 @@ public:
GroupUserConfigParam* group,
const char* comment = NULL);
void write(XMLWriter& stream) const;
void write(UTFWriter& stream) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);
@ -267,7 +266,7 @@ public:
BoolUserConfigParam(bool default_value, const char* param_name,
GroupUserConfigParam* group,
const char* comment = NULL);
void write(XMLWriter& stream) const;
void write(UTFWriter& stream) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);
@ -293,7 +292,7 @@ public:
GroupUserConfigParam* group,
const char* comment = NULL);
void write(XMLWriter& stream) const;
void write(UTFWriter& stream) const;
void findYourDataInAChildOf(const XMLNode* node);
void findYourDataInAnAttributeOf(const XMLNode* node);

View File

@ -16,90 +16,53 @@
// 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 "io/utf_writer.hpp"
#include <wchar.h>
#include <string>
#include <stdexcept>
using namespace irr;
#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8)
// ----------------------------------------------------------------------------
XMLWriter::XMLWriter(const char* dest) : m_base(dest, std::ios::out | std::ios::binary)
UTFWriter::UTFWriter(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));
throw std::runtime_error("Failed to open file for writing : " +
std::string(dest));
}
// FIXME: make sure to properly handle endianness
wchar_t BOM = 0xFEFF; // UTF-16 BOM is 0xFEFF; UTF-32 BOM is 0x0000FEFF. So this works in either case
// UTF-16 BOM is 0xFEFF; UTF-32 BOM is 0x0000FEFF. So this works in either case
wchar_t BOM = 0xFEFF;
m_base.write((char *) &BOM, sizeof(wchar_t));
}
} // UTFWriter
// ----------------------------------------------------------------------------
XMLWriter& XMLWriter::operator<< (const irr::core::stringw& txt)
UTFWriter& UTFWriter::operator<< (const irr::core::stringw& txt)
{
m_base.write((char *) txt.c_str(), txt.size() * sizeof(wchar_t));
return *this;
}
} // operator<< (stringw)
// ----------------------------------------------------------------------------
XMLWriter& XMLWriter::operator<< (const wchar_t*txt)
UTFWriter& UTFWriter::operator<< (const wchar_t*txt)
{
m_base.write((char *) txt, wcslen(txt) * sizeof(wchar_t));
return *this;
}
} // operator<< (wchar_t)
// ----------------------------------------------------------------------------
void XMLWriter::close()
void UTFWriter::close()
{
m_base.close();
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#else // Non-unicode version for irrlicht 1.7 and before
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));
}
}
} // close
// ----------------------------------------------------------------------------
XMLWriter& XMLWriter::operator<< (const irr::core::stringw& txt)
{
core::stringc s( txt.c_str() );
m_base.write((char *) s.c_str(), s.size());
return *this;
}
// ----------------------------------------------------------------------------
XMLWriter& XMLWriter::operator<< (const wchar_t*txt)
{
core::stringc s( txt );
m_base.write((char *) s.c_str(), s.size());
return *this;
}
// ----------------------------------------------------------------------------
void XMLWriter::close()
{
m_base.close();
}
// ----------------------------------------------------------------------------
#endif

View File

@ -16,8 +16,8 @@
// 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
#ifndef HEADER_UTF_WRITER_HPP
#define HEADER_UTF_WRITER_HPP
#include <fstream>
#include <irrString.h>
@ -28,18 +28,18 @@
* we only want to accept arrays of wchar_t to make sure we get reasonable files out
* \ingroup io
*/
class XMLWriter
class UTFWriter
{
std::ofstream m_base;
public:
XMLWriter(const char* dest);
UTFWriter(const char* dest);
XMLWriter& operator<< (const irr::core::stringw& txt);
XMLWriter& operator<< (const wchar_t* txt);
UTFWriter& operator<< (const irr::core::stringw& txt);
UTFWriter& operator<< (const wchar_t* txt);
template<typename T>
XMLWriter& operator<< (const T t)
UTFWriter& operator<< (const T t)
{
irr::core::stringw tmp;
tmp += t;

View File

@ -23,7 +23,7 @@
#include "config/user_config.hpp"
#include "io/file_manager.hpp"
#include "io/xml_writer.hpp"
#include "io/utf_writer.hpp"
#include "race/race_manager.hpp"
#include "utils/constants.hpp"
#include "utils/string_utils.hpp"
@ -149,7 +149,7 @@ void HighscoreManager::saveHighscores()
try
{
XMLWriter highscore_file(m_filename.c_str());
UTFWriter highscore_file(m_filename.c_str());
highscore_file << L"<?xml version=\"1.0\"?>\n";
highscore_file << L"<highscores version=\"" << CURRENT_HSCORE_FILE_VERSION << "\">\n";

View File

@ -18,13 +18,13 @@
#include "race/highscores.hpp"
#include "io/utf_writer.hpp"
#include "io/xml_node.hpp"
#include "race/race_manager.hpp"
#include <stdexcept>
#include <fstream>
#include "io/xml_node.hpp"
#include "io/xml_writer.hpp"
#include "race/race_manager.hpp"
// -----------------------------------------------------------------------------
Highscores::Highscores(const HighscoreType highscore_type,
int num_karts,
@ -105,7 +105,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(XMLWriter &writer)
void Highscores::writeEntry(UTFWriter &writer)
{
// Only
bool one_is_set = false;

View File

@ -27,7 +27,7 @@
#include <irrString.h>
class XMLNode;
class XMLWriter;
class UTFWriter;
/**
* Represents one highscore entry, i.e. the (atm up to three) highscores
@ -62,7 +62,7 @@ public:
Highscores (const XMLNode &node);
void readEntry (const XMLNode &node);
void writeEntry(XMLWriter &writer);
void writeEntry(UTFWriter &writer);
int matches (HighscoreType highscore_type, int num_karts,
const RaceManager::Difficulty difficulty,
const std::string track, const int number_of_laps,

24
tools/find_unused.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
echo "Searching for unused stkgui files"
echo "---------------------------------"
cd data/gui
l=""
for i in $(find . -iname "*.stkgui"); do
s=$(basename $i)
x=$(find ../../src/states_screens -exec grep -H $s \{} \; | wc -l)
echo -n "."
if [ $x == "0" ]; then
l="$l $i"
fi
done
echo
for i in $l; do
echo "$i appears to be not used."
done
echo "done"