[Orxonox-commit 714] r2202 - media/gui/scripts
rgrieder at orxonox.net
rgrieder at orxonox.net
Mon Jun 29 13:33:36 CEST 2009
Author: rgrieder
Date: 2009-06-29 13:33:36 +0200 (Mon, 29 Jun 2009)
New Revision: 2202
Added:
media/gui/scripts/mainmenu_3.lua
Log:
Accompanying changes to the source repo revision 3245.
Copied: media/gui/scripts/mainmenu_3.lua (from rev 2201, media/gui/scripts/mainmenu_2.lua)
===================================================================
--- media/gui/scripts/mainmenu_3.lua (rev 0)
+++ media/gui/scripts/mainmenu_3.lua 2009-06-29 11:33:36 UTC (rev 2202)
@@ -0,0 +1,77 @@
+-- mainmenu_2.lua
+gui = require("gui")
+local P = gui:new() --inherit everything from the gui package
+
+mainmenu_2 = P
+
+P.filename = "mainmenu_2"
+P.layoutString = "MainMenu_2.layout"
+
+function P:init()
+ listbox = winMgr:getWindow("orxonox/LevelListbox")
+ preselect = orxonox.LevelManager:getInstance():getStartLevel()
+ orxonox.GUIManager:getInstance():getLevelList() --levellist variable ist set now
+ table.sort(levellist)
+ for k,v in pairs(levellist) do
+ item = CEGUI.createListboxTextItem(v)
+ item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ CEGUI.toListbox(listbox):addItem(item)
+ if v .. ".oxw" == preselect then
+ listbox:setItemSelectState(item, true)
+ end
+ end
+end
+
+
+-- events for mainmenu
+function P.button_quit_clicked(e)
+ hideGUI()
+ orxonox.CommandExecutor:execute("exit")
+end
+
+function P.button_standalone_clicked(e)
+ choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
+ if choice then
+ orxonox.LevelManager:getInstance():setStartLevel(choice:getText() .. ".oxw")
+ orxonox.CommandExecutor:execute("startGame")
+ toggleGUI()
+ end
+end
+
+function P.button_server_clicked(e)
+ choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
+ if choice then
+ orxonox.LevelManager:getInstance():setStartLevel(choice:getText() .. ".oxw")
+ orxonox.CommandExecutor:execute("startServer")
+ toggleGUI()
+ end
+end
+
+function P.button_dedicated_clicked(e)
+ choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
+ if choice then
+ orxonox.LevelManager:getInstance():setStartLevel(choice:getText() .. ".oxw")
+ orxonox.CommandExecutor:execute("startDedicated")
+ toggleGUI()
+ end
+end
+
+function P.button_client_clicked(e)
+ choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
+ if choice then
+ orxonox.LevelManager:getInstance():setStartLevel(choice:getText() .. ".oxw")
+ orxonox.CommandExecutor:execute("startClient")
+ toggleGUI()
+ end
+end
+
+function P.listbox_level_selectionchanged(e)
+ if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then
+ winMgr:getWindow("orxonox/StandaloneButton"):enable()
+ else
+ winMgr:getWindow("orxonox/StandaloneButton"):disable()
+ end
+end
+
+return mainmenu_2
+
More information about the Orxonox-commit
mailing list