balakethelock / SuperAPI

The companion compatibility addon to the 1.12.1 client mod SuperWoW
10 stars 7 forks source link

SUPERAPIHOOK_SetItemButtonCount Fixes/Updates #2

Open veechs opened 6 months ago

veechs commented 6 months ago

Updates to SUPERAPIHOOK_SetItemButtonCount:

veechs commented 6 months ago

I just realized that always relying on Blizzard code means that when charges is at 1, they’ll be hidden just like count, which is probably why you didn’t write it that way. So if that’s your goal, feel free to ignore this (you’ll probably still want to fix the string concatenation bug though).

veechs commented 6 months ago

A simple fix for only the concatination issue would be:

function SUPERAPIHOOK_SetItemButtonCount(button, count)
    if not button or not count then
        return SUPERAPIHOOK_SetItemButtonCountOriginal(button, count)
    end
    if (count < 0) then
        getglobal(button:GetName().."Count"):SetText((count < -999) and "*" or math.abs(count));
        getglobal(button:GetName().."Count"):Show();
        getglobal(button:GetName().."Count"):SetFontObject(NumberFontNormalYellow);
    else
        getglobal(button:GetName().."Count"):SetFontObject(NumberFontNormal);
        SUPERAPIHOOK_SetItemButtonCountOriginal(button, count)
    end
end