While one issue is fixed, another one popped up. Pretty late, I'll look at it tomorrow. (Feel free to have a look ;) )
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13632 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
03be63ea5b
commit
d6f6383833
@ -32,7 +32,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
Achievement::Achievement(AchievementInfo * info)
|
Achievement::Achievement(const AchievementInfo * info)
|
||||||
|
:m_achievement_info(info)
|
||||||
{
|
{
|
||||||
m_id = info->getID();
|
m_id = info->getID();
|
||||||
m_achieved = false;
|
m_achieved = false;
|
||||||
@ -62,7 +63,7 @@ void Achievement::check()
|
|||||||
//show achievement
|
//show achievement
|
||||||
GUIEngine::DialogQueue::get()->pushDialog(
|
GUIEngine::DialogQueue::get()->pushDialog(
|
||||||
new NotificationDialog(NotificationDialog::T_Achievements,
|
new NotificationDialog(NotificationDialog::T_Achievements,
|
||||||
_("Completed achievement") + '"' + m_achievement_info->getDescription() + '".'
|
irr::core::stringw(_("Completed achievement")) + irr::core::stringw("\"") + m_achievement_info->getDescription() + irr::core::stringw("\".")
|
||||||
));
|
));
|
||||||
//send to server
|
//send to server
|
||||||
Online::CurrentUser::get()->onAchieving(m_id);
|
Online::CurrentUser::get()->onAchieving(m_id);
|
||||||
@ -71,7 +72,7 @@ void Achievement::check()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
SingleAchievement::SingleAchievement(AchievementInfo * info)
|
SingleAchievement::SingleAchievement(const AchievementInfo * info)
|
||||||
: Achievement(info)
|
: Achievement(info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ void SingleAchievement::increase(int increase)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
MapAchievement::MapAchievement(AchievementInfo * info)
|
MapAchievement::MapAchievement(const AchievementInfo * info)
|
||||||
: Achievement(info)
|
: Achievement(info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,11 @@ class Achievement
|
|||||||
protected:
|
protected:
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
bool m_achieved;
|
bool m_achieved;
|
||||||
AchievementInfo * m_achievement_info;
|
const AchievementInfo * m_achievement_info;
|
||||||
void check ();
|
void check ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Achievement (AchievementInfo * info);
|
Achievement (const AchievementInfo * info);
|
||||||
virtual ~Achievement ();
|
virtual ~Achievement ();
|
||||||
uint32_t getID () const { return m_id; }
|
uint32_t getID () const { return m_id; }
|
||||||
virtual void load (XMLNode * input) = 0;
|
virtual void load (XMLNode * input) = 0;
|
||||||
@ -65,7 +65,7 @@ protected:
|
|||||||
int m_progress;
|
int m_progress;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SingleAchievement (AchievementInfo * info);
|
SingleAchievement (const AchievementInfo * info);
|
||||||
virtual ~SingleAchievement () {};
|
virtual ~SingleAchievement () {};
|
||||||
|
|
||||||
void load (XMLNode * input);
|
void load (XMLNode * input);
|
||||||
@ -81,7 +81,7 @@ protected:
|
|||||||
std::map<std::string, int> m_progress_map;
|
std::map<std::string, int> m_progress_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapAchievement (AchievementInfo * info);
|
MapAchievement (const AchievementInfo * info);
|
||||||
virtual ~MapAchievement () {};
|
virtual ~MapAchievement () {};
|
||||||
|
|
||||||
void load (XMLNode * input);
|
void load (XMLNode * input);
|
||||||
|
@ -48,9 +48,9 @@ public:
|
|||||||
virtual ~AchievementInfo () {};
|
virtual ~AchievementInfo () {};
|
||||||
uint32_t getID () const { return m_id; }
|
uint32_t getID () const { return m_id; }
|
||||||
irr::core::stringw getDescription () const { return m_description; }
|
irr::core::stringw getDescription () const { return m_description; }
|
||||||
virtual Achievement::AchievementType getType () = 0;
|
virtual Achievement::AchievementType getType () const = 0;
|
||||||
virtual bool checkCompletion (Achievement * achievement) const = 0;
|
virtual bool checkCompletion (Achievement * achievement) const = 0;
|
||||||
bool needsResetAfterRace() {return m_reset_after_race; }
|
bool needsResetAfterRace() const {return m_reset_after_race; }
|
||||||
}; // class AchievementInfo
|
}; // class AchievementInfo
|
||||||
|
|
||||||
class SingleAchievementInfo : public AchievementInfo
|
class SingleAchievementInfo : public AchievementInfo
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
int getGoalValue () const { return m_goal_value; }
|
int getGoalValue () const { return m_goal_value; }
|
||||||
virtual bool checkCompletion (Achievement * achievement) const;
|
virtual bool checkCompletion (Achievement * achievement) const;
|
||||||
|
|
||||||
virtual Achievement::AchievementType getType() { return Achievement::AT_SINGLE; };
|
virtual Achievement::AchievementType getType() const { return Achievement::AT_SINGLE; };
|
||||||
}; // class SingleAchievementInfo
|
}; // class SingleAchievementInfo
|
||||||
|
|
||||||
class MapAchievementInfo : public AchievementInfo
|
class MapAchievementInfo : public AchievementInfo
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
int getGoalValue (const std::string & key) { return m_goal_values[key];}
|
int getGoalValue (const std::string & key) { return m_goal_values[key];}
|
||||||
virtual bool checkCompletion (Achievement * achievement) const;
|
virtual bool checkCompletion (Achievement * achievement) const;
|
||||||
|
|
||||||
virtual Achievement::AchievementType getType() { return Achievement::AT_MAP; };
|
virtual Achievement::AchievementType getType() const { return Achievement::AT_MAP; };
|
||||||
}; // class MapAchievementInfo
|
}; // class MapAchievementInfo
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -104,8 +104,6 @@ void AchievementsManager::parseConfigFile()
|
|||||||
Log::info("AchievementsManager", "Achievements file '%s' will be created.",
|
Log::info("AchievementsManager", "Achievements file '%s' will be created.",
|
||||||
filename.c_str());
|
filename.c_str());
|
||||||
createSlotsIfNeeded();
|
createSlotsIfNeeded();
|
||||||
save();
|
|
||||||
|
|
||||||
if (root) delete root;
|
if (root) delete root;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -114,7 +112,7 @@ void AchievementsManager::parseConfigFile()
|
|||||||
root->getNodes("slot", xml_slots);
|
root->getNodes("slot", xml_slots);
|
||||||
for (unsigned int n=0; n < xml_slots.size(); n++)
|
for (unsigned int n=0; n < xml_slots.size(); n++)
|
||||||
{
|
{
|
||||||
AchievementsSlot * slot = new AchievementsSlot(xml_slots[n]);
|
AchievementsSlot * slot = new AchievementsSlot(xml_slots[n], m_achievements_info);
|
||||||
if(!slot->isValid())
|
if(!slot->isValid())
|
||||||
{
|
{
|
||||||
Log::warn("AchievementsManager", "Found game slot with faulty or missing information. Discarding it.");
|
Log::warn("AchievementsManager", "Found game slot with faulty or missing information. Discarding it.");
|
||||||
@ -129,7 +127,7 @@ void AchievementsManager::parseConfigFile()
|
|||||||
|
|
||||||
AchievementsSlot * AchievementsManager::createNewSlot(std::string id, bool online)
|
AchievementsSlot * AchievementsManager::createNewSlot(std::string id, bool online)
|
||||||
{
|
{
|
||||||
AchievementsSlot* slot = new AchievementsSlot(id, false);
|
AchievementsSlot* slot = new AchievementsSlot(id, false, m_achievements_info);
|
||||||
m_slots.push_back(slot);
|
m_slots.push_back(slot);
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,6 @@ public:
|
|||||||
static AchievementsManager * get();
|
static AchievementsManager * get();
|
||||||
static void deallocate();
|
static void deallocate();
|
||||||
|
|
||||||
const PtrVector<AchievementInfo> & getAllInfo() const { return m_achievements_info;};
|
|
||||||
|
|
||||||
void parseDataFile();
|
void parseDataFile();
|
||||||
void parseConfigFile();
|
void parseConfigFile();
|
||||||
void save();
|
void save();
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
AchievementsSlot::AchievementsSlot(const XMLNode * input)
|
AchievementsSlot::AchievementsSlot(const XMLNode * input, const PtrVector<AchievementInfo> & info)
|
||||||
{
|
{
|
||||||
int fetched_user_id = input->get("user_id", &m_id);
|
int fetched_user_id = input->get("user_id", &m_id);
|
||||||
std::string online;
|
std::string online;
|
||||||
@ -43,7 +43,7 @@ AchievementsSlot::AchievementsSlot(const XMLNode * input)
|
|||||||
m_valid = true;
|
m_valid = true;
|
||||||
m_online = online == "true";
|
m_online = online == "true";
|
||||||
|
|
||||||
createFreshSlot();
|
createFreshSlot(info);
|
||||||
|
|
||||||
std::vector<XMLNode*> xml_achievements;
|
std::vector<XMLNode*> xml_achievements;
|
||||||
input->getNodes("achievement", xml_achievements);
|
input->getNodes("achievement", xml_achievements);
|
||||||
@ -62,23 +62,22 @@ AchievementsSlot::AchievementsSlot(const XMLNode * input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
AchievementsSlot::AchievementsSlot(std::string id, bool online)
|
AchievementsSlot::AchievementsSlot(std::string id, bool online, const PtrVector<AchievementInfo> & info)
|
||||||
{
|
{
|
||||||
m_valid = true;
|
m_valid = true;
|
||||||
m_online = online;
|
m_online = online;
|
||||||
m_id = id;
|
m_id = id;
|
||||||
|
|
||||||
createFreshSlot();
|
createFreshSlot(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
void AchievementsSlot::createFreshSlot()
|
void AchievementsSlot::createFreshSlot( const PtrVector<AchievementInfo> & all_info)
|
||||||
{
|
{
|
||||||
m_achievements.clear();
|
m_achievements.clear();
|
||||||
PtrVector<AchievementInfo> all_info = AchievementsManager::get()->getAllInfo();
|
|
||||||
for(int i=0; i < all_info.size(); i++)
|
for(int i=0; i < all_info.size(); i++)
|
||||||
{
|
{
|
||||||
AchievementInfo * info = all_info.get(i);
|
const AchievementInfo * info = all_info.get(i);
|
||||||
Achievement::AchievementType achievement_type = info->getType();
|
Achievement::AchievementType achievement_type = info->getType();
|
||||||
Achievement * achievement;
|
Achievement * achievement;
|
||||||
if(achievement_type == Achievement::AT_SINGLE)
|
if(achievement_type == Achievement::AT_SINGLE)
|
||||||
|
@ -35,11 +35,11 @@ private:
|
|||||||
bool m_valid;
|
bool m_valid;
|
||||||
std::string m_id;
|
std::string m_id;
|
||||||
|
|
||||||
void createFreshSlot();
|
void createFreshSlot( const PtrVector<AchievementInfo> & info);
|
||||||
|
|
||||||
public :
|
public :
|
||||||
AchievementsSlot(const XMLNode * input);
|
AchievementsSlot(const XMLNode * input, const PtrVector<AchievementInfo> & info);
|
||||||
AchievementsSlot(std::string id, bool online);
|
AchievementsSlot(std::string id, bool online, const PtrVector<AchievementInfo> & info);
|
||||||
bool isValid() const { return m_valid;}
|
bool isValid() const { return m_valid;}
|
||||||
void save(std::ofstream & out);
|
void save(std::ofstream & out);
|
||||||
bool isOnline() const {return m_online;}
|
bool isOnline() const {return m_online;}
|
||||||
|
@ -916,7 +916,7 @@ std::string FileManager::getFontFile(const std::string& file_name) const
|
|||||||
*/
|
*/
|
||||||
std::string FileManager::getConfigFile(const std::string &file_name) const
|
std::string FileManager::getConfigFile(const std::string &file_name) const
|
||||||
{
|
{
|
||||||
return getConfigDir()+"/"+file_name;
|
return getConfigDir()+file_name;
|
||||||
} // getChallengeFile
|
} // getChallengeFile
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user