| 37 | #include <CEGUI/Event.h> |
| 38 | |
| 39 | Gui::Gui(SoundEffectsManager* soundEffectsManager, const std::string& ceguiLogFileName) |
| 40 | : mSoundEffectsManager(soundEffectsManager) |
| 41 | { |
| 42 | OD_LOG_INF("*** Initializing CEGUI ***"); |
| 43 | CEGUI::OgreRenderer& renderer = CEGUI::OgreRenderer::create(); |
| 44 | OD_LOG_INF("OgreRenderer created"); |
| 45 | CEGUI::OgreResourceProvider& rp = CEGUI::OgreRenderer::createOgreResourceProvider(); |
| 46 | OD_LOG_INF("OgreResourceProvider created"); |
| 47 | CEGUI::OgreImageCodec& ic = CEGUI::OgreRenderer::createOgreImageCodec(); |
| 48 | OD_LOG_INF("OgreImageCodec created"); |
| 49 | CEGUI::System::create(renderer, &rp, static_cast<CEGUI::XMLParser*>(nullptr), &ic, nullptr, "", |
| 50 | reinterpret_cast<const CEGUI::utf8*>(ceguiLogFileName.c_str())); |
| 51 | OD_LOG_INF("CEGUI::System created"); |
| 52 | |
| 53 | CEGUI::SchemeManager::getSingleton().createFromFile("ODSkin.scheme"); |
| 54 | OD_LOG_INF("CEGUI::SchemeManager created"); |
| 55 | |
| 56 | // We want Ogre overlays to be displayed in front of CEGUI. According to |
| 57 | // http://cegui.org.uk/forum/viewtopic.php?f=10&t=5694 |
| 58 | // the best way is to disable CEGUI auto rendering by calling setFrameControlExecutionEnabled |
| 59 | // and render CEGUI in an Ogre::RenderQueueListener (done in ODFrameListener) by calling |
| 60 | // CEGUI::System::getSingleton().renderAllGUIContexts(); |
| 61 | renderer.setFrameControlExecutionEnabled(false); |
| 62 | |
| 63 | // Needed to get the correct offset when using up to CEGUI 0.8.4 |
| 64 | // We're thus using an empty mouse cursor. |
| 65 | CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext(); |
| 66 | context.getMouseCursor().setDefaultImage("OpenDungeonsSkin/MouseArrow"); |
| 67 | context.getMouseCursor().setVisible(true); |
| 68 | context.setDefaultTooltipType("OD/Tooltip"); |
| 69 | CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr(); |
| 70 | mSheets[hideGui] = wmgr->createWindow("DefaultWindow", "DummyWindow"); |
| 71 | mSheets[inGameMenu] = wmgr->loadLayoutFromFile("ModeGame.layout"); |
| 72 | mSheets[mainMenu] = wmgr->loadLayoutFromFile("MenuMain.layout"); |
| 73 | mSheets[skirmishMenu] = wmgr->loadLayoutFromFile("MenuSkirmish.layout"); |
| 74 | mSheets[multiplayerClientMenu] = wmgr->loadLayoutFromFile("MenuMultiplayerClient.layout"); |
| 75 | mSheets[multiplayerServerMenu] = wmgr->loadLayoutFromFile("MenuMultiplayerServer.layout"); |
| 76 | mSheets[multiMasterServerJoinMenu] = wmgr->loadLayoutFromFile("MenuMasterServerJoin.layout"); |
| 77 | mSheets[editorModeGui] = wmgr->loadLayoutFromFile("ModeEditor.layout"); |
| 78 | mSheets[editorNewMenu] = wmgr->loadLayoutFromFile("MenuEditorNew.layout"); |
| 79 | mSheets[editorLoadMenu] = wmgr->loadLayoutFromFile("MenuEditorLoad.layout"); |
| 80 | mSheets[configureSeats] = wmgr->loadLayoutFromFile("MenuConfigureSeats.layout"); |
| 81 | mSheets[replayMenu] = wmgr->loadLayoutFromFile("MenuReplay.layout"); |
| 82 | mSheets[loadSavedGameMenu] = wmgr->loadLayoutFromFile("MenuLoad.layout"); |
| 83 | mSheets[console] = wmgr->loadLayoutFromFile("WindowConsole.layout"); |
| 84 | |
| 85 | // Set the game version |
| 86 | mSheets[mainMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 87 | mSheets[skirmishMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 88 | mSheets[multiplayerServerMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 89 | mSheets[multiplayerClientMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 90 | mSheets[editorNewMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 91 | mSheets[editorLoadMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 92 | mSheets[replayMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 93 | mSheets[loadSavedGameMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 94 | mSheets[multiMasterServerJoinMenu]->getChild("VersionText")->setText(ODApplication::VERSION); |
| 95 | |
| 96 | // Add sound to button clicks |
nothing calls this directly
no test coverage detected