[Orxonox-commit 161] r2053 - media/gui/scripts
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Mar 25 15:17:07 CET 2009
Author: rgrieder
Date: 2009-03-25 14:17:07 +0000 (Wed, 25 Mar 2009)
New Revision: 2053
Added:
media/gui/scripts/loadGUI_2.lua
Modified:
media/gui/scripts/loadGUI.lua
Log:
Fixed all branches and the trunk (except for gui of course).
PLEASE NEVER MAKE ANY BREAKING CHANGES IN THE MEDIA REPOSITORY. Always only modify slightly or extend.
There is a thread in the forum that addresses this problem:
https://forum.orxonox.net/viewtopic.php?f=8&t=337
Modified: media/gui/scripts/loadGUI.lua
===================================================================
--- media/gui/scripts/loadGUI.lua 2009-03-25 10:13:58 UTC (rev 2052)
+++ media/gui/scripts/loadGUI.lua 2009-03-25 14:17:07 UTC (rev 2053)
@@ -1,88 +1,106 @@
local schemeMgr = CEGUI.SchemeManager:getSingleton()
local winMgr = CEGUI.WindowManager:getSingleton()
local logger = CEGUI.Logger:getSingleton()
-local system = CEGUI.System:getSingleton()
-local cursor = CEGUI.MouseCursor:getSingleton()
+local system = CEGUI.System:getSingleton()
-schemeMgr:loadScheme("TaharezLookSkin.scheme")
--- load scheme with our own images
-schemeMgr:loadScheme("OrxonoxGUIScheme.scheme")
-
+schemeMgr:loadScheme("TaharezLookSkin.scheme")
system:setDefaultMouseCursor("TaharezLook", "MouseArrow")
system:setDefaultFont("BlueHighway-12")
-
-local current = nil
-local loadedGUIs = {}
-local showing
--- we cannot directly call functions with parameters and so need this as a global variable, which sucks of course
-filename = ""
-datapath = "" -- points to media-folder (set after loading the script)
-
--- function to add a reference to list of reference of loaded GUIs
-loadedGUIs.addGUI = function (gui)
- loadedGUIs[#loadedGUIs+1] = gui
-end
-
--- function which returns a GUI by name
-loadedGUIs.getGUIbyName = function (str)
- for i = 1, #loadedGUIs, 1 do
- if str == loadedGUIs[i].filename then
- return loadedGUIs[i]
- end
- end
- return nil
+
+
+local rootSheet = winMgr:createWindow("DefaultGUISheet", "orxonox/Sheet")
+
+local leftOffset = 0.11
+local topOffset = 0.3
+local distance = 0.076
+local index = 0
+
+local standalone = winMgr:createWindow("TaharezLook/Button", "orxonox/StandaloneButton")
+standalone:setText("Standalone")
+standalone:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
+standalone:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
+standalone:subscribeEvent("Clicked","button_standalone_clicked")
+index = index + 1
+
+local dedicated = winMgr:createWindow("TaharezLook/Button", "orxonox/DedicatedButton")
+dedicated:setText("Dedicated")
+dedicated:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
+dedicated:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
+dedicated:subscribeEvent("Clicked","button_dedicated_clicked")
+index = index + 1
+
+local server = winMgr:createWindow("TaharezLook/Button", "orxonox/ServerButton")
+server:setText("Server")
+server:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
+server:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
+server:subscribeEvent("Clicked","button_server_clicked")
+index = index + 1
+
+local client = winMgr:createWindow("TaharezLook/Button", "orxonox/ClientButton")
+client:setText("Client")
+client:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
+client:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
+client:subscribeEvent("Clicked","button_client_clicked")
+index = index + 1
+
+local quit = winMgr:createWindow("TaharezLook/Button", "orxonox/QuitButton")
+quit:setText("Quit")
+quit:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
+quit:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
+quit:subscribeEvent("Clicked","button_quit_clicked")
+index = index + 1
+
+local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "main_menu_1.jpg")
+local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background")
+background:setProperty("FrameEnabled", "set: true")
+background:setProperty("BackgroundEnabled", "set: false")
+background:setProperty("Image", "set: GUI/Background image:full_image")
+
+rootSheet:addChildWindow(quit)
+rootSheet:addChildWindow(standalone)
+rootSheet:addChildWindow(server)
+rootSheet:addChildWindow(dedicated)
+rootSheet:addChildWindow(client)
+background:addChildWindow(rootSheet)
+
+
+function button_quit_clicked(e)
+ hideGUI()
+ orxonox.CommandExecutor:execute("exit")
end
-
--- loads the GUI with the specified filename
--- be sure to set the global variable "filename" before calling this function
-function loadGUI()
- -- check if it already exists
- newlyLoaded = loadedGUIs:getGUIbyName(filename)
- if newlyLoaded == nil then
- dofile(datapath .. "gui/scripts/" .. filename)
- newlyLoaded = winMgr:loadWindowLayout(layoutPath)
- newlyLoaded.filename = filename
- loadedGUIs:addGUI(newlyLoaded)
- -- if there has no GUI been loaded yet, set new GUI as current
- if #loadedGUIs == 1 then
- current = loadedGUIs[1]
- showing = false
- end
- -- hide new GUI as we do not want to show it accidentially
- newlyLoaded:hide()
- end
- return newlyLoaded
-end
-
--- shows the specified and loads it if not loaded already
--- be sure to set the global variable "filename" before calling this function
-function showGUI()
- if current == nil or current.filename ~= filename then
- current = loadedGUIs.getGUIbyName(filename)
- if current == nil then
- current = loadGUI(filename)
- end
- system:setGUISheet(current)
- end
- current:show()
- cursor:show()
- showing = true
-end
-
-function toggleGUI()
- if showing == true then
- current:hide()
- cursor:hide()
- showing = false
- else
- current:show()
- cursor:show()
- showing = true
- end
- return showing
+
+function button_standalone_clicked(e)
+ orxonox.CommandExecutor:execute("selectGameState standalone")
+ hideGUI()
end
-function hideGUI()
- current:hide()
- showing = false
+function button_server_clicked(e)
+ orxonox.CommandExecutor:execute("selectGameState server")
+ hideGUI()
end
+
+function button_dedicated_clicked(e)
+ orxonox.CommandExecutor:execute("selectGameState dedicated")
+ hideGUI()
+end
+
+function button_client_clicked(e)
+ orxonox.CommandExecutor:execute("selectGameState client")
+ hideGUI()
+end
+
+showBackground = false
+
+function showMainMenu()
+ if showBackground == true then
+ system:setGUISheet(background)
+ else
+ system:setGUISheet(rootSheet)
+ end
+ return 0;
+end
+
+function hideGUI()
+ system:setGUISheet(nil)
+ orxonox.GUIManager:getInstance():hideGUI()
+end
Copied: media/gui/scripts/loadGUI_2.lua (from rev 2052, media/gui/scripts/loadGUI.lua)
===================================================================
--- media/gui/scripts/loadGUI_2.lua (rev 0)
+++ media/gui/scripts/loadGUI_2.lua 2009-03-25 14:17:07 UTC (rev 2053)
@@ -0,0 +1,88 @@
+local schemeMgr = CEGUI.SchemeManager:getSingleton()
+local winMgr = CEGUI.WindowManager:getSingleton()
+local logger = CEGUI.Logger:getSingleton()
+local system = CEGUI.System:getSingleton()
+local cursor = CEGUI.MouseCursor:getSingleton()
+
+schemeMgr:loadScheme("TaharezLookSkin.scheme")
+-- load scheme with our own images
+schemeMgr:loadScheme("OrxonoxGUIScheme.scheme")
+
+system:setDefaultMouseCursor("TaharezLook", "MouseArrow")
+system:setDefaultFont("BlueHighway-12")
+
+local current = nil
+local loadedGUIs = {}
+local showing
+-- we cannot directly call functions with parameters and so need this as a global variable, which sucks of course
+filename = ""
+datapath = "" -- points to media-folder (set after loading the script)
+
+-- function to add a reference to list of reference of loaded GUIs
+loadedGUIs.addGUI = function (gui)
+ loadedGUIs[#loadedGUIs+1] = gui
+end
+
+-- function which returns a GUI by name
+loadedGUIs.getGUIbyName = function (str)
+ for i = 1, #loadedGUIs, 1 do
+ if str == loadedGUIs[i].filename then
+ return loadedGUIs[i]
+ end
+ end
+ return nil
+end
+
+-- loads the GUI with the specified filename
+-- be sure to set the global variable "filename" before calling this function
+function loadGUI()
+ -- check if it already exists
+ newlyLoaded = loadedGUIs:getGUIbyName(filename)
+ if newlyLoaded == nil then
+ dofile(datapath .. "gui/scripts/" .. filename)
+ newlyLoaded = winMgr:loadWindowLayout(layoutPath)
+ newlyLoaded.filename = filename
+ loadedGUIs:addGUI(newlyLoaded)
+ -- if there has no GUI been loaded yet, set new GUI as current
+ if #loadedGUIs == 1 then
+ current = loadedGUIs[1]
+ showing = false
+ end
+ -- hide new GUI as we do not want to show it accidentially
+ newlyLoaded:hide()
+ end
+ return newlyLoaded
+end
+
+-- shows the specified and loads it if not loaded already
+-- be sure to set the global variable "filename" before calling this function
+function showGUI()
+ if current == nil or current.filename ~= filename then
+ current = loadedGUIs.getGUIbyName(filename)
+ if current == nil then
+ current = loadGUI(filename)
+ end
+ system:setGUISheet(current)
+ end
+ current:show()
+ cursor:show()
+ showing = true
+end
+
+function toggleGUI()
+ if showing == true then
+ current:hide()
+ cursor:hide()
+ showing = false
+ else
+ current:show()
+ cursor:show()
+ showing = true
+ end
+ return showing
+end
+
+function hideGUI()
+ current:hide()
+ showing = false
+end
More information about the Orxonox-commit
mailing list