bool GUIManager::handleDSActivation ( CEGUI::EventArgs const & e ) { CEGUI::Window *tab = static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent(); CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0)); ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem()); if (item != NULL) { DataManager *dm = static_cast<DataManager *>(item->getUserData()); CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2)); std::vector<unsigned int> const & dims = dm->getDimensions(); unsigned int dim = dims[int(sb->getScrollPosition()*(dims.size()-1))]; float scrollPos = sb->getScrollPosition(); dm->activate(dim); // Enable global scrollbar CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton(); sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider")); sb->enable(); CEGUI::WindowEventArgs w(sb); sb->fireEvent(CEGUI::Scrollbar::EventScrollPositionChanged, w); // Set the global scrollbar to the right position. sb->setScrollPosition(scrollPos); CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText"); desc->show(); } // TODO handle else-error return true; }
bool GUIManager::handleOptionsVisibility ( CEGUI::EventArgs const & ) { CEGUI::Window *dsFrame = CEGUI::WindowManager::getSingleton().getWindow( "Sheet/DatasetFrame"); std::string prop = dsFrame->getProperty("Visible").c_str(); if (prop == "False") dsFrame->show(); else dsFrame->hide(); return true; }
/*********************************************************** refreshthe gui ***********************************************************/ void GameGUI::Refresh() { _cb.Show();_cb.Show(); _comb.Show();_comb.Show(); _telb.Show();_telb.Show(); _invb.Show();_invb.Show(); _shortb.Show();_shortb.Show(); _containerb.Refresh(); _invb.Refresh(); _shortb.Refresh(); CEGUI::Window * win = CEGUI::WindowManager::getSingleton().getWindow("PlayerName"); win->hide(); win->show(); }
//----------------------------------------------------------------------------- bool MyGUIManager::loadWindow(const std::string& layoutName) { CEGUI::Window *guiSheet; // 检测给定layout的文件是否加载,没有加载则加载 if(!getGUIWindowManager()->isWindowPresent(layoutName)) { // 从 .layout脚本文件读取一个UI布局设计,并将其放置到GUI资源组中。 guiSheet = getGUIWindowManager()->loadWindowLayout(layoutName + ".layout"); } else { // 如果已经加载则直接显示 guiSheet = getGUIWindowManager()->getWindow(layoutName); } // 接下来我们告诉CEGUI显示哪份UI布局。当然我们可以随时更换显示的UI布局。 mGUISystem->setGUISheet(guiSheet); //显示UI布局 guiSheet->show(); return true; }
CEGUI::Window* TestAARHUD::CreateText(const std::string& name, CEGUI::Window* parent, const std::string& text, float x, float y, float width, float height) { CEGUI::WindowManager* wm = CEGUI::WindowManager::getSingletonPtr(); // create base window and set our default attribs CEGUI::Window* result = wm->createWindow("WindowsLook/StaticText", name); parent->addChildWindow(result); result->setText(text); result->setPosition(CEGUI::UVector2(cegui_absdim(x), cegui_absdim(y))); result->setSize(CEGUI::UVector2(cegui_absdim(width), cegui_absdim(height))); result->setProperty("FrameEnabled", "false"); result->setProperty("BackgroundEnabled", "false"); result->setHorizontalAlignment(CEGUI::HA_LEFT); result->setVerticalAlignment(CEGUI::VA_TOP); // set default color to white result->setProperty("TextColours", CEGUI::PropertyHelper::colourToString(CEGUI::colour(1.0f, 1.0f, 1.0f))); result->show(); return result; }
bool GameInputHandler::keyPressed(const OIS::KeyEvent &evt) { CEGUIInputHandler::keyPressed(evt); handleCommonKeyboardEvents(evt); if (game.getSubState() != SUBST_EDITOR) return true; OIS::KeyCode ch = evt.key; if (ch == OIS::KC_P) { // Switch to player mode game.createPlayer(camera->getDerivedPosition()); } else if (ch == OIS::KC_I) { // Blend interface in/out CEGUI::Window* guiPage = windowManager.getPage("Editor"); if (guiPage->isVisible()) guiPage->hide(); else guiPage->show(); } else if (ch == OIS::KC_M) { // Output camera position and orientation to log /*string str = "INFO: position=\"" + StringConverter::toString(game.cameraNode->getPosition()) + "\"" + " yawOrientation=\"" + StringConverter::toString(game.cameraYawNode->getOrientation()) + "\"" + " pitchOrientation=\"" + StringConverter::toString(game.cameraPitchNode->getOrientation()) + "\""; */ string str = "INFO: position=\"" + StringConverter::toString(game.cameraNode->getPosition()) + "\"" + " yaw=\"" + StringConverter::toString(game.cameraYawNode->getOrientation().getYaw(false)) + "\"" + " pitch=\"" + StringConverter::toString(game.cameraPitchNode->getOrientation().getPitch(false)) + "\"" + " roll=\"" + StringConverter::toString(game.cameraRollNode->getOrientation().getRoll(false)) + "\""; LogManager::getSingleton().logMessage(str.c_str(), LML_CRITICAL); } else if (ch == OIS::KC_E) { // Place objects game.spawnObject(CEGUI::EventArgs()); } else if (evt.key == OIS::KC_O) { // Toggle polygon mode camera->setPolygonMode((PolygonMode)((camera->getPolygonMode() % 3) + 1)); if (camera->getPolygonMode() == PM_SOLID) vp->setClearEveryFrame(true, FBT_DEPTH); else vp->setClearEveryFrame(true, FBT_COLOUR | FBT_DEPTH); } if (objectManager.getEditObjects()) { if (ch == OIS::KC_G) objectManager.setEditMode(EDITMODE_GRAB); else if (ch == OIS::KC_R) objectManager.setEditMode(EDITMODE_ROTATE); else if (ch == OIS::KC_T) objectManager.setEditMode(EDITMODE_SCALE); else if (ch == OIS::KC_X) objectManager.setEditDirection(Vector3(1, 0, 0)); else if (ch == OIS::KC_Y) objectManager.setEditDirection(Vector3(0, 1, 0)); else if (ch == OIS::KC_Z) objectManager.setEditDirection(Vector3(0, 0, 1)); } return true; }