[Orxonox-commit 6694] r11324 - code/branches/Highscore_HS16/data/gui/scripts

kappenh at orxonox.net kappenh at orxonox.net
Thu Dec 8 15:21:56 CET 2016


Author: kappenh
Date: 2016-12-08 15:21:55 +0100 (Thu, 08 Dec 2016)
New Revision: 11324

Modified:
   code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
Log:
Menu working: TODO: add more minigames

Modified: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua	2016-12-05 17:01:02 UTC (rev 11323)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua	2016-12-08 14:21:55 UTC (rev 11324)
@@ -4,7 +4,7 @@
 
 P.scrollbarWidth = 13
 P.nameList = {}
-P.scoreList = {}
+P.tabList = {}
 P.linesList = {}
 P.levelList = {}
 
@@ -20,31 +20,7 @@
 
 function P.onLoad()
 	P.createLevelList()
-	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
-
-	P.linesList = {}
-
-
-    -- create tabs with desired tab as argument (nil for all)
-    
-    for k,v in pairs(P.levelList) do
-        -- only add level if it has desired tag
-        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")
     --P.createFilterTab("Presentations", "presentation")
@@ -56,18 +32,41 @@
 
 function P.onShow()
 	
-	P.scoreList = {}
+	P.nameList = {}
+	P.tabList = {}
+	P.linesList = {}
 	test = orxonox.Highscore:getInstance():getNumberOfHighscores()
 
 	for i=0,orxonox.Highscore:getInstance():getNumberOfHighscores()-1 do
-		table.insert(P.scoreList, orxonox.Highscore:getInstance():getHighscore(i))
+		table.insert(P.nameList, orxonox.Highscore:getInstance():getHighscore(i))
 	
 	end
+	
+    for k,v in pairs(P.levelList) do
+        -- only add level if it has desired tag
+        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
     --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()
+	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()
     P.levelList = {}
     local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
@@ -96,7 +95,7 @@
         tabName = tabName..tag
     end
 
-    
+    table.insert(P.tabList, tabName)
     -- create new tab window with desired name
 	local default = (winMgr:createWindow("DefaultWindow", tabName))
     default:setText(name)
@@ -108,11 +107,10 @@
 
    
     local offset = 2
-    for k,v in pairs(P.scoreList) do
+    for k,v in pairs(P.nameList) do
     	
     	local splitlist = P.Split(v,"./.")
-
-    	if(splitlist[1] ~= name)then  --TODO!!!!!!!
+    	if(splitlist[2] == name)then  
     		local line = P.createPickupEntry(tabName .. k,k,tag)
        	 	table.insert(P.linesList, line)
         	line:setYPosition(CEGUI.UDim(0,offset))
@@ -134,20 +132,20 @@
 function P.createPickupEntry(parent,k,tag)
    
     local name = "orxonox/HiscoreEntry" .. parent
-
+    local splitlist = P.Split(P.nameList[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)))
 
     local player = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Player")
-    player:setText(P.nameList[k].. tag)
+    player:setText(splitlist[1])
     player:setPosition(CEGUI.UVector2(CEGUI.UDim(0.005,0), CEGUI.UDim(0,0)))
     player:setSize(CEGUI.UVector2(CEGUI.UDim(0.49, 0), CEGUI.UDim(0, P.imageHeight)))
     
     item:addChildWindow(player)
     	
     local score = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Score")
-    score:setText(P.scoreList[k])
+    score:setText(splitlist[3])
     score:setPosition(CEGUI.UVector2(CEGUI.UDim(0.5,0), CEGUI.UDim(0,0)))
     score:setSize(CEGUI.UVector2(CEGUI.UDim(0.495, 0), CEGUI.UDim(0, P.imageHeight)))
     




More information about the Orxonox-commit mailing list