Ticket #1785: AttackIcons.patch

File AttackIcons.patch, 5.1 KB (added by Cerridan, 11 years ago)

Patch file.

  • binaries/data/mods/public/gui/session/selection_details.js

     
    191191    attack = "[font=\"serif-bold-13\"]"+type+"Attack:[/font] " + damageTypeDetails(entState.attack);
    192192    // Show max attack range if ranged attack, also convert to tiles (4m per tile)
    193193    if (entState.attack && entState.attack.type == "Ranged")
    194         attack += ", [font=\"serif-bold-13\"]Range:[/font] " + Math.round(entState.attack.maxRange/4);
     194        attack += " " + Math.round(entState.attack.maxRange/4) + getAtkComponentDisplayName("range");
    195195    getGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + damageTypeDetails(entState.armour);
    196196
    197197    // Icon Tooltip
  • binaries/data/mods/public/gui/session/setup.xml

     
    2626          sprite="stretched:session/icons/resources/time_small.png"
    2727          size="16 16"
    2828    />
     29    <icon name="iconHack"
     30          sprite="stretched:session/icons/damagetypes/hack.png"
     31          size="16 16"
     32    />
     33    <icon name="iconPierce"
     34          sprite="stretched:session/icons/damagetypes/pierce.png"
     35          size="16 16"
     36    />
     37    <icon name="iconCrush"
     38          sprite="stretched:session/icons/damagetypes/crush.png"
     39          size="16 16"
     40    />
     41    <icon name="iconRange"
     42          sprite="stretched:session/icons/damagetypes/range.png"
     43          size="16 16"
     44    />
    2945</setup>
  • binaries/data/mods/public/gui/session/utility_functions.js

     
    1212    "time": "[icon=\"iconTime\"]"
    1313};
    1414
     15const ATTACK_DISPLAY_NAMES = {
     16    "hack": "[icon=\"iconHack\"]",
     17    "pierce": "[icon=\"iconPierce\"]",
     18    "crush": "[icon=\"iconCrush\"]",
     19    "range": "[icon=\"iconRange\"]"
     20};
    1521//-------------------------------- -------------------------------- --------------------------------
    1622// Utility functions
    1723//-------------------------------- -------------------------------- --------------------------------
     
    164170    if (dmg)
    165171    {
    166172        var dmgArray = [];
    167         if (dmg.hack) dmgArray.push(dmg.hack + "[font=\"sans-10\"][color=\"orange\"] Hack[/color][/font]");
    168         if (dmg.pierce) dmgArray.push(dmg.pierce + "[font=\"sans-10\"][color=\"orange\"] Pierce[/color][/font]");
    169         if (dmg.crush) dmgArray.push(dmg.crush + "[font=\"sans-10\"][color=\"orange\"] Crush[/color][/font]");
     173        if (dmg.hack) dmgArray.push(dmg.hack + getAtkComponentDisplayName("hack"));//"[font=\"sans-10\"][color=\"orange\"] Hack[/color][/font]");
     174        if (dmg.pierce) dmgArray.push(dmg.pierce + getAtkComponentDisplayName("pierce")); //"[font=\"sans-10\"][color=\"orange\"] Pierce[/color][/font]");
     175        if (dmg.crush) dmgArray.push(dmg.crush + getAtkComponentDisplayName("crush")); //"[font=\"sans-10\"][color=\"orange\"] Crush[/color][/font]");
    170176
    171         return dmgArray.join(", ");
     177        return dmgArray.join(" ");
    172178    }
    173179    else
    174180    {
     
    182188    if (!dmg)
    183189        return "[font=\"serif-12\"](None)[/font]";
    184190
    185     var hackLabel = "[font=\"serif-12\"] Hack[/font]";
    186     var pierceLabel = "[font=\"serif-12\"] Pierce[/font]";
    187     var crushLabel = "[font=\"serif-12\"] Crush[/font]";
     191    var hackLabel = getAtkComponentDisplayName("hack");
     192    var pierceLabel = getAtkComponentDisplayName("pierce");
     193    var crushLabel = getAtkComponentDisplayName("crush");
    188194    var hackDamage = dmg.hack;
    189195    var pierceDamage = dmg.pierce;
    190196    var crushDamage = dmg.crush;
     
    194200    if (pierceDamage) dmgArray.push(pierceDamage + pierceLabel);
    195201    if (crushDamage) dmgArray.push(crushDamage + crushLabel);
    196202
    197     return dmgArray.join("[font=\"serif-12\"], [/font]");
     203    return dmgArray.join("[font=\"serif-12\"] [/font]");
    198204}
    199205
    200206function getEntityCommandsList(entState)
     
    260266}
    261267
    262268/**
     269 * Translates an attack identifier as they are used internally (e.g. "hack", "pierce", etc.) to proper
     270 * display names.
     271 */
     272function getAtkComponentDisplayName(attackComponentName)
     273{
     274    return ATTACK_DISPLAY_NAMES[attackComponentName];
     275}
     276/**
    263277 * Helper function for getEntityCostTooltip.
    264278 */
    265279function getEntityCostComponentsTooltipString(template, trainNum, entity)
     
    425439            var attack = "[font=\"serif-bold-13\"]" + type + " Attack:[/font] " + damageTypesToText(template.attack[type]);
    426440            // Show max attack range if ranged attack, also convert to tiles (4m per tile)
    427441            if (type == "Ranged")
    428                 attack += ", [font=\"serif-bold-13\"]Range:[/font] "+Math.round(template.attack[type].maxRange/4);
     442                attack += " " + Math.round(template.attack[type].maxRange/4) + getAtkComponentDisplayName("range");
    429443            attacks.push(attack);
    430444        }
    431445    }