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