/** * Show mouseover descriptions of disciplines and powers */ TooltipData MenuPowers::checkTooltip(const Point& mouse) { TooltipData tip; for (size_t i=0; i<power_cell.size(); i++) { if (tab_control && (tab_control->getActiveTab() != power_cell[i].tab)) continue; int cell_index = getCellByPowerIndex(power_cell[i].id, power_cell_all); if (!checkCellVisible(cell_index)) continue; if (slots[i] && isWithinRect(slots[i]->pos, mouse)) { bool base_unlocked = checkUnlocked(cell_index) || std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end(); createTooltip(&tip, static_cast<int>(i), power_cell, !base_unlocked); if (!power_cell[i].upgrades.empty()) { int next_level = getNextLevelCell(static_cast<int>(i)); if (next_level != -1) { tip.addText("\n" + msg->get("Next Level:")); createTooltip(&tip, next_level, power_cell_upgrade, base_unlocked); } } return tip; } } return tip; }
/** * Show mouseover descriptions of disciplines and powers */ TooltipData MenuPowers::checkTooltip(Point mouse) { TooltipData tip; for (unsigned i=0; i<power_cell.size(); i++) { if ((tabs_count > 1) && (tabControl->getActiveTab() != power_cell[i].tab)) continue; if (!powerIsVisible(power_cell[i].id)) continue; if (isWithin(slots[i]->pos, mouse)) { generatePowerDescription(&tip, i); if (power_cell[i].next_level != 0) { tip.addText(msg->get("\nNext Level:")); short next_level_cell = id_by_powerIndex(power_cell[i].next_level); generatePowerDescription(&tip, next_level_cell); } return tip; } } return tip; }
/** * If mousing-over an item with a tooltip, return that tooltip data. * * @param mouse The x,y screen coordinates of the mouse cursor */ TooltipData MenuInventory::checkTooltip(Point position) { int area; int slot; TooltipData tip; area = areaOver(position); if (area == -1) { if (position.x >= window_area.x + help_pos.x && position.y >= window_area.y+help_pos.y && position.x < window_area.x+help_pos.x+help_pos.w && position.y < window_area.y+help_pos.y+help_pos.h) { tip.addText(msg->get("Use SHIFT to move only one item.")); tip.addText(msg->get("CTRL-click a carried item to sell it.")); } return tip; } slot = inventory[area].slotOver(position); if (slot == -1) return tip; if (inventory[area][slot].item > 0) { tip = inventory[area].checkTooltip(position, stats, PLAYER_INV); } else if (area == EQUIPMENT && inventory[area][slot].item == 0) { tip.addText(msg->get(slot_desc[slot])); } return tip; }
/** * Show mouseover descriptions of disciplines and powers */ TooltipData MenuPowers::checkTooltip(Point mouse) { TooltipData tip; for (unsigned i=0; i<power_cell.size(); i++) { if ((tabs_count > 1) && (tabControl->getActiveTab() != power_cell[i].tab)) continue; if (!powerIsVisible(power_cell[i].id)) continue; if (isWithin(slots[i]->pos, mouse)) { generatePowerDescription(&tip, i, power_cell); if (!power_cell[i].upgrades.empty()) { short next_level = nextLevel(i); if (next_level != -1) { tip.addText("\n" + msg->get("Next Level:")); generatePowerDescription(&tip, next_level, power_cell_upgrade); } } return tip; } } return tip; }
TooltipData ItemManager::getShortTooltip(ItemStack stack) { stringstream ss; TooltipData tip; SDL_Color color = color_normal; if (stack.item == 0) return tip; // color quality if (items[stack.item].set > 0) { color = item_sets[items[stack.item].set].color; } else if (items[stack.item].quality == ITEM_QUALITY_LOW) { color = color_low; } else if (items[stack.item].quality == ITEM_QUALITY_HIGH) { color = color_high; } else if (items[stack.item].quality == ITEM_QUALITY_EPIC) { color = color_epic; } // name if (stack.quantity > 1) { ss << stack.quantity << " " << items[stack.item].name; } else { ss << items[stack.item].name; } tip.addText(ss.str(), color); return tip; }
/** * Show mouseover descriptions of disciplines and powers */ TooltipData MenuPowers::checkTooltip(Point mouse) { TooltipData tip; for (unsigned i=0; i<power_cell.size(); i++) { if (tab_control && (tab_control->getActiveTab() != power_cell[i].tab)) continue; if (!powerIsVisible(power_cell[i].id)) continue; if (slots[i] && isWithin(slots[i]->pos, mouse)) { bool base_unlocked = requirementsMet(power_cell[i].id) || std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end(); generatePowerDescription(&tip, i, power_cell, !base_unlocked); if (!power_cell[i].upgrades.empty()) { short next_level = nextLevel(static_cast<short>(i)); if (next_level != -1) { tip.addText("\n" + msg->get("Next Level:")); generatePowerDescription(&tip, next_level, power_cell_upgrade, base_unlocked); } } return tip; } } return tip; }
/** * If mousing-over an item with a tooltip, return that tooltip data. * * @param mouse The x,y screen coordinates of the mouse cursor */ TooltipData MenuInventory::checkTooltip(const Point& position) { int area; int slot; TooltipData tip; area = areaOver(position); if (area < 0) { if (position.x >= window_area.x + help_pos.x && position.y >= window_area.y+help_pos.y && position.x < window_area.x+help_pos.x+help_pos.w && position.y < window_area.y+help_pos.y+help_pos.h) { tip.addText(msg->get("Pick up item(s):") + " " + inpt->getBindingString(MAIN1)); tip.addText(msg->get("Use or equip item:") + " " + inpt->getBindingString(MAIN2) + "\n"); tip.addText(msg->get("%s modifiers", inpt->getBindingString(MAIN1).c_str())); tip.addText(msg->get("Select a quantity of item:") + " " + inpt->getBindingString(SHIFT) + " / " + inpt->getBindingString(SHIFT, INPUT_BINDING_ALT)); if (inv_ctrl == INV_CTRL_STASH) tip.addText(msg->get("Stash item stack:") + " " + inpt->getBindingString(CTRL) + " / " + inpt->getBindingString(CTRL, INPUT_BINDING_ALT)); else if (inv_ctrl == INV_CTRL_VENDOR || (SELL_WITHOUT_VENDOR && inv_ctrl != INV_CTRL_STASH)) tip.addText(msg->get("Sell item stack:") + " " + inpt->getBindingString(CTRL) + " / " + inpt->getBindingString(CTRL, INPUT_BINDING_ALT)); } return tip; } slot = inventory[area].slotOver(position); if (slot == -1) return tip; if (inventory[area][slot].item > 0) { tip = inventory[area].checkTooltip(position, stats, PLAYER_INV); } else if (area == EQUIPMENT && inventory[area][slot].empty()) { tip.addText(msg->get(items->getItemType(slot_type[slot]))); } return tip; }
void TooltipManager::push(const TooltipData& _tip_data, const Point& _pos, uint8_t _style) { if (_tip_data.isEmpty()) return; tip_data = _tip_data; pos = _pos; style = _style; }
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; }
/** * On mouseover, show tooltip for buttons */ TooltipData MenuActionBar::checkTooltip(const Point& mouse) { TooltipData tip; if (isWithin(menus[MENU_CHARACTER]->pos, mouse)) { if (COLORBLIND && requires_attention[MENU_CHARACTER]) tip.addText(msg->get("Character") + " (*)"); else tip.addText(msg->get("Character")); return tip; } if (isWithin(menus[MENU_INVENTORY]->pos, mouse)) { if (COLORBLIND && requires_attention[MENU_INVENTORY]) tip.addText(msg->get("Inventory") + " (*)"); else tip.addText(msg->get("Inventory")); return tip; } if (isWithin(menus[MENU_POWERS]->pos, mouse)) { if (COLORBLIND && requires_attention[MENU_POWERS]) tip.addText(msg->get("Powers") + " (*)"); else tip.addText(msg->get("Powers")); return tip; } if (isWithin(menus[MENU_LOG]->pos, mouse)) { if (COLORBLIND && requires_attention[MENU_LOG]) tip.addText(msg->get("Log") + " (*)"); else tip.addText(msg->get("Log")); return tip; } for (unsigned i = 0; i < slots_count; i++) { if (hotkeys_mod[i] != 0) { if (slots[i] && isWithin(slots[i]->pos, mouse)) { tip.addText(powers->powers[hotkeys_mod[i]].name); } } } return tip; }
/** * On mouseover, show tooltip for buttons */ TooltipData MenuActionBar::checkTooltip(Point mouse) { TooltipData tip; if (isWithin(menus[0], mouse)) { tip.addText(msg->get("Character Menu (C)")); return tip; } if (isWithin(menus[1], mouse)) { tip.addText(msg->get("Inventory Menu (I)")); return tip; } if (isWithin(menus[2], mouse)) { tip.addText(msg->get("Power Menu (P)")); return tip; } if (isWithin(menus[3], mouse)) { tip.addText(msg->get("Log Menu (L)")); return tip; } for (int i=0; i<12; i++) { if (hotkeys[i] != 0) { if (isWithin(slots[i], mouse)) { tip.addText(powers->powers[hotkeys[i]].name); } } } return tip; }
/** * On mouseover, show tooltip for buttons */ TooltipData MenuActionBar::checkTooltip(Point mouse) { TooltipData tip; if (isWithin(menus[MENU_CHARACTER]->pos, mouse)) { tip.addText(msg->get("Character")); return tip; } if (isWithin(menus[MENU_INVENTORY]->pos, mouse)) { tip.addText(msg->get("Inventory")); return tip; } if (isWithin(menus[MENU_POWERS]->pos, mouse)) { tip.addText(msg->get("Powers")); return tip; } if (isWithin(menus[MENU_LOG]->pos, mouse)) { tip.addText(msg->get("Log")); return tip; } for (int i=0; i<12; i++) { if (hotkeys[i] != 0) { if (isWithin(slots[i]->pos, mouse)) { tip.addText(powers->powers[hotkeys[i]].name); } } } return tip; }
/** * Create detailed tooltip showing all relevant item info */ TooltipData ItemManager::getTooltip(int item, StatBlock *stats, int context) { TooltipData tip; SDL_Color color = color_normal; if (item == 0) return tip; // color quality if (items[item].set > 0) { color = item_sets[items[item].set].color; } else if (items[item].quality == ITEM_QUALITY_LOW) { color = color_low; } else if (items[item].quality == ITEM_QUALITY_HIGH) { color = color_high; } else if (items[item].quality == ITEM_QUALITY_EPIC) { color = color_epic; } // name tip.addText(items[item].name, color); // level if (items[item].level != 0) { tip.addText(msg->get("Level %d", items[item].level)); } // type if (items[item].type != "other") { tip.addText(msg->get(getItemType(items[item].type))); } // damage if (items[item].dmg_melee_max > 0) { if (items[item].dmg_melee_min < items[item].dmg_melee_max) tip.addText(msg->get("Melee damage: %d-%d", items[item].dmg_melee_min, items[item].dmg_melee_max)); else tip.addText(msg->get("Melee damage: %d", items[item].dmg_melee_max)); } if (items[item].dmg_ranged_max > 0) { if (items[item].dmg_ranged_min < items[item].dmg_ranged_max) tip.addText(msg->get("Ranged damage: %d-%d", items[item].dmg_ranged_min, items[item].dmg_ranged_max)); else tip.addText(msg->get("Ranged damage: %d", items[item].dmg_ranged_max)); } if (items[item].dmg_ment_max > 0) { if (items[item].dmg_ment_min < items[item].dmg_ment_max) tip.addText(msg->get("Mental damage: %d-%d", items[item].dmg_ment_min, items[item].dmg_ment_max)); else tip.addText(msg->get("Mental damage: %d", items[item].dmg_ment_max)); } // absorb if (items[item].abs_max > 0) { if (items[item].abs_min < items[item].abs_max) tip.addText(msg->get("Absorb: %d-%d", items[item].abs_min, items[item].abs_max)); else tip.addText(msg->get("Absorb: %d", items[item].abs_max)); } // bonuses unsigned bonus_counter = 0; string modifier; while (bonus_counter < items[item].bonus_val.size() && items[item].bonus_stat[bonus_counter] != "") { if (items[item].bonus_stat[bonus_counter] == "speed") { modifier = msg->get("%d%% Speed", items[item].bonus_val[bonus_counter]); if (items[item].bonus_val[bonus_counter] >= 100) color = color_bonus; else color = color_penalty; } else { if (items[item].bonus_val[bonus_counter] > 0) { modifier = msg->get("Increases %s by %d", items[item].bonus_val[bonus_counter], msg->get(items[item].bonus_stat[bonus_counter])); color = color_bonus; } else { modifier = msg->get("Decreases %s by %d", items[item].bonus_val[bonus_counter], msg->get(items[item].bonus_stat[bonus_counter])); color = color_penalty; } } tip.addText(modifier, color); bonus_counter++; } // power if (items[item].power_desc != "") { tip.addText(items[item].power_desc, color_bonus); } // requirement if (items[item].req_val > 0) { if (items[item].req_stat == REQUIRES_PHYS) { if (stats->get_physical() < items[item].req_val) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Physical %d", items[item].req_val), color); } else if (items[item].req_stat == REQUIRES_MENT) { if (stats->get_mental() < items[item].req_val) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Mental %d", items[item].req_val), color); } else if (items[item].req_stat == REQUIRES_OFF) { if (stats->get_offense() < items[item].req_val) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Offense %d", items[item].req_val), color); } else if (items[item].req_stat == REQUIRES_DEF) { if (stats->get_defense() < items[item].req_val) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Defense %d", items[item].req_val), color); } } // flavor text if (items[item].flavor != "") { tip.addText(items[item].flavor, color_flavor); } // buy or sell price if (items[item].price > 0) { int price_per_unit; if (context == VENDOR_BUY) { price_per_unit = items[item].price; if (stats->currency < items[item].price) color = color_requirements_not_met; else color = color_normal; if (items[item].max_quantity <= 1) tip.addText(msg->get("Buy Price: %d %s", price_per_unit, CURRENCY), color); else tip.addText(msg->get("Buy Price: %d %s each", price_per_unit, CURRENCY), color); } else if (context == VENDOR_SELL) { price_per_unit = items[item].getSellPrice(); if (stats->currency < price_per_unit) color = color_requirements_not_met; else color = color_normal; if (items[item].max_quantity <= 1) tip.addText(msg->get("Buy Price: %d %s", price_per_unit, CURRENCY), color); else tip.addText(msg->get("Buy Price: %d %s each", price_per_unit, CURRENCY), color); } else if (context == PLAYER_INV) { price_per_unit = items[item].getSellPrice(); if (price_per_unit == 0) price_per_unit = 1; if (items[item].max_quantity <= 1) tip.addText(msg->get("Sell Price: %d %s", price_per_unit, CURRENCY)); else tip.addText(msg->get("Sell Price: %d %s each", price_per_unit, CURRENCY)); } } if (items[item].set > 0) { // item set bonuses ItemSet set = item_sets[items[item].set]; bonus_counter = 0; modifier = ""; tip.addText("\n" + msg->get("Set: ") + msg->get(item_sets[items[item].set].name), set.color); while (bonus_counter < set.bonus.size() && set.bonus[bonus_counter].bonus_stat != "") { if (set.bonus[bonus_counter].bonus_val > 0) { modifier = msg->get("%d items: ", set.bonus[bonus_counter].requirement) + msg->get("Increases %s by %d", set.bonus[bonus_counter].bonus_val, msg->get(set.bonus[bonus_counter].bonus_stat)); } else { modifier = msg->get("%d items: ", set.bonus[bonus_counter].requirement) + msg->get("Decreases %s by %d", set.bonus[bonus_counter].bonus_val, msg->get(set.bonus[bonus_counter].bonus_stat)); } tip.addText(modifier, set.color); bonus_counter++; } } return tip; }
/** * 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++; } // power if (items[stack.item].power_desc != "") { tip.addColoredText(items[stack.item].power_desc, font->getColor(FontEngine::COLOR_ITEM_BONUS)); } // level requirement if (items[stack.item].requires_level > 0) { if (stats->level < items[stack.item].requires_level) color = font->getColor(FontEngine::COLOR_REQUIREMENTS_NOT_MET); else color = font->getColor(FontEngine::COLOR_WIDGET_NORMAL); tip.addColoredText(msg->get("Requires Level %d", items[stack.item].requires_level), color); } // base stat requirement for (unsigned i=0; i<items[stack.item].req_stat.size(); ++i) { if (items[stack.item].req_val[i] > 0) { if (stats->get_primary(items[stack.item].req_stat[i]) < items[stack.item].req_val[i]) color = font->getColor(FontEngine::COLOR_REQUIREMENTS_NOT_MET); else color = font->getColor(FontEngine::COLOR_WIDGET_NORMAL); tip.addColoredText(msg->get("Requires %s %d", eset->primary_stats.list[items[stack.item].req_stat[i]].name, items[stack.item].req_val[i]), color); } } // requires class if (items[stack.item].requires_class != "") { if (items[stack.item].requires_class != stats->character_class) color = font->getColor(FontEngine::COLOR_REQUIREMENTS_NOT_MET); else color = font->getColor(FontEngine::COLOR_WIDGET_NORMAL); tip.addColoredText(msg->get("Requires Class: %s", msg->get(items[stack.item].requires_class)), color); } // buy or sell price if (items[stack.item].getPrice() > 0 && stack.item != eset->misc.currency_id) { int price_per_unit; if (context == VENDOR_BUY) { price_per_unit = items[stack.item].getPrice(); if (stats->currency < price_per_unit) color = font->getColor(FontEngine::COLOR_REQUIREMENTS_NOT_MET); else color = font->getColor(FontEngine::COLOR_WIDGET_NORMAL); if (items[stack.item].max_quantity <= 1) tip.addColoredText(msg->get("Buy Price: %d %s", price_per_unit, eset->loot.currency), color); else tip.addColoredText(msg->get("Buy Price: %d %s each", price_per_unit, eset->loot.currency), color); } else if (context == VENDOR_SELL) { price_per_unit = items[stack.item].getSellPrice(stack.can_buyback); if (stats->currency < price_per_unit) color = font->getColor(FontEngine::COLOR_REQUIREMENTS_NOT_MET); else color = font->getColor(FontEngine::COLOR_WIDGET_NORMAL); if (items[stack.item].max_quantity <= 1) tip.addColoredText(msg->get("Buy Price: %d %s", price_per_unit, eset->loot.currency), color); else tip.addColoredText(msg->get("Buy Price: %d %s each", price_per_unit, eset->loot.currency), color); } else if (context == PLAYER_INV) { price_per_unit = items[stack.item].getSellPrice(DEFAULT_SELL_PRICE); if (price_per_unit == 0) price_per_unit = 1; if (items[stack.item].max_quantity <= 1) tip.addText(msg->get("Sell Price: %d %s", price_per_unit, eset->loot.currency)); else tip.addText(msg->get("Sell Price: %d %s each", price_per_unit, eset->loot.currency)); } } if (items[stack.item].set > 0) { // item set bonuses ItemSet set = item_sets[items[stack.item].set]; bonus_counter = 0; tip.addColoredText("\n" + msg->get("Set:") + ' ' + msg->get(item_sets[items[stack.item].set].name), set.color); while (bonus_counter < set.bonus.size()) { ss.str(""); SetBonusData* bdata = &set.bonus[bonus_counter]; ss << msg->get("%d items:", bdata->requirement) << ' '; getBonusString(ss, bdata); tip.addColoredText(ss.str(), set.color); bonus_counter++; } } // input hint for consumables/books // TODO hint when not using mouse control. The action for using an item there is hard to describe if (context == PLAYER_INV && !settings->no_mouse) { int power_id = items[stack.item].power; if (power_id > 0 && items[stack.item].type == "consumable") { tip.addColoredText('\n' + msg->get("Press [%s] to use", inpt->getBindingString(Input::MAIN2)), font->getColor(FontEngine::COLOR_ITEM_BONUS)); } else if (!items[stack.item].book.empty()) { tip.addColoredText('\n' + msg->get("Press [%s] to read", inpt->getBindingString(Input::MAIN2)), font->getColor(FontEngine::COLOR_ITEM_BONUS)); } } return tip; }
/** * Create detailed tooltip showing all relevant item info */ TooltipData ItemManager::getTooltip(int item, StatBlock *stats, int context) { TooltipData tip; SDL_Color color = color_normal; if (item == 0) return tip; // color quality if (items[item].set > 0) { color = item_sets[items[item].set].color; } else if (items[item].quality == ITEM_QUALITY_LOW) { color = color_low; } else if (items[item].quality == ITEM_QUALITY_HIGH) { color = color_high; } else if (items[item].quality == ITEM_QUALITY_EPIC) { color = color_epic; } // name tip.addText(items[item].name, color); // level if (items[item].level != 0) { tip.addText(msg->get("Level %d", items[item].level)); } // type if (items[item].type != "other") { tip.addText(msg->get(getItemType(items[item].type))); } // damage if (items[item].dmg_melee_max > 0) { if (items[item].dmg_melee_min < items[item].dmg_melee_max) tip.addText(msg->get("Melee damage: %d-%d", items[item].dmg_melee_min, items[item].dmg_melee_max)); else tip.addText(msg->get("Melee damage: %d", items[item].dmg_melee_max)); } if (items[item].dmg_ranged_max > 0) { if (items[item].dmg_ranged_min < items[item].dmg_ranged_max) tip.addText(msg->get("Ranged damage: %d-%d", items[item].dmg_ranged_min, items[item].dmg_ranged_max)); else tip.addText(msg->get("Ranged damage: %d", items[item].dmg_ranged_max)); } if (items[item].dmg_ment_max > 0) { if (items[item].dmg_ment_min < items[item].dmg_ment_max) tip.addText(msg->get("Mental damage: %d-%d", items[item].dmg_ment_min, items[item].dmg_ment_max)); else tip.addText(msg->get("Mental damage: %d", items[item].dmg_ment_max)); } // absorb if (items[item].abs_max > 0) { if (items[item].abs_min < items[item].abs_max) tip.addText(msg->get("Absorb: %d-%d", items[item].abs_min, items[item].abs_max)); else tip.addText(msg->get("Absorb: %d", items[item].abs_max)); } // bonuses unsigned bonus_counter = 0; string modifier; while (bonus_counter < items[item].bonus_val.size() && items[item].bonus_stat[bonus_counter] != "") { if (items[item].bonus_stat[bonus_counter] == "speed") { modifier = msg->get("%d\% Speed", items[item].bonus_val[bonus_counter]); if (items[item].bonus_val[bonus_counter] >= 100) color = color_bonus; else color = color_penalty; } else { if (items[item].bonus_val[bonus_counter] > 0) {
void GameStateConfigDesktop::renderTooltips(TooltipData& tip_new) { GameStateConfigBase::renderTooltips(tip_new); if (active_tab == INPUT_TAB && tip_new.isEmpty()) tip_new = joystick_device_lstb->checkTooltip(inpt->mouse); }
/** * Show mouseover descriptions of disciplines and powers */ TooltipData MenuPowers::checkTooltip(Point mouse) { TooltipData tip; for (unsigned i=0; i<power_cell.size(); i++) { if ((tabs_count > 1) && (tabControl->getActiveTab() != power_cell[i].tab)) continue; if (isWithin(slots[i]->pos, mouse)) { tip.addText(powers->powers[power_cell[i].id].name); if (powers->powers[power_cell[i].id].passive) tip.addText("Passive"); tip.addText(powers->powers[power_cell[i].id].description); if (powers->powers[power_cell[i].id].requires_physical_weapon) tip.addText(msg->get("Requires a physical weapon")); else if (powers->powers[power_cell[i].id].requires_mental_weapon) tip.addText(msg->get("Requires a mental weapon")); else if (powers->powers[power_cell[i].id].requires_offense_weapon) tip.addText(msg->get("Requires an offense weapon")); // add requirement if ((power_cell[i].requires_physoff > 0) && (stats->physoff() < power_cell[i].requires_physoff)) { tip.addText(msg->get("Requires Physical Offense %d", power_cell[i].requires_physoff), color_penalty); } else if((power_cell[i].requires_physoff > 0) && (stats->physoff() >= power_cell[i].requires_physoff)) { tip.addText(msg->get("Requires Physical Offense %d", power_cell[i].requires_physoff)); } if ((power_cell[i].requires_physdef > 0) && (stats->physdef() < power_cell[i].requires_physdef)) { tip.addText(msg->get("Requires Physical Defense %d", power_cell[i].requires_physdef), color_penalty); } else if ((power_cell[i].requires_physdef > 0) && (stats->physdef() >= power_cell[i].requires_physdef)) { tip.addText(msg->get("Requires Physical Defense %d", power_cell[i].requires_physdef)); } if ((power_cell[i].requires_mentoff > 0) && (stats->mentoff() < power_cell[i].requires_mentoff)) { tip.addText(msg->get("Requires Mental Offense %d", power_cell[i].requires_mentoff), color_penalty); } else if ((power_cell[i].requires_mentoff > 0) && (stats->mentoff() >= power_cell[i].requires_mentoff)) { tip.addText(msg->get("Requires Mental Offense %d", power_cell[i].requires_mentoff)); } if ((power_cell[i].requires_mentdef > 0) && (stats->mentdef() < power_cell[i].requires_mentdef)) { tip.addText(msg->get("Requires Mental Defense %d", power_cell[i].requires_mentdef), color_penalty); } else if ((power_cell[i].requires_mentdef > 0) && (stats->mentdef() >= power_cell[i].requires_mentdef)) { tip.addText(msg->get("Requires Mental Defense %d", power_cell[i].requires_mentdef)); } if ((power_cell[i].requires_offense > 0) && (stats->get_offense() < power_cell[i].requires_offense)) { tip.addText(msg->get("Requires Offense %d", power_cell[i].requires_offense), color_penalty); } else if ((power_cell[i].requires_offense > 0) && (stats->get_offense() >= power_cell[i].requires_offense)) { tip.addText(msg->get("Requires Offense %d", power_cell[i].requires_offense)); } if ((power_cell[i].requires_defense > 0) && (stats->get_defense() < power_cell[i].requires_defense)) { tip.addText(msg->get("Requires Defense %d", power_cell[i].requires_defense), color_penalty); } else if ((power_cell[i].requires_defense > 0) && (stats->get_defense() >= power_cell[i].requires_defense)) { tip.addText(msg->get("Requires Defense %d", power_cell[i].requires_defense)); } if ((power_cell[i].requires_physical > 0) && (stats->get_physical() < power_cell[i].requires_physical)) { tip.addText(msg->get("Requires Physical %d", power_cell[i].requires_physical), color_penalty); } else if ((power_cell[i].requires_physical > 0) && (stats->get_physical() >= power_cell[i].requires_physical)) { tip.addText(msg->get("Requires Physical %d", power_cell[i].requires_physical)); } if ((power_cell[i].requires_mental > 0) && (stats->get_mental() < power_cell[i].requires_mental)) { tip.addText(msg->get("Requires Mental %d", power_cell[i].requires_mental), color_penalty); } else if ((power_cell[i].requires_mental > 0) && (stats->get_mental() >= power_cell[i].requires_mental)) { tip.addText(msg->get("Requires Mental %d", power_cell[i].requires_mental)); } // Draw required Level Tooltip if ((power_cell[i].requires_level > 0) && stats->level < power_cell[i].requires_level) { tip.addText(msg->get("Requires Level %d", power_cell[i].requires_level), color_penalty); } else if ((power_cell[i].requires_level > 0) && stats->level >= power_cell[i].requires_level) { tip.addText(msg->get("Requires Level %d", power_cell[i].requires_level)); } // Draw required Skill Point Tooltip if ((power_cell[i].requires_point) && !(find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end()) && (points_left < 1)) { tip.addText(msg->get("Requires %d Skill Point", power_cell[i].requires_point), color_penalty); } else if ((power_cell[i].requires_point) && !(find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end()) && (points_left > 0)) { tip.addText(msg->get("Requires %d Skill Point", power_cell[i].requires_point)); } // Draw unlock power Tooltip if (power_cell[i].requires_point && !(find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end()) && (points_left > 0) && powerUnlockable(power_cell[i].id) && (points_left > 0)) { tip.addText(msg->get("Click to Unlock"), color_bonus); } // Required Power Tooltip if ((power_cell[i].requires_power != 0) && !(requirementsMet(power_cell[i].requires_power))) { tip.addText(msg->get("Requires Power: %s", powers->powers[power_cell[i].requires_power].name), color_penalty); } else if ((power_cell[i].requires_power != 0) && (requirementsMet(power_cell[i].requires_power))) { tip.addText(msg->get("Requires Power: %s", powers->powers[power_cell[i].requires_power].name)); } // add mana cost if (powers->powers[power_cell[i].id].requires_mp > 0) { tip.addText(msg->get("Costs %d MP", powers->powers[power_cell[i].id].requires_mp)); } // add health cost if (powers->powers[power_cell[i].id].requires_hp > 0) { tip.addText(msg->get("Costs %d HP", powers->powers[power_cell[i].id].requires_hp)); } // add cooldown time if (powers->powers[power_cell[i].id].cooldown > 0) { tip.addText(msg->get("Cooldown: %d seconds", powers->powers[power_cell[i].id].cooldown / MAX_FRAMES_PER_SEC)); } return tip; } } return tip; }
void GameStateConfigBase::renderTooltips(TooltipData& tip_new) { if (active_tab == INTERFACE_TAB && tip_new.isEmpty()) tip_new = language_lstb->checkTooltip(inpt->mouse); if (active_tab == MODS_TAB && tip_new.isEmpty()) tip_new = activemods_lstb->checkTooltip(inpt->mouse); if (active_tab == MODS_TAB && tip_new.isEmpty()) tip_new = inactivemods_lstb->checkTooltip(inpt->mouse); }
/** * 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.addText(ss.str(), color); // quest item if (items[stack.item].quest_item) { tip.addText(msg->get("Quest Item"), color_bonus); } // only show the name of the currency item if (stack.item == CURRENCY_ID) return tip; // flavor text if (items[stack.item].flavor != "") { tip.addText(substituteVarsInString(items[stack.item].flavor, pc), color_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 (COLORBLIND && items[stack.item].quality != "") { color = color_normal; for (size_t i=0; i<item_qualities.size(); ++i) { if (item_qualities[i].id == items[stack.item].quality) { tip.addText(msg->get("Quality: %s", msg->get(item_qualities[i].name)), color); break; } } } // damage if (items[stack.item].dmg_melee_max > 0) { if (items[stack.item].dmg_melee_min < items[stack.item].dmg_melee_max) tip.addText(msg->get("Melee damage: %d-%d", items[stack.item].dmg_melee_min, items[stack.item].dmg_melee_max)); else tip.addText(msg->get("Melee damage: %d", items[stack.item].dmg_melee_max)); } if (items[stack.item].dmg_ranged_max > 0) { if (items[stack.item].dmg_ranged_min < items[stack.item].dmg_ranged_max) tip.addText(msg->get("Ranged damage: %d-%d", items[stack.item].dmg_ranged_min, items[stack.item].dmg_ranged_max)); else tip.addText(msg->get("Ranged damage: %d", items[stack.item].dmg_ranged_max)); } if (items[stack.item].dmg_ment_max > 0) { if (items[stack.item].dmg_ment_min < items[stack.item].dmg_ment_max) tip.addText(msg->get("Mental damage: %d-%d", items[stack.item].dmg_ment_min, items[stack.item].dmg_ment_max)); else tip.addText(msg->get("Mental damage: %d", items[stack.item].dmg_ment_max)); } // 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) { ss << msg->get("%d%% Speed", bdata->value); if (bdata->value >= 100) color = color_bonus; else color = color_penalty; } else { if (bdata->value > 0) { color = color_bonus; } else { color = color_penalty; } getBonusString(ss, bdata); } tip.addText(ss.str(), color); bonus_counter++; } // power if (items[stack.item].power_desc != "") { tip.addText(items[stack.item].power_desc, color_bonus); } // level requirement if (items[stack.item].requires_level > 0) { if (stats->level < items[stack.item].requires_level) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Level %d", items[stack.item].requires_level), color); } // base stat requirement for (unsigned i=0; i<items[stack.item].req_stat.size(); ++i) { if (items[stack.item].req_val[i] > 0) { if (items[stack.item].req_stat[i] == REQUIRES_PHYS) { if (stats->get_physical() < items[stack.item].req_val[i]) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Physical %d", items[stack.item].req_val[i]), color); } else if (items[stack.item].req_stat[i] == REQUIRES_MENT) { if (stats->get_mental() < items[stack.item].req_val[i]) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Mental %d", items[stack.item].req_val[i]), color); } else if (items[stack.item].req_stat[i] == REQUIRES_OFF) { if (stats->get_offense() < items[stack.item].req_val[i]) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Offense %d", items[stack.item].req_val[i]), color); } else if (items[stack.item].req_stat[i] == REQUIRES_DEF) { if (stats->get_defense() < items[stack.item].req_val[i]) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Defense %d", items[stack.item].req_val[i]), color); } } } // requires class if (items[stack.item].requires_class != "") { if (items[stack.item].requires_class != stats->character_class) color = color_requirements_not_met; else color = color_normal; tip.addText(msg->get("Requires Class: %s", msg->get(items[stack.item].requires_class)), color); } // buy or sell price if (items[stack.item].getPrice() > 0 && stack.item != CURRENCY_ID) { int price_per_unit; if (context == VENDOR_BUY) { price_per_unit = items[stack.item].getPrice(); if (stats->currency < price_per_unit) color = color_requirements_not_met; else color = color_normal; if (items[stack.item].max_quantity <= 1) tip.addText(msg->get("Buy Price: %d %s", price_per_unit, CURRENCY), color); else tip.addText(msg->get("Buy Price: %d %s each", price_per_unit, CURRENCY), color); } else if (context == VENDOR_SELL) { price_per_unit = items[stack.item].getSellPrice(); if (stats->currency < price_per_unit) color = color_requirements_not_met; else color = color_normal; if (items[stack.item].max_quantity <= 1) tip.addText(msg->get("Buy Price: %d %s", price_per_unit, CURRENCY), color); else tip.addText(msg->get("Buy Price: %d %s each", price_per_unit, CURRENCY), color); } else if (context == PLAYER_INV) { price_per_unit = items[stack.item].getSellPrice(); if (price_per_unit == 0) price_per_unit = 1; if (items[stack.item].max_quantity <= 1) tip.addText(msg->get("Sell Price: %d %s", price_per_unit, CURRENCY)); else tip.addText(msg->get("Sell Price: %d %s each", price_per_unit, CURRENCY)); } } if (items[stack.item].set > 0) { // item set bonuses ItemSet set = item_sets[items[stack.item].set]; bonus_counter = 0; tip.addText("\n" + msg->get("Set: ") + msg->get(item_sets[items[stack.item].set].name), set.color); while (bonus_counter < set.bonus.size()) { ss.str(""); Set_bonus* bdata = &set.bonus[bonus_counter]; ss << msg->get("%d items: ", bdata->requirement); if (bdata->is_speed) { ss << msg->get("%d%% Speed", bdata->value); } else { getBonusString(ss, bdata); } tip.addText(ss.str(), set.color); bonus_counter++; } } return tip; }