Created
April 9, 2022 17:43
-
-
Save vendethiel/749849d4314259c66ff2b38be40c6087 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scorpio "SmallBuff" "0.1" | |
import "System.Reactive" | |
local _Cache = {} | |
local function GetSpellFromCache(id) | |
if not _Cache[id] then | |
local name, _, icon = GetSpellInfo(id) | |
_Cache[id] = { name = name, icon = icon } | |
end | |
return _Cache[id] | |
end | |
interface "ICooldownLike"(function(_ENV) | |
property "ID" { type = Number, set = Tools.fakefunc } | |
property "Duration" { type = Number, set = Tools.fakefunc } | |
local sharedcd = { start = 0, duration = 0 } | |
function GetCooldown(self) | |
sharedcd.start = self:GetStart() | |
sharedcd.duration = self:GetDuration() | |
return sharedcd | |
end | |
end) | |
class "Cooldown"(function(_ENV) | |
inherit "ICooldownLike" | |
property "Start" { type = Number, set = Tools.fakefunc } | |
function GetCount() | |
return 1 | |
end | |
function GetName(self) | |
return GetSpellFromCache(self:GetID()).name | |
end | |
function GetIcon(self) | |
return GetSpellFromCache(self:GetID)).icon | |
end | |
function GetEnabled() | |
return true | |
end | |
function self:GetExpirationTime() | |
return self:GetStart() + self:GetDuration() | |
end | |
end) | |
class "Aura"(function(_ENV) | |
property "Name" { type = String, set = Tools.fakefunc } | |
property "Icon" { type = String, set = Tools.fakefunc } | |
property "Count" { type = Number, set = Tools.fakefunc } | |
property "ExpirationTime" { type = Number, set = Tools.fakefunc } | |
function GetIsEnabled() | |
return true | |
end | |
function GetStart(self) | |
return self:GetExpirationTime() - self:GetDuration() | |
end | |
end) | |
class "MixedElementPanelIcon" { Scorpio.Secure.UnitFrame.AuraPanelIcon } | |
__Sealed__() | |
class "MixedElementPanel"(function(_ENV) | |
inherit "ElementPanel" | |
__Observable__() | |
__Indexer__() | |
property "Data" { set = Toolset.fakefunc, type = ICooldownLike } | |
local function CooldownData(id) | |
local start, duration, enabled = GetSpellCooldown(id) | |
return Cooldown { id = id, duration = duration, start = start, enabled = enabled } | |
end | |
local function DataFor(id) | |
return BUFFS_CACHE[id] or DEBUFFS_CACHE[id] or CooldownData(id) | |
end | |
function Refresh(self) | |
local count = 0 | |
for i, data in self.IDs:Map(DataFor):GetIterator() do | |
self.Data[i] = data | |
count = i | |
end | |
self.Count = count | |
end | |
property "IDs" { default = function () return List[Number]() end, handler = Refresh } | |
function __ctor(self) | |
cacheSubject:Subscribe(function () self:Refresh() end) | |
end | |
end) | |
Style.UpdateSkin("Default", { | |
[MixedElementPanel] = { | |
elementType = MixedElementPanelIcon, | |
location = { Anchor("CENTER") }, | |
}, | |
[MixedElementPanelIcon] = { | |
IconTexture = { | |
setAllPoints = true, | |
file = Wow.FromPanelProperty("Data", "Icon"), | |
}, | |
Cooldown = { | |
setAllPoints = true, | |
enableMouse = false, | |
cooldown = Wow.FromPanelProperty("Data", "Cooldown") | |
} | |
} | |
}) | |
SMALLBUFF_PANEL = MixedElementPanel("SmallBuffMain") | |
__SlashCmd__ "sb" "add" | |
function AddBuff(id) -- TODO from param | |
SMALLBUFF_PANEL.IDs = List[Number]{ 774 } -- Rejuv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment