[Orxonox-commit 819] r2208 - media/gui/scripts
rgrieder at orxonox.net
rgrieder at orxonox.net
Thu Jul 23 20:05:38 CEST 2009
Author: rgrieder
Date: 2009-07-23 20:05:37 +0200 (Thu, 23 Jul 2009)
New Revision: 2208
Added:
media/gui/scripts/mainmenu_4.lua
Log:
Copied a gui script file for the (hopefully) last time. This implements the changes from r3339.
Copied: media/gui/scripts/mainmenu_4.lua (from rev 2203, media/gui/scripts/mainmenu_3.lua)
===================================================================
--- media/gui/scripts/mainmenu_4.lua (rev 0)
+++ media/gui/scripts/mainmenu_4.lua 2009-07-23 18:05:37 UTC (rev 2208)
@@ -0,0 +1,88 @@
+-- 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():getDefaultLevel()
+ orxonox.LevelManager:getInstance():compileAvailableLevelList()
+ local levelList = {}
+ local index = 0
+ local level = ""
+ while true do
+ level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
+ if level == "" then
+ break
+ end
+ table.insert(levelList, level)
+ index = index + 1
+ end
+ 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():setDefaultLevel(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():setDefaultLevel(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():setDefaultLevel(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():setDefaultLevel(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