Various changes #1

Merged
omicron merged 11 commits from absorb into main 2025-08-24 12:40:06 +00:00
10 changed files with 38 additions and 44 deletions
Showing only changes of commit f181c0022c - Show all commits

1
.stylua.toml Normal file
View File

@@ -0,0 +1 @@
indent_type = "Spaces"

View File

@@ -88,7 +88,7 @@ Commander.RegisterCommand("omi-pstart", {
PrintLn("To enable the script profiler run `/console scriptProfile 1`, then reload the UI.") PrintLn("To enable the script profiler run `/console scriptProfile 1`, then reload the UI.")
return return
end end
end end,
}) })
Commander.RegisterCommand("omi-pstop", { Commander.RegisterCommand("omi-pstop", {
@@ -117,7 +117,9 @@ Commander.RegisterCommand("omi-pstop", {
time = time * 1000, time = time * 1000,
}) })
end end
table.sort(data, function(a, b) return a.time < b.time end) table.sort(data, function(a, b)
return a.time < b.time
end)
end, end,
}) })
@@ -136,5 +138,5 @@ Commander.RegisterCommand("omi-pprint", {
local ms_per_sec = time / total local ms_per_sec = time / total
Printf("% 6.1f%% % 7.2fms %7.2fms/s %s\n", pct, time, ms_per_sec, item.name) Printf("% 6.1f%% % 7.2fms %7.2fms/s %s\n", pct, time, ms_per_sec, item.name)
end end
end end,
}) })

View File

@@ -26,13 +26,10 @@ local Indicator = types.CreateClass("Indicator")
types.Indicator = Indicator types.Indicator = Indicator
--- Show the indicator and supply it with data --- Show the indicator and supply it with data
function Indicator:Show(data) function Indicator:Show(data) end
end
--- Update the indicator with new data --- Update the indicator with new data
function Indicator:Update(data) function Indicator:Update(data) end
end
--- Hide the indicator --- Hide the indicator
function Indicator:Hide() function Indicator:Hide() end
end

View File

@@ -21,7 +21,9 @@ types.StatusBar = types.CreateClass("StatusBar")
local StatusBar = types.StatusBar local StatusBar = types.StatusBar
function StatusBar:Init(parent, width, height, level, top, texture, bgtexture) function StatusBar:Init(parent, width, height, level, top, texture, bgtexture)
if top == nil then top = true end if top == nil then
top = true
end
level = level or 0 level = level or 0
-- parent: the parent frame -- parent: the parent frame
self.parent = parent self.parent = parent

View File

@@ -27,20 +27,13 @@ local Trigger = types.Trigger
local AuraTrigger = types.CreateClass("AuraTrigger", Trigger) local AuraTrigger = types.CreateClass("AuraTrigger", Trigger)
types.AuraTrigger = AuraTrigger types.AuraTrigger = AuraTrigger
---Creates a new AuraTrigger from a config description and attaches it to the ---Creates a new AuraTrigger from a config description and attaches it to the
---correct data source ---correct data source
---@param unit UnitFrame ---@param unit UnitFrame
---@param config table ---@param config table
---@return AuraTrigger ---@return AuraTrigger
function AuraTrigger.CreateFromConfig(unit, config) function AuraTrigger.CreateFromConfig(unit, config)
local trigger = AuraTrigger:new( local trigger = AuraTrigger:new(config.spellId, config.own, config.requiredCount, config.invert, config.defaultData)
config.spellId,
config.own,
config.requiredCount,
config.invert,
config.defaultData
)
unit.auras:AddTrigger(trigger) unit.auras:AddTrigger(trigger)
return trigger return trigger
end end

View File

@@ -1,7 +1,7 @@
-- Copyright 2023 <omicron.me@protonmail.com> -- Copyright 2023 <omicron.me@protonmail.com>
-- --
-- This file is part of Omicron Frames -- This file is part of Omicron Frames
-- --
-- Omicron Frames is free software: you can redistribute it and/or modify it -- Omicron Frames is free software: you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the Free -- under the terms of the GNU General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) -- Software Foundation, either version 3 of the License, or (at your option)
@@ -13,7 +13,7 @@
-- more details. -- more details.
-- --
-- You should have received a copy of the GNU General Public License along with -- You should have received a copy of the GNU General Public License along with
-- Omicron Frames. If not, see <https://www.gnu.org/licenses/>. -- Omicron Frames. If not, see <https://www.gnu.org/licenses/>.
local omi = select(2, ...) local omi = select(2, ...)
local types = omi.GetModule("types") local types = omi.GetModule("types")
@@ -26,7 +26,7 @@ local Trigger = types.Trigger
---indicator. ---indicator.
---@class MultiTrigger: Trigger ---@class MultiTrigger: Trigger
---@field active boolean ---@field active boolean
---@field invert boolean ---@field invert boolean
local MultiTrigger = types.CreateClass("MultiTrigger", Trigger) local MultiTrigger = types.CreateClass("MultiTrigger", Trigger)
types.MultiTrigger = MultiTrigger types.MultiTrigger = MultiTrigger
@@ -73,7 +73,7 @@ function MultiTrigger:AddTrigger(trigger)
end, end,
Hide = function(_, data) Hide = function(_, data)
self:OnChildDeactivate(idx, trigger, data) self:OnChildDeactivate(idx, trigger, data)
end end,
}) })
end end
@@ -141,4 +141,3 @@ end
function MultiTrigger:Reset() function MultiTrigger:Reset()
self:SetState(false) self:SetState(false)
end end

View File

@@ -1,7 +1,7 @@
-- Copyright 2023 <omicron.me@protonmail.com> -- Copyright 2023 <omicron.me@protonmail.com>
-- --
-- This file is part of Omicron Frames -- This file is part of Omicron Frames
-- --
-- Omicron Frames is free software: you can redistribute it and/or modify it -- Omicron Frames is free software: you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the Free -- under the terms of the GNU General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) -- Software Foundation, either version 3 of the License, or (at your option)
@@ -13,7 +13,7 @@
-- more details. -- more details.
-- --
-- You should have received a copy of the GNU General Public License along with -- You should have received a copy of the GNU General Public License along with
-- Omicron Frames. If not, see <https://www.gnu.org/licenses/>. -- Omicron Frames. If not, see <https://www.gnu.org/licenses/>.
local omi = select(2, ...) local omi = select(2, ...)
local types = omi.GetModule("types") local types = omi.GetModule("types")
---@class Trigger ---@class Trigger
@@ -29,8 +29,7 @@ types.StatusTrigger = StatusTrigger
---@param unit UnitFrame ---@param unit UnitFrame
---@param config table ---@param config table
function StatusTrigger.CreateFromConfig(unit, config) function StatusTrigger.CreateFromConfig(unit, config)
local trigger = StatusTrigger:new(config.status, config.requiredCount, local trigger = StatusTrigger:new(config.status, config.requiredCount, config.invert, config.defaultData)
config.invert, config.defaultData)
unit.auras:AddTrigger(trigger) unit.auras:AddTrigger(trigger)
return trigger return trigger
end end
@@ -45,7 +44,7 @@ end
--- Initialize a new AuraTrigger object --- Initialize a new AuraTrigger object
---@param status string The kind of status to trigger on ---@param status string The kind of status to trigger on
---@param requiredCount number | nil ---@param requiredCount number | nil
---@param invert boolean | nil ---@param invert boolean | nil
function StatusTrigger:Init(status, requiredCount, invert, defaultData) function StatusTrigger:Init(status, requiredCount, invert, defaultData)
Trigger.Init(self, invert, defaultData) Trigger.Init(self, invert, defaultData)

View File

@@ -1,7 +1,7 @@
-- Copyright 2023 <omicron.me@protonmail.com> -- Copyright 2023 <omicron.me@protonmail.com>
-- --
-- This file is part of Omicron Frames -- This file is part of Omicron Frames
-- --
-- Omicron Frames is free software: you can redistribute it and/or modify it -- Omicron Frames is free software: you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the Free -- under the terms of the GNU General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) -- Software Foundation, either version 3 of the License, or (at your option)
@@ -13,22 +13,21 @@
-- more details. -- more details.
-- --
-- You should have received a copy of the GNU General Public License along with -- You should have received a copy of the GNU General Public License along with
-- Omicron Frames. If not, see <https://www.gnu.org/licenses/>. -- Omicron Frames. If not, see <https://www.gnu.org/licenses/>.
local omi = select(2, ...) local omi = select(2, ...)
local types = omi.GetModule("types") local types = omi.GetModule("types")
--- Triggers objects provide a link between indicators and some data source. They --- Triggers objects provide a link between indicators and some data source. They
-- can pass data from the data source into the indicator. This is a supertype for -- can pass data from the data source into the indicator. This is a supertype for
-- all triggers and should not be constructed on its own. -- all triggers and should not be constructed on its own.
---@class Trigger: Object ---@class Trigger: Object
---@field active boolean ---@field active boolean
---@field invert boolean ---@field invert boolean
---@field indicator Indicator ---@field indicator Indicator
---@field data table The most recent data updated by the data source ---@field data table The most recent data updated by the data source
local Trigger = types.CreateClass("Trigger") local Trigger = types.CreateClass("Trigger")
types.Trigger = Trigger types.Trigger = Trigger
---@param unit UnitFrame ---@param unit UnitFrame
---@param config table ---@param config table
---@return Trigger ---@return Trigger
@@ -91,4 +90,3 @@ end
function Trigger:Reset() function Trigger:Reset()
self:SetState(false, false) self:SetState(false, false)
end end

View File

@@ -24,7 +24,7 @@ local function CreateClassRaw(name, parent)
c.__typeInfo = { c.__typeInfo = {
name = name, name = name,
class = c, class = c,
parent = parent parent = parent,
} }
c.__index = c c.__index = c
if parent ~= nil then if parent ~= nil then
@@ -49,6 +49,5 @@ function types.IsDerivedFrom(a, b)
end end
current = current.__typeInfo.parent current = current.__typeInfo.parent
until current == nil until current == nil
;
return false return false
end end

View File

@@ -36,7 +36,6 @@ local BorderIndicator = types.BorderIndicator
local UnitFrame = types.CreateClass("UnitFrame") local UnitFrame = types.CreateClass("UnitFrame")
types.UnitFrame = UnitFrame types.UnitFrame = UnitFrame
local colors = { local colors = {
hostile = { 0.5, 0.0, 0.0 }, hostile = { 0.5, 0.0, 0.0 },
neutral = { 0.7, 0.7, 0.0 }, neutral = { 0.7, 0.7, 0.0 },
@@ -54,8 +53,8 @@ local colors = {
bomb = { 1.0, 0.7, 0.7 }, bomb = { 1.0, 0.7, 0.7 },
cyan = { 0.0, 0.8, 0.8 }, cyan = { 0.0, 0.8, 0.8 },
white = { 1.0, 1.0, 1.0 }, white = { 1.0, 1.0, 1.0 },
shield = { 0.85, .95, 1.0 }, shield = { 0.85, 0.95, 1.0 },
absorb = { 0.5, .4, .75 }, absorb = { 0.5, 0.4, 0.75 },
} }
-- This trucates _codepoints_ not graphemes. If combination codepoints are -- This trucates _codepoints_ not graphemes. If combination codepoints are
@@ -112,7 +111,6 @@ function UnitFrame:Init(unit, config)
self.auras = AuraList:new(self) self.auras = AuraList:new(self)
local overlays = CreateFrame("Frame", nil, secure) local overlays = CreateFrame("Frame", nil, secure)
overlays:SetFrameStrata("MEDIUM") overlays:SetFrameStrata("MEDIUM")
overlays:SetFrameLevel(100) overlays:SetFrameLevel(100)
@@ -292,9 +290,15 @@ function UnitFrame:PrepareWheelBinds(bindings)
if bind.button == "wheel-up" or bind.button == "wheel-down" then if bind.button == "wheel-up" or bind.button == "wheel-down" then
local prefix = ModifiersToPrefix(bind.mods) local prefix = ModifiersToPrefix(bind.mods)
local button = bind.button == "wheel-up" and "MOUSEWHEELUP" or "MOUSEWHEELDOWN" local button = bind.button == "wheel-up" and "MOUSEWHEELUP" or "MOUSEWHEELDOWN"
table.insert(bindScript, table.insert(
string.format([[self:SetBindingClick(false, "%s%s", "OmicronSecureFrame%s", "%s%s")]], bindScript,
prefix, button, unit, prefix, bind.button string.format(
[[self:SetBindingClick(false, "%s%s", "OmicronSecureFrame%s", "%s%s")]],
prefix,
button,
unit,
prefix,
bind.button
) )
) )
end end