[Orxonox-commit 6683] r11313 - in code/branches/Highscore_HS16: data/defaultConfig data/gui/scripts src/libraries/core src/modules/jump src/orxonox
kappenh at orxonox.net
kappenh at orxonox.net
Mon Nov 28 16:53:24 CET 2016
Author: kappenh
Date: 2016-11-28 16:53:24 +0100 (Mon, 28 Nov 2016)
New Revision: 11313
Added:
code/branches/Highscore_HS16/src/orxonox/Highscore.cc
code/branches/Highscore_HS16/src/orxonox/Highscore.h
Removed:
code/branches/Highscore_HS16/src/libraries/core/Highscore.cc
code/branches/Highscore_HS16/src/libraries/core/Highscore.h
Modified:
code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
code/branches/Highscore_HS16/src/libraries/core/CMakeLists.txt
code/branches/Highscore_HS16/src/modules/jump/Jump.cc
code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt
Log:
Able to save scores in ini. todo: save and retrieve pong score
Modified: code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini
===================================================================
--- code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini 2016-11-28 15:36:54 UTC (rev 11312)
+++ code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini 2016-11-28 15:53:24 UTC (rev 11313)
@@ -8,3 +8,8 @@
campaignMissions_[6] = "expeditionSector.oxw"
campaignMissions_[7] = "shuttleAttack.oxw"
campaignMissions_[8] = "shuttleRetaliation.oxw"
+
+[Highscore]
+tests_[0] = "name1"
+tests_[1] = "name2"
+
Modified: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-11-28 15:36:54 UTC (rev 11312)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-11-28 15:53:24 UTC (rev 11313)
@@ -23,9 +23,10 @@
P.nameList = {}
P.scoreList = {}
-
- for i=1,20 do
- table.insert(P.nameList, "Player "..i)
+ test = orxonox.Highscore:getInstance():getNumberOfHighscores()
+
+ for i=0,orxonox.Highscore:getInstance():getNumberOfHighscores()-1 do
+ table.insert(P.nameList, orxonox.Highscore:getInstance():getHighscore(i))
table.insert(P.scoreList, i)
end
@@ -40,8 +41,8 @@
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)
+ --local highscores = v:getHighscores()
+ --orxonox.CommandExecutor:execute("log test:".. highscores)
end
--P.createFilterTab("Minigames", "minigame")
@@ -54,6 +55,16 @@
end
function P.onShow()
+ P.nameList = {}
+
+ P.scoreList = {}
+ test = orxonox.Highscore:getInstance():getNumberOfHighscores()
+
+ for i=0,orxonox.Highscore:getInstance():getNumberOfHighscores()-1 do
+ table.insert(P.nameList, orxonox.Highscore:getInstance():getHighscore(i))
+ table.insert(P.scoreList, i)
+
+ end
--local description = winMgr:getWindow("orxonox/HighscoreText")
--height = getStaticTextWindowHeight(description)
Modified: code/branches/Highscore_HS16/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/Highscore_HS16/src/libraries/core/CMakeLists.txt 2016-11-28 15:36:54 UTC (rev 11312)
+++ code/branches/Highscore_HS16/src/libraries/core/CMakeLists.txt 2016-11-28 15:53:24 UTC (rev 11313)
@@ -26,7 +26,6 @@
GameConfig.cc
GameMode.cc
GameState.cc
- Highscore.cc
Language.cc
Loader.cc
LuaState.cc
@@ -90,7 +89,6 @@
GameMode.h
GraphicsManager.h
GUIManager.h
- Highscore.h
Loader.h
LuaState.h
input/InputManager.h
Deleted: code/branches/Highscore_HS16/src/libraries/core/Highscore.cc
===================================================================
--- code/branches/Highscore_HS16/src/libraries/core/Highscore.cc 2016-11-28 15:36:54 UTC (rev 11312)
+++ code/branches/Highscore_HS16/src/libraries/core/Highscore.cc 2016-11-28 15:53:24 UTC (rev 11313)
@@ -1,30 +0,0 @@
-#include "Highscore.h"
-
-#include <vector>
-#include "core/CoreIncludes.h"
-#include "core/config/ConfigValueIncludes.h"
-
-
-namespace orxonox
-{
-
- RegisterClassNoArgs(Highscore);
-
- Highscore::Highscore()
- {
- RegisterObject(Highscore);
- this->setConfigValues();
- }
-
- void Highscore::setConfigValues()
- {
-
- SetConfigValue(name_, "Orxonox").description("The name of the game");
- }
-
- /* static */ std::string Highscore::getName(){
- std::string result;
- result = Highscore::name_;
- return result;
- }
-}
Deleted: code/branches/Highscore_HS16/src/libraries/core/Highscore.h
===================================================================
--- code/branches/Highscore_HS16/src/libraries/core/Highscore.h 2016-11-28 15:36:54 UTC (rev 11312)
+++ code/branches/Highscore_HS16/src/libraries/core/Highscore.h 2016-11-28 15:53:24 UTC (rev 11313)
@@ -1,24 +0,0 @@
-
-
-#include <string>
-#include "core/config/Configurable.h"
-
-namespace orxonox
-{
-class _CoreExport Highscore : virtual public Configurable
-{
- public:
- Highscore(); // Constructor
- void setConfigValues(); // Inherited function
- void storeHighscore(std::string player, std::string level, int points);
-
- static std::string getName(); // tolua_export
-
-
- private:
- std::string name_;
- float version_;
-};
-
-
-}
\ No newline at end of file
Modified: code/branches/Highscore_HS16/src/modules/jump/Jump.cc
===================================================================
--- code/branches/Highscore_HS16/src/modules/jump/Jump.cc 2016-11-28 15:36:54 UTC (rev 11312)
+++ code/branches/Highscore_HS16/src/modules/jump/Jump.cc 2016-11-28 15:53:24 UTC (rev 11313)
@@ -33,6 +33,7 @@
#include "Jump.h"
#include "core/CoreIncludes.h"
+#include "Highscore.h"
#include "JumpCenterpoint.h"
#include "JumpPlatform.h"
@@ -310,7 +311,11 @@
{
cleanup();
GSLevel::startMainMenu();
-
+ orxout() << "Test Highscore" << endl;
+ if (Highscore::exists()){
+ orxout() << "exists" << endl;
+ Highscore::getInstance().storeHighscore("player","jump",sectionNumber_ - 2);
+ }
Deathmatch::end();
}
Modified: code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt 2016-11-28 15:36:54 UTC (rev 11312)
+++ code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt 2016-11-28 15:53:24 UTC (rev 11313)
@@ -26,6 +26,7 @@
Level.cc
LevelInfo.cc
LevelManager.cc
+ Highscore.cc
Main.cc
MoodManager.cc
PlayerManager.cc
@@ -60,6 +61,7 @@
chat/ChatInputHandler.h
LevelInfo.h
LevelManager.h
+ Highscore.h
MoodManager.h
controllers/HumanController.h
infos/PlayerInfo.h
Added: code/branches/Highscore_HS16/src/orxonox/Highscore.cc
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/Highscore.cc (rev 0)
+++ code/branches/Highscore_HS16/src/orxonox/Highscore.cc 2016-11-28 15:53:24 UTC (rev 11313)
@@ -0,0 +1,34 @@
+#include "Highscore.h"
+
+#include <vector>
+#include "core/CoreIncludes.h"
+#include "core/config/ConfigValueIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+
+namespace orxonox
+{
+
+ ManageScopedSingleton(Highscore, ScopeID::ROOT, false);
+ RegisterClassNoArgs(Highscore);
+
+ Highscore::Highscore()
+ {
+ RegisterObject(Highscore);
+ this->setConfigValues();
+ }
+
+ void Highscore::setConfigValues()
+ {
+
+ SetConfigValue(name_, "Test").description("The name of the game");
+ SetConfigValue(tests_, std::vector<std::string>()).description("Testvektor");
+ }
+ void Highscore::storeHighscore(std::string player, std::string level, int points){
+ ModifyConfigValue(tests_, add, player+"./."+level+"./."+std::to_string(points));
+ }
+ /* static std::string Highscore::getName(){
+ std::string result;
+ result = Highscore::name_;
+ return result;
+ }*/
+}
Added: code/branches/Highscore_HS16/src/orxonox/Highscore.h
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/Highscore.h (rev 0)
+++ code/branches/Highscore_HS16/src/orxonox/Highscore.h 2016-11-28 15:53:24 UTC (rev 11313)
@@ -0,0 +1,43 @@
+#include <string>
+#include "core/config/Configurable.h"
+#include "OrxonoxPrereqs.h"
+#include "util/Singleton.h"
+// tolua_begin
+namespace orxonox
+{
+class _OrxonoxExport Highscore
+// tolua_end
+ : public Singleton<Highscore>, public Configurable
+{ //tolua_export
+ friend class Singleton<Highscore>;
+ public:
+ Highscore(); // Constructor
+ void setConfigValues(); // Inherited function
+ void storeHighscore(std::string player, std::string level, int points);
+ // tolua_begin
+ inline const std::string& getName() {
+ return this->name_;
+ }
+ inline void test(){
+ this->storeHighscore("test","t",1);
+ }
+ inline unsigned int getNumberOfHighscores()
+ { return this->tests_.size(); }
+ inline const std::string& getHighscore(unsigned int index)
+ { return this->tests_[index]; }
+
+ static Highscore& getInstance()
+ { return Singleton<Highscore>::getInstance(); }
+
+ // tolua_end
+
+
+ private:
+ std::vector<std::string> tests_;
+ std::string name_;
+ float version_;
+ static Highscore* singletonPtr_s;
+}; //tolua_export
+
+
+} //tolua_export
\ No newline at end of file
More information about the Orxonox-commit
mailing list