[Orxonox-commit 6628] r11267 - in code/branches/Highscore_HS16: data/gui/scripts src/orxonox
kappenh at orxonox.net
kappenh at orxonox.net
Mon Nov 7 15:55:36 CET 2016
Author: kappenh
Date: 2016-11-07 15:55:36 +0100 (Mon, 07 Nov 2016)
New Revision: 11267
Modified:
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
code/branches/Highscore_HS16/src/orxonox/LevelInfo.cc
code/branches/Highscore_HS16/src/orxonox/LevelInfo.h
Log:
erste einbindung des Highscores in der levelinfo
Modified: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-11-07 14:55:27 UTC (rev 11266)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-11-07 14:55:36 UTC (rev 11267)
@@ -37,6 +37,9 @@
if tag == nil or v:hasTag(tag) then
P.createFilterTab(v:getName(), v:getName())
end
+ local highscores = v:getHighscores()
+ orxonox.CommandExecutor:execute("log test:".. highscores)
+
end
--P.createFilterTab("Minigames", "minigame")
--P.createFilterTab("Showcases", "showcase")
Modified: code/branches/Highscore_HS16/src/orxonox/LevelInfo.cc
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/LevelInfo.cc 2016-11-07 14:55:27 UTC (rev 11266)
+++ code/branches/Highscore_HS16/src/orxonox/LevelInfo.cc 2016-11-07 14:55:36 UTC (rev 11267)
@@ -150,6 +150,16 @@
return success;
}
+ bool LevelInfoItem::addHighscore(const std::string& name, const int score)
+ {
+ std::stringstream stream;
+ stream << name << "/:/" << score;
+ bool success = this->highscores_.insert(stream.str()).second;
+ if(success)
+ this->highscoresUpdated();
+ return success;
+ }
+
/**
@brief
Add a ship model to allowed models for the shipselection
@@ -190,6 +200,21 @@
this->tagsString_ = std::string(stream.str());
}
+ void LevelInfoItem::highscoresUpdated(void)
+ {
+ std::stringstream stream;
+ std::set<std::string>::iterator temp;
+ for(std::set<std::string>::iterator it = this->highscores_.begin(); it != this->highscores_.end(); )
+ {
+ temp = it;
+ if(++it == this->highscores_.end()) // If this is the last tag we don't add a comma.
+ stream << *temp;
+ else
+ stream << *temp << ", ";
+ }
+
+ this->highscoresString_ = std::string(stream.str());
+ }
/**
@brief
Updates the comma-seperated string of all ships, if the set of tags has changed.
Modified: code/branches/Highscore_HS16/src/orxonox/LevelInfo.h
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/LevelInfo.h 2016-11-07 14:55:27 UTC (rev 11266)
+++ code/branches/Highscore_HS16/src/orxonox/LevelInfo.h 2016-11-07 14:55:36 UTC (rev 11267)
@@ -117,6 +117,10 @@
*/
inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
+ bool addHighscore(const std::string& name,const int score);
+
+ inline const std::string& getHighscores(void) const { return this->highscoresString_; } // tolua_export
+
void setStartingShips(const std::string& ships); //!< Set the starting ship models of the level
bool addStartingShip(const std::string& ship, bool update = true); //!< Add a model to shipselection
/**
@@ -153,6 +157,7 @@
void changeStartingShip (const std::string& model);
void startingshipsUpdated(void); //!< Updates the comma-seperated string of all possible starting ships.
void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
+ void highscoresUpdated(void);
static void initializeTags(void); //!< Initialize the set of allowed tags.
/**
@brief Check whether an input tag is allowed.
@@ -169,6 +174,10 @@
std::string description_; //!< The description of the Level.
std::string screenshot_; //!< The screenshot of the Level.
std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
+
+ std::set<std::string> highscores_;
+ std::string highscoresString_;
+
std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
std::set<std::string> startingShips_; //!< The set of starting ship models the Level allows.
std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection.
@@ -243,6 +252,9 @@
*/
inline const std::string& getTags(void) const
{ return this->LevelInfoItem::getTags(); }
+
+ inline const std::string& getHighscores(void) const
+ { return this->LevelInfoItem::getHighscores(); }
/**
@brief Set the starting ship models of the level
@param ships A comma-seperated string of all the allowed ship models for the shipselection.
More information about the Orxonox-commit
mailing list