diff --git a/KkthnxUI/Config/AuraWatchGUI.lua b/KkthnxUI/Config/AuraWatchGUI.lua index 7024b48a..d693f9e9 100644 --- a/KkthnxUI/Config/AuraWatchGUI.lua +++ b/KkthnxUI/Config/AuraWatchGUI.lua @@ -10,7 +10,7 @@ local ERR_NOT_IN_COMBAT = ERR_NOT_IN_COMBAT local GameTooltip = GameTooltip local GetInventoryItemTexture = GetInventoryItemTexture local GetItemInfo = GetItemInfo -local GetSpellInfo = GetSpellInfo +local C_Spell_GetSpellInfo = C_Spell.GetSpellInfo local INVTYPE_CLOAK = INVTYPE_CLOAK local INVTYPE_FINGER = INVTYPE_FINGER local INVTYPE_TRINKET = INVTYPE_TRINKET @@ -404,7 +404,7 @@ local function CreatePanel() local function AddAura(parent, index, data) local typeID, spellID, unitID, caster, stack, amount, timeless, combat, text, flash = unpack(data) - local name, _, texture = GetSpellInfo(spellID) + local name, _, texture = C_Spell_GetSpellInfo(spellID) if typeID == "SlotID" then texture = GetInventoryItemTexture("player", spellID) name = slotIndex[spellID] @@ -461,7 +461,7 @@ local function CreatePanel() local function AddInternal(parent, index, data) local intID, duration, trigger, unit, itemID = unpack(data) - local name, _, texture = GetSpellInfo(intID) + local name, _, texture = C_Spell_GetSpellInfo(intID) if itemID then name = GetItemInfo(itemID) end @@ -703,7 +703,7 @@ local function CreatePanel() return end - if (typeID == "AuraID" or typeID == "SpellID") and not GetSpellInfo(spellID) then + if (typeID == "AuraID" or typeID == "SpellID") and not C_Spell_GetSpellInfo(spellID) then UIErrorsFrame:AddMessage(K.InfoColor .. L["Incorrect SpellID"]) return end @@ -727,7 +727,7 @@ local function CreatePanel() return end - if intID and not GetSpellInfo(intID) then + if intID and not C_Spell_GetSpellInfo(intID) then UIErrorsFrame:AddMessage(K.InfoColor .. L["Incorrect SpellID"]) return end diff --git a/KkthnxUI/Config/Elements/FilterLists/AuraWatchSpells.lua b/KkthnxUI/Config/Elements/FilterLists/AuraWatchSpells.lua index 49ee655c..87130ab8 100644 --- a/KkthnxUI/Config/Elements/FilterLists/AuraWatchSpells.lua +++ b/KkthnxUI/Config/Elements/FilterLists/AuraWatchSpells.lua @@ -4,7 +4,7 @@ local Module = K:NewModule("AurasTable") local string_format = string.format local table_wipe = table.wipe -local GetSpellInfo = GetSpellInfo +local C_Spell_GetSpellInfo = C_Spell.GetSpellInfo local UIParent = UIParent local AuraWatchList = {} @@ -46,7 +46,7 @@ function Module:AddNewAuraWatch(class, list) for _, v in pairs(k) do local spellID = v.AuraID or v.SpellID if spellID then - local name = GetSpellInfo(spellID) + local name = C_Spell_GetSpellInfo(spellID) if not name then table_wipe(v) if K.isDeveloper then diff --git a/KkthnxUI/Config/Elements/FilterLists/BadBuffs.lua b/KkthnxUI/Config/Elements/FilterLists/BadBuffs.lua index bd5b3cdf..7c9d77fe 100644 --- a/KkthnxUI/Config/Elements/FilterLists/BadBuffs.lua +++ b/KkthnxUI/Config/Elements/FilterLists/BadBuffs.lua @@ -1,9 +1,9 @@ local K, C = KkthnxUI[1], KkthnxUI[2] -local GetSpellInfo = GetSpellInfo +local C_Spell_GetSpellInfo = C_Spell.GetSpellInfo local function SpellName(id) - local name = GetSpellInfo(id) + local name = C_Spell_GetSpellInfo(id) if name then return name else diff --git a/KkthnxUI/Developer/Elements/Frame.lua b/KkthnxUI/Developer/Elements/Frame.lua index a030fdb9..6ee51354 100644 --- a/KkthnxUI/Developer/Elements/Frame.lua +++ b/KkthnxUI/Developer/Elements/Frame.lua @@ -21,7 +21,7 @@ local GetInstanceInfo = GetInstanceInfo local GetScreenHeight = GetScreenHeight local GetScreenWidth = GetScreenWidth local GetSpellDescription = GetSpellDescription -local GetSpellInfo = GetSpellInfo +local C_Spell_GetSpellInfo = C_Spell.GetSpellInfo local GetSpellTexture = GetSpellTexture local IsInGuild = IsInGuild local IsInRaid = IsInRaid @@ -75,7 +75,7 @@ end _G.SLASH_KKTHNXUI_ENUMFRAME1 = "/getframe" SlashCmdList["KKTHNXUI_DUMPSPELL"] = function(arg) - local name = GetSpellInfo(arg) + local name = C_Spell_GetSpellInfo(arg) if not name then print("Please enter a spell name --> /getspell SPELLNAME") return diff --git a/KkthnxUI/Init.lua b/KkthnxUI/Init.lua index ee64b1f5..1e7da00e 100644 --- a/KkthnxUI/Init.lua +++ b/KkthnxUI/Init.lua @@ -1,34 +1,7 @@ local AddOnName, Engine = ... --- KkthnxUI Compatibility Layer for Firestorm Dragonflight Release --- This script ensures backward compatibility with older WoW API functions. - --- Checking and initializing the C_AddOns table if it doesn't exist --- This is necessary to avoid nil reference errors in older WoW versions. -C_AddOns = C_AddOns or {} - --- Overwrite the IsAddOnLoaded function in the C_AddOns table. --- This ensures that C_AddOns.IsAddOnLoaded references the global IsAddOnLoaded function. --- Useful for older WoW versions where C_AddOns.IsAddOnLoaded might not be available. -C_AddOns.IsAddOnLoaded = C_AddOns.IsAddOnLoaded or IsAddOnLoaded - --- Overwrite the GetAddOnInfo function in the C_AddOns table. --- This ensures that C_AddOns.GetAddOnInfo references the global GetAddOnInfo function. --- Ensures compatibility for accessing addon information across different WoW versions. -C_AddOns.GetAddOnInfo = C_AddOns.GetAddOnInfo or GetAddOnInfo - --- Overwrite the GetNumAddOns function in the C_AddOns table. --- This ensures that C_AddOns.GetNumAddOns references the global GetNumAddOns function. --- Aligns with the above modification for consistency and backward compatibility. -C_AddOns.GetNumAddOns = C_AddOns.GetNumAddOns or GetNumAddOns - --- Overwrite C_AddOns.GetAddOnEnableState with the global GetAddOnEnableState function. --- Allows querying the enable state of addons in a manner compatible with older versions. -C_AddOns.GetAddOnEnableState = C_AddOns.GetAddOnEnableState or GetAddOnEnableState - --- Note: These overrides are specifically tailored for the Firestorm Dragonflight release --- and older versions of WoW. Ensure extensive testing across different WoW versions --- to maintain compatibility and avoid conflicts with other addons or game client behavior. +GetSpellTexture = C_Spell and C_Spell.GetSpellTexture or GetSpellTexture +GetSpellInfo = C_Spell and C_Spell.GetSpellInfo or GetSpellInfo local bit_band = bit.band local bit_bor = bit.bor diff --git a/KkthnxUI/Libraries/LibActionButton-1.0/LibActionButton-1.0.lua b/KkthnxUI/Libraries/LibActionButton-1.0/LibActionButton-1.0.lua index 7c9d584b..05ed0bc8 100644 --- a/KkthnxUI/Libraries/LibActionButton-1.0/LibActionButton-1.0.lua +++ b/KkthnxUI/Libraries/LibActionButton-1.0/LibActionButton-1.0.lua @@ -55,7 +55,7 @@ local UseCustomFlyout = WoWRetail local KeyBound = LibStub("LibKeyBound-1.0", true) local CBH = LibStub("CallbackHandler-1.0") -local LCG = LibStub("LibCustomGlow-1.0-KkthnxUI", true) -- NDui: use LCG mod +local LCG = LibStub("LibCustomGlow-1.0-NDui", true) -- NDui: use LCG mod local Masque = LibStub("Masque", true) lib.eventFrame = lib.eventFrame or CreateFrame("Frame") @@ -1710,7 +1710,7 @@ local function UpdateProfessionQuality(self) if quality then if not self.ProfessionQuality then self.ProfessionQuality = CreateFrame("Frame", nil, self) - self.ProfessionQuality:SetInside() + self.ProfessionQuality:SetAllPoints() local tex = self.ProfessionQuality:CreateTexture(nil, "ARTWORK") tex:SetPoint("TOPLEFT") self.ProfessionQuality.Texture = tex diff --git a/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua b/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua index a1039207..3e29546b 100644 --- a/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua +++ b/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua @@ -45,13 +45,11 @@ local Container = cargBags.classes.Container @param bags ]] function Container:SetBags(bags) - if cargBags.ParseBags then + if(cargBags.ParseBags) then bags = cargBags:ParseBags(bags) end - if not bags then - return - end + if(not bags) then return end self.implementation.bagToContainer = self.implementation.bagToContainer or {} local b2c = self.implementation.bagToContainer diff --git a/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua b/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua index 064b3128..3a67be5a 100644 --- a/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua +++ b/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua @@ -46,15 +46,9 @@ end Empties the filter table ]] function FilterSet:Empty() - for k in pairs(self.funcs) do - self.funcs[k] = nil - end - for k in pairs(self.params) do - self.params[k] = nil - end - for k in pairs(self.chained) do - self.chained[k] = nil - end + for k in pairs(self.funcs) do self.funcs[k] = nil end + for k in pairs(self.params) do self.params[k] = nil end + for k in pairs(self.chained) do self.chained[k] = nil end end --[[! @@ -73,7 +67,7 @@ end @param flag whether the filter is enabled (-1: inverted) [optional] ]] function FilterSet:SetExtended(filter, param, flag) - if not flag and param then + if(not flag and param) then flag = true end @@ -87,7 +81,7 @@ end @param ... a list of filters ]] function FilterSet:SetMultiple(flag, ...) - for i = 1, select("#", ...) do + for i=1, select("#", ...) do local filter = select(i, ...) self:Set(filter, flag) end @@ -113,14 +107,14 @@ function FilterSet:Check(item) -- check own filters for filter, flag in pairs(funcs) do local result = filter(item, params[filter]) - if (flag == true and not result) or (flag == -1 and result) then + if((flag == true and not result) or (flag == -1 and result)) then return nil end end -- check filters of chained sets for tbl in pairs(self.chained) do - if not tbl:Check(item) then + if(not tbl:Check(item)) then return nil end end @@ -135,7 +129,7 @@ end ]] function Implementation:GetContainerForItem(item) for _, container in ipairs(self.contByID) do - if not container.filters or container.filters:Check(item) then + if(not container.filters or container.filters:Check(item)) then return container end end @@ -144,13 +138,13 @@ end --[[ Simple function shortcuts for Containers ]] -for name, func in pairs({ +for name, func in pairs{ ["SetFilter"] = "Set", ["SetExtendedFilter"] = "SetExtended", ["SetMultipleFilters"] = "SetMultiple", ["ChainFilters"] = "Chain", - ["CheckFilters"] = "Check", -}) do + ["CheckFilters"]= "Check", +} do Container[name] = function(self, ...) self.filters = self.filters or FilterSet:New() self.filters[func](self.filters, ...) @@ -169,4 +163,4 @@ function Container:FilterForFunction(func, filters) local result = filters:Check(button:GetInfo()) func(button, result) end -end +end \ No newline at end of file diff --git a/KkthnxUI/Libraries/cargBags/base/container.lua b/KkthnxUI/Libraries/cargBags/base/container.lua index fa9f820c..ab2b96f4 100644 --- a/KkthnxUI/Libraries/cargBags/base/container.lua +++ b/KkthnxUI/Libraries/cargBags/base/container.lua @@ -26,13 +26,11 @@ local cargBags = ns.cargBags ]] local Container = cargBags:NewClass("Container", nil, "Button") -local mt_bags = { - __index = function(self, bagID) - self[bagID] = CreateFrame("Frame", nil, self.container) - self[bagID]:SetID(bagID) - return self[bagID] - end, -} +local mt_bags = {__index=function(self, bagID) + self[bagID] = CreateFrame("Frame", nil, self.container) + self[bagID]:SetID(bagID) + return self[bagID] +end} --[[! Creates a new instance of the class @@ -43,11 +41,11 @@ local mt_bags = { ]] function Container:New(name, ...) local implName = self.implementation.name - local container = setmetatable(CreateFrame("Button", implName .. name), self.__index) + local container = setmetatable(CreateFrame("Button", implName..name), self.__index) container.name = name container.buttons = {} - container.bags = setmetatable({ container = container }, mt_bags) + container.bags = setmetatable({container = container}, mt_bags) container:ScheduleContentCallback() container.implementation.contByName[name] = container -- Make this into pretty function? @@ -55,9 +53,7 @@ function Container:New(name, ...) container:SetParent(self.implementation) - if container.OnCreate then - container:OnCreate(name, ...) - end + if(container.OnCreate) then container:OnCreate(name, ...) end return container end @@ -73,12 +69,8 @@ function Container:AddButton(button) button:SetParent(self.bags[button.bagId]) self:ScheduleContentCallback() table.insert(self.buttons, button) - if button.OnAdd then - button:OnAdd(self) - end - if self.OnButtonAdd then - self:OnButtonAdd(button) - end + if(button.OnAdd) then button:OnAdd(self) end + if(self.OnButtonAdd) then self:OnButtonAdd(button) end end --[[! @@ -89,15 +81,11 @@ end ]] function Container:RemoveButton(button) for i, single in ipairs(self.buttons) do - if button == single then + if(button == single) then self:ScheduleContentCallback() button.container = nil - if button.OnRemove then - button:OnRemove(self) - end - if self.OnButtonRemove then - self:OnButtonRemove(button) - end + if(button.OnRemove) then button:OnRemove(self) end + if(self.OnButtonRemove) then self:OnButtonRemove(button) end return table.remove(self.buttons, i) end end @@ -106,14 +94,12 @@ end --[[ @callback OnContentsChanged() ]] -local updater, scheduled = CreateFrame("Frame"), {} +local updater, scheduled = CreateFrame"Frame", {} updater:Hide() updater:SetScript("OnUpdate", function(self) self:Hide() for container in pairs(scheduled) do - if container.OnContentsChanged then - container:OnContentsChanged() - end + if(container.OnContentsChanged) then container:OnContentsChanged() end scheduled[container] = nil end end) diff --git a/KkthnxUI/Libraries/cargBags/base/core.lua b/KkthnxUI/Libraries/cargBags/base/core.lua index a9b88c39..2d5bfae6 100644 --- a/KkthnxUI/Libraries/cargBags/base/core.lua +++ b/KkthnxUI/Libraries/cargBags/base/core.lua @@ -19,7 +19,7 @@ class-generation, helper-functions and the Blizzard-replacement. ]] local parent, ns = ... -local global = C_AddOns.GetAddOnMetadata(parent, "X-cargBags") +local global = C_AddOns.GetAddOnMetadata(parent, 'X-cargBags') --- @class table -- @name cargBags @@ -27,20 +27,19 @@ local global = C_AddOns.GetAddOnMetadata(parent, "X-cargBags") -- class-generation, helper-functions and the Blizzard-replacement local cargBags = CreateFrame("Button") + ns.cargBags = cargBags -if global then +if(global) then _G[global] = cargBags end cargBags.classes = {} --- Holds all classes by their name cargBags.itemKeys = {} ---
Holds all ItemKeys by their name -local widgets = setmetatable({}, { - __index = function(self, widget) - self[widget] = getmetatable(CreateFrame(widget)) - return self[widget] - end, -}) +local widgets = setmetatable({}, {__index = function(self, widget) + self[widget] = getmetatable(CreateFrame(widget)) + return self[widget] +end}) --- Creates a new class -- @param name The name of the class @@ -48,9 +47,7 @@ local widgets = setmetatable({}, { -- @param widget The widget type of the class -- @return class
The prototype of the class function cargBags:NewClass(name, parent, widget) - if self.classes[name] then - return - end + if(self.classes[name]) then return end parent = parent and self.classes[parent] local class = setmetatable({}, parent or (widget and widgets[widget])) class.__index = class @@ -73,15 +70,9 @@ function cargBags:GetImplementation(name) return self.classes.Implementation:Get(name) end -local function toggleBag(forceopen) - cargBags.blizzard:Toggle(forceopen) -end -local function toggleNoForce() - cargBags.blizzard:Toggle() -end -local function closeBag() - cargBags.blizzard:Hide() -end +local function toggleBag(forceopen) cargBags.blizzard:Toggle(forceopen) end +local function toggleNoForce() cargBags.blizzard:Toggle() end +local function closeBag() cargBags.blizzard:Hide() end --- Overwrites Blizzards Bag-Toggle-Functions with the implementation's ones -- @param name The name of the implementation [optional] @@ -94,11 +85,11 @@ function cargBags:ReplaceBlizzard(name) ToggleBag = toggleNoForce ToggleBackpack = toggleNoForce - OpenAllBags = toggleBag -- Name is misleading, Blizz-function actually toggles bags + OpenAllBags = toggleBag -- Name is misleading, Blizz-function actually toggles bags OpenBackpack = toggleBag -- Blizz does not provide toggling here CloseAllBags = closeBag CloseBackpack = closeBag - OpenBag = toggleBag -- fixed the loot won alert frame + OpenBag = toggleBag -- fixed the loot won alert frame BankFrame:UnregisterAllEvents() end @@ -108,7 +99,7 @@ end function cargBags:RegisterBlizzard(implementation) self.blizzard = implementation - if IsLoggedIn() then + if(IsLoggedIn()) then self:ReplaceBlizzard(self.blizzard) else self:RegisterEvent("PLAYER_LOGIN") @@ -121,7 +112,7 @@ end -- @param ... arguments of the event [optional] function cargBags:FireEvent(force, event, ...) for _, impl in pairs(self.classes.Implementation.instances) do - if force or impl:IsShown() then + if(force or impl:IsShown()) then impl:OnEvent(event or "BAG_UPDATE", ...) end end @@ -131,53 +122,47 @@ cargBags:RegisterEvent("BANKFRAME_OPENED") cargBags:RegisterEvent("BANKFRAME_CLOSED") cargBags:SetScript("OnEvent", function(self, event) - if not self.blizzard then - return - end + if(not self.blizzard) then return end local impl = self.blizzard - if event == "PLAYER_LOGIN" then + if(event == "PLAYER_LOGIN") then self:ReplaceBlizzard(impl) - elseif event == "BANKFRAME_OPENED" then + elseif(event == "BANKFRAME_OPENED") then self.atBank = true - if impl:IsShown() then + if(impl:IsShown()) then impl:OnEvent("BAG_UPDATE") else impl:Show() end - if impl.OnBankOpened then + if(impl.OnBankOpened) then impl:OnBankOpened() end - elseif event == "BANKFRAME_CLOSED" then + elseif(event == "BANKFRAME_CLOSED") then self.atBank = nil - if impl:IsShown() then + if(impl:IsShown()) then impl:Hide() end - if impl.OnBankClosed then + if(impl.OnBankClosed) then impl:OnBankClosed() end end end) -local handlerFuncs = setmetatable({}, { - __index = function(self, handler) - self[handler] = function(self, ...) - return self[handler] and self[handler](self, ...) - end - return self[handler] - end, -}) +local handlerFuncs = setmetatable({}, {__index=function(self, handler) + self[handler] = function(self, ...) return self[handler] and self[handler](self, ...) end + return self[handler] +end}) --- Sets a number of script handlers by redirecting them to the members function, e.g. self:OnEvent(self, ...) -- @param self -- @param ... A number of script handlers function cargBags.SetScriptHandlers(self, ...) - for i = 1, select("#", ...) do + for i=1, select("#", ...) do local handler = select(i, ...) self:SetScript(handler, handlerFuncs[handler]) end @@ -188,24 +173,22 @@ end -- @param slotID -- @return bagSlot function cargBags.ToBagSlot(bagID, slotID) - return bagID * 100 + slotID + return bagID*100+slotID end + --- Gets the bagID-slotID-pair of a bagSlot-index -- @param bagSlot -- @return bagID -- @return bagSlot function cargBags.FromBagSlot(bagSlot) - return floor(bagSlot / 100), bagSlot % 100 + return floor(bagSlot/100), bagSlot % 100 end --- Creates a new item table which has access to ItemKeys -- @return itemTable
-local m_item = { - __index = function(i, k) - return cargBags.itemKeys[k] and cargBags.itemKeys[k](i, k) - end, -} +local m_item = {__index = function(i,k) return cargBags.itemKeys[k] and cargBags.itemKeys[k](i,k) end} function cargBags:NewItemTable() return setmetatable({}, m_item) end + diff --git a/KkthnxUI/Libraries/cargBags/base/implementation.lua b/KkthnxUI/Libraries/cargBags/base/implementation.lua index ec414cdb..626988c2 100644 --- a/KkthnxUI/Libraries/cargBags/base/implementation.lua +++ b/KkthnxUI/Libraries/cargBags/base/implementation.lua @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]] local _, ns = ... +local B, C, L, DB = unpack(ns) local cargBags = ns.cargBags local GetContainerNumSlots = C_Container.GetContainerNumSlots @@ -44,12 +45,8 @@ local MYTHIC_KEYSTONES = { @return impl ]] function Implementation:New(name) - if self.instances[name] then - return error(("cargBags: Implementation '%s' already exists!"):format(name)) - end - if _G[name] then - return error(("cargBags: Global '%s' for Implementation is already used!"):format(name)) - end + if(self.instances[name]) then return error(("cargBags: Implementation '%s' already exists!"):format(name)) end + if(_G[name]) then return error(("cargBags: Global '%s' for Implementation is already used!"):format(name)) end local impl = setmetatable(CreateFrame("Button", name, UIParent), self.__index) impl.name = name @@ -79,17 +76,15 @@ end @callback OnOpen ]] function Implementation:OnShow() - if self.notInited then - if not (InCombatLockdown()) then -- initialization of bags in combat taints the itembuttons within - Lars Norberg + if(self.notInited) then + if not(InCombatLockdown()) then -- initialization of bags in combat taints the itembuttons within - Lars Norberg self:Init() else return end end - if self.OnOpen then - self:OnOpen() - end + if(self.OnOpen) then self:OnOpen() end self:OnEvent("BAG_UPDATE") end @@ -98,16 +93,10 @@ end @callback OnClose ]] function Implementation:OnHide() - if self.notInited then - return - end + if(self.notInited) then return end - if self.OnClose then - self:OnClose() - end - if self:AtBank() then - CloseBankFrame() - end + if(self.OnClose) then self:OnClose() end + if(self:AtBank()) then C_Bank.CloseBankFrame() end end --[[! @@ -115,7 +104,7 @@ end @param forceopen Only open it ]] function Implementation:Toggle(forceopen) - if not forceopen and self:IsShown() then + if(not forceopen and self:IsShown()) then self:Hide() else self:Show() @@ -153,15 +142,11 @@ end @return class
The class prototype ]] function Implementation:GetClass(name, create, ...) - if not name then - return - end + if(not name) then return end - name = self.name .. name + name = self.name..name local class = cargBags.classes[name] - if class or not create then - return class - end + if(class or not create) then return class end class = cargBags:NewClass(name, ...) class.implementation = self @@ -175,7 +160,7 @@ end @return class
The class prototype ]] function Implementation:GetContainerClass(name) - return self:GetClass((name or "") .. "Container", true, "Container") + return self:GetClass((name or "").."Container", true, "Container") end --[[! @@ -185,7 +170,7 @@ end @return class
The class prototype ]] function Implementation:GetItemButtonClass(name) - return self:GetClass((name or "") .. "ItemButton", true, "ItemButton") + return self:GetClass((name or "").."ItemButton", true, "ItemButton") end --[[! @@ -219,12 +204,12 @@ local _isEventRegistered = UIParent.IsEventRegistered function Implementation:RegisterEvent(event, key, func) local events = self.events - if not events[event] then + if(not events[event]) then events[event] = {} end events[event][key] = func - if event:upper() == event and not _isEventRegistered(self, event) then + if(event:upper() == event and not _isEventRegistered(self, event)) then _registerEvent(self, event) end end @@ -242,9 +227,7 @@ end Script handler, dispatches the events ]] function Implementation:OnEvent(event, ...) - if not (self.events[event] and self:IsShown()) then - return - end + if(not (self.events[event] and self:IsShown())) then return end for key, func in pairs(self.events[event]) do func(key, event, ...) @@ -256,22 +239,18 @@ end @callback OnInit ]] function Implementation:Init() - if not self.notInited then - return - end + if(not self.notInited) then return end -- initialization of bags in combat taints the itembuttons within - Lars Norberg - if InCombatLockdown() then + if (InCombatLockdown()) then return end self.notInited = nil - if self.OnInit then - self:OnInit() - end + if(self.OnInit) then self:OnInit() end - if not self.buttonClass then + if(not self.buttonClass) then self:SetDefaultItemButtonClass() end @@ -322,18 +301,17 @@ local defaultItem = cargBags:NewItemTable() @param i
[optional] @return i
]] -function Implementation:GetCustomItemInfo(bagID, slotID, i) +function Implementation:GetItemInfo(bagID, slotID, i) i = i or defaultItem - for k in pairs(i) do - i[k] = nil - end + for k in pairs(i) do i[k] = nil end i.bagId = bagID i.slotId = slotID + local texture, count, locked, quality, itemLink, noValue, itemID local info = C_Container.GetContainerItemInfo(bagID, slotID) if info then - i.texture, i.count, i.locked, i.quality, i.link, i.id, i.bound, i.hasPrice = info.iconFileID, info.stackCount, info.isLocked, (info.quality or 1), info.hyperlink, info.itemID, info.isBound, not info.hasNoValue + i.texture, i.count, i.locked, i.quality, i.link, i.id, i.hasPrice = info.iconFileID, info.stackCount, info.isLocked, (info.quality or 1), info.hyperlink, info.itemID, (not info.hasNoValue) i.isInSet, i.setName = C_Container.GetContainerItemEquipmentSetInfo(bagID, slotID) @@ -342,8 +320,7 @@ function Implementation:GetCustomItemInfo(bagID, slotID, i) local questInfo = C_Container.GetContainerItemQuestInfo(bagID, slotID) i.isQuestItem, i.questID, i.questActive = questInfo.isQuestItem, questInfo.questID, questInfo.isActive - i.spellID = GetItemSpell(i.link) - i.name, _, _, _, i.minlevel, i.type, i.subType, _, i.equipLoc, _, _, i.classID, i.subClassID, i.bindType = GetItemInfo(i.link) + i.name, _, _, _, _, i.type, i.subType, _, i.equipLoc, _, _, i.classID, i.subClassID = C_Item.GetItemInfo(i.link) i.equipLoc = _G[i.equipLoc] -- INVTYPE to localized string if i.id == PET_CAGE then @@ -368,13 +345,13 @@ end @param slotID ]] function Implementation:UpdateSlot(bagID, slotID) - local item = self:GetCustomItemInfo(bagID, slotID) + local item = self:GetItemInfo(bagID, slotID) local button = self:GetButton(bagID, slotID) local container = self:GetContainerForItem(item, button) - if container then - if button then - if container ~= button.container then + if(container) then + if(button) then + if(container ~= button.container) then button.container:RemoveButton(button) container:AddButton(button) end @@ -385,7 +362,7 @@ function Implementation:UpdateSlot(bagID, slotID) end button:ButtonUpdate(item) - elseif button then + elseif(button) then button.container:RemoveButton(button) self:SetButton(bagID, slotID, nil) button:Free() @@ -400,7 +377,7 @@ local closed ]] function Implementation:UpdateBag(bagID) local numSlots - if closed then + if(closed) then numSlots, closed = 0 else numSlots = GetContainerNumSlots(bagID) @@ -408,12 +385,12 @@ function Implementation:UpdateBag(bagID) local lastSlots = self.bagSizes[bagID] or 0 self.bagSizes[bagID] = numSlots - for slotID = 1, numSlots do + for slotID=1, numSlots do self:UpdateSlot(bagID, slotID) end - for slotID = numSlots + 1, lastSlots do + for slotID=numSlots+1, lastSlots do local button = self:GetButton(bagID, slotID) - if button then + if(button) then button.container:RemoveButton(button) self:SetButton(bagID, slotID, nil) button:Free() @@ -428,16 +405,14 @@ end @callback Container:OnBagUpdate(bagID, slotID) ]] function Implementation:BAG_UPDATE(_, bagID, slotID) - if self.isSorting then - return - end + if self.isSorting then return end - if bagID and slotID then + if(bagID and slotID) then self:UpdateSlot(bagID, slotID) - elseif bagID then + elseif(bagID) then self:UpdateBag(bagID) else - for bagID = -3, 12 do + for bagID = -3, 17 do self:UpdateBag(bagID) end end @@ -457,18 +432,18 @@ end @param bagID [optional] ]] function Implementation:BAG_UPDATE_COOLDOWN(_, bagID) - if bagID then - for slotID = 1, GetContainerNumSlots(bagID) do + if(bagID) then + for slotID=1, GetContainerNumSlots(bagID) do local button = self:GetButton(bagID, slotID) - if button then - local item = self:GetCustomItemInfo(bagID, slotID) + if(button) then + local item = self:GetItemInfo(bagID, slotID) button:ButtonUpdateCooldown(item) end end else for _, container in pairs(self.contByID) do for _, button in pairs(container.buttons) do - local item = self:GetCustomItemInfo(button.bagId, button.slotId) + local item = self:GetItemInfo(button.bagId, button.slotId) button:ButtonUpdateCooldown(item) end end @@ -481,16 +456,12 @@ end @param slotID [optional] ]] function Implementation:ITEM_LOCK_CHANGED(_, bagID, slotID) - if self.isSorting then - return - end - if not slotID then - return - end + if self.isSorting then return end + if(not slotID) then return end local button = self:GetButton(bagID, slotID) - if button then - local item = self:GetCustomItemInfo(bagID, slotID) + if(button) then + local item = self:GetItemInfo(bagID, slotID) button:ButtonUpdateLock(item) end end @@ -501,7 +472,7 @@ end @param slotID [optional] ]] function Implementation:PLAYERBANKSLOTS_CHANGED(event, bagID, slotID) - if bagID <= NUM_BANKGENERIC_SLOTS then + if(bagID <= NUM_BANKGENERIC_SLOTS) then slotID = bagID bagID = -1 else @@ -528,8 +499,8 @@ end function Implementation:UNIT_QUEST_LOG_CHANGED() for _, container in pairs(self.contByID) do for _, button in pairs(container.buttons) do - local item = self:GetCustomItemInfo(button.bagId, button.slotId) + local item = self:GetItemInfo(button.bagId, button.slotId) button:ButtonUpdateQuest(item) end end -end +end \ No newline at end of file diff --git a/KkthnxUI/Libraries/cargBags/base/itembutton.lua b/KkthnxUI/Libraries/cargBags/base/itembutton.lua index 34ef7bea..127215b1 100644 --- a/KkthnxUI/Libraries/cargBags/base/itembutton.lua +++ b/KkthnxUI/Libraries/cargBags/base/itembutton.lua @@ -20,10 +20,18 @@ local _, ns = ... local cargBags = ns.cargBags -local ReagentButtonInventorySlot = ReagentButtonInventorySlot -local ButtonInventorySlot = ButtonInventorySlot +local _G = _G +local ReagentButtonInventorySlot = _G.ReagentButtonInventorySlot +local ButtonInventorySlot = _G.ButtonInventorySlot local BANK_CONTAINER = BANK_CONTAINER or -1 local REAGENTBANK_CONTAINER = REAGENTBANK_CONTAINER or -3 +local ACCOUNTBANK_CONTAINERS = { + [Enum.BagIndex.AccountBankTab_1 or 13] = true, + [Enum.BagIndex.AccountBankTab_2 or 14] = true, + [Enum.BagIndex.AccountBankTab_3 or 15] = true, + [Enum.BagIndex.AccountBankTab_4 or 16] = true, + [Enum.BagIndex.AccountBankTab_5 or 17] = true, +} local SplitContainerItem = C_Container.SplitContainerItem --[[! @@ -44,17 +52,13 @@ function ItemButton:GetTemplate(bagID) or (bagID and "ContainerFrameItemButtonTemplate") or "", (bagID == REAGENTBANK_CONTAINER and ReagentBankFrame) - or (bagID == BANK_CONTAINER and BankFrame) - or (bagID and _G["ContainerFrame" .. (bagID + 1)]) - or "" + or (bagID == BANK_CONTAINER and BankFrame) + or (bagID and _G["ContainerFrame"..(bagID + 1)]) + or (ACCOUNTBANK_CONTAINERS[bagID] and AccountBankPanel) + or "" end -local mt_gen_key = { - __index = function(self, k) - self[k] = {} - return self[k] - end, -} +local mt_gen_key = {__index = function(self,k) self[k] = {}; return self[k]; end} --[[! Fetches a new instance of the ItemButton, creating one if necessary @@ -109,31 +113,19 @@ function ItemButton:Create(tpl, parent) impl.numSlots = (impl.numSlots or 0) + 1 local name = ("%sSlot%d"):format(impl.name, impl.numSlots) - local button = setmetatable(CreateFrame("ItemButton", name, parent, tpl .. ", BackdropTemplate"), self.__index) + local button = setmetatable(CreateFrame("ItemButton", name, parent, tpl..", BackdropTemplate"), self.__index) - if button.Scaffold then - button:Scaffold(tpl) - end - if button.OnCreate then - button:OnCreate(tpl) - end + if(button.Scaffold) then button:Scaffold(tpl) end + if(button.OnCreate) then button:OnCreate(tpl) end - local btnNT = _G[button:GetName() .. "NormalTexture"] + local btnNT = _G[button:GetName().."NormalTexture"] local btnNIT = button.NewItemTexture local btnBIT = button.BattlepayItemTexture local btnICO = button.ItemContextOverlay - if btnNT then - btnNT:SetTexture("") - end - if btnNIT then - btnNIT:SetTexture("") - end - if btnBIT then - btnBIT:SetTexture("") - end - if btnICO then - btnICO:SetTexture("") - end + if btnNT then btnNT:SetTexture("") end + if btnNIT then btnNIT:SetTexture("") end + if btnBIT then btnBIT:SetTexture("") end + if btnICO then btnICO:SetTexture("") end button:RegisterForDrag("LeftButton") -- fix button drag in 9.0 @@ -154,5 +146,5 @@ end @return item
]] function ItemButton:GetInfo(item) - return self.implementation:GetCustomItemInfo(self.bagId, self.slotId, item) -end + return self.implementation:GetItemInfo(self.bagId, self.slotId, item) +end \ No newline at end of file diff --git a/KkthnxUI/Libraries/cargBags/cargBags.xml b/KkthnxUI/Libraries/cargBags/cargBags.xml index 5ce27225..a83dcd8d 100644 --- a/KkthnxUI/Libraries/cargBags/cargBags.xml +++ b/KkthnxUI/Libraries/cargBags/cargBags.xml @@ -60,6 +60,7 @@ All optional -->