parent
d9fbab066c
commit
328b9c77e3
@ -1,6 +1,65 @@ |
||||
{ |
||||
"Lua.diagnostics.globals": [ |
||||
"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" |
||||
] |
||||
} |
@ -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) |
@ -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) |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue