void PropertiesPanelView::update(MyGUI::WidgetPtr _current_widget) { current_widget = _current_widget; if (nullptr == current_widget) current_widget_rectangle->setVisible(false); else { MyGUI::LayerManager::getInstance().upLayerItem(current_widget); MyGUI::IntCoord coord = current_widget->getCoord(); MyGUI::WidgetPtr parent = current_widget->getParent(); if (nullptr != parent) { // если выбрали виджет на табе, то подн¤ть лист таба if (parent->getTypeName() == "Sheet" || parent->getTypeName() == MyGUI::TabItem::getClassTypeName()) { MyGUI::TabPtr tab = parent->getParent()->castType<MyGUI::Tab>(); MyGUI::SheetPtr sheet = parent->castType<MyGUI::Sheet>(); tab->setItemSelected(sheet); } // если выбрали лист таба, то подн¤ть лист таба if (current_widget->getTypeName() == "Sheet" || current_widget->getTypeName() == MyGUI::TabItem::getClassTypeName()) { MyGUI::TabPtr tab = parent->castType<MyGUI::Tab>(); MyGUI::SheetPtr sheet = current_widget->castType<MyGUI::Sheet>(); tab->setItemSelected(sheet); } coord = current_widget->getAbsoluteCoord(); } current_widget_rectangle->setVisible(true); current_widget_rectangle->setCoord(coord); MyGUI::InputManager::getInstance().setKeyFocusWidget(current_widget_rectangle); } // delete all previous properties for (std::vector<MyGUI::StaticTextPtr>::iterator iter = propertiesText.begin(); iter != propertiesText.end(); ++iter) (*iter)->setVisible(false); for (MyGUI::VectorWidgetPtr::iterator iter = propertiesElement.begin(); iter != propertiesElement.end(); ++iter) (*iter)->setVisible(false); if (nullptr == _current_widget) { mMainWidget->setVisible(false); } else { mMainWidget->setVisible(true); pairs_counter = 0; mPanelMainProperties->update(_current_widget); mPanelTypeProperties->update(_current_widget, PanelProperties::TYPE_PROPERTIES); mPanelGeneralProperties->update(_current_widget, PanelProperties::WIDGET_PROPERTIES); mPanelEvents->update(_current_widget, PanelProperties::EVENTS); mPanelItems->update(_current_widget); mPanelUserData->update(_current_widget); } }
bool GUIMessageLayout::Load() { bool res = GUILayout::Load(); MyGUI::ButtonPtr button; MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui(); button = gui->findWidget<MyGUI::Button>("MessageButtonOK"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &GUIMessageLayout::mousePressed); MyGUI::WidgetPtr widget = Widgets.front(); widget->setPosition(gui->getViewWidth()/2-widget->getWidth()/2,gui->getViewHeight()/2-widget->getHeight()/2); return res; }
void MultiList::notifyButtonClick(MyGUI::WidgetPtr _widget) { if (_widget->_getInternalData() == mSortColumnIndex) { mSortUp = !mSortUp; redrawButtons(); // если было недосортированно то сортируем if (mIsDirtySort) sortList(); flipList(); } else { mSortColumnIndex = (size_t)_widget->_getInternalData(); mSortUp = true; redrawButtons(); sortList(); } }
void GraphicsImpl::windowResized(Ogre::RenderWindow* rw) { unsigned int width, height, depth; int left, top; rw->getMetrics(width, height, depth, left, top); mainGuiWidget->setSize(width, height); //windowSender.postMessage( WindowMessage(WINDOW_RESIZED, width, height, left, top) ); }
void MenuBar::eventMouseButtonPressed(MyGUI::WidgetPtr _sender, int _left, int _top, MouseButton _id) { if (_id == MB_Left) { size_t select = (size_t)_sender->_getInternalData(); if (mIndexSelect == select) select = ITEM_NONE; setItemSelect(select); } }
void PanelView::updateView() { // вычисл¤ем максимальную высоту всего добра int height = 0; for (VectorPanel::iterator iter=mItems.begin(); iter!=mItems.end(); ++iter) { MyGUI::WidgetPtr widget = (*iter)->getPanelCell()->mainWidget(); if (widget->isShow()) { height += widget->getHeight(); } } // ставим высоту холста, и спрашиваем получившуюс¤ ширину клиента mScrollView->setCanvasSize(0, height); // ширина клиента могла помен¤тс¤ MyGUI::IntCoord coord = mScrollView->getClientCoord(); mScrollView->setCanvasSize(coord.width, height); // выравниваем все панели int pos = 0; for (VectorPanel::iterator iter=mItems.begin(); iter!=mItems.end(); ++iter) { MyGUI::WidgetPtr widget = (*iter)->getPanelCell()->mainWidget(); if (widget->isShow()) { height = widget->getHeight(); widget->setPosition(MyGUI::IntCoord(0, pos, coord.width, height)); pos += height; } } mNeedUpdate = false; MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &PanelView::frameEntered); }
void Client::initPreGameGui() { // load starting layouts m_guiRoot = MyGUI::LayoutManager::getInstance().loadLayout( CONST_STR("GUI::ClientPreGameLayout") ); MyGUI::WidgetPtr currentWidgetRoot = m_guiRoot.at(0); currentWidgetRoot->findWidget("addressEditBox")->castType<MyGUI::EditBox>()->setCaption(m_hostAddress); std::stringstream ss; ss << m_hostPort; currentWidgetRoot->findWidget("portEditBox")->castType<MyGUI::EditBox>()->setCaption(ss.str()); currentWidgetRoot->findWidget("exitButton")->eventMouseButtonClick += MyGUI::newDelegate(this, &Client::button_handler); currentWidgetRoot->findWidget("connectButton")->eventMouseButtonClick += MyGUI::newDelegate(this, &Client::button_handler); m_guiRoot.at(1)->setVisible(false); m_guiRoot.at(1)->findWidget("progressBar")->castType<MyGUI::ProgressBar>()->setProgressPosition(1); m_isGuiOpened = true; }
void EditorWidgets::remove(MyGUI::WidgetPtr _widget) { // дети вперед MyGUI::VectorWidgetPtr childs = _widget->getChilds(); for (MyGUI::VectorWidgetPtr::iterator iter = childs.begin(); iter != childs.end(); ++iter) { if (null != find(*iter)) remove(*iter); } WidgetContainer * _container = find(_widget); MyGUI::WidgetPtr parent = _widget->getParent(); // FIXME у таба все не как у людей if ((null != parent) && (parent->getWidgetType() == "Tab")) MyGUI::castWidget<MyGUI::Tab>(parent)->removeSheet(MyGUI::castWidget<MyGUI::Sheet>(_widget)); else MyGUI::Gui::getInstance().destroyWidget(_widget); if (null != _container) { widgets.erase(std::find(widgets.begin(), widgets.end(), _container)); delete _container; } }
void GraphicsImpl::guiCallback(MyGUI::WidgetPtr sender) { std::string name = sender->getName(); if (name == "do") { InformationManager::Instance()->postDataToFeed("gui_event", DataContainer(DO_BUTTON)); } if (name == "exit") { InformationManager::Instance()->postDataToFeed("gui_event", DataContainer(EXIT_BUTTON)); } }
void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin) { size_t count = widget->getChildCount(); int pos = 0; pos += margin; int width = 0; for (unsigned i = 0; i < count; ++i) { MyGUI::WidgetPtr child = widget->getChildAt(i); if (!child->getVisible()) continue; child->setPosition(child->getLeft(), pos); width = std::max(width, child->getWidth()); pos += child->getHeight() + margin; } width += margin*2; widget->setSize(width, pos); }
void EditorWidgets::serialiseWidget(WidgetContainer * _container, MyGUI::xml::xmlNodePtr _node) { MyGUI::xml::xmlNodePtr node = _node->createChild("Widget"); node->addAttributes("type", _container->type); if ("" != _container->skin) node->addAttributes("skin", _container->skin); if ("" != _container->position) node->addAttributes("position", _container->position); if ("" != _container->position_real) node->addAttributes("position_real", _container->position_real); if ("" != _container->align) node->addAttributes("align", _container->align); if ("" != _container->layer) node->addAttributes("layer", _container->layer); if ("" != _container->name) node->addAttributes("name", _container->name); for (StringPairs::iterator iter = _container->mProperty.begin(); iter != _container->mProperty.end(); ++iter) { MyGUI::xml::xmlNodePtr nodeProp = node->createChild("Property"); nodeProp->addAttributes("key", iter->first); nodeProp->addAttributes("value", iter->second); } for (MapString::iterator iter = _container->mUserString.begin(); iter != _container->mUserString.end(); ++iter) { MyGUI::xml::xmlNodePtr nodeProp = node->createChild("UserString"); nodeProp->addAttributes("key", iter->first); nodeProp->addAttributes("value", iter->second); } // метод медленный, т.к. квадратичная сложность for (std::vector<WidgetContainer*>::iterator iter = widgets.begin(); iter != widgets.end(); ++iter) { MyGUI::WidgetPtr parent = (*iter)->widget->getParent(); // сынок - это ты? if (_container->widget->getWidgetType() == "Window"){ if (null != parent) if (_container->widget == parent->getParent()) serialiseWidget(*iter, node); }else if (_container->widget == parent) serialiseWidget(*iter, node); } }
void PanelObjectsList::mousePressed(MyGUI::WidgetPtr _widget) { EditorFrameHandler *handler = EditorFrameListener::GetInstance()->GetCurrentHandler(); size_t count = mItemsCheckBox.size(); for (size_t pos=0; pos<count; ++pos) { ((MyGUI::ButtonPtr)mItemsCheckBox[pos])->setStateCheck(false); } if (handler->SelectObject(_widget->getCaption())) ((MyGUI::ButtonPtr)_widget)->setStateCheck(true); else ((MyGUI::ButtonPtr)_widget)->setStateCheck(false); }
void GuiPopup::ButtonClick(MyGUI::WidgetPtr wp) { // get result button id btnResult = -1; sscanf(wp->getName().c_str(), "PopBtn%d", &btnResult); // save return fields from edits EditBox* ed; ed = (EditBox*)mWnd->findWidget("PopEdit0"); if (ed) edit0 = ed->getCaption(); ed = (EditBox*)mWnd->findWidget("PopEdit1"); if (ed) edit1 = ed->getCaption(); ed = (EditBox*)mWnd->findWidget("PopEdit2"); if (ed) edit2 = ed->getCaption(); ed = (EditBox*)mWnd->findWidget("PopEdit3"); if (ed) edit3 = ed->getCaption(); //Hide(); // done in delegate mDelegates(); }
void EditorWidgets::remove(MyGUI::WidgetPtr _widget) { // дети вперед MyGUI::VectorWidgetPtr childs = _widget->getChilds(); for (MyGUI::VectorWidgetPtr::iterator iter = childs.begin(); iter != childs.end(); ++iter) { if (null != find(*iter)) remove(*iter); } WidgetContainer * _container = find(_widget); MyGUI::Gui::getInstance().destroyWidget(_widget); if (null != _container) { widgets.erase(std::find(widgets.begin(), widgets.end(), _container)); delete _container; } }
void GUI_Multiplayer::openToolTip(MyGUI::WidgetPtr sender, const MyGUI::ToolTipInfo &t) { if (t.type == MyGUI::ToolTipInfo::Show) { String txt = sender->getUserString("tooltip"); if (!txt.empty()) { tooltipText->setCaption(txt); MyGUI::IntSize s = tooltipText->getTextSize(); int newWidth = s.width + 10; tooltipPanel->setPosition(t.point - MyGUI::IntPoint(newWidth + 10, 10)); tooltipPanel->setSize(newWidth, 20); tooltipText->setSize(newWidth, 16); tooltipPanel->setVisible(true); } } else if (t.type == MyGUI::ToolTipInfo::Hide) { tooltipPanel->setVisible(false); } }
SpaceShipDesignerGUI::SpaceShipDesignerGUI(ENGINE *engine, SpaceShipDesigner *parent) { mParent = parent; mEngine = engine; mGUI = engine->loadGUI("Designer.layout"); for(MyGUI::VectorWidgetPtr::iterator i=mGUI.begin(); i!=mGUI.end(); ++i) { MyGUI::WidgetPtr w = *i; if(w->getName() == "Root") { mRoot = w; mRoot->setSize(mEngine->getWindow()->getWidth(), mEngine->getWindow()->getHeight()); for(size_t j=0; j<mRoot->getChildCount(); j++) { if(w->getChildAt(j)->getTypeName() == "Button") w->getChildAt(j)->eventMouseButtonClick = MyGUI::newDelegate(SpaceShipDesignerGUI::buttonClicked); else if(w->getChildAt(j)->getTypeName() == "EditBox") ((MyGUI::EditBox *)w->getChildAt(j))->eventEditTextChange = MyGUI::newDelegate(SpaceShipDesignerGUI::editBoxUpdated); } } } }
void PropertiesPanelView::createPropertiesWidgetsPair(MyGUI::WidgetPtr _window, std::string _property, std::string _value, std::string _type,int y) { pairs_counter++; int x1 = 0, x2 = 125; int w1 = 120; int w2 = _window->getWidth() - x2; const int h = PropertyItemHeight; if (_property == "Position") { x1 = 66; w1 = w1 - x1; } MyGUI::StaticTextPtr text; MyGUI::WidgetPtr editOrCombo; //int string_int_float; // 0 - string, 1 - int, 2 - float int widget_for_type;// 0 - Edit, 1 - Combo mode drop, 2 - ... std::string type_names[2] = {"Edit", "ComboBox"}; if ("Name" == _type) widget_for_type = 0; else if ("Skin" == _type) widget_for_type = 1; else if ("Position" == _type) widget_for_type = 0; else if ("Layer" == _type) widget_for_type = 1; else if ("String" == _type) widget_for_type = 0; else if ("Align" == _type) widget_for_type = 1; // не совсем правильно FIXME else if ("1 int" == _type) widget_for_type = 0; else if ("2 int" == _type) widget_for_type = 0; else if ("4 int" == _type) widget_for_type = 0; else if ("1 float" == _type) widget_for_type = 0; else if ("2 float" == _type) widget_for_type = 0; // надо сделать проще FIXME else if ("Colour" == _type) widget_for_type = 0;//"Colour" хорошо бы колорпикером else if ("MessageButton" == _type) widget_for_type = 1; else if ("FileName" == _type) widget_for_type = 0; else widget_for_type = 1; if ((propertiesText.size() < pairs_counter) || (propertiesText[pairs_counter-1]->getParent() != _window)) { text = _window->createWidget<MyGUI::StaticText>("Editor_StaticText", x1, y, w1, h, MyGUI::Align::Default); text->setTextAlign(MyGUI::Align::Right); if (propertiesText.size() < pairs_counter) { propertiesText.push_back(text); } else { MyGUI::Gui::getInstance().destroyWidget(propertiesText[pairs_counter-1]); propertiesText[pairs_counter-1] = text; } } else { text = propertiesText[pairs_counter-1]; text->setVisible(true); text->setCoord(x1, y, w1, h); } std::string prop = _property; // trim widget name std::string::iterator iter = std::find(prop.begin(), prop.end(), '_'); if (iter != prop.end()) prop.erase(prop.begin(), ++iter); text->setCaption(prop); if ((propertiesElement.size() < pairs_counter) || (propertiesElement[pairs_counter-1]->getParent() != _window) || (type_names[widget_for_type] != propertiesElement[pairs_counter-1]->getTypeName())) { if (widget_for_type == 0) { editOrCombo = _window->createWidget<MyGUI::Edit>("Edit", x2, y, w2, h, MyGUI::Align::Top | MyGUI::Align::HStretch); editOrCombo->castType<MyGUI::Edit>()->eventEditTextChange = newDelegate (this, &PropertiesPanelView::notifyTryApplyProperties); editOrCombo->castType<MyGUI::Edit>()->eventEditSelectAccept = newDelegate (this, &PropertiesPanelView::notifyForceApplyProperties); } else if (widget_for_type == 1) { editOrCombo = _window->createWidget<MyGUI::ComboBox>("ComboBox", x2, y, w2, h, MyGUI::Align::Top | MyGUI::Align::HStretch); editOrCombo->castType<MyGUI::ComboBox>()->eventComboAccept = newDelegate (this, &PropertiesPanelView::notifyForceApplyProperties2); editOrCombo->castType<MyGUI::ComboBox>()->setComboModeDrop(true); } if (propertiesElement.size() < pairs_counter) { propertiesElement.push_back(editOrCombo); } else { MyGUI::Gui::getInstance().destroyWidget(propertiesElement[pairs_counter-1]); propertiesElement[pairs_counter-1] = editOrCombo; } } else { editOrCombo = propertiesElement[pairs_counter-1]; if (widget_for_type == 1) editOrCombo->castType<MyGUI::ComboBox>()->removeAllItems(); editOrCombo->setVisible(true); editOrCombo->setCoord(x2, y, w2, h); } // fill possible values if (widget_for_type == 1) { std::vector<std::string> values; if (_type == "Skin") values = WidgetTypes::getInstance().find(current_widget->getTypeName())->skin; else values = WidgetTypes::getInstance().findPossibleValues(_type); for (std::vector<std::string>::iterator iter = values.begin(); iter != values.end(); ++iter) editOrCombo->castType<MyGUI::ComboBox>()->addItem(*iter); } editOrCombo->setUserString("action", _property); editOrCombo->setUserString("type", _type); if (_value.empty()){ editOrCombo->setCaption(DEFAULT_VALUE); } else { editOrCombo->castType<MyGUI::Edit>()->setOnlyText(_value); checkType(editOrCombo->castType<MyGUI::Edit>(), _type); } }
void EditorWidgets::parseWidget(MyGUI::xml::xmlNodeIterator & _widget, MyGUI::WidgetPtr _parent) { WidgetContainer * container = new WidgetContainer(); // парсим атрибуты виджета MyGUI::IntCoord coord; MyGUI::Align align = MyGUI::ALIGN_DEFAULT; _widget->findAttribute("name", container->name); _widget->findAttribute("type", container->type); _widget->findAttribute("skin", container->skin); _widget->findAttribute("layer", container->layer); if (_widget->findAttribute("align", container->align)) align = MyGUI::SkinManager::getInstance().parseAlign(container->align); if (_widget->findAttribute("position", container->position)) coord = MyGUI::IntCoord::parse(container->position); if (_widget->findAttribute("position_real", container->position_real)) coord = MyGUI::Gui::getInstance().convertRelativeToInt(MyGUI::FloatCoord::parse(container->position_real), _parent); // в гуе на 2 одноименных виджета ругается и падает, а у нас будет просто переименовывать if (false == container->name.empty()) { WidgetContainer * iter = find(container->name); if (null != iter) { LOGGING(LogSection, Warning, "widget with same name name '" << container->name << "'. Renamed"); static long renameN=0; container->name = MyGUI::utility::toString(container->name, renameN++); } } std::string tmpname = container->name; if (tmpname.empty()) { tmpname = MyGUI::utility::toString(container->type, global_counter); global_counter++; } //может и не стоит tmpname = "LayoutEditor_" + tmpname; if (null == _parent) { container->widget = MyGUI::Gui::getInstance().createWidgetT(container->type, container->skin, coord, align, container->layer, tmpname); add(container); } else { container->widget = _parent->createWidgetT(container->type, container->skin, coord, align, tmpname); add(container); } // берем детей и крутимся MyGUI::xml::xmlNodeIterator widget = _widget->getNodeIterator(); while (widget.nextNode()) { std::string key, value; if (widget->getName() == "Widget") parseWidget(widget, container->widget); else if (widget->getName() == "Property") { // парсим атрибуты if (false == widget->findAttribute("key", key)) continue; if (false == widget->findAttribute("value", value)) continue; // и парсим свойство if (("Message_Modal" != key) && ("Window_AutoAlpha" != key)) MyGUI::WidgetManager::getInstance().parse(container->widget, key, value); container->mProperty.push_back(std::make_pair(key, value)); } else if (widget->getName() == "UserString") { // парсим атрибуты if (false == widget->findAttribute("key", key)) continue; if (false == widget->findAttribute("value", value)) continue; container->mUserString.insert(std::make_pair(key, value)); } }; }
void DashBoard::loadLayoutRecursive(MyGUI::WidgetPtr w) { std::string name = w->getName(); std::string anim = w->getUserString("anim"); std::string debug = w->getUserString("debug"); std::string linkArgs = w->getUserString("link"); // make it unclickable w->setUserString("interactive", "0"); if (!debug.empty()) { w->setVisible(false); return; } // find the root widget and ignore debug widgets if (name.size() > prefix.size()) { std::string prefixLessName = name.substr(prefix.size()); if (prefixLessName == "_Main") { mainWidget = (MyGUI::WindowPtr)w; // resize it windowResized(); } // ignore debug widgets if (prefixLessName == "DEBUG") { w->setVisible(false); return; } } // animations for this control? if (!linkArgs.empty()) { layoutLink_t ctrl; memset(&ctrl, 0, sizeof(ctrl)); if (!name.empty()) strncpy(ctrl.name, name.c_str(), 255); ctrl.widget = w; ctrl.initialSize = w->getSize(); ctrl.initialPosition = w->getPosition(); ctrl.last = 1337.1337f; // force update ctrl.lastState = true; // establish the link { replaceString(linkArgs, ">", ">"); replaceString(linkArgs, "<", "<"); String linkName = ""; if (linkArgs.empty()) { LOG("Dashboard ("+filename+"/"+name+"): empty Link"); return; } // conditional checks // TODO: improve the logic, this is crap ... if (linkArgs.find(">") != linkArgs.npos) { Ogre::StringVector args = Ogre::StringUtil::split(linkArgs, ">"); if (args.size() == 2) { linkName = args[0]; ctrl.conditionArgument = StringConverter::parseReal(args[1]); ctrl.condition = CONDITION_GREATER; } else { LOG("Dashboard ("+filename+"/"+name+"): error in conditional Link: " + linkArgs); return; } } else if (linkArgs.find("<") != linkArgs.npos ) { Ogre::StringVector args = Ogre::StringUtil::split(linkArgs, "<"); if (args.size() == 2) { linkName = args[0]; ctrl.conditionArgument = StringConverter::parseReal(args[1]); ctrl.condition = CONDITION_LESSER; } else { LOG("Dashboard ("+filename+"/"+name+"): error in conditional Link: " + linkArgs); return; } } else { ctrl.condition = CONDITION_NONE; ctrl.conditionArgument = 0; linkName = linkArgs; } // now try to get the enum id for it int linkID = manager->getLinkIDForName(linkName); if (linkID < 0) { LOG("Dashboard ("+filename+"/"+name+"): unknown Link: " + linkName); return; } ctrl.linkID = linkID; } // parse more attributes ctrl.wmin = StringConverter::parseReal(w->getUserString("min")); ctrl.wmax = StringConverter::parseReal(w->getUserString("max")); ctrl.vmin = StringConverter::parseReal(w->getUserString("vmin")); ctrl.vmax = StringConverter::parseReal(w->getUserString("vmax")); String texture = w->getUserString("texture"); if (!texture.empty()) strncpy(ctrl.texture, texture.c_str(), 255); String format = w->getUserString("format"); if (!format.empty()) strncpy(ctrl.format, format.c_str(), 255); String direction = w->getUserString("direction"); if (direction == "right") ctrl.direction = DIRECTION_RIGHT; else if (direction == "left") ctrl.direction = DIRECTION_LEFT; else if (direction == "down") ctrl.direction = DIRECTION_DOWN; else if (direction == "up") ctrl.direction = DIRECTION_UP; else if (!direction.empty()) { LOG("Dashboard ("+filename+"/"+name+"): unknown direction: " + direction); return; } // then specializations if (anim == "rotate") { ctrl.animationType = ANIM_ROTATE; // check if its the correct control // try to cast, will throw // and if the link is a float /* if (manager->getDataType(ctrl.linkID) != DC_FLOAT) { LOG("Dashboard ("+filename+"/"+name+"): Rotating controls can only link to floats"); continue; } */ try { ctrl.rotImg = w->getSubWidgetMain()->castType<MyGUI::RotatingSkin>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Rotating controls must use the RotatingSkin"); return; } if (!ctrl.rotImg) { LOG("Dashboard ("+filename+"/"+name+"): error loading rotation control"); return; } // special: set rotation center now into the middle ctrl.rotImg->setCenter(MyGUI::IntPoint(w->getHeight() * 0.5f, w->getWidth() * 0.5f)); } else if (anim == "scale") { ctrl.animationType = ANIM_SCALE; if (ctrl.direction == DIRECTION_NONE) { LOG("Dashboard ("+filename+"/"+name+"): direction empty: scale needs a direction"); return; } } else if (anim == "translate") { ctrl.animationType = ANIM_TRANSLATE; if (ctrl.direction == DIRECTION_NONE) { LOG("Dashboard ("+filename+"/"+name+"): direction empty: translate needs a direction"); return; } } else if (anim == "series") { ctrl.animationType = ANIM_SERIES; ctrl.img = (MyGUI::ImageBox *)w; //w->getSubWidgetMain()->castType<MyGUI::ImageBox>(); if (!ctrl.img) { LOG("Dashboard ("+filename+"/"+name+"): error loading series control"); return; } } else if (anim == "textcolor" || anim == "textcolour") { ctrl.animationType = ANIM_TEXTCOLOR; // try to cast, will throw try { ctrl.txt = (MyGUI::TextBox *)w; } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): textcolor controls must use the TextBox Control"); return; } } else if (anim == "textformat") { // try to cast, will throw try { ctrl.txt = (MyGUI::TextBox *)w; // w->getSubWidgetMain()->castType<MyGUI::TextBox>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Lamp controls must use the ImageBox Control"); return; } ctrl.animationType = ANIM_TEXTFORMAT; } else if (anim == "textstring") { // try to cast, will throw try { ctrl.txt = (MyGUI::TextBox *)w; // w->getSubWidgetMain()->castType<MyGUI::TextBox>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Lamp controls must use the ImageBox Control"); return; } ctrl.animationType = ANIM_TEXTSTRING; } else if (anim == "lamp") { // try to cast, will throw /* { try { w->getSubWidgetMain()->castType<MyGUI::ImageBox>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Lamp controls must use the ImageBox Control"); continue; } } */ ctrl.animationType = ANIM_LAMP; ctrl.img = (MyGUI::ImageBox *)w; //w->getSubWidgetMain()->castType<MyGUI::ImageBox>(); if (!ctrl.img) { LOG("Dashboard ("+filename+"/"+name+"): error loading Lamp control"); return; } } controls[free_controls] = ctrl; free_controls++; if (free_controls >= MAX_CONTROLS) { LOG("maximum amount of controls reached, discarding the rest: " + TOSTRING(MAX_CONTROLS)); return; } } // walk the children now MyGUI::EnumeratorWidgetPtr e = w->getEnumerator(); while (e.next()) { loadLayoutRecursive(e.current()); } }
void EditorWidgets::parseWidget(MyGUI::xml::xmlNodeIterator & _widget, MyGUI::WidgetPtr _parent) { WidgetContainer * container = new WidgetContainer(); // парсим атрибуты виджета MyGUI::IntCoord coord; MyGUI::Align align = MyGUI::ALIGN_DEFAULT; _widget->findAttribute("name", container->name); _widget->findAttribute("type", container->type); _widget->findAttribute("skin", container->skin); _widget->findAttribute("layer", container->layer); if (_widget->findAttribute("align", container->align)) align = MyGUI::SkinManager::getInstance().parseAlign(container->align); if (_widget->findAttribute("position", container->position)) coord = MyGUI::IntCoord::parse(container->position); if (_widget->findAttribute("position_real", container->position_real)) coord = MyGUI::Gui::getInstance().convertRelativeToInt(MyGUI::FloatCoord::parse(container->position_real), _parent); // в гуе на 2 одноименных виджета ругается и падает, а у нас будет просто переименовывать if (false == container->name.empty()) { WidgetContainer * iter = find(container->name); if (null != iter) { static long renameN=0; std::string mess = MyGUI::utility::toString("widget with same name name '", container->name, "'. Renamed to '", container->name, renameN, "'."); LOGGING(LogSection, Warning, mess); MyGUI::Message::_createMessage("Warning", mess, "", "LayoutEditor_Popup", true, null, MyGUI::Message::IconWarning | MyGUI::Message::Ok); container->name = MyGUI::utility::toString(container->name, renameN++); } } std::string tmpname = container->name; if (tmpname.empty()) { tmpname = MyGUI::utility::toString(container->type, global_counter); global_counter++; } //может и не стоит tmpname = "LayoutEditor_" + tmpname; if (null == _parent) { container->widget = MyGUI::Gui::getInstance().createWidgetT(container->type, container->skin, coord, align, container->layer, tmpname); add(container); } else { container->widget = _parent->createWidgetT(container->type, container->skin, coord, align, tmpname); add(container); } // берем детей и крутимся MyGUI::xml::xmlNodeIterator widget = _widget->getNodeIterator(); while (widget.nextNode()) { std::string key, value; if (widget->getName() == "Widget") parseWidget(widget, container->widget); else if (widget->getName() == "Property") { // парсим атрибуты if (false == widget->findAttribute("key", key)) continue; if (false == widget->findAttribute("value", value)) continue; // и парсим свойство try{ if (("Message_Modal" != key) && ("Window_AutoAlpha" != key) && ("Window_Snap" != key)) MyGUI::WidgetManager::getInstance().parse(container->widget, key, value); Ogre::Root::getSingleton().renderOneFrame(); } catch(...) { MyGUI::Message::_createMessage("Warning", "No such " + key + ": '" + value + "'", "", "LayoutEditor_Popup", true, null, MyGUI::Message::IconWarning | MyGUI::Message::Ok); if (key == "Image_Texture") MyGUI::WidgetManager::getInstance().parse(container->widget, key, ""); }// for incorrect meshes or textures container->mProperty.push_back(std::make_pair(key, value)); } else if (widget->getName() == "UserString") { // парсим атрибуты if (false == widget->findAttribute("key", key)) continue; if (false == widget->findAttribute("value", value)) continue; container->mUserString.insert(std::make_pair(key, value)); } }; }