main
JeffyLikesApples 11 months ago
parent c4b8c781bc
commit 8f93bae7a9
  1. 340
      DiesalComm-1.0/DiesalComm-1.0.lua
  2. 1
      DiesalGUI-2.0/Objects/Branch.lua
  3. 2
      DiesalGUI-2.0/Objects/ComboBoxItem.lua
  4. 4
      DiesalGUI-2.0/Objects/ObjectBase.lua
  5. 3
      DiesalMenu-2.0/Objects/MenuItem.lua
  6. 172
      DiesalStyle-2.0/DiesalStyle-2.0.lua

@ -1,8 +1,9 @@
---@diagnostic disable: inject-field, undefined-field, undefined-global
--- allows you to send messages of unlimited length over the addon comm channels. --- allows you to send messages of unlimited length over the addon comm channels.
-- It'll automatically split the messages into multiple parts and rebuild them on the receiving end.\\ -- It'll automatically split the messages into multiple parts and rebuild them on the receiving end.\\
-- **ChatThrottleLib** is of course being used to avoid being disconnected by the server. -- **ChatThrottleLib** is of course being used to avoid being disconnected by the server.
-- **DiesalComm** can be embeded into your addon, either explicitly by calling DiesalComm:Embed(MyAddon) or by -- **DiesalComm** can be embeded into your addon, either explicitly by calling DiesalComm:Embed(MyAddon) or by
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
-- and can be accessed directly, without having to explicitly call AceComm itself.\\ -- and can be accessed directly, without having to explicitly call AceComm itself.\\
-- It is recommended to embed AceComm, otherwise you'll have to specify a custom `self` on all calls you -- It is recommended to embed AceComm, otherwise you'll have to specify a custom `self` on all calls you
@ -15,7 +16,9 @@
-- ~~| Initialize library |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~| Initialize library |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local MAJOR, MINOR = "DiesalComm-1.0", 1 local MAJOR, MINOR = "DiesalComm-1.0", 1
local DiesalComm, oldminor = LibStub:NewLibrary(MAJOR, MINOR) local DiesalComm, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not DiesalComm then return end if not DiesalComm then
return
end
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0") local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
local CTL = assert(ChatThrottleLib, "DiesalComm-1.0 requires ChatThrottleLib") local CTL = assert(ChatThrottleLib, "DiesalComm-1.0 requires ChatThrottleLib")
@ -28,45 +31,42 @@ local error, assert = error, assert
-- ~~| WoW Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~| WoW Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Ambiguate = Ambiguate local Ambiguate = Ambiguate
-- ~~| DiesalComm Values |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~| DiesalComm Values |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DiesalComm.embeds = DiesalComm.embeds or {} DiesalComm.embeds = DiesalComm.embeds or {}
DiesalComm.msg_spool = DiesalComm.msg_spool or {} DiesalComm.msg_spool = DiesalComm.msg_spool or {}
local COMM_MODES = {'single','first','next','last'} local COMM_MODES = { "single", "first", "next", "last" }
local HEADER_SIZE = 14 local HEADER_SIZE = 14
local HEADER_FORMAT = '%[%x%x:%x%x%x%x:%x%x%x%x%]' local HEADER_FORMAT = "%[%x%x:%x%x%x%x:%x%x%x%x%]"
local MAX_CHUNK_SIZE = 240 local MAX_CHUNK_SIZE = 240
--- Register for Addon Traffic on a specified prefix --- Register for Addon Traffic on a specified prefix
-- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent), max 16 characters -- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent), max 16 characters
-- @param method Callback to call on message reception: Function reference, or method name (string) to call on self. Defaults to "OnCommReceived" -- @param method Callback to call on message reception: Function reference, or method name (string) to call on self. Defaults to "OnCommReceived"
function DiesalComm:RegisterComm(prefix, method) function DiesalComm:RegisterComm(prefix, method)
if method == nil then method = "OnCommReceived" end if method == nil then
if #prefix > 15 then error("AceComm:RegisterComm(prefix,method): prefix length is limited to 15 characters") end method = "OnCommReceived"
RegisterAddonMessagePrefix(prefix) end
if #prefix > 15 then
return DiesalComm.RegisterCallback(self, prefix, method) error("AceComm:RegisterComm(prefix,method): prefix length is limited to 15 characters")
end
RegisterAddonMessagePrefix(prefix)
return DiesalComm.RegisterCallback(self, prefix, method)
end end
local function formatValue(num, len)
num = format("%X", num)
local function formatValue(num,len) for i = 1, len - #num do
num = format('%X',num) num = "0" .. num
for i = 1, len - #num do end
num = "0"..num return num
end
return num
end end
local function encodeHeader(mode, chunk, totalChunks)
local function encodeHeader(mode, chunk ,totalChunks ) return "[" .. formatValue(mode, 2) .. ":" .. formatValue(chunk, 4) .. ":" .. formatValue(totalChunks, 4) .. "]"
return '['..formatValue(mode,2)..':'..formatValue(chunk,4)..':'..formatValue(totalChunks,4)..']'
end
local function decodeHeader()
end end
local function decodeHeader() end
--- Send a message over the Addon Channel --- Send a message over the Addon Channel
-- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent) -- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent)
@ -77,164 +77,161 @@ end
-- @param callbackArg: OPTIONAL: first arg to the callback function. nil will be passed if not specified. -- @param callbackArg: OPTIONAL: first arg to the callback function. nil will be passed if not specified.
-- @param prio OPTIONAL: ChatThrottleLib priority, "BULK", "NORMAL" or "ALERT". Defaults to "NORMAL". -- @param prio OPTIONAL: ChatThrottleLib priority, "BULK", "NORMAL" or "ALERT". Defaults to "NORMAL".
function AceComm:SendCommMessage(prefix, text, channel, target, callbackFn, callbackArg, prio) function AceComm:SendCommMessage(prefix, text, channel, target, callbackFn, callbackArg, prio)
prio = prio or "NORMAL" prio = prio or "NORMAL"
if type(prefix)~="string" and type(text)~="string" and type(channel)~="string" and (target==nil or type(target)~="string") and (prio~="BULK" or prio~="NORMAL" or prio~="ALERT") then if
error('Usage: SendCommMessage(addon, "prefix", "text", "channel"[, "target"[, callbackFn, callbackarg[, "prio"]]])', 2) type(prefix) ~= "string"
end and type(text) ~= "string"
and type(channel) ~= "string"
local textlen = #text and (target == nil or type(target) ~= "string")
local ctlCallback = callbackFn and function(sent) return callbackFn(callbackArg, sent, textlen) end or nil and (prio ~= "BULK" or prio ~= "NORMAL" or prio ~= "ALERT")
then
error('Usage: SendCommMessage(addon, "prefix", "text", "channel"[, "target"[, callbackFn, callbackarg[, "prio"]]])', 2)
end
if textlen <= MAX_CHUNK_SIZE then -- fits all in one message
text = '[0:0000:0000]'..text local textlen = #text
CTL:SendAddonMessage(prio, prefix, text, channel, target, nil, ctlCallback, textlen) local ctlCallback = callbackFn and function(sent)
else return callbackFn(callbackArg, sent, textlen)
-- first part end or nil
local chunk = strsub(text, 1, maxtextlen)
CTL:SendAddonMessage(prio, prefix, MSG_MULTI_FIRST..chunk, distribution, target, queueName, ctlCallback, maxtextlen) if textlen <= MAX_CHUNK_SIZE then -- fits all in one message
text = "[0:0000:0000]" .. text
-- continuation CTL:SendAddonMessage(prio, prefix, text, channel, target, nil, ctlCallback, textlen)
local pos = 1+maxtextlen else
-- first part
while pos+maxtextlen <= textlen do local chunk = strsub(text, 1, maxtextlen)
chunk = strsub(text, pos, pos+maxtextlen-1) CTL:SendAddonMessage(prio, prefix, MSG_MULTI_FIRST .. chunk, distribution, target, queueName, ctlCallback, maxtextlen)
CTL:SendAddonMessage(prio, prefix, MSG_MULTI_NEXT..chunk, distribution, target, queueName, ctlCallback, pos+maxtextlen-1)
pos = pos + maxtextlen -- continuation
end local pos = 1 + maxtextlen
-- final part while pos + maxtextlen <= textlen do
chunk = strsub(text, pos) chunk = strsub(text, pos, pos + maxtextlen - 1)
CTL:SendAddonMessage(prio, prefix, MSG_MULTI_LAST..chunk, distribution, target, queueName, ctlCallback, textlen) CTL:SendAddonMessage(prio, prefix, MSG_MULTI_NEXT .. chunk, distribution, target, queueName, ctlCallback, pos + maxtextlen - 1)
end pos = pos + maxtextlen
end
-- final part
chunk = strsub(text, pos)
CTL:SendAddonMessage(prio, prefix, MSG_MULTI_LAST .. chunk, distribution, target, queueName, ctlCallback, textlen)
end
end end
---------------------------------------- ----------------------------------------
-- Message receiving -- Message receiving
---------------------------------------- ----------------------------------------
do do
local compost = setmetatable({}, {__mode = "k"}) local compost = setmetatable({}, { __mode = "k" })
local function new() local function new()
local t = next(compost) local t = next(compost)
if t then if t then
compost[t]=nil compost[t] = nil
for i=#t,3,-1 do -- faster than pairs loop. don't even nil out 1/2 since they'll be overwritten for i = #t, 3, -1 do -- faster than pairs loop. don't even nil out 1/2 since they'll be overwritten
t[i]=nil t[i] = nil
end end
return t return t
end end
return {} return {}
end end
local function lostdatawarning(prefix,sender,where) local function lostdatawarning(prefix, sender, where)
DEFAULT_CHAT_FRAME:AddMessage(MAJOR..": Warning: lost network data regarding '"..tostring(prefix).."' from '"..tostring(sender).."' (in "..where..")") DEFAULT_CHAT_FRAME:AddMessage(MAJOR .. ": Warning: lost network data regarding '" .. tostring(prefix) .. "' from '" .. tostring(sender) .. "' (in " .. where .. ")")
end end
function AceComm:OnReceiveMultipartFirst(prefix, message, distribution, sender) function AceComm:OnReceiveMultipartFirst(prefix, message, distribution, sender)
local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender local key = prefix .. "\t" .. distribution .. "\t" .. sender -- a unique stream is defined by the prefix + distribution + sender
local spool = AceComm.multipart_spool local spool = AceComm.multipart_spool
--[[ --[[
if spool[key] then if spool[key] then
lostdatawarning(prefix,sender,"First") lostdatawarning(prefix,sender,"First")
-- continue and overwrite -- continue and overwrite
end end
--]] --]]
spool[key] = message -- plain string for now
end
function AceComm:OnReceiveMultipartNext(prefix, message, distribution, sender)
local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
local spool = AceComm.multipart_spool
local olddata = spool[key]
if not olddata then
--lostdatawarning(prefix,sender,"Next")
return
end
if type(olddata)~="table" then spool[key] = message -- plain string for now
-- ... but what we have is not a table. So make it one. (Pull a composted one if available) end
local t = new()
t[1] = olddata -- add old data as first string function AceComm:OnReceiveMultipartNext(prefix, message, distribution, sender)
t[2] = message -- and new message as second string local key = prefix .. "\t" .. distribution .. "\t" .. sender -- a unique stream is defined by the prefix + distribution + sender
spool[key] = t -- and put the table in the spool instead of the old string local spool = AceComm.multipart_spool
else local olddata = spool[key]
tinsert(olddata, message)
end if not olddata then
end --lostdatawarning(prefix,sender,"Next")
return
function AceComm:OnReceiveMultipartLast(prefix, message, distribution, sender) end
local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
local spool = AceComm.multipart_spool if type(olddata) ~= "table" then
local olddata = spool[key] -- ... but what we have is not a table. So make it one. (Pull a composted one if available)
local t = new()
if not olddata then t[1] = olddata -- add old data as first string
--lostdatawarning(prefix,sender,"End") t[2] = message -- and new message as second string
return spool[key] = t -- and put the table in the spool instead of the old string
end else
tinsert(olddata, message)
spool[key] = nil end
end
if type(olddata) == "table" then
-- if we've received a "next", the spooled data will be a table for rapid & garbage-free tconcat function AceComm:OnReceiveMultipartLast(prefix, message, distribution, sender)
tinsert(olddata, message) local key = prefix .. "\t" .. distribution .. "\t" .. sender -- a unique stream is defined by the prefix + distribution + sender
AceComm.callbacks:Fire(prefix, tconcat(olddata, ""), distribution, sender) local spool = AceComm.multipart_spool
compost[olddata] = true local olddata = spool[key]
else
-- if we've only received a "first", the spooled data will still only be a string if not olddata then
AceComm.callbacks:Fire(prefix, olddata..message, distribution, sender) --lostdatawarning(prefix,sender,"End")
end return
end end
spool[key] = nil
if type(olddata) == "table" then
-- if we've received a "next", the spooled data will be a table for rapid & garbage-free tconcat
tinsert(olddata, message)
AceComm.callbacks:Fire(prefix, tconcat(olddata, ""), distribution, sender)
compost[olddata] = true
else
-- if we've only received a "first", the spooled data will still only be a string
AceComm.callbacks:Fire(prefix, olddata .. message, distribution, sender)
end
end
end end
---------------------------------------- ----------------------------------------
-- Embed CallbackHandler -- Embed CallbackHandler
---------------------------------------- ----------------------------------------
if not AceComm.callbacks then if not AceComm.callbacks then
AceComm.callbacks = CallbackHandler:New(AceComm, AceComm.callbacks = CallbackHandler:New(AceComm, "_RegisterComm", "UnregisterComm", "UnregisterAllComm")
"_RegisterComm",
"UnregisterComm",
"UnregisterAllComm")
end end
AceComm.callbacks.OnUsed = nil AceComm.callbacks.OnUsed = nil
AceComm.callbacks.OnUnused = nil AceComm.callbacks.OnUnused = nil
local function OnEvent(self, event, prefix, message, distribution, sender) local function OnEvent(self, event, prefix, message, distribution, sender)
if event == "CHAT_MSG_ADDON" then if event == "CHAT_MSG_ADDON" then
sender = Ambiguate(sender, "none") sender = Ambiguate(sender, "none")
local control, rest = match(message, "^([\001-\009])(.*)") local control, rest = match(message, "^([\001-\009])(.*)")
if control then if control then
if control==MSG_MULTI_FIRST then if control == MSG_MULTI_FIRST then
AceComm:OnReceiveMultipartFirst(prefix, rest, distribution, sender) AceComm:OnReceiveMultipartFirst(prefix, rest, distribution, sender)
elseif control==MSG_MULTI_NEXT then elseif control == MSG_MULTI_NEXT then
AceComm:OnReceiveMultipartNext(prefix, rest, distribution, sender) AceComm:OnReceiveMultipartNext(prefix, rest, distribution, sender)
elseif control==MSG_MULTI_LAST then elseif control == MSG_MULTI_LAST then
AceComm:OnReceiveMultipartLast(prefix, rest, distribution, sender) AceComm:OnReceiveMultipartLast(prefix, rest, distribution, sender)
elseif control==MSG_ESCAPE then elseif control == MSG_ESCAPE then
AceComm.callbacks:Fire(prefix, rest, distribution, sender) AceComm.callbacks:Fire(prefix, rest, distribution, sender)
else else
-- unknown control character, ignore SILENTLY (dont warn unnecessarily about future extensions!) -- unknown control character, ignore SILENTLY (dont warn unnecessarily about future extensions!)
end end
else else
-- single part: fire it off immediately and let CallbackHandler decide if it's registered or not -- single part: fire it off immediately and let CallbackHandler decide if it's registered or not
AceComm.callbacks:Fire(prefix, message, distribution, sender) AceComm.callbacks:Fire(prefix, message, distribution, sender)
end end
else else
assert(false, "Received "..tostring(event).." event?!") assert(false, "Received " .. tostring(event) .. " event?!")
end end
end end
AceComm.frame = AceComm.frame or CreateFrame("Frame", "AceComm30Frame") AceComm.frame = AceComm.frame or CreateFrame("Frame", "AceComm30Frame")
@ -242,33 +239,32 @@ AceComm.frame:SetScript("OnEvent", OnEvent)
AceComm.frame:UnregisterAllEvents() AceComm.frame:UnregisterAllEvents()
AceComm.frame:RegisterEvent("CHAT_MSG_ADDON") AceComm.frame:RegisterEvent("CHAT_MSG_ADDON")
---------------------------------------- ----------------------------------------
-- Base library stuff -- Base library stuff
---------------------------------------- ----------------------------------------
local mixins = { local mixins = {
"RegisterComm", "RegisterComm",
"UnregisterComm", "UnregisterComm",
"UnregisterAllComm", "UnregisterAllComm",
"SendCommMessage", "SendCommMessage",
} }
-- Embeds AceComm-3.0 into the target object making the functions from the mixins list available on target:.. -- Embeds AceComm-3.0 into the target object making the functions from the mixins list available on target:..
-- @param target target object to embed AceComm-3.0 in -- @param target target object to embed AceComm-3.0 in
function AceComm:Embed(target) function AceComm:Embed(target)
for k, v in pairs(mixins) do for k, v in pairs(mixins) do
target[v] = self[v] target[v] = self[v]
end end
self.embeds[target] = true self.embeds[target] = true
return target return target
end end
function AceComm:OnEmbedDisable(target) function AceComm:OnEmbedDisable(target)
target:UnregisterAllComm() target:UnregisterAllComm()
end end
-- Update embeds -- Update embeds
for target, v in pairs(AceComm.embeds) do for target, v in pairs(AceComm.embeds) do
AceComm:Embed(target) AceComm:Embed(target)
end end

@ -312,6 +312,7 @@ local function Constructor()
local icon = self:CreateRegion("Texture", "icon", button) local icon = self:CreateRegion("Texture", "icon", button)
DiesalStyle:StyleTexture(icon, { DiesalStyle:StyleTexture(icon, {
type = "texture",
position = { 0, nil, 2, nil }, position = { 0, nil, 2, nil },
height = 16, height = 16,
width = 16, width = 16,

@ -116,7 +116,6 @@ local function Constructor()
frame:SetScript("OnEnter", function(this) end) frame:SetScript("OnEnter", function(this) end)
frame:SetScript("OnLeave", function(this) end) frame:SetScript("OnLeave", function(this) end)
---@type Diesal.GUI.Region.FontString
local text = self:CreateRegion("FontString", "text", frame) local text = self:CreateRegion("FontString", "text", frame)
text:SetPoint("TOPLEFT", 12, -2) text:SetPoint("TOPLEFT", 12, -2)
text:SetPoint("BOTTOMRIGHT", 0, 0) text:SetPoint("BOTTOMRIGHT", 0, 0)
@ -126,6 +125,7 @@ local function Constructor()
local check = self:CreateRegion("Texture", "check", frame) --[[ @as Texture ]] local check = self:CreateRegion("Texture", "check", frame) --[[ @as Texture ]]
DiesalStyle:StyleTexture(check, { DiesalStyle:StyleTexture(check, {
type = "texture",
position = { 2, nil, 0, nil }, position = { 2, nil, 0, nil },
height = 16, height = 16,
width = 16, width = 16,

@ -170,7 +170,7 @@ local ObjectBase = {
---@return RT ---@return RT
CreateRegion = function(self, regionType, regionName, parentRegion, defaultFontObject, ...) CreateRegion = function(self, regionType, regionName, parentRegion, defaultFontObject, ...)
if regionType == "FontString" then if regionType == "FontString" then
---@type Diesal.GUI.Region.FontString ---@class Diesal.GUI.Region.FontString
local fontString = parentRegion:CreateFontString() local fontString = parentRegion:CreateFontString()
fontString.defaultFontObject = defaultFontObject or _G.DiesalFontNormal fontString.defaultFontObject = defaultFontObject or _G.DiesalFontNormal
fontString:SetFont(fontString.defaultFontObject:GetFont()) fontString:SetFont(fontString.defaultFontObject:GetFont())
@ -434,7 +434,7 @@ DiesalGUI.ObjectBase = ObjectBase
---@class Diesal.GUI.ObjectBase.Settings ---@class Diesal.GUI.ObjectBase.Settings
---@field parent Frame ---@field parent Frame
---@field parentObject Diesal.Object ---@field parentObject Diesal.Object?
---@field height number ---@field height number
---@field width number ---@field width number

@ -120,6 +120,7 @@ local methods = {
subMenu:Show() subMenu:Show()
end, end,
} }
---@alias DiesalMenuItem Diesal.Menu.MenuItem
-- | Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- | Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local function Constructor() local function Constructor()
---@class Diesal.Menu.MenuItem : Diesal.GUI.ObjectBase ---@class Diesal.Menu.MenuItem : Diesal.GUI.ObjectBase
@ -162,6 +163,7 @@ local function Constructor()
local check = self:CreateRegion("Texture", "check", frame) local check = self:CreateRegion("Texture", "check", frame)
DiesalStyle:StyleTexture(check, { DiesalStyle:StyleTexture(check, {
type = "texture",
position = { 1, nil, 0, nil }, position = { 1, nil, 0, nil },
height = 16, height = 16,
width = 16, width = 16,
@ -169,6 +171,7 @@ local function Constructor()
}) })
local arrow = self:CreateRegion("Texture", "arrow", frame) local arrow = self:CreateRegion("Texture", "arrow", frame)
DiesalStyle:StyleTexture(arrow, { DiesalStyle:StyleTexture(arrow, {
type = "texture",
position = { nil, 2, -1, nil }, position = { nil, 2, -1, nil },
height = 16, height = 16,
width = 16, width = 16,

@ -34,6 +34,7 @@ DiesalStyle.Formatters = DiesalStyle.Formatters or {}
-- ~~| DiesalStyle UpValues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~| DiesalStyle UpValues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local AddonName = ... local AddonName = ...
---@type table<Diesal.Style.Texture, boolean>
local ReleasedTextures = DiesalStyle.ReleasedTextures local ReleasedTextures = DiesalStyle.ReleasedTextures
local TextureFrame = DiesalStyle.TextureFrame local TextureFrame = DiesalStyle.TextureFrame
local Media = DiesalStyle.Media local Media = DiesalStyle.Media
@ -42,6 +43,7 @@ local Formatters = DiesalStyle.Formatters
-- ~~| Locals |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~| Locals |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local OUTLINES = { "_LEFT", "_RIGHT", "_TOP", "_BOTTOM" } local OUTLINES = { "_LEFT", "_RIGHT", "_TOP", "_BOTTOM" }
---@diagnostic disable-next-line: undefined-global
local MEDIA_PATH = MEDIA_PATH local MEDIA_PATH = MEDIA_PATH
or type(AddonName) == "table" and string.format("Interface\\AddOns\\Media\\") or type(AddonName) == "table" and string.format("Interface\\AddOns\\Media\\")
or AddonName == "DiesalLibs" and string.format("Interface\\AddOns\\%s\\%s\\Media\\", AddonName, MAJOR) or AddonName == "DiesalLibs" and string.format("Interface\\AddOns\\%s\\%s\\Media\\", AddonName, MAJOR)
@ -70,14 +72,14 @@ local function getMedia(mediaType, name)
end end
local function newTexture() local function newTexture()
local newTexture = next(ReleasedTextures) local nt = next(ReleasedTextures)
if not newTexture then if not nt then
newTexture = TextureFrame:CreateTexture() nt = TextureFrame:CreateTexture() --[[@as Diesal.Style.Texture]]
else else
newTexture:Show() nt:Show()
ReleasedTextures[newTexture] = nil ReleasedTextures[nt] = nil
end end
return newTexture return nt
end end
local function releaseTexture(texture) local function releaseTexture(texture)
@ -114,8 +116,7 @@ local function GetBlizzColorValues(value)
if type(value) == "table" and #value >= 3 then if type(value) == "table" and #value >= 3 then
return value[1] / 255, value[2] / 255, value[3] / 255 return value[1] / 255, value[2] / 255, value[3] / 255
elseif type(value) == "string" then elseif type(value) == "string" then
return tonumber(sub(value, 1, 2), 16) / 255, tonumber(sub(value, 3, 4), 16) / 255, return tonumber(sub(value, 1, 2), 16) / 255, tonumber(sub(value, 3, 4), 16) / 255, tonumber(sub(value, 5, 6), 16) / 255
tonumber(sub(value, 5, 6), 16) / 255
end end
end end
@ -177,22 +178,17 @@ end
local function setColor(texture, r, g, b, a) local function setColor(texture, r, g, b, a)
local status, err = pcall(texture.SetColorTexture, texture, r, g, b, a) local status, err = pcall(texture.SetColorTexture, texture, r, g, b, a)
if not status then if not status then
errorhandler( errorhandler('error in "' .. (texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting", r, g, b, a)
'error in "' .. (texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting", r, g,
b,
a)
end end
end end
local function setGradient(texture, orientation, r1, g1, b1, a1, r2, g2, b2, a2) local function setGradient(texture, orientation, r1, g1, b1, a1, r2, g2, b2, a2)
local status, err = pcall(texture.SetGradient, texture, orientation, CreateColor(r1, g1, b1, a1), local status, err = pcall(texture.SetGradient, texture, orientation, CreateColor(r1, g1, b1, a1), CreateColor(r2, g2, b2, a2))
CreateColor(r2, g2, b2, a2))
if not status then if not status then
errorhandler('error in "' .. errorhandler('error in "' .. (texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting.")
(texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting.")
end end
end end
-- ~~| Media |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~| Media |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
do -- google material colors do -- google material colors
Colors.red_50 = "fde0dc" Colors.red_50 = "fde0dc"
Colors.red_100 = "f9bdbb" Colors.red_100 = "f9bdbb"
@ -462,24 +458,18 @@ do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Colors.UI_200 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.07) Colors.UI_200 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.07)
-- level 3 -- level 3
Colors.UI_300 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.12) Colors.UI_300 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.12)
Colors.UI_300_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.12), HSL(Colors.UI_Hue, Colors.UI_Saturation, Colors.UI_300_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.12), HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.11) }
0.11) }
Colors.UI_350 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.15) Colors.UI_350 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.15)
Colors.UI_350_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.17), HSL(Colors.UI_Hue, Colors.UI_Saturation, Colors.UI_350_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.17), HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.14) }
0.14) }
-- level 4 -- level 4
Colors.UI_400 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.20) Colors.UI_400 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.20)
Colors.UI_400_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.20), HSL(Colors.UI_Hue, Colors.UI_Saturation, Colors.UI_400_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.20), HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.17) }
0.17) } Colors.UI_450_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.24), HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.20) }
Colors.UI_450_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.24), HSL(Colors.UI_Hue, Colors.UI_Saturation,
0.20) }
-- level 5 -- level 5
Colors.UI_500 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.29) Colors.UI_500 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.29)
Colors.UI_500_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.29), HSL(Colors.UI_Hue, Colors.UI_Saturation, Colors.UI_500_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.29), HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.26) }
0.26) }
Colors.UI_600_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.35), HSL(Colors.UI_Hue, Colors.UI_Saturation, Colors.UI_600_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.35), HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.32) }
0.32) }
-- font Colors -35 -- font Colors -35
Colors.UI_F450 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.75) Colors.UI_F450 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.75)
@ -4152,9 +4142,7 @@ do -- Set Material Icons
end end
---@param iconName string ---@param iconName string
---@param iconType? "regular" | "outlined" | "round" | "sharp" | "twotone" function DiesalStyle.MaterialIcon(iconName)
function DiesalStyle.MaterialIcon(iconName, iconType)
iconType = iconType or "regular"
if MaterialIcons.bytes[iconName] then if MaterialIcons.bytes[iconName] then
return utf8(MaterialIcons.bytes[iconName]) return utf8(MaterialIcons.bytes[iconName])
end end
@ -4200,10 +4188,8 @@ do -- Set Icons
---@param key string ---@param key string
---@param table table ---@param table table
local function checkType(prefix, key, table) local function checkType(prefix, key, table)
assert(type(key) == "string", assert(type(key) == "string", string.format("key %d for %s not a string.", prefixInfo[prefix].count, prefixInfo[prefix].prefix))
string.format("key %d for %s not a string.", prefixInfo[prefix].count, prefixInfo[prefix].prefix)) assert(type(table) == "table", string.format("value %d for %s is not a table.", prefixInfo[prefix].count, prefixInfo[prefix].prefix))
assert(type(table) == "table",
string.format("value %d for %s is not a table.", prefixInfo[prefix].count, prefixInfo[prefix].prefix))
end end
for p1, p1Table in pairs(iconsToAdd) do for p1, p1Table in pairs(iconsToAdd) do
@ -4217,21 +4203,15 @@ do -- Set Icons
local filePrefixes = string.format("%s%s%s", p1, p2, p3) local filePrefixes = string.format("%s%s%s", p1, p2, p3)
Icons[p1][p2][p3] = Icons[p1][p2][p3] or {} Icons[p1][p2][p3] = Icons[p1][p2][p3] or {}
for iconSize, fileDimTable in pairs(p3Table) do for iconSize, fileDimTable in pairs(p3Table) do
assert(type(iconSize) == "number", assert(type(iconSize) == "number", string.format("icon size key %d for %s is not a number.", prefixInfo[3].iconSize, filePrefixes))
string.format("icon size key %d for %s is not a number.", prefixInfo[3].iconSize,
filePrefixes))
filePrefixes = string.format("%s[%d]", filePrefixes, iconSize) filePrefixes = string.format("%s[%d]", filePrefixes, iconSize)
Icons[p1][p2][p3][iconSize] = Icons[p1][p2][p3][iconSize] or {} Icons[p1][p2][p3][iconSize] = Icons[p1][p2][p3][iconSize] or {}
for fileDimKey, iconColumns in pairs(fileDimTable) do for fileDimKey, iconColumns in pairs(fileDimTable) do
assert(type(fileDimKey == "string"), assert(type(fileDimKey == "string"), string.format("file dimensions key for file %d in %s is not a string.", prefixInfo[3].file, filePrefixes))
string.format("file dimensions key for file %d in %s is not a string.",
prefixInfo[3].file, filePrefixes))
local fileDims = strsplittable("x", fileDimKey, 2) local fileDims = strsplittable("x", fileDimKey, 2)
assert(type(tonumber(fileDims[1])) == "number", assert(type(tonumber(fileDims[1])) == "number", string.format("could not obtain width from %s in %s", fileDimKey, filePrefixes))
string.format("could not obtain width from %s in %s", fileDimKey, filePrefixes)) assert(type(tonumber(fileDims[2])) == "number", string.format("could not obtain height from %s in %s", fileDimKey, filePrefixes))
assert(type(tonumber(fileDims[2])) == "number",
string.format("could not obtain height from %s in %s", fileDimKey, filePrefixes))
Icons[p1][p2][p3][iconSize][fileDimKey] = Icons[p1][p2][p3][iconSize][fileDimKey] or {} Icons[p1][p2][p3][iconSize][fileDimKey] = Icons[p1][p2][p3][iconSize][fileDimKey] or {}
filePrefixes = string.format("%s[%s]", filePrefixes, fileDimKey) filePrefixes = string.format("%s[%s]", filePrefixes, fileDimKey)
@ -4247,18 +4227,14 @@ do -- Set Icons
local rowCount = 0 local rowCount = 0
for column, rows in pairs(iconColumns) do for column, rows in pairs(iconColumns) do
columnCount = columnCount + 1 columnCount = columnCount + 1
assert(type(column) == "number", assert(type(column) == "number", string.format("column %d key in %s is not a number.", columnCount, filePrefixes))
string.format("column %d key in %s is not a number.", columnCount, filePrefixes)) assert(type(rows) == "table", string.format("column %d value in %s is not a table.", columnCount, filePrefixes))
assert(type(rows) == "table",
string.format("column %d value in %s is not a table.", columnCount, filePrefixes))
local filePrefixesColumn = string.format("%s[%d]", filePrefixes, column) local filePrefixesColumn = string.format("%s[%d]", filePrefixes, column)
iconsFileTable[column] = iconsFileTable[column] or {} iconsFileTable[column] = iconsFileTable[column] or {}
for row, icon in pairs(rows) do for row, icon in pairs(rows) do
rowCount = rowCount + 1 rowCount = rowCount + 1
assert(type(row) == "number", assert(type(row) == "number", string.format("row %d key in %s is not a number.", rowCount, filePrefixesColumn))
string.format("row %d key in %s is not a number.", rowCount, filePrefixesColumn)) assert(type(icon) == "string", string.format("row %d value in %s is not a string.", rowCount, filePrefixesColumn))
assert(type(icon) == "string",
string.format("row %d value in %s is not a string.", rowCount, filePrefixesColumn))
local filePrefixesColumnRow = string.format("%s[%d]", filePrefixesColumn, row) local filePrefixesColumnRow = string.format("%s[%d]", filePrefixesColumn, row)
local iconName = icon local iconName = icon
@ -4301,8 +4277,7 @@ do -- Set Icons
---@param iconTable DiesalStyle.Icon ---@param iconTable DiesalStyle.Icon
local function CreateIconStyle(iconTable) local function CreateIconStyle(iconTable)
local fileName = string.format("%s%s%s", iconTable.file.prefix[1], iconTable.file.prefix[2], local fileName = string.format("%s%s%s", iconTable.file.prefix[1], iconTable.file.prefix[2], iconTable.file.prefix[3])
iconTable.file.prefix[3])
local iconSize = iconTable.file.size.icon local iconSize = iconTable.file.size.icon
fileName = fileName .. (iconSize ~= 16 and iconSize or "") fileName = fileName .. (iconSize ~= 16 and iconSize or "")
@ -4677,10 +4652,8 @@ function DiesalStyle:StyleTexture(texture, style)
texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 } texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 }
-- gradient -- gradient
if texture.style.gradient then if texture.style.gradient then
texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or DEFAULT_GRADIENT_ORIENTATION
DEFAULT_GRADIENT_ORIENTATION texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or { DEFAULT_COLOR, DEFAULT_COLOR }
texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or
{ DEFAULT_COLOR, DEFAULT_COLOR }
end end
-- image -- image
if texture.style.image then if texture.style.image then
@ -4716,8 +4689,7 @@ function DiesalStyle:StyleTexture(texture, style)
end end
if style.debug then if style.debug then
print(texture:GetHeight(), texture.style.position[1], texture.style.position[2], texture.style.position[3], print(texture:GetHeight(), texture.style.position[1], texture.style.position[2], texture.style.position[3], texture.style.position[4])
texture.style.position[4])
end end
-- [1] Texture > [2] gradient > [3] color -- [1] Texture > [2] gradient > [3] color
if texture.style.image then -- [1] Texture if texture.style.image then -- [1] Texture
@ -4725,12 +4697,10 @@ function DiesalStyle:StyleTexture(texture, style)
texture.style.mode = "image" texture.style.mode = "image"
-- clear any old settings -- clear any old settings
setGradient(texture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) -- clear gradient setGradient(texture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) -- clear gradient
texture:SetColorTexture(1, 1, 1, 1) -- clear color texture:SetColorTexture(1, 1, 1, 1) -- clear color
-- apply settings -- apply settings
texture:SetTexCoord(texture.style.image.coords[1], texture.style.image.coords[2], texture.style.image.coords[3], texture:SetTexCoord(texture.style.image.coords[1], texture.style.image.coords[2], texture.style.image.coords[3], texture.style.image.coords[4])
texture.style.image.coords[4]) texture:SetTexture(texture.style.image.file, texture.style.image.tiling and texture.style.image.tiling[1], texture.style.image.tiling and texture.style.image.tiling[2])
texture:SetTexture(texture.style.image.file, texture.style.image.tiling and texture.style.image.tiling[1],
texture.style.image.tiling and texture.style.image.tiling[2])
texture:SetHorizTile(texture.style.image.tiling[1] and true) texture:SetHorizTile(texture.style.image.tiling[1] and true)
texture:SetVertTile(texture.style.image.tiling[2] and true) texture:SetVertTile(texture.style.image.tiling[2] and true)
local r, g, b = GetBlizzColorValues(texture.style.image.color) local r, g, b = GetBlizzColorValues(texture.style.image.color)
@ -4739,22 +4709,18 @@ function DiesalStyle:StyleTexture(texture, style)
-- set mode -- set mode
texture.style.mode = "gradient" texture.style.mode = "gradient"
-- clear any old settings -- clear any old settings
texture:SetTexture() -- clear image texture:SetTexture() -- clear image
texture:SetColorTexture(1, 1, 1, 1) -- clear color texture:SetColorTexture(1, 1, 1, 1) -- clear color
-- apply settings -- apply settings
local r1, g1, b1 = GetBlizzColorValues(texture.style.gradient.color local r1, g1, b1 = GetBlizzColorValues(texture.style.gradient.color[texture.style.gradient.orientation == "HORIZONTAL" and 1 or 2])
[texture.style.gradient.orientation == "HORIZONTAL" and 1 or 2]) local r2, g2, b2 = GetBlizzColorValues(texture.style.gradient.color[texture.style.gradient.orientation == "HORIZONTAL" and 2 or 1])
local r2, g2, b2 = GetBlizzColorValues(texture.style.gradient.color local a1, a2 = texture.style.alpha[texture.style.gradient.orientation == "HORIZONTAL" and 1 or 2], texture.style.alpha[texture.style.gradient.orientation == "HORIZONTAL" and 2 or 1]
[texture.style.gradient.orientation == "HORIZONTAL" and 2 or 1])
local a1, a2 =
texture.style.alpha[texture.style.gradient.orientation == "HORIZONTAL" and 1 or 2],
texture.style.alpha[texture.style.gradient.orientation == "HORIZONTAL" and 2 or 1]
setGradient(texture, texture.style.gradient.orientation, r1, g1, b1, a1, r2, g2, b2, a2) setGradient(texture, texture.style.gradient.orientation, r1, g1, b1, a1, r2, g2, b2, a2)
elseif texture.style.color then -- [3] color elseif texture.style.color then -- [3] color
-- set mode -- set mode
texture.style.mode = "color" texture.style.mode = "color"
-- clear any old settings -- clear any old settings
texture:SetTexture() -- clear image texture:SetTexture() -- clear image
setGradient(texture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) -- clear gradient setGradient(texture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) -- clear gradient
-- apply settings -- apply settings
local r, g, b = GetBlizzColorValues(texture.style.color) local r, g, b = GetBlizzColorValues(texture.style.color)
@ -4763,9 +4729,9 @@ function DiesalStyle:StyleTexture(texture, style)
-- set mode -- set mode
texture.style.mode = "none!" texture.style.mode = "none!"
-- clear the texture -- clear the texture
texture:SetTexture() -- clear image texture:SetTexture() -- clear image
setGradient(texture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient setGradient(texture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient
texture:SetColorTexture(0, 0, 0, 0) -- clear color texture:SetColorTexture(0, 0, 0, 0) -- clear color
end end
end end
@ -4794,8 +4760,7 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT
color = style.gradient[2] and style.gradient[3] and { style.gradient[2], style.gradient[3] }, color = style.gradient[2] and style.gradient[3] and { style.gradient[2], style.gradient[3] },
} }
end end
style.gradient_orientation = style.gradient_orientation and style.gradient_orientation = style.gradient_orientation and style.gradient_orientation:upper() --formatOrientation(style.gradient_orientation) -- fuck you
style.gradient_orientation:upper() --formatOrientation(style.gradient_orientation) -- fuck you
if not texture.style.gradient and (style.gradient_orientation or style.gradient_alpha or style.gradient_color) then if not texture.style.gradient and (style.gradient_orientation or style.gradient_alpha or style.gradient_color) then
texture.style.gradient = {} texture.style.gradient = {}
end end
@ -4808,10 +4773,8 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT
texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 } texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 }
-- gradient -- gradient
if texture.style.gradient then if texture.style.gradient then
texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or DEFAULT_GRADIENT_ORIENTATION
DEFAULT_GRADIENT_ORIENTATION texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or { DEFAULT_COLOR, DEFAULT_COLOR }
texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or
{ DEFAULT_COLOR, DEFAULT_COLOR }
end end
-- | Apply Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- | Apply Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -4892,11 +4855,11 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT
-- set mode -- set mode
texture.style.mode = "gradient" texture.style.mode = "gradient"
-- clear any old settings -- clear any old settings
leftTexture:SetTexture() -- clear image leftTexture:SetTexture() -- clear image
-- leftTexture:SetAlpha(1) -- reset alpha -- leftTexture:SetAlpha(1) -- reset alpha
rightTexture:SetTexture() -- clear image rightTexture:SetTexture() -- clear image
-- rightTexture:SetAlpha(1) -- reset alpha -- rightTexture:SetAlpha(1) -- reset alpha
topTexture:SetTexture() -- clear image topTexture:SetTexture() -- clear image
-- topTexture:SetAlpha(1) -- reset alpha -- topTexture:SetAlpha(1) -- reset alpha
bottomTexture:SetTexture() -- clear image bottomTexture:SetTexture() -- clear image
-- bottomTexture:SetAlpha(1) -- reset alpha -- bottomTexture:SetAlpha(1) -- reset alpha
@ -4907,7 +4870,7 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT
-- clear settings -- clear settings
setGradient(leftTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) setGradient(leftTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1)
setGradient(rightTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) setGradient(rightTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1)
topTexture:SetColorTexture(1, 1, 1, 1) -- clear color topTexture:SetColorTexture(1, 1, 1, 1) -- clear color
bottomTexture:SetColorTexture(1, 1, 1, 1) -- clear color bottomTexture:SetColorTexture(1, 1, 1, 1) -- clear color
-- aply settings -- aply settings
@ -4921,7 +4884,7 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT
setGradient(bottomTexture, "HORIZONTAL", r1, g1, b1, a1, r2, g2, b2, a2) setGradient(bottomTexture, "HORIZONTAL", r1, g1, b1, a1, r2, g2, b2, a2)
elseif texture.style.gradient.orientation == "VERTICAL" then elseif texture.style.gradient.orientation == "VERTICAL" then
-- clear settings -- clear settings
leftTexture:SetColorTexture(1, 1, 1, 1) -- clear color leftTexture:SetColorTexture(1, 1, 1, 1) -- clear color
rightTexture:SetColorTexture(1, 1, 1, 1) -- clear color rightTexture:SetColorTexture(1, 1, 1, 1) -- clear color
setGradient(topTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) setGradient(topTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1)
setGradient(bottomTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) setGradient(bottomTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1)
@ -4958,18 +4921,18 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT
-- set mode -- set mode
texture.style.mode = "none!" texture.style.mode = "none!"
-- clear the texture -- clear the texture
leftTexture:SetTexture() -- clear image leftTexture:SetTexture() -- clear image
setGradient(leftTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient setGradient(leftTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient
leftTexture:SetColorTexture(0, 0, 0, 0) -- clear color leftTexture:SetColorTexture(0, 0, 0, 0) -- clear color
rightTexture:SetTexture() -- clear image rightTexture:SetTexture() -- clear image
setGradient(rightTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient setGradient(rightTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient
rightTexture:SetColorTexture(0, 0, 0, 0) -- clear color rightTexture:SetColorTexture(0, 0, 0, 0) -- clear color
topTexture:SetTexture() -- clear image topTexture:SetTexture() -- clear image
setGradient(topTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient setGradient(topTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient
topTexture:SetColorTexture(0, 0, 0, 0) -- clear color topTexture:SetColorTexture(0, 0, 0, 0) -- clear color
bottomTexture:SetTexture() -- clear image bottomTexture:SetTexture() -- clear image
setGradient(bottomTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient setGradient(bottomTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient
bottomTexture:SetColorTexture(0, 0, 0, 0) -- clear color bottomTexture:SetColorTexture(0, 0, 0, 0) -- clear color
end end
end end
@ -4990,8 +4953,7 @@ end
---@param frame Frame ---@param frame Frame
---@param style Diesal.Style.ShadowStyle ---@param style Diesal.Style.ShadowStyle
function DiesalStyle:StyleShadow(object, frame, style) function DiesalStyle:StyleShadow(object, frame, style)
object.shadow = object.shadow or object.shadow = object.shadow or CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate") --CreateFrame("Frame",nil,frame)
CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate") --CreateFrame("Frame",nil,frame)
object.shadow:Show() object.shadow:Show()
if not object.shadow.style or style.clear then if not object.shadow.style or style.clear then
object.shadow.style = {} object.shadow.style = {}
@ -4999,8 +4961,7 @@ function DiesalStyle:StyleShadow(object, frame, style)
local shadowStyle = object.shadow.style local shadowStyle = object.shadow.style
-- ~~ Format New Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~ Format New Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local red, green, blue = DiesalTools.GetColor(style.color) local red, green, blue = DiesalTools.GetColor(style.color)
local offset = style.offset and type(style.offset) == "number" and local offset = style.offset and type(style.offset) == "number" and { style.offset, style.offset, style.offset, style.offset } or style.offset
{ style.offset, style.offset, style.offset, style.offset } or style.offset
-- Setting ~~~~~~~~~~~~~~~~~~~~~~~ New Setting ~~~~~~~~~~~~~~~ Old Setting ~~~~~~~~~~~~~~~~~ Default ~~~~~~~~~~~~~~~~~~ -- Setting ~~~~~~~~~~~~~~~~~~~~~~~ New Setting ~~~~~~~~~~~~~~~ Old Setting ~~~~~~~~~~~~~~~~~ Default ~~~~~~~~~~~~~~~~~~
shadowStyle.edgeFile = style.edgeFile or shadowStyle.edgeFile or getMedia("border", "shadow") shadowStyle.edgeFile = style.edgeFile or shadowStyle.edgeFile or getMedia("border", "shadow")
shadowStyle.edgeSize = style.edgeSize or shadowStyle.edgeSize or 28 shadowStyle.edgeSize = style.edgeSize or shadowStyle.edgeSize or 28
@ -5146,7 +5107,7 @@ function DiesalStyle:UpdateObjectStyle(object, name, style)
local textures = {} local textures = {}
for i = 1, #OUTLINES do for i = 1, #OUTLINES do
local texture = object.textures[name .. OUTLINES[i]] local texture = object.textures[name .. OUTLINES[i]]
if not texture then if type(texture) == "nil" then
texture = newTexture() texture = newTexture()
object.textures[name .. OUTLINES[i]] = texture object.textures[name .. OUTLINES[i]] = texture
end end
@ -5157,6 +5118,7 @@ function DiesalStyle:UpdateObjectStyle(object, name, style)
return return
end end
if styleType == "Shadow" then if styleType == "Shadow" then
---@cast object Diesal.Style.ShadowObject
DiesalStyle:StyleShadow(object, frame, style --[[ @as Diesal.Style.ShadowStyle ]]) DiesalStyle:StyleShadow(object, frame, style --[[ @as Diesal.Style.ShadowStyle ]])
return return
end end

Loading…
Cancel
Save