diff --git a/Core/Inspect.lua b/Core/Inspect.lua index d86b295..8d07a39 100644 --- a/Core/Inspect.lua +++ b/Core/Inspect.lua @@ -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}, @@ -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() @@ -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 diff --git a/Data/DataLoader.lua b/Data/DataLoader.lua index 880433b..fff6565 100644 --- a/Data/DataLoader.lua +++ b/Data/DataLoader.lua @@ -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, { -- diff --git a/Localization/enUS.lua b/Localization/enUS.lua index 398e9ab..f5c5bbd 100644 --- a/Localization/enUS.lua +++ b/Localization/enUS.lua @@ -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@ diff --git a/Localization/zhCN.lua b/Localization/zhCN.lua index ad668be..4697c1e 100644 --- a/Localization/zhCN.lua +++ b/Localization/zhCN.lua @@ -8,7 +8,7 @@ L['Show Model'] = '显示模型' L['Last update:'] = '最后更新:' L['Inspect target'] = '观察目标' L['Inspect mouseover'] = '观察鼠标悬停目标' - +L['Data source:'] = '数据来源:' -- @locale-fill@ -- @end-import@ diff --git a/Tooltip/FixItemSet.lua b/Tooltip/FixItemSet.lua index 2f75bc7..9243328 100644 --- a/Tooltip/FixItemSet.lua +++ b/Tooltip/FixItemSet.lua @@ -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) @@ -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 diff --git a/UI/GearFrame.lua b/UI/GearFrame.lua index d7d01a5..71af5af 100644 --- a/UI/GearFrame.lua +++ b/UI/GearFrame.lua @@ -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 = {} diff --git a/UI/GearItem.lua b/UI/GearItem.lua index e19dab3..c31577e 100644 --- a/UI/GearItem.lua +++ b/UI/GearItem.lua @@ -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() @@ -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 @@ -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 diff --git a/UI/InspectGearFrame.lua b/UI/InspectGearFrame.lua index 8a3b389..494be50 100644 --- a/UI/InspectGearFrame.lua +++ b/UI/InspectGearFrame.lua @@ -6,6 +6,7 @@ ---@type ns local ns = select(2, ...) +local L = ns.L local Inspect = ns.Inspect ---@class UI.InspectGearFrame : UI.GearFrame @@ -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() @@ -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 diff --git a/UI/ModelFrame.lua b/UI/ModelFrame.lua index edcdca6..49bf854 100644 --- a/UI/ModelFrame.lua +++ b/UI/ModelFrame.lua @@ -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 diff --git a/UI/TalentFrame.lua b/UI/TalentFrame.lua index 584b15d..18178da 100644 --- a/UI/TalentFrame.lua +++ b/UI/TalentFrame.lua @@ -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')