Index: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua	(revision 11315)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua	(revision 11324)
@@ -5,5 +5,5 @@
 P.scrollbarWidth = 13
 P.nameList = {}
-P.scoreList = {}
+P.tabList = {}
 P.linesList = {}
 P.levelList = {}
@@ -21,20 +21,26 @@
 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)
+
+    
+end
+
+function P.onShow()
+	
 	P.nameList = {}
-	
-	P.scoreList = {}
+	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))
-		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
@@ -46,26 +52,19 @@
 
     end
-    --P.createFilterTab("Minigames", "minigame")
-    --P.createFilterTab("Showcases", "showcase")
-    --P.createFilterTab("Presentations", "presentation")
-    --P.createFilterTab("Tests", "test")
-    --P.createFilterTab("Show All", nil)
-
-    
-end
-
-function P.onShow()
-	
-	P.scoreList = {}
-	test = orxonox.Highscore:getInstance():getNumberOfHighscores()
-
-	for i=0,orxonox.Highscore:getInstance():getNumberOfHighscores()-1 do
-		table.insert(P.scoreList, orxonox.Highscore:getInstance():getHighscore(i))
-	
-	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()
@@ -97,5 +96,5 @@
     end
 
-    
+    table.insert(P.tabList, tabName)
     -- create new tab window with desired name
 	local default = (winMgr:createWindow("DefaultWindow", tabName))
@@ -109,9 +108,8 @@
    
     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)
@@ -135,5 +133,5 @@
    
     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)))
@@ -141,5 +139,5 @@
 
     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)))
@@ -148,5 +146,5 @@
     	
     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)))
