From 000e731fbc86b04c26135df12866d17cc26e6c02 Mon Sep 17 00:00:00 2001 From: SabinDeus Date: Mon, 2 Jan 2023 01:52:56 -0500 Subject: [PATCH] Dynamically generate Priority Frames, fixing 16 option limit --- TurnIn.xml | 161 --------------------------------------------------- TurnInUI.lua | 82 +++++++++++--------------- 2 files changed, 35 insertions(+), 208 deletions(-) diff --git a/TurnIn.xml b/TurnIn.xml index 4157c22..16168aa 100755 --- a/TurnIn.xml +++ b/TurnIn.xml @@ -684,167 +684,6 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/TurnInUI.lua b/TurnInUI.lua index ac92868..f316a9f 100755 --- a/TurnInUI.lua +++ b/TurnInUI.lua @@ -1,3 +1,30 @@ +local TI_OptionsPriorityFramePool = {}; +local TI_OptionsPriorityFramePoolMax = 0; + +local function TI_GetOptionsPriorityFrame(idx) + if idx > TI_OptionsPriorityFramePoolMax then + for i=TI_OptionsPriorityFramePoolMax+1, idx, 1 do + local frame = CreateFrame("Button", "TI_OptionsPriority"..i, + getglobal("TI_OptionsPriority"), "TI_PriorityList", i); + if i == 1 then + frame:SetPoint("TOPLEFT", 0, 0); + else + frame:SetPoint("TOPLEFT", "TI_OptionsPriority"..i-1, "BOTTOMLEFT", 0, 0); + end + frame:Hide(); + table.insert(TI_OptionsPriorityFramePool, i, frame); + TI_OptionsPriorityFramePoolMax = TI_OptionsPriorityFramePoolMax + 1; + end + end + return TI_OptionsPriorityFramePool[idx]; +end + +local function TI_HideUnusedOptionFrames(last) + for i=last, TI_OptionsPriorityFramePoolMax, 1 do + TI_OptionsPriorityFramePool[i]:Hide(); + end +end + function TI_PopulateOptions(arg) TI_debug(arg); local CurrOpts; @@ -10,9 +37,9 @@ function TI_PopulateOptions(arg) end for i,v in ipairs(CurrOpts) do - local entry = "TI_OptionsPriority" .. i; - local entrybutton = getglobal(entry); - local entrytext = getglobal("TI_OptionsPriority"..i.."_Text"); + local entrybutton = TI_GetOptionsPriorityFrame(i); + local icon, entrytext = entrybutton:GetRegions(); + local checkbox = entrybutton:GetChildren(); local iconpath; if(v.name == nil) then TI_debug("oh noes") end; entrytext:SetText(v.name); @@ -35,16 +62,15 @@ function TI_PopulateOptions(arg) iconpath = "Interface/GossipFrame/" .. v.type .. "GossipIcon"; end end - getglobal(entry .. "_Icon"):SetTexture(iconpath); - getglobal(entry .. "_Check"):SetChecked(v.state); + icon:SetTexture(iconpath); + checkbox:SetChecked(v.state); entrytext:SetWidth(156); --make sure to change this if you change the anchors in the XML entrybutton:SetHeight( entrytext:GetHeight() + 6); entrybutton:Show(); last = last+1; end - for j=last, 16, 1 do - getglobal("TI_OptionsPriority" .. j):Hide(); - end + TI_HideUnusedOptionFrames(last); + TI_OptionsPriorityScrollFrame:SetVerticalScroll(0); TI_OptionsPriorityScrollFrame:UpdateScrollChildRect(); TI_StatusIndicatorUpdate(); @@ -53,31 +79,6 @@ function TI_PopulateOptions(arg) TI_SettingCheckboxUpdate(); end ---[[ -function TI_PopulateOptions(arg) - TI_debug(arg); - if(TI_status and TI_status.options) then - for i,v in ipairs(TI_status.options) do - local entry = "TI_OptionsPriority" .. i; - local iconpath; - if(v.name == nil) then TI_debug("oh noes") end; - if(getglobal(entry .. "_Text") == nil) then TI_debug("wtf "..entry .. "_Text") end; - getglobal(entry .. "_Text"):SetText(v.name); - if(v.type == "activequest") then - iconpath = "Interface\\GossipFrame\\ActiveQuestIcon"; - elseif(v.type == "availquest") then - iconpath = "Interface\\GossipFrame\\AvailableQuestIcon"; - else - iconpath = "Interface\\GossipFrame\\" .. v.type .. "GossipIcon"; - end - getglobal(entry .. "_Icon"):SetTexture(iconpath); - getglobal(entry .. "_Check"):SetChecked(v.state); - getglobal(entry):Show(); - end - end - TI_NPCListScrollBarUpdate(); -end -]]-- function TI_NPCListScrollBarUpdate() if(TI_NPCIndex) then @@ -89,20 +90,7 @@ function TI_NPCListScrollBarUpdate() local offset = FauxScrollFrame_GetOffset(TI_NPCListScrollFrame); local i=1; local j=1; - --~ for k, v in pairs(TI_NPCDB) do - --~ if(offset <= i and i < offset+8) then - --~ if(i <= table.getn(TI_NPCDB)) then - --~ getglobal("TI_OptionsNPCContainer"..j.."_Text"):SetText(k); - --~ getglobal("TI_OptionsNPCContainer"..j.."_Check"):SetChecked(v.state); - --~ getglobal("TI_OptionsNPCContainer"..j):Show(); - --~ else - --~ getglobal("TI_OptionsNPCContainer"..j):Hide(); - --~ end - --~ j = j + 1; - --~ end - --~ i = i + 1; - --~ end - + for line=1,8 do lineplusoffset = line + FauxScrollFrame_GetOffset(TI_NPCListScrollFrame); if(lineplusoffset <= table.getn(TI_NPCIndex)) then