diff --git a/ElvUI_SLE/config/profile.lua b/ElvUI_SLE/config/profile.lua index 15d5134..54e476a 100755 --- a/ElvUI_SLE/config/profile.lua +++ b/ElvUI_SLE/config/profile.lua @@ -73,6 +73,12 @@ P['sle'] = { ["fontSize"] = 12, ["fontOutline"] = "OUTLINE", }, + ['itemenchant'] = { + ['enable'] = true, + ["font"] = "ElvUI Font", + ["fontSize"] = 12, + ["fontOutline"] = "OUTLINE", + }, }, --Combat Icon diff --git a/ElvUI_SLE/modules/characterframe/characterframe.lua b/ElvUI_SLE/modules/characterframe/characterframe.lua index eb1c2cd..91b692e 100755 --- a/ElvUI_SLE/modules/characterframe/characterframe.lua +++ b/ElvUI_SLE/modules/characterframe/characterframe.lua @@ -4,14 +4,31 @@ local CFO = E:NewModule('CharacterFrameOptions', 'AceHook-3.0', 'AceEvent-3.0'); function CFO:ToggleCFO() self:UpdateItemDurability() self:UpdateItemLevel() - self:UpdateItemMods() + self:UpdateItemEnchants() +end + +function CFO:OnShowEquipmentChange() + CFO:UpdateItemLevel() + CFO:UpdateItemEnchants() end function CFO:Initialize() if not E.private.sle.characterframeoptions.enable then return; end + _G["CharacterFrame"]:HookScript("OnShow", function(self) + CFO:UpdateItemDurability() + CFO:UpdateItemLevel() + CFO:UpdateItemEnchants() + end) + + self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", "OnShowEquipmentChange") + --self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", "UpdateItemLevel") + --self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", "UpdateItemMods") + self:RegisterEvent("ITEM_UPGRADE_MASTER_UPDATE", "UpdateItemLevel") + self:RegisterEvent("UPDATE_INVENTORY_DURABILITY", "UpdateItemDurability") + self:LoadDurability() self:LoadItemLevel() - self:LoadItemMods() + self:LoadItemEnchants() end E:RegisterModule(CFO:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/characterframe/durability.lua b/ElvUI_SLE/modules/characterframe/durability.lua index e7faa0e..e4f0a99 100755 --- a/ElvUI_SLE/modules/characterframe/durability.lua +++ b/ElvUI_SLE/modules/characterframe/durability.lua @@ -39,11 +39,11 @@ function CFO:UpdateItemDurabilityFont() end function CFO:LoadDurability() - _G["CharacterFrame"]:HookScript("OnShow", function(self) - CFO:UpdateItemDurability() - end) + --_G["CharacterFrame"]:HookScript("OnShow", function(self) + -- CFO:UpdateItemDurability() + --end) - self:RegisterEvent("UPDATE_INVENTORY_DURABILITY", "UpdateItemDurability") + --self:RegisterEvent("UPDATE_INVENTORY_DURABILITY", "UpdateItemDurability") local frame for i = 1, #durabilitySlots do diff --git a/ElvUI_SLE/modules/characterframe/enchant.lua b/ElvUI_SLE/modules/characterframe/enchant.lua new file mode 100644 index 0000000..d4a0683 --- /dev/null +++ b/ElvUI_SLE/modules/characterframe/enchant.lua @@ -0,0 +1,160 @@ +local E, L, V, P, G, _ = unpack(ElvUI); +local CFO = E:GetModule('CharacterFrameOptions') +local LSM = LibStub("LibSharedMedia-3.0") + +local enchantSlot = { + "HeadSlot","NeckSlot","ShoulderSlot","BackSlot","ChestSlot","WristSlot", + "MainHandSlot","SecondaryHandSlot","HandsSlot","WaistSlot", + "LegsSlot","FeetSlot","Finger0Slot","Finger1Slot","Trinket0Slot","Trinket1Slot" +} + +local isEnchantable = { + "ShoulderSlot", + "BackSlot", + "ChestSlot", + "WristSlot", + "HandsSlot", + "MainHandSlot", + "SecondaryHandSlot", + "LegsSlot", + "FeetSlot" +} +local frameDB = { + CharacterHeadSlot, CharacterNeckSlot, CharacterShoulderSlot, CharacterBackSlot, CharacterChestSlot, CharacterWristSlot, + CharacterMainHandSlot, CharacterSecondaryHandSlot, CharacterHandsSlot, CharacterWaistSlot, + CharacterLegsSlot, CharacterFeetSlot, CharacterFinger0Slot, CharacterFinger1Slot, CharacterTrinket0Slot, CharacterTrinket1Slot +} +local PlayerProfession = {} + +function CFO:UpdateItemEnchants() + local frame = _G["CharacterFrame"] + if not frame:IsShown() then return end + --print("opened enchant") + for k, myslot in pairs(enchantSlot) do + --frame = _G[("Character%s"):format(enchantSlot[i])] + frame = frameDB[k] + frame.ItemEnchant:SetText() + + local canEnchant, isEnchanted + --slot = GetInventorySlotInfo(enchantSlot[i]) + local itemLink = GetInventoryItemLink("player",GetInventorySlotInfo(myslot)) + if itemLink then + if myslot == "Finger0Slot" or myslot == "Finger1Slot" then + local profNames = self:fetchProfs() + for k, v in pairs(profNames) do + if v == "Enchanting" then + canEnchant = true + isEnchanted = self:fetchChant(myslot) + end + end + elseif myslot == "RangedSlot" then + local subClass = self:fetchSubclass(myslot) + if subClass == "Bows" or subClass == "Guns" or subClass == "Crossbows" then + canEnchant = true + isEnchanted = self:fetchChant(myslot) + end + elseif myslot == "WristSlot" or myslot == "HandsSlot" then + canEnchant = true + isEnchanted = self:fetchChant(myslot) + else + for k ,v in pairs(isEnchantable) do + if v == myslot then + canEnchant = true + isEnchanted = self:fetchChant(myslot) + end + end + end + + isEnchanted = tonumber(isEnchanted) + if canEnchant == true then + if isEnchanted == 0 then + --self.ItemEnchant:SetFormattedText("|cffff0000%s|r|cffff0000%s|r", "E", "G") + frame.ItemEnchant:SetFormattedText("|cffff0000%s|r", "Not Enchanted") + elseif isEnchanted > 0 then + --self.ItemEnchant:SetFormattedText("|cff00ff00%i|r|cffff0000%s|r", "E", "G") + frame.ItemEnchant:SetFormattedText("|cff00ff00%s|r", "Enchanted") + end + elseif canEnchant == false then + frame.ItemEnchant:SetFormattedText("|cff00ff00%s|r", "Cant Enchant") + elseif canEnchant == nil then + frame.ItemEnchant:SetFormattedText("") + end + + if not E.db.sle.characterframeoptions.itemenchant.enable then + frame.ItemEnchant:Hide() + else + frame.ItemEnchant:Show() + end + end + end +end +function CFO:fetchChant(slotName) + local inventoryID = GetInventorySlotInfo(slotName) + local myLink = GetInventoryItemLink("player", inventoryID) + local parsedItemDataTable = {} + local foundStart, foundEnd, parsedItemData = string.find(myLink, "^|c%x+|H(.+)|h%[.*%]") + for v in string.gmatch(parsedItemData, "[^:]+") do + tinsert(parsedItemDataTable, v) + end + + return parsedItemDataTable[3] +end + +function CFO:fetchProfs() + local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions() + local profs = {prof1, prof2, archaeology, fishing, cooking, firstAid} + local profNames = {} + + for k, v in pairs(profs) do + local name, texture, rank, maxRank, numSpells, spelloffset, skillLine, rankModifier = GetProfessionInfo(v) + tinsert(profNames, name) + end + + return profNames +end +function CFO:fetchSubclass(slotName) + local slotId, texture, checkRelic = GetInventorySlotInfo(slotName) + local itemId = GetInventoryItemID("player", slotId) + if itemId then + local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemId) + return(subclass) + end +end +function CFO:UpdateItemEnchantFont() + local frame + for i = 1, #enchantSlot do + frame = _G[("Character%s"):format(enchantSlot[i])] + frame.ItemEnchant:FontTemplate(LSM:Fetch("font", E.db.sle.characterframeoptions.itemenchant.font), E.db.sle.characterframeoptions.itemenchant.fontSize, E.db.sle.characterframeoptions.itemenchant.fontOutline) + end +end + +function CFO:LoadItemEnchants() + --_G["CharacterFrame"]:HookScript("OnShow", function(self) + --CFO:UpdateItemMods() + --end) + + --self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", "UpdateItemMods") + + local frame + for i = 1, #enchantSlot do + frame = _G[("Character%s"):format(enchantSlot[i])] + frame.ItemEnchant = frame:CreateFontString(nil, "OVERLAY") + + if frame == CharacterHeadSlot or frame == CharacterNeckSlot or frame == CharacterShoulderSlot or frame == CharacterBackSlot or frame == CharacterChestSlot or frame == CharacterWristSlot or frame == CharacterShirtSlot or frame == CharacterTabardSlot then + frame.ItemEnchant:SetPoint("LEFT", frame, "RIGHT", 2, 7) + elseif frame == CharacterHandsSlot or frame == CharacterWaistSlot or frame == CharacterLegsSlot or frame == CharacterFeetSlot or frame == CharacterFinger0Slot or frame == CharacterFinger1Slot or frame == CharacterTrinket0Slot or frame == CharacterTrinket1Slot then + frame.ItemEnchant:SetPoint("RIGHT", frame, "LEFT", -2, 7) + elseif frame == CharacterMainHandSlot or frame == CharacterSecondaryHandSlot or frame == CharacterRangedSlot then + frame.ItemEnchant:SetPoint("TOP", frame, "BOTTOM", 0, -3) + end + frame.ItemEnchant:FontTemplate(LSM:Fetch("font", E.db.sle.characterframeoptions.itemenchant.font), E.db.sle.characterframeoptions.itemenchant.fontSize, E.db.sle.characterframeoptions.itemenchant.fontOutline) + + --frame.EnchantWarning = CreateFrame('Button', nil, frame) + --frame.EnchantWarning:Size(12) + --frame.EnchantWarning.Texture = frame.EnchantWarning:CreateTexture(nil, 'OVERLAY') + --frame.EnchantWarning.Texture:SetInside() + --frame.EnchantWarning.Texture:SetTexture('Interface\\AddOns\\ElvUI_SLE\\Media\\Textures\\Warning-Small.tga') + --frame.EnchantWarning:Point("LEFT", frame.ItemEnchant, "RIGHT", 3, 0) + --frame.EnchantWarning:Hide() + end +end \ No newline at end of file diff --git a/ElvUI_SLE/modules/characterframe/itemlevel.lua b/ElvUI_SLE/modules/characterframe/itemlevel.lua index 124cc55..a94dcd6 100755 --- a/ElvUI_SLE/modules/characterframe/itemlevel.lua +++ b/ElvUI_SLE/modules/characterframe/itemlevel.lua @@ -111,15 +111,12 @@ function CFO:UpdateItemLevelFont() end function CFO:LoadItemLevel() - _G["CharacterFrame"]:HookScript("OnShow", function(self) - CFO:UpdateItemLevel() - end) - - self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", "UpdateItemLevel") - --self:RegisterEvent("SOCKET_INFO_UPDATE", "UpdateItemLevel") - --self:RegisterEvent("MASTERY_UPDATE", "UpdateItemLevel") - --self:RegisterEvent("COMBAT_RATING_UPDATE", "UpdateItemLevel") - self:RegisterEvent("ITEM_UPGRADE_MASTER_UPDATE", "UpdateItemLevel") + --_G["CharacterFrame"]:HookScript("OnShow", function(self) + -- CFO:UpdateItemLevel() + --end) + + --self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", "UpdateItemLevel") + --self:RegisterEvent("ITEM_UPGRADE_MASTER_UPDATE", "UpdateItemLevel") local frame for i = 1, #ilvlSlots do diff --git a/ElvUI_SLE/modules/characterframe/itemmods.lua b/ElvUI_SLE/modules/characterframe/itemmods.lua deleted file mode 100644 index 4193a6f..0000000 --- a/ElvUI_SLE/modules/characterframe/itemmods.lua +++ /dev/null @@ -1,160 +0,0 @@ -local E, L, V, P, G, _ = unpack(ElvUI); -local CFO = E:GetModule('CharacterFrameOptions') -local LSM = LibStub("LibSharedMedia-3.0") - -local enchantSlot = { - "HeadSlot","NeckSlot","ShoulderSlot","BackSlot","ChestSlot","WristSlot", - "MainHandSlot","SecondaryHandSlot","HandsSlot","WaistSlot", - "LegsSlot","FeetSlot","Finger0Slot","Finger1Slot","Trinket0Slot","Trinket1Slot" -} - -local isEnchantable = { - "ShoulderSlot", - "BackSlot", - "ChestSlot", - "WristSlot", - "HandsSlot", - "MainHandSlot", - "SecondaryHandSlot", - "LegsSlot", - "FeetSlot" -} -local frameDB = { - CharacterHeadSlot, CharacterNeckSlot, CharacterShoulderSlot, CharacterBackSlot, CharacterChestSlot, CharacterWristSlot, - CharacterMainHandSlot, CharacterSecondaryHandSlot, CharacterHandsSlot, CharacterWaistSlot, - CharacterLegsSlot, CharacterFeetSlot, CharacterFinger0Slot, CharacterFinger1Slot, CharacterTrinket0Slot, CharacterTrinket1Slot -} -local PlayerProfession = {} - -function CFO:UpdateItemMods() - local frame = _G["CharacterFrame"] - if not frame:IsShown() then return end - - for k, myslot in pairs(enchantSlot) do - --frame = _G[("Character%s"):format(enchantSlot[i])] - frame = frameDB[k] - frame.ItemEnchant:SetText() - - local canEnchant, isEnchanted - --slot = GetInventorySlotInfo(enchantSlot[i]) - - --if itemLink then - if myslot == "Finger0Slot" or myslot == "Finger1Slot" then - local profNames = self:fetchProfs() - for k, v in pairs(profNames) do - if v == "Enchanting" then - canEnchant = true - isEnchanted = self:fetchChant(myslot) - end - end - elseif myslot == "RangedSlot" then - local subClass = self:fetchSubclass(myslot) - if subClass == "Bows" or subClass == "Guns" or subClass == "Crossbows" then - canEnchant = true - isEnchanted = self:fetchChant(myslot) - end - elseif myslot == "WristSlot" or myslot == "HandsSlot" then - canEnchant = true - isEnchanted = self:fetchChant(myslot) - else - for k ,v in pairs(isEnchantable) do - if v == myslot then - canEnchant = true - isEnchanted = self:fetchChant(myslot) - end - end - end - - isEnchanted = tonumber(isEnchanted) - if canEnchant == true then - if isEnchanted == 0 then - --self.ItemEnchant:SetFormattedText("|cffff0000%s|r|cffff0000%s|r", "E", "G") - frame.ItemEnchant:SetFormattedText("|cffff0000%s|r", "Not Enchanted") - elseif isEnchanted > 0 then - --self.ItemEnchant:SetFormattedText("|cff00ff00%i|r|cffff0000%s|r", "E", "G") - frame.ItemEnchant:SetFormattedText("|cff00ff00%s|r", "Enchanted") - end - elseif canEnchant == false then - frame.ItemEnchant:SetFormattedText("|cff00ff00%s|r", "Cant Enchant") - elseif canEnchant == nil then - frame.ItemEnchant:SetFormattedText("") - end - - if not E.db.sle.characterframeoptions.itemdurability.enable then - frame.ItemEnchant:Hide() - else - frame.ItemEnchant:Show() - end - --end - end -end -function CFO:fetchChant(slotName) - local inventoryID = GetInventorySlotInfo(slotName) - local myLink = GetInventoryItemLink("player", inventoryID) - local parsedItemDataTable = {} - local foundStart, foundEnd, parsedItemData = string.find(myLink, "^|c%x+|H(.+)|h%[.*%]") - for v in string.gmatch(parsedItemData, "[^:]+") do - tinsert(parsedItemDataTable, v) - end - - return parsedItemDataTable[3] -end - -function CFO:fetchProfs() - local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions() - local profs = {prof1, prof2, archaeology, fishing, cooking, firstAid} - local profNames = {} - - for k, v in pairs(profs) do - local name, texture, rank, maxRank, numSpells, spelloffset, skillLine, rankModifier = GetProfessionInfo(v) - tinsert(profNames, name) - end - - return profNames -end -function CFO:fetchSubclass(slotName) - local slotId, texture, checkRelic = GetInventorySlotInfo(slotName) - local itemId = GetInventoryItemID("player", slotId) - if itemId then - local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemId) - return(subclass) - end -end -function CFO:UpdateItemModsFont() - local frame - for i = 1, #enchantSlot do - frame = _G[("Character%s"):format(enchantSlot[i])] - frame.ItemEnchant:FontTemplate(LSM:Fetch("font", E.db.sle.characterframeoptions.itemdurability.font), E.db.sle.characterframeoptions.itemdurability.fontSize, E.db.sle.characterframeoptions.itemdurability.fontOutline) - end -end - -function CFO:LoadItemMods() - _G["CharacterFrame"]:HookScript("OnShow", function(self) - CFO:UpdateItemMods() - end) - - self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", "UpdateItemMods") - - local frame - for i = 1, #enchantSlot do - frame = _G[("Character%s"):format(enchantSlot[i])] - frame.ItemEnchant = frame:CreateFontString(nil, "OVERLAY") - - if frame == CharacterHeadSlot or frame == CharacterNeckSlot or frame == CharacterShoulderSlot or frame == CharacterBackSlot or frame == CharacterChestSlot or frame == CharacterWristSlot or frame == CharacterShirtSlot or frame == CharacterTabardSlot then - frame.ItemEnchant:SetPoint("LEFT", frame, "RIGHT", 2, 7) - elseif frame == CharacterHandsSlot or frame == CharacterWaistSlot or frame == CharacterLegsSlot or frame == CharacterFeetSlot or frame == CharacterFinger0Slot or frame == CharacterFinger1Slot or frame == CharacterTrinket0Slot or frame == CharacterTrinket1Slot then - frame.ItemEnchant:SetPoint("RIGHT", frame, "LEFT", -2, 7) - elseif frame == CharacterMainHandSlot or frame == CharacterSecondaryHandSlot or frame == CharacterRangedSlot then - frame.ItemEnchant:SetPoint("TOP", frame, "BOTTOM", 0, -3) - end - frame.ItemEnchant:FontTemplate(LSM:Fetch("font", E.db.sle.characterframeoptions.itemdurability.font), E.db.sle.characterframeoptions.itemdurability.fontSize, E.db.sle.characterframeoptions.itemdurability.fontOutline) - - --frame.EnchantWarning = CreateFrame('Button', nil, frame) - --frame.EnchantWarning:Size(12) - --frame.EnchantWarning.Texture = frame.EnchantWarning:CreateTexture(nil, 'OVERLAY') - --frame.EnchantWarning.Texture:SetInside() - --frame.EnchantWarning.Texture:SetTexture('Interface\\AddOns\\ElvUI_SLE\\Media\\Textures\\Warning-Small.tga') - --frame.EnchantWarning:Point("LEFT", frame.ItemEnchant, "RIGHT", 3, 0) - --frame.EnchantWarning:Hide() - end -end \ No newline at end of file diff --git a/ElvUI_SLE/modules/characterframe/load_characterframe.xml b/ElvUI_SLE/modules/characterframe/load_characterframe.xml index b7cc29a..fb0f4a8 100755 --- a/ElvUI_SLE/modules/characterframe/load_characterframe.xml +++ b/ElvUI_SLE/modules/characterframe/load_characterframe.xml @@ -2,6 +2,6 @@ <Script file='characterframe.lua'/> <Script file='durability.lua'/> <Script file='itemlevel.lua'/> - <Script file='itemmods.lua'/> + <Script file='enchant.lua'/> <Script file='options.lua'/> </Ui> \ No newline at end of file diff --git a/ElvUI_SLE/modules/characterframe/options.lua b/ElvUI_SLE/modules/characterframe/options.lua index 44dc06b..3988831 100755 --- a/ElvUI_SLE/modules/characterframe/options.lua +++ b/ElvUI_SLE/modules/characterframe/options.lua @@ -147,6 +147,66 @@ E.Options.args.sle.args.characterframeoptions = { }, }, }, + itemenchant = { + type = "group", + name = L["Enchanting Notification"], + --name = DURABILITY, + order = 6, + guiInline = true, + disabled = function() return not E.private.sle.characterframeoptions.enable end, + args = { + enable = { + order = 1, + type = "toggle", + name = L["Enable"], + --desc = L["Show/Hide Item Durability"], + get = function(info) return E.db.sle.characterframeoptions.itemenchant.enable end, + set = function(info, value) E.db.sle.characterframeoptions.itemenchant.enable = value; CFO:ToggleCFO() end, + }, + fontGroup = { + order = 2, + type = 'group', + guiInline = true, + disabled = function() return not E.db.sle.characterframeoptions.itemenchant.enable end, + name = L['Font'], + args = { + font = { + type = "select", dialogControl = 'LSM30_Font', + order = 1, + name = L["Font"], + desc = L["The font that the item durability will use."], + values = AceGUIWidgetLSMlists.font, + get = function(info) return E.db.sle.characterframeoptions.itemenchant.font end, + set = function(info, value) E.db.sle.characterframeoptions.itemenchant.font = value; CFO:UpdateItemEnchantFont(); end, + }, + fontSize = { + order = 2, + name = L["Font Size"], + desc = L["Set the font size that the enchant notification will use."], + type = "range", + min = 6, max = 22, step = 1, + get = function(info) return E.db.sle.characterframeoptions.itemenchant.fontSize end, + set = function(info, value) E.db.sle.characterframeoptions.itemenchant.fontSize = value; CFO:UpdateItemEnchantFont(); end, + }, + fontOutline = { + order = 3, + name = L["Font Outline"], + desc = L["Set the font outline that the enchant notification will use."], + type = "select", + values = { + ['NONE'] = L['None'], + ['OUTLINE'] = 'OUTLINE', + ['MONOCHROME'] = 'MONOCHROME', + ['MONOCHROMEOUTLINE'] = 'MONOCROMEOUTLINE', + ['THICKOUTLINE'] = 'THICKOUTLINE', + }, + get = function(info) return E.db.sle.characterframeoptions.itemenchant.fontOutline end, + set = function(info, value) E.db.sle.characterframeoptions.itemenchant.fontOutline = value; CFO:UpdateItemEnchantFont(); end, + }, + }, + }, + }, + }, }, } end