Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5215 was 5165, checked in by rgrieder, 16 years ago

added server/client button to main menu

File size: 3.1 KB
RevLine 
[5162]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
[5165]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")
[5162]24
[5165]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
[5162]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")
[5164]40background:subscribeEvent("CharacterKey", "key_pressed")
[5162]41
42rootSheet:addChildWindow(quit)
[5165]43rootSheet:addChildWindow(standalone)
44rootSheet:addChildWindow(server)
45rootSheet:addChildWindow(client)
[5162]46background:addChildWindow(rootSheet)
47
48
49function button_quit_clicked(e)
[5163]50  hideGUI()
[5162]51  orxonox.CommandExecutor:execute("exit")
52end
53
[5165]54function button_standalone_clicked(e)
[5164]55  orxonox.CommandExecutor:execute("selectGameState standalone")
[5162]56  hideGUI()
57end
58
[5165]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
[5164]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
[5163]76showBackground = false
[5162]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)
[5164]89  orxonox.GUIManager:getInstance():hideGUI()
[5162]90end
Note: See TracBrowser for help on using the repository browser.