Skip to content

Commit

Permalink
Framework update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Oct 18, 2024
1 parent 4735ead commit 690a082
Show file tree
Hide file tree
Showing 22 changed files with 1,980 additions and 773 deletions.
17 changes: 15 additions & 2 deletions Libs/DF/addon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ local addonLoaded = function(addonFrame, event, addonName)
addonObject.profile = profileTable

if (addonObject.OnLoad) then
detailsFramework:Dispatch(addonObject.OnLoad, addonObject, addonObject.profile)
detailsFramework:Dispatch(addonObject.OnLoad, addonObject, addonObject.profile, true)
end
end

Expand All @@ -65,7 +65,13 @@ end
--when the player logout or reloadUI
local addonUnload = function(addonFrame)
local addonObject = addonFrame.__addonObject
detailsFramework.SavedVars.SaveProfile(addonObject)
local bOkay, errortext = pcall(detailsFramework.SavedVars.SaveProfile, addonObject)
if (not bOkay) then
if (addonFrame.logoutLogs) then
table.insert(addonFrame.logoutLogs, 1, date("%a %b %d %H:%M:%S %Y") .. "|LOGOUT error:" .. errortext)
table.remove(addonFrame.logoutLogs, 3)
end
end
end

local addonEvents = {
Expand All @@ -90,6 +96,11 @@ detailsFramework.AddonMixin = {

}

--log erros during the save data
local setLogoutLogTable = function(addonObject, logTable)
addonObject.__frame.logoutLogs = logTable
end

---create an addon object
---@param addonName addonname
---@param globalSavedVariablesName string
Expand All @@ -115,6 +126,8 @@ function detailsFramework:CreateNewAddOn(addonName, globalSavedVariablesName, sa
addonFrame:RegisterEvent("PLAYER_LOGOUT")
addonFrame:SetScript("OnEvent", addonOnEvent)

newAddonObject.SetLogoutLogTable = setLogoutLogTable

return newAddonObject
end

Expand Down
76 changes: 55 additions & 21 deletions Libs/DF/auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -584,18 +584,35 @@ function DF:CreateAuraConfigPanel(parent, name, db, changeCallback, options, tex
debuffNameTracklistEntry:ClearFocus()

if (text ~= "") then
if (not tonumber(text)) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Invalid Spell-ID.")
end
if (text:find(";")) then
for _, spellName in ipairs({strsplit(";", text)}) do
spellName = strtrim(spellName)
if (not tonumber(spellName)) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Invalid Spell-ID: " .. (spellName or ""))
end

local spellId = getSpellIDFromSpellName(spellName)

--get the spellId
local spellId = getSpellIDFromSpellName(text)
if (not spellId) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Spell not found!")
return
end
if (spellId) then
newAuraPanel.db.aura_tracker.debuff_tracked [spellId] = false
else
DetailsFramework.Msg({__name = "DetailsFramework"}, "Spell not found: " .. (spellName or ""))
end
end
else
if (not tonumber(text)) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Invalid Spell-ID.")
end

newAuraPanel.db.aura_tracker.debuff_tracked [spellId] = false
--get the spellId
local spellId = getSpellIDFromSpellName(text)
if (not spellId) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Spell not found!")
return
end

newAuraPanel.db.aura_tracker.debuff_tracked [spellId] = false
end

--refresh the buff blacklist frame
newAuraPanel.debuff_tracked:Refresh()
Expand Down Expand Up @@ -635,19 +652,36 @@ function DF:CreateAuraConfigPanel(parent, name, db, changeCallback, options, tex
buffNameTracklistEntry:ClearFocus()

if (text ~= "") then
if (not tonumber(text)) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Invalid Spell-ID.")
end
if (text:find(";")) then
for _, spellName in ipairs({strsplit(";", text)}) do
spellName = strtrim(spellName)
if (not tonumber(spellName)) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Invalid Spell-ID: " .. (spellName or ""))
end

local spellId = getSpellIDFromSpellName(spellName)

--get the spellId
local spellId = getSpellIDFromSpellName(text)
if (not spellId) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Spell not found!")
return
end
if (spellId) then
newAuraPanel.db.aura_tracker.buff_tracked [spellId] = false
else
DetailsFramework.Msg({__name = "DetailsFramework"}, "Spell not found: " .. (spellName or ""))
end
end
else
if (not tonumber(text)) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Invalid Spell-ID.")
end

--add the spellId to the tracklist
newAuraPanel.db.aura_tracker.buff_tracked [spellId] = false
--get the spellId
local spellId = getSpellIDFromSpellName(text)
if (not spellId) then
DetailsFramework.Msg({__name = "DetailsFramework"}, "Spell not found!")
return
end

--add the spellId to the tracklist
newAuraPanel.db.aura_tracker.buff_tracked [spellId] = false
end

--refresh the buff tracklist frame
newAuraPanel.buff_tracked:Refresh()
Expand Down
63 changes: 57 additions & 6 deletions Libs/DF/button.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

--[=[
callback format:
function(button, clickType, param1, param2)
end
--]=]

local detailsFramework = _G["DetailsFramework"]

if (not detailsFramework or not DetailsFrameworkCanLoad) then
Expand Down Expand Up @@ -304,6 +311,15 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
end
end

function ButtonMetaFunctions:SetParameters(param1, param2)
if (param1 ~= nil) then
rawset(self, "param1", param1)
end
if (param2 ~= nil) then
rawset(self, "param2", param2)
end
end

---set the text shown on the button
---@param text string
function ButtonMetaFunctions:SetText(text)
Expand Down Expand Up @@ -493,7 +509,6 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
---enable the button making it clickable and not grayed out
---@return unknown
function ButtonMetaFunctions:Enable()

return self.button:Enable()
end

Expand All @@ -506,6 +521,15 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
return self.button:Disable()
end

---@param enable boolean
function ButtonMetaFunctions:SetEnabled(enable)
if (enable) then
self:Enable()
else
self:Disable()
end
end

---simulate a click on the button
function ButtonMetaFunctions:Exec()
local frameWidget = self.widget
Expand Down Expand Up @@ -692,7 +716,7 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
if (object.is_mouse_over) then
button.texture:SetTexCoord(unpack(button.texture.coords.Highlight))
else
button.texture:SetTexCoord(unpack(coords.Normal))
--button.texture:SetTexCoord(unpack(coords.Normal))
end
else
if (object.is_mouse_over) then
Expand Down Expand Up @@ -895,6 +919,7 @@ end
---@field Exec fun(self: df_button) execute the button function for the left button
---@field Disable fun(self: df_button) disable the button
---@field Enable fun(self: df_button) enable the button
---@field SetEnabled fun(self: df_button, enable: boolean) enable or disable the button
---@field IsEnabled fun(self: df_button) : boolean returns true if the button is enabled
---@field SetIcon fun(self: df_button,texture: string|number, width: number|nil, height: number|nil, layout: string|nil, texcoord: table|nil, overlay: table|nil, textDistance: number|nil, leftPadding: number|nil, textHeight: number|nil, shortMethod: any|nil)
---@field GetIconTexture fun(self: df_button) : string returns the texture path of the button icon
Expand All @@ -904,6 +929,7 @@ end
---@field SetTextColor fun(self: df_button, color: any) set the button text color
---@field SetText fun(self: df_button, text: string) set the button text
---@field SetTextTruncated fun(self: df_button, text: string, maxWidth: number) set the button text and truncate it if it's too long
---@field SetParameters fun(self: df_button, param1: any, param2: any) set the parameters for the button callback function
---@field SetClickFunction fun(self: df_button, func: function, param1: any, param2: any, clickType: "left"|"right"|nil)
---@field SetIconFilterMode fun(self: df_button, filterMode: any) set the filter mode for the icon, execute after SetIcon()

Expand Down Expand Up @@ -983,11 +1009,36 @@ end
buttonObject.text_overlay = _G[name .. "_Text"]
buttonObject.disabled_overlay = _G[name .. "_TextureDisabled"]

--check for atlas
texture = texture or ""
buttonObject.button:SetNormalTexture(texture)
buttonObject.button:SetPushedTexture(texture)
buttonObject.button:SetDisabledTexture(texture)
buttonObject.button:SetHighlightTexture(texture, "ADD")

local bSetTexture = false
if (type(texture) == "string") then
local isAtlas = C_Texture.GetAtlasInfo(texture)
if (isAtlas) then
buttonObject.button:SetNormalTexture("")
buttonObject.button:GetNormalTexture():SetAtlas(texture)
buttonObject.button:SetPushedTexture("")
buttonObject.button:GetPushedTexture():SetAtlas(texture)
buttonObject.button:SetDisabledTexture("")
buttonObject.button:GetDisabledTexture():SetAtlas(texture)
buttonObject.button:SetHighlightTexture("")
buttonObject.button:GetHighlightTexture():SetAtlas(texture)
bSetTexture = true

elseif (detailsFramework:IsHtmlColor(texture)) then
local r, g, b, a = detailsFramework:ParseColors(texture)
self.icon:SetColorTexture(r, g, b, a)
bSetTexture = true
end
end

if (not bSetTexture) then
buttonObject.button:SetNormalTexture(texture)
buttonObject.button:SetPushedTexture(texture)
buttonObject.button:SetDisabledTexture(texture)
buttonObject.button:SetHighlightTexture(texture, "ADD")
end

local locTable = text
detailsFramework.Language.SetTextWithLocTableWithDefault(buttonObject.button.text, locTable, text)
Expand Down
Loading

0 comments on commit 690a082

Please sign in to comment.