[Orxonox-commit 339] r2116 - in media/gui: layouts scripts
bknecht at orxonox.net
bknecht at orxonox.net
Thu May 7 17:05:09 CEST 2009
Author: bknecht
Date: 2009-05-07 17:05:08 +0200 (Thu, 07 May 2009)
New Revision: 2116
Added:
media/gui/layouts/MainMenu_2.layout
media/gui/scripts/gui.lua
media/gui/scripts/loadGUI_3.lua
media/gui/scripts/mainmenu_2.lua
Log:
new version of the GUI
Added: media/gui/layouts/MainMenu_2.layout
===================================================================
--- media/gui/layouts/MainMenu_2.layout (rev 0)
+++ media/gui/layouts/MainMenu_2.layout 2009-05-07 15:05:08 UTC (rev 2116)
@@ -0,0 +1,55 @@
+<?xml version="1.0" ?>
+<GUILayout>
+ <Window Type="TaharezLook/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"/>
+
+ <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
+ <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/>
+ <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
+ <Property Name="Text" Value="Standalone"/>
+ <Event Name="Clicked" Function="mainmenu_2.button_standalone_clicked"/>
+ </Window>
+
+ <Window Type="TaharezLook/Listbox" Name="orxonox/LevelListBox">
+ <Property Name="UnifiedPosition" Value="{{0.35,0},{0.3,0}}"/>
+ <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
+ <Item Type="TaharezLook/ListboxItem" Name="orxonox/LevelListItem1">
+ <Property Name="Text" Value="Item1"/>
+ </Item>
+ <Item Type="TaharezLook/ListboxItem" Name="orxonox/LevelListItem2">
+ <Property Name="Text" Value="Item2"/>
+ </Item>
+ </Window>
+
+ <Window Type="TaharezLook/Button" Name="orxonox/DedicatedButton">
+ <Property Name="UnifiedPosition" Value="{{0.11,0},{0.376,0}}"/>
+ <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
+ <Property Name="Text" Value="Dedicated"/>
+ <Event Name="Clicked" Function="mainmenu_2.button_dedicated_clicked"/>
+ </Window>
+
+ <Window Type="TaharezLook/Button" Name="orxonox/ServerButton">
+ <Property Name="UnifiedPosition" Value="{{0.11,0},{0.452,0}}"/>
+ <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
+ <Property Name="Text" Value="Server"/>
+ <Event Name="Clicked" Function="mainmenu_2.button_server_clicked"/>
+ </Window>
+
+ <Window Type="TaharezLook/Button" Name="orxonox/ClientButton">
+ <Property Name="UnifiedPosition" Value="{{0.11,0},{0.528,0}}"/>
+ <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
+ <Property Name="Text" Value="Client"/>
+ <Event Name="Clicked" Function="mainmenu_2.button_client_clicked"/>
+ </Window>
+
+ <Window Type="TaharezLook/Button" Name="orxonox/QuitButton">
+ <Property Name="UnifiedPosition" Value="{{0.11,0},{0.604,0}}"/>
+ <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
+ <Property Name="Text" Value="Quit"/>
+ <Event Name="Clicked" Function="mainmenu_2.button_quit_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Added: media/gui/scripts/gui.lua
===================================================================
--- media/gui/scripts/gui.lua (rev 0)
+++ media/gui/scripts/gui.lua 2009-05-07 15:05:08 UTC (rev 2116)
@@ -0,0 +1,36 @@
+-- gui.lua
+
+local P = {}
+if _REQUIREDNAME == nil then
+ gui = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.overlay = nil
+
+-- constructor of the GUI
+function P:new (gui, fname)
+ local newElement = { window = gui, filename = fname, visible = false } or {}
+ setmetatable(newElement, self) -- connects new element with class
+ self.__index = self
+ return newElement
+end
+
+-- hide function for the GUI
+function P:hide ()
+ self.window:hide()
+ self.visible = false
+end
+
+-- show function for the GUI
+function P:show ()
+ self.window:show()
+ self.visible = true
+end
+
+function P:load ()
+ return self:new(winMgr:loadWindowLayout(self.layoutString), self.filename)
+end
+
+return gui or _G[_REQUIREDNAME]
Added: media/gui/scripts/loadGUI_3.lua
===================================================================
--- media/gui/scripts/loadGUI_3.lua (rev 0)
+++ media/gui/scripts/loadGUI_3.lua 2009-05-07 15:05:08 UTC (rev 2116)
@@ -0,0 +1,86 @@
+local schemeMgr = CEGUI.SchemeManager:getSingleton()
+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")
+
+loadedGUIs = {}
+
+-- datapath is set before executing the script and points to media-folder
+package.path = package.path .. ";" .. datapath .. "gui/scripts/?.lua"
+
+-- loads the GUI with the specified filename
+-- be sure to set the global variable "filename" before calling this function
+function loadGUI(filename)
+ -- check if it already exists
+ loadedGui = loadedGUIs[filename]
+ if loadedGui == nil then
+ loadedGuiNS = require(filename)
+ loadedGui = loadedGuiNS:load()
+ loadedGUIs[filename] = loadedGui
+ -- 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
+ loadedGui:hide()
+ end
+ return loadedGui
+end
+
+function showGUI(filename, ptr)
+ gui = showGUI(filename)
+ gui.overlay = ptr
+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(filename)
+ if current == nil or current.filename ~= filename then
+ current = loadedGUIs[filename]
+ if current == nil then
+ current = loadGUI(filename)
+ end
+ system:setGUISheet(current.window)
+ end
+ current:show()
+ showing = true
+ return current
+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 hideCursor()
+ cursor:hide()
+end
+
+function showCursor()
+ cursor:show()
+end
+
+function hideGUI(filename)
+ current = loadedGUIs[filename]
+ if current ~= nil then
+ current:hide()
+ showing = false
+ end
+end
Added: media/gui/scripts/mainmenu_2.lua
===================================================================
--- media/gui/scripts/mainmenu_2.lua (rev 0)
+++ media/gui/scripts/mainmenu_2.lua 2009-05-07 15:05:08 UTC (rev 2116)
@@ -0,0 +1,50 @@
+-- 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"
+
+-- overwrites load function of previous load function
+function P:load()
+ element = P.__index.load(P) -- calling load function of parent class with ourselves and do other stuff now
+ --win = winMgr:getWindow("orxonox/LevelListBox")
+ --print(win.getItemCount())
+ --item = winMgr:createWindow("TaharezLook/ListboxItem", "orxonox/LevelListBoxItem1")
+ --item:setText("HiHo")
+ --win:addItem(item)
+ --print(win:getItemCount())
+ return element
+end
+
+
+-- events for mainmenu
+function P.button_quit_clicked(e)
+ hideGUI()
+ orxonox.CommandExecutor:execute("exit")
+end
+
+function P.button_standalone_clicked(e)
+ orxonox.CommandExecutor:execute("startGame")
+ toggleGUI()
+end
+
+function P.button_server_clicked(e)
+ orxonox.CommandExecutor:execute("echo Not yet supported!")
+ hideGUI()
+end
+
+function P.button_dedicated_clicked(e)
+ orxonox.CommandExecutor:execute("echo Not yet supported!")
+ hideGUI()
+end
+
+function P.button_client_clicked(e)
+ orxonox.CommandExecutor:execute("echo Not yet supported!")
+ hideGUI()
+end
+
+return mainmenu_2
+
More information about the Orxonox-commit
mailing list