[Orxonox-commit 6704] r11333 - in code/branches/Highscore_HS16: data/defaultConfig data/gui/scripts src/modules/dodgerace src/modules/invader src/modules/jump src/modules/tetris src/modules/towerdefense src/orxonox
kappenh at orxonox.net
kappenh at orxonox.net
Mon Dec 12 15:28:37 CET 2016
Author: kappenh
Date: 2016-12-12 15:28:37 +0100 (Mon, 12 Dec 2016)
New Revision: 11333
Removed:
code/branches/Highscore_HS16/src/orxonox/highscore/
Modified:
code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
code/branches/Highscore_HS16/data/gui/scripts/MiscConfigMenu.lua
code/branches/Highscore_HS16/src/modules/dodgerace/DodgeRace.cc
code/branches/Highscore_HS16/src/modules/invader/Invader.cc
code/branches/Highscore_HS16/src/modules/jump/Jump.cc
code/branches/Highscore_HS16/src/modules/tetris/Tetris.cc
code/branches/Highscore_HS16/src/modules/towerdefense/TowerDefense.cc
code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt
code/branches/Highscore_HS16/src/orxonox/Highscore.cc
code/branches/Highscore_HS16/src/orxonox/Highscore.h
Log:
Finished Project
Modified: code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini
===================================================================
--- code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini 2016-12-12 14:28:37 UTC (rev 11333)
@@ -9,6 +9,5 @@
campaignMissions_[7] = "shuttleAttack.oxw"
campaignMissions_[8] = "shuttleRetaliation.oxw"
-[Highscore]
-highscores_[0] = "player./.Jump./.0"
+
Modified: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-12-12 14:28:37 UTC (rev 11333)
@@ -2,70 +2,47 @@
local P = createMenuSheet("HighscoreMenu")
-P.scrollbarWidth = 13
-P.nameList = {}
+P.highscoreList = {}
P.tabList = {}
P.linesList = {}
P.levelList = {}
-P.sampleWindow = nil
-P.lineHeight = 0
-P.playerWidth = 0
-P.editboxWidth = 0
-P.resetWidth = 0
-P.spaceWidth = 0
P.imageHeight = 50
-P.textHeight = 30
function P.onLoad()
- P.createLevelList()
-
- --P.createFilterTab("Minigames", "minigame")
- --P.createFilterTab("Showcases", "showcase")
- --P.createFilterTab("Presentations", "presentation")
- --P.createFilterTab("Tests", "test")
- --P.createFilterTab("Show All", nil)
-
-
+ P.createLevelList()
end
function P.onShow()
- P.nameList = {}
+ -- reset tables
+ P.highscoreList = {}
P.tabList = {}
P.linesList = {}
- test = orxonox.Highscore:getInstance():getNumberOfHighscores()
- for i=0,orxonox.Highscore:getInstance():getNumberOfHighscores()-1 do
- table.insert(P.nameList, orxonox.Highscore:getInstance():getHighscore(i))
+ -- fetch save scores and write it into the list
+ for i=orxonox.Highscore:getInstance():getNumberOfHighscores()-1,0,-1 do
+ table.insert(P.highscoreList, orxonox.Highscore:getInstance():getHighscore(i))
end
+ -- read minigames out of the levelList
for k,v in pairs(P.levelList) do
- -- only add level if it has desired tag
- if(v:getName() ~= "Hover level" and v:getName() ~= "Pong") then
+ if(v:getName() ~= "Hover level" and v:getName() ~= "Pong") then -- hover and pong dont contain relevant scores
P.createFilterTab(v:getName(), v:getName())
end
-
- --local highscores = v:getHighscores()
- --orxonox.CommandExecutor:execute("log test:".. highscores)
-
end
- --local description = winMgr:getWindow("orxonox/HighscoreText")
-
- --height = getStaticTextWindowHeight(description)
- --description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height)))
+
end
function P.onHide()
+
+ -- delete old windows to reload them on show
local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
for k,v in pairs(P.tabList) do
local default = winMgr:getWindow(v)
tabControl:removeChildWindow(default)
winMgr:destroyWindow(default)
- --local highscores = v:getHighscores()
- --orxonox.CommandExecutor:execute("log test:".. highscores)
-
end
end
function P.createLevelList()
@@ -76,14 +53,6 @@
while index < size do
level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
if (level ~= nil and level:getXMLFilename() ~= "_temp.oxw" and level:hasTag("minigame")) then
- local levelXMLFilename = level:getXMLFilename()
- -- create an imageset for each screenshot
- local imageName = level:getScreenshot()
- if imageName ~= "" then
- CEGUI.ImagesetManager:getSingleton():createFromImageFile(levelXMLFilename..imageName, imageName)
- else
- CEGUI.ImagesetManager:getSingleton():createFromImageFile(levelXMLFilename..imageName, "noscreenshot.png")
- end
table.insert(P.levelList, level)
end
index = index + 1
@@ -108,8 +77,8 @@
local offset = 2
- for k,v in pairs(P.nameList) do
-
+ for k,v in pairs(P.highscoreList) do
+ -- split the score ("Playername./.game./.score")
local splitlist = P.Split(v,"./.")
if(splitlist[2] == name)then
local line = P.createPickupEntry(tabName .. k,k,tag)
@@ -121,19 +90,16 @@
end
+ local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
+ tabControl:addChildWindow(default)
- local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
- orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".HighscoreSelectionChanged")
- --if listbox:getItemCount() > 0 then
- tabControl:addChildWindow(default)
- --end
end
function P.createPickupEntry(parent,k,tag)
local name = "orxonox/HiscoreEntry" .. parent
- local splitlist = P.Split(P.nameList[k],"./.")
+ local splitlist = P.Split(P.highscoreList[k],"./.")
local item = winMgr:createWindow("DefaultWindow", name)
item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight)))
item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
@@ -192,33 +158,9 @@
end
return result
end
-function P.HighscoreSelectionChanged(e)
- --local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
- --pane:moveToFront()
- --[[local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription")
- local configButton = winMgr:getWindow("orxonox/SingleplayerConfigButton")
- local level = P.HighscoreGetSelectedLevel()
- if level ~= nil then
- local levelXMLFilename = level:getXMLFilename()
- local imageName = level:getScreenshot()
- -- set the screenshot and the description for the selected level
- levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
- levelDescription:setText(level:getDescription())
- -- only enable config button for "gametype" levels
- if level:hasTag("gametype") then
- configButton:setProperty("Disabled", "False")
- else
- configButton:setProperty("Disabled", "True")
- end
- else
- -- also take care of "no level selected"
- levelImage:setProperty("Image", "")
- levelDescription:setText("")
- configButton:setProperty("Disabled", "True")
- end --]]
-end
+
function P.HighscoreBackButton_clicked(e)
hideMenuSheet(P.name)
end
Modified: code/branches/Highscore_HS16/data/gui/scripts/MiscConfigMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/MiscConfigMenu.lua 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/data/gui/scripts/MiscConfigMenu.lua 2016-12-12 14:28:37 UTC (rev 11333)
@@ -17,6 +17,7 @@
function P.onLoad()
P.commandList = {}
+ table.insert(P.commandList, "Highscore playerName_")
table.insert(P.commandList, "KeyBinder mouseSensitivity_")
table.insert(P.commandList, "KeyBinder mouseSensitivityDerived_")
table.insert(P.commandList, "KeyBinder bDeriveMouseInput_")
@@ -42,6 +43,7 @@
table.insert(P.commandList, "HUDRadar RadarMode_")
P.nameList = {}
+ table.insert(P.nameList, "Playername")
table.insert(P.nameList, "Mouse sensitivity")
table.insert(P.nameList, "Mouse acceleration")
table.insert(P.nameList, "Derive mouse input")
Modified: code/branches/Highscore_HS16/src/modules/dodgerace/DodgeRace.cc
===================================================================
--- code/branches/Highscore_HS16/src/modules/dodgerace/DodgeRace.cc 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/modules/dodgerace/DodgeRace.cc 2016-12-12 14:28:37 UTC (rev 11333)
@@ -227,7 +227,7 @@
if (Highscore::exists()){
int score = this->getPoints();
if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
- Highscore::getInstance().storeHighscore("Player","Dodge Race",score);
+ Highscore::getInstance().storeHighscore("Dodge Race",score);
}
GSLevel::startMainMenu();
Modified: code/branches/Highscore_HS16/src/modules/invader/Invader.cc
===================================================================
--- code/branches/Highscore_HS16/src/modules/invader/Invader.cc 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/modules/invader/Invader.cc 2016-12-12 14:28:37 UTC (rev 11333)
@@ -191,7 +191,7 @@
if (Highscore::exists()){
int score = this->getPoints();
if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
- Highscore::getInstance().storeHighscore("Player","Orxonox Arcade",score);
+ Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
}
GSLevel::startMainMenu();
Modified: code/branches/Highscore_HS16/src/modules/jump/Jump.cc
===================================================================
--- code/branches/Highscore_HS16/src/modules/jump/Jump.cc 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/modules/jump/Jump.cc 2016-12-12 14:28:37 UTC (rev 11333)
@@ -314,7 +314,7 @@
if (Highscore::exists()){
int score = this->getScore(this->getPlayer());
if(score > Highscore::getInstance().getHighestScoreOfGame("Jump"))
- Highscore::getInstance().storeHighscore("Player","Jump",score);
+ Highscore::getInstance().storeHighscore("Jump",score);
}
Deathmatch::end();
Modified: code/branches/Highscore_HS16/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/Highscore_HS16/src/modules/tetris/Tetris.cc 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/modules/tetris/Tetris.cc 2016-12-12 14:28:37 UTC (rev 11333)
@@ -330,7 +330,7 @@
if (Highscore::exists()){
int score = this->getScore(this->getPlayer());
if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris"))
- Highscore::getInstance().storeHighscore("Player","Tetris",score);
+ Highscore::getInstance().storeHighscore("Tetris",score);
}
this->cleanup();
Modified: code/branches/Highscore_HS16/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/Highscore_HS16/src/modules/towerdefense/TowerDefense.cc 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/modules/towerdefense/TowerDefense.cc 2016-12-12 14:28:37 UTC (rev 11333)
@@ -200,7 +200,7 @@
if (Highscore::exists()){
int score = this->getWaveNumber();
if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense"))
- Highscore::getInstance().storeHighscore("Player","Tower Defense",score);
+ Highscore::getInstance().storeHighscore("Tower Defense",score);
}
TeamDeathmatch::end();
Modified: code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt 2016-12-12 14:28:37 UTC (rev 11333)
@@ -46,7 +46,6 @@
ADD_SUBDIRECTORY(gamestates)
ADD_SUBDIRECTORY(gametypes)
ADD_SUBDIRECTORY(graphics)
-ADD_SUBDIRECTORY(highscore)
ADD_SUBDIRECTORY(infos)
ADD_SUBDIRECTORY(interfaces)
ADD_SUBDIRECTORY(items)
Modified: code/branches/Highscore_HS16/src/orxonox/Highscore.cc
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/Highscore.cc 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/orxonox/Highscore.cc 2016-12-12 14:28:37 UTC (rev 11333)
@@ -16,18 +16,25 @@
RegisterObject(Highscore);
this->setConfigValues();
}
-
+ /**
+ * @brief set the config values in the orxonox.ini file
+ */
void Highscore::setConfigValues()
{
- SetConfigValue(highscores_, std::vector<std::string>()).description("HighscoreVektor");
+ SetConfigValue(highscores_, std::vector<std::string>()).description("Highscores saved as vector");
+ SetConfigValue(playerName_, "Player").description("Name of the player");
}
-
+ /**
+ * @brief Returns highest score of given game, if exists.
+ * Else returns -1.
+ */
int Highscore::getHighestScoreOfGame(std::string game){
- std::string delimiter = "./.";
+ std::string delimiter = "./."; //score save as "Playername./.game./.score"
int best = -1;
+ //check for the highest Score of given game
for (std::string score : this->highscores_)
{
-
+ //filter the game string from given highscore
score.erase(0, score.find(delimiter) + delimiter.length());
if(game.compare(score.substr(0,score.find(delimiter))) == 0){
score.erase(0, score.find(delimiter) + delimiter.length());
@@ -41,13 +48,11 @@
return best;
}
-
- void Highscore::storeHighscore(std::string player, std::string level, int points){
- ModifyConfigValue(highscores_, add, player+"./."+level+"./."+std::to_string(points));
+ /**
+ * @brief stores a new highscore in the orxonox.ini file
+ */
+ void Highscore::storeHighscore(std::string level, int points){
+ ModifyConfigValue(highscores_, add, playerName_+"./."+level+"./."+std::to_string(points));
}
- /* static std::string Highscore::getName(){
- std::string result;
- result = Highscore::name_;
- return result;
- }*/
+
}
Modified: code/branches/Highscore_HS16/src/orxonox/Highscore.h
===================================================================
--- code/branches/Highscore_HS16/src/orxonox/Highscore.h 2016-12-12 14:17:21 UTC (rev 11332)
+++ code/branches/Highscore_HS16/src/orxonox/Highscore.h 2016-12-12 14:28:37 UTC (rev 11333)
@@ -13,7 +13,7 @@
public:
Highscore(); // Constructor
void setConfigValues(); // Inherited function
- void storeHighscore(std::string player, std::string level, int points);
+ void storeHighscore(std::string level, int points);
int getHighestScoreOfGame(std::string game);
// tolua_begin
@@ -31,6 +31,7 @@
private:
std::vector<std::string> highscores_;
float version_;
+ std::string playerName_;
static Highscore* singletonPtr_s;
}; //tolua_export
More information about the Orxonox-commit
mailing list