From 021d991bd06ea518489675efbbb35d0fcbe184fa Mon Sep 17 00:00:00 2001 From: torhal Date: Mon, 23 Nov 2009 23:53:19 +0000 Subject: [PATCH] Moved creation of arlSpellTooltip from addon:InitializeFrame() into the main file body, and changed its parent from MainPanel to UIParent. In SetSpellTooltip(): Copy GameTooltip's main settings over to arlSpellTooltip so AddOns which modify GameTooltip will work on it. Moved the setting of arlSpellTooltip's scale from addon:DisplayFrame() to SetSpellTooltip(), where the config option will actually work. Moved the setting of arlTooltip's scale to after its anchor points have been cleared then set so the config option will actually work. Moved TipTac skinning of arlSpellTooltip from addon:InitializeFrame() to SetSpellTooltip(). In giveDisplay(): Change L["UI Scale"] to _G.UI_SCALE, removed check for addon.Frame's existence, and removed the attempt to set the scale of arlTooltip and arlSpellTooltip. Removed "UI Scale" from the localization table. Removed some comments for which their code was obvious in function. Removed global references to arlTooltip and arlSpellTooltip. Added file-local arlTooltip, as there is no reason for it to be global. --- ARLConfig.lua | 28 ++++++++----------------- ARLFrame.lua | 58 ++++++++++++++++++++++++++------------------------- Locals/testenUS.lua | 1 - 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/ARLConfig.lua b/ARLConfig.lua index 07652ae..527c693 100644 --- a/ARLConfig.lua +++ b/ARLConfig.lua @@ -512,10 +512,8 @@ end local displayoptions = nil local function giveDisplay() - - if (not displayoptions) then - - displayoptions = { + if not displayoptions then + displayoptions = { order = 1, type = "group", name = L["Display Options"], @@ -538,7 +536,7 @@ local function giveDisplay() uiscale = { order = 3, type = "range", - name = L["UI Scale"], + name = _G.UI_SCALE, desc = L["UI_SCALE_DESC"], min = .5, max = 1.5, @@ -546,8 +544,8 @@ local function giveDisplay() bigStep = .05, get = function() return addon.db.profile.frameopts.uiscale end, set = function(info, v) - addon.db.profile.frameopts.uiscale = v - if (addon.Frame) then addon.Frame:SetScale(v) end + addon.db.profile.frameopts.uiscale = v + addon.Frame:SetScale(v) end, }, fontsize = { @@ -602,11 +600,11 @@ local function giveDisplay() max = 1.5, step = .05, bigStep = .05, - get = function() return addon.db.profile.frameopts.tooltipscale end, + get = function() + return addon.db.profile.frameopts.tooltipscale + end, set = function(info, v) - addon.db.profile.frameopts.tooltipscale = v - if (arlTooltip) then arlTooltip:SetScale(v) end - if (arlSpellTooltip) then arlSpellTooltip:SetScale(v) end + addon.db.profile.frameopts.tooltipscale = v end, }, acquiretooltiplocation = { @@ -629,16 +627,11 @@ local function giveDisplay() }, }, } - - end - return displayoptions - end function addon:SetupOptions() - AceConfigReg:RegisterOptionsTable(MODNAME, fullOptions) self.optionsFrame = AceConfigDialog:AddToBlizOptions(MODNAME, nil, nil, "general") @@ -655,7 +648,6 @@ function addon:SetupOptions() self:RegisterModuleOptions("Documentation", giveDocs(), L["ARL Documentation"]) self:RegisterModuleOptions("Map", giveMap(), L["Map Options"]) self:RegisterModuleOptions("Profiles", giveProfiles(), L["Profile Options"]) - end -- Description: Function which extends our options table in a modular way @@ -667,8 +659,6 @@ end -- Output: None. function addon:RegisterModuleOptions(name, optionsTable, displayName) - modularOptions[name] = optionsTable self.optionsFrame[name] = AceConfigDialog:AddToBlizOptions(MODNAME, displayName, MODNAME, name) - end diff --git a/ARLFrame.lua b/ARLFrame.lua index 1ce6349..4edfe30 100644 --- a/ARLFrame.lua +++ b/ARLFrame.lua @@ -87,8 +87,8 @@ local FLYAWAY_SINGLE_WIDTH = 136 local FLYAWAY_DOUBLE_WIDTH = 300 local FLYAWAY_HEIGHT = 312 -local FLYAWAY_SMALL = 112 -local FLYAWAY_LARGE = 210 +local FLYAWAY_SMALL = 112 +local FLYAWAY_LARGE = 210 ------------------------------------------------------------------------------- @@ -96,9 +96,6 @@ local FLYAWAY_LARGE = 210 ------------------------------------------------------------------------------- local FilterValueMap -- Assigned in addon:InitializeFrame() -local arlTooltip = _G["arlTooltip"] -local arlSpellTooltip = _G["arlSpellTooltip"] - local ARL_SearchText, ARL_LastSearchedText local ARL_ExpGeneralOptCB, ARL_ExpObtainOptCB, ARL_ExpBindingOptCB, ARL_ExpItemOptCB, ARL_ExpPlayerOptCB, ARL_ExpRepOptCB, ARL_RepOldWorldCB, ARL_RepBCCB, ARL_RepLKCB,ARL_ExpMiscOptCB @@ -175,6 +172,11 @@ do end -- do block ------------------------------------------------------------------------------- +-- Create arlSpellTooltip +------------------------------------------------------------------------------- +local arlSpellTooltip = CreateFrame("GameTooltip", "arlSpellTooltip", UIParent, "GameTooltipTemplate") + +------------------------------------------------------------------------------- -- Create the MainPanel and set its values ------------------------------------------------------------------------------- local MainPanel = CreateFrame("Frame", "ARL_MainPanel", UIParent) @@ -190,7 +192,8 @@ MainPanel:Show() MainPanel.is_expanded = false -tinsert(UISpecialFrames, "ARL_MainPanel") -- Allows ARL to be closed with the Escape key +-- Let the user banish the MainPanel with the ESC key. +tinsert(UISpecialFrames, "ARL_MainPanel") addon.Frame = MainPanel @@ -923,6 +926,8 @@ end ------------------------------------------------------------------------------- -- Tooltip functions and data. ------------------------------------------------------------------------------- +local arlTooltip + -- Font Objects needed for arlTooltip local narrowFont local normalFont @@ -1002,15 +1007,29 @@ end local function SetSpellTooltip(owner, loc, link) arlSpellTooltip:SetOwner(owner, "ANCHOR_NONE") arlSpellTooltip:ClearAllPoints() - if (loc == "Top") then + + if loc == "Top" then arlSpellTooltip:SetPoint("BOTTOMLEFT", owner, "TOPLEFT") - elseif (loc == "Bottom") then + elseif loc == "Bottom" then arlSpellTooltip:SetPoint("TOPLEFT", owner, "BOTTOMLEFT") - elseif (loc == "Left") then + elseif loc == "Left" then arlSpellTooltip:SetPoint("TOPRIGHT", owner, "TOPLEFT") - elseif (loc == "Right") then + elseif loc == "Right" then arlSpellTooltip:SetPoint("TOPLEFT", owner, "TOPRIGHT") end + + -- Add TipTac Support + if TipTac and TipTac.AddModifiedTip and not arlSpellTooltip.tiptac then + TipTac:AddModifiedTip(arlSpellTooltip) + arlSpellTooltip.tiptac = true + end + + -- Set the spell tooltip's scale, and copy its other values from GameTooltip so AddOns which modify it will work. + arlSpellTooltip:SetBackdrop(GameTooltip:GetBackdrop()) + arlSpellTooltip:SetBackdropColor(GameTooltip:GetBackdropColor()) + arlSpellTooltip:SetBackdropBorderColor(GameTooltip:GetBackdropBorderColor()) + arlSpellTooltip:SetScale(addon.db.profile.frameopts.tooltipscale) + arlSpellTooltip:SetHyperlink(link) arlSpellTooltip:Show() end @@ -1033,7 +1052,6 @@ local function GenerateTooltipContent(owner, rIndex) return end arlTooltip = QTip:Acquire(MODNAME.." Tooltip", 2, "LEFT", "LEFT") - arlTooltip:SetScale(addon.db.profile.frameopts.tooltipscale) arlTooltip:ClearAllPoints() if acquireTooltipLocation == "Right" then @@ -1059,6 +1077,7 @@ local function GenerateTooltipContent(owner, rIndex) local clr1, clr2 = "", "" arlTooltip:Clear() + arlTooltip:SetScale(addon.db.profile.frameopts.tooltipscale) arlTooltip:AddHeader() arlTooltip:SetCell(1, 1, "|cff"..addon:hexcolor("HIGH")..recipe_entry["Name"], "CENTER", 2) @@ -2571,16 +2590,6 @@ function addon:InitializeFrame() end -- do ------------------------------------------------------------------------------- - -- I'm going to use my own tooltip for recipebuttons - ------------------------------------------------------------------------------- - arlSpellTooltip = CreateFrame("GameTooltip", "arlSpellTooltip", MainPanel, "GameTooltipTemplate") - - -- Add TipTac Support - if TipTac and TipTac.AddModifiedTip then - TipTac:AddModifiedTip(arlSpellTooltip) - end - - ------------------------------------------------------------------------------- -- The main recipe list buttons and scrollframe ------------------------------------------------------------------------------- do @@ -3909,7 +3918,6 @@ function addon:DisplayFrame() MainPanel:SetScale(addon.db.profile.frameopts.uiscale) ARL_DD_Sort.initialize = ARL_DD_Sort_Initialize -- Initialize dropdown - arlSpellTooltip:SetScale(addon.db.profile.frameopts.tooltipscale) SortRecipeList() @@ -4034,7 +4042,6 @@ do if num_entries < display_lines then display_lines = num_entries / 2 end - FauxScrollFrame_Update(self, num_entries, display_lines, 16) addon:ClosePopups() @@ -4102,27 +4109,22 @@ do showpopup = true end - -- If the recipe total is at 0, it means we have not scanned the profession yet if Player.recipes_total == 0 then if showpopup then StaticPopup_Show("ARL_NOTSCANNED") end - -- We know all the recipes elseif Player.recipes_known == Player.recipes_total then if showpopup then StaticPopup_Show("ARL_ALLKNOWN") end - -- Our filters are actually filtering something elseif (Player.recipes_total_filtered - Player.recipes_known_filtered) == 0 then if showpopup then StaticPopup_Show("ARL_ALLFILTERED") end - -- Our exclusion list is preventing something from being displayed elseif Player.excluded_recipes_unknown ~= 0 then if showpopup then StaticPopup_Show("ARL_ALLEXCLUDED") end - -- We have some search text that is preventing stuff from being displayed elseif ARL_SearchText:GetText() ~= "" then StaticPopup_Show("ARL_SEARCHFILTERED") else diff --git a/Locals/testenUS.lua b/Locals/testenUS.lua index f7c2e0a..7c7900d 100644 --- a/Locals/testenUS.lua +++ b/Locals/testenUS.lua @@ -151,7 +151,6 @@ L["Display Exclusions"] = true L["DISPLAY_EXCLUSION_DESC"] = "Display recipes that are in the exclusion list." L["Reset Window Position"] = true L["RESET_WINDOW_DESC"] = "Resets the ARL GUI to default position." -L["UI Scale"] = true L["UI_SCALE_DESC"] = "Changes the scale of the UI. Ranges from .5 to 1.5 (1 is default)" L["Tooltip Scale"] = true L["TOOLTIP_SCALE_DESC"] = "Changes the scale of the ARL tooltip. Ranges from .5 to 1.5 (.9 is default)" -- 1.7.9.5