Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/Media/gui/scripts/loadGUI.lua @ 5236

Last change on this file since 5236 was 5236, checked in by landauf, 16 years ago
  • put hudtemplates into a separate file
  • added dedicated button to loadGUI
  • changed some parameters in some material files
File size: 3.6 KB
Line 
1local schemeMgr = CEGUI.SchemeManager:getSingleton()
2local winMgr = CEGUI.WindowManager:getSingleton()
3local logger = CEGUI.Logger:getSingleton()
4local system = CEGUI.System:getSingleton()
5
6schemeMgr:loadScheme("TaharezLookSkin.scheme")
7system:setDefaultMouseCursor("TaharezLook", "MouseArrow")
8system:setDefaultFont("BlueHighway-12")
9
10
11local rootSheet = winMgr:createWindow("DefaultGUISheet", "orxonox/Sheet")
12
13local quit = winMgr:createWindow("TaharezLook/Button", "orxonox/QuitButton")
14quit:setText("Quit")
15quit:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
16quit:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.7, 0)))
17quit:subscribeEvent("Clicked","button_quit_clicked")
18
19local standalone = winMgr:createWindow("TaharezLook/Button", "orxonox/StandaloneButton")
20standalone:setText("Standalone")
21standalone:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
22standalone:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.3, 0)))
23standalone:subscribeEvent("Clicked","button_standalone_clicked")
24
25local dedicated = winMgr:createWindow("TaharezLook/Button", "orxonox/DedicatedButton")
26dedicated:setText("Dedicated")
27dedicated:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
28dedicated:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.4, 0)))
29dedicated:subscribeEvent("Clicked","button_dedicated_clicked")
30
31local server = winMgr:createWindow("TaharezLook/Button", "orxonox/ServerButton")
32server:setText("Server")
33server:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
34server:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.5, 0)))
35server:subscribeEvent("Clicked","button_server_clicked")
36
37local client = winMgr:createWindow("TaharezLook/Button", "orxonox/ClientButton")
38client:setText("Client")
39client:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
40client:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.6, 0)))
41client:subscribeEvent("Clicked","button_client_clicked")
42
43local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "sample_loading.jpg")
44local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background")
45background:setProperty("Image", "set: GUI/Background image:full_image")
46background:subscribeEvent("CharacterKey", "key_pressed")
47
48rootSheet:addChildWindow(quit)
49rootSheet:addChildWindow(standalone)
50rootSheet:addChildWindow(server)
51rootSheet:addChildWindow(dedicated)
52rootSheet:addChildWindow(client)
53background:addChildWindow(rootSheet)
54
55
56function button_quit_clicked(e)
57  hideGUI()
58  orxonox.CommandExecutor:execute("exit")
59end
60
61function button_standalone_clicked(e)
62  orxonox.CommandExecutor:execute("selectGameState standalone")
63  hideGUI()
64end
65
66function button_server_clicked(e)
67  orxonox.CommandExecutor:execute("selectGameState server")
68  hideGUI()
69end
70
71function button_dedicated_clicked(e)
72  orxonox.CommandExecutor:execute("selectGameState dedicated")
73  hideGUI()
74end
75
76function button_client_clicked(e)
77  orxonox.CommandExecutor:execute("selectGameState client")
78  hideGUI()
79end
80
81function key_pressed(e)
82  keyevent = tolua.cast(e, "CEGUI::KeyEventArgs")
83  if keyevent.codepoint == 167 then
84    orxonox.CommandExecutor:execute("openConsole")
85  end
86end
87
88showBackground = false
89
90function showMainMenu()
91  if showBackground == true then
92    system:setGUISheet(background)
93  else
94    system:setGUISheet(rootSheet)
95  end
96  return 0;
97end
98
99function hideGUI()
100  system:setGUISheet(nil)
101  orxonox.GUIManager:getInstance():hideGUI()
102end
Note: See TracBrowser for help on using the repository browser.