Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DengSir committed Sep 1, 2024
1 parent e3d53d3 commit fb9ff99
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 55 deletions.
101 changes: 81 additions & 20 deletions Core/Inspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,73 @@ function Inspect:IsItemEquipped(itemId)
end
end

local function GetSlotItemLevel(slot)
local itemId = Inspect:GetItemLink(slot)
if not itemId then
return 0
end

local itemLevel = select(4, GetItemInfo(itemId))
if itemLevel then
return itemLevel
end
end

local function GetMainhandItemLevel(slot)
local itemId = Inspect:GetItemLink(slot)
if not itemId then
return 0
end
local itemLevel, _, _, _, _, itemEquipLoc = select(4, GetItemInfo(itemId))
if itemEquipLoc == 'INVTYPE_2HWEAPON' then
return itemLevel * 2
end
return itemLevel
end

local function GetRangedItemLevel(slot)
if UnitClassBase('player') ~= 'HUNTER' then
return 0, true
end
return GetSlotItemLevel(slot)
end

local SLOTS = {
[INVSLOT_HEAD] = GetSlotItemLevel,
[INVSLOT_NECK] = GetSlotItemLevel,
[INVSLOT_SHOULDER] = GetSlotItemLevel,
[INVSLOT_CHEST] = GetSlotItemLevel,
[INVSLOT_WAIST] = GetSlotItemLevel,
[INVSLOT_LEGS] = GetSlotItemLevel,
[INVSLOT_FEET] = GetSlotItemLevel,
[INVSLOT_WRIST] = GetSlotItemLevel,
[INVSLOT_HAND] = GetSlotItemLevel,
[INVSLOT_FINGER1] = GetSlotItemLevel,
[INVSLOT_FINGER2] = GetSlotItemLevel,
[INVSLOT_TRINKET1] = GetSlotItemLevel,
[INVSLOT_TRINKET2] = GetSlotItemLevel,
[INVSLOT_BACK] = GetSlotItemLevel,
[INVSLOT_MAINHAND] = GetMainhandItemLevel,
[INVSLOT_OFFHAND] = GetSlotItemLevel,
[INVSLOT_RANGED] = GetRangedItemLevel,
}

function Inspect:GetItemLevel()
local total, count = 0, 0

for slot, f in pairs(SLOTS) do
local itemLevel, ignore = f(slot)
if not itemLevel then
return
end
if not ignore then
count = count + 1
total = total + itemLevel
end
end
return total / count
end

-- @build>2@
local GEM_COLORS = {
[Enum.ItemGemSubclass.Red] = {Enum.ItemGemSubclass.Red},
Expand Down Expand Up @@ -234,40 +301,23 @@ end
-- @end-build>2@

function Inspect:GetEquippedSetItems(id)
local count = 0
local items = {}
local overrideNames = {}
local slotItems = ns.ItemSets[id].slots

local count = 0
for slot = 1, 18 do
local link = self:GetItemLink(slot)
if link then
local name, _, _, _, _, _, _, _, equipLoc, _, _, _, _, _, _, setId = GetItemInfo(link)
if name and setId and setId == id then
local baseName
local itemId = ns.ItemLinkToId(link)

if equipLoc == 'INVTYPE_ROBE' then
equipLoc = 'INVTYPE_CHEST'
end

local isBaseItem = slotItems[equipLoc][itemId]
if not isBaseItem then
local baseItemId = next(slotItems[equipLoc])
baseName = GetItemInfo(baseItemId)
if baseName then
overrideNames[baseName] = name
end
items[name] = (items[name] or 0) + 1
end

items[equipLoc] = itemId
count = count + 1
baseName = baseName or name
items[baseName] = (items[baseName] or 0) + 1
end
end
end
return count, items, overrideNames
return count, items
end

function Inspect:GetUnitClassFileName()
Expand Down Expand Up @@ -310,6 +360,17 @@ function Inspect:GetUnitLevel()
end
end

function Inspect:GetDataSource()
if self.db.proto then
if self.db.proto.tdInspect then
return 'tdInspect'
elseif self.db.proto.TalentEmu then
return 'TalentEmu'
end
end
return 'Blizzard'
end

function Inspect:GetNumTalentGroups()
return self.db.numGroups or 0
end
Expand Down
4 changes: 1 addition & 3 deletions Data/DataLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ function ns.ItemSetMake()
end

local function SetItemSetSlotItem(slot, itemId)
slot = SLOTS[slot]
CURRENT.slots[slot] = CURRENT.slots[slot] or {}
CURRENT.slots[slot][itemId] = true
tinsert(CURRENT.slots, {slot = SLOTS[slot], itemId = itemId})
end

setfenv(2, { --
Expand Down
1 change: 1 addition & 0 deletions Localization/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ L["Show Model"] = true
-- @import@
L['Show Model'] = true
L['Last update:'] = true
L['Data source:'] = true
L['Inspect target'] = true
L['Inspect mouseover'] = true
-- @locale-fill@
Expand Down
2 changes: 1 addition & 1 deletion Localization/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ L['Show Model'] = '显示模型'
L['Last update:'] = '最后更新:'
L['Inspect target'] = '观察目标'
L['Inspect mouseover'] = '观察鼠标悬停目标'

L['Data source:'] = '数据来源:'
-- @locale-fill@

-- @end-import@
38 changes: 22 additions & 16 deletions Tooltip/FixItemSet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ function ns.FixItemSets(tip, id)
return
end

local equippedCount, itemNames, overrideNames = ns.Inspect:GetEquippedSetItems(setId)
local equippedCount, equippedSetItems = ns.Inspect:GetEquippedSetItems(setId)
local setNameLinePattern = '^(' .. setName .. '.+)(%d+)/(%d+)(.+)$'

local setLine
local firstBonusLine
local inSetLine = true
local bonus = ns.ItemSets[setId].bouns
local slots = ns.ItemSets[setId].slots
local setLineFinished = false

for i = 2, tip:NumLines() do
local textLeft = tip:GetFontStringLeft(i)
Expand All @@ -47,26 +48,31 @@ function ns.FixItemSets(tip, id)
setLine = i
textLeft:SetText(prefix .. equippedCount .. '/' .. maxCount .. suffix)
end
elseif inSetLine then
elseif setLine and not setLineFinished then
local line = text:trim()
local setSlotIndex = i - setLine
local slotItem = slots[setSlotIndex]

if line == '' then
inSetLine = false
if not slotItem or line == '' then
setLineFinished = true
else
local n = itemNames[line]
if n and n > 0 then
local overrideName = overrideNames[line]
if overrideName and line ~= overrideName then
textLeft:SetText(text:sub(1, #text - #line) .. overrideName)
end
local item = equippedSetItems[slotItem.slot]
local hasItem = item
if not item then
item = slotItem.itemId
end

textLeft:SetTextColor(1, 1, 0.6)
itemNames[line] = n > 1 and n - 1 or nil
else
textLeft:SetTextColor(0.5, 0.5, 0.5)
local name = GetItemInfo(item)
if name then
textLeft:SetText(' ' .. name)
if hasItem then
textLeft:SetTextColor(1, 1, 0.6)
else
textLeft:SetTextColor(0.5, 0.5, 0.5)
end
end
end
else
elseif setLineFinished then
local summary, count = MatchBonus(text)
if summary then
if not firstBonusLine then
Expand Down
9 changes: 5 additions & 4 deletions UI/GearFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ function GearFrame:Constructor()
Title:SetPoint('TOPLEFT', 66, -18)
self.Title = Title

local Level = self:CreateFontString(nil, 'ARTWORK', 'ChatFontNormal')
Level:SetPoint('TOPLEFT', 66, -42)
Level:SetFont(Level:GetFont(), 12, 'THINOUTLINE')
self.Level = Level
local ItemLevel = self:CreateFontString(nil, 'ARTWORK', 'ChatFontNormal')
ItemLevel:SetPoint('TOPLEFT', 66, -42)
ItemLevel:SetFont(ItemLevel:GetFont(), 12, 'THINOUTLINE')
ItemLevel:SetTextColor(NORMAL_FONT_COLOR:GetRGB())
self.ItemLevel = ItemLevel

self.gears = {}
self.columnWidths = {}
Expand Down
7 changes: 2 additions & 5 deletions UI/GearItem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ end
function GearItem:SetItem(item, inspect)
self.inspect = inspect
self.item = item
self:Hide()
self:Update()
self:Show()
end

function GearItem:OnEnter()
Expand Down Expand Up @@ -102,14 +104,11 @@ function GearItem:Update()
return
end

self:Hide()

local socketWidth = SPACING

local name, link, quality, itemLevel = GetItemInfo(self.item)
if name then
local enchant = ns.GetItemEnchantInfo(self.item)
print(link, enchant)
if enchant then
local tex = ns.UI.EnchantItem:Alloc(self)
if enchant.itemId then
Expand Down Expand Up @@ -157,6 +156,4 @@ function GearItem:Update()
self.parent:ApplyColumnWidth('Name', nameWidth + socketWidth)

self:SetPoint('RIGHT', self.parent.LevelColumn, 'RIGHT', nameWidth + 5, 0)

self:Show()
end
17 changes: 16 additions & 1 deletion UI/InspectGearFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
---@type ns
local ns = select(2, ...)

local L = ns.L
local Inspect = ns.Inspect

---@class UI.InspectGearFrame : UI.GearFrame
Expand All @@ -14,6 +15,13 @@ local InspectGearFrame = ns.Addon:NewClass('UI.InspectGearFrame', ns.UI.GearFram
function InspectGearFrame:Constructor()
self:SetScript('OnShow', self.OnShow)
self:SetScript('OnHide', self.UnregisterAllMessages)

-- @debug@
local DataSource = self:CreateFontString(nil, 'ARTWORK', 'GameFontNormalSmall')
DataSource:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', 10, 0)
DataSource:SetFont(DataSource:GetFont(), 12, 'OUTLINE')
self.DataSource = DataSource
-- @end-debug@
end

function InspectGearFrame:OnShow()
Expand All @@ -31,11 +39,18 @@ function InspectGearFrame:Update()
local classFileName = Inspect:GetUnitClassFileName()
local classColor = RAID_CLASS_COLORS[classFileName]

self.Level:SetText(Inspect:GetUnitLevel())
self.ItemLevel:SetFormattedText('%s %.1f', L['iLvl:'], Inspect:GetItemLevel() or 0)
self.Title:SetTextColor(classColor.r, classColor.g, classColor.b)
self.Title:SetText(Ambiguate(Inspect:GetUnitName(), 'none'))

self:SetBackdropBorderColor(classColor.r, classColor.g, classColor.b)

-- @debug@
local dataSource = Inspect:GetDataSource()
local lastUpdate = Inspect:GetLastUpdate()
self.DataSource:SetFormattedText('%s|cffffffff%s|r %s|cffffffff%s|r', L['Data source:'], dataSource,
L['Last update:'], FriendsFrame_GetLastOnline(lastUpdate))
-- @end-debug@

self:EndLayout()
end
6 changes: 3 additions & 3 deletions UI/ModelFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ local UnitFactionGroup = UnitFactionGroup
local Inspect = ns.Inspect

local factionLogoTextures = {
['Alliance'] = 'Interface\\Timer\\Alliance-Logo',
['Horde'] = 'Interface\\Timer\\Horde-Logo',
['Neutral'] = 'Interface\\Timer\\Panda-Logo',
Alliance = [[Interface\Timer\Alliance-Logo]],
Horde = [[Interface\Timer\Horde-Logo]],
Neutral = [[Interface\Timer\Panda-Logo]],
}

---@class UI.ModelFrame: Object, Frame, AceEvent-3.0
Expand Down
4 changes: 2 additions & 2 deletions UI/TalentFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ function TalentFrame:Update()
local isUnlocked = true
local name, background, pointsSpent = self.talent:GetTabInfo(self.tabIndex)
if name then
base = 'Interface\\TalentFrame\\' .. background .. '-'
base = [[Interface\TalentFrame\]] .. background .. '-'
else
-- temporary default for classes without talents poor guys
base = 'Interface\\TalentFrame\\MageFire-'
base = [[Interface\TalentFrame\MageFire-]]
end

self.TopLeft:SetTexture(base .. 'TopLeft')
Expand Down

0 comments on commit fb9ff99

Please sign in to comment.