Code:
function BetterItemCount_SetItemButtonCount(button, count)
-- orig by Miyke
if ( not button ) then return end
if ( not count ) then
count = 0
end
button.count = count
local countText = getglobal(button:GetName().."Count")
if count > 1 or (button.isBag and count > 0) then
if count > 999 then
local fixedCount = count+50
count = floor((fixedCount)/1000).."."..floor(((mod(fixedCount, 1000))/100)).."k"
end
countText:SetText(count)
countText:Show()
else
countText:Hide()
end
end
hooksecurefunc("SetItemButtonCount",BetterItemCount_SetItemButtonCount)
Any help in fixing this would be greatly appreciated. Thanks in advance.|||Quote:
I'm currently using the addon BetterItemCount out of the old Cosmos pack. I love the addon, however with the semi-recent ammo change to allow ammo to stack to 1k the font size on the ammo bag is too large to display properly on the button and as much as I have tried I cannot figure out how to change the font size. I will paste the code so someone can look at it and either fix it or tell me what to do as I'm really new to lua coding. I did mess around a bit with the xml from EverQuest.. but this is a whole new ball game.
Code:
function BetterItemCount_SetItemButtonCount(button, count)
-- orig by Miyke
if ( not button ) then return end
if ( not count ) then
count = 0
end
button.count = count
local countText = getglobal(button:GetName().."Count")
if count > 1 or (button.isBag and count > 0) then
if count > 999 then
local fixedCount = count+50
count = floor((fixedCount)/1000).."."..floor(((mod(fixedCount, 1000))/100)).."k"
end
countText:SetText(count)
countText:Show()
else
countText:Hide()
end
end
hooksecurefunc("SetItemButtonCount",BetterItemCount_SetItemButtonCount)
Any help in fixing this would be greatly appreciated. Thanks in advance.
Hmm... What is it that you want really? This one will say "1.0k" and similar when you cross the 1000 barrier (with an ugly approach to integer rounding). Is that not enough? Do you want an exact count even when it is above 1000?
Anyway - if you want to change the font size, it has nothing to do with the code you pasted.
It all depends on how the number-display is defined in the XML code. But most likely you can redefine it with this:
getglobal(button:GetName().."Count"):SetTextHeight(<your new height>)
If the count-display is defined to follow the text-size, it should work just fine. Also it may be overridden somewhere in the lua-code somewhere. Make an extensive search for "SetTextHeight" to make sure it is not.
Since I have no idea what so ever how the rest of the code looks like, I can at least say that you should be able to insert the new code in the code you pasted here. There's probably a better place, but that should work just fine.
No comments:
Post a Comment