Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Kkthnx committed Aug 15, 2024
1 parent 602071c commit 319c1fb
Show file tree
Hide file tree
Showing 62 changed files with 980 additions and 856 deletions.
10 changes: 5 additions & 5 deletions KkthnxUI/Config/AuraWatchGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions KkthnxUI/Config/Elements/FilterLists/AuraWatchSpells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions KkthnxUI/Config/Elements/FilterLists/BadBuffs.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions KkthnxUI/Developer/Elements/Frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
31 changes: 2 additions & 29 deletions KkthnxUI/Init.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ local Container = cargBags.classes.Container
@param bags <BagType>
]]
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
Expand Down
30 changes: 12 additions & 18 deletions KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

--[[!
Expand All @@ -73,7 +67,7 @@ end
@param flag <bool> 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

Expand All @@ -87,7 +81,7 @@ end
@param ... <function> 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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, ...)
Expand All @@ -169,4 +163,4 @@ function Container:FilterForFunction(func, filters)
local result = filters:Check(button:GetInfo())
func(button, result)
end
end
end
44 changes: 15 additions & 29 deletions KkthnxUI/Libraries/cargBags/base/container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,21 +41,19 @@ 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?
table.insert(container.implementation.contByID, container)

container:SetParent(self.implementation)

if container.OnCreate then
container:OnCreate(name, ...)
end
if(container.OnCreate) then container:OnCreate(name, ...) end

return container
end
Expand All @@ -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

--[[!
Expand All @@ -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
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 319c1fb

Please sign in to comment.