diff --git a/Interface/Common.lua b/Interface/Common.lua index 2135a6e..d41ef40 100644 --- a/Interface/Common.lua +++ b/Interface/Common.lua @@ -118,127 +118,3 @@ do frame:SetScript("OnLeave", Hide_Tooltip) end end -- do - -------------------------------------------------------------------------------- --- Generic function for creating buttons. -------------------------------------------------------------------------------- -do - -- I hate stretchy buttons. Thanks very much to ckknight for this code - -- (found in RockConfig) - - -- when pressed, the button should look pressed - local function button_OnMouseDown(self) - if self:IsEnabled() then - self.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]]) - self.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]]) - self.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]]) - end - end - - -- when depressed, return to normal - local function button_OnMouseUp(self) - if self:IsEnabled() then - self.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - self.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - self.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - end - end - - local function button_Disable(self) - self.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]]) - self.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]]) - self.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]]) - self:__Disable() - self:EnableMouse(false) - end - - local function button_Enable(self) - self.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - self.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - self.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - self:__Enable() - self:EnableMouse(true) - end - - function private.GenericCreateButton(name, parent, height, width, font_object, label, justify_h, tip_text, noTextures) - local button = CreateFrame("Button", name, parent) - - button:SetHeight(height) - button:SetWidth(width) - - if noTextures == 0 then - local highlight_texture = button:CreateTexture(nil, "BORDER") - highlight_texture:SetTexture([[Interface\ClassTrainerFrame\TrainerTextures]]) - highlight_texture:SetTexCoord(0.00195313, 0.57421875, 0.75390625, 0.84570313) - highlight_texture:SetBlendMode("ADD") - highlight_texture:SetPoint("TOPLEFT", 2, 0) - highlight_texture:SetPoint("BOTTOMRIGHT", -2, 1) - button:SetHighlightTexture(highlight_texture) - elseif noTextures == 1 then - local left = button:CreateTexture(nil, "BACKGROUND") - button.left = left - left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - - local middle = button:CreateTexture(nil, "BACKGROUND") - button.middle = middle - middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - - local right = button:CreateTexture(nil, "BACKGROUND") - button.right = right - right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]]) - - left:SetPoint("TOPLEFT") - left:SetPoint("BOTTOMLEFT") - left:SetWidth(12) - left:SetTexCoord(0, 0.09375, 0, 0.6875) - - right:SetPoint("TOPRIGHT") - right:SetPoint("BOTTOMRIGHT") - right:SetWidth(12) - right:SetTexCoord(0.53125, 0.625, 0, 0.6875) - - middle:SetPoint("TOPLEFT", left, "TOPRIGHT") - middle:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT") - middle:SetTexCoord(0.09375, 0.53125, 0, 0.6875) - - button:SetScript("OnMouseDown", button_OnMouseDown) - button:SetScript("OnMouseUp", button_OnMouseUp) - - button.__Enable = button.Enable - button.__Disable = button.Disable - button.Enable = button_Enable - button.Disable = button_Disable - - local highlight = button:CreateTexture(nil, "OVERLAY", "UIPanelButtonHighlightTexture") - button:SetHighlightTexture(highlight) - elseif noTextures == 2 then - button:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up") - button:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-Down") - button:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight") - button:SetDisabledTexture("Interface\\Buttons\\UI-PlusButton-Disabled") - elseif noTextures == 3 then - button:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up") - button:SetPushedTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Down") - button:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight") - button:SetDisabledTexture("Interface\\Buttons\\UI-PlusButton-Disabled") - end - - if font_object then - local text = button:CreateFontString(nil, "ARTWORK") - button:SetFontString(text) - button.text = text - text:SetPoint("LEFT", button, "LEFT", 7, 0) - text:SetPoint("RIGHT", button, "RIGHT", -7, 0) - text:SetJustifyH(justify_h) - - text:SetFontObject(font_object) - text:SetText(label) - end - - if tip_text and tip_text ~= "" then - private.SetTooltipScripts(button, tip_text) - end - return button - end -end -- do - diff --git a/Interface/FilterMenus.lua b/Interface/FilterMenus.lua index ac1ece1..a4ced56 100644 --- a/Interface/FilterMenus.lua +++ b/Interface/FilterMenus.lua @@ -25,14 +25,13 @@ local QTip = LibStub("LibQTip-1.0") -- Upvalues ------------------------------------------------------------------------------- local SetTextColor = private.SetTextColor -local GenericCreateButton = private.GenericCreateButton local SetTooltipScripts = private.SetTooltipScripts ------------------------------------------------------------------------------- -- Constants ------------------------------------------------------------------------------- -local FILTERMENU_HEIGHT = 312 -local FILTERMENU_WIDTH = 210 +local FILTERMENU_WIDTH = 306 +local FILTERMENU_HEIGHT = 343 local EXPANSION_FRAMES = { ["expansion0"] = true, @@ -69,8 +68,8 @@ do local function CreateCheckButton(parent, ttText, scriptVal, row, col) -- set the position of the new checkbox - local xPos = 2 + ((col - 1) * 175) - local yPos = -3 - ((row - 1) * 17) + local xPos = 10 + ((col - 1) * 175) + local yPos = -10 - ((row - 1) * 17) local check = _G.CreateFrame("CheckButton", nil, parent, "UICheckButtonTemplate") check:SetPoint("TOPLEFT", parent, "TOPLEFT", xPos, yPos) @@ -140,10 +139,16 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- -- The filter_reset button ------------------------------------------------------------------------------- - local filter_reset = GenericCreateButton(nil, MainPanel, 22, 78, "GameFontNormalSmall", _G.RESET, "CENTER", L["RESET_DESC"], 1) - filter_reset:SetPoint("BOTTOMRIGHT", MainPanel, "BOTTOMRIGHT", -95, 80) + local filter_reset_name = ("%s_FilterMenuResetButton"):format(FOLDER_NAME) + local filter_reset = _G.CreateFrame("Button", filter_reset_name, MainPanel, "UIPanelButtonTemplate") + filter_reset:SetWidth(78) + filter_reset:SetHeight(22) + filter_reset:SetPoint("BOTTOMRIGHT", MainPanel, "BOTTOMRIGHT", -95, 78) + filter_reset:SetText(_G.RESET) filter_reset:Hide() + private.SetTooltipScripts(filter_reset, L["RESET_DESC"]) + MainPanel.filter_reset = filter_reset do @@ -325,10 +330,10 @@ function private.InitializeFilterPanel() -- Main filter_menu frame. ------------------------------------------------------------------------------- local FilterPanel = _G.CreateFrame("Frame", nil, MainPanel) - FilterPanel:SetWidth(300) + FilterPanel:SetWidth(FILTERMENU_WIDTH) FilterPanel:SetHeight(FILTERMENU_HEIGHT) FilterPanel:SetFrameStrata("MEDIUM") - FilterPanel:SetPoint("TOPRIGHT", MainPanel, "TOPRIGHT", -135, -60) + FilterPanel:SetPoint("TOPRIGHT", MainPanel, "TOPRIGHT", -117, -71) FilterPanel:EnableMouse(true) FilterPanel:EnableKeyboard(true) FilterPanel:SetMovable(false) @@ -339,13 +344,10 @@ function private.InitializeFilterPanel() function FilterPanel:CreateSubMenu(name) local submenu = _G.CreateFrame("Frame", nil, self) - - submenu:SetWidth(FILTERMENU_WIDTH) - submenu:SetHeight(FILTERMENU_HEIGHT) submenu:EnableMouse(true) submenu:EnableKeyboard(true) submenu:SetMovable(false) - submenu:SetPoint("TOPLEFT", self, "TOPLEFT", 17, -16) + submenu:SetAllPoints() submenu:Hide() self[name] = submenu @@ -375,10 +377,17 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- -- Create the Class toggle and CheckButtons. ------------------------------------------------------------------------------- - local class_toggle = GenericCreateButton(nil, general_frame, 20, 105, "GameFontHighlight", L["Classes"] .. ":", "LEFT", L["CLASS_TEXT_DESC"], 0) - class_toggle:SetPoint("TOPLEFT", FilterPanel.general.unknown, "BOTTOMLEFT", -4, -10) - class_toggle:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight") + local class_toggle = _G.CreateFrame("Button", nil, general_frame) + class_toggle:SetWidth(105) + class_toggle:SetHeight(20) + class_toggle:SetNormalFontObject("QuestTitleFont") + class_toggle:SetHighlightFontObject("QuestTitleFontBlackShadow") + class_toggle:SetFormattedText(_G.ITEM_CLASSES_ALLOWED, "") + class_toggle:SetPoint("TOP", general_frame, "TOP", 0, -80) class_toggle:RegisterForClicks("LeftButtonUp", "RightButtonUp") + + private.SetTooltipScripts(class_toggle, L["CLASS_TEXT_DESC"]) + class_toggle:SetScript("OnClick", function(self, button) local classes = addon.db.profile.filters.classes @@ -474,10 +483,17 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- -- Create the Armor toggle and CheckButtons ------------------------------------------------------------------------------- - local armor_toggle = GenericCreateButton(nil, item_frame, 20, 105, "GameFontHighlight", _G.ARMOR .. ":", "LEFT", L["ARMOR_TEXT_DESC"], 0) - armor_toggle:SetPoint("TOPLEFT", item_frame, "TOPLEFT", -2, -4) - armor_toggle:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight") + local armor_toggle = _G.CreateFrame("Button", nil, item_frame) + armor_toggle:SetWidth(105) + armor_toggle:SetHeight(20) + armor_toggle:SetNormalFontObject("QuestTitleFont") + armor_toggle:SetHighlightFontObject("QuestTitleFontBlackShadow") + armor_toggle:SetText(_G.ARMOR .. ":") + armor_toggle:SetPoint("TOP", item_frame, "TOP", 0, -7) armor_toggle:RegisterForClicks("LeftButtonUp", "RightButtonUp") + + private.SetTooltipScripts(armor_toggle, L["ARMOR_TEXT_DESC"]) + armor_toggle:SetScript("OnClick", function(self, button) local armors = addon.db.profile.filters.item.armor @@ -510,11 +526,17 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- -- Create the Weapon toggle and CheckButtons ------------------------------------------------------------------------------- - local weapon_toggle = GenericCreateButton(nil, item_frame, 20, 105, "GameFontHighlight", L["Weapon"] .. ":", "LEFT", L["WEAPON_TEXT_DESC"], 0) - weapon_toggle:SetPoint("TOPLEFT", item_frame, "TOPLEFT", -2, -122) - - weapon_toggle:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight") + local weapon_toggle = _G.CreateFrame("Button", nil, item_frame) + weapon_toggle:SetWidth(105) + weapon_toggle:SetHeight(20) + weapon_toggle:SetNormalFontObject("QuestTitleFont") + weapon_toggle:SetHighlightFontObject("QuestTitleFontBlackShadow") + weapon_toggle:SetText(L["Weapon"] .. ":") + weapon_toggle:SetPoint("TOP", item_frame, "TOP", 0, -122) weapon_toggle:RegisterForClicks("LeftButtonUp", "RightButtonUp") + + private.SetTooltipScripts(weapon_toggle, L["WEAPON_TEXT_DESC"]) + weapon_toggle:SetScript("OnClick", function(self, button) local weapons = addon.db.profile.filters.item.weapon @@ -588,19 +610,15 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- do local player_frame = FilterPanel:CreateSubMenu("player") - local tank_desc = string.format(L["ROLE_DESC_FORMAT"], _G.TANK) - local melee_desc = string.format(L["ROLE_DESC_FORMAT"], _G.MELEE) - local healer_desc = string.format(L["ROLE_DESC_FORMAT"], _G.HEALER) - local caster_desc = string.format(L["ROLE_DESC_FORMAT"], _G.DAMAGER) ------------------------------------------------------------------------------- -- Create the CheckButtons ------------------------------------------------------------------------------- local role_buttons = { - ["tank"] = { tt = tank_desc, text = _G.TANK, row = 1, col = 1 }, - ["melee"] = { tt = melee_desc, text = _G.MELEE, row = 2, col = 1 }, - ["healer"] = { tt = healer_desc, text = _G.HEALER, row = 3, col = 1 }, - ["caster"] = { tt = caster_desc, text = _G.DAMAGER, row = 4, col = 1 }, + ["tank"] = { tt = L["ROLE_DESC_FORMAT"]:format(_G.TANK), text = _G.TANK, row = 1, col = 1 }, + ["melee"] = { tt = L["ROLE_DESC_FORMAT"]:format(_G.MELEE), text = _G.MELEE, row = 2, col = 1 }, + ["healer"] = { tt = L["ROLE_DESC_FORMAT"]:format(_G.HEALER), text = _G.HEALER, row = 3, col = 1 }, + ["caster"] = { tt = L["ROLE_DESC_FORMAT"]:format(_G.DAMAGER), text = _G.DAMAGER, row = 4, col = 1 }, } GenerateCheckBoxes(player_frame, role_buttons) role_buttons = nil @@ -691,16 +709,16 @@ function private.InitializeFilterPanel() -- Create the expansion toggles. ------------------------------------------------------------------------------- local expansion0 = rep_frame:CreateExpansionButton("Glues-WoW-Logo", "expansion0") - expansion0:SetPoint("TOPLEFT", FilterPanel.rep, "TOPLEFT", 0, -10) + expansion0:SetPoint("TOPLEFT", FilterPanel.rep, "TOPLEFT", 2, -10) local expansion1 = rep_frame:CreateExpansionButton("GLUES-WOW-BCLOGO", "expansion1") - expansion1:SetPoint("TOPLEFT", FilterPanel.rep, "TOPLEFT", 0, -60) + expansion1:SetPoint("TOP", expansion0, "BOTTOM", 0, 0) local expansion2 = rep_frame:CreateExpansionButton("Glues-WOW-WotlkLogo", "expansion2") - expansion2:SetPoint("TOPLEFT", FilterPanel.rep, "TOPLEFT", 0, -110) + expansion2:SetPoint("TOP", expansion1, "BOTTOM", 0, 0) local expansion3 = rep_frame:CreateExpansionButton("Glues-WOW-CCLogo", "expansion3") - expansion3:SetPoint("TOPLEFT", FilterPanel.rep, "TOPLEFT", 0, -160) + expansion3:SetPoint("TOP", expansion2, "BOTTOM", 0, 0) rep_frame.toggle_expansion0 = expansion0 rep_frame.toggle_expansion1 = expansion1 @@ -750,12 +768,12 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- do local expansion0_frame = _G.CreateFrame("Frame", nil, FilterPanel.rep) - expansion0_frame:SetWidth(150) - expansion0_frame:SetHeight(280) + expansion0_frame:SetWidth(200) + expansion0_frame:SetHeight(FILTERMENU_HEIGHT) expansion0_frame:EnableMouse(true) expansion0_frame:EnableKeyboard(true) expansion0_frame:SetMovable(false) - expansion0_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", -30, -16) + expansion0_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", 0, 0) expansion0_frame:Hide() FilterPanel.rep.expansion0 = expansion0_frame @@ -772,11 +790,17 @@ function private.InitializeFilterPanel() } GenerateCheckBoxes(expansion0_frame, expansion0_buttons) - local expansion0_toggle = GenericCreateButton(nil, expansion0_frame, 15, 120, "GameFontHighlight", _G.REPUTATION .. ":", "LEFT", L["REP_TEXT_DESC"], 0) - expansion0_toggle:SetPoint("TOPLEFT", expansion0_frame, "TOPLEFT", -2, -4) - expansion0_toggle:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]]) + local expansion0_toggle = _G.CreateFrame("Button", nil, expansion0_frame) + expansion0_toggle:SetWidth(105) + expansion0_toggle:SetHeight(20) + expansion0_toggle:SetNormalFontObject("QuestTitleFont") + expansion0_toggle:SetHighlightFontObject("QuestTitleFontBlackShadow") + expansion0_toggle:SetText(_G.REPUTATION .. ":") + expansion0_toggle:SetPoint("TOPLEFT", expansion0_frame, "TOPLEFT", -2, -7) expansion0_toggle:RegisterForClicks("LeftButtonUp", "RightButtonUp") + private.SetTooltipScripts(expansion0_toggle, L["REP_TEXT_DESC"]) + expansion0_toggle.buttons = expansion0_buttons expansion0_toggle.frame = expansion0_frame @@ -788,12 +812,12 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- do local expansion1_frame = _G.CreateFrame("Frame", nil, FilterPanel.rep) - expansion1_frame:SetWidth(150) - expansion1_frame:SetHeight(280) + expansion1_frame:SetWidth(200) + expansion1_frame:SetHeight(FILTERMENU_HEIGHT) expansion1_frame:EnableMouse(true) expansion1_frame:EnableKeyboard(true) expansion1_frame:SetMovable(false) - expansion1_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", -30, -16) + expansion1_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", -0, -0) expansion1_frame:Hide() FilterPanel.rep.expansion1 = expansion1_frame @@ -819,11 +843,17 @@ function private.InitializeFilterPanel() } GenerateCheckBoxes(expansion1_frame, expansion1_buttons) - local expansion1_toggle = GenericCreateButton(nil, expansion1_frame, 15, 120, "GameFontHighlight", _G.REPUTATION .. ":", "LEFT", L["REP_TEXT_DESC"], 0) - expansion1_toggle:SetPoint("TOPLEFT", expansion1_frame, "TOPLEFT", -2, -4) - expansion1_toggle:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]]) + local expansion1_toggle = _G.CreateFrame("Button", nil, expansion1_frame) + expansion1_toggle:SetWidth(105) + expansion1_toggle:SetHeight(20) + expansion1_toggle:SetNormalFontObject("QuestTitleFont") + expansion1_toggle:SetHighlightFontObject("QuestTitleFontBlackShadow") + expansion1_toggle:SetText(_G.REPUTATION .. ":") + expansion1_toggle:SetPoint("TOPLEFT", expansion1_frame, "TOPLEFT", -2, -7) expansion1_toggle:RegisterForClicks("LeftButtonUp", "RightButtonUp") + private.SetTooltipScripts(expansion1_toggle, L["REP_TEXT_DESC"]) + expansion1_toggle.buttons = expansion1_buttons expansion1_toggle.frame = expansion1_frame @@ -835,12 +865,12 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- do local expansion2_frame = _G.CreateFrame("Frame", nil, FilterPanel.rep) - expansion2_frame:SetWidth(150) - expansion2_frame:SetHeight(280) + expansion2_frame:SetWidth(200) + expansion2_frame:SetHeight(FILTERMENU_HEIGHT) expansion2_frame:EnableMouse(true) expansion2_frame:EnableKeyboard(true) expansion2_frame:SetMovable(false) - expansion2_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", -30, -16) + expansion2_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", 0, 0) expansion2_frame:Hide() FilterPanel.rep.expansion2 = expansion2_frame @@ -876,11 +906,17 @@ function private.InitializeFilterPanel() expansion2_frame.wrathcommon4:Disable() expansion2_frame.wrathcommon5:Disable() - local expansion2_toggle = GenericCreateButton(nil, expansion2_frame, 15, 120, "GameFontHighlight", _G.REPUTATION .. ":", "LEFT", L["REP_TEXT_DESC"], 0) - expansion2_toggle:SetPoint("TOPLEFT", expansion2_frame, "TOPLEFT", -2, -4) - expansion2_toggle:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]]) + local expansion2_toggle = _G.CreateFrame("Button", nil, expansion2_frame) + expansion2_toggle:SetWidth(105) + expansion2_toggle:SetHeight(20) + expansion2_toggle:SetNormalFontObject("QuestTitleFont") + expansion2_toggle:SetHighlightFontObject("QuestTitleFontBlackShadow") + expansion2_toggle:SetText(_G.REPUTATION .. ":") + expansion2_toggle:SetPoint("TOPLEFT", expansion2_frame, "TOPLEFT", -2, -7) expansion2_toggle:RegisterForClicks("LeftButtonUp", "RightButtonUp") + private.SetTooltipScripts(expansion2_toggle, L["REP_TEXT_DESC"]) + expansion2_toggle.buttons = expansion2_buttons expansion2_toggle.frame = expansion2_frame @@ -892,12 +928,12 @@ function private.InitializeFilterPanel() ------------------------------------------------------------------------------- do local expansion3_frame = _G.CreateFrame("Frame", nil, FilterPanel.rep) - expansion3_frame:SetWidth(150) - expansion3_frame:SetHeight(280) + expansion3_frame:SetWidth(200) + expansion3_frame:SetHeight(FILTERMENU_HEIGHT) expansion3_frame:EnableMouse(true) expansion3_frame:EnableKeyboard(true) expansion3_frame:SetMovable(false) - expansion3_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", -30, -16) + expansion3_frame:SetPoint("TOPRIGHT", FilterPanel, "TOPRIGHT", 0, 0) expansion3_frame:Hide() FilterPanel.rep.expansion3 = expansion3_frame @@ -927,11 +963,17 @@ function private.InitializeFilterPanel() expansion3_frame.earthenring:Disable() expansion3_frame.therazane:Disable() - local expansion3_toggle = GenericCreateButton(nil, expansion3_frame, 15, 120, "GameFontHighlight", _G.REPUTATION .. ":", "LEFT", L["REP_TEXT_DESC"], 0) - expansion3_toggle:SetPoint("TOPLEFT", expansion3_frame, "TOPLEFT", -2, -4) - expansion3_toggle:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]]) + local expansion3_toggle = _G.CreateFrame("Button", nil, expansion3_frame) + expansion3_toggle:SetWidth(105) + expansion3_toggle:SetHeight(20) + expansion3_toggle:SetNormalFontObject("QuestTitleFont") + expansion3_toggle:SetHighlightFontObject("QuestTitleFontBlackShadow") + expansion3_toggle:SetText(_G.REPUTATION .. ":") + expansion3_toggle:SetPoint("TOPLEFT", expansion3_frame, "TOPLEFT", -2, -7) expansion3_toggle:RegisterForClicks("LeftButtonUp", "RightButtonUp") + private.SetTooltipScripts(expansion3_toggle, L["REP_TEXT_DESC"]) + expansion3_toggle.buttons = expansion3_buttons expansion3_toggle.frame = expansion3_frame @@ -1065,8 +1107,8 @@ function private.InitializeFilterPanel() tip:Clear() if not click_info.realm then - local other_realms = nil - local header = nil + local other_realms + local header for realm in pairs(tskl_list) do if target_realm and realm ~= target_realm then diff --git a/Interface/List.lua b/Interface/List.lua index 1692941..6d28e06 100644 --- a/Interface/List.lua +++ b/Interface/List.lua @@ -53,7 +53,6 @@ local spell_tip local AcquireTable = private.AcquireTable local ReleaseTable = private.ReleaseTable local SetTextColor = private.SetTextColor -local GenericCreateButton = private.GenericCreateButton ------------------------------------------------------------------------------- -- Frame creation and anchoring @@ -319,24 +318,45 @@ function private.InitializeListFrame() ListFrame.state_buttons = {} ListFrame.entry_buttons = {} - for i = 1, NUM_RECIPE_LINES do + for index = 1, NUM_RECIPE_LINES do local cur_container = _G.CreateFrame("Frame", nil, ListFrame) cur_container:SetHeight(16) cur_container:SetWidth(LIST_ENTRY_WIDTH) - local cur_state = GenericCreateButton(nil, ListFrame, 16, 16, nil, nil, nil, nil, 2) - local cur_entry = GenericCreateButton(nil, ListFrame, 16, LIST_ENTRY_WIDTH, "GameFontNormalSmall", "Blort", "LEFT", nil, 0) - cur_entry.text:SetJustifyV("CENTER") - - if i == 1 then + local cur_state = _G.CreateFrame("Button", nil, ListFrame) + cur_state:SetWidth(16) + cur_state:SetHeight(16) + + local entry_name = ("%s_ListEntryButton%d"):format(FOLDER_NAME, index) + local cur_entry = _G.CreateFrame("Button", entry_name, cur_container) + cur_entry:SetWidth(LIST_ENTRY_WIDTH) + cur_entry:SetHeight(16) + + local highlight_texture = cur_entry:CreateTexture(nil, "BORDER") + highlight_texture:SetTexture([[Interface\ClassTrainerFrame\TrainerTextures]]) + highlight_texture:SetTexCoord(0.00195313, 0.57421875, 0.75390625, 0.84570313) + highlight_texture:SetBlendMode("ADD") + highlight_texture:SetPoint("TOPLEFT", 2, 0) + highlight_texture:SetPoint("BOTTOMRIGHT", -2, 1) + cur_entry:SetHighlightTexture(highlight_texture) + + local label = cur_entry:CreateFontString(nil, "ARTWORK") + label:SetPoint("LEFT", cur_entry, "LEFT", 7, 0) + label:SetPoint("RIGHT", cur_entry, "RIGHT", -7, 0) + label:SetFontObject("GameFontNormalSmall") + label:SetJustifyH("LEFT") + label:SetJustifyV("CENTER") + + cur_entry:SetFontString(label) + cur_entry.text = label + + if index == 1 then cur_container:SetPoint("TOPLEFT", ListFrame, "TOPLEFT", 0, -3) cur_state:SetPoint("LEFT", cur_container, "LEFT", 0, 0) cur_entry:SetPoint("LEFT", cur_state, "RIGHT", -3, 0) else - local prev_container = ListFrame.button_containers[i - 1] - - cur_container:SetPoint("TOPLEFT", prev_container, "BOTTOMLEFT", 0, 3) + cur_container:SetPoint("TOPLEFT", ListFrame.button_containers[index - 1], "BOTTOMLEFT", 0, 3) cur_state:SetPoint("LEFT", cur_container, "LEFT", 0, 0) cur_entry:SetPoint("LEFT", cur_state, "RIGHT", -3, 0) end @@ -345,9 +365,9 @@ function private.InitializeListFrame() cur_state:SetScript("OnClick", ListItem_OnClick) cur_entry:SetScript("OnClick", ListItem_OnClick) - ListFrame.button_containers[i] = cur_container - ListFrame.state_buttons[i] = cur_state - ListFrame.entry_buttons[i] = cur_entry + ListFrame.button_containers[index] = cur_container + ListFrame.state_buttons[index] = cur_state + ListFrame.entry_buttons[index] = cur_entry end function ListFrame:InsertEntry(entry, parent_entry, entry_index, entry_type, entry_expanded, expand_mode) @@ -356,27 +376,10 @@ function private.InitializeListFrame() if parent_entry then if parent_entry ~= entry then entry.parent = parent_entry - - local recipe_id = parent_entry.recipe_id - local acquire_id = parent_entry.acquire_id - local location_id = parent_entry.location_id - local npc_id = parent_entry.npc_id - - if recipe_id then - entry.recipe_id = recipe_id - end - - if acquire_id then - entry.acquire_id = acquire_id - end - - if location_id then - entry.location_id = location_id - end - - if npc_id then - entry.npc_id = npc_id - end + entry.recipe_id = parent_entry.recipe_id + entry.acquire_id = parent_entry.acquire_id + entry.location_id = parent_entry.location_id + entry.npc_id = parent_entry.npc_id else addon:Debug("Attempting to parent an entry to itself.") end diff --git a/Interface/Panel.lua b/Interface/Panel.lua index e1f59c0..a8d9eac 100644 --- a/Interface/Panel.lua +++ b/Interface/Panel.lua @@ -48,7 +48,6 @@ local BFAC = LibStub("LibBabble-Faction-3.0"):GetLookupTable() local AcquireTable = private.AcquireTable local ReleaseTable = private.ReleaseTable local SetTextColor = private.SetTextColor -local GenericCreateButton = private.GenericCreateButton local SetTooltipScripts = private.SetTooltipScripts local A = private.acquire_types @@ -796,42 +795,50 @@ function private.InitializeFrame() ------------------------------------------------------------------------------- -- Create the expand button and set its scripts. ------------------------------------------------------------------------------- - local ExpandButtonFrame = _G.CreateFrame("Frame", nil, MainPanel) - - ExpandButtonFrame:SetHeight(20) - ExpandButtonFrame:SetPoint("TOPLEFT", SearchBox, "BOTTOMLEFT", -12, -5) - - ExpandButtonFrame.left = ExpandButtonFrame:CreateTexture(nil, "BACKGROUND") - ExpandButtonFrame.left:SetWidth(8) - ExpandButtonFrame.left:SetHeight(22) - ExpandButtonFrame.left:SetPoint("TOPLEFT", ExpandButtonFrame, 0, 4) - ExpandButtonFrame.left:SetTexture("Interface\\QuestFrame\\UI-QuestLogSortTab-Left") - - ExpandButtonFrame.right = ExpandButtonFrame:CreateTexture(nil, "BACKGROUND") - ExpandButtonFrame.right:SetWidth(8) - ExpandButtonFrame.right:SetHeight(22) - ExpandButtonFrame.right:SetPoint("TOPRIGHT", ExpandButtonFrame, 0, 4) - ExpandButtonFrame.right:SetTexture("Interface\\QuestFrame\\UI-QuestLogSortTab-Right") - - ExpandButtonFrame.middle = ExpandButtonFrame:CreateTexture(nil, "BACKGROUND") - ExpandButtonFrame.middle:SetHeight(22) - ExpandButtonFrame.middle:SetPoint("LEFT", ExpandButtonFrame.left, "RIGHT") - ExpandButtonFrame.middle:SetPoint("RIGHT", ExpandButtonFrame.right, "LEFT") - ExpandButtonFrame.middle:SetTexture("Interface\\QuestFrame\\UI-QuestLogSortTab-Middle") - - local ExpandButton = GenericCreateButton(nil, MainPanel, 16, 16, "GameFontNormalSmall", _G.ALL, "LEFT", L["EXPANDALL_DESC"], 2) + local expand_button_frame = _G.CreateFrame("Frame", nil, MainPanel) + + expand_button_frame:SetHeight(20) + expand_button_frame:SetPoint("TOPLEFT", SearchBox, "BOTTOMLEFT", -12, -5) + + expand_button_frame.left = expand_button_frame:CreateTexture(nil, "BACKGROUND") + expand_button_frame.left:SetWidth(8) + expand_button_frame.left:SetHeight(22) + expand_button_frame.left:SetPoint("TOPLEFT", expand_button_frame, 0, 4) + expand_button_frame.left:SetTexture("Interface\\QuestFrame\\UI-QuestLogSortTab-Left") + + expand_button_frame.right = expand_button_frame:CreateTexture(nil, "BACKGROUND") + expand_button_frame.right:SetWidth(8) + expand_button_frame.right:SetHeight(22) + expand_button_frame.right:SetPoint("TOPRIGHT", expand_button_frame, 0, 4) + expand_button_frame.right:SetTexture("Interface\\QuestFrame\\UI-QuestLogSortTab-Right") + + expand_button_frame.middle = expand_button_frame:CreateTexture(nil, "BACKGROUND") + expand_button_frame.middle:SetHeight(22) + expand_button_frame.middle:SetPoint("LEFT", expand_button_frame.left, "RIGHT") + expand_button_frame.middle:SetPoint("RIGHT", expand_button_frame.right, "LEFT") + expand_button_frame.middle:SetTexture("Interface\\QuestFrame\\UI-QuestLogSortTab-Middle") + + local expand_button = _G.CreateFrame("Button", nil, MainPanel) + expand_button:SetWidth(16) + expand_button:SetHeight(16) + + local expand_label = expand_button:CreateFontString(nil, "ARTWORK") + expand_label:SetFontObject("GameFontNormalSmall") + expand_label:SetPoint("LEFT", expand_button, "Right", 0, 0) + expand_label:SetJustifyH("LEFT") + expand_label:SetText(_G.ALL) + + expand_button:SetFontString(expand_label) + private.SetTooltipScripts(expand_button, L["EXPANDALL_DESC"]) -- Make sure the button frame is large enough to hold the localized word for "All" - ExpandButtonFrame:SetWidth(27 + ExpandButton:GetFontString():GetStringWidth()) + expand_button_frame:SetWidth(27 + expand_button:GetFontString():GetStringWidth()) - MainPanel.expand_button = ExpandButton + MainPanel.expand_button = expand_button - ExpandButton:SetPoint("LEFT", ExpandButtonFrame.left, "RIGHT", -3, -3) + expand_button:SetPoint("LEFT", expand_button_frame.left, "RIGHT", -3, -3) - ExpandButton.text:ClearAllPoints() - ExpandButton.text:SetPoint("LEFT", ExpandButton, "Right", 0, 0) - - ExpandButton:SetScript("OnClick", + expand_button:SetScript("OnClick", function(self, mouse_button, down) local current_tab = MainPanel.tabs[MainPanel.current_tab] local expanded = current_tab["expand_button_"..MainPanel.profession] @@ -860,7 +867,7 @@ function private.InitializeFrame() end end) - function ExpandButton:Expand(current_tab) + function expand_button:Expand(current_tab) current_tab["expand_button_"..MainPanel.profession] = true self:SetNormalTexture("Interface\\BUTTONS\\UI-MinusButton-Up") @@ -871,7 +878,7 @@ function private.InitializeFrame() SetTooltipScripts(self, L["CONTRACTALL_DESC"]) end - function ExpandButton:Contract(current_tab) + function expand_button:Contract(current_tab) current_tab["expand_button_"..MainPanel.profession] = nil self:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up") @@ -947,9 +954,13 @@ function private.InitializeFrame() -- Create MainPanel.filter_toggle, and set its scripts. ------------------------------------------------------------------------------- do - local filter_toggle = GenericCreateButton(nil, MainPanel, 24, 24, nil, nil, nil, L["FILTER_OPEN_DESC"], 2) + local filter_toggle = _G.CreateFrame("Button", nil, MainPanel) + filter_toggle:SetWidth(24) + filter_toggle:SetHeight(24) filter_toggle:SetPoint("TOPLEFT", MainPanel, "TOPLEFT", 323, -41) + private.SetTooltipScripts(filter_toggle, L["FILTER_OPEN_DESC"]) + filter_toggle:SetScript("OnClick", function(self, button, down) -- The first time this button is clicked, everything in the expanded section of the MainPanel must be created. if private.InitializeFilterPanel then @@ -980,13 +991,16 @@ function private.InitializeFrame() ------------------------------------------------------------------------------- -- Sort-mode toggle button. ------------------------------------------------------------------------------- - local SortToggle = GenericCreateButton(nil, MainPanel, 24, 24, nil, nil, nil, L["SORTING_DESC"], 2) + local sort_toggle = _G.CreateFrame("Button", nil, MainPanel) + sort_toggle:SetWidth(24) + sort_toggle:SetHeight(24) + sort_toggle:SetPoint("LEFT", expand_button_frame, "RIGHT", 0, 2) - MainPanel.sort_button = SortToggle + private.SetTooltipScripts(sort_toggle, L["SORTING_DESC"]) - SortToggle:SetPoint("LEFT", ExpandButtonFrame, "RIGHT", 0, 2) + MainPanel.sort_button = sort_toggle - SortToggle:SetScript("OnClick", + sort_toggle:SetScript("OnClick", function(self, button, down) local sort_type = addon.db.profile.sorting @@ -996,9 +1010,9 @@ function private.InitializeFrame() MainPanel.list_frame:Update(nil, false) end) - SortToggle:SetHighlightTexture([[Interface\CHATFRAME\UI-ChatIcon-BlinkHilight]]) + sort_toggle:SetHighlightTexture([[Interface\CHATFRAME\UI-ChatIcon-BlinkHilight]]) - function SortToggle:SetTextures() + function sort_toggle:SetTextures() local sort_type = addon.db.profile.sorting if sort_type == "Ascending" then @@ -1051,14 +1065,19 @@ function private.InitializeFrame() ------------------------------------------------------------------------------- -- Create the close button, and set its scripts. ------------------------------------------------------------------------------- - MainPanel.close_button = GenericCreateButton(nil, MainPanel, 24, 111, "GameFontNormalSmall", _G.EXIT, "CENTER", L["CLOSE_DESC"], 1) - MainPanel.close_button:SetPoint("LEFT", MainPanel.progress_bar, "RIGHT", 3, 1) + local close_button = _G.CreateFrame("Button", ("%s_CloseButton"):format(FOLDER_NAME), MainPanel, "UIPanelButtonTemplate") + close_button:SetWidth(111) + close_button:SetHeight(24) + close_button:SetPoint("LEFT", MainPanel.progress_bar, "RIGHT", 3, 1) + close_button:SetText(_G.EXIT) - MainPanel.close_button:SetScript("OnClick", - function(self, button, down) - MainPanel:Hide() - end) + MainPanel.close_button = close_button + + close_button:SetScript("OnClick", function(self, button, down) + MainPanel:Hide() + end) + private.SetTooltipScripts(close_button, L["CLOSE_DESC"]) ------------------------------------------------------------------------------- -- Initialize components defined in other files. -------------------------------------------------------------------------------