-
Posted by Taborious on Tue, 30 Jun 2009 20:43:15
ok, i have a frame and in that frame I want to populate it with a row for each raid member. each column of these rows would contain data specific to each toon. So for example, 25 people in the raid, there would be 25 rows and about 5 columns displaying data specific to each toon in the list.
Below is the code i started, not all the columns i want more for testing. Is this really the best way to do this? I will be populating each cell after build with information in a table created from scanning the raid.
First thing you will notice is that the first row is much different than the others, i was getting an error with the "." for my separators.
function TCoL_ScoreUs_FontStrings() tcolsufsname = {} tcolsu.fs = {} vStepping = -10 h.name = 2 h.score = 30 h.hp = 50 h.me = 70 h.gear = 100 for rowCount = 1, GetNumRaidMembers() do local tcolsufsname[rowCount] = TCoL_ScoreUs_Frame_Body:CreateFontString(nil, "OVERLAY", UIParent) --tcolsufsname[rowCount]:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME") tcolsufsname[rowCount]:SetFontObject(GameFontNormalSmall) tcolsufsname[rowCount]:SetPoint("TOPLEFT", TCoL_ScoreUs_Frame_Body, "TOPLEFT", h.name, vStepping) tcolsufsname[rowCount]:SetText("stuff") local tcolsu.fs[rowCount].score = TCoL_ScoreUs_Frame_Body:CreateFontString(nil, "OVERLAY") tcolsu.fs[rowCount].score:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME") tcolsu.fs[rowCount].score:SetPoint("TOPLEFT", TCoL_ScoreUs_Frame_Body, "TOPLEFT", h.score, vStepping) tcolsu.fs[rowCount].score:SetText("stuff") local tcolsu.fs[rowCount].hp = TCoL_ScoreUs_Frame_Body:CreateFontString(nil, "OVERLAY") tcolsu.fs[rowCount].hp:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME") tcolsu.fs[rowCount].hp:SetPoint("TOPLEFT", TCoL_ScoreUs_Frame_Body, "TOPLEFT", h.hp, vStepping) tcolsu.fs[rowCount].hp:SetText("stuff") end end
-
Posted by Taborious on Wed, 01 Jul 2009 13:56:31
OK, rather than debugging my code, how would one go about creating a dynamic fontstring structure inside a frame?
example:
numRows = 4 numColumns = 5
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4
so you end up with 20 different fontstrings that can set individually.
or are fontstrings not the way to go for getting this kind of result?
-
Posted by Mirrikat45 on Fri, 03 Jul 2009 16:44:50
I am also interested in this. Or at least an escape code that "Tabs".
-
Posted by jnwhiteh on Sun, 05 Jul 2009 15:02:05
OK, rather than debugging my code, how would one go about creating a dynamic fontstring structure inside a frame?
example:
numRows = 4 numColumns = 5
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4
so you end up with 20 different fontstrings that can set individually.
or are fontstrings not the way to go for getting this kind of result?
They are pretty much all you have. Here's how I would do something like that, assuming you have a frame called 'frame' in scope (code untested):
local rows = {} for i=1,numRows do -- Setup a table for this row that will hold the columns local row = {} -- Create the columns for j=1,numColumns do local fontstring = frame:CreateFontString(nil, "OVERLAY") row[j] = fontstring fontstring:SetText(tostring(i)) if i == 1 and j == 1 then -- Anchor the first column/row to the topleft of our frame fontstring:SetPoint("TOPLEFT", 0, 0) elseif j == 1 then -- Anchor the first column of any other row to the first column of the previous row fontstring:SetPoint("TOPLEFT", rows[i-1][1], "BOTTOMLEFT", 0, 0) else -- Anchor the columns left to right fontstring:SetPoint("TOPLEFT", row[j-1], "TOPRIGHT", 5, 0) end end end
-
Posted by jnwhiteh on Sun, 05 Jul 2009 15:02:21
I am also interested in this. Or at least an escape code that "Tabs".
There is no escape code in WoW that is capable of tabbing.
-
Posted by Taborious on Mon, 06 Jul 2009 15:07:53
I got it working so figured id share for anyone else looking to do something like this. In my code each row is a frame and then inside that frame i create fontstrings for the columns, works perfect. I also store the fontstring in a table so i can update them after some other code runs. If you take this code or anything like it remember you only need to run this ONE time when you addon first runs. putting this in a code sequence that runs this everytime the addon is opened will chew up memory.
function TCoL_ScoreUs_FontStrings() tcolsu_fs = {} local v_stepping = -10 local vpos = -25 --negative values move things down local hpos = 2 local COLS = 6 local rowHeight = 11 local rowWidth = 420 local colWidth = { [1]=12, [2]=95, [3]=60, [4]=60, [5]=50, [6]=50 } -- counter, name, score, HP, me, gear local colPos = 8 for rowCount = 1, 25 do colPos=3 local row = CreateFrame("Frame", nil, TCoL_ScoreUs_Frame_Body) if (rowCount == 1) then row:SetPoint("TOPLEFT", TCoL_ScoreUs_Frame_Body, "TOPLEFT", 4, vpos) row:SetWidth(rowWidth) row:SetHeight(rowHeight) row:Show() else row:SetPoint("TOPLEFT", TCoL_ScoreUs_Frame_Body, "TOPLEFT", 4, vpos) row:SetWidth(rowWidth) row:SetHeight(rowHeight) row:Show() end tcolsu_fs[rowCount] = {} for colCount=1,COLS do local fs = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") fs:SetPoint("TOPLEFT", row, "TOPLEFT", colPos, 0) fs:SetWidth(colWidth[colCount]) fs:SetHeight(rowHeight) fs:SetJustifyH("LEFT") colPos = colPos + colWidth[colCount] tcolsu_fs[rowCount][colCount] = fs end vpos = vpos + v_stepping end end
-
Posted by jnwhiteh on Mon, 06 Jul 2009 23:50:24
Glad to hear it, thanks for reporting back!