[Orxonox-commit 6595] r11235 - in code/branches/Highscore_HS16/data/gui: layouts scripts
kappenh at orxonox.net
kappenh at orxonox.net
Mon Oct 17 15:59:54 CEST 2016
Author: kappenh
Date: 2016-10-17 15:59:53 +0200 (Mon, 17 Oct 2016)
New Revision: 11235
Added:
code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
Log:
Added HighscoreTable to the main menu and added layout files
Added: code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout
===================================================================
--- code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout (rev 0)
+++ code/branches/Highscore_HS16/data/gui/layouts/HighscoreMenu.layout 2016-10-17 13:59:53 UTC (rev 11235)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/HighscoreMenu/Background" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/HighscoreWindow" >
+ <Property Name="Text" Value="Highscore" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <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}}" />
+ <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" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
+ <Window Type="MenuWidgets/ScrollablePane" Name="orxonox/HighscoreMenuPane" >
+ <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
+ <Property Name="HorzStepSize" Value="0.005" />
+ <Property Name="VertStepSize" Value="0.005" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzOverlapSize" Value="0.01" />
+ <Property Name="UnifiedAreaRect" Value="{{0.005,0},{0.01,0},{0.995,0},{0.99,0}}" />
+ <Property Name="VertOverlapSize" Value="0.01" />
+ <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" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="HighscoreMenu.HighscoreBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Added: code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
===================================================================
--- code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua (rev 0)
+++ code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua 2016-10-17 13:59:53 UTC (rev 11235)
@@ -0,0 +1,124 @@
+-- HighscoreMenu.lua
+
+local P = createMenuSheet("HighscoreMenu")
+
+P.scrollbarWidth = 13
+P.nameList = {}
+P.scoreList = {}
+P.linesList = {}
+
+P.sampleWindow = nil
+
+P.lineHeight = 0
+P.playerWidth = 0
+P.editboxWidth = 0
+P.resetWidth = 0
+P.spaceWidth = 0
+
+function P.onLoad()
+ P.nameList = {}
+ table.insert(P.nameList, "firsttestPlayer")
+ table.insert(P.nameList, "secondtestPlayer")
+ P.scoreList = {}
+ table.insert(P.scoreList, 120)
+ table.insert(P.scoreList, 20)
+
+ P.linesList = {}
+
+ --Calculate design parameters:
+ P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/SampleWindow")
+ P.sampleWindow:setText("SampleText")
+
+ 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()
+ --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.createLine(k)
+ -- content window for the entire line
+ local line = winMgr:createWindow("DefaultWindow", "orxonox/HighscoreMenuPane/Score" .. k)
+ 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" .. k .. "/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" .. k .. "/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)
+ 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
+
+return P
+
More information about the Orxonox-commit
mailing list