diff --git a/.pkgmeta b/.pkgmeta index 00803e3..fc74409 100644 --- a/.pkgmeta +++ b/.pkgmeta @@ -64,4 +64,5 @@ move-folders: StarTip/Modules/Texts: StarTip_Texts StarTip/Modules/UnitTooltip: StarTip_UnitTooltip StarTip/Modules/Portrait: StarTip_Portrait - StarTip/Modules/Icons: StarTip_Icons \ No newline at end of file + StarTip/Modules/Icons: StarTip_Icons + StarTip/Modules/Gestures: StarTip_Gestures \ No newline at end of file diff --git a/Modules/Fade/Fade.lua b/Modules/Fade/Fade.lua index e1a6fce..785ac5f 100644 --- a/Modules/Fade/Fade.lua +++ b/Modules/Fade/Fade.lua @@ -83,8 +83,6 @@ function mod:OnInitialize() end function mod:OnEnable() - self:RawHook(GameTooltip, "FadeOut", "GameTooltipFadeOut", true) - self:RawHook(GameTooltip, "Hide", "GameTooltipHide", true) StarTip:SetOptionsDisabled(options, false) end @@ -151,17 +149,15 @@ end function mod:GameTooltipFadeOut(this, ...) if self.justFade then self.justFade = nil - self.hooks[this].FadeOut(this, ...) - return + return true end local kind - if self.isUnit then + if UnitExists(StarTip.unit or "mouseover") then if GameTooltip:IsOwned(UIParent) then kind = self.db.profile.units else kind = self.db.profile.unitFrames end - self.isUnit = nil else if GameTooltip:IsOwned(UIParent) then kind = self.db.profile.objects @@ -170,7 +166,7 @@ function mod:GameTooltipFadeOut(this, ...) end end if kind == 2 then - self.hooks[this].FadeOut(this, ...) + return true else self.justHide = true GameTooltip:Hide() @@ -180,16 +176,15 @@ end function mod:GameTooltipHide(this, ...) if self.justHide then self.justHide = nil - return self.hooks[this].Hide(this, ...) + return true end local kind - if self.isUnit then + if UnitExists(StarTip.unit or "mouseover") then if GameTooltip:IsOwned(UIParent) then kind = self.db.profile.units else kind = self.db.profile.unitFrames end - self.isUnit = nil else if GameTooltip:IsOwned(UIParent) then kind = self.db.profile.objects @@ -199,13 +194,9 @@ function mod:GameTooltipHide(this, ...) end if kind == 2 then self.justFade = true - return GameTooltip:FadeOut() + GameTooltip:FadeOut() else - return self.hooks[this].Hide(this, ...) + return true end end -function mod:SetUnit() - self.isUnit = true -end - diff --git a/Modules/Gestures/Gestures.lua b/Modules/Gestures/Gestures.lua new file mode 100644 index 0000000..8199ec0 --- /dev/null +++ b/Modules/Gestures/Gestures.lua @@ -0,0 +1,71 @@ +local mod = StarTip:NewModule("Gestures") +mod.name = "Gestures" +mod.toggled = true +local WidgetGestures = LibStub("LibScriptableDisplayWidgetGestures-1.0") +local LibCore = LibStub("LibScriptableDisplayCore-1.0") +local _G = _G +local GameTooltip = _G.GameTooltip +local StarTip = _G.StarTip +local UIParent = _G.UIParent +local gestures = {} +local environment = {} + +local defaults = { + profile = { + gestures = { + [1] = { + name = "Hide Tooltip", + enabled = true, + gestures = {{type="line", pattern="right"}, {type="line", pattern="left"}, {type="line", pattern="right"}, {type="line", pattern="left"}}, + expression = [[ +--_G.GameTooltip:Hide() +]] + } + } + } +} + + +local options = { +} + +local function copy(tbl) + if type(tbl) ~= "table" then return tbl end + local newTbl = {} + for k, v in pairs(tbl) do + newTbl[k] = copy(v) + end + return newTbl +end + + +function mod:OnInitialize() + self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults) + StarTip:SetOptionsDisabled(options, true) + + self.core = LibCore:New(mod, environment, "StarTip.Gestures", {["StarTip.Gestures"] = {}}, nil, StarTip.db.profile.errorLevel) +end + +function mod:OnEnable() + StarTip:SetOptionsDisabled(options, false) + for i, gesture in ipairs(self.db.profile.gestures) do + local widget = WidgetGestures:New(self.core, gesture.name, copy(gesture), StarTip.db.profile.errorLevel, timer) + if gesture.enabled then + widget:Start() + end + tinsert(gestures, widget) + end +end + +function mod:OnDisable() + StarTip:SetOptionsDisabled(options, true) + for i, widget in ipairs(gestures) do + widget:Del() + end + wipe(gestures) +end + +function mod:GetOptions() + return options +end + diff --git a/Modules/Gestures/StarTip_Gestures.toc b/Modules/Gestures/StarTip_Gestures.toc new file mode 100644 index 0000000..7ccb0a4 --- /dev/null +++ b/Modules/Gestures/StarTip_Gestures.toc @@ -0,0 +1,9 @@ +## Interface: 30300 +## X-Compatible-With: 40000 +## Title: StarTip [Gestures] +## Notes: Tooltips from outerspace +## Author: Starlon +## Version: 1.0 +## OptionalDeps: StarTip + +Gestures.lua \ No newline at end of file diff --git a/Modules/Histograms/Histograms.lua b/Modules/Histograms/Histograms.lua index 243c389..d2b0c45 100644 --- a/Modules/Histograms/Histograms.lua +++ b/Modules/Histograms/Histograms.lua @@ -42,12 +42,10 @@ for i, v in ipairs(anchors) do end local function copy(tbl) + if type(tbl) ~= "table" then return tbl end local newTbl = {} for k, v in pairs(tbl) do - if type(v) == "table" then - v = copy(v) - end - newTbl[k] = v + newTbl[k] = copy(v) end return newTbl end diff --git a/Modules/Portrait/Portrait.lua b/Modules/Portrait/Portrait.lua index 289b3f4..0874f18 100644 --- a/Modules/Portrait/Portrait.lua +++ b/Modules/Portrait/Portrait.lua @@ -117,7 +117,7 @@ function mod:SetUnit() self.texture:Show() self.model:Hide() end - self.text:SetFormattedText('|T%s:%d|t %s', self.texture:GetTexture(), self.db.profile.size, self.text:GetText()) -- we only need a blank space for the texture + self.text:SetFormattedText('|T%s:%d|t %s', self.texture:GetTexture(), self.db.profile.size, self.text:GetText() or "") -- we only need a blank space for the texture end function mod:OnHide() diff --git a/Modules/UnitTooltip/UnitTooltip.lua b/Modules/UnitTooltip/UnitTooltip.lua index 7dd66ac..10fbcb7 100644 --- a/Modules/UnitTooltip/UnitTooltip.lua +++ b/Modules/UnitTooltip/UnitTooltip.lua @@ -573,6 +573,7 @@ function mod:CreateLines() end}) end +--[[ function mod:OnHide() for i, v in ipairs(lines) do if v.leftObj then @@ -586,6 +587,21 @@ function mod:OnHide() self.timer:Stop() end end +]] + +function mod.GameTooltipHide() + for i, v in ipairs(lines) do + if v.leftObj then + v.leftObj:Stop() + end + if v.rightObj then + v.rightObj:Stop() + end + end + if self.timer then + self.timer:Stop() + end +end local function escape(text) return text:replace("|","||") diff --git a/StarTip.lua b/StarTip.lua index f30fe30..aa3d72f 100644 --- a/StarTip.lua +++ b/StarTip.lua @@ -479,10 +479,11 @@ function StarTip:OnEnable() GameTooltip:HookScript("OnTooltipSetSpell", self.OnTooltipSetSpell) self:RawHookScript(GameTooltip, "OnHide", "OnTooltipHide") self:RawHookScript(GameTooltip, "OnShow", "OnTooltipShow") - self:SecureHook(GameTooltip, "Show", self.GameTooltipShow) + self:RawHook(GameTooltip, "FadeOut", "GameTooltipFadeOut", true) + self:RawHook(GameTooltip, "Hide", "GameTooltipHide", true) + self:RawHook(GameTooltip, "Show", "GameTooltipShow", true) self:SecureHook(GameTooltip, "AddDoubleLine", self.GameTooltipAddLine) self:SecureHook(GameTooltip, "AddLine", self.GameTooltipAddLine) - self:SecureHook(GameTooltip, "FadeOut", self.GameTooltipFade) for k,v in self:IterateModules() do if (self.db.profile.modules[k] == nil and not v.defaultOff) or self.db.profile.modules[k] then @@ -710,6 +711,20 @@ function StarTip:HideAll() end end +function StarTip:GameTooltipHide(...) + local hide = true + + for k, v in StarTip:IterateModules() do + if v.GameTooltipHide and v:IsEnabled() then + hide = hide and v:GameTooltipHide(...) + end + end + + if hide then + StarTip.hooks[GameTooltip].Hide(...) + end +end + function StarTip:OnTooltipHide(...) if not self.justHide then for k, v in self:IterateModules() do @@ -763,7 +778,17 @@ function StarTip:GameTooltipShow(...) end end - if not show then GameTooltip:Hide() end + if not show then GameTooltip:Hide(); return end + + for k, v in StarTip:IterateModules() do + if v.GameTooltipShow and v:IsEnabled() then + show = show and v:GameTooltipShow(...) + end + end + + if show then + StarTip.hooks[GameTooltip].Show(...) + end end function StarTip.OnTooltipShow(...) @@ -778,9 +803,15 @@ function StarTip.OnTooltipShow(...) return StarTip.hooks[GameTooltip].OnShow(...) end -function StarTip.GameTooltipFade(...) +function StarTip:GameTooltipFadeOut(...) + local fadeOut = true for k, v in StarTip:IterateModules() do - if v.OnFadeOut and v:IsEnabled() then v:OnFadeOut(...) end + if v.GameTooltipFadeOut and v:IsEnabled() then + fadeOut = fadeOut and v:GameTooltipFadeOut(...) + end + end + if fadeOut then + StarTip.hooks[GameTooltip].FadeOut(...) end end diff --git a/modules.xml b/modules.xml index 25e8a93..4ca2afa 100644 --- a/modules.xml +++ b/modules.xml @@ -14,6 +14,7 @@ <Script file = "Modules\UnitTooltip\UnitTooltip.lua"/> <Script file = "Modules\Portrait\Portrait.lua"/> <Script file = "Modules\Icons\Icons.lua"/> +<Script file = "Modules\Gestures\Gestures.lua"/> <Script file = "Modules\Debug\Debug.lua"/> <!--@end-debug@-->