bool GUIManager::loadWindow(const std::string &windowName) { bool flag = false; // 检测给定layout的文件是否加载,没有加载则加载 if(!getWindowManager()->isWindowPresent(windowName)) { // 从 .layout脚本文件读取一个UI布局设计,并将其放置到GUI资源组中。 CEGUI::Window *editorGuiSheet = getWindowManager()->loadWindowLayout(windowName + ".layout"); // 接下来我们告诉CEGUI显示哪份UI布局。当然我们可以随时更换显示的UI布局。 CEGUI::System &sys = CEGUI::System::getSingleton(); sys.setGUISheet(editorGuiSheet); //getSingletonPtr()->getGUISystem()->setGUISheet(editorGuiSheet); editorGuiSheet->setVisible(true); editorGuiSheet->setMousePassThroughEnabled(true); flag = true; } else { assert(0); //// 如果已经加载则直接显示 //CEGUI::Window *window = getWindowManager()->getWindow(windowName); //getSingletonPtr()->getGUISystem()->setGUISheet(window); //window->show(); } return flag; }
void EditorGUI::Init() { // Load imagesets for Editor gGUIMgr.LoadSystemImageset("EditorToolbar.imageset"); // Load GUI sheet CEGUI::Window* editor = gGUIMgr.LoadSystemLayout("Editor.layout"); if (editor == 0 || !gGUIMgr.SetGUISheet(editor)) { ocError << "Cannot load editor."; return; } CEGUI::System::getSingleton().setDefaultTooltip("Editor/Tooltip"); editor->setMousePassThroughEnabled(true); // Initialize in-game console gGUIMgr.InitConsole(); // Initialize EditorMenu mEditorMenu = new EditorMenu(); mEditorMenu->Init(); // Initialize EntityWindow mEntityWindow = new EntityWindow(); mEntityWindow->Init(); // Initialize LayerWindow mLayerWindow = new LayerWindow(); mLayerWindow->Init(); // Initialize ResourceWindow mResourceWindow = new ResourceWindow(); mResourceWindow->Init(); // Initialize PrototypeWindow mPrototypeWindow = new PrototypeWindow(); mPrototypeWindow->Init(); // Initialize HiearchyWindow mHierarchyWindow = new HierarchyWindow(); mHierarchyWindow->Init(); // Initialize top viewport mGameViewport = static_cast<GUISystem::ViewportWindow*>(gGUIMgr.GetWindow("Editor/GameViewport")); mGameViewport->SetDragAndDropCamera(false); // Initialize bottom viewport mEditorViewport = static_cast<GUISystem::ViewportWindow*>(gGUIMgr.GetWindow("Editor/EditorViewport")); mEditorViewport->SetDragAndDropCamera(true); mEditorViewport->subscribeEvent(CEGUI::Window::EventDragDropItemDropped, CEGUI::Event::Subscriber(&EditorGUI::OnEditorViewportItemDropped, this)); mEditorViewport->subscribeEvent(CEGUI::Window::EventMouseClick, CEGUI::Event::Subscriber(&EditorGUI::OnEditorViewportClicked, this)); // Initialize popup menu CreatePopupMenu(); }
CEGUI::Window* HUDDemo::spawnPlate() { CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window* plateRoot = winMgr.createWindow("DefaultWindow"); plateRoot->setSize(CEGUI::USize(cegui_absdim(0.0f), cegui_reldim(0.16f))); plateRoot->setAspectMode(CEGUI::AM_EXPAND); plateRoot->setAspectRatio(1.0f); plateRoot->setRiseOnClickEnabled(false); plateRoot->setPixelAligned(false); plateRoot->subscribeEvent(CEGUI::Window::EventMouseButtonDown, Event::Subscriber(&HUDDemo::handlePlateWindowClicked, this)); d_rootIngame->addChild(plateRoot); CEGUI::Window* plateImgWnd = winMgr.createWindow("Generic/Image", "ImageWindowPlate"); plateImgWnd->setProperty("Image", s_imageNamePlate); plateImgWnd->setSize(CEGUI::USize(cegui_reldim(1.0f), cegui_absdim(0.0f))); plateImgWnd->setAspectRatio(3.308f); plateImgWnd->setAspectMode(CEGUI::AM_EXPAND); plateImgWnd->setVerticalAlignment(CEGUI::VA_BOTTOM); plateImgWnd->setMousePassThroughEnabled(true); plateImgWnd->setPixelAligned(false); plateRoot->addChild(plateImgWnd); CEGUI::String image = getRandomGameImage(); CEGUI::Window* plateTopping = winMgr.createWindow("Generic/Image", "ImageWindowObject"); plateTopping->setProperty("Image", image); plateTopping->setSize(CEGUI::USize(cegui_reldim(0.88f), cegui_absdim(0.0f))); plateTopping->setAspectRatio(1.0f); plateTopping->setAspectMode(CEGUI::AM_EXPAND); plateTopping->setHorizontalAlignment(CEGUI::HA_CENTRE); plateTopping->setMousePassThroughEnabled(true); plateTopping->setPixelAligned(false); plateRoot->addChild(plateTopping); int randumNumber = rand() % 10000; float posY = randumNumber / 10000.0f; plateRoot->setPosition(CEGUI::UVector2(cegui_absdim(0.0f), cegui_reldim(0.1f + 0.6f * posY))); return plateRoot; }
void MenusScene::Initialize() { InitializeResources(resourceGroupName); player1Nav = MenuNavigator(this); player1Nav.AllowMenuControls = true; player2Nav = MenuNavigator(this); Player1Data.MainElement = ElementEnum::Earth; Player2Data.MainElement = ElementEnum::Earth; InputNotifier::GetInstance()->AddObserver(&player1Nav); InputNotifier::GetInstance()->AddObserver(&player2Nav); guiManager->AddScheme("MainMenu.scheme"); guiManager->LoadLayout("MainMenuLayout.layout", nullptr); guiManager->LoadLayout("GameSetupMenu.layout", nullptr); guiManager->LoadLayout("TutorialLayout.layout", nullptr); //guiManager->LoadLayout("CharacterSetupMenu.layout", nullptr); if(progressBar.GetWindow() == NULL) { CEGUI::Window* progressWindow = CEGUI::WindowManager::getSingleton().createWindow("Generic/Image", "CursorProgress"); progressWindow->setSize( CEGUI::USize(CEGUI::UDim( 0.1f, 0 ), CEGUI::UDim( 0.1f, 0 ) ) ); progressWindow->setPosition( CEGUI::UVector2(CEGUI::UDim( 0.5f, 0 ), CEGUI::UDim( 0.5f, 0 ) ) ); progressWindow->setAlwaysOnTop(true); progressWindow->setMousePassThroughEnabled(true); guiManager->GetRootWindow()->addChild(progressWindow); progressBar.SetWindow(progressWindow); progressWindow->setVisible(true); } handlers[Screens::MainMenu] = new MainMenuHandler(this); //handlers[Screens::CharacterSetup] = new CharacterMenuHandler(this); handlers[Screens::GameSetup] = new GameSetupMenuHandler(this); handlers[Screens::Tutorial] = new TutorialMenuHandler(this); for (unsigned int i = 0; i < Screens::Count; i++) { handlers[i]->Hide(); } //currentScreen = GameSetup; handlers[currentScreen]->Show(); InputManager* inputManager = InputManager::GetInstance(); KinectSpeechReader* speechReader = inputManager->GetSpeechReader(); if(speechReader) { inputManager->RegisterAudioListener(&player1Nav); //Load the grammar for this scene if(!speechReader->LoadGrammarFile("MenusSpeech.grxml")) printf("Grammer Load Fail\n"); //Set the confidence threshold speechReader->SetConfidenceThreshold(0.6f); } ogreSceneManager->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f, 1.0f)); CreateCameraAndViewport(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 0.0f)); }