Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/media/gui/scripts/loadGUI.lua @ 5430

Last change on this file since 5430 was 5430, checked in by rgrieder, 15 years ago

svn:eol-style "native" for the gui scripts.

  • Property svn:eol-style set to native
File size: 3.7 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 leftOffset = 0.11
14local topOffset  = 0.3
15local distance   = 0.076
16local index      = 0
17
18local standalone = winMgr:createWindow("TaharezLook/Button", "orxonox/StandaloneButton")
19standalone:setText("Standalone")
20standalone:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
21standalone:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
22standalone:subscribeEvent("Clicked","button_standalone_clicked")
23index = index + 1
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(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
29dedicated:subscribeEvent("Clicked","button_dedicated_clicked")
30index = index + 1
31
32local server = winMgr:createWindow("TaharezLook/Button", "orxonox/ServerButton")
33server:setText("Server")
34server:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
35server:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
36server:subscribeEvent("Clicked","button_server_clicked")
37index = index + 1
38
39local client = winMgr:createWindow("TaharezLook/Button", "orxonox/ClientButton")
40client:setText("Client")
41client:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
42client:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
43client:subscribeEvent("Clicked","button_client_clicked")
44index = index + 1
45
46local quit = winMgr:createWindow("TaharezLook/Button", "orxonox/QuitButton")
47quit:setText("Quit")
48quit:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
49quit:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
50quit:subscribeEvent("Clicked","button_quit_clicked")
51index = index + 1
52
53local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "main_menu_1.jpg")
54local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background")
55background:setProperty("FrameEnabled", "set: true")
56background:setProperty("BackgroundEnabled", "set: false")
57background:setProperty("Image", "set: GUI/Background image:full_image")
58
59rootSheet:addChildWindow(quit)
60rootSheet:addChildWindow(standalone)
61rootSheet:addChildWindow(server)
62rootSheet:addChildWindow(dedicated)
63rootSheet:addChildWindow(client)
64background:addChildWindow(rootSheet)
65
66
67function button_quit_clicked(e)
68  hideGUI()
69  orxonox.CommandExecutor:execute("exit")
70end
71
72function button_standalone_clicked(e)
73  orxonox.CommandExecutor:execute("selectGameState standalone")
74  hideGUI()
75end
76
77function button_server_clicked(e)
78  orxonox.CommandExecutor:execute("selectGameState server")
79  hideGUI()
80end
81
82function button_dedicated_clicked(e)
83  orxonox.CommandExecutor:execute("selectGameState dedicated")
84  hideGUI()
85end
86
87function button_client_clicked(e)
88  orxonox.CommandExecutor:execute("selectGameState client")
89  hideGUI()
90end
91
92showBackground = false
93
94function showMainMenu()
95  if showBackground == true then
96    system:setGUISheet(background)
97  else
98    system:setGUISheet(rootSheet)
99  end
100  return 0;
101end
102
103function hideGUI()
104  system:setGUISheet(nil)
105  orxonox.GUIManager:getInstance():hideGUI()
106end
Note: See TracBrowser for help on using the repository browser.