[Orxonox-commit 6614] r11254 - in code/branches/Highscore_HS16/data/gui: layouts scripts
kappenh at orxonox.net
kappenh at orxonox.net
Mon Oct 31 15:27:31 CET 2016
Author: kappenh
Date: 2016-10-31 15:27:31 +0100 (Mon, 31 Oct 2016)
New Revision: 11254
Modified:
code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
Log:
Layout fertig
Modified: code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout
===================================================================
--- code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout 2016-10-31 13:07:50 UTC (rev 11253)
+++ code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout 2016-10-31 14:27:31 UTC (rev 11254)
@@ -19,7 +19,7 @@
<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" >
+ <!--<Window Type="MenuWidgets/StaticText" Name="orxonox/HighscoreMenuWrapper" >
<Property Name="InheritsAlpha" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="HorzFormatting" Value="HorzCentred" />
@@ -36,7 +36,9 @@
<Property Name="HorzScrollPosition" Value="0" />
<Property Name="VertScrollPosition" Value="0" />
</Window>
+
</Window>
+ -->
</Window>
<Window Type="MenuWidgets/Button" Name="orxonox/HighscoreBackButton" >
<Property Name="Text" Value="Back" />
Modified: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-10-31 13:07:50 UTC (rev 11253)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-10-31 14:27:31 UTC (rev 11254)
@@ -14,6 +14,8 @@
P.editboxWidth = 0
P.resetWidth = 0
P.spaceWidth = 0
+P.imageHeight = 50
+P.textHeight = 30
function P.onLoad()
P.nameList = {}
@@ -25,52 +27,18 @@
P.linesList = {}
- --Calculate design parameters:
- 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("Game1", "game1")
+ P.createFilterTab("Game2", "game2")
--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]
-
- P.playerWidth = 0
- for k,v in pairs(P.scoreList) do
- P.sampleWindow:setText(P.nameList[k])
- size = getMinTextSize(P.sampleWindow)
- if size[2] > P.playerWidth then
- P.playerWidth = size[2]
- end
- end
-
- P.sampleWindow:setText("reset")
- size = getMinTextSize(P.sampleWindow)
- P.resetWidth = size[2]+20
-
- P.spaceWidth = 10
- local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
- size = pane:getViewableArea()
-
- P.editboxWidth = size:getWidth() - P.playerWidth - P.resetWidth - 5*P.spaceWidth
-
- P.createLines()
-
- P:setButton(1, 1, {
- ["button"] = winMgr:getWindow("orxonox/HighscoreBackButton"),
- ["callback"] = P.HighscoreBackButton_clicked
- })
end
function P.onShow()
@@ -88,18 +56,57 @@
-- create new tab window with desired name
- local default = CEGUI.toListbox(winMgr:createWindow("DefaultWindow", tabName))
+ local default = (winMgr:createWindow("DefaultWindow", tabName))
default:setText(name)
+ default:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
+ default:setProperty("UnifiedAreaRect", "{{0,0},{0,0},{1,0},{1,0}}")
+ local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", tabName .. "pane")
+ pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
+ default:addChildWindow(pane)
+
+
+ local offset = 2
+ for k,v in pairs(P.scoreList) do
+ local line = P.createPickupEntry(tabName .. k,k,tag)
+ table.insert(P.linesList, line)
+ line:setYPosition(CEGUI.UDim(0,offset))
+ offset = offset + line:getHeight():asAbsolute(1)+2
+ pane:addChildWindow(line)
+ end
+
local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".HighscoreSelectionChanged")
--if listbox:getItemCount() > 0 then
- tabControl:addChildWindow(tabName)
+ tabControl:addChildWindow(default)
--end
end
+function P.createPickupEntry(parent,k,tag)
+
+ local name = "orxonox/HiscoreEntry" .. parent
+ 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: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: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)))
+
+ item:addChildWindow(score)
+
+ return item
+end
function P.HighscoreGetSelectedLevel()
-- choose the active listbox
local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/HighscoreTabControl"))
@@ -116,8 +123,8 @@
end
function P.HighscoreSelectionChanged(e)
- local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
- pane:moveToFront()
+ --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()
@@ -141,63 +148,7 @@
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" .. tabName)
- line:setHeight(CEGUI.UDim(0, P.lineHeight))
- line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
-
- local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
- local half = (pane:getViewableArea()):getWidth() * 0.5
- local offset = half * 0.01
- -- config name
- 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)))
- line:addChildWindow(player)
-
-
- -- config value (editable)
-
- 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])
- playerValue:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0)))
- playerValue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, half+offset), CEGUI.UDim(0, 0)))
- -- enable the reset button if the value changed
- orxonox.GUIManager:subscribeEventHelper(playerValue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted")
- line:addChildWindow(playerValue)
-
-
-
- line:setWidth(CEGUI.UDim(0, 2*half))
-
- return line
-end
-
-function P.createLines()
- local window = winMgr:getWindow("orxonox/HighscoreMenuPane")
-
- for k,v in pairs(P.scoreList) do
- local line = P.createLine(k,nil)
- table.insert(P.linesList, line)
- window:addChildWindow(line)
- end
-
- local pane = tolua.cast(window, "CEGUI::ScrollablePane")
- pane:setVerticalStepSize(getScrollingStepSize(window))
-end
-
-
function P.HighscoreBackButton_clicked(e)
hideMenuSheet(P.name)
end
More information about the Orxonox-commit
mailing list