Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DengSir committed Aug 29, 2024
1 parent 775bc59 commit e3d53d3
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 137 deletions.
2 changes: 0 additions & 2 deletions Addon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ end

function Addon:SetupUI()
self.InspectFrame = ns.UI.InspectFrame:Bind(InspectFrame)
self.InspectGearFrame = ns.UI.InspectGearFrame:Create(self.InspectFrame)
self.InspectGearFrame:SetPoint('TOPLEFT', self.InspectFrame, 'TOPRIGHT', -33, -12)
end

function Addon:ADDON_LOADED(_, addon)
Expand Down
2 changes: 1 addition & 1 deletion Api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function ns.GetItemEnchantInfo(link)
if not link then
return
end
local enchantId = tonumber(link:match('item:%d+:(%d*):'))
local enchantId = tonumber(link:match('item:%d+:(%d*)'))
if enchantId then
local itemId, _, _, _, _, classId, subClassId = GetItemInfoInstant(link)
local invType = C_Item.GetItemInventoryTypeByID(itemId)
Expand Down
28 changes: 21 additions & 7 deletions Core/Inspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ function Inspect:SetUnit(unit, name)
end
end

function Inspect:GetUnitName()
if self.unit then
return ns.UnitName(self.unit)
else
return Ambiguate(self.unitName, 'none')
end
end

function Inspect:Clear()
ClearInspectPlayer()
self.unitName = nil
Expand Down Expand Up @@ -399,31 +407,31 @@ function Inspect:Query(unit, name)
if queryEquip or queryTalent or queryGlyph or queryRune then

local co = coroutine.create(function()
local me = self:IsCharacterHasProto('tdInspect')
local ala = self:IsCharacterHasProto('TalentEmu')
local unitName = self.unitName
local me = self:IsCharacterHasProto(unitName, 'tdInspect')
local ala = self:IsCharacterHasProto(unitName, 'TalentEmu')


self:ClearCharacterProto(self.unitName, 'tdInspect')
self:ClearCharacterProto(unitName, 'tdInspect')
self:SendCommMessage(PROTO_PREFIX, Serializer:Serialize('Q', queryTalent, queryEquip, PROTO_VERSION,
queryGlyph, queryRune), 'WHISPER', self.unitName)

if me then
sleep(1)
end

if self:IsCharacterHasProto('tdInspect') then
if self:IsCharacterHasProto(unitName, 'tdInspect') then
return
end

self:ClearCharacterProto(self.unitName, 'TalentEmu')
self:ClearCharacterProto(unitName, 'TalentEmu')
self:SendCommMessage(ALA_PREFIX, ns.Ala:PackQuery(queryEquip, queryTalent, queryGlyph, queryRune),
'WHISPER', self.unitName)

if ala then
sleep(1)
end

if self:IsCharacterHasProto('TalentEmu') then
if self:IsCharacterHasProto(unitName, 'TalentEmu') then
return
end

Expand Down Expand Up @@ -510,6 +518,12 @@ end

function Inspect:UpdateCharacter(sender, data)
local name = ns.GetFullName(sender)

if self:IsCharacterHasProto(name, 'tdInspect') and self.userCache[name] and self.userCache[name].timestamp and
time() - self.userCache[name].timestamp < 5 then
return
end

local db = self:BuildCharacterDb(name)

if data.class then
Expand Down
2 changes: 0 additions & 2 deletions Load.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
<Script file="UI\SocketItem.lua" />
<Script file="UI\BaseItem.lua" />
<Script file="UI\SlotItem.lua" />
<Script file="UI\EquipItem.lua" />
<Script file="UI\EquipFrame.lua" />
<Script file="UI\ModelFrame.lua" />
<Script file="UI\PaperDoll.lua" />
<Script file="UI\InspectFrame.lua" />
Expand Down
1 change: 0 additions & 1 deletion UI/ElvUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ hooksecurefunc(ns.Addon, 'SetupUI', function(self)
self.InspectFrame.TalentFrame.TalentFrame:StripTextures()
self.InspectFrame.TalentFrame.TalentFrame:CreateBackdrop('Default')

self.InspectFrame.PaperDoll.EquipFrame:CreateBackdrop('Default')
self.InspectFrame.PaperDoll.ModelFrame:CreateBackdrop('Default')

for i, tab in ipairs(self.InspectFrame.TalentFrame.Tabs) do
Expand Down
12 changes: 6 additions & 6 deletions UI/EquipItem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ function EquipItem:OnEnter()
end

function EquipItem:Update()
self.itemId = nil
self:FreeAllEnchants()

self.Name:SetText('')
self.ItemLevel:SetText('')
self.Slot:SetTextColor(0.6, 0.6, 0.6)

local id = self:GetID()

local item = Inspect:GetItemLink(id)
Expand Down Expand Up @@ -162,7 +165,7 @@ function EquipItem:Update()
end
end

self.Enchant:SetWidth(17 * self.enchantCount)
self.Enchant:SetWidth(max(0.1, 17 * self.enchantCount))
self.Name:SetPoint('RIGHT', self.Enchant, 'LEFT', -2, 0)

local name, link, quality, itemLevel = GetItemInfo(item)
Expand All @@ -177,10 +180,7 @@ function EquipItem:Update()
return
else
self:WaitItem(item)
return
end
end

self.Name:SetText('')
self.ItemLevel:SetText('')
self.Slot:SetTextColor(0.6, 0.6, 0.6)
end
53 changes: 28 additions & 25 deletions UI/GearFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ local EQUIP_SLOTS = {
{id = 17, name = SECONDARYHANDSLOT}, --
{id = 18, name = RANGEDSLOT}, --
}
local SPACING = 3

local SPACING_V = 3
local SPACING_H = 5
local PADDING = 10

---@class UI.GearFrame : Frame, AceEvent-3.0
---@class UI.GearFrame : Frame, BackdropTemplate, AceEvent-3.0
local GearFrame = ns.Addon:NewClass('UI.GearFrame', 'Frame')

function GearFrame:Create(parent)
Expand All @@ -38,36 +40,30 @@ end
function GearFrame:Constructor()
self:SetHeight(424)
self:SetBackdrop{
bgFile = 'Interface\\Tooltips\\UI-Tooltip-Background',
edgeFile = 'Interface\\Tooltips\\UI-Tooltip-Border',
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
tile = true,
tileSize = 8,
edgeSize = 16,
insets = {left = 4, right = 4, top = 4, bottom = 4},
}
self:SetBackdropColor(0, 0, 0, 0.8)
self:SetBackdropBorderColor(0.6, 0.6, 0.6)
self:SetBackdropColor(0, 0, 0, 0.95)

local SlotColumn = CreateFrame('Frame', nil, self)
SlotColumn:SetPoint('TOPLEFT', PADDING, 0)
SlotColumn:SetHeight(1)
self.SlotColumn = SlotColumn

local LevelColumn = CreateFrame('Frame', nil, self)
LevelColumn:SetPoint('TOPLEFT', SlotColumn, 'TOPRIGHT', SPACING, 0)
LevelColumn:SetPoint('TOPLEFT', SlotColumn, 'TOPRIGHT', SPACING_H, 0)
LevelColumn:SetHeight(1)
self.LevelColumn = LevelColumn

local Portrait = CreateFrame('Frame', nil, self, 'ClassicGarrisonFollowerPortraitTemplate')
Portrait:SetPoint('TOPLEFT', 18, -16)
Portrait:SetScale(0.8)
self.Portrait = Portrait

local Title = frame:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLargeOutline')
local Title = self:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLargeOutline')
Title:SetPoint('TOPLEFT', 66, -18)
self.Title = Title

local Level = frame:CreateFontString(nil, 'ARTWORK', 'ChatFontNormal')
local Level = self:CreateFontString(nil, 'ARTWORK', 'ChatFontNormal')
Level:SetPoint('TOPLEFT', 66, -42)
Level:SetFont(Level:GetFont(), 12, 'THINOUTLINE')
self.Level = Level
Expand All @@ -77,35 +73,42 @@ function GearFrame:Constructor()

for i, v in ipairs(EQUIP_SLOTS) do
local item = ns.UI.GearItem:New(self, v.id, v.name)
local y = -(i - 1) * (item:GetHeight() + SPACING) - 80
local y = -(i - 1) * (item:GetHeight() + SPACING_V) - 80
item:SetPoint('TOPLEFT', PADDING, y)
item:SetPoint('TOPRIGHT', -PADDING, y)
item:SetWidth(100)
self.gears[v.id] = item
end
end

function GearFrame:OnUpdate()
self:SetScript('OnUpdate', nil)
self:UpdateSize()
function GearFrame:ApplyColumnWidth(key, width)
self.columnWidths[key] = max(self.columnWidths[key] or 0, width)
self:RequestUpdateSize()
end

function GearFrame:OnChildSizeChanged()
function GearFrame:RequestUpdateSize()
self:SetScript('OnUpdate', self.OnUpdate)
end

function GearFrame:ApplyColumnWidth(key, width)
self.columnWidths[key] = max(self.columnWidths[key] or 0, width)
function GearFrame:OnUpdate()
self:SetScript('OnUpdate', nil)
self:UpdateSize()
end

function GearFrame:UpdateSize()
local width = 0
for key, v in pairs(self.columnWidths) do
width = width + v + SPACING
width = width + v + SPACING_H

if self[key] then
self[key]:SetWidth(v)
end
end
self:SetWidth(width - SPACING + PADDING * 2)
self:SetWidth(width - SPACING_V + PADDING * 2)
end

function GearFrame:StartLayout()
wipe(self.columnWidths)
end

function GearFrame:EndLayout()
self:RequestUpdateSize()
end
Loading

0 comments on commit e3d53d3

Please sign in to comment.