[Orxonox-commit 5223] r9886 - in code/branches/spacestationentry/data/gui: layouts scripts

agermann at orxonox.net agermann at orxonox.net
Mon Dec 9 15:59:57 CET 2013


Author: agermann
Date: 2013-12-09 15:59:56 +0100 (Mon, 09 Dec 2013)
New Revision: 9886

Added:
   code/branches/spacestationentry/data/gui/layouts/UndockingDialog.layout
   code/branches/spacestationentry/data/gui/scripts/UndockingDialog.lua
Log:
 

Added: code/branches/spacestationentry/data/gui/layouts/UndockingDialog.layout
===================================================================
--- code/branches/spacestationentry/data/gui/layouts/UndockingDialog.layout	                        (rev 0)
+++ code/branches/spacestationentry/data/gui/layouts/UndockingDialog.layout	2013-12-09 14:59:56 UTC (rev 9886)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+    <Window Type="MenuWidgets/StaticImage" Name="orxonox/Undocking/Background" >
+        <Property Name="FrameEnabled" Value="False" />
+        <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}}" />
+        <Property Name="BackgroundEnabled" Value="False" />
+        <Window Type="MenuWidgets/StaticText" Name="orxonox/Undocking/Title" >
+            <Property Name="Text" Value="Undocking" />
+            <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.25,0},{0.2875,0},{0.75,0},{0.7,0}}" />
+            <Window Type="MenuWidgets/Listbox" Name="orxonox/Undocking/Docks" >
+                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}" />
+            </Window>
+        </Window>
+        <Window Type="MenuWidgets/Button" Name="orxonox/Undocking/DockButton" >
+            <Property Name="Text" Value="Undock" />
+            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.725,0},{0.4875,0},{0.775,0}}" />
+            <Event Name="Clicked" Function="UndockingDialog.undockButton_clicked"/>
+        </Window>
+        <Window Type="MenuWidgets/Button" Name="orxonox/Undocking/CancelButton" >
+            <Property Name="Text" Value="Cancel" />
+            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.725,0},{0.7125,0},{0.775,0}}" />
+            <Event Name="Clicked" Function="UndockingDialog.cancelButton_clicked"/>
+        </Window>
+    </Window>
+</GUILayout>

Added: code/branches/spacestationentry/data/gui/scripts/UndockingDialog.lua
===================================================================
--- code/branches/spacestationentry/data/gui/scripts/UndockingDialog.lua	                        (rev 0)
+++ code/branches/spacestationentry/data/gui/scripts/UndockingDialog.lua	2013-12-09 14:59:56 UTC (rev 9886)
@@ -0,0 +1,69 @@
+-- DockingDialog.lua
+
+local P = createMenuSheet("UndockingDialog")
+
+P.docks = {}
+
+function P.onLoad()
+
+     --button are arranged in a 1x2 matrix
+    P:setButton(1, 1, {
+            ["button"] = winMgr:getWindow("orxonox/Undocking/DockButton"),
+            ["callback"]  = P.undockButton_clicked
+    })
+
+    P:setButton(1, 2, {
+            ["button"] = winMgr:getWindow("orxonox/Undocking/CancelButton"),
+            ["callback"]  = P.cancelButton_clicked
+    })
+    
+end
+
+function P.onShow()
+    orxonox.execute("setPause 1")
+    P.update()
+end
+
+function P.onHide()
+    orxonox.execute("setPause 0")
+end
+
+function P.update()
+    -- update dock list
+    P.docks = {}
+    local docks = orxonox.Dock:getNumberOfActiveDocks()
+    for i = 0, docks-1 do
+        table.insert(P.docks, orxonox.Dock:getActiveDockAtIndex(i))
+    end
+
+    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/Undocking/Docks"))
+    listbox:resetList()
+
+    for k in pairs(P.docks) do
+        local item = CEGUI.createListboxTextItem("Dock " .. k)
+        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
+        listbox:addItem(item)
+        if k == 1 then
+            listbox:setItemSelectState(item, true)
+        end
+    end
+end
+
+function P.undockButton_clicked(e)
+    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/Undocking/Docks"))
+    local choice = listbox:getFirstSelectedItem()
+    if choice ~= nil then
+        local index = listbox:getItemIndex(choice)
+        local dock = P.docks[index+1]
+        if dock ~= nil then
+            dock:undock()
+        end
+    end
+    hideMenuSheet(P.name)
+end
+
+function P.cancelButton_clicked(e)
+    hideMenuSheet(P.name)
+end
+
+return P




More information about the Orxonox-commit mailing list