Skip to content

Commit 8a01641

Browse files
committed
fix the enchant string section to allow users to add missing enchants by using the enchant id provided in the message in chat or tooltip on the item with the enchant
1 parent e5d2728 commit 8a01641

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
local _, _, _, _, G = unpack(ElvUI)
22

33
G.cataarmory = {
4-
enchantStrings = {
5-
UserReplaced = {},
6-
CustomReplacement = {},
7-
}
4+
enchantStrings = {
5+
UserReplaced = {}, --* Strings that are in the lib database that the user replaced
6+
}
87
}

ReforgedArmory/Options/Options.lua

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,24 @@ end
274274

275275
local EnchantIDSelected = ''
276276

277-
local function HandleReplacement(value)
278-
local default = E.Libs.GetEnchantList.LibGetEnchantDB[tonumber(EnchantIDSelected)]
279-
280-
if (value and value ~= '') and default ~= value then
281-
E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] = value
282-
else
277+
local function HandleReplacement(newEnchantString)
278+
if not EnchantIDSelected or EnchantIDSelected == '' then return module:Print('No enchant id selected.') end
279+
local defaultEnchantString = E.Libs.GetEnchantList.LibGetEnchantDB[tonumber(EnchantIDSelected)]
280+
281+
if newEnchantString and newEnchantString ~= '' then
282+
if defaultEnchantString then
283+
if defaultEnchantString ~= newEnchantString then
284+
E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] = newEnchantString
285+
else
286+
E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] = nil
287+
EnchantIDSelected = nil
288+
end
289+
else
290+
E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] = newEnchantString
291+
end
292+
elseif E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] then
283293
E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] = nil
294+
EnchantIDSelected = nil
284295
end
285296

286297
module:UpdateOptions(nil, true)
@@ -326,9 +337,10 @@ local function configTable()
326337
local StringReplacement = ACH:Group(L["Enchant Strings"], nil, 2)
327338
Armory.args.stringReplacement = StringReplacement
328339
StringReplacement.args.header3 = ACH:Header(L["Direct Enchant String Replacement"], 21)
329-
StringReplacement.args.desc = ACH:Description(L["This is the |cff00fc00recommended|r method to keep performance impact to a minimum.\nEnter the |cffFFD100EnchantID|r in the |cffFFD100EnchantID|r input box below. You can obtain the |cffFFD100EnchantID|r in the tooltip of the item."], 22, 'medium')
330-
StringReplacement.args.selectID = ACH:Input(L["EnchantID"], L["Mouseover an item that has an enchant to view the id in the tooltip. \n|cffFFD100Hint:|r If you do not see it listed, make sure you have the option enabled and that the item even has the enchant on it."], 23, nil, nil, function() return EnchantIDSelected--[[get]] end, function(info, value) EnchantIDSelected = value --[[set func]] end, nil, nil, --[[function(_, value) if value and E.Libs.GetEnchantList.LibGetEnchantDB[tonumber(value)] then return true else return false end end]] nil)
331-
StringReplacement.args.string = ACH:Input(function() return EnchantIDSelected and EnchantIDSelected ~= '' and format(L["|cFFCA3C3CDefault String|r: |cff00fc00%s|r"], E.Libs.GetEnchantList.LibGetEnchantDB[tonumber(EnchantIDSelected)]) or L["No EnchantID Selected"] end, function() return EnchantIDSelected and EnchantIDSelected ~= '' and format(L["|cFFCA3C3CEnchantID:|r |cffFFD100%s|r|n|cFFCA3C3CModified String:|r |cff00fc00%s|r"], EnchantIDSelected, E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] or L["Not Modified"]) or '' end, 24, nil, 'full', function() return EnchantIDSelected and EnchantIDSelected ~= '' and (E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] or E.Libs.GetEnchantList.LibGetEnchantDB[tonumber(EnchantIDSelected)]) or nil end, function(_, value) HandleReplacement(value) end, function() if not EnchantIDSelected or EnchantIDSelected == '' then return true end return false end, nil, nil)
340+
StringReplacement.args.desc = ACH:Description(L["This is the |cff00fc00recommended|r method to keep performance impact to a minimum.\nEnter the |cffFFD100EnchantID|r in the |cffFFD100EnchantID|r input box below. You can obtain the |cffFFD100EnchantID|r in the tooltip of the item.\n\n|cffFFD100Notice|r: You can use this if you find an enchant not in the database currently. This will keep you from having to wait for a new update."], 22, 'medium')
341+
StringReplacement.args.spacer1 = ACH:Spacer(24, 'full')
342+
StringReplacement.args.selectID = ACH:Input(L["EnchantID"], L["Mouseover an item that has an enchant to view the id in the tooltip. \n|cffFFD100Hint:|r If you do not see it listed, make sure you have the option enabled and that the item even has the enchant on it."], 25, nil, nil, function() return EnchantIDSelected end, function(info, value) EnchantIDSelected = value end)
343+
StringReplacement.args.string = ACH:Input(function() local enchantName = EnchantIDSelected and EnchantIDSelected ~= '' and E.Libs.GetEnchantList.LibGetEnchantDB[tonumber(EnchantIDSelected)] if EnchantIDSelected and EnchantIDSelected ~= '' then return format(L["|cFFCA3C3CDefault String|r: |cff00fc00%s|r"], enchantName or 'Not In Database') else return L["No EnchantID Selected"] end end, function() if EnchantIDSelected and EnchantIDSelected ~= '' then return format(L["|cFFCA3C3CEnchantID:|r |cffFFD100%s|r|n|cFFCA3C3CModified String:|r |cff00fc00%s|r"], EnchantIDSelected, E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] or L["Not Modified"]) end return '' end, 26, nil, 'full', function() return EnchantIDSelected and EnchantIDSelected ~= '' and (E.global.cataarmory.enchantStrings.UserReplaced[tonumber(EnchantIDSelected)] or E.Libs.GetEnchantList.LibGetEnchantDB[tonumber(EnchantIDSelected)]) or nil end, function(_, value) HandleReplacement(value) end, function() if not EnchantIDSelected or EnchantIDSelected == '' then return true end return false end)
332344
end
333345

334346
tinsert(module.Configs, configTable)

0 commit comments

Comments
 (0)