Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-19-20, 04:37 PM   #1
Zulu
A Murloc Raider
Join Date: Nov 2020
Posts: 5
Fontstrings not displaying in certain cases

Hello everyone,

I'm working on an addon which will help players manage their auctions and their stock of "comodities".

Right now, I'm coding a tab in my addon panel called stockpile, which list all reagent in either a list view, or a grid view.

There is also a dropdown with all types of reagent so the user can filter the list or the grid by a specific type (enchanting, metal and stone, ...)

Here is how the grid view looks with no filter (the dropdown in the center is set to "all")



As you can see, on each reagent icon, there is a text which is the count of this reagant in all bags, bank, etc..

But, when I apply a filter, the count texts don't show anymore, and I can't understand why. Here is how it looks with a random filter



Count texts are not shown ! Here is my lua code :

Code:
function Merchant.UI.AddStockpileStock(itemID, count)
  if #Merchant.UI.StockpileStocks < Merchant.UI.StockpileStockCnt then
    local frame = Merchant.UI.StockpileGridScrollFrameContent
    local x = (32 + 10) * ((Merchant.UI.StockpileStockCnt - 1) % Merchant.UI.StockpileGridMaxPerLine)
    local y = (-32 - 10) * math.floor((Merchant.UI.StockpileStockCnt - 1) / Merchant.UI.StockpileGridMaxPerLine)

    local iconFrame = CreateFrame("Frame", nil, frame)
    iconFrame:SetSize(32, 32)
    iconFrame:SetPoint("TOPLEFT", x, y)
    local itemTexture = iconFrame:CreateTexture(nil, "OVERLAY")
    itemTexture:SetAllPoints()

    local countFrame = CreateFrame("Frame", nil, frame)
    countFrame:SetSize(32, 32)
    countFrame:SetPoint("TOPLEFT", x, y - 9)
    local itemCountText = countFrame:CreateFontString(nil, "OVERLAY")
    itemCountText:SetAllPoints()
    itemCountText:SetFont("Fonts\\FRIZQT__.TTF", 11, "THICKOUTLINE")
    itemCountText:SetJustifyH("RIGHT")

    table.insert(Merchant.UI.StockpileStocks, {
      IconFrame = iconFrame,
      ItemTexture = itemTexture,
      ItemCountFrame = countFrame,
      ItemCountText = itemCountText
    })
  end

  local stock = Merchant.UI.StockpileStocks[Merchant.UI.StockpileStockCnt]
  stock.ItemTexture:SetTexture(GetItemIcon(itemID))
  stock.ItemCountText:SetText("|cFFFFFFFF" .. tostring(count))

  Merchant.UI.StockpileStockCnt = Merchant.UI.StockpileStockCnt + 1
  Merchant.UI.StockpileGridScrollFrameContent:SetHeight((32 + 10) * math.floor((Merchant.UI.StockpileStockCnt - 1) / Merchant.UI.StockpileGridMaxPerLine))
end

--------------------------------------------------------------------------------

function Merchant.UI.EmptyStockpileGrid()
  for key, row in pairs(Merchant.UI.StockpileStocks) do
    row.ItemTexture:SetTexture("")
    row.ItemCountText:SetText("")
  end
  Merchant.UI.StockpileStockCnt = 1
end

--------------------------------------------------------------------------------

function Merchant.UI.DrawStockpileGrid(charName, filter)
  Merchant.UI.EmptyStockpileGrid()
  local stockpile = Merchant_Vars.Accounts[Merchant.RealmName].Stockpile[charName]
  if stockpile == nil then
    Merchant.Debug("error: no stockpile for " .. charName .. " character")
    return
  end
  if filter == "all" then
    table.sort(stockpile, function (a, b) return a.ItemSubClassID < b.ItemSubClassID end)
  end
  for idx, stock in ipairs(stockpile) do
    if filter == "all" or stock.ItemSubClassID == filter then
      Merchant.UI.AddStockpileStock(stock.ItemID, stock.ItemCount)
    end
  end
  if math.floor((Merchant.UI.StockpileStockCnt - 1) / Merchant.UI.StockpileGridMaxPerLine) > 9 then
    Merchant.UI.StockpileGridScrollFrameSlider:Show()
  else
    Merchant.UI.StockpileGridScrollFrameSlider:Hide()
  end
end
I create a frame which holds the texture (iconFrame).
I create a frame which holds the count text (countFrame).
They are both children of the upper frame, which is ScrollFrame.
They are created once when a new reagent is added for the first time and stored in a table for future use.
After the widgets are created, they are filled with the correct values, an item icon for the texture, and the reagent count for the count text.


At first, an upper function calls DrawStockpileGrid when the user selects the grid view or select a reagent type filter.
It calls first EmptyStockpileGrid which resets the table of widgets by setting their value to an empty string.
And then iterates an another table which contains all reagents for a character, calling AddStockpileStock for each stock.


I tried to play with frame stratas and levels but it didn't change anything. I tried to comment all code which concerns icons to leave only the countFrame and its FontString, but they still don't show.


I hope I gave you all necessary info. Thanks in advance for any info, help and advices. I'll give you any precision if you need it.
Attached Files
File Type: lua Stockpile_Grid.lua (3.6 KB, 124 views)
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Fontstrings not displaying in certain cases

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off