Changeset 5427
- Timestamp:
- Mar 25, 2009, 11:13:58 AM (16 years ago)
- Location:
- data/media/gui
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
data/media/gui/layouts/MainMenu.layout
r5414 r5427 1 1 <?xml version="1.0" ?> 2 2 <GUILayout> 3 <Window Type="DefaultGUISheet" Name="orxonox/RootSheet"> 3 <Window Type="TaharezLook/StaticImage" Name="orxonox/Background"> 4 <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/> 5 <Property Name="Image" Value="set:MainMenuBackground image:Background"/> 6 4 7 <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton"> 5 8 <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/> … … 8 11 <Event Name="Clicked" Function="button_standalone_clicked"/> 9 12 </Window> 13 10 14 <Window Type="TaharezLook/Button" Name="orxonox/DedicatedButton"> 11 15 <Property Name="UnifiedPosition" Value="{{0.11,0},{0.376,0}}"/> … … 14 18 <Event Name="Clicked" Function="button_dedicated_clicked"/> 15 19 </Window> 20 16 21 <Window Type="TaharezLook/Button" Name="orxonox/ServerButton"> 17 22 <Property Name="UnifiedPosition" Value="{{0.11,0},{0.452,0}}"/> … … 20 25 <Event Name="Clicked" Function="button_server_clicked"/> 21 26 </Window> 27 22 28 <Window Type="TaharezLook/Button" Name="orxonox/ClientButton"> 23 29 <Property Name="UnifiedPosition" Value="{{0.11,0},{0.528,0}}"/> … … 26 32 <Event Name="Clicked" Function="button_client_clicked"/> 27 33 </Window> 34 28 35 <Window Type="TaharezLook/Button" Name="orxonox/QuitButton"> 29 36 <Property Name="UnifiedPosition" Value="{{0.11,0},{0.528,0}}"/> … … 32 39 <Event Name="Clicked" Function="button_quit_clicked"/> 33 40 </Window> 34 <Window Type="TaharezLook/Button" Name="orxonox/TestButton">35 <Property Name="UnifiedPosition" Value="{{0.11,0},{0.604,0}}"/>36 <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>37 <Property Name="Text" Value="Hide"/>38 <Event Name="Clicked" Function="toggleGUI"/>39 </Window>40 41 </Window> 41 42 </GUILayout> -
data/media/gui/scripts/loadGUI.lua
r5414 r5427 3 3 local logger = CEGUI.Logger:getSingleton() 4 4 local system = CEGUI.System:getSingleton() 5 local cursor = CEGUI.MouseCursor:getSingleton() 5 6 6 7 schemeMgr:loadScheme("TaharezLookSkin.scheme") 8 -- load scheme with our own images 9 schemeMgr:loadScheme("OrxonoxGUIScheme.scheme") 10 7 11 system:setDefaultMouseCursor("TaharezLook", "MouseArrow") 8 12 system:setDefaultFont("BlueHighway-12") 9 13 14 local current = nil 15 local loadedGUIs = {} 16 local showing 17 -- we cannot directly call functions with parameters and so need this as a global variable, which sucks of course 18 filename = "" 19 datapath = "" -- points to media-folder (set after loading the script) 10 20 11 local mainmenu = winMgr:loadWindowLayout("MainMenu.layout") 12 13 local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "main_menu_1.jpg") 14 local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background") 15 background:setProperty("FrameEnabled", "set: true") 16 background:setProperty("BackgroundEnabled", "set: false") 17 background:setProperty("Image", "set: GUI/Background image:full_image") 18 19 background:addChildWindow(mainmenu) 20 21 22 function button_quit_clicked(e) 23 hideGUI() 24 orxonox.CommandExecutor:execute("exit") 21 -- function to add a reference to list of reference of loaded GUIs 22 loadedGUIs.addGUI = function (gui) 23 loadedGUIs[#loadedGUIs+1] = gui 25 24 end 26 25 27 function button_standalone_clicked(e) 28 orxonox.CommandExecutor:execute("selectGameState standalone") 29 hideGUI() 26 -- function which returns a GUI by name 27 loadedGUIs.getGUIbyName = function (str) 28 for i = 1, #loadedGUIs, 1 do 29 if str == loadedGUIs[i].filename then 30 return loadedGUIs[i] 31 end 32 end 33 return nil 30 34 end 31 35 32 function button_server_clicked(e) 33 orxonox.CommandExecutor:execute("selectGameState server") 34 hideGUI() 36 -- loads the GUI with the specified filename 37 -- be sure to set the global variable "filename" before calling this function 38 function loadGUI() 39 -- check if it already exists 40 newlyLoaded = loadedGUIs:getGUIbyName(filename) 41 if newlyLoaded == nil then 42 dofile(datapath .. "gui/scripts/" .. filename) 43 newlyLoaded = winMgr:loadWindowLayout(layoutPath) 44 newlyLoaded.filename = filename 45 loadedGUIs:addGUI(newlyLoaded) 46 -- if there has no GUI been loaded yet, set new GUI as current 47 if #loadedGUIs == 1 then 48 current = loadedGUIs[1] 49 showing = false 50 end 51 -- hide new GUI as we do not want to show it accidentially 52 newlyLoaded:hide() 53 end 54 return newlyLoaded 35 55 end 36 56 37 function button_dedicated_clicked(e) 38 orxonox.CommandExecutor:execute("selectGameState dedicated") 39 hideGUI() 57 -- shows the specified and loads it if not loaded already 58 -- be sure to set the global variable "filename" before calling this function 59 function showGUI() 60 if current == nil or current.filename ~= filename then 61 current = loadedGUIs.getGUIbyName(filename) 62 if current == nil then 63 current = loadGUI(filename) 64 end 65 system:setGUISheet(current) 66 end 67 current:show() 68 cursor:show() 69 showing = true 40 70 end 41 42 function button_client_clicked(e)43 orxonox.CommandExecutor:execute("selectGameState client")44 hideGUI()45 end46 47 showBackground = true48 49 function showMainMenu()50 if showBackground == true then51 system:setGUISheet(background)52 else53 orxonox.GUIManager:getInstance():testOutput("set new Menu")54 system:setGUISheet(mainmenu)55 end56 return 0;57 end58 59 showing = true60 71 61 72 function toggleGUI() 62 73 if showing == true then 63 mainmenu:hide() 74 current:hide() 75 cursor:hide() 64 76 showing = false 65 orxonox.GUIManager:getInstance():testOutput("hiding Menu")66 77 else 67 mainmenu:show() 78 current:show() 79 cursor:show() 68 80 showing = true 69 orxonox.GUIManager:getInstance():testOutput("showing Menu")70 81 end 82 return showing 71 83 end 72 84 73 85 function hideGUI() 74 --system:setGUISheet(nil)75 --orxonox.GUIManager:getInstance():hideGUI()86 current:hide() 87 showing = false 76 88 end
Note: See TracChangeset
for help on using the changeset viewer.