Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/Media/gui/scripts/loadGUI.lua @ 5180

Last change on this file since 5180 was 5180, checked in by dafrick, 16 years ago
File size: 3.1 KB
RevLine 
[5180]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.6, 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 server = winMgr:createWindow("TaharezLook/Button", "orxonox/ServerButton")
26server:setText("Server")
27server:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
28server:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.4, 0)))
29server:subscribeEvent("Clicked","button_server_clicked")
30
31local client = winMgr:createWindow("TaharezLook/Button", "orxonox/ClientButton")
32client:setText("Client")
33client:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
34client:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.5, 0)))
35client:subscribeEvent("Clicked","button_client_clicked")
36
37local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "sample_loading.jpg")
38local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background")
39background:setProperty("Image", "set: GUI/Background image:full_image")
40background:subscribeEvent("CharacterKey", "key_pressed")
41
42rootSheet:addChildWindow(quit)
43rootSheet:addChildWindow(standalone)
44rootSheet:addChildWindow(server)
45rootSheet:addChildWindow(client)
46background:addChildWindow(rootSheet)
47
48
49function button_quit_clicked(e)
50  hideGUI()
51  orxonox.CommandExecutor:execute("exit")
52end
53
54function button_standalone_clicked(e)
55  orxonox.CommandExecutor:execute("selectGameState standalone")
56  hideGUI()
57end
58
59function button_server_clicked(e)
60  orxonox.CommandExecutor:execute("selectGameState server")
61  hideGUI()
62end
63
64function button_client_clicked(e)
65  orxonox.CommandExecutor:execute("selectGameState client")
66  hideGUI()
67end
68
69function key_pressed(e)
70  keyevent = tolua.cast(e, "CEGUI::KeyEventArgs")
71  if keyevent.codepoint == 167 then
72    orxonox.CommandExecutor:execute("openConsole")
73  end
74end
75
76showBackground = false
77
78function showMainMenu()
79  if showBackground == true then
80    system:setGUISheet(background)
81  else
82    system:setGUISheet(rootSheet)
83  end
84  return 0;
85end
86
87function hideGUI()
88  system:setGUISheet(nil)
89  orxonox.GUIManager:getInstance():hideGUI()
90end
Note: See TracBrowser for help on using the repository browser.