diff --git a/Modules/UnitTooltip/UnitTooltip.lua b/Modules/UnitTooltip/UnitTooltip.lua index 7479bcb..f75acfe 100644 --- a/Modules/UnitTooltip/UnitTooltip.lua +++ b/Modules/UnitTooltip/UnitTooltip.lua @@ -804,44 +804,52 @@ function mod:OnInitialize() self.evaluator = LibEvaluator self:ReInit() end + local draw local update function mod:OnEnable() StarTip:SetOptionsDisabled(options, false) - self.timer = LibTimer:New("Text module", self.db.profile.refreshRate, true, draw, nil, self.db.profile.errorLevel, self.db.profile.durationLimit) + self.timer = LibTimer:New("Text module", self.db.profile.refreshRate, true, draw, nil, self.db.profile.errorLevel) + self.trunkTimer = LibTimer:New("Text trunk timer", 500, true, self.AppendTrunk, self, self.db.profile.errorLevel) end + function mod:OnDisable() StarTip:SetOptionsDisabled(options, true) self.timer:Del() + self.trunkTimer:Del() end + function mod:GetOptions() self:RebuildOpts() return options end + function mod:UPDATE_FACTION() for i = 1, GetNumFactions() do local name = GetFactionInfo(i) factionList[name] = true end end + local widgetUpdate do local widgetsToDraw = {} function widgetUpdate(widget) tinsert(widgetsToDraw, widget) if mod.db.profile.refreshRate == 0 then - draw() + draw(true) end end local fontsList = LSM:List("font") - function draw() + function draw(bypass) if not UnitExists(StarTip.unit) then mod.timer:Stop() + mod.trunkTimer:Stop() StarTip.tooltipMain:Hide() return end --[[ - if GetMouseFocus() ~= "WorldFrame" then + if #StarTip.trunk > 0 and not bypass then wipe(widgetsToDraw) for k, v in pairs(lines) do if v.leftObj then @@ -879,7 +887,7 @@ do if not widget.config.right and widget.x == 1 then colSpan = 2 end - if widget.y and widget.buffer ~= "" then + if type(widget.y) == "number" and widget.y <= StarTip.tooltipMain:GetLineCount() and widget.buffer ~= "" then StarTip.tooltipMain:SetCell(widget.y, widget.x, widget.buffer, widget.fontObj, justification, colSpan, nil, 0, 0, nil, nil, 40) @@ -891,6 +899,11 @@ do end end end + table.wipe(widgetsToDraw) + end +end + +function mod:AppendTrunk() for i, v in ipairs(StarTip.trunk) do if #v == 2 then local y = StarTip.tooltipMain:AddLine('', '') @@ -902,11 +915,9 @@ do end end StarTip:TrunkClear() - table.wipe(widgetsToDraw) - end end -function mod:ClearLines() +function mod:StopLines() for k, v in pairs(lines) do if v.leftObj then v.leftObj:Stop() @@ -915,8 +926,14 @@ function mod:ClearLines() v.rightObj:Stop() end end + +end + +function mod:ClearLines() + self:StopLines() wipe(lines) end + local tbl function mod:CreateLines() local llines = {} @@ -1026,15 +1043,9 @@ function mod:CreateLines() end function mod:OnHide() - for i, v in ipairs(lines) do - if v.leftObj then - v.leftObj:Stop() - end - if v.rightObj then - v.rightObj:Stop() - end - end + self:StopLines() self.timer:Stop() + self.trunkTimer:Stop() end function mod:OnFadeOut() @@ -1583,12 +1594,17 @@ function mod:SetUnit() end StarTip:TrunkAdd(txt1, r1, g1, b1, txt2, r2, g2, b2) end + + mod:StopLines() lines() - draw() + mod:AppendTrunk() + if mod.db.profile.refreshRate ~= 0 then self.timer:Start() end + self.trunkTimer:Start() end + --[[ function mod:RefixEndLines() -- Another part taken from CowTip diff --git a/StarTip.lua b/StarTip.lua index f6b3ef1..2ec6fa7 100644 --- a/StarTip.lua +++ b/StarTip.lua @@ -359,22 +359,6 @@ environment.new = StarTip.new environment.newDict = StarTip.newDict environment.del = StarTip.del ---[[ -PluginRangeCheck:New(environment) -PluginUnit:New(environment) -PluginWidgetText:New(environment) -PluginBit:New(environment) -PluginLua:New(environment) -PluginMath:New(environment) -PluginString:New(environment) -PluginTable:New(environment) -PluginResourceTools:New(environment) -PluginLocation:New(environment) -PluginUnitTooltipScan:New(environment) -if PluginDBM then PluginDBM:New(environment) end ---PluginLinq:New(environment) ---]] - local function errorhandler(err) return geterrorhandler()(err) end @@ -406,16 +390,6 @@ function StarTip:RefreshConfig() self:Print(L["You may need to reload your UI."]) end -local checkTooltipAlphaFrame -local checkTooltipAlpha = function() - if GameTooltip:GetAlpha() < 1 then - StarTip.fading = true - checkTooltipAlphaFrame:SetScript("OnUpdate", nil) - end -end - -checkTooltipAlphaFrame = CreateFrame("Frame") - local menuoptions = { name = "StarTip", type = "group", @@ -427,6 +401,7 @@ local menuoptions = { } } } + function StarTip:OnInitialize() self.db = LibStub("AceDB-3.0"):New("StarTipDB", defaults, "Default") self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig") @@ -445,10 +420,9 @@ function StarTip:OnInitialize() self.lastConfig = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("StarTip-Addon", "Profiles", "StarTip-Addon", "Profiles") end - local leftGameTooltipStrings, rightGameTooltipStrings = {}, {} self.leftLines = {} self.rightLines = {} - self.qtipLines = {} + --self.qtipLines = {} for i = 1, 50 do GameTooltip:AddDoubleLine(' ', ' ') self.leftLines[i] = _G["GameTooltipTextLeft" .. i] @@ -719,6 +693,7 @@ function StarTip:HideTooltip() GameTooltip:Hide() self.tooltipHidden = true end +--]] function StarTip:ShowTooltip(unit) self.tooltipHidden = false @@ -728,7 +703,7 @@ function StarTip:ShowTooltip(unit) GameTooltip:SetUnit(unit) GameTooltip:Show() end -]] + function StarTip.GameTooltipAddLine(...) end @@ -753,7 +728,6 @@ function StarTip.OnTooltipSetUnit(...) if not unit then return end - StarTip:TrunkClear() trunkLines = GameTooltip:NumLines() @@ -772,7 +746,7 @@ function StarTip.OnTooltipSetUnit(...) if unit ~= "mouseover" and UnitIsUnit(unit, "mouseover") then unit = "mouseover" end - + StarTip.owner = GameTooltip:GetOwner() StarTip.unit = unit environment.unit = unit @@ -961,6 +935,7 @@ function StarTip:SetOptionsDisabled(t, bool) end -- Taken from CowTip +--[[ function StarTip:GetMouseoverUnit() local _, tooltipUnit = GameTooltip:GetUnit() if not tooltipUnit or not UnitExists(tooltipUnit) or UnitIsUnit(tooltipUnit, "mouseover") then @@ -969,6 +944,7 @@ function StarTip:GetMouseoverUnit() return tooltipUnit end end +]] -- Taken from CowTip and modified a bit function StarTip:MODIFIER_STATE_CHANGED(ev, modifier, up, ...)