Compare commits
2 Commits
87059f128d
...
5ff421bd09
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ff421bd09 | |||
| 0e7a0c909a |
@@ -16,6 +16,50 @@ local DEFAULT_AMIBIS_CHAR_DB = {
|
|||||||
overrideSpec = nil,
|
overrideSpec = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local TOP_UPGRADES_COUNT = 3
|
||||||
|
|
||||||
|
local UPGRADE_STAT_KEYS = {
|
||||||
|
["PRIEST"] = {
|
||||||
|
["Discipline"] = { "healing", "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Shadow"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
},
|
||||||
|
["DRUID"] = {
|
||||||
|
["Balance"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
},
|
||||||
|
["PALADIN"] = {
|
||||||
|
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
},
|
||||||
|
["SHAMAN"] = {
|
||||||
|
["Elemental"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
},
|
||||||
|
["MAGE"] = {
|
||||||
|
["Arcane"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Fire"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Frost"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
},
|
||||||
|
["WARLOCK"] = {
|
||||||
|
["Affliction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Demonology"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
["Destruction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local DEFAULT_UPGRADE_STAT_KEYS = { "spellPower", "intellect", "spirit", "mp5", "haste", "crit" }
|
||||||
|
|
||||||
|
local function GetUpgradeStatKeys(class, spec)
|
||||||
|
if class and UPGRADE_STAT_KEYS[class] and UPGRADE_STAT_KEYS[class][spec] then
|
||||||
|
return UPGRADE_STAT_KEYS[class][spec]
|
||||||
|
end
|
||||||
|
return DEFAULT_UPGRADE_STAT_KEYS
|
||||||
|
end
|
||||||
|
|
||||||
|
function Amibis:GetStatKeysForSpec(class, spec)
|
||||||
|
return GetUpgradeStatKeys(class, spec)
|
||||||
|
end
|
||||||
|
|
||||||
local function InitializeDB()
|
local function InitializeDB()
|
||||||
if not AmibisDB then
|
if not AmibisDB then
|
||||||
AmibisDB = CopyTable(DEFAULT_AMIBIS_DB)
|
AmibisDB = CopyTable(DEFAULT_AMIBIS_DB)
|
||||||
@@ -139,6 +183,11 @@ local STAT_MAP = {
|
|||||||
["ITEM_MOD_HEALING_SHORT"] = "healing",
|
["ITEM_MOD_HEALING_SHORT"] = "healing",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local MAX_AGGREGATE_STATS = {
|
||||||
|
healing = true,
|
||||||
|
spellDamage = true,
|
||||||
|
}
|
||||||
|
|
||||||
function Amibis:ScanItemStats(itemID)
|
function Amibis:ScanItemStats(itemID)
|
||||||
if not itemID then return nil end
|
if not itemID then return nil end
|
||||||
|
|
||||||
@@ -152,8 +201,16 @@ function Amibis:ScanItemStats(itemID)
|
|||||||
|
|
||||||
local result = {}
|
local result = {}
|
||||||
for wowKey, ourKey in pairs(STAT_MAP) do
|
for wowKey, ourKey in pairs(STAT_MAP) do
|
||||||
if stats[wowKey] then
|
local value = stats[wowKey]
|
||||||
result[ourKey] = (result[ourKey] or 0) + stats[wowKey]
|
if value then
|
||||||
|
if MAX_AGGREGATE_STATS[ourKey] then
|
||||||
|
local current = result[ourKey]
|
||||||
|
if not current or value > current then
|
||||||
|
result[ourKey] = value
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result[ourKey] = (result[ourKey] or 0) + value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -202,7 +259,7 @@ function Amibis:CompareGear()
|
|||||||
slots = {},
|
slots = {},
|
||||||
bisCount = 0,
|
bisCount = 0,
|
||||||
totalSlots = 0,
|
totalSlots = 0,
|
||||||
biggestUpgrade = nil,
|
topUpgrades = {},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -210,7 +267,7 @@ function Amibis:CompareGear()
|
|||||||
local slots = {}
|
local slots = {}
|
||||||
local bisCount = 0
|
local bisCount = 0
|
||||||
local totalSlots = 0
|
local totalSlots = 0
|
||||||
local biggestUpgrade = nil
|
local allUpgrades = {}
|
||||||
|
|
||||||
for slotName, bisItem in pairs(bisList) do
|
for slotName, bisItem in pairs(bisList) do
|
||||||
totalSlots = totalSlots + 1
|
totalSlots = totalSlots + 1
|
||||||
@@ -222,47 +279,48 @@ function Amibis:CompareGear()
|
|||||||
bisCount = bisCount + 1
|
bisCount = bisCount + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local itemLevelDiff = nil
|
|
||||||
if equippedItem and not isBIS then
|
|
||||||
local equippedILvl = GetItemInfo(equippedItem.itemID) and select(4, GetItemInfo(equippedItem.itemID))
|
|
||||||
local bisILvl = GetItemInfo(bisItem.itemID) and select(4, GetItemInfo(bisItem.itemID))
|
|
||||||
if equippedILvl and bisILvl then
|
|
||||||
itemLevelDiff = bisILvl - equippedILvl
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not isBIS and equippedItem then
|
|
||||||
if not biggestUpgrade or (itemLevelDiff and biggestUpgrade.itemLevelDiff and itemLevelDiff > biggestUpgrade.itemLevelDiff) then
|
|
||||||
biggestUpgrade = {
|
|
||||||
slot = slotName,
|
|
||||||
equipped = equippedItem,
|
|
||||||
bis = bisItem,
|
|
||||||
itemLevelDiff = itemLevelDiff,
|
|
||||||
}
|
|
||||||
elseif not biggestUpgrade then
|
|
||||||
biggestUpgrade = {
|
|
||||||
slot = slotName,
|
|
||||||
equipped = equippedItem,
|
|
||||||
bis = bisItem,
|
|
||||||
itemLevelDiff = itemLevelDiff,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
elseif not isBIS and not biggestUpgrade then
|
|
||||||
biggestUpgrade = {
|
|
||||||
slot = slotName,
|
|
||||||
equipped = nil,
|
|
||||||
bis = bisItem,
|
|
||||||
itemLevelDiff = nil,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(slots, {
|
table.insert(slots, {
|
||||||
slotName = slotName,
|
slotName = slotName,
|
||||||
equipped = equippedItem,
|
equipped = equippedItem,
|
||||||
bis = bisItem,
|
bis = bisItem,
|
||||||
isBIS = isBIS,
|
isBIS = isBIS,
|
||||||
itemLevelDiff = itemLevelDiff,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if not isBIS then
|
||||||
|
local statDiffs = {}
|
||||||
|
local score = 0
|
||||||
|
local equippedStats = (equippedItem and self:ScanItemStats(equippedItem.itemID)) or {}
|
||||||
|
local bisStats = self:ScanItemStats(bisItem.itemID) or {}
|
||||||
|
local upgradeStatKeys = GetUpgradeStatKeys(class, spec)
|
||||||
|
|
||||||
|
for _, statKey in ipairs(upgradeStatKeys) do
|
||||||
|
local diff = (bisStats[statKey] or 0) - (equippedStats[statKey] or 0)
|
||||||
|
if diff > 0 then
|
||||||
|
statDiffs[statKey] = diff
|
||||||
|
score = score + diff
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(allUpgrades, {
|
||||||
|
slot = slotName,
|
||||||
|
equipped = equippedItem,
|
||||||
|
bis = bisItem,
|
||||||
|
statDiffs = statDiffs,
|
||||||
|
score = score,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(allUpgrades, function(a, b)
|
||||||
|
if a.score ~= b.score then
|
||||||
|
return a.score > b.score
|
||||||
|
end
|
||||||
|
return a.slot < b.slot
|
||||||
|
end)
|
||||||
|
|
||||||
|
local topUpgrades = {}
|
||||||
|
for i = 1, math.min(TOP_UPGRADES_COUNT, #allUpgrades) do
|
||||||
|
table.insert(topUpgrades, allUpgrades[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
table.sort(slots, function(a, b)
|
table.sort(slots, function(a, b)
|
||||||
@@ -307,7 +365,7 @@ function Amibis:CompareGear()
|
|||||||
slots = slots,
|
slots = slots,
|
||||||
bisCount = bisCount,
|
bisCount = bisCount,
|
||||||
totalSlots = totalSlots,
|
totalSlots = totalSlots,
|
||||||
biggestUpgrade = biggestUpgrade,
|
topUpgrades = topUpgrades,
|
||||||
equippedStats = equippedStats,
|
equippedStats = equippedStats,
|
||||||
bisStats = bisStats,
|
bisStats = bisStats,
|
||||||
statsComplete = statsComplete,
|
statsComplete = statsComplete,
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ local COLOR_EMPTY = { 0.6, 0.6, 0.6 }
|
|||||||
local MainFrame = nil
|
local MainFrame = nil
|
||||||
local TitleText = nil
|
local TitleText = nil
|
||||||
local SummaryText = nil
|
local SummaryText = nil
|
||||||
local UpgradeText = nil
|
|
||||||
local ScrollFrame = nil
|
local ScrollFrame = nil
|
||||||
local SlotRows = {}
|
local SlotRows = {}
|
||||||
local MAX_VISIBLE_ROWS = 17
|
local MAX_VISIBLE_ROWS = 17
|
||||||
@@ -26,7 +25,7 @@ local ROW_SPACING = 24
|
|||||||
|
|
||||||
local function CreateMainFrame()
|
local function CreateMainFrame()
|
||||||
local frame = CreateFrame("Frame", "AmibisMainFrame", UIParent, "BackdropTemplate")
|
local frame = CreateFrame("Frame", "AmibisMainFrame", UIParent, "BackdropTemplate")
|
||||||
frame:SetSize(480, 680)
|
frame:SetSize(640, 680)
|
||||||
frame:SetFrameStrata("MEDIUM")
|
frame:SetFrameStrata("MEDIUM")
|
||||||
frame:SetFrameLevel(10)
|
frame:SetFrameLevel(10)
|
||||||
|
|
||||||
@@ -113,13 +112,7 @@ local function CreateSummaryBar(parent, anchor)
|
|||||||
summaryText:SetPoint("LEFT", bar, "LEFT", 8, 0)
|
summaryText:SetPoint("LEFT", bar, "LEFT", 8, 0)
|
||||||
summaryText:SetTextColor(0.8, 0.8, 0.8, 1)
|
summaryText:SetTextColor(0.8, 0.8, 0.8, 1)
|
||||||
|
|
||||||
local upgradeText = bar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
return bar, summaryText
|
||||||
upgradeText:SetPoint("BOTTOMLEFT", bar, "TOPLEFT", 8, 2)
|
|
||||||
upgradeText:SetPoint("BOTTOMRIGHT", bar, "TOPRIGHT", -8, 2)
|
|
||||||
upgradeText:SetJustifyH("LEFT")
|
|
||||||
upgradeText:SetTextColor(COLOR_UPGRADE[1], COLOR_UPGRADE[2], COLOR_UPGRADE[3], 1)
|
|
||||||
|
|
||||||
return bar, summaryText, upgradeText
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CreateColumnHeaders(parent, anchor)
|
local function CreateColumnHeaders(parent, anchor)
|
||||||
@@ -165,8 +158,8 @@ local function CreateColumnHeaders(parent, anchor)
|
|||||||
enchantHeader:SetTextColor(0.7, 0.7, 0.7, 1)
|
enchantHeader:SetTextColor(0.7, 0.7, 0.7, 1)
|
||||||
|
|
||||||
local sourceHeader = header:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local sourceHeader = header:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
|
sourceHeader:SetPoint("LEFT", enchantHeader, "RIGHT", 5, 0)
|
||||||
sourceHeader:SetPoint("RIGHT", header, "RIGHT", -8, 0)
|
sourceHeader:SetPoint("RIGHT", header, "RIGHT", -8, 0)
|
||||||
sourceHeader:SetWidth(70)
|
|
||||||
sourceHeader:SetJustifyH("RIGHT")
|
sourceHeader:SetJustifyH("RIGHT")
|
||||||
sourceHeader:SetText("Source")
|
sourceHeader:SetText("Source")
|
||||||
sourceHeader:SetTextColor(0.7, 0.7, 0.7, 1)
|
sourceHeader:SetTextColor(0.7, 0.7, 0.7, 1)
|
||||||
@@ -209,15 +202,14 @@ local function CreateSlotRows(parent, anchor)
|
|||||||
row.enchantText:SetJustifyH("LEFT")
|
row.enchantText:SetJustifyH("LEFT")
|
||||||
|
|
||||||
row.sourceText = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
row.sourceText = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
|
row.sourceText:SetPoint("LEFT", row.enchantText, "RIGHT", 5, 0)
|
||||||
row.sourceText:SetPoint("RIGHT", row, "RIGHT", -8, 0)
|
row.sourceText:SetPoint("RIGHT", row, "RIGHT", -8, 0)
|
||||||
row.sourceText:SetWidth(70)
|
|
||||||
row.sourceText:SetJustifyH("RIGHT")
|
row.sourceText:SetJustifyH("RIGHT")
|
||||||
row.sourceText:SetWordWrap(true)
|
|
||||||
|
|
||||||
row:SetScript("OnEnter", function(self)
|
row:SetScript("OnEnter", function(self)
|
||||||
if self.bisLink then
|
if self.bisLink then
|
||||||
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
||||||
GameTooltip:SetHyperlink(self.bisLink)
|
pcall(GameTooltip.SetHyperlink, GameTooltip, self.bisLink)
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -245,22 +237,72 @@ local StatsPanel = nil
|
|||||||
local StatsPanelTitle = nil
|
local StatsPanelTitle = nil
|
||||||
local StatLabels = {}
|
local StatLabels = {}
|
||||||
local StatValues = {}
|
local StatValues = {}
|
||||||
|
local UpgradeLabels = {}
|
||||||
|
|
||||||
local STAT_DISPLAY = {
|
local STAT_LABELS = {
|
||||||
{ key = "healing", label = "+Healing" },
|
healing = "+Healing",
|
||||||
{ key = "spellPower", label = "+Spell Power" },
|
spellDamage = "+Spell Damage",
|
||||||
{ key = "intellect", label = "Intellect" },
|
spellPower = "+Spell Power",
|
||||||
{ key = "spirit", label = "Spirit" },
|
intellect = "Intellect",
|
||||||
{ key = "mp5", label = "MP5" },
|
spirit = "Spirit",
|
||||||
{ key = "haste", label = "Haste" },
|
mp5 = "MP5",
|
||||||
{ key = "crit", label = "Crit" },
|
haste = "Haste",
|
||||||
|
crit = "Crit",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local STAT_DISPLAY_NAME = {
|
||||||
|
healing = "healing",
|
||||||
|
spellDamage = "spell damage",
|
||||||
|
spellPower = "spell power",
|
||||||
|
intellect = "intellect",
|
||||||
|
spirit = "spirit",
|
||||||
|
mp5 = "mp5",
|
||||||
|
haste = "haste",
|
||||||
|
crit = "crit",
|
||||||
|
}
|
||||||
|
|
||||||
|
local STATS_COL_W = 60
|
||||||
|
local STATS_LABEL_W = 80
|
||||||
|
local STATS_CURRENT_X = STATS_LABEL_W + 16
|
||||||
|
local STATS_BIS_X = STATS_CURRENT_X + STATS_COL_W
|
||||||
|
local STATS_DIFF_X = STATS_BIS_X + STATS_COL_W
|
||||||
|
local currentStatKeys = {}
|
||||||
|
|
||||||
|
local function GetStatDisplayName(key)
|
||||||
|
return STAT_DISPLAY_NAME[key] or key
|
||||||
|
end
|
||||||
|
|
||||||
|
local function FormatUpgradeEntry(idx, upgrade)
|
||||||
|
local text = string.format("%d. %s: ", idx, upgrade.slot)
|
||||||
|
|
||||||
|
if not upgrade.equipped then
|
||||||
|
return text .. "|cff888888(empty slot)|r"
|
||||||
|
end
|
||||||
|
|
||||||
|
if not next(upgrade.statDiffs) then
|
||||||
|
return text .. "|cff888888(no stat gain)|r"
|
||||||
|
end
|
||||||
|
|
||||||
|
local sorted = {}
|
||||||
|
for statKey, diff in pairs(upgrade.statDiffs) do
|
||||||
|
table.insert(sorted, { key = statKey, diff = diff })
|
||||||
|
end
|
||||||
|
table.sort(sorted, function(a, b) return a.diff > b.diff end)
|
||||||
|
|
||||||
|
local parts = {}
|
||||||
|
local maxShow = math.min(2, #sorted)
|
||||||
|
for i = 1, maxShow do
|
||||||
|
table.insert(parts, string.format("+%d %s", sorted[i].diff, GetStatDisplayName(sorted[i].key)))
|
||||||
|
end
|
||||||
|
|
||||||
|
return text .. table.concat(parts, ", ")
|
||||||
|
end
|
||||||
|
|
||||||
local function CreateStatsPanel(parent, anchor)
|
local function CreateStatsPanel(parent, anchor)
|
||||||
local panel = CreateFrame("Frame", nil, parent, "BackdropTemplate")
|
local panel = CreateFrame("Frame", nil, parent, "BackdropTemplate")
|
||||||
panel:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -8)
|
panel:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -8)
|
||||||
panel:SetPoint("TOPRIGHT", anchor, "BOTTOMRIGHT", 0, -8)
|
panel:SetPoint("TOPRIGHT", anchor, "BOTTOMRIGHT", 0, -8)
|
||||||
panel:SetHeight(#STAT_DISPLAY * 16 + 24)
|
panel:SetHeight(24)
|
||||||
|
|
||||||
panel:SetBackdrop({
|
panel:SetBackdrop({
|
||||||
bgFile = "Interface\\Buttons\\WHITE8x8",
|
bgFile = "Interface\\Buttons\\WHITE8x8",
|
||||||
@@ -277,70 +319,109 @@ local function CreateStatsPanel(parent, anchor)
|
|||||||
title:SetTextColor(1, 0.82, 0, 1)
|
title:SetTextColor(1, 0.82, 0, 1)
|
||||||
StatsPanelTitle = title
|
StatsPanelTitle = title
|
||||||
|
|
||||||
local colW = 60
|
|
||||||
local labelW = 80
|
|
||||||
local currentX = labelW + 16
|
|
||||||
local bisX = currentX + colW
|
|
||||||
local diffX = bisX + colW
|
|
||||||
|
|
||||||
local currentLabel = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local currentLabel = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
currentLabel:SetPoint("TOPLEFT", panel, "TOPLEFT", currentX, -4)
|
currentLabel:SetPoint("TOPLEFT", panel, "TOPLEFT", STATS_CURRENT_X, -4)
|
||||||
currentLabel:SetWidth(colW)
|
currentLabel:SetWidth(STATS_COL_W)
|
||||||
currentLabel:SetJustifyH("CENTER")
|
currentLabel:SetJustifyH("CENTER")
|
||||||
currentLabel:SetText("Current")
|
currentLabel:SetText("Current")
|
||||||
currentLabel:SetTextColor(0.7, 0.7, 0.7, 1)
|
currentLabel:SetTextColor(0.7, 0.7, 0.7, 1)
|
||||||
|
|
||||||
local bisLabel = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local bisLabel = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
bisLabel:SetPoint("TOPLEFT", panel, "TOPLEFT", bisX, -4)
|
bisLabel:SetPoint("TOPLEFT", panel, "TOPLEFT", STATS_BIS_X, -4)
|
||||||
bisLabel:SetWidth(colW)
|
bisLabel:SetWidth(STATS_COL_W)
|
||||||
bisLabel:SetJustifyH("CENTER")
|
bisLabel:SetJustifyH("CENTER")
|
||||||
bisLabel:SetText("BIS")
|
bisLabel:SetText("BIS")
|
||||||
bisLabel:SetTextColor(0.7, 0.7, 0.7, 1)
|
bisLabel:SetTextColor(0.7, 0.7, 0.7, 1)
|
||||||
|
|
||||||
local diffLabel = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local diffLabel = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
diffLabel:SetPoint("TOPLEFT", panel, "TOPLEFT", diffX, -4)
|
diffLabel:SetPoint("TOPLEFT", panel, "TOPLEFT", STATS_DIFF_X, -4)
|
||||||
diffLabel:SetWidth(colW)
|
diffLabel:SetWidth(STATS_COL_W)
|
||||||
diffLabel:SetJustifyH("CENTER")
|
diffLabel:SetJustifyH("CENTER")
|
||||||
diffLabel:SetText("Diff")
|
diffLabel:SetText("Diff")
|
||||||
diffLabel:SetTextColor(0.7, 0.7, 0.7, 1)
|
diffLabel:SetTextColor(0.7, 0.7, 0.7, 1)
|
||||||
|
|
||||||
for i, stat in ipairs(STAT_DISPLAY) do
|
local separator = panel:CreateTexture(nil, "ARTWORK")
|
||||||
local y = -(i - 1) * 16 - 22
|
separator:SetTexture("Interface\\Buttons\\WHITE8x8")
|
||||||
|
separator:SetVertexColor(0.2, 0.2, 0.2, 1)
|
||||||
|
separator:SetPoint("TOPLEFT", panel, "TOPLEFT", 290, 4)
|
||||||
|
separator:SetPoint("BOTTOMLEFT", panel, "BOTTOMLEFT", 290, -4)
|
||||||
|
separator:SetWidth(1)
|
||||||
|
|
||||||
|
local upgradesTitle = panel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||||
|
upgradesTitle:SetPoint("TOPLEFT", panel, "TOPLEFT", 300, -4)
|
||||||
|
upgradesTitle:SetText("Top Upgrades")
|
||||||
|
upgradesTitle:SetTextColor(1, 0.82, 0, 1)
|
||||||
|
|
||||||
|
for i = 1, 3 do
|
||||||
|
local y = -22 - (i - 1) * 16
|
||||||
|
local label = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
|
label:SetPoint("TOPLEFT", panel, "TOPLEFT", 300, y)
|
||||||
|
label:SetWidth(320)
|
||||||
|
label:SetJustifyH("LEFT")
|
||||||
|
label:SetText("")
|
||||||
|
label:SetTextColor(COLOR_UPGRADE[1], COLOR_UPGRADE[2], COLOR_UPGRADE[3], 1)
|
||||||
|
UpgradeLabels[i] = label
|
||||||
|
end
|
||||||
|
|
||||||
|
StatsPanel = panel
|
||||||
|
return panel
|
||||||
|
end
|
||||||
|
|
||||||
|
local function RebuildStatRows(panel, statKeys)
|
||||||
|
for _, vals in pairs(StatValues) do
|
||||||
|
vals.label:Hide()
|
||||||
|
vals.current:Hide()
|
||||||
|
vals.bis:Hide()
|
||||||
|
vals.diff:Hide()
|
||||||
|
end
|
||||||
|
StatLabels = {}
|
||||||
|
StatValues = {}
|
||||||
|
|
||||||
|
for i, statKey in ipairs(statKeys) do
|
||||||
|
local y = -22 - (i - 1) * 16
|
||||||
|
local labelText = STAT_LABELS[statKey] or statKey
|
||||||
|
|
||||||
local label = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local label = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
label:SetPoint("TOPLEFT", panel, "TOPLEFT", 8, y)
|
label:SetPoint("TOPLEFT", panel, "TOPLEFT", 8, y)
|
||||||
label:SetWidth(labelW)
|
label:SetWidth(STATS_LABEL_W)
|
||||||
label:SetJustifyH("RIGHT")
|
label:SetJustifyH("RIGHT")
|
||||||
label:SetText(stat.label)
|
label:SetText(labelText)
|
||||||
label:SetTextColor(0.6, 0.6, 0.6, 1)
|
label:SetTextColor(0.6, 0.6, 0.6, 1)
|
||||||
|
|
||||||
local current = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local current = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
current:SetPoint("TOPLEFT", panel, "TOPLEFT", currentX, y)
|
current:SetPoint("TOPLEFT", panel, "TOPLEFT", STATS_CURRENT_X, y)
|
||||||
current:SetWidth(colW)
|
current:SetWidth(STATS_COL_W)
|
||||||
current:SetJustifyH("CENTER")
|
current:SetJustifyH("CENTER")
|
||||||
current:SetText("0")
|
current:SetText("0")
|
||||||
current:SetTextColor(1, 0.5, 0.5, 1)
|
current:SetTextColor(1, 0.5, 0.5, 1)
|
||||||
|
|
||||||
local bis = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local bis = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
bis:SetPoint("TOPLEFT", panel, "TOPLEFT", bisX, y)
|
bis:SetPoint("TOPLEFT", panel, "TOPLEFT", STATS_BIS_X, y)
|
||||||
bis:SetWidth(colW)
|
bis:SetWidth(STATS_COL_W)
|
||||||
bis:SetJustifyH("CENTER")
|
bis:SetJustifyH("CENTER")
|
||||||
bis:SetText("0")
|
bis:SetText("0")
|
||||||
bis:SetTextColor(0, 1, 0, 1)
|
bis:SetTextColor(0, 1, 0, 1)
|
||||||
|
|
||||||
local diff = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local diff = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
diff:SetPoint("TOPLEFT", panel, "TOPLEFT", diffX, y)
|
diff:SetPoint("TOPLEFT", panel, "TOPLEFT", STATS_DIFF_X, y)
|
||||||
diff:SetWidth(colW)
|
diff:SetWidth(STATS_COL_W)
|
||||||
diff:SetJustifyH("CENTER")
|
diff:SetJustifyH("CENTER")
|
||||||
diff:SetText("0")
|
diff:SetText("0")
|
||||||
diff:SetTextColor(1, 1, 1, 1)
|
diff:SetTextColor(1, 1, 1, 1)
|
||||||
|
|
||||||
StatLabels[stat.key] = label
|
StatLabels[statKey] = label
|
||||||
StatValues[stat.key] = { current = current, bis = bis, diff = diff }
|
StatValues[statKey] = { current = current, bis = bis, diff = diff }
|
||||||
end
|
end
|
||||||
|
|
||||||
StatsPanel = panel
|
panel:SetHeight(#statKeys * 16 + 24)
|
||||||
return panel
|
end
|
||||||
|
|
||||||
|
local function StatKeysEqual(a, b)
|
||||||
|
if #a ~= #b then return false end
|
||||||
|
for i, key in ipairs(a) do
|
||||||
|
if b[i] ~= key then return false end
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function InitializeUI()
|
local function InitializeUI()
|
||||||
@@ -350,9 +431,8 @@ local function InitializeUI()
|
|||||||
local titleBar, title = CreateTitleBar(MainFrame)
|
local titleBar, title = CreateTitleBar(MainFrame)
|
||||||
TitleText = title
|
TitleText = title
|
||||||
|
|
||||||
local summaryBar, summary, upgrade = CreateSummaryBar(MainFrame, titleBar)
|
local summaryBar, summary = CreateSummaryBar(MainFrame, titleBar)
|
||||||
SummaryText = summary
|
SummaryText = summary
|
||||||
UpgradeText = upgrade
|
|
||||||
|
|
||||||
local header = CreateColumnHeaders(MainFrame, summaryBar)
|
local header = CreateColumnHeaders(MainFrame, summaryBar)
|
||||||
local slotContainer = CreateSlotRows(MainFrame, header)
|
local slotContainer = CreateSlotRows(MainFrame, header)
|
||||||
@@ -398,7 +478,11 @@ function ns.UI.RefreshUI()
|
|||||||
|
|
||||||
if not data.hasBISList then
|
if not data.hasBISList then
|
||||||
SummaryText:SetText(string.format("|cffff6666No BIS list available for %s %s in %s|r", data.class, data.spec or "Unknown", data.phase))
|
SummaryText:SetText(string.format("|cffff6666No BIS list available for %s %s in %s|r", data.class, data.spec or "Unknown", data.phase))
|
||||||
UpgradeText:SetText("")
|
for i = 1, 3 do
|
||||||
|
if UpgradeLabels[i] then
|
||||||
|
UpgradeLabels[i]:SetText("")
|
||||||
|
end
|
||||||
|
end
|
||||||
for i = 1, MAX_VISIBLE_ROWS do
|
for i = 1, MAX_VISIBLE_ROWS do
|
||||||
SlotRows[i].slotText:SetText("")
|
SlotRows[i].slotText:SetText("")
|
||||||
SlotRows[i].equippedText:SetText("")
|
SlotRows[i].equippedText:SetText("")
|
||||||
@@ -412,17 +496,6 @@ function ns.UI.RefreshUI()
|
|||||||
|
|
||||||
SummaryText:SetText(string.format("BIS: %d/%d slots", data.bisCount, data.totalSlots))
|
SummaryText:SetText(string.format("BIS: %d/%d slots", data.bisCount, data.totalSlots))
|
||||||
|
|
||||||
if data.biggestUpgrade then
|
|
||||||
local bu = data.biggestUpgrade
|
|
||||||
if bu.equipped then
|
|
||||||
UpgradeText:SetText(string.format("Biggest upgrade: %s -> %s (%s)", bu.equipped.name, bu.bis.name, bu.bis.source))
|
|
||||||
else
|
|
||||||
UpgradeText:SetText(string.format("Empty slot: %s -> %s (%s)", bu.slot, bu.bis.name, bu.bis.source))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
UpgradeText:SetText("|cff00ff00All slots are BIS!|r")
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, MAX_VISIBLE_ROWS do
|
for i = 1, MAX_VISIBLE_ROWS do
|
||||||
local row = SlotRows[i]
|
local row = SlotRows[i]
|
||||||
local slotData = data.slots[i]
|
local slotData = data.slots[i]
|
||||||
@@ -492,14 +565,20 @@ function ns.UI.RefreshUI()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if data.equippedStats and data.bisStats then
|
if data.equippedStats and data.bisStats then
|
||||||
|
local statKeys = Amibis:GetStatKeysForSpec(data.class, data.spec)
|
||||||
|
if not StatKeysEqual(currentStatKeys, statKeys) then
|
||||||
|
RebuildStatRows(StatsPanel, statKeys)
|
||||||
|
currentStatKeys = statKeys
|
||||||
|
end
|
||||||
|
|
||||||
if not data.statsComplete then
|
if not data.statsComplete then
|
||||||
if StatsPanelTitle then
|
if StatsPanelTitle then
|
||||||
StatsPanelTitle:SetText("Stats Comparison |cff888888(loading...)|r")
|
StatsPanelTitle:SetText("Stats Comparison |cff888888(loading...)|r")
|
||||||
end
|
end
|
||||||
for _, stat in ipairs(STAT_DISPLAY) do
|
for _, statKey in ipairs(statKeys) do
|
||||||
local vals = StatValues[stat.key]
|
local vals = StatValues[statKey]
|
||||||
if vals then
|
if vals then
|
||||||
local current = data.equippedStats[stat.key] or 0
|
local current = data.equippedStats[statKey] or 0
|
||||||
vals.current:SetText(current)
|
vals.current:SetText(current)
|
||||||
vals.bis:SetText("|cff888888...|r")
|
vals.bis:SetText("|cff888888...|r")
|
||||||
vals.diff:SetText("")
|
vals.diff:SetText("")
|
||||||
@@ -525,11 +604,11 @@ function ns.UI.RefreshUI()
|
|||||||
if StatsPanelTitle then
|
if StatsPanelTitle then
|
||||||
StatsPanelTitle:SetText("Stats Comparison")
|
StatsPanelTitle:SetText("Stats Comparison")
|
||||||
end
|
end
|
||||||
for _, stat in ipairs(STAT_DISPLAY) do
|
for _, statKey in ipairs(statKeys) do
|
||||||
local vals = StatValues[stat.key]
|
local vals = StatValues[statKey]
|
||||||
if vals then
|
if vals then
|
||||||
local current = data.equippedStats[stat.key] or 0
|
local current = data.equippedStats[statKey] or 0
|
||||||
local bis = data.bisStats[stat.key] or 0
|
local bis = data.bisStats[statKey] or 0
|
||||||
local diff = bis - current
|
local diff = bis - current
|
||||||
|
|
||||||
vals.current:SetText(current)
|
vals.current:SetText(current)
|
||||||
@@ -548,6 +627,36 @@ function ns.UI.RefreshUI()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not data.statsComplete then
|
||||||
|
if UpgradeLabels[1] then
|
||||||
|
UpgradeLabels[1]:SetText("|cff888888Loading...|r")
|
||||||
|
end
|
||||||
|
for i = 2, 3 do
|
||||||
|
if UpgradeLabels[i] then
|
||||||
|
UpgradeLabels[i]:SetText("")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif data.topUpgrades and #data.topUpgrades > 0 then
|
||||||
|
for i = 1, 3 do
|
||||||
|
if UpgradeLabels[i] then
|
||||||
|
if data.topUpgrades[i] then
|
||||||
|
UpgradeLabels[i]:SetText(FormatUpgradeEntry(i, data.topUpgrades[i]))
|
||||||
|
else
|
||||||
|
UpgradeLabels[i]:SetText("")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if UpgradeLabels[1] then
|
||||||
|
UpgradeLabels[1]:SetText("|cff00ff00All slots are BIS!|r")
|
||||||
|
end
|
||||||
|
for i = 2, 3 do
|
||||||
|
if UpgradeLabels[i] then
|
||||||
|
UpgradeLabels[i]:SetText("")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user