From 5450f8f0c8f3b754b8db19a9102ca751e3a05a15 Mon Sep 17 00:00:00 2001 From: Dencer Date: Thu, 5 Sep 2024 15:03:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 ++ Addon.lua | 85 +++++++++++++++++++++++++++++++++++++-- Core/Pool.lua | 1 - Libs/tdOptions | 1 + Load.xml | 1 + UI/CharacterGearFrame.lua | 21 +++++++++- UI/GearFrame.lua | 27 ++++++++----- UI/InspectGearFrame.lua | 9 +++-- UI/Option.lua | 50 +++++++++++++++++++++++ UI/PaperDoll.lua | 14 +++---- UI/Template.xml | 9 ++--- tdInspect.toc | 1 + 12 files changed, 189 insertions(+), 33 deletions(-) create mode 160000 Libs/tdOptions create mode 100644 UI/Option.lua diff --git a/.gitmodules b/.gitmodules index 3890259..f74ff50 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "Libs/LibShowUIPanel-1.0"] path = Libs/LibShowUIPanel-1.0 url = https://github.com/DengSir/LibShowUIPanel-1.0.git +[submodule "Libs/tdOptions"] + path = Libs/tdOptions + url = git@github.com:DengSir/tdOptions.git diff --git a/Addon.lua b/Addon.lua index 0461b4a..b832b7d 100644 --- a/Addon.lua +++ b/Addon.lua @@ -49,7 +49,12 @@ function Addon:OnInitialize() global = { -- userCache = {}, }, - profile = {}, + profile = { -- + characterGear = true, + inspectGear = true, + inspectCompare = true, + showTalentBackground = true, + }, } ---@type tdInspectProfile | AceDB.Schema @@ -66,15 +71,22 @@ function Addon:OnInitialize() end self.db.global.version = ns.VERSION + + self.CharacterGearParent = CreateFrame('Frame', nil, PaperDollFrame) + self.CharacterGearParent:SetPoint('TOPLEFT', CharacterFrame, 'TOPRIGHT', -33, -12) + self.CharacterGearParent:SetSize(1, 1) + self.CharacterGearParent:SetScript('OnShow', function() + self:OpenCharacterGearFrame() + end) + + self:SetupOptionFrame() end function Addon:OnEnable() self:RegisterEvent('ADDON_LOADED') self:RegisterMessage('INSPECT_READY') self:RegisterMessage('INSPECT_TALENT_READY', 'INSPECT_READY') - - self.GearFrame = ns.UI.CharacterGearFrame:Create(PaperDollFrame) - self.GearFrame:SetPoint('TOPLEFT', CharacterFrame, 'TOPRIGHT', -33, -12) + self:RegisterMessage('TDINSPECT_OPTION_CHANGED') end function Addon:OnModuleCreated(module) @@ -112,3 +124,68 @@ function Addon:INSPECT_READY(_, unit, name) ShowUIPanel(self.InspectFrame) end end + +function Addon:TDINSPECT_OPTION_CHANGED(_, key, value) + if key == 'characterGear' then + if value then + if self.CharacterGearParent:IsShown() then + self:OpenCharacterGearFrame() + end + elseif self.CharacterGearFrame then + if not self.db.profile.inspectCompare or not self.InspectGearFrame or not self.InspectGearFrame:IsShown() then + self.CharacterGearFrame:Hide() + end + end + elseif key == 'inspectGear' then + if value then + if InspectPaperDollFrame:IsShown() then + self:OpenInspectGearFrame() + elseif self.InspectGearFrame then + self.InspectGearFrame:Hide() + end + end + end +end + +---@return UI.CharacterGearFrame +function Addon:GetCharacterGearFrame() + if not self.CharacterGearFrame then + self.CharacterGearFrame = ns.UI.CharacterGearFrame:Create(self.CharacterGearParent) + end + return self.CharacterGearFrame +end + +function Addon:GetInspectGearFrame() + if not self.InspectGearFrame then + self.InspectGearFrame = ns.UI.InspectGearFrame:Create(InspectPaperDollFrame) + self.InspectGearFrame:SetPoint('TOPLEFT', InspectPaperDollFrame, 'TOPRIGHT', -33, -12) + end + return self.InspectGearFrame +end + +function Addon:OpenCharacterGearFrame() + if self.db.profile.characterGear then + local characterGearFrame = self:GetCharacterGearFrame() + + if characterGearFrame:IsShown() then + return + end + + characterGearFrame:TapTo(self.CharacterGearParent, 'TOPLEFT') + characterGearFrame:Show() + end +end + +function Addon:OpenInspectGearFrame() + if self.db.profile.inspectGear then + local inspectGearFrame = self:GetInspectGearFrame() + inspectGearFrame:Show() + + if self.db.profile.inspectCompare then + local characterGearFrame = self:GetCharacterGearFrame() + + characterGearFrame:TapTo(inspectGearFrame, 'TOPLEFT', inspectGearFrame, 'TOPRIGHT', 0, 0) + characterGearFrame:Show() + end + end +end diff --git a/Core/Pool.lua b/Core/Pool.lua index 56e0d73..7a0eff3 100644 --- a/Core/Pool.lua +++ b/Core/Pool.lua @@ -38,7 +38,6 @@ function Pool:Alloc(parent) end function Pool:Free() - print(self, debugstack()) self.pool[self] = true if self.Hide then diff --git a/Libs/tdOptions b/Libs/tdOptions new file mode 160000 index 0000000..19552f3 --- /dev/null +++ b/Libs/tdOptions @@ -0,0 +1 @@ +Subproject commit 19552f3f66794a6ea541dd5cdd705ac55ba548e2 diff --git a/Load.xml b/Load.xml index 9c04992..d47b53e 100644 --- a/Load.xml +++ b/Load.xml @@ -44,5 +44,6 @@