diff --git a/DiesalGUI-2.0/DiesalGUI-2.0.lua b/DiesalGUI-2.0/DiesalGUI-2.0.lua index 0a5edfe..68b5245 100644 --- a/DiesalGUI-2.0/DiesalGUI-2.0.lua +++ b/DiesalGUI-2.0/DiesalGUI-2.0.lua @@ -234,7 +234,7 @@ end -- Registers an Object constructor in the ObjectFactory ---@generic T : Diesal.Object.Type ---@param Type `T` ----@param constructor fun(name: string): T +---@param constructor fun(): T ---@param version number function DiesalGUI:RegisterObjectConstructor(Type, constructor, version) assert(type(constructor) == "function") @@ -366,7 +366,7 @@ function DiesalGUI:Release(object) object.frame:ClearAllPoints() object.frame:Hide() object.frame:SetParent(UIParent) - for k,v in pairs(object.userdata) do + for k, v in pairs(object.userdata) do object.userdata[k] = nil end releaseObject(object, object.type) @@ -399,7 +399,7 @@ end -- Mouse Input capture for any DiesalGUI interactive region ---@param frame Frame ----@param button MouseButton | "MouseWheel" +---@param button mouseButton | "MouseWheel" function DiesalGUI:OnMouse(frame, button) -- print(button) OnMouse(frame, button) diff --git a/DiesalGUI-2.0/Objects/Branch.lua b/DiesalGUI-2.0/Objects/Branch.lua index 021504d..d092600 100644 --- a/DiesalGUI-2.0/Objects/Branch.lua +++ b/DiesalGUI-2.0/Objects/Branch.lua @@ -281,7 +281,7 @@ local function Constructor() button:RegisterForClicks("RightButtonUp", "LeftButtonUp") button:RegisterForDrag("LeftButton") ---@param this Button - ---@param button MouseButton + ---@param button mouseButton button:SetScript("OnClick", function(this, button) DiesalGUI:OnMouse(this, button) if button == "LeftButton" then diff --git a/DiesalGUI-2.0/Objects/Button.lua b/DiesalGUI-2.0/Objects/Button.lua index 44a9d16..f49f4b6 100644 --- a/DiesalGUI-2.0/Objects/Button.lua +++ b/DiesalGUI-2.0/Objects/Button.lua @@ -96,7 +96,7 @@ local function Constructor(name) frame:SetFontString(text) ---@param this Button - ---@param button MouseButton + ---@param button mouseButton frame:SetScript("OnClick", function(this, button, ...) DiesalGUI:OnMouse(this, button) diff --git a/DiesalGUI-2.0/Objects/ComboBox.lua b/DiesalGUI-2.0/Objects/ComboBox.lua index a34e8e1..3236c06 100644 --- a/DiesalGUI-2.0/Objects/ComboBox.lua +++ b/DiesalGUI-2.0/Objects/ComboBox.lua @@ -217,6 +217,7 @@ local methods = { } ---@class DiesalComboBox : Diesal.GUI.Object.ComboBox + -- ~~| ComboBox Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ local function Constructor() ---@class Diesal.GUI.Object.ComboBox : Diesal.GUI.ObjectBase, Diesal.GUI.ComboBox.Methods @@ -284,7 +285,7 @@ local function Constructor() end) ---@param this Button - ---@param b MouseButton + ---@param b mouseButton button:SetScript("OnClick", function(this, b) self:FireEvent("OnButtonClick") diff --git a/DiesalGUI-2.0/Objects/DropDown.lua b/DiesalGUI-2.0/Objects/DropDown.lua index 3b87637..a250791 100644 --- a/DiesalGUI-2.0/Objects/DropDown.lua +++ b/DiesalGUI-2.0/Objects/DropDown.lua @@ -313,7 +313,8 @@ local methods = { dropdownItem:SetSelected(true) selectedCount = selectedCount + 1 if not self.settings.multiSelect then - 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 end selectionTable[#selectionTable + 1] = dropdownItem.settings.key end @@ -406,7 +407,7 @@ local methods = { end end, ---@param self Diesal.GUI.Object.DropDown - ---@param button MouseButton + ---@param button mouseButton ---@param down boolean OnClick = function(self, button, down) if button == "LeftButton" then diff --git a/DiesalGUI-2.0/Objects/ScrollingEditBox.lua b/DiesalGUI-2.0/Objects/ScrollingEditBox.lua index 3b1dba7..3bb57db 100644 --- a/DiesalGUI-2.0/Objects/ScrollingEditBox.lua +++ b/DiesalGUI-2.0/Objects/ScrollingEditBox.lua @@ -141,7 +141,8 @@ local methods = { self.grip:SetPoint("TOP", 0, -gripPositionOnTrack) end, ["SetVerticalScroll"] = function(self, scroll) -- user scrolled only - self.settings.forceScrollBottom = DiesalTools.Round(scroll) == DiesalTools.Round(self.scrollFrame:GetVerticalScrollRange()) + self.settings.forceScrollBottom = DiesalTools.Round(scroll) == + DiesalTools.Round(self.scrollFrame:GetVerticalScrollRange()) self.scrollFrame:SetVerticalScroll(scroll) end, ["SetText"] = function(self, txt) @@ -154,8 +155,8 @@ local methods = { ---@class DiesalScrollingEditBox : Diesal.GUI.Object.ScrollingEditBox ---@class Diesal.GUI.Object.ScrollingEditBox.Settings : Diesal.GUI.Object.ScrollingEditBox.Defaults ----@field justifyH JustifyH ----@field justifyV JustifyV +---@field justifyH JustifyHorizontal +---@field justifyV JustifyVertical ---@field contentHeight? number ---@field text? string diff --git a/DiesalStyle-2.0/DiesalStyle-2.0.lua b/DiesalStyle-2.0/DiesalStyle-2.0.lua index e04a24f..d6fd7df 100644 --- a/DiesalStyle-2.0/DiesalStyle-2.0.lua +++ b/DiesalStyle-2.0/DiesalStyle-2.0.lua @@ -111,7 +111,8 @@ local function GetBlizzColorValues(value) if type(value) == "table" and #value >= 3 then return value[1] / 255, value[2] / 255, value[3] / 255 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 @@ -173,17 +174,22 @@ end local function setColor(texture, r, g, b, a) local status, err = pcall(texture.SetColorTexture, texture, r, g, b, a) if not status then - errorhandler('error in "' .. (texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting", r, g, b, a) + errorhandler( + 'error in "' .. (texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting", r, g, + b, + a) end end local function setGradient(texture, orientation, r1, g1, b1, a1, r2, g2, b2, a2) - local status, err = pcall(texture.SetGradient, texture, orientation, CreateColorDiesal(r1, g1, b1, a1), CreateColorDiesal(r2, g2, b2, a2)) + local status, err = pcall(texture.SetGradient, texture, orientation, CreateColorDiesal(r1, g1, b1, a1), + CreateColorDiesal(r2, g2, b2, a2)) if not status then - errorhandler('error in "' .. (texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting.") + errorhandler('error in "' .. + (texture.style.name or "texture") .. '" ' .. texture.style.mode .. " or alpha setting.") end end -- ~~| Media |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ do -- google material colors Colors.red_50 = "fde0dc" Colors.red_100 = "f9bdbb" @@ -453,18 +459,24 @@ do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Colors.UI_200 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.07) -- level 3 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, 0.11) } + Colors.UI_300_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.12), HSL(Colors.UI_Hue, Colors.UI_Saturation, + 0.11) } 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, 0.14) } + Colors.UI_350_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.17), HSL(Colors.UI_Hue, Colors.UI_Saturation, + 0.14) } -- level 4 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, 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_400_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.20), HSL(Colors.UI_Hue, Colors.UI_Saturation, + 0.17) } + Colors.UI_450_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.24), HSL(Colors.UI_Hue, Colors.UI_Saturation, + 0.20) } -- level 5 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, 0.26) } + Colors.UI_500_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.29), HSL(Colors.UI_Hue, Colors.UI_Saturation, + 0.26) } - Colors.UI_600_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.35), HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.32) } + Colors.UI_600_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.35), HSL(Colors.UI_Hue, Colors.UI_Saturation, + 0.32) } -- font Colors -35 Colors.UI_F450 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 0.75) @@ -502,65 +514,7 @@ end do -- | Text Formatters |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Formatters.tooltip = "|cff" .. Colors.gray_50 .. "%s\n|cff" .. Colors.yellow_500 .. "%s" end ---[[ do -- | Set Media |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - addMedia("font", "calibrib", "Fonts\\calibrib.ttf") - addMedia("font", "DejaVuSansMono", "Fonts\\DejaVuSansMono.ttf") -- Monospaced - addMedia("font", "DejaVuSansMonoBold", "Fonts\\DejaVuSansMono-Bold.ttf") -- Monospaced - addMedia("font", "FFF Intelligent Thin Condensed", "Fonts\\FFF Intelligent Thin Condensed.ttf") -- pixel fonts - addMedia("font", "FiraMonoBold", "Fonts\\FiraMono-Bold.ttf") -- Monospaced - addMedia("font", "FiraMonoMedium", "Fonts\\FiraMono-Medium.ttf") -- Monospaced - addMedia("font", "FiraMonoRegular", "Fonts\\FiraMono-Regular.ttf") -- Monospaced - addMedia("font", "FiraSans", "Fonts\\FiraSans-Regular.ttf") -- pixel fonts - addMedia("font", "HackBold", "Fonts\\Hack-Bold.ttf") -- Monospaced - addMedia("font", "HackRegular", "Fonts\\Hack-Regular.ttf") -- Monospaced - addMedia("font", "InconsolataBold", "Fonts\\Inconsolata-Bold.ttf") -- Monospaced - addMedia("font", "InconsolataRegular", "Fonts\\Inconsolata-Regular.ttf") -- Monospaced - addMedia("font", "LucidiaMono", "Fonts\\LUCON.ttf") -- Monospaced - addMedia("font", "MonoFur", "Fonts\\monof55.ttf") -- Monospaced - addMedia("font", "MonoFurItalic", "Fonts\\monof56.ttf") -- Monospaced - addMedia("font", "OfficeCodeProBold", "Fonts\\OfficeCodePro-Bold.ttf") -- Monospaced - addMedia("font", "OfficeCodeProMedium", "Fonts\\OfficeCodePro-Medium.ttf") -- Monospaced - addMedia("font", "OfficeCodeProRegular", "Fonts\\OfficeCodePro-Regular.ttf") -- Monospaced - addMedia("font", "RobotoMonoBold", "Fonts\\RobotoMono-Bold.ttf") -- Monospaced - addMedia("font", "RobotoMonoMedium", "Fonts\\RobotoMono-Medium.ttf") -- Monospaced - addMedia("font", "RobotoMonoRegular", "Fonts\\RobotoMono-Regular.ttf") -- Monospaced - addMedia("font", "SourceCodeProBlack", "Fonts\\SourceCodePro-Black.ttf") -- Monospaced - addMedia("font", "SourceCodeProBold", "Fonts\\SourceCodePro-Bold.ttf") -- Monospaced - addMedia("font", "SourceCodeProMedium", "Fonts\\SourceCodePro-Medium.ttf") -- Monospaced - addMedia("font", "SourceCodeProRegular", "Fonts\\SourceCodePro-Regular.ttf") -- Monospaced - addMedia("font", "SourceCodeProSemibold", "Fonts\\SourceCodePro-Semibold.ttf") -- Monospaced - addMedia("font", "Standard0755", "Fonts\\Standard0755.ttf") -- pixel fonts - addMedia("font", "UbuntuMonoBold", "Fonts\\UbuntuMono-B.ttf") -- Monospaced - addMedia("font", "UbuntuMonoRegular", "Fonts\\UbuntuMono-R.ttf") -- Monospaced - - addMedia("texture", "DiesalGUIcons", "Textures\\DiesalGUIcons16x256x128.tga") -- Icon Textures - addMedia("texture", "DiesalGUIcons64", "Textures\\DiesalGUIcons64x256x256.tga") -- Icon Textures - addMedia("texture", "DiesalGUIcons32", "Textures\\DiesalGUIcons32x256x256.tga") -- Icons Textures - addMedia("texture", "DiesalButtonIcons32", "Textures\\DiesalButtonIcons32x128x512.tga") -- Icons Textures - - addMedia("border", "shadow", "Textures\\shadow.tga") -- Shadows - addMedia("border", "shadowNoDist", "Textures\\shadowNoDist.tga") -- Shadows -end ]] - ---[[ do -- | Add LibSharedMedia |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - local font = getMedia("font", "calibrib") - if font then - LibSharedMedia:Register("font", "Calibri Bold", font) - end - font = getMedia("font", "FiraSans") - if font then - LibSharedMedia:Register("font", "Fira Sans", font) - end - - font = getMedia("font", "Standard0755") - if font then - LibSharedMedia:Register("font", "Standard0755", font) - end - font = getMedia("font", "FFF Intelligent Thin Condensed") - if font then - LibSharedMedia:Register("font", "FFF Intelligent", font) - end -end ]] + DiesalFontNormal = CreateFont("DiesalFontNormal") DiesalFontNormal:SetFont("Fonts\\OpenSans-Regular.ttf", 11, "") @@ -573,49 +527,13 @@ DiesalFontNormalOutline:SetFont("Fonts\\OpenSans-Regular.ttf", 11, "OUTLINE") for _, fontName in pairs(GetFonts()) do if fontName == "FontAwesome_L" and FontAwesome_L then - - local file, height, flags = FontAwesome_L--[[@as Font]]:GetFont() + local file, height, flags = (FontAwesome_L --[[@as Font]]):GetFont() if file then - DiesalFontAwesomeRegular:SetFont(file, 11, "") + DiesalFontAwesomeRegular:SetFont(file, 11, flags or "") end end end ---[[ do - DiesalFontAwesomeRegular = CreateFont("DiesalFontAwesomeRegular") - DiesalFontAwesomeRegular:SetFont("Fonts\\FontAwesomeProRegular.otf", 11, "") -end ]] - ---[[ do -- | Set Fonts |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - DiesalFontNormal = CreateFont("DiesalFontNormal") - DiesalFontNormal:SetFont("Fonts\\OpenSans-Regular.ttf", 11, "") --SetFont("Fonts\\SourceCodePro-Regular.ttf", 11, "") - - local font = getMedia("font", "calibrib") - if font then - DiesalFontNormalOutline = CreateFont("DiesalFontNormalOutline") - DiesalFontNormalOutline:SetFont(font, 11, "OUTLINE") - end - - font = getMedia("font", "Standard0755") - if font then - DiesalFontPixel = CreateFont("DiesalFontPixel") - DiesalFontPixel:SetFont(font, 8, "") - end - - font = getMedia("font", "Standard0755") - if font then - DiesalFontPixelOutLine = CreateFont("DiesalFontPixelOutLine") - DiesalFontPixelOutLine:SetFont(font, 8, "OUTLINE, MONOCHROME") - DiesalFontPixelOutLine:SetSpacing(2) - end - - font = getMedia("font", "FFF Intelligent Thin Condensed") - if font then - DiesalFontPixel2 = CreateFont("DiesalFontPixel2") - DiesalFontPixel2:SetFont(font, 8, "OUTLINE, MONOCHROME") - end -end ]] - local bytemarkers = { { 0x7FF, 192 }, { 0xFFFF, 224 }, { 0x1FFFFF, 240 } } ---@param decimal number @@ -638,346 +556,6 @@ function DiesalStyle:UTF8(decimal) return table.concat(charbytes) end ---[[ do -- Set Icons - ---@class DiesalStyle.Icon.Coords - ---@field column integer - ---@field row integer - - ---@class DiesalStyle.Icon.File - ---@field prefix { [1]: string, [2]: string, [3]: string } - ---@field size { width: integer, height: integer, icon: integer } - - ---@class DiesalStyle.Icon - ---@field name string - ---@field file DiesalStyle.Icon.File - ---@field coords DiesalStyle.Icon.Coords - - ---@class DiesalStyle.Icons : { [string]: table>>>>> } - DiesalStyle.Icons = DiesalStyle.Icons or {} - - local Icons = DiesalStyle.Icons - - ---@class DiesalStyle.IconsByFileColumnRow : { [string]: DiesalStyle.Icon } - local IconsByFileColumnRow = {} - - ---@class DiesalStyle.IconsByName : { [string]: DiesalStyle.Icon } - local IconsByName = {} - - function DiesalStyle.AddIcons(iconsToAdd) - assert(type(iconsToAdd) == "table", "iconsToAdd parameter (1) should be a table") - - local prefixInfo = { - [1] = { prefix = "prefix1", count = 1, file = 1, iconSize = 1 }, - [2] = { prefix = "prefix2", count = 1, file = 1, iconSize = 1 }, - [3] = { prefix = "prefix3", count = 1, file = 1, iconSize = 1 }, - } - - ---@param prefix integer - ---@param key string - ---@param table table - local function checkType(prefix, key, table) - assert(type(key) == "string", 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)) - end - - for p1, p1Table in pairs(iconsToAdd) do - checkType(1, p1, p1Table) - Icons[p1] = Icons[p1] or {} - for p2, p2Table in pairs(p1Table) do - checkType(2, p2, p2Table) - Icons[p1][p2] = Icons[p1][p2] or {} - for p3, p3Table in pairs(p2Table) do - checkType(3, p3, p3Table) - local filePrefixes = string.format("%s%s%s", p1, p2, p3) - Icons[p1][p2][p3] = Icons[p1][p2][p3] or {} - for iconSize, fileDimTable in pairs(p3Table) do - assert(type(iconSize) == "number", string.format("icon size key %d for %s is not a number.", prefixInfo[3].iconSize, filePrefixes)) - filePrefixes = string.format("%s[%d]", filePrefixes, iconSize) - Icons[p1][p2][p3][iconSize] = Icons[p1][p2][p3][iconSize] or {} - for fileDimKey, iconColumns in pairs(fileDimTable) do - assert(type(fileDimKey == "string"), string.format("file dimensions key for file %d in %s is not a string.", prefixInfo[3].file, filePrefixes)) - local fileDims = strsplittable("x", fileDimKey, 2) - - assert(type(tonumber(fileDims[1])) == "number", 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)) - Icons[p1][p2][p3][iconSize][fileDimKey] = Icons[p1][p2][p3][iconSize][fileDimKey] or {} - - filePrefixes = string.format("%s[%s]", filePrefixes, fileDimKey) - - local fileWidth = tonumber(fileDims[1]) or 0 - local fileHeight = tonumber(fileDims[2]) or 0 - local maxColumns = math.floor(fileWidth / iconSize) - local maxRows = math.floor(fileHeight / iconSize) - - local iconsFileTable = Icons[p1][p2][p3][iconSize][fileDimKey] - - local columnCount = 0 - local rowCount = 0 - for column, rows in pairs(iconColumns) do - columnCount = columnCount + 1 - assert(type(column) == "number", 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)) - local filePrefixesColumn = string.format("%s[%d]", filePrefixes, column) - iconsFileTable[column] = iconsFileTable[column] or {} - for row, icon in pairs(rows) do - rowCount = rowCount + 1 - assert(type(row) == "number", 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)) - - local filePrefixesColumnRow = string.format("%s[%d]", filePrefixesColumn, row) - local iconName = icon - - iconsFileTable[column][row] = { - name = iconName, - file = { - prefix = { - [1] = p1, - [2] = p2, - [3] = p3, - }, - size = { - width = fileWidth, - height = fileHeight, - icon = iconSize, - }, - }, - coords = { - column = column, - row = row, - }, - } - IconsByName[iconName] = IconsByName[iconName] or iconsFileTable[column][row] - IconsByFileColumnRow[filePrefixesColumnRow] = iconsFileTable[column][row] - end - rowCount = 1 - end - prefixInfo[3].file = prefixInfo[3].file + 1 - end - prefixInfo[3].iconSize = prefixInfo[3].iconSize + 1 - end - prefixInfo[3].count = prefixInfo[3].count + 1 - end - prefixInfo[2].count = prefixInfo[2].count + 1 - end - prefixInfo[1].count = prefixInfo[1].count + 1 - end - end - - ---@param iconTable DiesalStyle.Icon - local function CreateIconStyle(iconTable) - local fileName = string.format("%s%s%s", iconTable.file.prefix[1], iconTable.file.prefix[2], iconTable.file.prefix[3]) - local iconSize = iconTable.file.size.icon - - fileName = fileName .. (iconSize ~= 16 and iconSize or "") - local fileWidth = iconTable.file.size.width - local fileHeight = iconTable.file.size.height - local column = iconTable.coords.column - local row = iconTable.coords.row - return { - fileName, - { - column, - row, - iconSize, - fileWidth, - fileHeight, - }, - } - end - - ---@param iconName string - function DiesalStyle.GetIconStyleByName(iconName) - return IconsByName[iconName] and CreateIconStyle(IconsByName[iconName]) or {} - end - - -- [prefix1][prefix2][prefix3][iconSize][fileWidthxfileHeight][column][row] - -- DiesalGUIcons16x256x128.tga, Column 3, Row 4 - -- [Diesal][GUI][cons][16][256x128][3][4] - ---@param iconFile string - function DiesalStyle.GetIconByFileColumnRow(iconFile) - return IconsByFileColumnRow[iconFile] and CreateIconStyle(IconsByFileColumnRow[iconFile]) or {} - end - - -- Camel Case File Name - local DefaultDiesalIcons = { - -- Prefix 1 - Diesal = { - -- Prefix 2 - Button = { - -- Prefix 3 - Icons = { - -- Icon Size - [32] = { - -- WidthxHeight - ["128x512"] = { - [1] = { - [1] = "background-horseshoe", - [2] = "hover-horseshoe", - [3] = "normal-horseshoe", - }, - [2] = { - [1] = "background-crosshair", - [2] = "hover-crosshair", - [3] = "normal-crosshair", - }, - [3] = { - [1] = "background-crossbones", - [2] = "hover-crossbones", - [3] = "normal-crossbones", - }, - [4] = { - [1] = "background-tag", - [2] = "hover-tag", - [3] = "normal-tag", - }, - [5] = { - [1] = "background-crossed-swords", - [2] = "hover-crossed-swords", - [3] = "normal-crossed-swords", - }, - [6] = { - [1] = "background-oc", - [2] = "hover-oc", - [3] = "normal-oc", - }, - }, - }, - }, - }, - -- Prefix 2 - GU = { - -- Prefix 3 - Icons = { - -- Icon Size - [16] = { - -- WidthxHeight - ["256x128"] = { - -- Column 1 - [1] = { - -- Row 1 - [1] = "solid-white-arrow-up", - [4] = "outline-textured-rewind", - [5] = "outline-textured-question-mark", - [6] = "outline-textured-cirle-plus", - [7] = "outline-textured-file", - [8] = "outline-blue-folder-closed", - }, - [2] = { - [1] = "solid-white-arrow-down", - [4] = "outline-textured-pause", - [5] = "outline-textured-cog", - [6] = "outline-textured-cirle-minus", - [7] = "outline-textured-folder", - [8] = "outline-blue-folder-opened", - }, - [3] = { - [1] = "solid-white-arrow-right", - [4] = "outline-textured-play", - [5] = "outline-textured-reload", - [6] = "outline-textured-square-minus", - [7] = "outline-textured-folder-plus", - [8] = "outline-white-file", - }, - [4] = { - [1] = "solid-white-arrow-left", - [4] = "outline-textured-fast-forward", - [5] = "outline-textured-home", - [6] = "outline-textured-square-plus", - [7] = "outline-textured-folder-minus", - [8] = "outline-multi-cluster", - }, - [5] = { - [1] = "solid-white-circle", - [4] = "outline-textured-back", - [5] = "outline-textured-arrow-down", - [8] = "outline-textured-diskette", - }, - [6] = { - [4] = "outline-textured-forward", - [5] = "outline-textured-arrow-up", - }, - [7] = { - [5] = "outline-textured-arrow-right", - }, - [8] = { - [5] = "outline-textured-arrow-left", - }, - [9] = { - [5] = "outline-textured-arrow-close", - }, - [10] = { - [5] = "outline-textured-check", - }, - [11] = { - [5] = "outline-textured-lock-unclocked", - }, - [12] = { - [5] = "outline-textured-lock-locked", - }, - [13] = { - [5] = "outline-textured-lock-delete", - }, - [14] = { - [4] = "outline-textured-circle", - [5] = "outline-textured-power", - }, - [15] = { - [4] = "outline-textured-dropplet-down", - [5] = "outline-textured-ellipse", - }, - [16] = { - [4] = "outline-textured-dropplet-square", - }, - }, - }, - [32] = { - ["256x256"] = { - [1] = { - [1] = "white-horseshoe", - [2] = "black-horseshoe", - }, - [2] = { - [1] = "white-crosshair", - [2] = "black-crosshair", - }, - [3] = { - [1] = "white-crossbones", - [2] = "black-crossbones", - }, - [4] = { - [1] = "white-tag", - [2] = "black-tag", - }, - [5] = { - [1] = "white-crossed-swords", - [2] = "black-crossed-swords", - }, - [6] = { - [1] = "white-oc", - [2] = "black-oc", - }, - }, - }, - [64] = { - ["256x256"] = { - [1] = { - [1] = "marker-droplette-yellow-diamond", - }, - [2] = { - [1] = "marker-droplette-green-leaf", - }, - [3] = { - [1] = "marker-droplette-teal-star", - }, - }, - }, - }, - }, - }, - } - - DiesalStyle.AddIcons(DefaultDiesalIcons) -end ]] -- ~~| DiesalStyle API |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --[[ Texture style table format @@ -1140,8 +718,10 @@ function DiesalStyle:StyleTexture(texture, style) texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 } -- gradient if texture.style.gradient then - texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or DEFAULT_GRADIENT_ORIENTATION - texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or { DEFAULT_COLOR, DEFAULT_COLOR } + texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or + DEFAULT_GRADIENT_ORIENTATION + texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or + { DEFAULT_COLOR, DEFAULT_COLOR } end -- image if texture.style.image then @@ -1177,7 +757,8 @@ function DiesalStyle:StyleTexture(texture, style) end if style.debug then - print(texture:GetHeight(), texture.style.position[1], texture.style.position[2], texture.style.position[3], texture.style.position[4]) + print(texture:GetHeight(), texture.style.position[1], texture.style.position[2], texture.style.position[3], + texture.style.position[4]) end -- [1] Texture > [2] gradient > [3] color if texture.style.image then -- [1] Texture @@ -1185,10 +766,12 @@ function DiesalStyle:StyleTexture(texture, style) texture.style.mode = "image" -- clear any old settings 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 - texture:SetTexCoord(texture.style.image.coords[1], texture.style.image.coords[2], texture.style.image.coords[3], 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:SetTexCoord(texture.style.image.coords[1], texture.style.image.coords[2], texture.style.image.coords[3], + 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:SetHorizTile(texture.style.image.tiling[1] and true) texture:SetVertTile(texture.style.image.tiling[2] and true) local r, g, b = GetBlizzColorValues(texture.style.image.color) @@ -1197,18 +780,21 @@ function DiesalStyle:StyleTexture(texture, style) -- set mode texture.style.mode = "gradient" -- clear any old settings - texture:SetTexture() -- clear image + texture:SetTexture() -- clear image texture:SetColorTexture(1, 1, 1, 1) -- clear color -- apply settings - local r1, g1, b1 = GetBlizzColorValues(texture.style.gradient.color[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 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] + local r1, g1, b1 = GetBlizzColorValues(texture.style.gradient.color + [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 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) elseif texture.style.color then -- [3] color -- set mode texture.style.mode = "color" -- 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 -- apply settings local r, g, b = GetBlizzColorValues(texture.style.color) @@ -1217,9 +803,9 @@ function DiesalStyle:StyleTexture(texture, style) -- set mode texture.style.mode = "none!" -- clear the texture - texture:SetTexture() -- clear image + texture:SetTexture() -- clear image 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 @@ -1248,7 +834,8 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT color = style.gradient[2] and style.gradient[3] and { style.gradient[2], style.gradient[3] }, } end - style.gradient_orientation = style.gradient_orientation and style.gradient_orientation:upper() --formatOrientation(style.gradient_orientation) -- fuck you + style.gradient_orientation = style.gradient_orientation and + 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 texture.style.gradient = {} end @@ -1261,8 +848,10 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 } -- gradient if texture.style.gradient then - texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or DEFAULT_GRADIENT_ORIENTATION - texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or { DEFAULT_COLOR, DEFAULT_COLOR } + texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or + DEFAULT_GRADIENT_ORIENTATION + texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or + { DEFAULT_COLOR, DEFAULT_COLOR } end -- | Apply Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1343,11 +932,11 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT -- set mode texture.style.mode = "gradient" -- clear any old settings - leftTexture:SetTexture() -- clear image + leftTexture:SetTexture() -- clear image -- leftTexture:SetAlpha(1) -- reset alpha - rightTexture:SetTexture() -- clear image + rightTexture:SetTexture() -- clear image -- rightTexture:SetAlpha(1) -- reset alpha - topTexture:SetTexture() -- clear image + topTexture:SetTexture() -- clear image -- topTexture:SetAlpha(1) -- reset alpha bottomTexture:SetTexture() -- clear image -- bottomTexture:SetAlpha(1) -- reset alpha @@ -1358,7 +947,7 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT -- clear settings setGradient(leftTexture, "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 -- aply settings @@ -1372,7 +961,7 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT setGradient(bottomTexture, "HORIZONTAL", r1, g1, b1, a1, r2, g2, b2, a2) elseif texture.style.gradient.orientation == "VERTICAL" then -- 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 setGradient(topTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) setGradient(bottomTexture, "HORIZONTAL", 1, 1, 1, 1, 1, 1, 1, 1) @@ -1409,18 +998,18 @@ function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomT -- set mode texture.style.mode = "none!" -- clear the texture - leftTexture:SetTexture() -- clear image - setGradient(leftTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient - leftTexture:SetColorTexture(0, 0, 0, 0) -- clear color - rightTexture:SetTexture() -- clear image - setGradient(rightTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient - rightTexture:SetColorTexture(0, 0, 0, 0) -- clear color - topTexture:SetTexture() -- clear image - setGradient(topTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient - topTexture:SetColorTexture(0, 0, 0, 0) -- clear color - bottomTexture:SetTexture() -- clear image + leftTexture:SetTexture() -- clear image + setGradient(leftTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + leftTexture:SetColorTexture(0, 0, 0, 0) -- clear color + rightTexture:SetTexture() -- clear image + setGradient(rightTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + rightTexture:SetColorTexture(0, 0, 0, 0) -- clear color + topTexture:SetTexture() -- clear image + setGradient(topTexture, "HORIZONTAL", 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + topTexture:SetColorTexture(0, 0, 0, 0) -- clear color + bottomTexture:SetTexture() -- clear image 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 @@ -1441,7 +1030,7 @@ end ---@param frame Frame ---@param style Diesal.Style.ShadowStyle function DiesalStyle:StyleShadow(object, frame, style) - object.shadow = object.shadow or CreateFrame("Frame",nil,frame) + object.shadow = object.shadow or CreateFrame("Frame", nil, frame) object.shadow:Show() if not object.shadow.style or style.clear then object.shadow.style = {} @@ -1449,9 +1038,11 @@ function DiesalStyle:StyleShadow(object, frame, style) local shadowStyle = object.shadow.style -- ~~ Format New Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ local red, green, blue = DiesalTools.GetColor(style.color) - local offset = style.offset and type(style.offset) == "number" and { style.offset, style.offset, style.offset, style.offset } or style.offset + local offset = style.offset and type(style.offset) == "number" and + { style.offset, style.offset, style.offset, style.offset } or style.offset -- Setting ~~~~~~~~~~~~~~~~~~~~~~~ New Setting ~~~~~~~~~~~~~~~ Old Setting ~~~~~~~~~~~~~~~~~ Default ~~~~~~~~~~~~~~~~~~ - shadowStyle.edgeFile = style.edgeFile or shadowStyle.edgeFile or [[Interface\Buttons\WHITE8X8]] -- getMedia("border", "shadow") + shadowStyle.edgeFile = style.edgeFile or shadowStyle.edgeFile or + [[Interface\Buttons\WHITE8X8]] -- getMedia("border", "shadow") shadowStyle.edgeSize = style.edgeSize or shadowStyle.edgeSize or 5 shadowStyle.red = red or shadowStyle.red or 0