[Orxonox-commit 2993] r7689 - in code/trunk: . data/gui/layouts data/gui/scripts src/orxonox/gamestates src/orxonox/overlays
dafrick at orxonox.net
dafrick at orxonox.net
Wed Dec 1 15:00:19 CET 2010
Author: dafrick
Date: 2010-12-01 15:00:19 +0100 (Wed, 01 Dec 2010)
New Revision: 7689
Added:
code/trunk/data/gui/layouts/HostMenu.layout
code/trunk/data/gui/scripts/HostMenu.lua
Modified:
code/trunk/
code/trunk/data/gui/layouts/MainMenuBackground.layout
code/trunk/data/gui/layouts/MultiplayerMenu.layout
code/trunk/data/gui/scripts/AudioMenu.lua
code/trunk/data/gui/scripts/ControlsMenu.lua
code/trunk/data/gui/scripts/CreditsMenu.lua
code/trunk/data/gui/scripts/GUISheet.lua
code/trunk/data/gui/scripts/GUITools.lua
code/trunk/data/gui/scripts/GraphicsMenu.lua
code/trunk/data/gui/scripts/InGameMenu.lua
code/trunk/data/gui/scripts/MainMenu.lua
code/trunk/data/gui/scripts/MenuSheet.lua
code/trunk/data/gui/scripts/MultiplayerMenu.lua
code/trunk/data/gui/scripts/SettingsMenu.lua
code/trunk/data/gui/scripts/SheetManager.lua
code/trunk/data/gui/scripts/SingleplayerMenu.lua
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
code/trunk/src/orxonox/overlays/InGameConsole.cc
Log:
Merging menu branch to trunk.
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/lastmanstanding:7479-7644
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
+ /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/lastmanstanding:7479-7644
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
Copied: code/trunk/data/gui/layouts/HostMenu.layout (from rev 7687, code/branches/menu/data/gui/layouts/HostMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/HostMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/HostMenu.layout 2010-12-01 14:00:19 UTC (rev 7689)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="MenuWidgets/StaticImage" Name="orxonox/HostMenuBackground" >
+ <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/HostMenuWindow" >
+ <Property Name="Text" Value="Multiplayer" />
+ <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/HostMenuListbox" >
+ <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 Type="MenuWidgets/RadioButton" Name="orxonox/HostMenuHostButton" >
+ <Property Name="Text" Value="Build Server"/>
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.87,0},{0.3,0},{0.97,0}}" />
+ <Event Name="SelectStateChanged" Function="HostMenu.HostMenuBuildServerButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/RadioButton" Name="orxonox/HostMenuDedicatedButton" >
+ <Property Name="Text" Value="Dedicated" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.5,0},{0.87,0},{0.7,0},{0.97,0}}" />
+ <Event Name="SelectStateChanged" Function="HostMenu.HostMenuDedicatedButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Checkbox" Name="orxonox/MultiplayerShowAllCheckbox" >
+ <Property Name="Text" Value="show all" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.8,0},{0.87,0},{1,0},{.97,0}}" />
+ <Event Name="CheckStateChanged" Function="HostMenu.MultiplayerShowAll_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/HostMenuStartButton" >
+ <Property Name="Text" Value="Start" />
+ <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="HostMenu.HostMenuStartButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/HostMenuBackButton" >
+ <Property Name="Text" Value="Back" />
+ <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="HostMenu.HostMenuBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
+
Modified: code/trunk/data/gui/layouts/MainMenuBackground.layout
===================================================================
--- code/trunk/data/gui/layouts/MainMenuBackground.layout 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/layouts/MainMenuBackground.layout 2010-12-01 14:00:19 UTC (rev 7689)
@@ -1,10 +1,10 @@
<?xml version="1.0" ?>
<GUILayout>
<Window Type="MenuWidgets/StaticImage" Name="orxonox/Background">
- <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
- <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
- <Property Name="FrameEnabled" Value="set:true"/>
- <Property Name="BackgroundEnabled" Value="set:false"/>
- <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
+ <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
+ <Property Name="FrameEnabled" Value="set:true"/>
+ <Property Name="BackgroundEnabled" Value="set:false"/>
+ <Property Name="InheritsAlpha" Value="False" />
</Window>
</GUILayout>
Modified: code/trunk/data/gui/layouts/MultiplayerMenu.layout
===================================================================
--- code/trunk/data/gui/layouts/MultiplayerMenu.layout 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/layouts/MultiplayerMenu.layout 2010-12-01 14:00:19 UTC (rev 7689)
@@ -14,48 +14,30 @@
<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}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
<Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerListbox" >
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.8,0}}" />
</Window>
- <Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerJoinButton" >
- <Property Name="Text" Value="Join" />
- <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.81,0},{0.3,0},{0.89,0}}" />
- <Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerJoinButton_clicked"/>
- </Window>
- <Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerHostButton" >
- <Property Name="Text" Value="Host" />
- <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.81,0},{0.6,0},{0.89,0}}" />
- <Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerHostButton_clicked"/>
- </Window>
- <Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerDedicatedButton" >
- <Property Name="Text" Value="Dedicated" />
- <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.81,0},{0.9,0},{0.89,0}}" />
- <Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerDedicatedButton_clicked"/>
- </Window>
- <Window Type="MenuWidgets/Checkbox" Name="orxonox/MultiplayerShowAllCheckbox" >
- <Property Name="Text" Value="show all" />
- <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.89,0},{0.8,0},{0.99,0}}" />
- <Property Name="Disabled" Value="True" />
- <Event Name="CheckStateChanged" Function="MultiplayerMenu.MultiplayerShowAll_clicked"/>
- </Window>
</Window>
- <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerStartButton" >
- <Property Name="Text" Value="Start" />
- <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="MultiplayerMenu.MultiplayerStartButton_clicked"/>
- </Window>
- <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerBackButton" >
+ <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerBackButton" >
<Property Name="Text" Value="Back" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.725,0},{0.7125,0},{0.775,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.7125,0},{0.8625,0},{0.9125,0},{0.9125,0}}" />
<Event Name="Clicked" Function="MultiplayerMenu.MultiplayerBackButton_clicked"/>
</Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerJoinButton" >
+ <Property Name="Text" Value="Join" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.6625,0},{0.4875,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="MultiplayerMenu.MultiplayerJoinButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerHostButton" >
+ <Property Name="Text" Value="Host" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.6625,0},{0.7125,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="MultiplayerMenu.MultiplayerHostButton_clicked"/>
+ </Window>
</Window>
</GUILayout>
+
Modified: code/trunk/data/gui/scripts/AudioMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/AudioMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/AudioMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -2,6 +2,13 @@
local P = createMenuSheet("AudioMenu")
+P.buttonList = {}
+
+function P.onShow()
+ P.oldindex = -2
+ P.index = -1
+end
+
function P.onLoad()
soundMgr = orxonox.SoundManager:getInstance()
block = false
@@ -41,6 +48,12 @@
else
listboxwindow:setItemSelectState(0,true)
end
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
+ ["function"] = P.AudioBackButton_clicked
+ }
+ P.buttonList[1] = item
end
function P.AudioMasterScrollbar_changed(e)
@@ -171,5 +184,9 @@
hideMenuSheet(P.name)
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 1, 1)
+end
+
return P
Modified: code/trunk/data/gui/scripts/ControlsMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/ControlsMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/ControlsMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -1,8 +1,39 @@
-- ControlsMenu.lua
local P = createMenuSheet("ControlsMenu")
+P.buttonList = {}
P.loadAlong = { "MouseControlsMenu", "KeyBindMenu" }
+function P.onLoad()
+ P.multiplayerMode = "startClient"
+
+ --buttons are arranged in a 3x1 matrix:
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/MouseControlsButton"),
+ ["function"] = P.ControlsMouseControlsButton_clicked
+ }
+ P.buttonList[1] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/KeybindingsButton"),
+ ["function"] = P.ControlsKeyboardControlsButton_clicked
+ }
+ P.buttonList[2] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/ControlsBackButton"),
+ ["function"] = P.ControlsBackButton_clicked
+ }
+ P.buttonList[3] = item
+
+end
+
+function P.onShow()
+ --indices to iterate through buttonlist
+ P.oldindex = -2
+ P.index = -1
+end
+
function P.ControlsMouseControlsButton_clicked(e)
showMenuSheet("MouseControlsMenu", true)
end
@@ -15,5 +46,9 @@
hideMenuSheet(P.name)
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 3, 1)
+end
+
return P
Modified: code/trunk/data/gui/scripts/CreditsMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/CreditsMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/CreditsMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -2,9 +2,29 @@
local P = createMenuSheet("CreditsMenu")
+P.buttonList = {}
+
+function P.onLoad()
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/CreditsBackButton"),
+ ["function"] = P.CreditsBackButton_clicked
+ }
+ P.buttonList[1] = item
+end
+
+function P.onShow()
+ --indices to iterate through buttonlist
+ P.oldindex = -2
+ P.index = -1
+end
+
function P.CreditsBackButton_clicked(e)
hideMenuSheet(P.name)
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 1, 1)
+end
+
return P
Modified: code/trunk/data/gui/scripts/GUISheet.lua
===================================================================
--- code/trunk/data/gui/scripts/GUISheet.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/GUISheet.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -63,4 +63,7 @@
return self
end
+function P:onKeyPressed(e)
+end
+
return P
Modified: code/trunk/data/gui/scripts/GUITools.lua
===================================================================
--- code/trunk/data/gui/scripts/GUITools.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/GUITools.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -53,3 +53,282 @@
local height = lines * window:getFont():getLineSpacing() + frameHeight
return height
end
+
+--function to iterate through a menu sheet by using arrowkeys
+
+-- at arguments:
+-- list: 2-dimensional table, arguments are items that contain a button and its function
+-- !!note: each button can only be in the list once!!
+-- code: code of any key on the keyboard
+-- P: menusheet
+-- n: number of rows of the buttontable
+-- m: number of colums of the buttontable
+
+function buttonIteratorHelper(list, code, P, n, m)
+
+ --after a key (down,up,left,right) is pressed the index of the current button has to be updated
+
+ --key down
+ if code == "208" then
+ if P.index < 0 then -- initial status
+ P.index = 0
+ P.oldindex = -1
+ else
+ P.oldindex = P.index
+ P.index = (P.index + m) % (m*n) --modulo operation works as a "wrap around" in the button menu
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = (P.index + m) % (m*n)
+ end
+ end
+
+ --key up
+ elseif code == "200" then
+ if P.index < 0 then
+ P.index = 0
+ P.oldindex = -1
+ elseif(P.index == 0) then
+ P.oldindex = P.index
+ P.index = m*n-m
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = (P.index-m)%(m*n)
+ end
+ else
+ P.oldindex = P.index
+ P.index = (P.index -m) % (m*n)
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = (P.index-m)%(m*n)
+ end
+ end
+
+ --key right
+ elseif code == "205" then
+ if P.index < 0 then
+ P.index = 0
+ P.oldindex = -1
+ elseif (P.index+1) % m == 0 then -- we are at the right-end of a row
+ P.oldindex = P.index
+ P.index = P.index + 1 -m
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = P.index + 1
+ end
+ else
+ P.oldindex = P.index
+ P.index = P.index + 1
+
+ while list[P.index+1] == nil do
+ if (P.index+1) % m == 0 then -- we are at the right-end of a row
+ P.oldindex = P.index
+ P.index = P.index + 1-m
+
+ else
+ P.oldindex = P.index
+ P.index = P.index + 1
+ end
+ end
+ end
+
+ --key left
+ elseif code == "203" then
+ if P.index < 0 then
+ P.index = 0
+ P.oldindex = -1
+ elseif P.index % m == 0 then -- we are at the left-end of a row
+ P.oldindex = P.index
+ P.index = P.index +m-1
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = P.index -1
+ end
+ else
+ P.oldindex = P.index
+ P.index = P.index -1
+
+ while list[P.index+1] == nil do
+ if P.index % m == 0 then -- we are at the left-end of a row
+ P.oldindex = P.index
+ P.index = P.index -1 + m
+ else
+ P.oldindex = P.index
+ P.index = P.index -1
+ end
+ end
+ end
+ end
+
+ --to update the new current button
+ if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then
+
+ local system = CEGUI.System:getSingleton()
+ local window = winMgr:getWindow("orxonox/MainMenuBackground")
+
+ local item = list[P.index+1]
+ local child = item["button"]
+
+ --teste ob der Button nicht schon gehighlightet ist
+ if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then
+ --nop
+ else
+ child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")
+ child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")
+ child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")
+ if P.oldindex >= 0 then
+ if list[P.oldindex+1] ~= nil then
+ local item = list[P.oldindex+1]
+ local oldChild = item["button"]
+ oldChild:setProperty("NormalImageRightEdge", string.sub(oldChild:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
+ oldChild:setProperty("NormalImageLeftEdge", string.sub(oldChild:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
+ oldChild:setProperty("NormalImageBackground", string.sub(oldChild:getProperty("NormalImageBackground"),1,-10) .. "Normal")
+ end
+ end
+ end
+
+ --for every highlighted button check if index is on its position. If not, set imageproperty on "normal"
+ local i = 1
+ while i < (n*m) do
+ if i == P.index +1 then
+ i = i+1
+ else
+ if list[i] ~= nil then
+ local item = list[i]
+ local child = item["button"]
+ if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then
+ child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
+ child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
+ child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
+ end
+ end
+ end
+ i=i+1
+ end
+ end
+
+ --enter
+ if code == "28" then
+ local item = list[P.index+1]
+ local child = item["button"]
+ child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
+ child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
+ child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
+
+ local foo = item["function"]
+ foo()
+ end
+
+end
+
+--write index and oldindex on the console
+--works like buttonIteratorHelper
+function indexTester(list,code,P,n,m)
+ --key down
+ if code == "208" then
+ if P.index < 0 then -- initial status
+ P.index = 0
+ P.oldindex = -1
+ else
+ P.oldindex = P.index
+ P.index = (P.index + m) % (m*n)
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = (P.index + m) % (m*n)
+ end
+ end
+
+ --key up
+ elseif code == "200" then
+ if P.index < 0 then
+ P.index = 0
+ P.oldindex = -1
+ elseif(P.index == 0) then
+ P.oldindex = P.index
+ P.index = m*n-m
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = (P.index-m)%(m*n)
+ end
+ else
+ P.oldindex = P.index
+ P.index = (P.index -m) % (m*n)
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = P.index -m
+ end
+ end
+
+ --key right
+ elseif code == "205" then
+ if P.index < 0 then
+ P.index = 0
+ P.oldindex = -1
+ elseif (P.index+1) % m == 0 then -- we are at the right-end of a row
+ P.oldindex = P.index
+ P.index = P.index + 1 -m
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = P.index + 1
+ end
+ else
+ P.oldindex = P.index
+ P.index = P.index + 1
+
+ while list[P.index+1] == nil do
+ if (P.index+1) % m == 0 then -- we are at the right-end of a row
+ P.oldindex = P.index
+ P.index = P.index + 1-m
+
+ else
+ P.oldindex = P.index
+ P.index = P.index + 1
+ end
+ end
+ end
+
+ --key left
+ elseif code == "203" then
+ if P.index < 0 then
+ P.index = 0
+ P.oldindex = -1
+ elseif P.index % m == 0 then -- we are at the left-end of a row
+ P.oldindex = P.index
+ P.index = P.index +m-1
+
+ while list[P.index+1] == nil do
+ P.oldindex = P.index
+ P.index = P.index -1
+ end
+ else
+ P.oldindex = P.index
+ P.index = P.index -1
+
+ while list[P.index+1] == nil do
+ if P.index % m == 0 then -- we are at the left-end of a row
+ P.oldindex = P.index
+ P.index = P.index -1 + m
+ else
+ P.oldindex = P.index
+ P.index = P.index -1
+ end
+ end
+ end
+ end
+
+ cout(0, P.oldindex)
+ cout(0, P.index)
+
+end
+
+
+
+
Modified: code/trunk/data/gui/scripts/GraphicsMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/GraphicsMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/GraphicsMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -2,6 +2,14 @@
local P = createMenuSheet("GraphicsMenu")
+P.buttonList = {}
+
+function P.onShow()
+ --indices to iterate through buttonlist (trivial in this menu sheet)
+ P.oldindex = -2
+ P.index = -1
+end
+
function P.onLoad()
block = true
file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
@@ -82,6 +90,12 @@
end
scrollbar_active = false
block = false
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"),
+ ["function"] = P.GraphicsBackButton_clicked
+ }
+ P.buttonList[1] = item
end
function P.GraphicsResolutionListbox_changed(e)
@@ -194,5 +208,9 @@
hideMenuSheet(P.name)
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 1, 1)
+end
+
return P
Copied: code/trunk/data/gui/scripts/HostMenu.lua (from rev 7687, code/branches/menu/data/gui/scripts/HostMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/HostMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/HostMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -0,0 +1,126 @@
+-- HostMenu.lua
+
+local P = createMenuSheet("HostMenu")
+
+P.multiplayerMode = "startServer"
+
+P.buttonList = {}
+P.levelList = {}
+P.itemList = {}
+P.showAll = false
+
+function P.onLoad()
+ P.multiplayerMode = "startServer"
+ local window = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
+ local button = tolua.cast(window,"CEGUI::Checkbox")
+ button:setSelected(false)
+ P.createLevelList()
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/HostMenuStartButton"),
+ ["function"] = P.HostMenuStartButton_clicked
+ }
+ P.buttonList[1] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/HostMenuBackButton"),
+ ["function"] = P.HostMenuBackButton_clicked
+ }
+ P.buttonList[2] = item
+end
+
+function P.onShow()
+ if P.multiplayerMode == "startServer" then
+ local window = winMgr:getWindow("orxonox/HostMenuHostButton")
+ local button = tolua.cast(window,"CEGUI::RadioButton")
+ button:setSelected(true)
+ P.createLevelList()
+ end
+
+ if P.multiplayerMode == "startDedicated" then
+ local window = winMgr:getWindow("orxonox/HostMenuDedicatedButton")
+ local button = tolua.cast(window,"CEGUI::RadioButton")
+ button:setSelected(true)
+ P.createLevelList()
+ end
+
+ P.oldindex = -2
+ P.index = -1
+
+end
+
+function P.createLevelList()
+ P.levelList = {}
+ P.itemList = {}
+ local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/HostMenuListbox"))
+ listbox:resetList()
+ orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
+ local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
+ local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
+ local index = 0
+ local level = nil
+ while index < size do
+ level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
+ if level ~= nil then
+ if P.showAll or not level:hasTag("test") then
+ table.insert(P.levelList, level)
+ end
+ end
+ index = index + 1
+ end
+ --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
+ --table.sort(levelList)
+ for k,v in pairs(P.levelList) do
+ local item = CEGUI.createListboxTextItem(v:getName())
+ item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
+ listbox:addItem(item)
+ if v:getXMLFilename() == preselect then
+ listbox:setItemSelectState(item, true)
+ end
+ P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
+ orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
+ end
+end
+
+function P.HostMenuBuildServerButton_clicked(e)
+ P.multiplayerMode = "startServer"
+ P.createLevelList()
+end
+
+function P.HostMenuDedicatedButton_clicked(e)
+ P.multiplayerMode = "startDedicated"
+ P.createLevelList()
+end
+
+function P.HostMenuBackButton_clicked(e)
+ hideMenuSheet(P.name)
+end
+
+function P.HostMenuStartButton_clicked(e)
+ local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/HostMenuListbox"))
+ local choice = listbox:getFirstSelectedItem()
+ if choice ~= nil then
+ local index = listbox:getItemIndex(choice)
+ local level = P.levelList[index+1]
+ if level ~= nil then
+ orxonox.LevelManager:getInstance():setDefaultLevel(level:getXMLFilename())
+ orxonox.execute(P.multiplayerMode)
+ hideAllMenuSheets()
+ end
+ end
+end
+
+function P.MultiplayerShowAll_clicked(e)
+ local checkbox = tolua.cast(winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox"), "CEGUI::Checkbox")
+ local show = checkbox:isSelected()
+ if show ~= P.showAll then
+ P.showAll = show
+ P.createLevelList()
+ end
+end
+
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 1, 2)
+end
+
+return P
Modified: code/trunk/data/gui/scripts/InGameMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/InGameMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/InGameMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -11,7 +11,6 @@
function P.button_mainmenu_clicked(e)
orxonox.Game:getInstance():popState()
orxonox.Game:getInstance():popState()
- orxonox.Game:getInstance():requestState("mainmenu")
hideMenuSheet("InGameMenu")
end
Modified: code/trunk/data/gui/scripts/MainMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/MainMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/MainMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -3,6 +3,53 @@
local P = createMenuSheet("MainMenu")
P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
+P.buttonList = {}
+
+function P.onLoad()
+ --buttons are arranged in a 6x1 Matrix (list)
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
+ ["function"] = P.QuickGameTestButton_clicked
+ }
+ table.insert(P.buttonList,item)
+
+ item = {
+ ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"),
+ ["function"] = P.SingleplayerButton_clicked
+ }
+ table.insert(P.buttonList,item)
+
+ item = {
+ ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"),
+ ["function"] = P.MultiplayerButton_clicked
+ }
+ table.insert(P.buttonList,item)
+
+ item = {
+ ["button"] = winMgr:getWindow("orxonox/SettingsButton"),
+ ["function"] = P.SettingsButton_clicked
+ }
+ table.insert(P.buttonList,item)
+
+ item = {
+ ["button"] = winMgr:getWindow("orxonox/CreditsButton"),
+ ["function"] = P.CreditsButton_clicked
+ }
+ table.insert(P.buttonList,item)
+
+ item = {
+ ["button"] = winMgr:getWindow("orxonox/ExitButton"),
+ ["function"] = P.ExitButton_clicked
+ }
+ table.insert(P.buttonList,item)
+end
+
+function P.onShow()
+ --indices to iterate through buttonlist
+ P.oldindex = -2
+ P.index = -1
+end
+
-- events for MainMenu
function P.QuickGameTestButton_clicked(e)
hideAllMenuSheets()
@@ -29,5 +76,9 @@
orxonox.execute("exit")
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 6, 1)
+end
+
return P
Modified: code/trunk/data/gui/scripts/MenuSheet.lua
===================================================================
--- code/trunk/data/gui/scripts/MenuSheet.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/MenuSheet.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -15,7 +15,7 @@
local newSheet = GUISheet.new(_name)
newSheet.bHidePrevious = handleDefArg(_bHidePrevious, true)
newSheet.tShowCursor = handleDefArg(_tShowCusor, TriBool.True)
- newSheet.tUseKeyboard = handleDefArg(_tUseKeyboard, TriBool.Dontcare)
+ newSheet.tUseKeyboard = handleDefArg(_tUseKeyboard, TriBool.True)
newSheet.bBlockJoyStick = handleDefArg(_bBlockJoyStick, false)
setmetatable(newSheet, P)
Modified: code/trunk/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/MultiplayerMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/MultiplayerMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -2,89 +2,55 @@
local P = createMenuSheet("MultiplayerMenu")
-P.levelList = {}
-P.itemList = {}
-P.showAll = false
+P.buttonList = {}
function P.onLoad()
- P.multiplayerMode = "startClient"
-end
+ P.multiplayerMode = "startClient"
-function P.onShow()
- if P.multiplayerMode == "startClient" then
- local window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
- local button = tolua.cast(window,"CEGUI::RadioButton")
- button:setSelected(true)
- local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
- checkbox:setProperty("Disabled", "True")
- P.showServerList()
- end
- if P.multiplayerMode == "startServer" then
- local window = winMgr:getWindow("orxonox/MultiplayerHostButton")
- local button = tolua.cast(window,"CEGUI::RadioButton")
- button:setSelected(true)
- local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
- checkbox:setProperty("Disabled", "False")
- P.showLevelList()
- end
- if P.multiplayerMode == "startDedicated" then
- local window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
- local button = tolua.cast(window,"CEGUI::RadioButton")
- button:setSelected(true)
- local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
- checkbox:setProperty("Disabled", "True")
- P.showLevelList()
- end
+ --button are arranged in a 2x2 matrix, the left lower item is nil
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton"),
+ ["function"] = P.MultiplayerJoinButton2_clicked
+ }
+ P.buttonList[1] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton"),
+ ["function"] = P.MultiplayerHostButton2_clicked
+ }
+ P.buttonList[2] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/MultiplayerBackButton"),
+ ["function"] = P.MultiplayerBackButton_clicked
+ }
+ P.buttonList[4] = item
+
end
-function P.MultiplayerJoinButton_clicked(e)
- P.multiplayerMode = "startClient"
- local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
- checkbox:setProperty("Disabled", "True")
+function P.onShow()
P.showServerList()
+
+ --indices to iterate through buttonlist
+ P.oldindex = -2
+ P.index = -1
end
function P.MultiplayerHostButton_clicked(e)
- P.multiplayerMode = "startServer"
- local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
- checkbox:setProperty("Disabled", "False")
- P.showLevelList()
+ showMenuSheet("HostMenu", true)
end
-function P.MultiplayerDedicatedButton_clicked(e)
- P.multiplayerMode = "startDedicated"
- local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
- checkbox:setProperty("Disabled", "True")
- P.showLevelList()
-end
-function P.MultiplayerShowAll_clicked(e)
- local checkbox = tolua.cast(winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox"), "CEGUI::Checkbox")
- local show = checkbox:isSelected()
- if show ~= P.showAll then
- P.showAll = show
- P.createLevelList()
- end
-end
-
-function P.MultiplayerStartButton_clicked(e)
+function P.MultiplayerJoinButton_clicked(e)
local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem()
- if P.multiplayerMode == "startClient" then
- if choice then
- local client = orxonox.Client:getInstance()
- local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID()
- client:setDestination( P.serverList[index][2], 55556 )
- else
- return
- end
+ if choice then
+ local client = orxonox.Client:getInstance()
+ local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID()
+ client:setDestination( P.serverList[index][2], 55556 )
else
- if choice then
- orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
- else
- return
- end
+ return
end
- orxonox.execute(P.multiplayerMode)
+ orxonox.execute("startClient")
hideAllMenuSheets()
end
@@ -92,43 +58,6 @@
hideMenuSheet(P.name)
end
-function P.showLevelList()
- P.createLevelList()
-end
-
-function P.createLevelList()
- P.levelList = {}
- P.itemList = {}
- local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/MultiplayerListbox"))
- listbox:resetList()
- orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
- local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
- local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
- local index = 0
- local level = nil
- while index < size do
- level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
- if level ~= nil then
- if P.showAll or not level:hasTag("test") then
- table.insert(P.levelList, level)
- end
- end
- index = index + 1
- end
- --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
- --table.sort(levelList)
- for k,v in pairs(P.levelList) do
- local item = CEGUI.createListboxTextItem(v:getName())
- item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
- listbox:addItem(item)
- if v:getXMLFilename() == preselect then
- listbox:setItemSelectState(item, true)
- end
- P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
- orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
- end
-end
-
function P.showServerList()
local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
CEGUI.toListbox(listbox):resetList()
@@ -160,5 +89,9 @@
end
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 2, 2)
+end
+
return P
Modified: code/trunk/data/gui/scripts/SettingsMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/SettingsMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/SettingsMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -3,6 +3,50 @@
local P = createMenuSheet("SettingsMenu")
P.loadAlong = { "ControlsMenu", "AudioMenu", "GraphicsMenu" }
+P.buttonList = {}
+
+function P.onLoad()
+ --"Gameplay" and "Multiplayer Options" are not integrated in the list
+ --buttons are arranged in a 4x2 matrix. The lower-right element is not in the matrix!
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"),
+ ["function"] = P.SettingsGraphicsButton_clicked
+ }
+ P.buttonList[2] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/SettingsMenu/AudioButton"),
+ ["function"] = P.SettingsAudioButton_clicked
+ }
+ P.buttonList[4] = item
+
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"),
+ ["function"] = P.SettingsControlsButton_clicked
+ }
+ P.buttonList[5] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"),
+ ["function"] = P.SettingsMiscellaneousButton_clicked
+ }
+ P.buttonList[6] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"),
+ ["function"] = P.SettingsBackButton_clicked
+ }
+ P.buttonList[7] = item
+
+end
+
+function P.onShow()
+ --indices to iterate through buttonlist
+ P.oldindex = 3
+ P.index = 2
+end
+
function P.SettingsGameplayButton_clicked(e)
showMenuSheet("GameplayMenu", true)
end
@@ -31,5 +75,9 @@
hideMenuSheet(P.name)
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 4, 2)
+end
+
return P
Modified: code/trunk/data/gui/scripts/SheetManager.lua
===================================================================
--- code/trunk/data/gui/scripts/SheetManager.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/SheetManager.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -4,6 +4,9 @@
local loadedSheets = {}
local activeMenuSheets = {size = 0, topSheetTuple = nil}
local menuSheetsRoot = guiMgr:getMenuRootWindow()
+local bInGameConsoleClosed = false
+local mainMenuLoaded = false
+orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
-----------------------
--- Local functions ---
@@ -68,7 +71,7 @@
end
-- Count the number of sheets that don't need input till the first that does.
- local counter = noInputSheetCounter()
+ local counter = noInputSheetIndex()
-- Pause game control if this is the first menu to be displayed
-- HUGE HACK?
if bNoInput == false and counter == 0 then
@@ -99,6 +102,11 @@
-- Add sheet to the root window
menuSheetsRoot:addChildWindow(menuSheet.window)
+ -- If sheet is the MainMenu
+ if name == "MainMenu" then
+ mainMenuLoaded = true
+ end
+
-- Handle input distribution
if bNoInput == false then
inputMgr:enterState(menuSheet.inputState)
@@ -117,8 +125,9 @@
activeMenuSheets[i].sheet:hide()
end
end
-
+
menuSheet:show()
+ menuSheetsRoot:activate()
return menuSheet
end
@@ -160,6 +169,11 @@
activeMenuSheets.size = activeMenuSheets.size - 1
activeMenuSheets.topSheetTuple = activeMenuSheets[activeMenuSheets.size]
+ -- If sheet is the MainMenu
+ if name == "MainMenu" then
+ mainMenuLoaded = false
+ end
+
-- Leave the input state
if not sheetTuple.bNoInput then
inputMgr:leaveState(sheetTuple.sheet.inputState)
@@ -178,7 +192,7 @@
end
-- Count the number of sheets that don't need input till the first that does.
- local counter = noInputSheetCounter()
+ local counter = noInputSheetIndex()
-- Resume control if the last (non-noInput) menu is hidden
if counter == 0 then
orxonox.HumanController:resumeControl()
@@ -198,11 +212,17 @@
function keyESC()
-- HUGE, very HUGE hacks!
+ -- If the InGameConsole is active, ignore the ESC command.
+ if bInGameConsoleClosed == true then
+ bInGameConsoleClosed = false
+ return
+ end
+
-- Count the number of sheets that don't need input till the first that does.
- local counter = noInputSheetCounter()
+ local counter = noInputSheetIndex()
-- If the first sheet that needs input is the MainMenu.
- if counter == 1 and activeMenuSheets[1].sheet.name == "MainMenu" then
+ if noInputSheetCounter() == 1 and activeMenuSheets[counter].sheet.name == "MainMenu" then
orxonox.execute("exit")
-- If there is at least one sheet that needs input.
elseif counter > 0 then
@@ -212,19 +232,49 @@
end
end
+function keyPressed(e)
+ local we = tolua.cast(e, "CEGUI::KeyEventArgs")
+ local sheet = activeMenuSheets[activeMenuSheets.size]
+ code = tostring(we.scancode)
+ -- Some preprocessing
+ if not mainMenuLoaded and not sheet.bNoInput then
+ if code == "1" then
+ keyESC()
+ elseif code == "0"then
+ orxonox.CommandExecutor:execute("openConsole")
+ end
+ end
+ sheet.sheet:onKeyPressed()
+end
+
function setBackgroundImage(imageSet, imageName)
guiMgr:setBackgroundImage(imageSet, imageName)
end
+function noInputSheetIndex()
+ -- Count the number of sheets that don't need input till the first that does.
+ local index = activeMenuSheets.size
+ while index > 0 and activeMenuSheets[index].bNoInput do
+ index = index - 1
+ end
+ return index
+end
+
function noInputSheetCounter()
- -- Count the number of sheets that don't need input till the first that does.
+ -- Count the number of sheets that do need input.
local counter = activeMenuSheets.size
- while counter > 0 and activeMenuSheets[counter].bNoInput do
- counter = counter - 1
+ for i = 1,activeMenuSheets.size do
+ if activeMenuSheets[i].bNoInput then
+ counter = counter - 1
+ end
end
return counter
end
+function inGameConsoleClosed()
+ bInGameConsoleClosed = not bInGameConsoleClosed;
+end
+
----------------------
--- Initialisation ---
----------------------
Modified: code/trunk/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/SingleplayerMenu.lua 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/data/gui/scripts/SingleplayerMenu.lua 2010-12-01 14:00:19 UTC (rev 7689)
@@ -2,6 +2,7 @@
local P = createMenuSheet("SingleplayerMenu")
+P.buttonList = {}
P.levelList = {}
P.itemList = {}
P.showAll = false
@@ -11,6 +12,19 @@
local button = tolua.cast(window,"CEGUI::Checkbox")
button:setSelected(false)
P.createLevelList()
+
+ --buttons are arranged in a 1x2 matrix
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
+ ["function"] = P.SingleplayerStartButton_clicked
+ }
+ P.buttonList[1] = item
+
+ local item = {
+ ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
+ ["function"] = P.SingleplayerBackButton_clicked
+ }
+ P.buttonList[2] = item
end
function P.createLevelList()
@@ -46,6 +60,12 @@
end
end
+function P.onShow()
+ --indices to iterate through buttonlist
+ P.oldindex = -2
+ P.index = -1
+end
+
function P.SingleplayerStartButton_clicked(e)
local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))
local choice = listbox:getFirstSelectedItem()
@@ -73,5 +93,9 @@
hideMenuSheet(P.name)
end
+function P.onKeyPressed()
+ buttonIteratorHelper(P.buttonList, code, P, 1, 2)
+end
+
return P
Modified: code/trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.cc 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.cc 2010-12-01 14:00:19 UTC (rev 7689)
@@ -66,7 +66,7 @@
{
RegisterRootObject(GSMainMenu);
- InputManager::getInstance().createInputState("MainMenuHackery")->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
+ InputManager::getInstance().createInputState("MainMenuHackery", true, true)->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
// create an empty Scene
this->scene_ = new Scene(NULL);
Modified: code/trunk/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.cc 2010-12-01 13:11:44 UTC (rev 7688)
+++ code/trunk/src/orxonox/overlays/InGameConsole.cc 2010-12-01 14:00:19 UTC (rev 7689)
@@ -48,9 +48,11 @@
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/command/ConsoleCommand.h"
+#include "core/GUIManager.h"
#include "core/input/InputManager.h"
#include "core/input/InputState.h"
#include "core/input/InputBuffer.h"
+#include "core/LuaState.h"
namespace orxonox
{
@@ -118,7 +120,7 @@
for (int i = 0; i < LINES; i++)
{
if (this->consoleOverlayTextAreas_[i])
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
this->consoleOverlayTextAreas_[i] = 0;
}
@@ -494,7 +496,7 @@
output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
}
else
- this->inputWindowStart_ = 0;
+ this->inputWindowStart_ = 0;
this->displayedText_ = output;
this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
}
@@ -531,6 +533,7 @@
if (this->bActive_)
{
this->bActive_ = false;
+ GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()"); // Notify the SheetManager in lua, that the console has been closed.
InputManager::getInstance().leaveState("console");
this->shell_->unregisterListener(this);
@@ -607,6 +610,8 @@
*/
/*static*/ void InGameConsole::closeConsole()
{
+ GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()"); // Notify the SheetManager in lua, that the console has been closed, but not by ESC.
InGameConsole::getInstance().deactivate();
}
+
}
More information about the Orxonox-commit
mailing list