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); } }
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()); } }