Skip to content

Commit

Permalink
Merge pull request #13 from GovtGeek/ptr-3.4.2
Browse files Browse the repository at this point in the history
OutfitterMinimapButton radius now dynamically set based on expansion.…
  • Loading branch information
GovtGeek authored May 15, 2023
2 parents 39b8607 + 64deaab commit 4318854
Show file tree
Hide file tree
Showing 6 changed files with 8,773 additions and 8,709 deletions.
2 changes: 2 additions & 0 deletions Libraries/LibDropdown-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ local function InitializeFrame(frame)
if (frame:GetEffectiveScale() ~= GameTooltip:GetEffectiveScale()) then -- consider applied SetIgnoreParentScale() on GameTooltip regarding scaling of the frame
frame:SetScale(frame:GetScale() * GameTooltip:GetEffectiveScale() / frame:GetEffectiveScale())
end
--frame:SetBackdrop(BACKDROP_DARK_DIALOG_32_32) -- keep for nostalgia (the original thick gray border for a dialog)

end

local editBoxCount = 1
Expand Down
251 changes: 124 additions & 127 deletions Libraries/MC2ItemStatsLib/MC2ItemStatsLib.lua
Original file line number Diff line number Diff line change
@@ -1,127 +1,124 @@
----------------------------------------
-- ItemStatsLib
--
-- Provides functions for converting item references (links, locations) into structured info about the item
--
-- Requires: MC2AddonLib, MC2TooltipLib
----------------------------------------

local _, Addon = ...

local function stripColonFromBlizzardLabel(label)
if not label then
return "nil"
end

return label:gsub(":$", "")
end

----------------------------------------
Addon.ItemStatsLib = {
----------------------------------------
version = 1,
}

Addon.ItemStatsLib.strings = {}
Addon.ItemStatsLib.strings.Stamina = stripColonFromBlizzardLabel(STAMINA_COLON)
Addon.ItemStatsLib.strings.Strength = stripColonFromBlizzardLabel(STRENGTH_COLON)
Addon.ItemStatsLib.strings.Intellect = stripColonFromBlizzardLabel(INTELLECT_COLON)
Addon.ItemStatsLib.strings.Agility = stripColonFromBlizzardLabel(AGILITY_COLON)
Addon.ItemStatsLib.strings.Spirit = stripColonFromBlizzardLabel(SPIRIT_COLON)
Addon.ItemStatsLib.strings.Haste = STAT_HASTE
Addon.ItemStatsLib.strings.Versatility = "Versatility"
Addon.ItemStatsLib.strings.Mastery = STAT_MASTERY
Addon.ItemStatsLib.strings.CriticalStrike = "Critical Strike"
Addon.ItemStatsLib.strings.Power = ATTACK_POWER
Addon.ItemStatsLib.strings.Dodge = STAT_DODGE
Addon.ItemStatsLib.strings.ItemLevel = "Item Level"
Addon.ItemStatsLib.strings.Hit = ITEM_MOD_HIT_RATING_SHORT
Addon.ItemStatsLib.strings.SpellHit = ITEM_MOD_HIT_SPELL_RATING_SHORT

Addon.ItemStatsLib.strings.FrostResist = RESISTANCE4_NAME
Addon.ItemStatsLib.strings.NatureResist = RESISTANCE3_NAME --Miv
Addon.ItemStatsLib.strings.FireResist = RESISTANCE2_NAME
Addon.ItemStatsLib.strings.ShadowResist = RESISTANCE5_NAME --Miv
Addon.ItemStatsLib.strings.ArcaneResist = RESISTANCE6_NAME

Addon.ItemStatsLib.statNormalization = {}
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Stamina] = "STA"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Strength] = "STR"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Intellect] = "INT"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Agility] = "AGI"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Spirit] = "SPI"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Haste] = "HAS"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Versatility] = "VER"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Mastery] = "MAS"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.CriticalStrike] = "CRI"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.ItemLevel] = "ITEM_LEVEL"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.FireResist] = RESISTANCE2_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.NatureResist] = RESISTANCE3_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.FrostResist] = RESISTANCE4_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.ShadowResist] = RESISTANCE5_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.ArcaneResist] = RESISTANCE6_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Hit] = ITEM_MOD_HIT_RATING_SHORT
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.SpellHit] = ITEM_MOD_HIT_SPELL_RATING_SHORT


function Addon.ItemStatsLib:statsForBagItem(bag, slot)
local stats = Addon:new(self._Stats)
stats:setToBagItem(bag, slot)
return stats
end

function Addon.ItemStatsLib:statsForLink(link)
local stats = Addon:new(self._Stats)
stats:setToLink(link)
return stats
end

----------------------------------------
Addon.ItemStatsLib._Stats = {}
----------------------------------------

function Addon.ItemStatsLib._Stats:setToInventoryItem(inventorySlot)
local stats = Addon.TooltipLib:StatsForInventoryItem(inventorySlot)
self:setTooltipStats(stats)

local link = GetInventoryItemLink(inventorySlot)
self:setInfoFromLink(link)
end

function Addon.ItemStatsLib._Stats:setToBagItem(bag, slot)
local stats = Addon.TooltipLib:StatsForBagItem(bag, slot)
self:setTooltipStats(stats)

local link = GetContainerItemLink(bag, slot)
self:setInfoFromLink(link)
end

function Addon.ItemStatsLib._Stats:setToLink(link)
local stats = Addon.TooltipLib:StatsForLink(link)
--print(stats[0])
--print(stats[1])
--print(stats[2])
--print(stats[3])
self:setTooltipStats(stats)
self:setInfoFromLink(link)
end

function Addon.ItemStatsLib._Stats:setTooltipStats(tooltipStats)
self.values = {}
for key, value in pairs(Addon.ItemStatsLib.statNormalization) do
--print("Key: " .. key .. " Value: " .. value)
if tooltipStats[key] then
--print("Value: " .. value .. " " .. tooltipStats[key])
self.values[value] = tooltipStats[key]
end
end
end

function Addon.ItemStatsLib._Stats:setInfoFromLink(link)
local name, link, rarity, level, minLevel, type, subType, stackCount, equipLoc, texture, sellPrice = GetItemInfo(link)

self.itemLevel = tonumber(level)
self.minLevel = tonumber(minLevel)
end

-- /dump Outfitter.ItemStatsLib:statsForBagItem(0, 1)
----------------------------------------
-- ItemStatsLib
--
-- Provides functions for converting item references (links, locations) into structured info about the item
--
-- Requires: MC2AddonLib, MC2TooltipLib
----------------------------------------

local _, Addon = ...

local function stripColonFromBlizzardLabel(label)
if not label then
return "nil"
end

return label:gsub(":$", "")
end

----------------------------------------
Addon.ItemStatsLib = {
----------------------------------------
version = 1,
}

Addon.ItemStatsLib.strings = {}
Addon.ItemStatsLib.strings.Stamina = ITEM_MOD_STAMINA_SHORT
Addon.ItemStatsLib.strings.Strength = ITEM_MOD_STRENGTH_SHORT
Addon.ItemStatsLib.strings.Intellect = ITEM_MOD_INTELLECT_SHORT
Addon.ItemStatsLib.strings.Agility = ITEM_MOD_AGILITY_SHORT
Addon.ItemStatsLib.strings.Spirit = ITEM_MOD_SPIRIT_SHORT
Addon.ItemStatsLib.strings.Haste = STAT_HASTE
Addon.ItemStatsLib.strings.Versatility = STAT_VERSATILITY
Addon.ItemStatsLib.strings.Mastery = STAT_MASTERY
Addon.ItemStatsLib.strings.CriticalStrike = STAT_CRITICAL_STRIKE
Addon.ItemStatsLib.strings.Power = ATTACK_POWER
Addon.ItemStatsLib.strings.Dodge = STAT_DODGE
Addon.ItemStatsLib.strings.ItemLevel = "Item Level"
Addon.ItemStatsLib.strings.Hit = ITEM_MOD_HIT_RATING_SHORT
Addon.ItemStatsLib.strings.SpellHit = ITEM_MOD_HIT_SPELL_RATING_SHORT

Addon.ItemStatsLib.strings.FrostResist = RESISTANCE4_NAME
Addon.ItemStatsLib.strings.NatureResist = RESISTANCE3_NAME --Miv
Addon.ItemStatsLib.strings.FireResist = RESISTANCE2_NAME
Addon.ItemStatsLib.strings.ShadowResist = RESISTANCE5_NAME --Miv
Addon.ItemStatsLib.strings.ArcaneResist = RESISTANCE6_NAME

Addon.ItemStatsLib.statNormalization = {}
----[[
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Stamina] = ITEM_MOD_STAMINA_SHORT
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Strength] = ITEM_MOD_STRENGTH_SHORT
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Intellect] = ITEM_MOD_INTELLECT_SHORT
--Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Agility] = "AGI"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Agility] = ITEM_MOD_AGILITY_SHORT
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Spirit] = ITEM_MOD_SPIRIT_SHORT
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Haste] = STAT_HASTE
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Versatility] = STAT_VERSATILITY
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Mastery] = STAT_MASTERY
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.CriticalStrike] = STAT_CRITICAL_STRIKE
--]]
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.ItemLevel] = "ITEM_LEVEL"
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.FireResist] = RESISTANCE2_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.NatureResist] = RESISTANCE3_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.FrostResist] = RESISTANCE4_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.ShadowResist] = RESISTANCE5_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.ArcaneResist] = RESISTANCE6_NAME
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.Hit] = ITEM_MOD_HIT_RATING_SHORT
Addon.ItemStatsLib.statNormalization[Addon.ItemStatsLib.strings.SpellHit] = ITEM_MOD_HIT_SPELL_RATING_SHORT


function Addon.ItemStatsLib:statsForBagItem(bag, slot)
local stats = Addon:new(self._Stats)
stats:setToBagItem(bag, slot)
return stats
end

function Addon.ItemStatsLib:statsForLink(link)
local stats = Addon:new(self._Stats)
stats:setToLink(link)
return stats
end

----------------------------------------
Addon.ItemStatsLib._Stats = {}
----------------------------------------

function Addon.ItemStatsLib._Stats:setToInventoryItem(inventorySlot)
local stats = Addon.TooltipLib:StatsForInventoryItem(inventorySlot)
self:setTooltipStats(stats)

local link = GetInventoryItemLink(inventorySlot)
self:setInfoFromLink(link)
end

function Addon.ItemStatsLib._Stats:setToBagItem(bag, slot)
local stats = Addon.TooltipLib:StatsForBagItem(bag, slot)
self:setTooltipStats(stats)

local link = GetContainerItemLink(bag, slot)
self:setInfoFromLink(link)
end

function Addon.ItemStatsLib._Stats:setToLink(link)
local stats = Addon.TooltipLib:StatsForLink(link)
self:setTooltipStats(stats)
self:setInfoFromLink(link)
end

function Addon.ItemStatsLib._Stats:setTooltipStats(tooltipStats)
self.values = {}
for key, value in pairs(Addon.ItemStatsLib.statNormalization) do
if tooltipStats[key] then
self.values[value] = tooltipStats[key]
end
end
end

function Addon.ItemStatsLib._Stats:setInfoFromLink(link)
local name, link, rarity, level, minLevel, type, subType, stackCount, equipLoc, texture, sellPrice = GetItemInfo(link)

self.itemLevel = tonumber(level)
self.minLevel = tonumber(minLevel)
end

-- /dump Outfitter.ItemStatsLib:statsForBagItem(0, 1)
Loading

0 comments on commit 4318854

Please sign in to comment.