main
ck 11 months ago
parent d9fbab066c
commit 328b9c77e3
  1. 61
      .vscode/settings.json
  2. 6
      DiesalLibs/DiesalGUI-2.0/DiesalGUI-2.0.lua
  3. 1
      DiesalLibs/DiesalGUI-2.0/Objects/Button.lua
  4. 64
      DiesalLibs/DiesalGUI-2.0/Objects/Container.lua
  5. 9
      DiesalLibs/DiesalGUI-2.0/Objects/DropDown.lua
  6. 6
      DiesalLibs/DiesalGUI-2.0/Objects/DropDownItem.lua
  7. 253
      DiesalLibs/DiesalGUI-2.0/Objects/IconToggle.lua
  8. 42
      DiesalLibs/DiesalGUI-2.0/Objects/ObjectBase.lua
  9. 8
      DiesalLibs/DiesalGUI-2.0/Objects/Toggle.lua
  10. 9
      DiesalLibs/DiesalGUI-2.0/Objects/Window.lua
  11. 11303
      DiesalLibs/DiesalStyle-2.0/DiesalStyle-2.0.lua
  12. BIN
      DiesalLibs/DiesalStyle-2.0/Media/Fonts/MaterialIcons-Regular.ttf
  13. BIN
      DiesalLibs/DiesalStyle-2.0/Media/Fonts/MaterialIconsOutlined-Regular.otf
  14. BIN
      DiesalLibs/DiesalStyle-2.0/Media/Fonts/MaterialIconsRound-Regular.otf
  15. BIN
      DiesalLibs/DiesalStyle-2.0/Media/Fonts/MaterialIconsSharp-Regular.otf
  16. BIN
      DiesalLibs/DiesalStyle-2.0/Media/Fonts/MaterialIconsTwoTone-Regular.otf
  17. 82
      DiesalLibs/DiesalTools-2.0/DiesalTools-2.0.lua
  18. 4
      README.md

@ -1,6 +1,65 @@
{ {
"Lua.diagnostics.globals": [ "Lua.diagnostics.globals": [
"DEFAULT_CHAT_FRAME", "DEFAULT_CHAT_FRAME",
"ChatFrame1" "ChatFrame1",
"RED_FONT_COLOR",
"WHITE_FONT_COLOR",
"class",
"message",
"Ambiguate",
"CreateFrame",
"format",
"geterrorhandler",
"GetTime",
"GetFramerate",
"wipe",
"UnitInRaid",
"UnitInParty",
"hooksecurefunc",
"CreateColor",
"floor",
"GetCursorPosition",
"GetScreenWidth",
"GetScreenHeight",
"GetSpellInfo",
"GetBonusBarOffset",
"GetDodgeChance",
"GetCombatRatingBonus",
"PlaySound",
"UIParent",
"type",
"next",
"pairs",
"tostring",
"error",
"assert",
"string",
"table",
"setmetatable",
"print",
"select",
"tonumber",
"math",
"getmetatable",
"ipairs",
"min",
"max",
"loadstring",
"rawset",
"rawget",
"xpcall",
"GameTooltip",
"getfenv",
"_G",
"unpack",
"pcall",
"tinsert",
"tremove",
"IsShiftKeyDown",
"CreateFont",
"BackdropTemplateMixin",
"strsplittable",
"debugstack",
"GetLocale"
] ]
} }

@ -219,7 +219,7 @@ end ]]
---@generic T ---@generic T
---@param objectType `T` | Diesal.Object.Type ---@param objectType `T` | Diesal.Object.Type
---@param name? string | boolean ---@param name? string | boolean
---@param methods? table ---@param methods? table<string, fun(self?: self, ...): any>
---@return T object ---@return T object
function DiesalGUI:Create(objectType, name, methods) function DiesalGUI:Create(objectType, name, methods)
local base = (name ~= nil and type(name) == "boolean") and name or nil local base = (name ~= nil and type(name) == "boolean") and name or nil
@ -231,7 +231,9 @@ function DiesalGUI:Create(objectType, name, methods)
else else
object = newObject(objectType, base) object = newObject(objectType, base)
end end
object:SetMethods(methods) if type(methods) == "table" then
object:SetMethods(methods)
end
object:ResetSettings() object:ResetSettings()
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if object.OnAcquire then if object.OnAcquire then

@ -81,6 +81,7 @@ local function Constructor(name)
local self = DiesalGUI:Create(Type, true) local self = DiesalGUI:Create(Type, true)
local frame = CreateFrame("Button", name, UIParent) local frame = CreateFrame("Button", name, UIParent)
self.frame = frame self.frame = frame
self.frame.m = self
self.defaults = { self.defaults = {
height = 32, height = 32,
width = 32, width = 32,

@ -0,0 +1,64 @@
---@type Diesal.GUI
local DiesalGUI = LibStub("DiesalGUI-2.0")
local Type = "DiesalContainer"
local Version = 1
---@class Diesal.GUI.Container.Methods
local ContainerMethods = {
---@param self Diesal.GUI.Container
OnAcquire = function(self)
self:ResetSettings(true)
self:Show()
end,
---@param self Diesal.GUI.Container
OnRelease = function(self)
self:ReleaseChildren()
end,
---@param self Diesal.GUI.Container
ApplySettings = function(self)
local content = self.content
content:SetPoint("TOPLEFT")
content:SetPoint("BOTTOMRIGHT")
self.frame:SetToplevel(true)
end,
---@param self Diesal.GUI.Container
SetTopLevel = function(self)
self.frame:SetToplevel(true)
end,
---@param self Diesal.GUI.Container
---@param element Diesal.GUI.ObjectBase
SetElement = function(self, element)
element.container = self
element:SetParentObject(self)
self:AddChild(element)
self.element = element
end,
}
---@alias DiesalContainer Diesal.GUI.Container
local function Constructor()
---@class Diesal.GUI.Container : Diesal.GUI.ObjectBase, Diesal.GUI.Container.Methods
---@field content Frame
---@field element? Diesal.GUI.ObjectBase
local self = DiesalGUI:Create(Type, true)
self.isContainer = true
local frame = CreateFrame("Frame", nil, UIParent)
self.frame = frame
self.defaults = {}
local content = self:CreateRegion("Frame", "content", frame)
frame:SetToplevel(true)
for k, v in pairs(ContainerMethods) do
self[k] = v
end
return self
end
DiesalGUI:RegisterObjectConstructor(Type, Constructor, Version)

@ -128,12 +128,10 @@ local methods = {
---@param self Diesal.GUI.Object.DropDown ---@param self Diesal.GUI.Object.DropDown
---@param list table ---@param list table
---@param orderedKeys? table SetList = function(self, list)
SetList = function(self, list, orderedKeys)
self:ReleaseChildren() self:ReleaseChildren()
self:SetText("") self:SetText("")
local settings = self.settings local settings = self.settings
--local orderedKeys = sortList(list, orderedKeys)
settings.list = list settings.list = list
local foldColor = "353535" local foldColor = "353535"
local expandColor = "5a5a5a" local expandColor = "5a5a5a"
@ -148,7 +146,7 @@ local methods = {
clickable = item.clickable, clickable = item.clickable,
indent = item.indent or 0, indent = item.indent or 0,
}, true) }, true)
if item.indent > 0 then if item.indent and item.indent > 0 then
local leftOffset = -6 + (-6 * item.indent) local leftOffset = -6 + (-6 * item.indent)
dropdownItem:UpdateStyle("frame-lineV", { dropdownItem:UpdateStyle("frame-lineV", {
type = "texture", type = "texture",
@ -259,7 +257,8 @@ local methods = {
for _, key in ipairs(keyTable) do for _, key in ipairs(keyTable) do
if dropdownItem.settings.key == key then if dropdownItem.settings.key == key then
dropdownItem:SetSelected(true) dropdownItem:SetSelected(true)
dropdownText = dropdownText and format("%s, %s", dropdownText, dropdownItem.settings.value) or dropdownItem.settings.value dropdownText = dropdownText and format("%s, %s", dropdownText, dropdownItem.settings.value) or
dropdownItem.settings.value
selectionTable[#selectionTable + 1] = dropdownItem.settings.key selectionTable[#selectionTable + 1] = dropdownItem.settings.key
end end
end end

@ -77,7 +77,6 @@ local methods = {
local selectionTable = {} local selectionTable = {}
local dropdownText local dropdownText
print(settings.key, settings.value, settings.clickable)
if not settings.clickable then if not settings.clickable then
return return
end end
@ -86,7 +85,8 @@ local methods = {
self:SetSelected(not settings.selected) self:SetSelected(not settings.selected)
for i = 1, #dropdownItems do for i = 1, #dropdownItems do
if dropdownItems[i].settings.selected then if dropdownItems[i].settings.selected then
dropdownText = dropdownText and format("%s, %s", dropdownText, dropdownItems[i].settings.value) or dropdownItems[i].settings.value dropdownText = dropdownText and format("%s, %s", dropdownText, dropdownItems[i].settings.value) or
dropdownItems[i].settings.value
selectionTable[#selectionTable + 1] = dropdownItems[i].settings.key selectionTable[#selectionTable + 1] = dropdownItems[i].settings.key
end end
end end
@ -118,6 +118,7 @@ local methods = {
} }
---@class Diesal.GUI.DropDownItem.Settings : Diesal.GUI.ObjectBase.Settings ---@class Diesal.GUI.DropDownItem.Settings : Diesal.GUI.ObjectBase.Settings
---@field last boolean
---@field key string ---@field key string
---@field value string ---@field value string
---@field position number ---@field position number
@ -154,6 +155,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 = { 2, nil, 0, nil }, position = { 2, nil, 0, nil },
height = 16, height = 16,
width = 16, width = 16,

@ -0,0 +1,253 @@
---@type Tinkr, Bastion
Tinkr, Bastion = ...
---@type Diesal.GUI
local DiesalGUI = LibStub("DiesalGUI-2.0")
---@type Diesal.Tools
local DiesalTools = LibStub("DiesalTools-2.0")
---@type Diesal.Style
local DiesalStyle = LibStub("DiesalStyle-2.0")
-- ~~| Diesal Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Colors = DiesalStyle.Colors
local HSL, ShadeColor, TintColor = DiesalTools.HSL, DiesalTools.ShadeColor, DiesalTools.TintColor
-- ~~| Lua Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local type, tonumber, select = type, tonumber, select
local pairs, ipairs, next = pairs, ipairs, next
local min, max = math.min, math.max
-- ~~| WoW Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local CreateFrame, UIParent, GetCursorPosition = CreateFrame, UIParent, GetCursorPosition
-- ~~| Button |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Type = "DiesalIconToggle"
local Version = 1
-- ~~| Button Stylesheets |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Stylesheet = {
["frame-background"] = {
type = "texture",
layer = "BACKGROUND",
color = "000000",
alpha = 0.60,
position = -2,
},
["frame-inline"] = {
type = "outline",
layer = "BORDER",
color = "000000",
alpha = 0.6,
position = -2,
},
["frame-outline"] = {
type = "outline",
layer = "BORDER",
color = "FFFFFF",
alpha = 0.1,
position = -1,
},
}
local checkBoxStyle = {
base = {
type = "font",
color = Colors.UI_A400,
},
disabled = {
type = "font",
color = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.35) --[[@as string]],
},
enabled = {
type = "font",
color = Colors.UI_A400,
},
}
local wireFrame = {
["frame-white"] = {
type = "outline",
layer = "OVERLAY",
color = "ffffff",
},
}
-- ~~| Button Methods |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---@class Diesal.GUI.IconToggle.Methods
local methods = {
---@param self Diesal.GUI.Object.IconToggle
OnAcquire = function(self)
self:ApplySettings()
self:SetStylesheet(Stylesheet)
self:Enable()
-- self:SetStylesheet(wireFrameSheet)
self.label:SetFontObject(DiesalFontNormal)
self.label:SetText()
self:Show()
end,
---@param self Diesal.GUI.Object.IconToggle
OnRelease = function(self) end,
---@param self Diesal.GUI.Object.IconToggle
ApplySettings = function(self)
local settings = self.settings
local frame = self.frame
self:SetWidth(settings.width)
self:SetHeight(settings.height)
self.check:SetFont(MaterialIconsRegular:GetFont(), settings.height + 1, "")
end,
---@param self Diesal.GUI.Object.IconToggle
---@param value boolean
SetChecked = function(self, value)
self.settings.checked = value
self.check:SetText(value and DiesalStyle.MaterialIcon("check_box") or DiesalStyle.MaterialIcon("check_box_outline_blank"))
self.frame:SetChecked(value)
self[self.settings.disabled and "Disable" or "Enable"](self)
end,
---@param self Diesal.GUI.Object.IconToggle
GetChecked = function(self)
return self.settings.checked
end,
---@param self Diesal.GUI.Object.IconToggle
Disable = function(self)
self.settings.disabled = true
local r, g, b = DiesalTools.GetColor(checkBoxStyle.disabled.color)
self.check:SetTextColor(r, g, b, 1)
--DiesalStyle:StyleTexture(self.check, self.checkBoxStyle and self.checkBoxStyle.disabled or checkBoxStyle.disabled)
self.frame:Disable()
end,
---@param self Diesal.GUI.Object.IconToggle
Enable = function(self)
self.settings.disabled = false
local r, g, b = DiesalTools.GetColor(checkBoxStyle.enabled.color)
self.check:SetTextColor(r, g, b, 1)
--DiesalStyle:StyleTexture(self.check, self.checkBoxStyle and self.checkBoxStyle.enabled or checkBoxStyle.enabled)
self.frame:Enable()
end,
---@param self Diesal.GUI.Object.IconToggle
---@param ... any
RegisterForClicks = function(self, ...)
self.frame:RegisterForClicks(...)
end,
---@param self Diesal.GUI.Object.IconToggle
---@param text? string
SetText = function(self, text)
self.label:SetText(text)
self.frame:SetHitRectInsets(0, -self.label:GetWidth(), 0, 0)
end,
}
---@alias DiesalIconToggle Diesal.GUI.Object.Toggle
---@class Diesal.GUI.Object.IconToggle.CheckBox.Style
---@field base {type: "font", color: string}
---@field disabled {type: "font", color: string}
---@field enabled {type: "texture", color: string}}
---@class Diesal.GUI.IconToggle.Settings
---@field height number
---@field width number
---@field checked boolean
---@field disabled boolean
---@field tooltip? string
-- ~~| Button Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local function Constructor()
---@class Diesal.GUI.Object.IconToggle : Diesal.GUI.ObjectBase, Diesal.GUI.IconToggle.Methods
---@field check Diesal.GUI.Region.FontString
---@field settings Diesal.GUI.IconToggle.Settings
---@field checkBoxStyle? Diesal.GUI.Object.IconToggle.CheckBox.Style
---@field label FontString
local self = DiesalGUI:Create(Type, true)
local frame = CreateFrame("CheckButton", nil, UIParent)
local fontString = self:CreateRegion("FontString", "label", frame)
self.frame = frame
local c, a = 0.5, 0.5
local tex = frame:CreateTexture(nil, "BACKGROUND")
tex:SetAllPoints()
tex:SetColorTexture(0, 0, 0, 0)
-- ~~ Default Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
self.defaults = {
height = 12,
width = 12,
}
-- ~~ Events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- OnAcquire, OnRelease, OnHeightSet, OnWidthSet
-- OnValueChanged, OnEnter, OnLeave, OnDisable, OnEnable
-- ~~ Construct ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--local check = self:CreateRegion("Texture", "check", frame)
---@type Diesal.GUI.Region.FontString
local check = self:CreateRegion("FontString", "check", frame)
check:SetAllPoints(frame, true)
--check:SetAllPoints(frame, true)
check:SetFont(MaterialIconsRegular:GetFont(), self.defaults.height, "")
-- Setting self.check again is pointless when CreateRegion already does it....
-- self.check = check
--DiesalStyle:StyleTexture(check, self.checkBoxStyle and self.checkBoxStyle.base or checkBoxStyle.base)
--frame:SetCheckedTexture(check)
frame:SetScript("OnClick", function(this, button, ...)
DiesalGUI:OnMouse(this, button)
if not self.settings.disabled then
self:SetChecked(not self.settings.checked)
if self.settings.checked then
PlaySound(856)
else
PlaySound(857)
end
self:FireEvent("OnValueChanged", self.settings.checked)
end
end)
frame:SetScript("OnEnter", function(this)
if self.settings.tooltip then
GameTooltip:SetOwner(this, "ANCHOR_TOPLEFT", 0, 2)
GameTooltip:AddLine(self.settings.tooltip)
GameTooltip:Show()
end
self:FireEvent("OnEnter")
check:SetTextColor(c, c, c, a)
--tex:SetColorTexture(c, c, c, a)
-- SetCursor([[Interface\Cursor\Cast]])
end)
frame:SetScript("OnLeave", function(this)
if self.settings.tooltip then
GameTooltip:Hide()
end
self:FireEvent("OnLeave")
--tex:SetColorTexture(0, 0, 0, 0)
-- SetCursor(nil)
end)
frame:SetScript("OnDisable", function(this)
self:FireEvent("OnDisable")
end)
frame:SetScript("OnEnable", function(this)
self:FireEvent("OnEnable")
end)
fontString:SetPoint("LEFT", frame, "RIGHT", 5, 0)
fontString:SetHeight(15)
fontString:SetWordWrap(false)
-- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
self:SetMethods(methods)
--[[ for method, func in pairs(methods) do
self[method] = func
end ]]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
return self
end
DiesalGUI:RegisterObjectConstructor(Type, Constructor, Version)

@ -138,7 +138,8 @@ local ObjectBase = {
--#endregion BlizzardFrameMethods --#endregion BlizzardFrameMethods
---@class Diesal.GUI.Region.FontString : { defaultFontObject: Font }, FontString ---@class Diesal.GUI.Region.FontString : FontString
---@field defaultFontObject Font
---@class Diesal.GUI.Region.EditBox : EditBox, FontableFrameMixin ---@class Diesal.GUI.Region.EditBox : EditBox, FontableFrameMixin
---@field defaultFontObject Font ---@field defaultFontObject Font
@ -224,7 +225,7 @@ local ObjectBase = {
---@generic T : Diesal.GUI.ObjectBase ---@generic T : Diesal.GUI.ObjectBase
---@param self T | Diesal.GUI.ObjectBase ---@param self T | Diesal.GUI.ObjectBase
---@param methods? table<string, fun(self: self, ...): any> ---@param methods? table<string, fun(self?: self, ...): any>
SetMethods = function(self, methods) SetMethods = function(self, methods)
if methods and type(methods) == "table" then if methods and type(methods) == "table" then
for method, func in pairs(methods) do for method, func in pairs(methods) do
@ -327,17 +328,40 @@ local ObjectBase = {
---@param event string ---@param event string
FireEvent = function(self, event, ...) FireEvent = function(self, event, ...)
if self.eventListeners[event] then if self.eventListeners[event] then
return self.eventListeners[event](self, event, ...) for _, listner in ipairs(self.eventListeners[event]) do
listner(self, event, ...)
end
--return self.eventListeners[event](self, event, ...)
end
end,
---@generic T : Diesal.GUI.ObjectBase
---@param self T | Diesal.GUI.ObjectBase
---@param event string
---@param listener fun(self: T, event: string, ...: any)
AddEventListener = function(self, event, listener)
if type(listener) == "function" then
--self.eventListeners[event] = listener
if not self.eventListeners[event] then
self.eventListeners[event] = {}
end
table.insert(self.eventListeners[event], listener)
else
error("listener is required to be a function", 2)
end end
end, end,
---@generic T : Diesal.GUI.ObjectBase ---@generic T : Diesal.GUI.ObjectBase
---@param self T | Diesal.GUI.ObjectBase ---@param self T | Diesal.GUI.ObjectBase
---@param event string ---@param event string
---@param listener fun(self: T, event: string, ...) ---@param listener fun(self: T, event: string, ...: any)
SetEventListener = function(self, event, listener) SetEventListener = function(self, event, listener)
if type(listener) == "function" then if type(listener) == "function" then
self.eventListeners[event] = listener --self.eventListeners[event] = listener
if not self.eventListeners[event] then
self.eventListeners[event] = {}
end
table.insert(self.eventListeners[event], listener)
else else
error("listener is required to be a function", 2) error("listener is required to be a function", 2)
end end
@ -397,6 +421,10 @@ local ObjectBase = {
DiesalStyle:ReleaseTextures(self) DiesalStyle:ReleaseTextures(self)
end, end,
---@generic T : Diesal.GUI.ObjectBase
---@param self T | Diesal.GUI.ObjectBase
ApplySettings = function(self) end,
--#endregion DiesalObjectMethods --#endregion DiesalObjectMethods
--#endregion Diesal.GUI.Objectbase.BaseMethods --#endregion Diesal.GUI.Objectbase.BaseMethods
@ -413,7 +441,7 @@ DiesalGUI.ObjectBase = ObjectBase
---@class Diesal.GUI.ObjectBase.Methods ---@class Diesal.GUI.ObjectBase.Methods
---@field OnAcquire fun() ---@field OnAcquire fun()
---@field OnRelease fun() ---@field OnRelease fun()
---@field ApplySettings fun() ---@field ApplySettings fun(self)
---@alias DiesalObjectBase Diesal.GUI.ObjectBase ---@alias DiesalObjectBase Diesal.GUI.ObjectBase
@ -427,7 +455,7 @@ local Constructor = function(objectType)
---@field fontStrings { [string]: Diesal.GUI.Region.FontString } ---@field fontStrings { [string]: Diesal.GUI.Region.FontString }
---@field textures { [string]: Diesal.Style.Texture } ---@field textures { [string]: Diesal.Style.Texture }
---@field children { [number]: Diesal.GUI.ObjectBase } ---@field children { [number]: Diesal.GUI.ObjectBase }
---@field eventListeners { [string]: fun(self: self, event: string, ...) } ---@field eventListeners { [string]: fun(self: self, event: string, ...)[] }
---@field settings Diesal.GUI.ObjectBase.Settings ---@field settings Diesal.GUI.ObjectBase.Settings
---@field defaults Diesal.GUI.ObjectBase.Settings ---@field defaults Diesal.GUI.ObjectBase.Settings
local object = { local object = {

@ -111,7 +111,8 @@ local methods = {
---@param self DiesalToggle ---@param self DiesalToggle
Disable = function(self) Disable = function(self)
self.settings.disabled = true self.settings.disabled = true
DiesalStyle:StyleTexture(self.check, self.checkBoxStyle and self.checkBoxStyle.disabled or checkBoxStyle.disabled) DiesalStyle:StyleTexture(self.check, self.checkBoxStyle and self.checkBoxStyle.disabled or checkBoxStyle
.disabled)
self.frame:Disable() self.frame:Disable()
end, end,
@ -159,6 +160,7 @@ local function Constructor()
---@field label FontString ---@field label FontString
local self = DiesalGUI:Create(Type, true) local self = DiesalGUI:Create(Type, true)
local frame = CreateFrame("CheckButton", nil, UIParent) local frame = CreateFrame("CheckButton", nil, UIParent)
---@type Diesal.GUI.Region.FontString
local fontString = self:CreateRegion("FontString", "label", frame) local fontString = self:CreateRegion("FontString", "label", frame)
self.frame = frame self.frame = frame
@ -228,9 +230,7 @@ local function Constructor()
end) end)
fontString:SetPoint("LEFT", frame, "RIGHT", 5, 0) fontString:SetPoint("LEFT", frame, "RIGHT", 5, 0)
fontString:SetHeight(0) fontString:SetHeight(15)
fontString:SetJustifyH("MIDDLE")
fontString:SetJustifyV("MIDDLE")
fontString:SetWordWrap(false) fontString:SetWordWrap(false)
-- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@ -209,7 +209,7 @@ local methods = {
closeButton:SetHeight(settings.titleBarHeight) closeButton:SetHeight(settings.titleBarHeight)
closeButton:SetWidth(settings.titleBarHeight) closeButton:SetWidth(settings.titleBarHeight)
content:SetPoint("TOPLEFT", settings.padding[1], -(settings.titleBarHeight + headerHeight)) content:SetPoint("TOPLEFT", settings.padding[1], -(settings.titleBarHeight + headerHeight + settings.padding[3]))
content:SetPoint("BOTTOMRIGHT", -settings.padding[2], footerHeight + settings.padding[4]) content:SetPoint("BOTTOMRIGHT", -settings.padding[2], footerHeight + settings.padding[4])
header:SetHeight(headerHeight) header:SetHeight(headerHeight)
footer:SetHeight(footerHeight) footer:SetHeight(footerHeight)
@ -262,6 +262,11 @@ local methods = {
end, end,
} }
---@alias PaddingLeft number
---@alias PaddingRight number
---@alias PaddingTop number
---@alias PaddingBottom number
---@class Diesal.GUI.Window.Frame : Frame, { obj: Diesal.GUI.Object.Window } ---@class Diesal.GUI.Window.Frame : Frame, { obj: Diesal.GUI.Object.Window }
---@class Diesal.GUI.Window.Settings ---@class Diesal.GUI.Window.Settings
@ -275,7 +280,7 @@ local methods = {
---@field maxWidth number -- 9999 ---@field maxWidth number -- 9999
---@field minHeight number -- 200 ---@field minHeight number -- 200
---@field minWidth number -- 200 ---@field minWidth number -- 200
---@field padding { [1]: number, [2]: number, [3]: number, [4]: number } ---@field padding { [1]: PaddingLeft, [2]: PaddingBottom, [3]: PaddingTop, [4]: PaddingBottom }
---@field sizerB boolean -- true ---@field sizerB boolean -- true
---@field sizerBR boolean -- true ---@field sizerBR boolean -- true
---@field sizerBRHeight number -- 6, ---@field sizerBRHeight number -- 6,

File diff suppressed because it is too large Load Diff

@ -19,15 +19,15 @@ local CreateFrame, UIParent, GetCursorPosition = CreateFrame, UIParent, GetCurso
local GetScreenWidth, GetScreenHeight = GetScreenWidth, GetScreenHeight local GetScreenWidth, GetScreenHeight = GetScreenWidth, GetScreenHeight
-- ~~| Locals |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~| Locals |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local escapeSequences = { local escapeSequences = {
["\a"] = "\\a", -- Bell ["\a"] = "\\a", -- Bell
["\b"] = "\\b", -- Backspace ["\b"] = "\\b", -- Backspace
["\t"] = "\\t", -- Horizontal tab ["\t"] = "\\t", -- Horizontal tab
["\n"] = "\\n", -- Newline ["\n"] = "\\n", -- Newline
["\v"] = "\\v", -- Vertical tab ["\v"] = "\\v", -- Vertical tab
["\f"] = "\\f", -- Form feed ["\f"] = "\\f", -- Form feed
["\r"] = "\\r", -- Carriage return ["\r"] = "\\r", -- Carriage return
["\\"] = "\\\\", -- Backslash ["\\"] = "\\\\", -- Backslash
['"'] = '\\"', -- Quotation mark ['"'] = '\\"', -- Quotation mark
["|"] = "||", ["|"] = "||",
} }
local lua_keywords = { local lua_keywords = {
@ -77,25 +77,33 @@ local function GetCaller(level)
-- Blizzard Sandbox -- Blizzard Sandbox
local match, _, file, line = trace:find("^.*\\(.-):(%d+)") local match, _, file, line = trace:find("^.*\\(.-):(%d+)")
if match then if match then
return format("%s[%s%s: %s%s%s]|r", colors.orange, colors.yellow, file, colors.lightyellow, line, colors.orange) return format("%s[%s%s: %s%s%s]|r", colors.orange, colors.yellow, file, colors.lightyellow, line,
colors.orange)
end end
-- PQI DataFile -- PQI DataFile
local match, _, file, line = trace:find('^%[string "[%s%-]*(.-%.lua).-"%]:(%d+)') local match, _, file, line = trace:find('^%[string "[%s%-]*(.-%.lua).-"%]:(%d+)')
if match then if match then
return format("%s[%s%s: %s%s%s]|r", colors.orange, colors.yellow, file, colors.lightyellow, line, colors.orange) return format("%s[%s%s: %s%s%s]|r", colors.orange, colors.yellow, file, colors.lightyellow, line,
colors.orange)
end end
-- PQR Ability code -- PQR Ability code
local match, _, file, line = trace:find('^%[string "(.-)"%]:(%d+)') local match, _, file, line = trace:find('^%[string "(.-)"%]:(%d+)')
if match then if match then
return format("%s[%s%s: %s%s%s]|r", colors.orange, colors.yellow, file, colors.lightyellow, line, colors.orange) return format("%s[%s%s: %s%s%s]|r", colors.orange, colors.yellow, file, colors.lightyellow, line,
colors.orange)
end end
end end
return format("%s[%sUnknown Caller%s]|r", colors.orange, colors.red, colors.orange) return format("%s[%sUnknown Caller%s]|r", colors.orange, colors.red, colors.orange)
end end
---@param number number
---@param base? number
local function round(number, base) local function round(number, base)
base = base or 1 base = base or 1
return floor((number + base / 2) / base) * base return floor((number + base / 2) / base) * base
end end
---@param color string | number | table
---@param g? number
---@param b? number
local function getRGBColorValues(color, g, b) local function getRGBColorValues(color, g, b)
if type(color) == "number" and type(g) == "number" and type(b) == "number" then if type(color) == "number" and type(g) == "number" and type(b) == "number" then
if color <= 1 and g <= 1 and b <= 1 then if color <= 1 and g <= 1 and b <= 1 then
@ -120,7 +128,8 @@ function DiesalTools.GetColor(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, tonumber(sub(value, 5, 6), 16) / 255 return tonumber(sub(value, 1, 2), 16) / 255, tonumber(sub(value, 3, 4), 16) / 255,
tonumber(sub(value, 5, 6), 16) / 255
end end
end end
@ -132,11 +141,13 @@ function DiesalTools.Stack()
for trace in stack:gmatch("(.-)\n") do for trace in stack:gmatch("(.-)\n") do
local match, _, file, line, func = trace:find("^.*\\(.-):(%d+).-`(.*)'$") local match, _, file, line, func = trace:find("^.*\\(.-):(%d+).-`(.*)'$")
if match then if match then
print(format("%s[%s%s: %s%s%s] %sfunction|r %s|r", colors.orange, colors.yellow, file, colors.lightyellow, line, colors.orange, colors.blue, func)) print(format("%s[%s%s: %s%s%s] %sfunction|r %s|r", colors.orange, colors.yellow, file, colors.lightyellow,
line, colors.orange, colors.blue, func))
end end
end end
print("|r--------------------------------------------------------------------------------") print("|r--------------------------------------------------------------------------------")
end end
--[[ copy = TableCopy(src, dest, metatable) --[[ copy = TableCopy(src, dest, metatable)
@Arguments: @Arguments:
dest Table to copy to dest Table to copy to
@ -161,6 +172,7 @@ function DiesalTools.TableCopy(src, dest, metatable)
end end
return dest return dest
end end
--[[ red, blue, green = GetColor(value) --[[ red, blue, green = GetColor(value)
@Arguments: @Arguments:
value Hex color code or a table contating R,G,B color values value Hex color code or a table contating R,G,B color values
@ -172,13 +184,16 @@ end
-- | Color Tools |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- | Color Tools |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---@alias ColorType 'rgb255' | 'rgb1' | 'hex' | 'hsl' ---@alias ColorType "rgb255" | "rgb1" | "hex" | "hsl"
-- converts a color from RGB[0-1], RGB[0-255], HEX or HSL to RGB[0-1], RGB[0-255] or HEX -- converts a color from RGB[0-1], RGB[0-255], HEX or HSL to RGB[0-1], RGB[0-255] or HEX
---@param from ColorType ---@param from ColorType
---@param to ColorType ---@param to ColorType
---@param v1 string | number | table ---@param v1 string | number | table
---@param v2? string | number ---@param v2? string | number
---@param v3? string | number ---@param v3? string | number
---@overload fun(from: "rgb1" | "hsl" | "rbg255", to: "rgb1" | "hsl" | "rbg255", v1: number, v2: number, v3: number): number, number, number
---@overload fun(from: "hex", to: "rgb255" | "rgb1" | "hsl", v1: string): number, number, number
---@overload fun(from: "rgb255" | "rgb1" | "hsl", to: "hex", v1: number, v2: number, v3: number): string, nil, nil
function DiesalTools.ConvertColor(from, to, v1, v2, v3) function DiesalTools.ConvertColor(from, to, v1, v2, v3)
if not from or not to or not v1 then if not from or not to or not v1 then
return return
@ -187,6 +202,7 @@ function DiesalTools.ConvertColor(from, to, v1, v2, v3)
v1, v2, v3 = v1[1], v1[2], v1[3] v1, v2, v3 = v1[1], v1[2], v1[3]
end end
local r, g, b local r, g, b
---@type ColorType, ColorType
from, to = from:lower(), to:lower() from, to = from:lower(), to:lower()
if from == "rgb255" and type(v1) == "number" and type(v2) == "number" and type(v3) == "number" then if from == "rgb255" and type(v1) == "number" and type(v2) == "number" and type(v3) == "number" then
@ -234,7 +250,12 @@ function DiesalTools.ConvertColor(from, to, v1, v2, v3)
return format("%02x%02x%02x", r, g, b) return format("%02x%02x%02x", r, g, b)
end end
end end
-- Mixes a color with pure white to produce a lighter color -- Mixes a color with pure white to produce a lighter color
---@param color string | table
---@param percent number
---@param to? ColorType
---@param from? ColorType
function DiesalTools.TintColor(color, percent, to, from) function DiesalTools.TintColor(color, percent, to, from)
percent = min(1, max(0, percent)) percent = min(1, max(0, percent))
from, to = from or "hex", to and to:lower() or "hex" from, to = from or "hex", to and to:lower() or "hex"
@ -243,13 +264,19 @@ function DiesalTools.TintColor(color, percent, to, from)
if to == "rgb255" then if to == "rgb255" then
return round((255 - r) * percent + r), round((255 - g) * percent + g), round((255 - b) * percent + b) return round((255 - r) * percent + r), round((255 - g) * percent + g), round((255 - b) * percent + b)
elseif to == "rgb1" then elseif to == "rgb1" then
return round(((255 - r) * percent + r) / 255), round(((255 - g) * percent + g) / 255), round(((255 - b) * percent + b) / 255) return round(((255 - r) * percent + r) / 255), round(((255 - g) * percent + g) / 255),
round(((255 - b) * percent + b) / 255)
elseif to == "hex" then elseif to == "hex" then
return format("%02x%02x%02x", round((255 - r) * percent + r), round((255 - g) * percent + g), round((255 - b) * percent + b)) return format("%02x%02x%02x", round((255 - r) * percent + r), round((255 - g) * percent + g),
round((255 - b) * percent + b))
end end
-- return format("%02x%02x%02x", round((255-r)*percent+r), round((255-g)*percent+g), round((255-b)*percent+b) ) -- return format("%02x%02x%02x", round((255-r)*percent+r), round((255-g)*percent+g), round((255-b)*percent+b) )
end end
-- Mixes a color with pure black to produce a darker color -- Mixes a color with pure black to produce a darker color
---@overload fun(color: string, percent: number, to: "hex", from: "hex"): string, nil, nil
---@overload fun(color: string, percent: number, to: "rgb255" | "rgb1", from: ColorType): number, number, number
---@overload fun(color: table, percent: number, to: "hex", from: ColorType): string
function DiesalTools.ShadeColor(color, percent, to, from) function DiesalTools.ShadeColor(color, percent, to, from)
percent = min(1, max(0, percent)) percent = min(1, max(0, percent))
from, to = from or "hex", to and to:lower() or "hex" from, to = from or "hex", to and to:lower() or "hex"
@ -263,6 +290,7 @@ function DiesalTools.ShadeColor(color, percent, to, from)
return format("%02x%02x%02x", round(-r * percent + r), round(-g * percent + g), round(-b * percent + b)) return format("%02x%02x%02x", round(-r * percent + r), round(-g * percent + g), round(-b * percent + b))
end end
end end
-- Mixes a color with the another color to produce an intermediate color. -- Mixes a color with the another color to produce an intermediate color.
function DiesalTools.MixColors(color1, color2, percent, to, from) function DiesalTools.MixColors(color1, color2, percent, to, from)
percent = min(1, max(0, percent)) percent = min(1, max(0, percent))
@ -275,11 +303,14 @@ function DiesalTools.MixColors(color1, color2, percent, to, from)
if to == "rgb255" then if to == "rgb255" then
return round((r2 - r1) * percent) + r1, round((g2 - g1) * percent) + g1, round((b2 - b1) * percent) + b1 return round((r2 - r1) * percent) + r1, round((g2 - g1) * percent) + g1, round((b2 - b1) * percent) + b1
elseif to == "rgb1" then elseif to == "rgb1" then
return round(((r2 - r1) * percent + r1) / 255), round(((g2 - g1) * percent + g1) / 255), round(((b2 - b1) * percent + b1) / 255) return round(((r2 - r1) * percent + r1) / 255), round(((g2 - g1) * percent + g1) / 255),
round(((b2 - b1) * percent + b1) / 255)
elseif to == "hex" then elseif to == "hex" then
return format("%02x%02x%02x", round((r2 - r1) * percent) + r1, round((g2 - g1) * percent) + g1, round((b2 - b1) * percent) + b1) return format("%02x%02x%02x", round((r2 - r1) * percent) + r1, round((g2 - g1) * percent) + g1,
round((b2 - b1) * percent) + b1)
end end
end end
--- converts color HSL to HEX --- converts color HSL to HEX
function DiesalTools.HSL(v1, v2, v3) function DiesalTools.HSL(v1, v2, v3)
if not v1 then if not v1 then
@ -351,8 +382,10 @@ function DiesalTools.GetIconCoords(column, row, size, textureWidth, textureHeigh
size = size or 16 size = size or 16
textureWidth = textureWidth or 128 textureWidth = textureWidth or 128
textureHeight = textureHeight or 16 textureHeight = textureHeight or 16
return (column * size - size) / textureWidth, (column * size) / textureWidth, (row * size - size) / textureHeight, (row * size) / textureHeight return (column * size - size) / textureWidth, (column * size) / textureWidth, (row * size - size) / textureHeight,
(row * size) / textureHeight
end end
-- | String Tools |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- | String Tools |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--[[ Capitalize a string --[[ Capitalize a string
@ -361,24 +394,28 @@ end
function DiesalTools.Capitalize(str) function DiesalTools.Capitalize(str)
return (str:gsub("^%l", upper)) return (str:gsub("^%l", upper))
end end
--[[ Escape all formatting in a WoW-lua string --[[ Escape all formatting in a WoW-lua string
-- @Param str the string to escape -- @Param str the string to escape
-- @Return the escaped string ]] -- @Return the escaped string ]]
function DiesalTools.EscapeString(string) function DiesalTools.EscapeString(string)
return string:gsub('[%z\1-\31"\\|\127-\255]', escapeSequences) return string:gsub('[%z\1-\31"\\|\127-\255]', escapeSequences)
end end
--[[ ID = CreateID(s) --[[ ID = CreateID(s)
-- @Param s string to parse -- @Param s string to parse
-- @Return ID string stripped of all non letter characters and color codes.]] -- @Return ID string stripped of all non letter characters and color codes.]]
function DiesalTools.CreateID(s) function DiesalTools.CreateID(s)
return gsub(s:gsub("c%x%x%x%x%x%x%x%x", ""), "[^%a%d]", "") return gsub(s:gsub("c%x%x%x%x%x%x%x%x", ""), "[^%a%d]", "")
end end
--[[ str = TrimString(s) --[[ str = TrimString(s)
-- @Param s string to parse -- @Param s string to parse
-- @Return str string stripped of leading and trailing spaces.]] -- @Return str string stripped of leading and trailing spaces.]]
function DiesalTools.TrimString(s) function DiesalTools.TrimString(s)
return s:gsub("^%s*(.-)%s*$", "%1") return s:gsub("^%s*(.-)%s*$", "%1")
end end
--[[ string = SpliceString(string, start, End, txt) --[[ string = SpliceString(string, start, End, txt)
@Arguments: @Arguments:
string string to splice string string to splice
@ -394,6 +431,7 @@ end
function DiesalTools.SpliceString(string, start, End, txt) function DiesalTools.SpliceString(string, start, End, txt)
return string:sub(1, start - 1) .. txt .. string:sub(End + 1, -1) return string:sub(1, start - 1) .. txt .. string:sub(End + 1, -1)
end end
--[[ string = Serialize(table) --[[ string = Serialize(table)
@Param table - table to to serialize @Param table - table to to serialize
@Return string - serialized table (string) @Return string - serialized table (string)
@ -451,8 +489,8 @@ local function impl(t, cat, visited)
if if
k_type ~= "number" -- non-string non-number k_type ~= "number" -- non-string non-number
or k >= next_i or k >= next_i
or k < 1 -- integer key in hash part of the table or k < 1 -- integer key in hash part of the table
or k % 1 ~= 0 -- non-integer key or k % 1 ~= 0 -- non-integer key
then then
if need_comma then if need_comma then
cat(",") cat(",")
@ -507,6 +545,7 @@ function DiesalTools.Round(number, base)
base = base or 1 base = base or 1
return floor((number + base / 2) / base) * base return floor((number + base / 2) / base) * base
end end
--[[ Round a number for printing --[[ Round a number for printing
-- @Param number the number to round -- @Param number the number to round
-- @Param idp number of decimal points to round to [Default:1] -- @Param idp number of decimal points to round to [Default:1]
@ -567,6 +606,7 @@ end
function DiesalTools.Pack(...) function DiesalTools.Pack(...)
return { n = select("#", ...), ... } return { n = select("#", ...), ... }
end end
--[[ Unpack(...) --[[ Unpack(...)
@Arguments: @Arguments:
t table to unpack t table to unpack

@ -1 +1,5 @@
# DiesalLibs # DiesalLibs
Required Libraries:
- [LibSharedMedia 3.0](https://www.curseforge.com/wow/addons/libsharedmedia-3-0)
- [CallbackHandler 1.0](https://www.curseforge.com/wow/addons/callbackhandler)
Loading…
Cancel
Save