Thread Tools Display Modes
06-28-19, 05:01 PM   #21
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Yes, I wish they'd still put game manuals with the WoW expansions, now it's just a leaflet with download code

Most of the newer API had been undocumented ever since patch 8.0.1
I've started updating the api docs like 3 months ago and feel like almost nobody else really cares to contribute
https://wow.gamepedia.com/index.php?...action=history
  Reply With Quote
06-28-19, 11:04 PM   #22
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
Is FauxScrollFrame capable of, say, a 3-4 column sheet (ie: Listing players, their class, their dkp etc) that is sortable by each column? Or would that have to be Hybrid? If anyone had an example it would be great but if not, I'll figure it out eventually
  Reply With Quote
06-28-19, 11:35 PM   #23
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
Originally Posted by Ketho View Post
Yes, I wish they'd still put game manuals with the WoW expansions, now it's just a leaflet with download code

Most of the newer API had been undocumented ever since patch 8.0.1
I've started updating the api docs like 3 months ago and feel like almost nobody else really cares to contribute
https://wow.gamepedia.com/index.php?...action=history
Thank you Kethos that you did that!
  Reply With Quote
06-29-19, 02:08 AM   #24
LanceDH
A Cyclonian
 
LanceDH's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 41
Originally Posted by Ketho View Post
Yes, I wish they'd still put game manuals with the WoW expansions, now it's just a leaflet with download code

Most of the newer API had been undocumented ever since patch 8.0.1
I've started updating the api docs like 3 months ago and feel like almost nobody else really cares to contribute
https://wow.gamepedia.com/index.php?...action=history
I've updated the ItemType page a while back because it was outdated and I needed the info myself.
Either way, I have some free time the coming weeks, and my projects are up to date, so I'll see if I can add some documentation. I can try my hand at a HybridScrollFrames guide and fill in some missing documentation on stuff like the Cooldown widget.
  Reply With Quote
06-29-19, 06:36 AM   #25
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by LanceDH View Post
Either way, I have some free time the coming weeks, and my projects are up to date, so I'll see if I can add some documentation. I can try my hand at a HybridScrollFrames guide and fill in some missing documentation on stuff like the Cooldown widget.
That would be great, I'll see if I can add tables to the ItemType page with the LE_ITEM enums
  Reply With Quote
06-29-19, 09:39 AM   #26
fusionpit
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 6
Originally Posted by Aeriez View Post
Is FauxScrollFrame capable of, say, a 3-4 column sheet (ie: Listing players, their class, their dkp etc) that is sortable by each column?
Absolutely it is. The auction house uses a ScrollFrame based on FauxScrollFrameTemplate to implement the browse portion, which can also be sorted by the column tabs at top.

Here is the template blizz uses for the AH sort tabs, here is an example of how that template is used in xml, and here is the sorting being done in lua.

For your case you would need to store some state like the direction of the sort, but that would be pretty simple. You could use table.sort to reorder the source of the FSF, with the sort func being tied to the column and direction. After that you just run your Update function to repopulate the FSF with the newly ordered data.

Lua Code:
  1. local data = {
  2.     {player="Sveng",class="Mage",dkp=1.41},
  3.     {player="Sarex",class="Rogue",dkp=-50}
  4. };
  5. function MyFrame_Update()
  6.     local offset = FauxScrollFrame_GetOffset(MyScrollFrame);
  7.     for i=1,MAX_ROWS do
  8.         local row = _G["MyScrollFrameRow"..i];
  9.         local rowData = data[i+offset];
  10.         if (rowData ~= nil) then
  11.             -- set row data
  12.             row:Show();
  13.         else
  14.             row:Hide();
  15.         end
  16.     end
  17.     FauxScrollFrame_Update(MyScrollFrame, #data, MAX_ROWS, ROW_HEIGHT);
  18. end
  19. ...
  20. -- 'true' being asc, 'false' being desc, 'nil' being unsorted
  21. local sortDirections = {player=nil,class=nil,dkp=nil};
  22. local function sortData(propKey, direction)
  23.     sortDirections[propKey] = direction == "asc"
  24.     table.sort(data, function(a,b)
  25.         if (a[propKey] == b[propKey]) then
  26.             return nil;
  27.         end
  28.         if (sortDirections[propKey]) then
  29.             return a[propKey] < b[propKey];
  30.         else
  31.             return a[propKey] > b[propKey];
  32.         end
  33.     end);
  34.     FauxScrollFrame_SetOffset(MyScrollFrame, 0);
  35.     MyFrame_Update();
  36. end
  37. sortData("dkp", "desc");
  Reply With Quote
06-29-19, 10:55 AM   #27
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
And to package the table into a really ugly (but hopefully visual concept wise) no xml (on your part) scroll list for display (use sorting from fusionpit to add sort buttons):

Lua Code:
  1. local classes = { "Rogue", "Paladin", "Mage", "Warlock", "Priest", "DK", "DH", "Hunter", "Shaman", "Druid", "Monk", "Warrior" }
  2.  
  3. local width, height, numrows = 200, 20, 6
  4.  
  5. local TableData = {}
  6.  
  7. for i=1, 30 do
  8.     tinsert(TableData, { player=i, class=random(1, #classes), dkp=random(0, 10000) })
  9. end
  10.  
  11. local function OnClick(self)
  12.     print(self:GetText())
  13. end
  14.  
  15. local function CreateRow(parent, id) -- Create 3 buttons for each row in the list
  16.     local f = CreateFrame("Frame", "$parentLine"..id, parent)
  17.     f.Buttons = {}
  18.     f:SetSize(width, height)
  19.     for i=1, 3 do
  20.         tinsert(f.Buttons, CreateFrame("Button", "$parentButton"..i, f, "UIPanelButtonTemplate"))
  21.         f.Buttons[i]:SetSize(width/3, height)
  22.         f.Buttons[i]:SetPoint("LEFT", f.Buttons[i-1] or f, f.Buttons[i-1] and "RIGHT" or "LEFT")
  23.         f.Buttons[i]:SetScript("OnClick", OnClick)
  24.     end
  25.     return f
  26. end
  27.  
  28. local function MyFrame_Update(self)
  29.     local numOptions = #TableData
  30.     local index, row
  31.     local offset = FauxScrollFrame_GetOffset(self)
  32.     for i=1, numrows do
  33.         row = self.Rows[i]
  34.         index = offset + i
  35.         if TableData[index] then
  36.             row:Show()
  37.             row.index = index
  38.             row.Buttons[1]:SetText("Player"..TableData[index].player)
  39.             row.Buttons[2]:SetText(classes[TableData[index].class])
  40.             row.Buttons[3]:SetText(TableData[index].dkp)
  41.         else
  42.             row:Hide()
  43.         end
  44.     end
  45.     FauxScrollFrame_Update(self, numOptions, numrows, height)
  46. end
  47.  
  48. local f = CreateFrame("ScrollFrame", "FizzleScrollFrame", UIParent, "FauxScrollFrameTemplate")
  49. f:SetSize(width, height*numrows)
  50. f:SetPoint("LEFT", 20, 0)
  51. f.Rows = {}
  52. for i=1, numrows do
  53.     f.Rows[i] = CreateRow(f, i)
  54.     f.Rows[i]:SetPoint("TOPLEFT", f.Rows[i-1] or f, f.Rows[i-1] and "BOTTOMLEFT" or "TOPLEFT")
  55. end
  56. f:SetScript("OnVerticalScroll", function(self, offset)
  57.     FauxScrollFrame_OnVerticalScroll(self, offset, height, MyFrame_Update)
  58. end)
  59. MyFrame_Update(f)

You could make each row a single button with 3 FontStrings or ...
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-29-19 at 02:41 PM.
  Reply With Quote
06-29-19, 02:03 PM   #28
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
Tremendously appreciated guys.
  Reply With Quote
06-29-19, 05:25 PM   #29
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
Originally Posted by Fizzlemizz View Post
You could make each row a single button with 3 FontStrings or ...
I went ahead and made each row a single button with 3 embedded fontstrings so you could get the highlight effect on mouseover for the entire row. But when it scrolls, it simply overwrites the previous fontstring (you end up with a dozen or more strings stacked on top of each other in each row). I've tried clearing the fontstring prior to setting it, but that doesn't seem to work. And I don't feel like clearing and rebuilding the entire table on scroll would be efficient.

Lua Code:
  1. local _, core = ...;
  2. local _G = _G;
  3. local classes = { "Rogue", "Paladin", "Mage", "Warlock", "Priest", "DK", "DH", "Hunter", "Shaman", "Druid", "Monk", "Warrior" }
  4. core.TableWidth, core.TableHeight, core.TableNumrows = 500, 18, 25;
  5. local TableData = {}
  6. local SelectedData = 0;
  7.  
  8. for i=1, 70 do
  9.     tinsert(TableData, { player=i, class=random(1, #classes), dkp=random(0, 10000) })
  10. end
  11.  
  12. --[[
  13.   Table above will be structured as:
  14.  
  15. TableData = {
  16.   ["player"] = "TestClass",
  17.   ["class"] = "Warrior",
  18.   ["dkp"] = 1000,
  19.   ["previous_dkp"] = 800, --not implemented yet. set previous_dkp = dkp at beginning of raid to see how much was gained/lost during a raid.
  20.  
  21. }
  22. --]]
  23.  
  24. function OnClick(self)   -- self = Rows[]
  25.     SelectedData = self.index;
  26.     for i=1, core.TableNumrows do
  27.       self:GetParent().Rows[i]:SetNormalTexture(nil)
  28.     end
  29.     self:SetNormalTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp")
  30.     --[[  
  31.     for k,v in pairs(TableData[SelectedData]) do
  32.       if(tostring(k) == "class") then
  33.         print(k, " -> ", classes[v])
  34.       else
  35.         print(k, " -> ", v)
  36.       end
  37.     end
  38.     --retrieves string text
  39.     print(self.DKPInfo[1].data:GetText())
  40.     print(self.DKPInfo[2].data:GetText())
  41.     print(self.DKPInfo[3].data:GetText())
  42.     self.index selects the number of the row
  43.     --]]
  44. end
  45.  
  46. function CreateRow(parent, id) -- Create 3 buttons for each row in the list
  47.     local f = CreateFrame("Button", "$parentLine"..id, parent)
  48.     f.DKPInfo = {}
  49.     f:SetSize(core.TableWidth, core.TableHeight)
  50.     f:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
  51.     f:SetScript("OnClick", OnClick)
  52.     for i=1, 3 do
  53.         tinsert(f.DKPInfo, CreateFrame("Frame", "$parentButton"..i, f))
  54.         f.DKPInfo[i]:SetSize(core.TableWidth/3, core.TableHeight)
  55.         f.DKPInfo[i]:SetPoint("LEFT", f.DKPInfo[i-1] or f, f.DKPInfo[i-1] and "RIGHT" or "LEFT")
  56.     end
  57.     return f
  58. end
  59.  
  60. function MyFrame_Update(self)
  61.     local numOptions = #TableData
  62.     local index, row
  63.     local offset = FauxScrollFrame_GetOffset(self)
  64.     for i=1, core.TableNumrows do
  65.         row = self.Rows[i]
  66.         index = offset + i
  67.         if (index == SelectedData) then
  68.           row:SetNormalTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp")
  69.         else
  70.           row:SetNormalTexture(nil)
  71.         end
  72.         if TableData[index] then
  73.             row:Show()
  74.             row.index = index
  75.             row.DKPInfo[1].data = row.DKPInfo[1]:CreateFontString(nil, "OVERLAY");
  76.             row.DKPInfo[1].data:SetFontObject("GameFontHighlight");
  77.             row.DKPInfo[1].data:SetTextColor(1, 1, 1, 1);
  78.             row.DKPInfo[1].data:SetPoint("CENTER", row.DKPInfo[1], "CENTER");
  79.             row.DKPInfo[1].data:SetText("Player"..TableData[index].player)
  80.  
  81.             row.DKPInfo[2].data = row.DKPInfo[2]:CreateFontString(nil, "OVERLAY");
  82.             row.DKPInfo[2].data:SetFontObject("GameFontHighlight");
  83.             row.DKPInfo[2].data:SetTextColor(1, 1, 1, 1);
  84.             row.DKPInfo[2].data:SetPoint("CENTER", row.DKPInfo[2], "CENTER");
  85.             row.DKPInfo[2].data:SetText(classes[TableData[index].class])
  86.  
  87.             row.DKPInfo[3].data = row.DKPInfo[3]:CreateFontString(nil, "OVERLAY");
  88.             row.DKPInfo[3].data:SetFontObject("GameFontHighlight");
  89.             row.DKPInfo[3].data:SetTextColor(1, 1, 1, 1);
  90.             row.DKPInfo[3].data:SetPoint("CENTER", row.DKPInfo[3], "CENTER");
  91.             row.DKPInfo[3].data:SetText(TableData[index].dkp)
  92.         else
  93.             row:Hide()
  94.         end
  95.     end
  96.     FauxScrollFrame_Update(self, numOptions, core.TableNumrows, core.TableHeight)
  97. end

Last edited by Aeriez : 06-29-19 at 06:14 PM.
  Reply With Quote
06-29-19, 06:20 PM   #30
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
MyFrame_Update is creating new FontStrings each scroll on top of the ones before.

Create the Fontstrings in CreateRow() so they only get created once

Code:
f.DKPInfo[i].Text1 = f.DKPInfo[i]:CreateFontString(nil, "OVERLAY");
...
f.DKPInfo[i].Text2 = f.DKPInfo[i]:CreateFontString(nil, "OVERLAY");
...
f.DKPInfo[i].Text3 = f.DKPInfo[i]:CreateFontString(nil, "OVERLAY");
In MyFrame_Update() just set the new text to the three FontString for that row
Code:
row.DKPInfo[1].Text1:SetText(...)
row.DKPInfo[1].Text2:SetText(...)
row.DKPInfo[1].Text3:SetText(...)
Create and Update would look more like
Code:
function CreateRow(parent, id) -- Create 3 buttons for each row in the list
    local f = CreateFrame("Button", "$parentLine"..id, parent)
    f.Strings = {}
    f:SetSize(core.TableWidth, core.TableHeight)
    f:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
    f:SetScript("OnClick", OnClick)
    for i=1, 3 do
    	f.Strings[i] = f:CreateFontString(nil, "OVERLAY");
    	f.Strings[i]:SetFontObject("GameFontHighlight");
    	f.Strings[i]:SetTextColor(1, 1, 1, 1);
    end
    f.Strings[1]:SetPoint("LEFT")
    f.Strings[2]:SetPoint("CENTER")
    f.Strings[3]:SetPoint("RIGHT", -30, 0)
    return f
end
 
function MyFrame_Update(self)
    local numOptions = #TableData
    local index, row
    local offset = FauxScrollFrame_GetOffset(self)
    for i=1, core.TableNumrows do
        row = self.Rows[i]
        index = offset + i
        if (index == SelectedData) then
          row:SetNormalTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp")
        else
          row:SetNormalTexture(nil)
        end
        if TableData[index] then
            row.Strings[1]:SetText("Player"..TableData[index].player) 
            row.Strings[2]:SetText(classes[TableData[index].class])
            row.Strings[3]:SetText(TableData[index].dkp)
        else
            row:Hide()
        end
    end
    FauxScrollFrame_Update(self, numOptions, numrows, height)
end
I didn't put a lot of thought into positioning the FontStrings
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-29-19 at 11:03 PM.
  Reply With Quote
06-29-19, 07:05 PM   #31
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
If you're going to sort on classes, you'll probably want to create the classes table in alphabetical order because TableData is storing the classes key (1, 2, 3 etc.) not the actual class name.

Code:
local classes = { "DH", "DK", "Druid", "Hunter", "Mage", "Monk", "Paladin", "Priest", "Rogue", "Shaman", "Warlock", "Warrior" } -- Sorted to use keys[i] insted of full class name in the table
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
06-30-19, 03:41 PM   #32
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
So I've been making a lot of progress on the look and feel of the whole thing. However, I tried making a filter for the list (checkboxes for each class). On click, it runs the update function omitting any classes unchecked. It works perfectly... Until the list gets smaller than the rows displayed... Then the whole frame disappears as if it was hidden. Any insight on what may cause that?

I have SetText("") to simply clear out the text of any rows that go beyond the number of entries (27 rows total, if there's only 25 entries in the WorkingTable then it should blank out the last 2 lines... or so I thought).

Lua Code:
  1. function DKPTable_Update(self)
  2.     local numOptions;
  3.     local index, row
  4.     local offset = FauxScrollFrame_GetOffset(core.DKPTable)
  5.     local classFiltered = {};
  6.     core.WorkingTable = {}
  7.     for k,v in pairs(classes) do
  8.       if (core.ConfigTab1.checkBtn[k]:GetChecked() == true) then
  9.         classFiltered[v] = true;
  10.       else
  11.         classFiltered[v] = false;
  12.       end
  13.     end
  14.     for k,v in pairs(DKP_DKPTable) do
  15.       if(classFiltered[DKP_DKPTable[k]["class"]] == true) then
  16.         tinsert(core.WorkingTable, v)
  17.       end
  18.     end
  19.     numOptions = #core.WorkingTable;
  20.     for i=1, core.TableNumrows do
  21.         index = offset + i
  22.         row = core.DKPTable.Rows[i]
  23.         if (i <= numOptions) then
  24.           local c = GetCColors(core.WorkingTable[index].class);
  25.           row.DKPInfo[1].data:SetText(core.WorkingTable[index].player)
  26.           row.DKPInfo[1].data:SetTextColor(c.r, c.g, c.b, 1)
  27.           row.DKPInfo[2].data:SetText("N/A")
  28.           row.DKPInfo[3].data:SetText(core.WorkingTable[index].dkp)
  29.           row.DKPInfo[3].adjusted:SetText("("..core.WorkingTable[index].dkp - core.WorkingTable[index].previous_dkp..")");
  30.         else
  31.           row.DKPInfo[1].data:SetText("")
  32.           row.DKPInfo[2].data:SetText("")
  33.           row.DKPInfo[3].data:SetText("")
  34.           row.DKPInfo[3].adjusted:SetText("");
  35.         end
  36.         if (index == SelectedData) then
  37.           row:SetNormalTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp")
  38.         else
  39.           row:SetNormalTexture(nil)
  40.         end
  41.         if core.WorkingTable[index] then
  42.             row:Show()
  43.             row.index = index
  44.         else
  45.             row:Hide()
  46.         end
  47.     end
  48.     FauxScrollFrame_Update(core.DKPTable, numOptions, core.TableNumrows, core.TableHeight)
  49. end

EDIT: I have tried reactively adjusting core.TableNumrows (number of rows to draw) based on numOptions (number of entries in the table).. But that doesn't seem to effect anything

Last edited by Aeriez : 06-30-19 at 05:27 PM.
  Reply With Quote
06-30-19, 06:29 PM   #33
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Probably easier to use a filtered "display" table to store information from the main table.

Lua Code:
  1. local upper = string.upper
  2. local classes = { "DH", "DK", "Druid", "Hunter", "Mage", "Monk", "Paladin", "Priest", "Rogue", "Shaman", "Warlock", "Warrior" } -- Sorted to use keys[i] insted of full class name in the table
  3. local width, height, numrows = 200, 20, 6
  4. local TableData = {}
  5. local FilteredData = {}
  6.  
  7. for i=1, 30 do
  8.     tinsert(TableData, { Player=i, Class=random(1, #classes), DKP=random(0, 10000) })
  9. end
  10.  
  11. local function OnClick(self)
  12.     print(self.Strings[1]:GetText(), self.Strings[2]:GetText(), self.Strings[3]:GetText())
  13. end
  14.  
  15. function CreateRow(parent, id) -- Create 3 buttons for each row in the list
  16.     local f = CreateFrame("Button", "$parentLine"..id, parent)
  17.     f.Strings = {}
  18.     f:SetSize(width, height)
  19.     f:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
  20.     f:SetScript("OnClick", OnClick)
  21.     for i=1, 3 do
  22.         f.Strings[i] = f:CreateFontString(nil, "OVERLAY");
  23.         f.Strings[i]:SetFontObject("GameFontHighlight");
  24.         f.Strings[i]:SetTextColor(1, 1, 1, 1);
  25.     end
  26.     f.Strings[1]:SetPoint("LEFT")
  27.     f.Strings[2]:SetPoint("CENTER")
  28.     f.Strings[3]:SetPoint("RIGHT", -30, 0)
  29.     return f
  30. end
  31.  
  32. local function ScrollFrame_Update(self)
  33.     local numOptions = #FilteredData
  34.     local index, row
  35.     local offset = FauxScrollFrame_GetOffset(self) or 0
  36.     for i=1, numrows do
  37.         row = self.Rows[i]
  38.         index = offset + i
  39.         if FilteredData[index] then
  40.             row:Show()
  41.             row.index = index
  42.             row.Strings[1]:SetText("Player"..FilteredData[index].Player)
  43.             row.Strings[2]:SetText(classes[FilteredData[index].Class])
  44.             row.Strings[3]:SetText(FilteredData[index].DKP)
  45.         else
  46.             row:Hide()
  47.         end
  48.     end
  49.     FauxScrollFrame_Update(self, numOptions, numrows, height, nil, nil, nil, nil, nil, nil, true) -- alwaysShowScrollBar= true to stop frame from hiding
  50. end
  51.  
  52. local f = CreateFrame("ScrollFrame", "FizzleScrollFrame", UIParent, "FauxScrollFrameTemplate")
  53. f:SetSize(width, height*numrows)
  54. f:SetPoint("LEFT", 20, 0)
  55. f.ScrollBar = FauxScrollFrame_GetChildFrames(f)
  56. f.Rows = {}
  57. for i=1, numrows do
  58.     f.Rows[i] = CreateRow(f, i)
  59.     f.Rows[i]:SetPoint("TOPLEFT", f.Rows[i-1] or f, f.Rows[i-1] and "BOTTOMLEFT" or "TOPLEFT")
  60. end
  61. f:SetScript("OnVerticalScroll", function(self, offset)
  62.     FauxScrollFrame_OnVerticalScroll(self, offset, height, ScrollFrame_Update)
  63. end)
  64.  
  65. ------------ Add Sorting and Header Buttons -------------------------
  66. local SortButtons = {}
  67.  
  68. local function SortTable(id, reset)
  69.     local button = SortButtons[id]
  70.     if reset then
  71.         button.Ascend = true
  72.     else
  73.         button.Ascend = not button.Ascend
  74.     end
  75.     local Suffix = button.Ascend and " ^" or " v"
  76.     button:SetText(button.Id .. Suffix)
  77.     for k, v in pairs(SortButtons) do
  78.         if v ~= button then
  79.             v.Ascend = nil
  80.             v:SetText(v.Id)
  81.         end
  82.     end
  83.     table.sort(FilteredData, function(a, b)
  84.         if button.Ascend then
  85.                 return a[button.Id] < b[button.Id]
  86.         else
  87.             return a[button.Id] > b[button.Id]
  88.         end
  89.         end)
  90.         ScrollFrame_Update(f)
  91. end
  92.  
  93. -- add the buttons
  94. SortButtons.Player = CreateFrame("Button", "FizzleSortButtonPlayer", f, "UIPanelButtonTemplate")
  95. SortButtons.Class = CreateFrame("Button", "FizzleSortButtonClass", f, "UIPanelButtonTemplate")
  96. SortButtons.DKP = CreateFrame("Button", "FizzleSortButtonDkp", f, "UIPanelButtonTemplate")
  97.  
  98. SortButtons.Class:SetPoint("BOTTOM", f, "TOP", 0, 5)
  99. SortButtons.Player:SetPoint("RIGHT", SortButtons.Class, "LEFT")
  100. SortButtons.DKP:SetPoint("LEFT", SortButtons.Class, "RIGHT")
  101.  
  102. for k, v in pairs(SortButtons) do
  103.     v.Id = k
  104.     v:SetText(k)
  105.     v:SetSize(width/3, height)
  106.     v:SetScript("OnClick", function(self) SortTable(self.Id) end)
  107. end
  108.  
  109. ------------ Add Filtering on Class and Edit Box -------------------------
  110. local function FilterTable(filter, sort)
  111.     table.wipe(FilteredData)
  112.     for k, v in pairs(TableData) do
  113.         if filter == "" or upper(classes[v.Class]) == upper(filter) then
  114.             tinsert(FilteredData, v)
  115.         end
  116.     end
  117.     SortTable(sort)
  118. end
  119.  
  120. -- add the editbox and label
  121. local Filter = CreateFrame("EditBox", "FizzleFilter", FizzleScrollFrame, "InputBoxTemplate")
  122. Filter:SetSize(75, 20)
  123. Filter:SetAutoFocus(false)
  124. Filter:SetPoint("BOTTOMLEFT", SortButtons.Player, "TOPLEFT", 0, 2)
  125. Filter:SetScript("OnEnterPressed", function(self)
  126.     FilterTable(self:GetText(), "Player")
  127. end)
  128. Filter.Label = Filter:CreateFontString()
  129. Filter.Label:SetFont("Fonts\\FRIZQT__.TTF", 12)
  130. Filter.Label:SetPoint("LEFT", Filter, "RIGHT", 2, 0)
  131. Filter.Label:SetText("Filter Class [press Enter]")
  132.  
  133. ------------ Let's load the list to start -------------------------
  134. FilterTable("", "Player")
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-30-19 at 11:54 PM.
  Reply With Quote
06-30-19, 11:18 PM   #34
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
Thanks a ton! I ended up doing something similar to that actually. Much appreciated!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trying to Learn

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