Changeset 11333
- Timestamp:
- Dec 12, 2016, 3:28:37 PM (8 years ago)
- Location:
- code/branches/Highscore_HS16
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini
r11315 r11333 10 10 campaignMissions_[8] = "shuttleRetaliation.oxw" 11 11 12 [Highscore]13 highscores_[0] = "player./.Jump./.0"14 12 13 -
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
r11326 r11333 3 3 local P = createMenuSheet("HighscoreMenu") 4 4 5 P.scrollbarWidth = 13 6 P.nameList = {} 5 P.highscoreList = {} 7 6 P.tabList = {} 8 7 P.linesList = {} 9 8 P.levelList = {} 10 9 11 P.sampleWindow = nil12 10 13 P.lineHeight = 014 P.playerWidth = 015 P.editboxWidth = 016 P.resetWidth = 017 P.spaceWidth = 018 11 P.imageHeight = 50 19 P.textHeight = 3020 12 21 13 function P.onLoad() 22 P.createLevelList() 23 24 --P.createFilterTab("Minigames", "minigame") 25 --P.createFilterTab("Showcases", "showcase") 26 --P.createFilterTab("Presentations", "presentation") 27 --P.createFilterTab("Tests", "test") 28 --P.createFilterTab("Show All", nil) 29 30 14 P.createLevelList() 31 15 end 32 16 33 17 function P.onShow() 34 18 35 P.nameList = {} 19 -- reset tables 20 P.highscoreList = {} 36 21 P.tabList = {} 37 22 P.linesList = {} 38 test = orxonox.Highscore:getInstance():getNumberOfHighscores()39 23 40 for i=0,orxonox.Highscore:getInstance():getNumberOfHighscores()-1 do 41 table.insert(P.nameList, orxonox.Highscore:getInstance():getHighscore(i)) 24 -- fetch save scores and write it into the list 25 for i=orxonox.Highscore:getInstance():getNumberOfHighscores()-1,0,-1 do 26 table.insert(P.highscoreList, orxonox.Highscore:getInstance():getHighscore(i)) 42 27 43 28 end 44 29 30 -- read minigames out of the levelList 45 31 for k,v in pairs(P.levelList) do 46 -- only add level if it has desired tag 47 if(v:getName() ~= "Hover level" and v:getName() ~= "Pong") then 32 if(v:getName() ~= "Hover level" and v:getName() ~= "Pong") then -- hover and pong dont contain relevant scores 48 33 P.createFilterTab(v:getName(), v:getName()) 49 34 end 50 51 --local highscores = v:getHighscores()52 --orxonox.CommandExecutor:execute("log test:".. highscores)53 54 35 end 55 --local description = winMgr:getWindow("orxonox/HighscoreText") 56 57 --height = getStaticTextWindowHeight(description) 58 --description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height))) 36 59 37 end 60 38 function P.onHide() 39 40 -- delete old windows to reload them on show 61 41 local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl") 62 42 for k,v in pairs(P.tabList) do … … 64 44 tabControl:removeChildWindow(default) 65 45 winMgr:destroyWindow(default) 66 --local highscores = v:getHighscores()67 --orxonox.CommandExecutor:execute("log test:".. highscores)68 69 46 end 70 47 end … … 77 54 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 78 55 if (level ~= nil and level:getXMLFilename() ~= "_temp.oxw" and level:hasTag("minigame")) then 79 local levelXMLFilename = level:getXMLFilename()80 -- create an imageset for each screenshot81 local imageName = level:getScreenshot()82 if imageName ~= "" then83 CEGUI.ImagesetManager:getSingleton():createFromImageFile(levelXMLFilename..imageName, imageName)84 else85 CEGUI.ImagesetManager:getSingleton():createFromImageFile(levelXMLFilename..imageName, "noscreenshot.png")86 end87 56 table.insert(P.levelList, level) 88 57 end … … 109 78 110 79 local offset = 2 111 for k,v in pairs(P. nameList) do112 80 for k,v in pairs(P.highscoreList) do 81 -- split the score ("Playername./.game./.score") 113 82 local splitlist = P.Split(v,"./.") 114 83 if(splitlist[2] == name)then … … 122 91 end 123 92 93 local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl") 94 tabControl:addChildWindow(default) 124 95 125 local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")126 orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".HighscoreSelectionChanged")127 --if listbox:getItemCount() > 0 then128 tabControl:addChildWindow(default)129 --end130 96 131 97 … … 134 100 135 101 local name = "orxonox/HiscoreEntry" .. parent 136 local splitlist = P.Split(P. nameList[k],"./.")102 local splitlist = P.Split(P.highscoreList[k],"./.") 137 103 local item = winMgr:createWindow("DefaultWindow", name) 138 104 item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight))) … … 193 159 return result 194 160 end 195 function P.HighscoreSelectionChanged(e) 196 --local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane") 197 --pane:moveToFront() 198 --[[local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription") 199 local configButton = winMgr:getWindow("orxonox/SingleplayerConfigButton") 200 local level = P.HighscoreGetSelectedLevel() 201 if level ~= nil then 202 local levelXMLFilename = level:getXMLFilename() 203 local imageName = level:getScreenshot() 204 -- set the screenshot and the description for the selected level 205 levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image") 206 levelDescription:setText(level:getDescription()) 207 -- only enable config button for "gametype" levels 208 if level:hasTag("gametype") then 209 configButton:setProperty("Disabled", "False") 210 else 211 configButton:setProperty("Disabled", "True") 212 end 213 else 214 -- also take care of "no level selected" 215 levelImage:setProperty("Image", "") 216 levelDescription:setText("") 217 configButton:setProperty("Disabled", "True") 218 end --]] 219 end 161 220 162 221 163 -
code/branches/Highscore_HS16/data/gui/scripts/MiscConfigMenu.lua
r9977 r11333 18 18 19 19 P.commandList = {} 20 table.insert(P.commandList, "Highscore playerName_") 20 21 table.insert(P.commandList, "KeyBinder mouseSensitivity_") 21 22 table.insert(P.commandList, "KeyBinder mouseSensitivityDerived_") … … 43 44 44 45 P.nameList = {} 46 table.insert(P.nameList, "Playername") 45 47 table.insert(P.nameList, "Mouse sensitivity") 46 48 table.insert(P.nameList, "Mouse acceleration") -
code/branches/Highscore_HS16/src/modules/dodgerace/DodgeRace.cc
r11326 r11333 228 228 int score = this->getPoints(); 229 229 if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race")) 230 Highscore::getInstance().storeHighscore(" Player","Dodge Race",score);230 Highscore::getInstance().storeHighscore("Dodge Race",score); 231 231 232 232 } -
code/branches/Highscore_HS16/src/modules/invader/Invader.cc
r11326 r11333 192 192 int score = this->getPoints(); 193 193 if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade")) 194 Highscore::getInstance().storeHighscore(" Player","Orxonox Arcade",score);194 Highscore::getInstance().storeHighscore("Orxonox Arcade",score); 195 195 196 196 } -
code/branches/Highscore_HS16/src/modules/jump/Jump.cc
r11326 r11333 315 315 int score = this->getScore(this->getPlayer()); 316 316 if(score > Highscore::getInstance().getHighestScoreOfGame("Jump")) 317 Highscore::getInstance().storeHighscore(" Player","Jump",score);317 Highscore::getInstance().storeHighscore("Jump",score); 318 318 319 319 } -
code/branches/Highscore_HS16/src/modules/tetris/Tetris.cc
r11326 r11333 331 331 int score = this->getScore(this->getPlayer()); 332 332 if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris")) 333 Highscore::getInstance().storeHighscore(" Player","Tetris",score);333 Highscore::getInstance().storeHighscore("Tetris",score); 334 334 335 335 } -
code/branches/Highscore_HS16/src/modules/towerdefense/TowerDefense.cc
r11326 r11333 201 201 int score = this->getWaveNumber(); 202 202 if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense")) 203 Highscore::getInstance().storeHighscore(" Player","Tower Defense",score);203 Highscore::getInstance().storeHighscore("Tower Defense",score); 204 204 205 205 } -
code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt
r11313 r11333 47 47 ADD_SUBDIRECTORY(gametypes) 48 48 ADD_SUBDIRECTORY(graphics) 49 ADD_SUBDIRECTORY(highscore)50 49 ADD_SUBDIRECTORY(infos) 51 50 ADD_SUBDIRECTORY(interfaces) -
code/branches/Highscore_HS16/src/orxonox/Highscore.cc
r11315 r11333 17 17 this->setConfigValues(); 18 18 } 19 19 /** 20 * @brief set the config values in the orxonox.ini file 21 */ 20 22 void Highscore::setConfigValues() 21 23 { 22 SetConfigValue(highscores_, std::vector<std::string>()).description("HighscoreVektor"); 24 SetConfigValue(highscores_, std::vector<std::string>()).description("Highscores saved as vector"); 25 SetConfigValue(playerName_, "Player").description("Name of the player"); 23 26 } 24 27 /** 28 * @brief Returns highest score of given game, if exists. 29 * Else returns -1. 30 */ 25 31 int Highscore::getHighestScoreOfGame(std::string game){ 26 std::string delimiter = "./."; 32 std::string delimiter = "./."; //score save as "Playername./.game./.score" 27 33 int best = -1; 34 //check for the highest Score of given game 28 35 for (std::string score : this->highscores_) 29 36 { 30 37 //filter the game string from given highscore 31 38 score.erase(0, score.find(delimiter) + delimiter.length()); 32 39 if(game.compare(score.substr(0,score.find(delimiter))) == 0){ … … 42 49 43 50 } 44 45 void Highscore::storeHighscore(std::string player, std::string level, int points){ 46 ModifyConfigValue(highscores_, add, player+"./."+level+"./."+std::to_string(points)); 51 /** 52 * @brief stores a new highscore in the orxonox.ini file 53 */ 54 void Highscore::storeHighscore(std::string level, int points){ 55 ModifyConfigValue(highscores_, add, playerName_+"./."+level+"./."+std::to_string(points)); 47 56 } 48 /* static std::string Highscore::getName(){ 49 std::string result; 50 result = Highscore::name_; 51 return result; 52 }*/ 57 53 58 } -
code/branches/Highscore_HS16/src/orxonox/Highscore.h
r11315 r11333 14 14 Highscore(); // Constructor 15 15 void setConfigValues(); // Inherited function 16 void storeHighscore(std::string player, std::stringlevel, int points);16 void storeHighscore(std::string level, int points); 17 17 18 18 int getHighestScoreOfGame(std::string game); … … 32 32 std::vector<std::string> highscores_; 33 33 float version_; 34 std::string playerName_; 34 35 static Highscore* singletonPtr_s; 35 36 }; //tolua_export
Note: See TracChangeset
for help on using the changeset viewer.