MCPcopy Create free account
hub / github.com/TurningWheel/Barony / getSpellIconPath

Method getSpellIconPath

src/mod_tools.cpp:3103–3170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3101}
3102
3103std::string ItemTooltips_t::getSpellIconPath(const int player, Item& item, int spellID)
3104{
3105#ifdef EDITOR
3106 return "items/images/null.png";
3107#else
3108 node_t* spellImageNode = nullptr;
3109 if ( itemCategory(&item) == MAGICSTAFF )
3110 {
3111 spell_t* spell = nullptr;
3112 for ( auto& s : spellItems )
3113 {
3114 if ( s.second.magicstaffId == item.type )
3115 {
3116 spell = getSpellFromID(s.first);
3117 break;
3118 }
3119 }
3120 if ( spell )
3121 {
3122 spellImageNode = list_Node(&items[SPELL_ITEM].images, spell->ID);
3123 }
3124 else
3125 {
3126 spellImageNode = list_Node(&items[SPELL_ITEM].images, 0);
3127 }
3128 }
3129 else if ( itemCategory(&item) == SPELLBOOK )
3130 {
3131 spellImageNode = list_Node(&items[SPELL_ITEM].images, getSpellIDFromSpellbook(item.type));
3132 }
3133 else if ( itemCategory(&item) == TOME_SPELL )
3134 {
3135 spellImageNode = list_Node(&items[SPELL_ITEM].images, item.getTomeSpellID());
3136 }
3137 else if ( item.type == TOOL_SPELLBOT )
3138 {
3139 spellImageNode = list_Node(&items[SPELL_ITEM].images, item.status < EXCELLENT ? SPELL_FORCEBOLT : SPELL_MAGICMISSILE);
3140 }
3141 else if ( item.type == SPELL_ITEM )
3142 {
3143 if ( spellID > SPELL_NONE )
3144 {
3145 spellImageNode = getSpellNodeFromSpellID(spellID);
3146 }
3147 else
3148 {
3149 spell_t* spell = getSpellFromItem(player, &item, false);
3150 if ( spell )
3151 {
3152 spellImageNode = getSpellNodeFromSpellID(spell->ID);
3153 }
3154 else
3155 {
3156 spellImageNode = getSpellNodeFromSpellID(SPELL_NONE);
3157 }
3158 }
3159 }
3160 if ( spellImageNode )

Callers 2

getItemSpritePathFunction · 0.80
updateFrameTooltipMethod · 0.80

Calls 6

getSpellFromIDFunction · 0.85
list_NodeFunction · 0.85
getSpellIDFromSpellbookFunction · 0.85
getSpellFromItemFunction · 0.85
getTomeSpellIDMethod · 0.80
itemCategoryFunction · 0.70

Tested by

no test coverage detected