[Orxonox-commit 6605] r11245 - in code/branches/Highscore_HS16/data/gui: layouts scripts
kappenh at orxonox.net
kappenh at orxonox.net
Mon Oct 24 16:04:51 CEST 2016
Author: kappenh
Date: 2016-10-24 16:04:51 +0200 (Mon, 24 Oct 2016)
New Revision: 11245
Modified:
code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
Log:
Tabbar im HS Menu
Modified: code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout
===================================================================
--- code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout 2016-10-24 14:03:24 UTC (rev 11244)
+++ code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout 2016-10-24 14:04:51 UTC (rev 11245)
@@ -12,7 +12,13 @@
<Property Name="HorzFormatting" Value="HorzCentred" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="VertFormatting" Value="TopAligned" />
- <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.2125,0},{0.85,0},{0.6375,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.1,0},{0.85,0},{0.85,0}}" />
+ <Window Type="MenuWidgets/TabControl" Name="orxonox/HighscoreTabControl" >
+ <Property Name="TabHeight" Value="{0,30}" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="TabPanePosition" Value="Top" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.105,0},{0.95,0},{0.99,0}}" />
+ </Window>
<Window Type="MenuWidgets/StaticText" Name="orxonox/HighscoreMenuWrapper" >
<Property Name="InheritsAlpha" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
@@ -35,7 +41,7 @@
<Window Type="MenuWidgets/Button" Name="orxonox/HighscoreBackButton" >
<Property Name="Text" Value="Back" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.8625,0},{0.6,0},{0.9125,0}}" />
<Event Name="Clicked" Function="HighscoreMenu.HighscoreBackButton_clicked"/>
</Window>
</Window>
Modified: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-10-24 14:03:24 UTC (rev 11244)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-10-24 14:04:51 UTC (rev 11245)
@@ -29,6 +29,19 @@
P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/SampleWindow")
P.sampleWindow:setText("SampleText")
+ -- create tabs with desired tab as argument (nil for all)
+
+ P.createFilterTab("Gametypes", "gametype")
+ P.createFilterTab("Missions", "mission")
+ --P.createFilterTab("Minigames", "minigame")
+ --P.createFilterTab("Showcases", "showcase")
+ --P.createFilterTab("Presentations", "presentation")
+ --P.createFilterTab("Tests", "test")
+ --P.createFilterTab("Show All", nil)
+
+ -- update description and screenshot boxes
+ --P.SingleplayerSelectionChanged()
+
local size = getMinTextSize(P.sampleWindow)
P.lineHeight = size[1]
@@ -66,9 +79,78 @@
--height = getStaticTextWindowHeight(description)
--description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height)))
end
-function P.createLine(k)
+function P.createFilterTab(name, tag)
+ -- create unique tab window name
+ local tabName = "orxonox/HighscoreLevelTab"
+ if tag ~= nil then
+ tabName = tabName..tag
+ end
+
+
+ -- create new tab window with desired name
+ local default = CEGUI.toListbox(winMgr:createWindow("DefaultWindow", tabName))
+ default:setText(name)
+
+ local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
+ orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".HighscoreSelectionChanged")
+ --if listbox:getItemCount() > 0 then
+ tabControl:addChildWindow(tabName)
+ --end
+
+
+end
+
+function P.HighscoreGetSelectedLevel()
+ -- choose the active listbox
+ local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/HighscoreTabControl"))
+ local listbox = CEGUI.toListbox(tabControl:getTabContentsAtIndex(tabControl:getSelectedTabIndex()))
+ local choice = listbox:getFirstSelectedItem()
+ if choice ~= nil then
+ -- get the right tab and the right index
+ local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1]
+ local index = tabIndexes[listbox:getItemIndex(choice)+1]
+ return P.levelList[index]
+ else
+ return nil
+ end
+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.createLine(k,tag)
+
+ local tabName = k
+
+ if tag ~= nil then
+ tabName = tabName..tag
+ end
+
-- content window for the entire line
- local line = winMgr:createWindow("DefaultWindow", "orxonox/HighscoreMenuPane/Score" .. k)
+ local line = winMgr:createWindow("DefaultWindow", "orxonox/HighscoreMenuPane/Score" .. tabName)
line:setHeight(CEGUI.UDim(0, P.lineHeight))
line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
@@ -76,7 +158,7 @@
local half = (pane:getViewableArea()):getWidth() * 0.5
local offset = half * 0.01
-- config name
- local player = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. k .. "/Player")
+ local player = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. tabName .. "/Player")
player:setText(P.nameList[k])
player:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0)))
player:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
@@ -85,7 +167,7 @@
-- config value (editable)
- local playerValue = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. k .. "/Value")
+ local playerValue = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. tabName .. "/Value")
--playerValue:setProperty("ReadOnly", "set:False")
--local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])SS
playerValue:setText(P.scoreList[k])
@@ -106,7 +188,7 @@
local window = winMgr:getWindow("orxonox/HighscoreMenuPane")
for k,v in pairs(P.scoreList) do
- local line = P.createLine(k)
+ local line = P.createLine(k,nil)
table.insert(P.linesList, line)
window:addChildWindow(line)
end
More information about the Orxonox-commit
mailing list