本文整理汇总了C++中TooltipData::addColoredText方法的典型用法代码示例。如果您正苦于以下问题:C++ TooltipData::addColoredText方法的具体用法?C++ TooltipData::addColoredText怎么用?C++ TooltipData::addColoredText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TooltipData
的用法示例。
在下文中一共展示了TooltipData::addColoredText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getShortTooltip
TooltipData ItemManager::getShortTooltip(ItemStack stack) {
std::stringstream ss;
TooltipData tip;
if (stack.empty()) return tip;
// name
if (stack.quantity > 1) {
ss << stack.quantity << " " << getItemName(stack.item);
}
else {
ss << getItemName(stack.item);
}
tip.addColoredText(ss.str(), getItemColor(stack.item));
return tip;
}
示例2: getTooltip
/**
* Create detailed tooltip showing all relevant item info
*/
TooltipData ItemManager::getTooltip(ItemStack stack, StatBlock *stats, int context) {
TooltipData tip;
if (stack.empty()) return tip;
Color color = getItemColor(stack.item);
// name
std::stringstream ss;
if (stack.quantity == 1)
ss << getItemName(stack.item);
else
ss << getItemName(stack.item) << " (" << stack.quantity << ")";
tip.addColoredText(ss.str(), color);
// quest item
if (items[stack.item].quest_item) {
tip.addColoredText(msg->get("Quest Item"), font->getColor(FontEngine::COLOR_ITEM_BONUS));
}
// only show the name of the currency item
if (stack.item == eset->misc.currency_id)
return tip;
// flavor text
if (items[stack.item].flavor != "") {
tip.addColoredText(Utils::substituteVarsInString(items[stack.item].flavor, pc), font->getColor(FontEngine::COLOR_ITEM_FLAVOR));
}
// level
if (items[stack.item].level != 0) {
tip.addText(msg->get("Level %d", items[stack.item].level));
}
// type
if (items[stack.item].type != "") {
tip.addText(msg->get(getItemType(items[stack.item].type)));
}
// item quality text for colorblind users
if (settings->colorblind && items[stack.item].quality != "") {
color = font->getColor(FontEngine::COLOR_WIDGET_NORMAL);
for (size_t i=0; i<item_qualities.size(); ++i) {
if (item_qualities[i].id == items[stack.item].quality) {
tip.addColoredText(msg->get("Quality: %s", msg->get(item_qualities[i].name)), color);
break;
}
}
}
// damage
for (size_t i = 0; i < eset->damage_types.list.size(); ++i) {
if (items[stack.item].dmg_max[i] > 0) {
std::stringstream dmg_str;
dmg_str << eset->damage_types.list[i].name;
if (items[stack.item].dmg_min[i] < items[stack.item].dmg_max[i]) {
dmg_str << ": " << items[stack.item].dmg_min[i] << "-" << items[stack.item].dmg_max[i];
tip.addText(dmg_str.str());
}
else {
dmg_str << ": " << items[stack.item].dmg_max[i];
tip.addText(dmg_str.str());
}
}
}
// absorb
if (items[stack.item].abs_max > 0) {
if (items[stack.item].abs_min < items[stack.item].abs_max)
tip.addText(msg->get("Absorb: %d-%d", items[stack.item].abs_min, items[stack.item].abs_max));
else
tip.addText(msg->get("Absorb: %d", items[stack.item].abs_max));
}
// bonuses
unsigned bonus_counter = 0;
while (bonus_counter < items[stack.item].bonus.size()) {
ss.str("");
BonusData* bdata = &items[stack.item].bonus[bonus_counter];
if (bdata->is_speed || bdata->is_attack_speed) {
if (bdata->value >= 100)
color = font->getColor(FontEngine::COLOR_ITEM_BONUS);
else
color = font->getColor(FontEngine::COLOR_ITEM_PENALTY);
}
else {
if (bdata->value > 0)
color = font->getColor(FontEngine::COLOR_ITEM_BONUS);
else
color = font->getColor(FontEngine::COLOR_ITEM_PENALTY);
}
getBonusString(ss, bdata);
tip.addColoredText(ss.str(), color);
bonus_counter++;
//.........这里部分代码省略.........