diff --git a/PerfectRaid_Buffs.lua b/PerfectRaid_Buffs.lua index bfeb303..4b0ed52 100644 --- a/PerfectRaid_Buffs.lua +++ b/PerfectRaid_Buffs.lua @@ -170,98 +170,18 @@ function Buffs:CreateOptions(opt) local options = CreateFrame("Frame", "PROptions_Buffs", PROptions) opt:AddOptionsTab(L["Buffs/Debuffs"], options) - self:CreateListFrame(options, 15) - - local delete = CreateFrame("Button", "PRBuffs_Delete", options, "PRButtonTemplate") - delete:SetText(L["Delete"]) - delete:SetPoint("BOTTOMRIGHT", 0, 5) - delete:SetScript("OnClick", function() self:DeleteEntry() end) - delete:Show() - - local edit = CreateFrame("Button", "PRBuffs_Edit", options, "PRButtonTemplate") - edit:SetText(L["Edit"]) - edit:SetPoint("BOTTOMRIGHT", delete, "BOTTOMLEFT", -10, 0) - edit:SetScript("OnClick", function() self:EditEntry() end) - edit:Show() - - local add = CreateFrame("Button", "PRBuffs_Add", options, "PRButtonTemplate") - add:SetText(L["Add"]) - add:SetPoint("BOTTOMRIGHT", edit, "BOTTOMLEFT", -10, 0) - add:SetScript("OnClick", function() self:AddEntry() end) - add:Show() - - self:CreateEditFrame(options) -end - -function Buffs:CreateListFrame(parent, num) - local function OnClick(self) - local scrollframe = getglobal(parent:GetName().."ScrollFrame") - local parent = self:GetParent() - - local offset = FauxScrollFrame_GetOffset(scrollframe) - local idx = offset + self.idx - - if parent.selected then - parent.entries[parent.selected - offset]:SetChecked(nil) - end - parent.selected = idx - Buffs:EnableButtons() - end - - local function MakeEntry(name, parent) - local entry = CreateFrame("CheckButton", name, parent) - entry:SetScript("OnClick", OnClick) - entry:SetHeight(20) - entry:SetWidth(545) - entry:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") - entry:SetCheckedTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") - entry:GetHighlightTexture():SetBlendMode("ADD") - entry.line1 = entry:CreateFontString(nil, "ARTWORK", "GameFontHighlight") - entry.line1:SetPoint("LEFT", 0 ,0) - entry.line1:SetPoint("RIGHT", -5, 0) - entry.line1:SetText(L["Buff Name"]) - entry.line1:SetJustifyH("LEFT") - return entry - end - - parent.entries = {} - local entries = parent.entries - for i=1,num do - entries[i] = MakeEntry(parent:GetName().."Entry"..i, parent) - entries[i].idx = i - end - - entries[1]:SetPoint("TOPLEFT",0,0) - - for i=2,num do - entries[i]:SetPoint("TOPLEFT", entries[i-1], "BOTTOMLEFT", 0, 0) - end - - local scrollframe = CreateFrame("ScrollFrame", parent:GetName().."ScrollFrame", parent, "FauxScrollFrameTemplate") - scrollframe:SetPoint("TOPLEFT", entries[1], "TOPLEFT", 0, 0) - scrollframe:SetPoint("BOTTOMRIGHT", entries[num], "BOTTOMRIGHT", 0, 0) - - local texture = scrollframe:CreateTexture(nil, "BACKGROUND") - texture:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") - texture:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 14, 0) - texture:SetPoint("BOTTOMRIGHT", scrollframe, "BOTTOMRIGHT", 23, 0) - texture:SetGradientAlpha("HORIZONTAL", 0.5, 0.25, 0.05, 0, 0.15,0.15, 0.15, 1) - - local texture = scrollframe:CreateTexture(nil, "BACKGROUND") - texture:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") - texture:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, 0) - texture:SetPoint("BOTTOMRIGHT", scrollframe, "BOTTOMRIGHT", 14, 0) - texture:SetGradientAlpha("HORIZONTAL", 0.15, 0.15, 0.15, 0.15, 1, 0.5, 0.25, 0.05, 0) + local num_entries = 15 + local scrollframe = opt:CreateListFrame(options, num_entries) local update = function() local list = PerfectRaid.db.profile.buffs local idx,button local offset = FauxScrollFrame_GetOffset(scrollframe) - FauxScrollFrame_Update(scrollframe, #list, num, 20) - for i=1,num do + FauxScrollFrame_Update(scrollframe, #list, 15, 20) + for i=1,num_entries do idx = offset + i - button = entries[i] + button = scrollframe.entries[i] if idx <= #list then local entry = list[idx] local display = entry.buffname @@ -271,7 +191,7 @@ function Buffs:CreateListFrame(parent, num) display = display .. " (|cFF"..entry.color..entry.disptext.."|r)" button.line1:SetText(display) button:Show() - if parent.selected == idx then + if scrollframe.selected == idx then button:SetChecked(true) else button:SetChecked(false) @@ -283,16 +203,46 @@ function Buffs:CreateListFrame(parent, num) end scrollframe.update = update + scrollframe:SetScript("OnVerticalScroll", function() FauxScrollFrame_OnVerticalScroll(20, update) self:EnableButtons() end) scrollframe:SetScript("OnShow", function() - update() + scrollframe.update() self:EnableButtons() end) + + local postClick = function() + self:EnableButtons() + end + + for i,frame in ipairs(scrollframe.entries) do + frame:SetScript("PostClick", postClick) + end + + local delete = CreateFrame("Button", "PRBuffs_Delete", options, "PRButtonTemplate") + delete:SetText(L["Delete"]) + delete:SetPoint("BOTTOMRIGHT", 0, 5) + delete:SetScript("OnClick", function() self:DeleteEntry() end) + delete:Show() + + local edit = CreateFrame("Button", "PRBuffs_Edit", options, "PRButtonTemplate") + edit:SetText(L["Edit"]) + edit:SetPoint("BOTTOMRIGHT", delete, "BOTTOMLEFT", -10, 0) + edit:SetScript("OnClick", function() self:EditEntry() end) + edit:Show() + + local add = CreateFrame("Button", "PRBuffs_Add", options, "PRButtonTemplate") + add:SetText(L["Add"]) + add:SetPoint("BOTTOMRIGHT", edit, "BOTTOMLEFT", -10, 0) + add:SetScript("OnClick", function() self:AddEntry() end) + add:Show() + + self:CreateEditFrame(options) end + function Buffs:CreateEditFrame(parent) local frame = CreateFrame("Frame", "PROptions_Buffs_Edit", PROptions) local name = "PROptions_Buffs_Edit" diff --git a/PerfectRaid_Hacks.lua b/PerfectRaid_Hacks.lua index 88d9e76..3f70335 100644 --- a/PerfectRaid_Hacks.lua +++ b/PerfectRaid_Hacks.lua @@ -135,6 +135,8 @@ end function Hacks:UpdateScale(val) if InCombatLockdown() then return end local scale = val or PerfectRaid.db.profile.HacksScale + if PRHeader1:GetScale() == scale then return end + for i=1,8 do local name = "PRHeader"..i local button = getglobal(name) @@ -142,6 +144,7 @@ function Hacks:UpdateScale(val) button:SetScale(scale) end end + PerfectRaid:RestorePosition("PRHeader1") end function Hacks:SavePositions() diff --git a/PerfectRaid_Options.lua b/PerfectRaid_Options.lua index 11cfcc2..ed4e491 100644 --- a/PerfectRaid_Options.lua +++ b/PerfectRaid_Options.lua @@ -145,9 +145,65 @@ function Options:TabOnClick(tab) self:TriggerEvent("PERFECTRAID_TAB_CHANGED", old, tab) end ---[[ -Cide: local dialogBackdrop = { bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", -[5:51pm] Cide: edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", -[5:51pm] Cide: tile = true, tileSize = 32, edgeSize = 32, -[5:51pm] Cide: insets = { left = 11, right = 12, top = 12, bottom = 11 }}; ---]] \ No newline at end of file +function Options:CreateListFrame(parent, num) + local function OnClick(self) + local scrollframe = getglobal(parent:GetName().."ScrollFrame") + local parent = self:GetParent() + + local offset = FauxScrollFrame_GetOffset(scrollframe) + local idx = offset + self.idx + + if parent.selected then + parent.entries[parent.selected - offset]:SetChecked(nil) + end + parent.selected = idx + end + + local function MakeEntry(name, parent) + local entry = CreateFrame("CheckButton", name, parent) + entry:SetScript("OnClick", OnClick) + entry:SetHeight(20) + entry:SetWidth(545) + entry:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") + entry:SetCheckedTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") + entry:GetHighlightTexture():SetBlendMode("ADD") + entry.line1 = entry:CreateFontString(nil, "ARTWORK", "GameFontHighlight") + entry.line1:SetPoint("LEFT", 0 ,0) + entry.line1:SetPoint("RIGHT", -5, 0) + entry.line1:SetText(L["Buff Name"]) + entry.line1:SetJustifyH("LEFT") + return entry + end + + parent.entries = {} + local entries = parent.entries + for i=1,num do + entries[i] = MakeEntry(parent:GetName().."Entry"..i, parent) + entries[i].idx = i + end + + entries[1]:SetPoint("TOPLEFT",0,0) + + for i=2,num do + entries[i]:SetPoint("TOPLEFT", entries[i-1], "BOTTOMLEFT", 0, 0) + end + + local scrollframe = CreateFrame("ScrollFrame", parent:GetName().."ScrollFrame", parent, "FauxScrollFrameTemplate") + scrollframe:SetPoint("TOPLEFT", entries[1], "TOPLEFT", 0, 0) + scrollframe:SetPoint("BOTTOMRIGHT", entries[num], "BOTTOMRIGHT", 0, 0) + + local texture = scrollframe:CreateTexture(nil, "BACKGROUND") + texture:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") + texture:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 14, 0) + texture:SetPoint("BOTTOMRIGHT", scrollframe, "BOTTOMRIGHT", 23, 0) + texture:SetGradientAlpha("HORIZONTAL", 0.5, 0.25, 0.05, 0, 0.15,0.15, 0.15, 1) + + local texture = scrollframe:CreateTexture(nil, "BACKGROUND") + texture:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") + texture:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, 0) + texture:SetPoint("BOTTOMRIGHT", scrollframe, "BOTTOMRIGHT", 14, 0) + texture:SetGradientAlpha("HORIZONTAL", 0.15, 0.15, 0.15, 0.15, 1, 0.5, 0.25, 0.05, 0) + + scrollframe.entries = entries + return scrollframe +end