Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11333


Ignore:
Timestamp:
Dec 12, 2016, 3:28:37 PM (8 years ago)
Author:
kappenh
Message:

Finished Project

Location:
code/branches/Highscore_HS16
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Highscore_HS16/data/defaultConfig/orxonox.ini

    r11315 r11333  
    1010campaignMissions_[8] = "shuttleRetaliation.oxw"
    1111
    12 [Highscore]
    13 highscores_[0] = "player./.Jump./.0"
    1412
     13
  • code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua

    r11326 r11333  
    33local P = createMenuSheet("HighscoreMenu")
    44
    5 P.scrollbarWidth = 13
    6 P.nameList = {}
     5P.highscoreList = {}
    76P.tabList = {}
    87P.linesList = {}
    98P.levelList = {}
    109
    11 P.sampleWindow = nil
    1210
    13 P.lineHeight = 0
    14 P.playerWidth = 0
    15 P.editboxWidth = 0
    16 P.resetWidth = 0
    17 P.spaceWidth = 0
    1811P.imageHeight = 50
    19 P.textHeight = 30
    2012
    2113function 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()   
    3115end
    3216
    3317function P.onShow()
    3418       
    35         P.nameList = {}
     19        -- reset tables
     20        P.highscoreList = {}
    3621        P.tabList = {}
    3722        P.linesList = {}
    38         test = orxonox.Highscore:getInstance():getNumberOfHighscores()
    3923
    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))
    4227       
    4328        end
    4429       
     30        -- read minigames out of the levelList
    4531    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
    4833            P.createFilterTab(v:getName(), v:getName())
    4934        end
    50        
    51         --local highscores = v:getHighscores()
    52         --orxonox.CommandExecutor:execute("log test:".. highscores)
    53 
    5435    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 
    5937end
    6038function P.onHide()
     39
     40        -- delete old windows to reload them on show
    6141        local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
    6242        for k,v in pairs(P.tabList) do
     
    6444            tabControl:removeChildWindow(default)
    6545                winMgr:destroyWindow(default)
    66         --local highscores = v:getHighscores()
    67         --orxonox.CommandExecutor:execute("log test:".. highscores)
    68 
    6946    end
    7047end
     
    7754        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
    7855        if (level ~= nil and level:getXMLFilename() ~= "_temp.oxw" and level:hasTag("minigame")) then
    79             local levelXMLFilename = level:getXMLFilename()
    80             -- create an imageset for each screenshot
    81             local imageName = level:getScreenshot()
    82             if imageName ~= "" then
    83                 CEGUI.ImagesetManager:getSingleton():createFromImageFile(levelXMLFilename..imageName, imageName)
    84             else
    85                 CEGUI.ImagesetManager:getSingleton():createFromImageFile(levelXMLFilename..imageName, "noscreenshot.png")
    86             end
    8756            table.insert(P.levelList, level)
    8857        end
     
    10978   
    11079    local offset = 2
    111     for k,v in pairs(P.nameList) do
    112        
     80    for k,v in pairs(P.highscoreList) do
     81        -- split the score ("Playername./.game./.score")
    11382        local splitlist = P.Split(v,"./.")
    11483        if(splitlist[2] == name)then 
     
    12291    end
    12392
     93        local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
     94        tabControl:addChildWindow(default)
    12495 
    125     local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
    126     orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".HighscoreSelectionChanged")
    127     --if listbox:getItemCount() > 0 then
    128         tabControl:addChildWindow(default)
    129     --end
    13096
    13197   
     
    134100   
    135101    local name = "orxonox/HiscoreEntry" .. parent
    136     local splitlist = P.Split(P.nameList[k],"./.")
     102    local splitlist = P.Split(P.highscoreList[k],"./.")
    137103    local item = winMgr:createWindow("DefaultWindow", name)
    138104    item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight)))
     
    193159    return result
    194160end
    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
    220162
    221163
  • code/branches/Highscore_HS16/data/gui/scripts/MiscConfigMenu.lua

    r9977 r11333  
    1818
    1919    P.commandList = {}
     20    table.insert(P.commandList, "Highscore playerName_")
    2021    table.insert(P.commandList, "KeyBinder mouseSensitivity_")
    2122    table.insert(P.commandList, "KeyBinder mouseSensitivityDerived_")
     
    4344
    4445    P.nameList = {}
     46    table.insert(P.nameList, "Playername")
    4547    table.insert(P.nameList, "Mouse sensitivity")
    4648    table.insert(P.nameList, "Mouse acceleration")
  • code/branches/Highscore_HS16/src/modules/dodgerace/DodgeRace.cc

    r11326 r11333  
    228228                    int score = this->getPoints();
    229229                    if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
    230                         Highscore::getInstance().storeHighscore("Player","Dodge Race",score);
     230                        Highscore::getInstance().storeHighscore("Dodge Race",score);
    231231
    232232          }
  • code/branches/Highscore_HS16/src/modules/invader/Invader.cc

    r11326 r11333  
    192192                    int score = this->getPoints();
    193193                    if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
    194                         Highscore::getInstance().storeHighscore("Player","Orxonox Arcade",score);
     194                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
    195195
    196196          }
  • code/branches/Highscore_HS16/src/modules/jump/Jump.cc

    r11326 r11333  
    315315                    int score = this->getScore(this->getPlayer());
    316316                    if(score > Highscore::getInstance().getHighestScoreOfGame("Jump"))
    317                         Highscore::getInstance().storeHighscore("Player","Jump",score);
     317                        Highscore::getInstance().storeHighscore("Jump",score);
    318318
    319319          }
  • code/branches/Highscore_HS16/src/modules/tetris/Tetris.cc

    r11326 r11333  
    331331                    int score = this->getScore(this->getPlayer());
    332332                    if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris"))
    333                         Highscore::getInstance().storeHighscore("Player","Tetris",score);
     333                        Highscore::getInstance().storeHighscore("Tetris",score);
    334334
    335335          }
  • code/branches/Highscore_HS16/src/modules/towerdefense/TowerDefense.cc

    r11326 r11333  
    201201                    int score = this->getWaveNumber();
    202202                    if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense"))
    203                         Highscore::getInstance().storeHighscore("Player","Tower Defense",score);
     203                        Highscore::getInstance().storeHighscore("Tower Defense",score);
    204204
    205205          }
  • code/branches/Highscore_HS16/src/orxonox/CMakeLists.txt

    r11313 r11333  
    4747ADD_SUBDIRECTORY(gametypes)
    4848ADD_SUBDIRECTORY(graphics)
    49 ADD_SUBDIRECTORY(highscore)
    5049ADD_SUBDIRECTORY(infos)
    5150ADD_SUBDIRECTORY(interfaces)
  • code/branches/Highscore_HS16/src/orxonox/Highscore.cc

    r11315 r11333  
    1717        this->setConfigValues();
    1818    }
    19 
     19    /**
     20     * @brief set the config values in the orxonox.ini file
     21     */
    2022    void Highscore::setConfigValues()
    2123    {
    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");
    2326    }
    24 
     27    /**
     28     * @brief Returns highest score of given game, if exists.
     29     * Else returns -1.
     30     */
    2531    int Highscore::getHighestScoreOfGame(std::string game){
    26         std::string delimiter = "./.";
     32        std::string delimiter = "./."; //score save as "Playername./.game./.score"
    2733        int best = -1;
     34        //check for the highest Score of given game
    2835        for (std::string score : this->highscores_)
    2936        {
    30            
     37            //filter the game string from given highscore
    3138            score.erase(0, score.find(delimiter) + delimiter.length());
    3239            if(game.compare(score.substr(0,score.find(delimiter))) == 0){
     
    4249       
    4350    }
    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));
    4756    }
    48     /* static std::string Highscore::getName(){
    49         std::string result;
    50         result = Highscore::name_;
    51         return result;
    52     }*/
     57   
    5358}
  • code/branches/Highscore_HS16/src/orxonox/Highscore.h

    r11315 r11333  
    1414        Highscore();              // Constructor
    1515        void setConfigValues(); // Inherited function
    16         void storeHighscore(std::string player, std::string level, int points);
     16        void storeHighscore(std::string level, int points);
    1717
    1818        int getHighestScoreOfGame(std::string game);
     
    3232        std::vector<std::string> highscores_;
    3333        float version_;
     34        std::string playerName_;
    3435        static Highscore* singletonPtr_s;
    3536}; //tolua_export
Note: See TracChangeset for help on using the changeset viewer.