[Lua] [Lua] [Jass] Correcting attack/armor icon placement

Hello! I noticed a while ago that the Reforged icons were being cut off, or overlapping, in game. This is a script to correct that behavior.

In the image, you can see how both the (un-upgraded) and (upgradable) icons no longer overlap and cut each other off, versus the original, which removes a pixel line of the icon border, or covers the upgrade value box.

This also aligns the Damage text with Strength, on heroes.

JASS:
scope DamageAlignment initializer Init
    function UISetup takes nothing returns nothing
        local framehandle fh = BlzGetFrameByName("InfoPanelIconBackdrop", 0)
        call BlzFrameClearAllPoints(fh)
        call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPRIGHT, 0.3455, 0.083)
        set fh = null
    endfunction
 
    private function Init takes nothing returns nothing
        call UISetup()
    endfunction
endscope

Lua:
do
    local timer = CreateTimer()
    TimerStart( timer, 0, false, function()
        local framehandle
        fh = BlzGetFrameByName("InfoPanelIconBackdrop", 0)
        BlzFrameClearAllPoints(fh)
        BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPRIGHT, 0.3455, 0.083)
        DestroyTimer(timer)
    end)
end

attackarmorexample.png
 
Last edited:
Level 22
Joined
Jan 1, 2011
Messages
1,465
Undefined handles are already null, so no need to do that during local declaration.

However, you do need to null that handle at the end of the script.

Also you might as well define the local immediately:
JASS:
function UISetup takes nothing returns nothing
    local framehandle fh = BlzGetFrameByName("InfoPanelIconBackdrop", 0)
    // Fix Damage and Armor overlap
    call BlzFrameClearAllPoints(fh)
    call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPRIGHT, 0.3455, 0.083)
     set fh = null
endfunction
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,328
You should add proper vJASS initialization. There is no need for a pure JASS version, because this resource is only for newer versions.
 

Bribe

Code Moderator
Level 47
Joined
Sep 26, 2009
Messages
9,233
Even something simple like:

Lua:
do
    local timer = CreateTimer()
    TimerStart( timer, 0, false, function()
        local framehandle
        fh = BlzGetFrameByName("InfoPanelIconBackdrop", 0)
        BlzFrameClearAllPoints(fh)
        BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPRIGHT, 0.3455, 0.083)
        DestroyTimer(timer)
    end)
    print(“Timer Started”) -- won’t run. Or at least, didn’t run back in 2019.
end
 
Top