[5180] | 1 | local schemeMgr = CEGUI.SchemeManager:getSingleton() |
---|
| 2 | local winMgr = CEGUI.WindowManager:getSingleton() |
---|
| 3 | local logger = CEGUI.Logger:getSingleton() |
---|
| 4 | local system = CEGUI.System:getSingleton() |
---|
| 5 | |
---|
| 6 | schemeMgr:loadScheme("TaharezLookSkin.scheme") |
---|
| 7 | system:setDefaultMouseCursor("TaharezLook", "MouseArrow") |
---|
| 8 | system:setDefaultFont("BlueHighway-12") |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | local rootSheet = winMgr:createWindow("DefaultGUISheet", "orxonox/Sheet") |
---|
| 12 | |
---|
| 13 | local quit = winMgr:createWindow("TaharezLook/Button", "orxonox/QuitButton") |
---|
| 14 | quit:setText("Quit") |
---|
| 15 | quit:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0))) |
---|
| 16 | quit:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.6, 0))) |
---|
| 17 | quit:subscribeEvent("Clicked","button_quit_clicked") |
---|
| 18 | |
---|
| 19 | local standalone = winMgr:createWindow("TaharezLook/Button", "orxonox/StandaloneButton") |
---|
| 20 | standalone:setText("Standalone") |
---|
| 21 | standalone:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0))) |
---|
| 22 | standalone:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.3, 0))) |
---|
| 23 | standalone:subscribeEvent("Clicked","button_standalone_clicked") |
---|
| 24 | |
---|
| 25 | local server = winMgr:createWindow("TaharezLook/Button", "orxonox/ServerButton") |
---|
| 26 | server:setText("Server") |
---|
| 27 | server:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0))) |
---|
| 28 | server:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.4, 0))) |
---|
| 29 | server:subscribeEvent("Clicked","button_server_clicked") |
---|
| 30 | |
---|
| 31 | local client = winMgr:createWindow("TaharezLook/Button", "orxonox/ClientButton") |
---|
| 32 | client:setText("Client") |
---|
| 33 | client:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0))) |
---|
| 34 | client:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0.5, 0))) |
---|
| 35 | client:subscribeEvent("Clicked","button_client_clicked") |
---|
| 36 | |
---|
| 37 | local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "sample_loading.jpg") |
---|
| 38 | local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background") |
---|
| 39 | background:setProperty("Image", "set: GUI/Background image:full_image") |
---|
| 40 | background:subscribeEvent("CharacterKey", "key_pressed") |
---|
| 41 | |
---|
| 42 | rootSheet:addChildWindow(quit) |
---|
| 43 | rootSheet:addChildWindow(standalone) |
---|
| 44 | rootSheet:addChildWindow(server) |
---|
| 45 | rootSheet:addChildWindow(client) |
---|
| 46 | background:addChildWindow(rootSheet) |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | function button_quit_clicked(e) |
---|
| 50 | hideGUI() |
---|
| 51 | orxonox.CommandExecutor:execute("exit") |
---|
| 52 | end |
---|
| 53 | |
---|
| 54 | function button_standalone_clicked(e) |
---|
| 55 | orxonox.CommandExecutor:execute("selectGameState standalone") |
---|
| 56 | hideGUI() |
---|
| 57 | end |
---|
| 58 | |
---|
| 59 | function button_server_clicked(e) |
---|
| 60 | orxonox.CommandExecutor:execute("selectGameState server") |
---|
| 61 | hideGUI() |
---|
| 62 | end |
---|
| 63 | |
---|
| 64 | function button_client_clicked(e) |
---|
| 65 | orxonox.CommandExecutor:execute("selectGameState client") |
---|
| 66 | hideGUI() |
---|
| 67 | end |
---|
| 68 | |
---|
| 69 | function key_pressed(e) |
---|
| 70 | keyevent = tolua.cast(e, "CEGUI::KeyEventArgs") |
---|
| 71 | if keyevent.codepoint == 167 then |
---|
| 72 | orxonox.CommandExecutor:execute("openConsole") |
---|
| 73 | end |
---|
| 74 | end |
---|
| 75 | |
---|
| 76 | showBackground = false |
---|
| 77 | |
---|
| 78 | function showMainMenu() |
---|
| 79 | if showBackground == true then |
---|
| 80 | system:setGUISheet(background) |
---|
| 81 | else |
---|
| 82 | system:setGUISheet(rootSheet) |
---|
| 83 | end |
---|
| 84 | return 0; |
---|
| 85 | end |
---|
| 86 | |
---|
| 87 | function hideGUI() |
---|
| 88 | system:setGUISheet(nil) |
---|
| 89 | orxonox.GUIManager:getInstance():hideGUI() |
---|
| 90 | end |
---|