Skip to content

Commit

Permalink
Merge pull request #4 from Anonomit/cata
Browse files Browse the repository at this point in the history
Update for Cataclysm
  • Loading branch information
Anonomit authored Apr 30, 2024
2 parents ac2d8ad + f052773 commit 299e0a6
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 880 deletions.
55 changes: 32 additions & 23 deletions Config/OptionsTables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,20 @@ local function MakeExtraOptions(opts, categoryName)
local function MakeItemLevelOptions()
local stat = "ItemLevel"

local sampleItemLevel = random(1, self.MAX_ITEMLEVEL)

local samples = {}
local defaultText = format(self:GetOption("itemLevel", "useShortName") and GARRISON_FOLLOWER_ITEM_LEVEL or ITEM_LEVEL, random(1, self.MAX_ITEMLEVEL))
local _, formattedText = GetFormattedText(stat, self.COLORS.DEFAULT, defaultText, self:RewordItemLevel(defaultText))
defaultText = self.stealthIcon .. self:MakeColorCode(self.COLORS.GRAY, defaultText)
local defaultText = format(ITEM_LEVEL, sampleItemLevel)
local itemLevelText = format(self:GetOption("itemLevel", "useShortName") and GARRISON_FOLLOWER_ITEM_LEVEL or ITEM_LEVEL, sampleItemLevel)
local defaultText, _ = GetFormattedText(stat, self.COLORS.WHITE, defaultText, defaultText)
local _, formattedText = GetFormattedText(stat, self.COLORS.WHITE, itemLevelText, self:RewordItemLevel(itemLevelText))
if self.expansionLevel < self.expansions.cata then
defaultText = self.stealthIcon .. self:MakeColorCode(self.COLORS.GRAY, self:StripColorCode(defaultText))
end
tinsert(samples, {defaultText, formattedText})

local opts = GUI:CreateGroup(opts, stat, samples[1][2], nil, nil, disabled)

CreateSamples(opts, samples)

CreateReorder(opts, stat, L["Show this line where it was originally positioned in Wrath of The Lich King."])
Expand Down Expand Up @@ -1061,20 +1067,22 @@ local function MakeExtraOptions(opts, categoryName)
if self:GetOption("doReorder", "SoulboundTradeable") then MakeTradeableOption() end

-- Trainable
do
local stat = "Trainable"

local defaultText = self.L["Weapon"]
local _, name = GetFormattedText(stat, self.COLORS.RED, L["Trainable Equipment"], L["Trainable Equipment"])
local defaultText, formattedText, changed = GetFormattedText(stat, self.COLORS.RED, defaultText, defaultText)

local opts = GUI:CreateGroup(opts, stat, name, L["Equipment that a trainer can teach you to wear."])

CreateTitle(opts, defaultText, formattedText, changed)

CreateColor(opts, stat)
if self.expansionLevel < self.expansions.cata then
do
local stat = "Trainable"

local defaultText = self.L["Weapon"]
local _, name = GetFormattedText(stat, self.COLORS.RED, L["Trainable Equipment"], L["Trainable Equipment"])
local defaultText, formattedText, changed = GetFormattedText(stat, self.COLORS.RED, defaultText, defaultText)

local opts = GUI:CreateGroup(opts, stat, name, L["Equipment that a trainer can teach you to wear."])

CreateTitle(opts, defaultText, formattedText, changed)

CreateColor(opts, stat)
end
GUI:CreateGroup(opts, GUI:Order(), " ", nil, nil, true)
end
GUI:CreateGroup(opts, GUI:Order(), " ", nil, nil, true)

-- Weapon Damage
do
Expand Down Expand Up @@ -1519,15 +1527,16 @@ local function MakeExtraOptions(opts, categoryName)
if self.expansionLevel >= self.expansions.tbc then
local stat = "Socket"

local sockets = {
{"Socket_red", GEM_TEXT_RED},
{"Socket_blue", GEM_TEXT_BLUE},
{"Socket_yellow", GEM_TEXT_YELLOW},
local sockets = Addon:Squish{
{"Socket_red", EMPTY_SOCKET_RED},
{"Socket_blue", EMPTY_SOCKET_BLUE},
{"Socket_yellow", EMPTY_SOCKET_YELLOW},
{"Socket_purple", GEM_TEXT_PURPLE},
{"Socket_green", GEM_TEXT_GREEN},
{"Socket_orange", GEM_TEXT_ORANGE},
{"Socket_prismatic", GEM_TEXT_PRISMATIC},
{"Socket_meta", GEM_TEXT_META},
{"Socket_prismatic", EMPTY_SOCKET_PRISMATIC},
{"Socket_meta", EMPTY_SOCKET_META},
Addon:ShortCircuit(Addon.expansionLevel >= Addon.expansions.cata, {"Socket_cogwheel", EMPTY_SOCKET_COGWHEEL}, nil),
}

local samples = {}
Expand Down
13 changes: 8 additions & 5 deletions Config/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ function Addon:MakeDefaultOptions()
recolor = true,
},

order = {
[self.expansions.wrath] = tblConcat(self.statList[self.expansions.wrath] , ","),
[self.expansions.tbc] = tblConcat(self.statList[self.expansions.tbc] , ","),
[self.expansions.era] = tblConcat(self.statList[self.expansions.era], ","),
},
order = (function()
local order={}
for i = 1, self.expansionLevel do
order[i] = tblConcat(self.statList[i], ",")
end
return order
end)(),
hide = {
["*"] = false,
uselessRaces = true,
Expand Down Expand Up @@ -82,6 +84,7 @@ function Addon:MakeDefaultOptions()
Socket_orange = false,
Socket_prismatic = false,
Socket_meta = false,
Socket_cogwheel = false,
Equip = false, -- just to match Use
ChanceOnHit = false, -- just to match Use
Use = false, -- because of EnchantOnUse
Expand Down
24 changes: 20 additions & 4 deletions Init/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,28 @@ do
end
end


local function SwitchHelper(result, val)
if type(result) == "function" then
return result(val)
else
return result
end
end
function Addon:Switch(val, t, fallback)
fallback = fallback or nop
if val == nil then
return fallback(val)
return SwitchHelper(fallback, val)
else
return SwitchHelper(setmetatable(t, {__index = function() return fallback end})[val], val)
end
end


function Addon:ShortCircuit(expression, trueVal, falseVal)
if expression then
return trueVal
else
return setmetatable(t, {__index = function() return fallback end})[val](val)
return falseVal
end
end
end
Expand Down Expand Up @@ -875,7 +890,8 @@ do
local SetFunction = function(keys) local funcName = format("Set%sOptionConfig", dbType) return function(info, val) Addon[funcName](Addon, val, unpack(keys)) end end
local ResetFunction = function(keys) local funcName = format("Reset%sOptionConfig", dbType) return function(info, val) Addon[funcName](Addon, unpack(keys)) end end
local GetColorFunction = function(keys) local funcName = format("Get%sOption", dbType) return function(info) return Addon:ConvertColorToBlizzard(Addon[funcName](Addon, unpack(keys))) end end
local SetColorFunction = function(keys) local funcName = format("Set%sOptionConfig", dbType) return function(info, r, g, b) Addon[funcName](Addon, Addon:ConvertColorFromBlizzard(r, g, b), unpack(keys)) end end
local SetColorFunction = function(keys) local funcName = format("Set%sOption", dbType) return function(info, r, g, b) Addon[funcName](Addon, Addon:ConvertColorFromBlizzard(r, g, b), unpack(keys)) end end
-- options window needs to redraw if color changes

function GUI:SetDBType(typ)
dbType = typ or ""
Expand Down
Loading

0 comments on commit 299e0a6

Please sign in to comment.