/** * Create all widgets and their initial contents. * * CEGUI is based on tree structure of Windows. On top of that * tree is a GUISheet, named "root". Each child has a position and * a size - both given as values relative to the parent elements area. * Position is given as the top left corner of a child within the parent area. * Size is given as the relative portions of the parent area. */ void createGUIWindow() { CEGUI::System *ceguiSystem= CEGUI::System::getSingletonPtr(); assert(ceguiSystem); CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr(); assert(winMgr); CEGUI::Window *ceguiRoot = winMgr->createWindow("DefaultGUISheet","root"); assert(ceguiRoot); ceguiSystem->setGUISheet(ceguiRoot); // Top element, fills the display area CEGUI::UVector2 buttonSize = CEGUI::UVector2(CEGUI::UDim(0.6, 0), CEGUI::UDim(0.1, 0)); setupCEGUIResources(); // Create a button of type "TaharezLook/Button" and name "root/Button" mButton = winMgr->createWindow( reinterpret_cast<const CEGUI::utf8*>("TaharezLook/Button"), reinterpret_cast<const CEGUI::utf8*>("root/Button")); mButton->setAlpha(0.5f); mButton->setText("Hello World!"); mButton->setSize(buttonSize); mButton->setPosition(CEGUI::UVector2(CEGUI::UDim(0.2, 0), CEGUI::UDim(0.6, 0))); mEditBox = winMgr->createWindow( reinterpret_cast<const CEGUI::utf8*>("TaharezLook/Editbox"), reinterpret_cast<const CEGUI::utf8*>("root/EditBox")); mEditBox->setAlpha(0.5f); mEditBox->setSize(CEGUI::UVector2(CEGUI::UDim(0.6, 0), CEGUI::UDim(0.1, 0))); mEditBox->setPosition(CEGUI::UVector2(CEGUI::UDim(0.2, 0), CEGUI::UDim(0.3, 0))); // Add both created elements to the GUI sheet. ceguiRoot->addChildWindow(mEditBox); ceguiRoot->addChildWindow(mButton); /* Add event subscribers to both elements. * CEGUI input handling is based on function pointers being subscribed * to certain events - events of each window type are defined in the * CEGUI API docs. When the event occurs, all subscriber functions * are called (in some order?) */ // EventTextAccepted occurs when input box has focus, and user presses // Enter, Return or Tab, and so accepts the input. mEditBox->subscribeEvent(CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber(&inputEntered)); // EventClicked occurs when button is clicked. mButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&inputEntered)); }
Dan2::Dan2(DanListener * listener):KeyListener(true),_n(0), _time(-1.f),_callback(listener) { _win= CEGUI::WindowManager::getSingleton().loadWindowLayout("Dan2.layout"); _win->setAlwaysOnTop(true); _win->hide(); CEGUI::Window * f = CEGUI::WindowManager::getSingleton().getWindow("AnimalUI"); f->addChildWindow(_win); for(int i = 0; i<9; ++i) { _editboxs[i] = static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingleton().getWindow("Dan2/Bg/" + Ogre::StringConverter::toString(i+1))); _editboxs[i]->setMaxTextLength(1); _editboxs[i]->subscribeEvent(CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber(&Dan2::textAccepted, this)); } _editboxs[0]->setValidationString("[1-7]*"); _editboxs[1]->setValidationString("[1-4]*"); _editboxs[2]->setValidationString("[1-4]*"); _editboxs[3]->setValidationString("[1-6]*"); _editboxs[4]->setValidationString("[0-3]*"); _editboxs[5]->setValidationString("[0-9]*"); _editboxs[6]->setValidationString("[1-5]*"); _editboxs[7]->setValidationString("[1-9]*"); _editboxs[8]->setValidationString("[1-7]*"); }
/*********************************************************** resize inventory ***********************************************************/ void ContainerBox::ResizeInventory(int newsize) { if(_inventory_size == newsize) return; _inventory_size = newsize; for(size_t i=0; i<_inv_boxes.size(); ++i) _inv_boxes[i]->destroy(); _inv_boxes.clear(); CEGUI::Window* pane = CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/InvScrollable"); CEGUI::Window* tmpwindow; for(int i=0; i<_inventory_size; ++i) { int x = i / 4; int y = i % 4; tmpwindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText"); tmpwindow->setArea(CEGUI::UDim(0,5+((float)_boxsize+2)*y), CEGUI::UDim(0,5+((float)_boxsize+2.0f)*x), CEGUI::UDim(0, (float)_boxsize), CEGUI::UDim(0, (float)_boxsize)); pane->addChildWindow(tmpwindow); tmpwindow->subscribeEvent( CEGUI::Window::EventDragDropItemDropped, CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInInventory, this)); tmpwindow->setID(i); _inv_boxes.push_back(tmpwindow); } CleanInventory(); }
bool OnShopCityContentSelChanged(const CEGUI::EventArgs& e) { CEGUI::TabControl* tbs = WTabControl(WEArgs(e).window); if(tbs) { CEGUI::Window* tbcontent = tbs->getTabContentsAtIndex(tbs->getSelectedTabIndex()); if(tbcontent) { tbcontent->addChildWindow(GetWindow(SHOPCITY_CHILD_PAGE_NAME));//把唯一ShopCityChild加到当前选中tbcontent上 //更新ItemSet的显示 FireUIEvent(SHOPCITY_ITEMSET_PAGE_NAME,SHOPCITY_ITEMSET_EVENT_UPDATE); //更新最近购买 FireUIEvent(SHOPCITY_LATESTBUY_NAME,SHOPCITY_PAGE_EVENT_UPDATE_LATESTBUY); //更新推荐 FireUIEvent(SHOPCITY_TWITTER_NAME,SHOPCITY_TWITTER_EVENT_NAME); //更新左搜索(导购)菜单 FireUIEvent(SHOPCITY_SEARCH_LEFTWND_NAME,SHOPCITY_SEARCHLEFT_EVENT_MENUUPDATE_NAME); //更新右搜索(筛选)菜单 FireUIEvent(SHOPCITY_SEARCH_RIGHTWND_NAME,SHOPCITY_SEARCHRIGHT_EVENT_MENUUPDATE_NAME); //设置更新源类型 ShopCityMsgMgr& msgMgr = GetInst(ShopCityMsgMgr); msgMgr.SetStateUpdateUIByType(0);//由选中的商城商店类型来更新 } } return true; }
//------------------------------------------------------------------------------ GUITeamSelect::GUITeamSelect(PuppetMasterClient * puppet_master) : puppet_master_(puppet_master) { enableFloatingPointExceptions(false); CEGUI::WindowManager& wm = CEGUI::WindowManager::getSingleton(); /// XXX hack because root window is stored inside metatask, no easy way to retrieve it CEGUI::Window * parent = wm.getWindow("TankApp_root/"); // Use parent window name as prefix to avoid name clashes root_ = wm.loadWindowLayout("teamselectmenu.layout", parent->getName()); menu_window_ = (CEGUI::Window*) wm.getWindow(parent->getName() + "teamselectmenu/menu"); menu_btn_[0] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn1"); menu_btn_[1] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn2"); menu_btn_spec_ = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn3"); menu_btn_text_[0] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn1/text"); menu_btn_text_[1] = (CEGUI::ButtonBase*) wm.getWindow(parent->getName() + "teamselectmenu/btn2/text"); // add score to widget tree parent->addChildWindow(menu_window_); menu_window_->setVisible(false); registerCallbacks(); enableFloatingPointExceptions(); s_input_handler.registerInputCallback("Change Team", input_handler::SingleInputHandler(this, &GUITeamSelect::toggleShow), &fp_group_); }
void Application::setupCEGUI() { // CEGUI setup m_renderer = new CEGUI::OgreCEGUIRenderer(m_window, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, m_sceneManager); m_system = new CEGUI::System(m_renderer); CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme"); m_system->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow"); m_system->setDefaultFont((CEGUI::utf8*)"BlueHighway-12"); CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr(); CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Sheet"); float distanceBorder = 0.01; float sizeX = 0.2; float sizeY = 0.05; float posX = distanceBorder; float posY = distanceBorder; debugWindow = win->createWindow("TaharezLook/StaticText", "Widget1"); debugWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(posX, 0), CEGUI::UDim(posY, 0))); debugWindow->setSize(CEGUI::UVector2(CEGUI::UDim(sizeX, 0), CEGUI::UDim(sizeY, 0))); debugWindow->setText("Debug Info!"); sheet->addChildWindow(debugWindow); m_system->setGUISheet(sheet); }
_MEMBER_FUNCTION_IMPL(GUIElement, setParent) { const char * parent; sq_getstring(pVM, -1, &parent); CGUIFrameWindow * pWindow = sq_getinstance<CGUIFrameWindow *>(pVM); if(!pWindow) { sq_pushbool(pVM, false); return 1; } CEGUI::Window * pParentWindow = NULL; try { pParentWindow = g_pClient->GetGUI()->GetWindowManager()->getWindow(parent); } catch(CEGUI::UnknownObjectException &e) { (void)e; sq_pushbool(pVM, false); return 1; } pParentWindow->addChildWindow(pWindow); sq_pushbool(pVM, true); return 1; }
Dan::Dan(DanListener * listener):_time(-1.f),_callback(listener) { _win= CEGUI::WindowManager::getSingleton().loadWindowLayout("dan.layout"); _win->setAlwaysOnTop(true); _win->hide(); CEGUI::Window * f = CEGUI::WindowManager::getSingleton().getWindow("AnimalUI"); f->addChildWindow(_win); for(int i = 0; i < 10; i++) { std::string n = boost::lexical_cast<std::string>(i); LinePtr line(new DanLine()); for(int j=0;j<9; ++j) { //std::cout<<"Dan/Bg/Line0/Tt" + n + boost::lexical_cast<std::string>(j)<<std::endl; line->push_back(CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Line0/Tt" + n + boost::lexical_cast<std::string>(j))); } _lines.push_back(line); } }
bool CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage ) {GUCE_TRACE; CEGUI::Window* rootWindow = NULL; CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr(); GUCEF_DEBUG_LOG( 0, "Starting layout load for a GUI Form" ); try { // provide hacky access to the given data m_dummyArchive->AddResource( layoutStorage, "currentFile" ); // Now we can load the window layout from the given storage // Note that if CEGUI ever provides an interface to do this directly // clean up this mess !!! rootWindow = wmgr->loadWindowLayout( "currentFile" , m_widgetNamePrefix.C_String() , m_resourceGroupName.C_String() ); m_dummyArchive->ClearResourceList(); } catch ( Ogre::Exception& e ) { GUCEF_ERROR_LOG( 0, CString( "Ogre Exception while attempting to load form layout: " ) + e.getFullDescription().c_str() ); return false; } // Now that we completed loading lets see what we got from CEGUI if ( NULL != rootWindow ) { // Begin by providing a wrapper for the root window m_rootWindow = CreateAndHookWrapperForWindow( rootWindow ); if ( NULL != m_rootWindow ) { CString localWidgetName = m_rootWindow->GetName().SubstrToChar( '/', false ); m_widgetMap[ localWidgetName ] = m_rootWindow; WrapAndHookChildWindows( rootWindow ); // We will directly add the form as a child of the root for now CEGUI::Window* globalRootWindow = wmgr->getWindow( "root" ); if ( NULL != globalRootWindow ) { globalRootWindow->addChildWindow( rootWindow ); GUCEF_DEBUG_LOG( 0, "Successfully loaded a GUI Form layout" ); return true; } else { GUCEF_ERROR_LOG( 0, "Failed to add form as a child to the global \"root\" window" ); } } rootWindow->hide(); } GUCEF_DEBUG_LOG( 0, "Failed to loaded a GUI Form layout" ); return false; }
void McsHudGui::init() { CEGUI::MouseCursor::getSingleton().hide(); CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *sheet = wmgr.createWindow("DefaultWindow", "MCSHudDefault/DefaultHud"); CEGUI::Window *crosshair = wmgr.createWindow("Vanilla/StaticImage", "MCSHud/Crosshair"); crosshair->setProperty("Image", "set:HudImages image:cross"); crosshair->setSize(CEGUI::UVector2(CEGUI::UDim(0, 32), CEGUI::UDim(0, 32))); crosshair->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5f, -16), CEGUI::UDim(0.5f, -16))); crosshair->setProperty("BackgroundEnabled", "False"); crosshair->setProperty("FrameEnabled", "False"); mFpsText = wmgr.createWindow("Vanilla/StaticText", "MCSHud/FpsText"); mFpsText->setAlpha(0.6f); mFpsText->setText(""); mFpsText->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 5), CEGUI::UDim(0.0f, 5))); mFpsText->setSize(CEGUI::UVector2(CEGUI::UDim(0.4f, 0), CEGUI::UDim(0.04f, 0))); mFpsText->setProperty("BackgroundEnabled", "False"); mFpsText->setProperty("FrameEnabled", "False"); mPosText = wmgr.createWindow("Vanilla/StaticText", "MCSHud/PosText"); mPosText->setAlpha(0.6f); mPosText->setText(""); mPosText->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 5), CEGUI::UDim(0.04f, 5))); mPosText->setSize(CEGUI::UVector2(CEGUI::UDim(0.4f, 0), CEGUI::UDim(0.04f, 0))); mPosText->setProperty("BackgroundEnabled", "False"); mPosText->setProperty("FrameEnabled", "False"); mHitPosText = wmgr.createWindow("Vanilla/StaticText", "MCSHud/HitPosText"); mHitPosText->setAlpha(0.6f); mHitPosText->setText(""); mHitPosText->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 5), CEGUI::UDim(0.08f, 5))); mHitPosText->setSize(CEGUI::UVector2(CEGUI::UDim(0.4f, -5), CEGUI::UDim(0.04f, 0))); mHitPosText->setProperty("BackgroundEnabled", "False"); mHitPosText->setProperty("FrameEnabled", "False"); addFrameGraph(sheet); sheet->addChildWindow(crosshair); sheet->addChildWindow(mFpsText); sheet->addChildWindow(mPosText); sheet->addChildWindow(mHitPosText); CEGUI::System::getSingleton().setGUISheet(sheet); }
void GUISystem::FolderSelector::Show(const CEGUI::String& windowTitle, bool showEditbox, const CEGUI::String& editboxLabel) { bool success = false; OC_CEGUI_TRY; { CEGUI::Window* root = gGUIMgr.GetGUISheet(); mWindow = gGUIMgr.LoadSystemLayout("FolderSelector.layout", root->getName() + "/"); mWindow->setAlwaysOnTop(true); mWindow->setModalState(true); root->addChildWindow(mWindow); CEGUI::Window* frame = mWindow->getChild(root->getName() + "/FolderSelector/Frame"); frame->setText(windowTitle); mButtonOK = frame->getChild(root->getName() + "/FolderSelector/ButtonOK"); mButtonCancel = frame->getChild(root->getName() + "/FolderSelector/ButtonCancel"); mPathBox = frame->getChild(root->getName() + "/FolderSelector/PathBox"); mFolderList = static_cast<CEGUI::Listbox*>(frame->getChild(root->getName() + "/FolderSelector/FolderList")); mFolderList->setWantsMultiClickEvents(true); mEditbox = frame->getChild(root->getName() + "/FolderSelector/Editbox"); mEditbox->subscribeEvent(CEGUI::Editbox::EventKeyDown, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnEditboxKeyDown, this)); mButtonOK->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnButtonClicked, this)); mButtonCancel->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnButtonClicked, this)); mFolderList->subscribeEvent(CEGUI::Listbox::EventMouseDoubleClick, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnFolderListDoubleClicked, this)); CEGUI::Window* buttonCreateDirectory = frame->getChild(root->getName() + "/FolderSelector/ButtonCreateDirectory"); buttonCreateDirectory->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::FolderSelector::OnCreateDirectoryClicked, this)); if (!showEditbox) { mEditbox->hide(); frame->getChild(root->getName() + "/FolderSelector/EditboxLabel")->hide(); } else { frame->getChild(root->getName() + "/FolderSelector/EditboxLabel")->setText(editboxLabel); mEditbox->activate(); } UpdateFolderList(); success = true; } OC_CEGUI_CATCH; if (!success) { ocError << "Cannot show FolderSelector."; delete this; } }
void Game::createScene(void) { switch (state) { case 1: { Menu::createBackground(); myCEGUI::implimentingCEGUI(); Menu::startGame()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Game::start, this)); Menu::exitGame()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Game::quit, this)); Menu::stage2()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Game::stage2, this)); //Menu::FPS(); float avFPS; avFPS = 0;//mWindow->getAverageFPS(); //avFPS = mSceneMgr->getCurrentViewport()->getTarget()->getAverageFPS(); CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *sheet = wmgr.getWindow("CEGUIDemo/Sheet"); FPS = wmgr.createWindow("TaharezLook/Button", "CEGUIDemo/FPS"); char fps[20]; sprintf(fps, "FPS: %d", avFPS); FPS->setText(fps); FPS->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); FPS->setPosition(CEGUI::UVector2(CEGUI::UDim(0.85, 0), CEGUI::UDim(0.0, 0))); sheet->addChildWindow(FPS); CEGUI::System::getSingleton().setGUISheet(sheet); break; } case 2: { myCEGUI::implimentingCEGUI(); myCEGUI::createButton()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Game::quit, this)); myCEGUI::createMenuButton()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Game::menu, this)); TerrainLevel tl; tl.createLevel(); break; } case 3: { myCEGUI::implimentingCEGUI(); myCEGUI::createButton()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Game::quit, this)); myCEGUI::createMenuButton()->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Game::menu, this)); MeshLevels::createLevel(); break; } } }
void MenuState::createScene() { CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *window = wmgr.createWindow("DefaultWindow", "CEGUI/MenuWindow"); // title logo CEGUI::Window *si = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "TitlePng"); si->setSize(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.25, 0))); si->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.05, 0))); si->setProperty("Image","set:Title image:full_image"); si->setProperty("FrameEnabled", "False"); si->setProperty("BackgroundEnabled", "False"); window->addChildWindow(si); // new game button CEGUI::Window *new_game = wmgr.createWindow("TaharezLook/Button", "CEGUI/NewGameButton"); new_game->setText("Start Game"); new_game->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.15, 0))); new_game->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.34, 0))); window->addChildWindow(new_game); // how to play button CEGUI::Window *instructions = wmgr.createWindow("TaharezLook/Button", "CEGUI/InstructionsButton"); instructions->setText("How to Play"); instructions->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.15, 0))); instructions->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.53, 0))); window->addChildWindow(instructions); // quit button CEGUI::Window *quit = wmgr.createWindow("TaharezLook/Button", "CEGUI/QuitButton"); quit->setText("Exit Game"); quit->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.15, 0))); quit->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.72, 0))); window->addChildWindow(quit); CEGUI::System::getSingleton().setGUISheet(window); // event calls new_game->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MenuState::start, this)); instructions->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MenuState::instruction, this)); quit->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MenuState::quit, this)); }
CEGUI::Window * Records::_createRecordEntry(const std::string name, const int &points, const int &number) { CEGUI::Window *container = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow"); std::ostringstream tempStream; std::string pointsString = Ogre::StringConverter::toString(points); CEGUI::Window *nameText = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText"); nameText->setProperty("Text", "[colour='" + _configValue<std::string>("font_color_record") + "']" + name); nameText->setProperty("Font", _configValue<std::string>("font_record")); nameText->setProperty("UnifiedAreaRect", "{{0,0},{0,0},{1,0},{1,0}}"); CEGUI::Window *pointsText = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText"); pointsText->setProperty("Text", "[colour='" + _configValue<std::string>("font_color_record") + "']" + pointsString); pointsText->setProperty("Font", _configValue<std::string>("font_record")); pointsText->setProperty("UnifiedAreaRect", "{{0, 370},{0,0},{1,0},{1,0}}"); container->addChildWindow(nameText); container->addChildWindow(pointsText); container->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 275), CEGUI::UDim(0, -300 + number * 60))); return container; }
void GUIManager::LoadMainMenu() { CEGUI::ImagesetManager::getSingletonPtr()->createFromImageFile("mainMenuBG","background.tga"); //add background CEGUI::Window *mainMenu = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "mainMenu"); sheet->addChildWindow(mainMenu); mainMenu->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0))); mainMenu->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0))); mainMenu->setProperty("Image", "set:mainMenuBG image:full_image" ); mainMenu->setAlpha(1.0); CEGUI::PushButton* login = (CEGUI::PushButton*)CEGUI::WindowManager::getSingleton().createWindow("WindowsLook/Button"); mainMenu->addChildWindow(login); login->setArea(CEGUI::URect(CEGUI::UDim(0.2f,0), CEGUI::UDim(0.65f,0), CEGUI::UDim(0.3f,0), CEGUI::UDim(0.7f,0))); login->subscribeEvent(CEGUI::PushButton::EventActivated, CEGUI::Event::Subscriber(&GUIManager::HandleGameLoginClicked, this)); }
void Editor::EditorGUI::CreatePopupMenu() { mNewComponentPopupMenu = gPopupMgr->CreatePopupMenu("Editor/EditorViewport/Popup/NewComponent/AutoPopup"); for (size_t i = 0; i < EntitySystem::NUM_COMPONENT_TYPES; ++i) { const string& componentName = EntitySystem::GetComponentTypeName((EntitySystem::eComponentType)i); const CEGUI::String& componentMenuItemName = "Editor/EditorViewport/Popup/NewComponent/Component" + Utils::StringConverter::ToString(i); mNewComponentPopupMenu->addChildWindow(gPopupMgr->CreateMenuItem(componentMenuItemName, componentName, "", i)); } mPopupMenu = gPopupMgr->CreatePopupMenu("Editor/EditorViewport/Popup"); CEGUI::Window* newComponentItem = gPopupMgr->CreateMenuItem("Editor/EditorViewport/Popup/NewComponent", TR("new_component"), TR("new_component_hint")); newComponentItem->addChildWindow(mNewComponentPopupMenu); mPopupMenu->addChildWindow(newComponentItem); mPopupMenu->addChildWindow(gPopupMgr->CreateMenuItem("Editor/EditorViewport/Popup/DuplicateEntity", TR("hierarchy_duplicate"), TR("hierarchy_duplicate_hint"), PI_DUPLICATE_ENTITY)); mPopupMenu->addChildWindow(gPopupMgr->CreateMenuItem("Editor/EditorViewport/Popup/DeleteEntity", TR("hierarchy_delete"), TR("hierarchy_delete_hint"), PI_DELETE_ENTITY)); mPopupMenu->addChildWindow(gPopupMgr->CreateMenuItem("Editor/EditorViewport/Popup/CreatePrototype", TR("hierarchy_prototype"), TR("hierarchy_prototype_hint"), PI_CREATE_PROTOTYPE)); }
void Dan2::show(void) { if(BlackBoardSystem::getInstance().has(WheelEnum::SETUP_STR)) { CEGUI::Window * root = CEGUI::System::getSingleton().getGUISheet(); if(root) root->addChildWindow(_win); SetupInfoPtr setup = BlackBoardSystem::getInstance().read<SetupInfoPtr>(WheelEnum::SETUP_STR); for(size_t i=0; i< setup->size(); ++i) { setDan2Data(i, setup->at(i)); } } Orz::IInputManager::getSingleton().addKeyListener(this); _win->show(); _n = 0; redo(_n, _n); }
bool OnShopCityChildTabContentSelChanged(const CEGUI::EventArgs& e) { TabControl* tbc = WTabControl(WEArgs(e).window); if(tbc) { CEGUI::Window* tbcontent = tbc->getTabContentsAtIndex(tbc->getSelectedTabIndex()); if(tbcontent) { //把唯一ShopCityItemSet加到单前选中项上 CEGUI::Window* itemSet = GetWindow(SHOPCITY_ITEMSET_PAGE_NAME); tbcontent->addChildWindow(itemSet); //更新ItemSet的显示 FireUIEvent(SHOPCITY_ITEMSET_PAGE_NAME,SHOPCITY_ITEMSET_EVENT_UPDATE); //更新右搜索(筛选)菜单 FireUIEvent(SHOPCITY_SEARCH_RIGHTWND_NAME,SHOPCITY_SEARCHRIGHT_EVENT_MENUUPDATE_NAME); //更新左搜索(导购)菜单 FireUIEvent(SHOPCITY_SEARCH_LEFTWND_NAME,SHOPCITY_SEARCHLEFT_EVENT_MENUUPDATE_NAME); } } return true; }
void Dan::show(void) { Orz::IInputManager::getSingleton().addKeyListener(this); check(); refresh(); F5TableInterface * table = _table->queryInterface<F5TableInterface>(); _connection = table->refreshSigConnection(boost::bind(&Dan::refresh,this)); CEGUI::Window * win = CEGUI::System::getSingleton().getGUISheet(); if(win) { win->addChildWindow(_win); } _win->show(); CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->activate(); static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin"))->setValidationString("[0-9Xx]*"); static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin"))->setMaxTextLength(10); CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")-> subscribeEvent(CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber(&Dan::textAccepted, this)); }
void OgreWiiApp::setupCEGUI() { //mWindow = mRoot->getAutoCreatedWindow(); mRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr); mSystem = new CEGUI::System(mRenderer); CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme"); mSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow"); mSystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12"); CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr(); CEGUI::Window *sheet = winMgr->createWindow("DefaultGUISheet", "Vp/Sheet"); CEGUI::UVector2 buttonSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)); CEGUI::UVector2 checkboxSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)); CEGUI::UVector2 comboboxSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.15, 0)); CEGUI::UVector2 infoboxSize(CEGUI::UDim(0.5, 0.0), CEGUI::UDim(0.1, 0.0)); CEGUI::UVector2 controlboxSize(CEGUI::UDim(0.5, 0.0), CEGUI::UDim(0.5, 0.0)); CEGUI::UVector2 scrollSize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.025, 0)); float dy = 0.06f; float y = 0.01f; CEGUI::Window *win = winMgr->createWindow("TaharezLook/Editbox", "Vp/OscAddress"); win->setText(mAddress); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(buttonSize); sheet->addChildWindow(win); y+=dy; win = winMgr->createWindow("TaharezLook/Editbox", "Vp/OscPort"); win->setText(StringConverter::toString(mPort)); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(buttonSize); sheet->addChildWindow(win); y+=dy; win = winMgr->createWindow("TaharezLook/Button", "Vp/Reconnect"); win->setText("Reconnect"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(buttonSize); sheet->addChildWindow(win); y+=dy; win = winMgr->createWindow("TaharezLook/Checkbox", "Vp/FirstPersonView"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setText("First Person View"); win->setSize(checkboxSize); sheet->addChildWindow(win); y+=dy; win = winMgr->createWindow("TaharezLook/HorizontalScrollbar", "Vp/Scrollbar1"); win->setText("Scrollbar1"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(scrollSize); sheet->addChildWindow(win); y+=dy; win = winMgr->createWindow("TaharezLook/HorizontalScrollbar", "Vp/Scrollbar2"); win->setText("Scrollbar1"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(scrollSize); sheet->addChildWindow(win); y+=dy; win = winMgr->createWindow("TaharezLook/HorizontalScrollbar", "Vp/Scrollbar3"); win->setText("Scrollbar1"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(scrollSize); sheet->addChildWindow(win); // Snapshot button y+=dy; win = winMgr->createWindow("TaharezLook/Button", "Vp/SnapButton"); win->setText("Shapshot"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(buttonSize); sheet->addChildWindow(win); // Quit button y+=dy; win = winMgr->createWindow("TaharezLook/Button", "Vp/QuitButton"); win->setText("Quit"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( y, 0 ) ) ); win->setSize(buttonSize); sheet->addChildWindow(win); // Info txt box win = winMgr->createWindow("TaharezLook/StaticText", "Vp/TextBoxInfo"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.01f, 0 ), CEGUI::UDim( 0.85f, 0 ) ) ); win->setSize(infoboxSize); sheet->addChildWindow(win); // Info txt box win = winMgr->createWindow("TaharezLook/StaticText", "Vp/TextBoxAR"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.6f, 0 ), CEGUI::UDim( 0.85f, 0 ) ) ); win->setSize(infoboxSize); win->setVisible(true); sheet->addChildWindow(win); // Controls txt box /* win = winMgr->createWindow("TaharezLook/StaticText", "Vp/TextBoxControls"); win->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.5f, 0 ), CEGUI::UDim( 0.0f, 0 ) ) ); win->setSize(controlboxSize); sheet->addChildWindow(win); */ mSystem->setGUISheet(sheet); }
void SelectorHelper::SwitchToLevelSelectMenu(void) { recycleViewers(); CEGUI::WindowManager *wmgr = CEGUI::WindowManager::getSingletonPtr(); CEGUI::Window *levelSelectorWindow = wmgr->getWindow("Menu/LevelSelector"); if (CEGUI::System::getSingleton().getGUISheet()->getName().compare("Leaderboard") == 0) { CEGUI::System::getSingleton().setGUISheet(levelSelectorWindow); return; } // Pre-load windows LevelLoader *loader = LevelLoader::getSingleton(); CEGUI::Window *lsBack = wmgr->getWindow("LevelSelector/Back"); CEGUI::Window *lsPrev = wmgr->getWindow("LevelSelector/Prev"); CEGUI::Window *lsNext = wmgr->getWindow("LevelSelector/Next"); CEGUI::Window *lsButtons[8]; for (int i = 0; i < 8; i++) { std::stringstream ss; ss << "LevelSelector/" << i+1; lsButtons[i] = wmgr->getWindow(ss.str()); } lsPrev->removeEvent(CEGUI::PushButton::EventClicked); lsPrev->subscribeEvent(CEGUI::PushButton::EventClicked, &SelectorHelper::handleLSPrev); lsNext->removeEvent(CEGUI::PushButton::EventClicked); lsNext->subscribeEvent(CEGUI::PushButton::EventClicked, &SelectorHelper::handleLSNext); CEGUI::System::getSingleton().setGUISheet(levelSelectorWindow); // This variable ensures that viewers are only initiated once, then reused. static bool initViewers = false; // Load each level in level viewer int selectorEnd = selectorStart + 8; //(selectorRows*selectorColumns); for (int i = 0; i < 8; i++) { lsButtons[i]->setVisible(false); if (viewerPool.size() > i) { viewerPool[i]->window->setVisible(false); } } for (int i = selectorStart; i < selectorEnd && i < loader->levelNames.size(); i++) { LevelViewer *v; if (initViewers) { // Recycle your Level Viewers! if (viewerPool.empty()) break; v = viewerPool.back(); viewerPool.pop_back(); v->loadLevel(loader->levelNames[i].c_str()); v->window->setVisible(true); } else { v = new LevelViewer(OgreBallApplication::getSingleton()->mRenderer, loader->levelNames[i].c_str()); } levelSelectorWindow->addChildWindow(v->window); if(type_flag == TYPE_SINGLE_PLAYER || type_flag == TYPE_MULTI_HOST){ MenuActivity *activity = (MenuActivity*) OgreBallApplication::getSingleton()->activity; lsBack->removeEvent(CEGUI::PushButton::EventClicked); lsBack->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MenuActivity::SwitchToMainMenu, activity)); if (type_flag == TYPE_SINGLE_PLAYER) { v->window->removeEvent(CEGUI::PushButton::EventMouseClick); v->window->subscribeEvent(CEGUI::PushButton::EventMouseClick, CEGUI::Event::Subscriber(&MenuActivity::StartSinglePlayer, activity)); lsButtons[i % 8]->setVisible(true); lsButtons[i % 8]->removeEvent(CEGUI::PushButton::EventMouseClick); lsButtons[i % 8]->subscribeEvent(CEGUI::PushButton::EventMouseClick, &SelectorHelper::ShowLeaderboard); } else { v->window->removeEvent(CEGUI::PushButton::EventMouseClick); v->window->subscribeEvent(CEGUI::PushButton::EventMouseClick, CEGUI::Event::Subscriber(&MenuActivity::StartMultiPlayerHost, activity)); } } else if (type_flag == TYPE_MULTI_CHANGE) { HostPlayerActivity *activity = (HostPlayerActivity*) OgreBallApplication::getSingleton()->activity; v->window->removeEvent(CEGUI::PushButton::EventMouseClick); v->window->subscribeEvent(CEGUI::PushButton::EventMouseClick, CEGUI::Event::Subscriber(&HostPlayerActivity::handleLevelSelected, activity)); } v->setPositionPercent(0.05 + ((i%8)%selectorColumns)*0.9/selectorColumns, 0.2 + ((i%8)/selectorColumns)*0.6/selectorRows); levelViewers.push_back(v); } initViewers = true; }
bool StartMe::Application() { // Set up window transparency. Must happen _before_ system is opened! csRef<iGraphics2D> g2d = csQueryRegistry<iGraphics2D> (GetObjectRegistry ()); if (!g2d) return ReportError ("Failed to obtain canvas!"); natwin = scfQueryInterface<iNativeWindow> (g2d); if (natwin) { natwin->SetWindowTransparent (true); } // Open the main system. This will open all the previously loaded plug-ins. // i.e. all windows will be opened. if (!OpenApplication(GetObjectRegistry())) return ReportError("Error opening system!"); // The window is open, so lets make it disappear! if (natwin) { natwin->SetWindowDecoration (iNativeWindow::decoCaption, false); natwin->SetWindowDecoration (iNativeWindow::decoClientFrame, false); } // Now get the pointer to various modules we need. We fetch them // from the object registry. The RequestPlugins() call we did earlier // registered all loaded plugins with the object registry. g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry()); if (!g3d) return ReportError("Failed to locate 3D renderer!"); engine = csQueryRegistry<iEngine> (GetObjectRegistry()); if (!engine) return ReportError("Failed to locate 3D engine!"); vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry()); if (!vc) return ReportError("Failed to locate Virtual Clock!"); kbd = csQueryRegistry<iKeyboardDriver> (GetObjectRegistry()); if (!kbd) return ReportError("Failed to locate Keyboard Driver!"); loader = csQueryRegistry<iLoader> (GetObjectRegistry()); if (!loader) return ReportError("Failed to locate Loader!"); vfs = csQueryRegistry<iVFS> (GetObjectRegistry()); if (!vfs) return ReportError("Failed to locate VFS!"); confman = csQueryRegistry<iConfigManager> (GetObjectRegistry()); if (!confman) return ReportError("Failed to locate Config Manager!"); cegui = csQueryRegistry<iCEGUI> (GetObjectRegistry()); if (!cegui) return ReportError("Failed to locate CEGUI plugin"); // Initialize the CEGUI wrapper cegui->Initialize (); // Let the CEGUI plugin take care of the rendering by itself cegui->SetAutoRender (true); // Set the logging level cegui->GetLoggerPtr ()->setLoggingLevel(CEGUI::Informative); vfs->ChDir ("/cegui/"); // Load the 'ice' skin (which uses the Falagard skinning system) cegui->GetSchemeManagerPtr ()->create("ice.scheme"); cegui->GetSystemPtr ()->setDefaultMouseCursor("ice", "MouseArrow"); // Setup the fonts cegui->GetFontManagerPtr ()->createFreeTypeFont (FONT_NORMAL, 10, true, "/fonts/ttf/DejaVuSerif.ttf"); cegui->GetFontManagerPtr ()->createFreeTypeFont (FONT_NORMAL_ITALIC, 10, true, "/fonts/ttf/DejaVuSerif-Italic.ttf"); cegui->GetFontManagerPtr ()->createFreeTypeFont (FONT_TITLE, 15, true, "/fonts/ttf/DejaVuSerif-Bold.ttf"); cegui->GetFontManagerPtr ()->createFreeTypeFont (FONT_TITLE_ITALIC, 15, true, "/fonts/ttf/DejaVuSerif-BoldItalic.ttf"); CEGUI::WindowManager* winMgr = cegui->GetWindowManagerPtr (); // Load the CEGUI layout and set it as the root layout vfs->ChDir ("/data/startme/"); cegui->GetSchemeManagerPtr ()->create ("crystal.scheme"); cegui->GetSystemPtr ()->setGUISheet(winMgr->loadWindowLayout ("startme.layout")); // We need a View to the virtual world. view.AttachNew (new csView (engine, g3d)); LoadConfig (); CEGUI::Window* logo = winMgr->getWindow("Logo"); logo->subscribeEvent(CEGUI::Window::EventMouseClick, CEGUI::Event::Subscriber(&StartMe::OnLogoClicked, this)); ///TODO: Using 'EventMouseEntersArea' is more correct but is only available /// in 0.7.2+ logo->subscribeEvent(CEGUI::Window::EventMouseEnters, CEGUI::Event::Subscriber(&StartMe::OnEnterLogo, this)); logo->subscribeEvent(CEGUI::Window::EventMouseLeaves, CEGUI::Event::Subscriber(&StartMe::OnLeaveLogo, this)); vfs->ChDir ("/lib/startme"); CEGUI::Window* root = winMgr->getWindow("root"); for (size_t i = 0 ; i < demos.GetSize () ; i++) { demos[i].window = winMgr->createWindow("crystal/Icon"); demos[i].window->setSize(CEGUI::UVector2(CEGUI::UDim(0.0f, 128.0f), CEGUI::UDim(0.0f, 128.0f))); demos[i].window->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f), CEGUI::UDim(0.0f, 0.0f))); demos[i].window->setVisible(false); CEGUI::ImagesetManager* imsetmgr = cegui->GetImagesetManagerPtr(); if (!imsetmgr->isDefined(demos[i].image)) imsetmgr->createFromImageFile(demos[i].image, demos[i].image); std::string img = "set:"+std::string(demos[i].image)+" image:full_image"; demos[i].window->setProperty("Image", img); root->addChildWindow(demos[i].window); demos[i].window->subscribeEvent(CEGUI::Window::EventMouseClick, CEGUI::Event::Subscriber(&StartMe::OnClick, this)); } // Initialize the starting position of the demo wheel to a random value csRandomFloatGen frandomGenerator; position = frandomGenerator.Get (demos.GetSize () - 1); // Let the engine prepare everything engine->Prepare (); printer.AttachNew (new FramePrinter (object_reg)); // This calls the default runloop. This will basically just keep // broadcasting process events to keep the application going on. Run(); return true; }
/*********************************************************** initalize the box ***********************************************************/ void ContainerBox::Initialize(CEGUI::Window* Root) { try { _myBox = CEGUI::WindowManager::getSingleton().loadWindowLayout( "container.layout" ); Root->addChildWindow(_myBox); CEGUI::FrameWindow * frw = static_cast<CEGUI::FrameWindow *> ( CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame")); frw->subscribeEvent ( CEGUI::FrameWindow::EventCloseClicked, CEGUI::Event::Subscriber (&ContainerBox::HandleCancel, this)); static_cast<CEGUI::PushButton *> ( CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/OK"))->subscribeEvent ( CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber (&ContainerBox::HandleOk, this)); static_cast<CEGUI::PushButton *> ( CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/TakeAll"))->subscribeEvent ( CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber (&ContainerBox::HandleTakeAll, this)); static_cast<CEGUI::PushButton *> ( CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/Cancel"))->subscribeEvent ( CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber (&ContainerBox::HandleCancel, this)); CEGUI::Window* pane = CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/ConScrollable"); CEGUI::Window* tmpwindow; for(int i=0; i<_NB_BOX_CONTAINER_; ++i) { int x = i / 3; int y = i % 3; tmpwindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText"); tmpwindow->setArea(CEGUI::UDim(0,5+((float)_boxsize+2)*y), CEGUI::UDim(0,5+((float)_boxsize+2)*x), CEGUI::UDim(0, (float)_boxsize), CEGUI::UDim(0, (float)_boxsize)); pane->addChildWindow(tmpwindow); tmpwindow->subscribeEvent( CEGUI::Window::EventDragDropItemDropped, CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInContainer, this)); tmpwindow->setID(i); _cont_boxes.push_back(tmpwindow); } frw->show(); _myBox->hide(); frw->subscribeEvent(CEGUI::Window::EventKeyDown, CEGUI::Event::Subscriber (&ContainerBox::HandleEnterKey, this)); } catch(CEGUI::Exception &ex) { LogHandler::getInstance()->LogToFile(std::string("Exception init ContainerBox: ") + ex.getMessage().c_str()); } }
GUI::GUI(CEGUI::Event::Subscriber* spSub, CEGUI::Event::Subscriber* clientSub, CEGUI::Event::Subscriber* serverSub) { // Initialize CEGUI mRenderer = &CEGUI::OgreRenderer::bootstrapSystem(); // Set CEGUI resource groups CEGUI::Imageset::setDefaultResourceGroup("Imagesets"); CEGUI::Font::setDefaultResourceGroup("Fonts"); CEGUI::Scheme::setDefaultResourceGroup("Schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel"); CEGUI::WindowManager::setDefaultResourceGroup("Layouts"); //Set the CEGUI skin CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme"); CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow"); // create window manager and sheet CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *menuSheet = wmgr.createWindow("DefaultWindow", "GUI/Sheet"); // create buttons p1score = wmgr.createWindow("TaharezLook/Button", "UI/Score1"); p2score = wmgr.createWindow("TaharezLook/Button", "UI/Score2"); spBTN = wmgr.createWindow("TaharezLook/Button", "Menu/SingleButton"); clientBTN = wmgr.createWindow("TaharezLook/Button", "Menu/ClientButton"); serverBTN = wmgr.createWindow("TaharezLook/Button", "Menu/SeverButton"); // set buttons sizes and locations spBTN->setText("SINGLE PLAYER"); spBTN->setSize(CEGUI::UVector2(CEGUI::UDim(0.18, 0), CEGUI::UDim(0.05, 0))); spBTN->setPosition(CEGUI::UVector2(CEGUI::UDim(0.4,0), CEGUI::UDim(0.3, 0))); clientBTN->setText("CLIENT"); clientBTN->setSize(CEGUI::UVector2(CEGUI::UDim(0.18, 0), CEGUI::UDim(0.05, 0))); clientBTN->setPosition(CEGUI::UVector2(CEGUI::UDim(0.4,0), CEGUI::UDim(0.4, 0))); serverBTN->setText("SERVER"); serverBTN->setSize(CEGUI::UVector2(CEGUI::UDim(0.18, 0), CEGUI::UDim(0.05, 0))); serverBTN->setPosition(CEGUI::UVector2(CEGUI::UDim(0.4,0), CEGUI::UDim(0.5, 0))); p1score->setText("PLAYER 1"); p1score->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); p2score->setText("PLAYER 2"); p2score->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); p2score->setPosition(CEGUI::UVector2(CEGUI::UDim(0.85,0), CEGUI::UDim(0, 0))); // find the hostname of this machine char hostname[1024]; hostname[1023] = '\0'; gethostname(hostname, 1023); // create text fields for IP addresses and ports serverIPBox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox","SIP")); serverIPBox->setSize(CEGUI::UVector2(CEGUI::UDim(0.15,0), CEGUI::UDim(0.05,0))); serverIPBox->setPosition(CEGUI::UVector2(CEGUI::UDim(0.32,0), CEGUI::UDim(0.65,0))); serverIPBox->setText(hostname); serverPortBox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox","SPORT")); serverPortBox->setSize(CEGUI::UVector2(CEGUI::UDim(0.15,0), CEGUI::UDim(0.05,0))); serverPortBox->setPosition(CEGUI::UVector2(CEGUI::UDim(0.52,0), CEGUI::UDim(0.65,0))); serverPortBox->setText("55554"); spBTN->subscribeEvent(CEGUI::PushButton::EventClicked, spSub); clientBTN->subscribeEvent(CEGUI::PushButton::EventClicked, clientSub); serverBTN->subscribeEvent(CEGUI::PushButton::EventClicked, serverSub); // add buttons to sheet menuSheet->addChildWindow(spBTN); menuSheet->addChildWindow(clientBTN); menuSheet->addChildWindow(serverBTN); menuSheet->addChildWindow(p1score); menuSheet->addChildWindow(p2score); menuSheet->addChildWindow(serverIPBox); menuSheet->addChildWindow(serverPortBox); CEGUI::System::getSingleton().setGUISheet(menuSheet); }
void World::Init() { using namespace Ogre; SceneManager* sm = m_pRenderSystem->m_pSceneMgr; Camera* cam = m_pRenderSystem->m_pMainCamera; m_pSceneQuery = sm->createAABBQuery(AxisAlignedBox()); m_pRaySceneQuery = sm->createRayQuery(Ray()); m_pRaySceneQuery->setSortByDistance(true); Ogre::MovableObject::setDefaultQueryFlags(eQueryType_Default); m_cameraMan = new OgreBites::SdkCameraMan(cam); m_cameraMan->setStyle(OgreBites::CS_FREELOOK); //RTS锁死视角 cam->setPosition(0, 24, 0); cam->lookAt(0, 0, 8); //cam->setFOVy(Degree(30)); //初始化行为库 aiBehaviorTreeTemplateManager& btMgr = aiBehaviorTreeTemplateManager::GetSingleton(); btMgr.AddBehavior("Idle", new aiBehaviorIdle); btMgr.AddBehavior("MoveToEnemyBase", new aiBehaviorMoveToEnemyBase); //加载所有行为树模板 btMgr.LoadAll(); //测试两个AI m_player[eGameRace_Terran] = new FactionAI(eGameRace_Terran); m_player[eGameRace_Zerg] = new FactionAI(eGameRace_Zerg); m_player[eGameRace_Terran]->SetEnemy(m_player[eGameRace_Zerg]); m_player[eGameRace_Zerg]->SetEnemy(m_player[eGameRace_Terran]); m_player[eGameRace_Terran]->SetTeamColor(COLOR::Blue); m_player[eGameRace_Zerg]->SetTeamColor(COLOR::Red); GameDataDefManager::GetSingleton().LoadAllData(); //初始化Recast库 OgreRecastConfigParams recastParams = OgreRecastConfigParams(); recastParams.setCellSize(1); recastParams.setCellHeight(0.16f); recastParams.setAgentMaxSlope(15); recastParams.setAgentHeight(1.5f); recastParams.setAgentMaxClimb(0.5f); recastParams.setAgentRadius(0.4f); recastParams.setEdgeMaxLen(2); recastParams.setEdgeMaxError(1.3f); recastParams.setVertsPerPoly(6); recastParams.setRegionMinSize(2); recastParams.setRegionMergeSize(3); recastParams.setDetailSampleDist(6); recastParams.setDetailSampleMaxError(1); m_pRecast = new OgreRecast(sm, recastParams); m_pDetourTileCache = new OgreDetourTileCache(m_pRecast); //加载编辑器导出的导航网格数据 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource( "NavMesh.Bin", "General", false); assert(m_pDetourTileCache->loadAll(stream)); //m_pDetourTileCache->drawNavMesh(); //初始化Detour寻路库 m_pDetourCrowd = new OgreDetourCrowd(m_pRecast); g_Environment.m_pRecast = m_pRecast; g_Environment.m_pCrowd = m_pDetourCrowd; //加载测试场景 m_pTestScene = new Kratos::Scene(); m_pTestScene->Load("MyStarCraft.Scene", "General", this); //UI for test Ogre::Entity* pEntConsole = m_pRenderSystem->CreateEntityWithTangent("ConsoleTerran_0.mesh", sm); pEntConsole->setRenderQueueGroup(Ogre::RENDER_QUEUE_WORLD_GEOMETRY_2); pEntConsole->setCastShadows(false); m_pUISceneNode1 = sm->getRootSceneNode()->createChildSceneNode("UIConsoleNode"); m_pUISceneNode1->attachObject(pEntConsole); m_pConsoleAnim1 = pEntConsole->getAnimationState("Birth"); assert(m_pConsoleAnim1); (const_cast<Ogre::AxisAlignedBox&>(pEntConsole->getMesh()->getBounds())).setInfinite(); pEntConsole = m_pRenderSystem->CreateEntityWithTangent("ConsoleTerran_1.mesh", sm); pEntConsole->setRenderQueueGroup(Ogre::RENDER_QUEUE_WORLD_GEOMETRY_2); pEntConsole->setCastShadows(false); m_pUISceneNode2 = m_pUISceneNode1->createChildSceneNode("InfoPanelNode"); m_pUISceneNode2->attachObject(pEntConsole); m_pConsoleAnim2 = pEntConsole->getAnimationState("Birth"); assert(m_pConsoleAnim2); (const_cast<Ogre::AxisAlignedBox&>(pEntConsole->getMesh()->getBounds())).setInfinite(); pEntConsole = m_pRenderSystem->CreateEntityWithTangent("ConsoleTerran_2.mesh", sm); pEntConsole->setRenderQueueGroup(Ogre::RENDER_QUEUE_WORLD_GEOMETRY_2); pEntConsole->setCastShadows(false); m_pUISceneNode3 = m_pUISceneNode1->createChildSceneNode("CmdPanelNode"); m_pUISceneNode3->attachObject(pEntConsole); (const_cast<Ogre::AxisAlignedBox&>(pEntConsole->getMesh()->getBounds())).setInfinite(); pEntConsole = m_pRenderSystem->CreateEntityWithTangent("ConsoleProtoss_6.mesh", sm); pEntConsole->setRenderQueueGroup(Ogre::RENDER_QUEUE_WORLD_GEOMETRY_2); pEntConsole->setCastShadows(false); m_pUISceneNode4 = m_pUISceneNode1->createChildSceneNode("PortraitPanelNode"); m_pUISceneNode4->attachObject(pEntConsole); (const_cast<Ogre::AxisAlignedBox&>(pEntConsole->getMesh()->getBounds())).setInfinite(); m_cmdPanel->Init(); m_infoPanel->Init(); m_portraitPanel->Init(); CEGUI::WindowManager& wndMgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window* pRoot = wndMgr.getWindow("Root"); assert(pRoot); GUIMANAGER.SetGUISheet(pRoot); pRoot->addChildWindow(wndMgr.getWindow("InfoPanelFrame")); }
/*********************************************************** add an item inside the container ***********************************************************/ std::pair<CEGUI::Window*, CEGUI::Window*> ContainerBox::AddInventoryItem(long Id, int number, CEGUI::Window* parent, bool tocontainer) { CEGUI::Window* tmp = CEGUI::WindowManager::getSingleton().createWindow("DragContainer"); tmp->setArea(CEGUI::UDim(0,0), CEGUI::UDim(0,0), CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)); tmp->setID(Id); CEGUI::Window* tmp2 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage"); tmp2->setArea(CEGUI::UDim(0,5.0f), CEGUI::UDim(0,12.0f), CEGUI::UDim(0, (float)_boxsize-10.0f), CEGUI::UDim(0, (float)_boxsize-20.0f)); std::string imagesetname = ImageSetHandler::GetInstance()->GetInventoryImage(Id); tmp2->setProperty("Image", "set:" + imagesetname + " image:full_image"); tmp2->setProperty("MousePassThroughEnabled", "True"); CEGUI::Window* tmp3 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText"); tmp3->setArea(CEGUI::UDim(0,2), CEGUI::UDim(0,4), CEGUI::UDim(1, -1), CEGUI::UDim(0, 14)); tmp3->setProperty("FrameEnabled", "False"); tmp3->setProperty("BackgroundEnabled", "False"); tmp3->setProperty("MousePassThroughEnabled", "True"); tmp3->setAlwaysOnTop(true); tmp3->setProperty("Font" , "contourfont"); std::stringstream strs; strs<<number; tmp3->setText(strs.str().c_str()); if(tocontainer) tmp3->setID(3); else tmp3->setID(2); CEGUI::String tmpstr((const unsigned char *)InventoryHandler::getInstance()->GetItemDescription(Id).c_str()); tmp->setProperty("Tooltip", tmpstr); tmp->addChildWindow(tmp2); tmp->addChildWindow(tmp3); parent->addChildWindow(tmp); tmp->subscribeEvent( CEGUI::Window::EventMouseEnters, CEGUI::Event::Subscriber(&ContainerBox::HandleInventoryEnter, this)); if(tocontainer) { tmp->subscribeEvent( CEGUI::Window::EventDragDropItemDropped, CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInContainerItem, this)); tmp->subscribeEvent (CEGUI::Window::EventMouseClick, CEGUI::Event::Subscriber (&ContainerBox::HandleContainerItemClicked, this)); } else { tmp->subscribeEvent( CEGUI::Window::EventDragDropItemDropped, CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInInventoryItem, this)); tmp->subscribeEvent (CEGUI::Window::EventMouseClick, CEGUI::Event::Subscriber (&ContainerBox::HandleInventoryItemClicked, this)); } return std::make_pair<CEGUI::Window*, CEGUI::Window*>(tmp, tmp3); }
llm::Menu::Menu() { m_pSceneManager = llm::Application::getInstance()->root()->createSceneManager( "DefaultSceneManager", "Menu" ); m_pCamera = m_pSceneManager->createCamera( "Camera" ); m_pCamera->setNearClipDistance(5); ///---------initialisation CEGUI ----------- CEGUI::OgreRenderer::bootstrapSystem(); //Chargement des ressources Ogre::ResourceGroupManager& rgm = Ogre::ResourceGroupManager::getSingleton(); rgm.createResourceGroup("imagesets"); rgm.createResourceGroup("fonts"); rgm.createResourceGroup("layouts"); rgm.createResourceGroup("schemes"); rgm.createResourceGroup("looknfeels"); rgm.addResourceLocation( "../res/CEGUI/schemes/", "FileSystem", "Schemes"); rgm.addResourceLocation( "../res/CEGUI/imagesets/", "FileSystem", "Imagesets"); rgm.addResourceLocation( "../res/CEGUI/fonts/", "FileSystem", "Fonts"); rgm.addResourceLocation( "../res/CEGUI/layouts/", "FileSystem", "Layouts"); rgm.addResourceLocation( "../res/CEGUI/looknfeel/", "FileSystem", "LookNFeel"); rgm.initialiseAllResourceGroups(); //Linkage des ressources avec CEGUI CEGUI::Imageset::setDefaultResourceGroup("Imagesets"); CEGUI::Font::setDefaultResourceGroup("Fonts"); CEGUI::Scheme::setDefaultResourceGroup("Schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel"); CEGUI::WindowManager::setDefaultResourceGroup("Layouts"); //Définition CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme"); CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow"); CEGUI::MouseCursor::getSingleton().setImage( CEGUI::System::getSingleton().getDefaultMouseCursor()); CEGUI::ImagesetManager::getSingleton().createFromImageFile("BackgroundImage","MenuBackground.tga"); CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton(); llm::Application* app = llm::Application::getInstance(); /******* Menu ********/ CEGUI::Window *Menu = wmgr.createWindow("DefaultWindow", "Menu"); //conteneur CEGUI::System::getSingleton().setGUISheet(Menu);//Linkage du conteneur a CEGUI /******StartMenu*****/ CEGUI::Window *startMenu = wmgr.createWindow("TaharezLook/StaticImage", "StartMenu/Sheet"); //conteneur startMenu->setPosition( CEGUI::UVector2( CEGUI::UDim( 0, 0 ), CEGUI::UDim( 0, 0 ) ) ); startMenu->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0))); startMenu->setProperty( "Image", "set:BackgroundImage image:full_image" ); Menu->addChildWindow(startMenu); CEGUI::Window *options = wmgr.createWindow("TaharezLook/OptionsButton", "StartMenu/OptionsButton"); //quit->setText("Options"); options->setPosition(CEGUI::UVector2( CEGUI::UDim( 0.2f, 0 ), CEGUI::UDim( 0.8f, 0 ) ) ); options->setSize(CEGUI::UVector2(CEGUI::UDim(0.18, 0), CEGUI::UDim(0.16, 0))); startMenu->addChildWindow(options);//intégration du bouton dans le conteneur CEGUI::Window *start = wmgr.createWindow("TaharezLook/PlayButton", "StartMenu/StartButton"); //bouton //start->setText("Start"); start->setPosition(CEGUI::UVector2( CEGUI::UDim( 0.4f, 0 ), CEGUI::UDim( 0.75f, 0 ) ) ); start->setSize(CEGUI::UVector2(CEGUI::UDim(0.2, 0), CEGUI::UDim(0.19f, 0))); startMenu->addChildWindow(start);//intégration du bouton dans le conteneur CEGUI::Window *quitStart = wmgr.createWindow("TaharezLook/QuitButton", "StartMenu/QuitButton"); //bouton //quit->setText("Quit"); quitStart->setPosition(CEGUI::UVector2( CEGUI::UDim( 0.62f, 0 ), CEGUI::UDim( 0.8f, 0 ) ) ); quitStart->setSize(CEGUI::UVector2(CEGUI::UDim(0.18, 0), CEGUI::UDim(0.16, 0))); startMenu->addChildWindow(quitStart);//intégration du bouton dans le conteneur wmgr.getWindow("StartMenu/StartButton")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&llm::Application::startGame, app));//event du bouton wmgr.getWindow("StartMenu/QuitButton")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&llm::Application::quit, app));//event du bouton /******PauseMenu*****/ CEGUI::Window *PauseMenu = wmgr.createWindow("DefaultWindow", "PauseMenu/Sheet"); //conteneur Menu->addChildWindow(PauseMenu); CEGUI::Window *continued = wmgr.createWindow("TaharezLook/Button", "PauseMenu/ContinueButton"); //bouton continued->setText("Continue"); continued->setPosition(CEGUI::UVector2( CEGUI::UDim( 0.42f, 0 ), CEGUI::UDim( 0.40f, 0 ) ) ); continued->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); PauseMenu->addChildWindow(continued);//intégration du bouton dans le conteneur CEGUI::Window *reset = wmgr.createWindow("TaharezLook/Button", "PauseMenu/ResetButton"); //bouton reset->setText("Reset"); reset->setPosition(CEGUI::UVector2( CEGUI::UDim( 0.42f, 0 ), CEGUI::UDim( 0.50f, 0 ) ) ); reset->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); PauseMenu->addChildWindow(reset);//intégration du bouton dans le conteneur CEGUI::Window *quitPause = wmgr.createWindow("TaharezLook/Button", "PauseMenu/QuitButton"); //bouton quitPause->setText("Quit"); quitPause->setPosition(CEGUI::UVector2( CEGUI::UDim( 0.42f, 0 ), CEGUI::UDim( 0.60f, 0 ) ) ); quitPause->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); PauseMenu->addChildWindow(quitPause);//intégration du bouton dans le conteneur wmgr.getWindow("PauseMenu/ContinueButton")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&llm::Application::pause, app));//event du bouton wmgr.getWindow("PauseMenu/ResetButton")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&llm::Application::reset, app));//event du bouton wmgr.getWindow("PauseMenu/QuitButton")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&llm::Application::quit, app));//event du bouton desactive(); }
CEGUI::String LinkButtonParser::Parse(const CEGUI::String &str) { std::string szStr = CEGUIStringToAnsiChar( str ); size_t parentWinPos,IDPos,TextPos,ColorPos,endPos; parentWinPos = IDPos = TextPos = ColorPos = endPos = CEGUI::String::npos; char ParentWinName[128] = ""; char LinkID[32] = ""; char LinkText[128] = ""; char ColorVal[32] = ""; parentWinPos = str.find("WIN:"); IDPos = str.find("ID:"); TextPos = str.find("TEXT:"); ColorPos = str.find("COLOR:"); std::string wndName("LinkBtn_"),temp; static DWORD LinkWndCounter = 0; wndName += CEGUI::PropertyHelper::intToString(LinkWndCounter++).c_str(); CEGUI::Window *linkWnd = 0; if (CEGUI::WindowManager::getSingleton().isWindowPresent(wndName) == false) { linkWnd = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button",wndName); linkWnd->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&LinkButtonParser::OnLinkBtnClicked,this)); //解析父窗口 if (parentWinPos != CEGUI::String::npos) { temp = szStr.substr(parentWinPos+5); endPos = temp.find("'"); strcpy_s<128>(ParentWinName,temp.substr(0,endPos).c_str()); CEGUI::Window *pParentWnd = CEGUI::WindowManager::getSingleton().getWindow(ParentWinName); pParentWnd->addChildWindow(linkWnd); } //解析ID if (IDPos != CEGUI::String::npos) { temp = szStr.substr(IDPos+3); endPos = temp.find(" "); strcpy_s<32>(LinkID,temp.substr(0,endPos).c_str()); LinkMap[linkWnd] = LinkID; } //解析链接按钮文本 if (TextPos != CEGUI::String::npos) { temp = szStr.substr(TextPos+6); endPos = temp.find("'"); strcpy_s<128>(LinkText,temp.substr(0,endPos).c_str()); float fWidth = linkWnd->getFont()->getTextExtent(LinkText); float fheight = linkWnd->getFont()->getFontHeight(); linkWnd->setSize(CEGUI::UVector2(cegui_absdim(fWidth),cegui_absdim(fheight))); //解析链接按钮文本的颜色 if (ColorPos != CEGUI::String::npos) { temp = szStr.substr(ColorPos+6); endPos = temp.find(" "); strcpy_s(ColorVal,temp.substr(0,endPos).c_str()); temp = "[COLOR "; temp += ColorVal; temp += "]"; temp += CEGUI::String(LinkText).c_str(); linkWnd->setText(ToCEGUIString(temp.c_str())); } else linkWnd->setText(ToCEGUIString(LinkText)); } } return wndName; }
void GameState::createScene() { graphics = new Graphics(m_pSceneMgr); physics = new Physics(graphics); graphics->setPhysics(physics); physics->initialize(); PenguinNode = m_pSceneMgr->getSceneNode("penguin"); m_pSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8); // Create a snowstorm Ogre::ParticleSystem* snow = m_pSceneMgr->createParticleSystem("snow", "Examples/Snow"); Ogre::SceneNode* sNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("snowNode"); sNode->translate(0, 1200, 2000); sNode->attachObject(snow); snow->fastForward(100); CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *gameWindow = wmgr.createWindow("DefaultWindow", "CEGUI/GameGUI"); // penguin portrait face = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "FacePng"); face->setSize(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.13, 0))); face->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0))); face->setProperty("Image","set:Face image:full_image"); face->setProperty("FrameEnabled", "False"); face->setProperty("BackgroundEnabled", "False"); gameWindow->addChildWindow(face); // life life = wmgr.createWindow("TaharezLook/StaticText", "CEGUI/Life"); stringstream s; s << physics->getLives(); life->setText("x"+s.str()); life->setSize(CEGUI::UVector2(CEGUI::UDim(0.04, 0), CEGUI::UDim(0.05, 0))); life->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08, 0), CEGUI::UDim(0.048, 0))); life->setProperty("FrameEnabled", "False"); life->setProperty("BackgroundEnabled", "False"); // life->setProperty("Font", "Jura-18"); gameWindow->addChildWindow(life); // health bar for certain stages hp = 1.0f; showHealth = false; health = wmgr.createWindow("TaharezLook/ProgressBar", "CEGUI/Health"); health->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.04, 0))); health->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08, 0), CEGUI::UDim(0.01, 0))); health->setProperty("Visible", "False"); gameWindow->addChildWindow(health); // Pause menu pauseWindow = wmgr.createWindow("TaharezLook/StaticText", "CEGUI/PauseWindow"); pauseWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0.4, 0), CEGUI::UDim(0.35, 0))); pauseWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0.3, 0), CEGUI::UDim(0.35, 0))); pauseWindow->setProperty("Visible", "False"); gameWindow->addChildWindow(pauseWindow); CEGUI::Window *ret = wmgr.createWindow("TaharezLook/Button", "CEGUI/ReturnToGameButton"); ret->setText("Resume Game"); ret->setSize(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.2, 0))); ret->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.25, 0))); pauseWindow->addChildWindow(ret); CEGUI::Window *bac = wmgr.createWindow("TaharezLook/Button", "CEGUI/BackToTitleButton"); bac->setText("Back to Title"); bac->setSize(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.2, 0))); bac->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.55, 0))); pauseWindow->addChildWindow(bac); CEGUI::System::getSingleton().setGUISheet(gameWindow); // event calls ret->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GameState::returnToGame, this)); bac->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GameState::backToTitle, this)); }