wuira 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -1
- package/README.md +242 -0
- package/lib/Spells.d.ts +11 -0
- package/lib/Spells.lua +22 -0
- package/lib/datasources/KnownSpells.d.ts +21 -0
- package/lib/datasources/KnownSpells.lua +794 -0
- package/lib/datasources/ManaRegenTimer.d.ts +29 -0
- package/lib/datasources/ManaRegenTimer.lua +674 -0
- package/lib/datasources/ProgressSource.lua +15 -2
- package/lib/datasources/Resources.d.ts +13 -1
- package/lib/datasources/Resources.lua +118 -39
- package/lib/datasources/SpellCooldown.d.ts +4 -2
- package/lib/datasources/SpellCooldown.lua +13 -2
- package/lib/datasources/SpellSource.d.ts +14 -0
- package/lib/datasources/SpellSource.lua +224 -0
- package/lib/datasources/TimerSource.d.ts +2 -0
- package/lib/datasources/TimerSource.lua +54 -0
- package/lib/datasources/TotemTimer.d.ts +10 -0
- package/lib/datasources/TotemTimer.lua +260 -0
- package/lib/datasources/index.d.ts +7 -0
- package/lib/datasources/index.lua +16 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.lua +16 -0
- package/lib/platform/ActionBars.d.ts +27 -0
- package/lib/platform/ActionBars.lua +726 -0
- package/lib/platform/AddonSettings.d.ts +9 -0
- package/lib/platform/AddonSettings.lua +36 -0
- package/lib/platform/BlizzardUI.d.ts +5 -0
- package/lib/platform/BlizzardUI.lua +357 -20
- package/lib/platform/MicroMenu.d.ts +15 -0
- package/lib/platform/MicroMenu.lua +219 -0
- package/lib/platform/SecureButton.d.ts +5 -0
- package/lib/platform/SecureButton.lua +196 -0
- package/lib/platform/SlashCommands.d.ts +3 -0
- package/lib/platform/SlashCommands.lua +309 -0
- package/lib/platform/forever.d.ts +78 -3
- package/lib/skins/MicroBar.d.ts +8 -0
- package/lib/skins/MicroBar.lua +65 -0
- package/lib/skins/NativeSkin.d.ts +26 -0
- package/lib/skins/NativeSkin.lua +601 -0
- package/lib/skins/index.d.ts +3 -0
- package/lib/skins/index.lua +11 -0
- package/lib/store/index.lua +13 -0
- package/lib/ui/Button.d.ts +10 -0
- package/lib/ui/Button.lua +9 -0
- package/lib/ui/Cell.d.ts +5 -1
- package/lib/ui/FrameMover.d.ts +21 -0
- package/lib/ui/FrameMover.lua +123 -0
- package/lib/ui/HoverTracker.d.ts +20 -0
- package/lib/ui/HoverTracker.lua +88 -0
- package/lib/ui/KeybindCapture.d.ts +20 -0
- package/lib/ui/KeybindCapture.lua +488 -0
- package/lib/ui/SecureButton.d.ts +44 -0
- package/lib/ui/SecureButton.lua +9 -0
- package/lib/ui/index.d.ts +9 -0
- package/lib/ui/index.lua +20 -0
- package/lib/ui/layout/measureLayout.lua +4 -2
- package/lib/ui/mount.lua +500 -117
- package/lib/ui/primitives/jsx.d.ts +9 -1
- package/lib/wuira.d.ts +3 -0
- package/lib/wuira.lua +5 -0
- package/package.json +8 -1
- package/tools/build-library.mjs +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ProgressSource } from "./ProgressSource";
|
|
2
|
+
import type { ProgressOverrides } from "./ProgressSource";
|
|
3
|
+
type ObserveMana = (listener: (event: string, payload: unknown[], value: number) => void) => () => void;
|
|
4
|
+
export type ManaRegenPhase = "fiveSecondRule" | "estimatedTick" | "inactive";
|
|
5
|
+
/** Owned by Mana.UseRegenTimer(). The two-second phase is an estimate, not a server clock. */
|
|
6
|
+
export declare class ManaRegenTimer extends ProgressSource {
|
|
7
|
+
private readonly observe;
|
|
8
|
+
private phase;
|
|
9
|
+
private start;
|
|
10
|
+
private total;
|
|
11
|
+
private manaChanged;
|
|
12
|
+
private scheduled?;
|
|
13
|
+
private unsubscribe?;
|
|
14
|
+
private readonly bindings;
|
|
15
|
+
private alphaCurve?;
|
|
16
|
+
private disposed;
|
|
17
|
+
constructor(observe: ObserveMana);
|
|
18
|
+
get Phase(): ManaRegenPhase;
|
|
19
|
+
get IsActive(): boolean;
|
|
20
|
+
private Remaining;
|
|
21
|
+
private OnManaEvent;
|
|
22
|
+
private Begin;
|
|
23
|
+
private Notify;
|
|
24
|
+
private Stop;
|
|
25
|
+
BindTo(frame: wuiraNativeStatusBar, options?: ProgressOverrides): () => void;
|
|
26
|
+
protected Listen(): void;
|
|
27
|
+
Dispose(): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
-- Lua Library inline imports
|
|
3
|
+
local function __TS__Class(self)
|
|
4
|
+
local c = {prototype = {}}
|
|
5
|
+
c.prototype.__index = c.prototype
|
|
6
|
+
c.prototype.constructor = c
|
|
7
|
+
return c
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
local function __TS__ClassExtends(target, base)
|
|
11
|
+
target.____super = base
|
|
12
|
+
local staticMetatable = setmetatable({__index = base}, base)
|
|
13
|
+
setmetatable(target, staticMetatable)
|
|
14
|
+
local baseMetatable = getmetatable(base)
|
|
15
|
+
if baseMetatable then
|
|
16
|
+
if type(baseMetatable.__index) == "function" then
|
|
17
|
+
staticMetatable.__index = baseMetatable.__index
|
|
18
|
+
end
|
|
19
|
+
if type(baseMetatable.__newindex) == "function" then
|
|
20
|
+
staticMetatable.__newindex = baseMetatable.__newindex
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
setmetatable(target.prototype, base.prototype)
|
|
24
|
+
if type(base.prototype.__index) == "function" then
|
|
25
|
+
target.prototype.__index = base.prototype.__index
|
|
26
|
+
end
|
|
27
|
+
if type(base.prototype.__newindex) == "function" then
|
|
28
|
+
target.prototype.__newindex = base.prototype.__newindex
|
|
29
|
+
end
|
|
30
|
+
if type(base.prototype.__tostring) == "function" then
|
|
31
|
+
target.prototype.__tostring = base.prototype.__tostring
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
local __TS__Symbol, Symbol
|
|
36
|
+
do
|
|
37
|
+
local symbolMetatable = {__tostring = function(self)
|
|
38
|
+
return ("Symbol(" .. (self.description or "")) .. ")"
|
|
39
|
+
end}
|
|
40
|
+
function __TS__Symbol(description)
|
|
41
|
+
return setmetatable({description = description}, symbolMetatable)
|
|
42
|
+
end
|
|
43
|
+
Symbol = {
|
|
44
|
+
asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
|
|
45
|
+
dispose = __TS__Symbol("Symbol.dispose"),
|
|
46
|
+
iterator = __TS__Symbol("Symbol.iterator"),
|
|
47
|
+
hasInstance = __TS__Symbol("Symbol.hasInstance"),
|
|
48
|
+
species = __TS__Symbol("Symbol.species"),
|
|
49
|
+
toStringTag = __TS__Symbol("Symbol.toStringTag")
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
local __TS__Iterator
|
|
54
|
+
do
|
|
55
|
+
local function iteratorGeneratorStep(self)
|
|
56
|
+
local co = self.____coroutine
|
|
57
|
+
local status, value = coroutine.resume(co)
|
|
58
|
+
if not status then
|
|
59
|
+
error(value, 0)
|
|
60
|
+
end
|
|
61
|
+
if coroutine.status(co) == "dead" then
|
|
62
|
+
return
|
|
63
|
+
end
|
|
64
|
+
return true, value
|
|
65
|
+
end
|
|
66
|
+
local function iteratorIteratorStep(self)
|
|
67
|
+
local result = self:next()
|
|
68
|
+
if result.done then
|
|
69
|
+
return
|
|
70
|
+
end
|
|
71
|
+
return true, result.value
|
|
72
|
+
end
|
|
73
|
+
local function iteratorStringStep(self, index)
|
|
74
|
+
index = index + 1
|
|
75
|
+
if index > #self then
|
|
76
|
+
return
|
|
77
|
+
end
|
|
78
|
+
return index, string.sub(self, index, index)
|
|
79
|
+
end
|
|
80
|
+
function __TS__Iterator(iterable)
|
|
81
|
+
if type(iterable) == "string" then
|
|
82
|
+
return iteratorStringStep, iterable, 0
|
|
83
|
+
elseif iterable.____coroutine ~= nil then
|
|
84
|
+
return iteratorGeneratorStep, iterable
|
|
85
|
+
elseif iterable[Symbol.iterator] then
|
|
86
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
87
|
+
return iteratorIteratorStep, iterator
|
|
88
|
+
else
|
|
89
|
+
return ipairs(iterable)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
local function __TS__New(target, ...)
|
|
95
|
+
local instance = setmetatable({}, target.prototype)
|
|
96
|
+
instance:____constructor(...)
|
|
97
|
+
return instance
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
local Set
|
|
101
|
+
do
|
|
102
|
+
Set = __TS__Class()
|
|
103
|
+
Set.name = "Set"
|
|
104
|
+
function Set.prototype.____constructor(self, values)
|
|
105
|
+
self[Symbol.toStringTag] = "Set"
|
|
106
|
+
self.size = 0
|
|
107
|
+
self.nextKey = {}
|
|
108
|
+
self.previousKey = {}
|
|
109
|
+
if values == nil then
|
|
110
|
+
return
|
|
111
|
+
end
|
|
112
|
+
local iterable = values
|
|
113
|
+
if iterable[Symbol.iterator] then
|
|
114
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
115
|
+
while true do
|
|
116
|
+
local result = iterator:next()
|
|
117
|
+
if result.done then
|
|
118
|
+
break
|
|
119
|
+
end
|
|
120
|
+
self:add(result.value)
|
|
121
|
+
end
|
|
122
|
+
else
|
|
123
|
+
local array = values
|
|
124
|
+
for ____, value in ipairs(array) do
|
|
125
|
+
self:add(value)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
function Set.prototype.add(self, value)
|
|
130
|
+
local isNewValue = not self:has(value)
|
|
131
|
+
if isNewValue then
|
|
132
|
+
self.size = self.size + 1
|
|
133
|
+
end
|
|
134
|
+
if self.firstKey == nil then
|
|
135
|
+
self.firstKey = value
|
|
136
|
+
self.lastKey = value
|
|
137
|
+
elseif isNewValue then
|
|
138
|
+
self.nextKey[self.lastKey] = value
|
|
139
|
+
self.previousKey[value] = self.lastKey
|
|
140
|
+
self.lastKey = value
|
|
141
|
+
end
|
|
142
|
+
return self
|
|
143
|
+
end
|
|
144
|
+
function Set.prototype.clear(self)
|
|
145
|
+
self.nextKey = {}
|
|
146
|
+
self.previousKey = {}
|
|
147
|
+
self.firstKey = nil
|
|
148
|
+
self.lastKey = nil
|
|
149
|
+
self.size = 0
|
|
150
|
+
end
|
|
151
|
+
function Set.prototype.delete(self, value)
|
|
152
|
+
local contains = self:has(value)
|
|
153
|
+
if contains then
|
|
154
|
+
self.size = self.size - 1
|
|
155
|
+
local next = self.nextKey[value]
|
|
156
|
+
local previous = self.previousKey[value]
|
|
157
|
+
if next ~= nil and previous ~= nil then
|
|
158
|
+
self.nextKey[previous] = next
|
|
159
|
+
self.previousKey[next] = previous
|
|
160
|
+
elseif next ~= nil then
|
|
161
|
+
self.firstKey = next
|
|
162
|
+
self.previousKey[next] = nil
|
|
163
|
+
elseif previous ~= nil then
|
|
164
|
+
self.lastKey = previous
|
|
165
|
+
self.nextKey[previous] = nil
|
|
166
|
+
else
|
|
167
|
+
self.firstKey = nil
|
|
168
|
+
self.lastKey = nil
|
|
169
|
+
end
|
|
170
|
+
self.nextKey[value] = nil
|
|
171
|
+
self.previousKey[value] = nil
|
|
172
|
+
end
|
|
173
|
+
return contains
|
|
174
|
+
end
|
|
175
|
+
function Set.prototype.forEach(self, callback)
|
|
176
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
177
|
+
callback(nil, key, key, self)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
function Set.prototype.has(self, value)
|
|
181
|
+
return self.nextKey[value] ~= nil or self.lastKey == value
|
|
182
|
+
end
|
|
183
|
+
Set.prototype[Symbol.iterator] = function(self)
|
|
184
|
+
return self:values()
|
|
185
|
+
end
|
|
186
|
+
function Set.prototype.entries(self)
|
|
187
|
+
local function getFirstKey()
|
|
188
|
+
return self.firstKey
|
|
189
|
+
end
|
|
190
|
+
local nextKey = self.nextKey
|
|
191
|
+
local key
|
|
192
|
+
local started = false
|
|
193
|
+
return {
|
|
194
|
+
[Symbol.iterator] = function(self)
|
|
195
|
+
return self
|
|
196
|
+
end,
|
|
197
|
+
next = function(self)
|
|
198
|
+
if not started then
|
|
199
|
+
started = true
|
|
200
|
+
key = getFirstKey(nil)
|
|
201
|
+
else
|
|
202
|
+
key = nextKey[key]
|
|
203
|
+
end
|
|
204
|
+
return {done = not key, value = {key, key}}
|
|
205
|
+
end
|
|
206
|
+
}
|
|
207
|
+
end
|
|
208
|
+
function Set.prototype.keys(self)
|
|
209
|
+
local function getFirstKey()
|
|
210
|
+
return self.firstKey
|
|
211
|
+
end
|
|
212
|
+
local nextKey = self.nextKey
|
|
213
|
+
local key
|
|
214
|
+
local started = false
|
|
215
|
+
return {
|
|
216
|
+
[Symbol.iterator] = function(self)
|
|
217
|
+
return self
|
|
218
|
+
end,
|
|
219
|
+
next = function(self)
|
|
220
|
+
if not started then
|
|
221
|
+
started = true
|
|
222
|
+
key = getFirstKey(nil)
|
|
223
|
+
else
|
|
224
|
+
key = nextKey[key]
|
|
225
|
+
end
|
|
226
|
+
return {done = not key, value = key}
|
|
227
|
+
end
|
|
228
|
+
}
|
|
229
|
+
end
|
|
230
|
+
function Set.prototype.values(self)
|
|
231
|
+
local function getFirstKey()
|
|
232
|
+
return self.firstKey
|
|
233
|
+
end
|
|
234
|
+
local nextKey = self.nextKey
|
|
235
|
+
local key
|
|
236
|
+
local started = false
|
|
237
|
+
return {
|
|
238
|
+
[Symbol.iterator] = function(self)
|
|
239
|
+
return self
|
|
240
|
+
end,
|
|
241
|
+
next = function(self)
|
|
242
|
+
if not started then
|
|
243
|
+
started = true
|
|
244
|
+
key = getFirstKey(nil)
|
|
245
|
+
else
|
|
246
|
+
key = nextKey[key]
|
|
247
|
+
end
|
|
248
|
+
return {done = not key, value = key}
|
|
249
|
+
end
|
|
250
|
+
}
|
|
251
|
+
end
|
|
252
|
+
function Set.prototype.union(self, other)
|
|
253
|
+
local result = __TS__New(Set, self)
|
|
254
|
+
for ____, item in __TS__Iterator(other) do
|
|
255
|
+
result:add(item)
|
|
256
|
+
end
|
|
257
|
+
return result
|
|
258
|
+
end
|
|
259
|
+
function Set.prototype.intersection(self, other)
|
|
260
|
+
local result = __TS__New(Set)
|
|
261
|
+
for ____, item in __TS__Iterator(self) do
|
|
262
|
+
if other:has(item) then
|
|
263
|
+
result:add(item)
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
return result
|
|
267
|
+
end
|
|
268
|
+
function Set.prototype.difference(self, other)
|
|
269
|
+
local result = __TS__New(Set, self)
|
|
270
|
+
for ____, item in __TS__Iterator(other) do
|
|
271
|
+
result:delete(item)
|
|
272
|
+
end
|
|
273
|
+
return result
|
|
274
|
+
end
|
|
275
|
+
function Set.prototype.symmetricDifference(self, other)
|
|
276
|
+
local result = __TS__New(Set, self)
|
|
277
|
+
for ____, item in __TS__Iterator(other) do
|
|
278
|
+
if self:has(item) then
|
|
279
|
+
result:delete(item)
|
|
280
|
+
else
|
|
281
|
+
result:add(item)
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
return result
|
|
285
|
+
end
|
|
286
|
+
function Set.prototype.isSubsetOf(self, other)
|
|
287
|
+
for ____, item in __TS__Iterator(self) do
|
|
288
|
+
if not other:has(item) then
|
|
289
|
+
return false
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
return true
|
|
293
|
+
end
|
|
294
|
+
function Set.prototype.isSupersetOf(self, other)
|
|
295
|
+
for ____, item in __TS__Iterator(other) do
|
|
296
|
+
if not self:has(item) then
|
|
297
|
+
return false
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
return true
|
|
301
|
+
end
|
|
302
|
+
function Set.prototype.isDisjointFrom(self, other)
|
|
303
|
+
for ____, item in __TS__Iterator(self) do
|
|
304
|
+
if other:has(item) then
|
|
305
|
+
return false
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
return true
|
|
309
|
+
end
|
|
310
|
+
Set[Symbol.species] = Set
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
local function __TS__CloneDescriptor(____bindingPattern0)
|
|
314
|
+
local value
|
|
315
|
+
local writable
|
|
316
|
+
local set
|
|
317
|
+
local get
|
|
318
|
+
local configurable
|
|
319
|
+
local enumerable
|
|
320
|
+
enumerable = ____bindingPattern0.enumerable
|
|
321
|
+
configurable = ____bindingPattern0.configurable
|
|
322
|
+
get = ____bindingPattern0.get
|
|
323
|
+
set = ____bindingPattern0.set
|
|
324
|
+
writable = ____bindingPattern0.writable
|
|
325
|
+
value = ____bindingPattern0.value
|
|
326
|
+
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
|
|
327
|
+
local hasGetterOrSetter = get ~= nil or set ~= nil
|
|
328
|
+
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
|
|
329
|
+
if hasGetterOrSetter and hasValueOrWritableAttribute then
|
|
330
|
+
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
|
|
331
|
+
end
|
|
332
|
+
if get or set then
|
|
333
|
+
descriptor.get = get
|
|
334
|
+
descriptor.set = set
|
|
335
|
+
else
|
|
336
|
+
descriptor.value = value
|
|
337
|
+
descriptor.writable = writable == true
|
|
338
|
+
end
|
|
339
|
+
return descriptor
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
local __TS__DescriptorGet
|
|
343
|
+
do
|
|
344
|
+
local getmetatable = _G.getmetatable
|
|
345
|
+
local ____rawget = _G.rawget
|
|
346
|
+
function __TS__DescriptorGet(self, metatable, key)
|
|
347
|
+
while metatable do
|
|
348
|
+
local rawResult = ____rawget(metatable, key)
|
|
349
|
+
if rawResult ~= nil then
|
|
350
|
+
return rawResult
|
|
351
|
+
end
|
|
352
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
353
|
+
if descriptors then
|
|
354
|
+
local descriptor = descriptors[key]
|
|
355
|
+
if descriptor ~= nil then
|
|
356
|
+
if descriptor.get then
|
|
357
|
+
return descriptor.get(self)
|
|
358
|
+
end
|
|
359
|
+
return descriptor.value
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
metatable = getmetatable(metatable)
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
local __TS__DescriptorSet
|
|
368
|
+
do
|
|
369
|
+
local getmetatable = _G.getmetatable
|
|
370
|
+
local ____rawget = _G.rawget
|
|
371
|
+
local rawset = _G.rawset
|
|
372
|
+
function __TS__DescriptorSet(self, metatable, key, value)
|
|
373
|
+
while metatable do
|
|
374
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
375
|
+
if descriptors then
|
|
376
|
+
local descriptor = descriptors[key]
|
|
377
|
+
if descriptor ~= nil then
|
|
378
|
+
if descriptor.set then
|
|
379
|
+
descriptor.set(self, value)
|
|
380
|
+
else
|
|
381
|
+
if descriptor.writable == false then
|
|
382
|
+
error(
|
|
383
|
+
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
|
|
384
|
+
0
|
|
385
|
+
)
|
|
386
|
+
end
|
|
387
|
+
descriptor.value = value
|
|
388
|
+
end
|
|
389
|
+
return
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
metatable = getmetatable(metatable)
|
|
393
|
+
end
|
|
394
|
+
rawset(self, key, value)
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
local __TS__SetDescriptor
|
|
399
|
+
do
|
|
400
|
+
local getmetatable = _G.getmetatable
|
|
401
|
+
local function descriptorIndex(self, key)
|
|
402
|
+
return __TS__DescriptorGet(
|
|
403
|
+
self,
|
|
404
|
+
getmetatable(self),
|
|
405
|
+
key
|
|
406
|
+
)
|
|
407
|
+
end
|
|
408
|
+
local function descriptorNewIndex(self, key, value)
|
|
409
|
+
return __TS__DescriptorSet(
|
|
410
|
+
self,
|
|
411
|
+
getmetatable(self),
|
|
412
|
+
key,
|
|
413
|
+
value
|
|
414
|
+
)
|
|
415
|
+
end
|
|
416
|
+
function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
417
|
+
if isPrototype == nil then
|
|
418
|
+
isPrototype = false
|
|
419
|
+
end
|
|
420
|
+
local ____isPrototype_0
|
|
421
|
+
if isPrototype then
|
|
422
|
+
____isPrototype_0 = target
|
|
423
|
+
else
|
|
424
|
+
____isPrototype_0 = getmetatable(target)
|
|
425
|
+
end
|
|
426
|
+
local metatable = ____isPrototype_0
|
|
427
|
+
if not metatable then
|
|
428
|
+
metatable = {}
|
|
429
|
+
setmetatable(target, metatable)
|
|
430
|
+
end
|
|
431
|
+
if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
|
|
432
|
+
local instanceMetatable = {}
|
|
433
|
+
instanceMetatable._isOwnDescriptorMetatable = true
|
|
434
|
+
setmetatable(instanceMetatable, metatable)
|
|
435
|
+
setmetatable(target, instanceMetatable)
|
|
436
|
+
metatable = instanceMetatable
|
|
437
|
+
end
|
|
438
|
+
local value = rawget(target, key)
|
|
439
|
+
if value ~= nil then
|
|
440
|
+
rawset(target, key, nil)
|
|
441
|
+
end
|
|
442
|
+
if not rawget(metatable, "_descriptors") then
|
|
443
|
+
metatable._descriptors = {}
|
|
444
|
+
end
|
|
445
|
+
metatable._descriptors[key] = __TS__CloneDescriptor(desc)
|
|
446
|
+
metatable.__index = descriptorIndex
|
|
447
|
+
metatable.__newindex = descriptorNewIndex
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
-- End of Lua Library inline imports
|
|
451
|
+
local ____exports = {}
|
|
452
|
+
local ____ProgressSource = require("datasources.ProgressSource")
|
|
453
|
+
local ProgressSource = ____ProgressSource.ProgressSource
|
|
454
|
+
--- Owned by Mana.UseRegenTimer(). The two-second phase is an estimate, not a server clock.
|
|
455
|
+
____exports.ManaRegenTimer = __TS__Class()
|
|
456
|
+
local ManaRegenTimer = ____exports.ManaRegenTimer
|
|
457
|
+
ManaRegenTimer.name = "ManaRegenTimer"
|
|
458
|
+
__TS__ClassExtends(ManaRegenTimer, ProgressSource)
|
|
459
|
+
function ManaRegenTimer.prototype.____constructor(self, observe)
|
|
460
|
+
ProgressSource.prototype.____constructor(
|
|
461
|
+
self,
|
|
462
|
+
{
|
|
463
|
+
current = function() return self:Remaining() end,
|
|
464
|
+
min = function() return 0 end,
|
|
465
|
+
max = function() return self.total end,
|
|
466
|
+
percent = function() return self.total > 0 and self:Remaining() / self.total * 100 or 0 end
|
|
467
|
+
}
|
|
468
|
+
)
|
|
469
|
+
self.observe = observe
|
|
470
|
+
self.phase = "inactive"
|
|
471
|
+
self.start = 0
|
|
472
|
+
self.total = 0
|
|
473
|
+
self.manaChanged = false
|
|
474
|
+
self.bindings = __TS__New(Set)
|
|
475
|
+
self.disposed = false
|
|
476
|
+
end
|
|
477
|
+
function ManaRegenTimer.prototype.Remaining(self)
|
|
478
|
+
return self.IsActive and math.max(
|
|
479
|
+
0,
|
|
480
|
+
self.start + self.total - GetTime()
|
|
481
|
+
) or 0
|
|
482
|
+
end
|
|
483
|
+
function ManaRegenTimer.prototype.OnManaEvent(self, event, payload, mana)
|
|
484
|
+
if event == "PLAYER_ENTERING_WORLD" then
|
|
485
|
+
self:Stop()
|
|
486
|
+
return
|
|
487
|
+
end
|
|
488
|
+
if not issecretvalue(mana) then
|
|
489
|
+
local maximum = UnitPowerMax("player", 0)
|
|
490
|
+
if not issecretvalue(maximum) and mana >= maximum then
|
|
491
|
+
self:Stop()
|
|
492
|
+
return
|
|
493
|
+
end
|
|
494
|
+
end
|
|
495
|
+
if event == "UNIT_SPELLCAST_SUCCEEDED" then
|
|
496
|
+
local spellId = payload[3]
|
|
497
|
+
if issecretvalue(spellId) or type(spellId) ~= "number" then
|
|
498
|
+
return
|
|
499
|
+
end
|
|
500
|
+
local ____opt_0 = C_Spell and C_Spell.GetSpellPowerCost
|
|
501
|
+
local costs = ____opt_0 and ____opt_0(spellId)
|
|
502
|
+
if issecretvalue(costs) or costs == nil then
|
|
503
|
+
return
|
|
504
|
+
end
|
|
505
|
+
for ____, cost in ipairs(costs) do
|
|
506
|
+
do
|
|
507
|
+
local __continue15
|
|
508
|
+
repeat
|
|
509
|
+
if issecretvalue(cost.type) or cost.type ~= 0 then
|
|
510
|
+
__continue15 = true
|
|
511
|
+
break
|
|
512
|
+
end
|
|
513
|
+
if issecretvalue(cost.cost) or cost.cost ~= nil and cost.cost > 0 then
|
|
514
|
+
self:Begin(
|
|
515
|
+
"fiveSecondRule",
|
|
516
|
+
GetTime()
|
|
517
|
+
)
|
|
518
|
+
return
|
|
519
|
+
end
|
|
520
|
+
__continue15 = true
|
|
521
|
+
until true
|
|
522
|
+
if not __continue15 then
|
|
523
|
+
break
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
elseif event == "UNIT_POWER_UPDATE" and not issecretvalue(payload[2]) and payload[2] == "MANA" then
|
|
528
|
+
if self.phase == "inactive" then
|
|
529
|
+
self:Begin(
|
|
530
|
+
"estimatedTick",
|
|
531
|
+
GetTime()
|
|
532
|
+
)
|
|
533
|
+
elseif self.phase == "estimatedTick" then
|
|
534
|
+
self.manaChanged = true
|
|
535
|
+
end
|
|
536
|
+
end
|
|
537
|
+
self:Notify()
|
|
538
|
+
end
|
|
539
|
+
function ManaRegenTimer.prototype.Begin(self, phase, start)
|
|
540
|
+
local ____opt_4 = self.scheduled
|
|
541
|
+
if ____opt_4 ~= nil then
|
|
542
|
+
____opt_4:Cancel()
|
|
543
|
+
end
|
|
544
|
+
self.phase = phase
|
|
545
|
+
self.total = phase == "fiveSecondRule" and 5 or 2
|
|
546
|
+
self.start = start
|
|
547
|
+
self.manaChanged = false
|
|
548
|
+
self:Notify()
|
|
549
|
+
local ____end = start + self.total
|
|
550
|
+
self.scheduled = C_Timer.NewTimer(
|
|
551
|
+
math.max(
|
|
552
|
+
0.01,
|
|
553
|
+
____end - GetTime()
|
|
554
|
+
),
|
|
555
|
+
function()
|
|
556
|
+
self.scheduled = nil
|
|
557
|
+
if self.phase == "fiveSecondRule" or self.manaChanged then
|
|
558
|
+
self:Begin(
|
|
559
|
+
"estimatedTick",
|
|
560
|
+
____end > GetTime() - 2 and ____end or GetTime()
|
|
561
|
+
)
|
|
562
|
+
else
|
|
563
|
+
self:Stop()
|
|
564
|
+
end
|
|
565
|
+
end
|
|
566
|
+
)
|
|
567
|
+
end
|
|
568
|
+
function ManaRegenTimer.prototype.Notify(self)
|
|
569
|
+
for ____, refresh in __TS__Iterator(self.bindings) do
|
|
570
|
+
refresh(nil)
|
|
571
|
+
end
|
|
572
|
+
end
|
|
573
|
+
function ManaRegenTimer.prototype.Stop(self)
|
|
574
|
+
local ____opt_6 = self.scheduled
|
|
575
|
+
if ____opt_6 ~= nil then
|
|
576
|
+
____opt_6:Cancel()
|
|
577
|
+
end
|
|
578
|
+
self.scheduled = nil
|
|
579
|
+
self.phase = "inactive"
|
|
580
|
+
self.total = 0
|
|
581
|
+
self.manaChanged = false
|
|
582
|
+
self:Notify()
|
|
583
|
+
end
|
|
584
|
+
function ManaRegenTimer.prototype.BindTo(self, frame, options)
|
|
585
|
+
if options == nil then
|
|
586
|
+
options = {}
|
|
587
|
+
end
|
|
588
|
+
if self.disposed then
|
|
589
|
+
error("ManaRegenTimer: source is disposed")
|
|
590
|
+
end
|
|
591
|
+
if options.min ~= nil or options.max ~= nil or options.current ~= nil then
|
|
592
|
+
error("ManaRegenTimer: range/current overrides are unsupported")
|
|
593
|
+
end
|
|
594
|
+
local bar = frame
|
|
595
|
+
if bar.SetTimerDuration == nil or C_DurationUtil == nil then
|
|
596
|
+
error("ManaRegenTimer: native duration support is unavailable")
|
|
597
|
+
end
|
|
598
|
+
local timer = C_DurationUtil.CreateDuration()
|
|
599
|
+
if self.alphaCurve == nil and C_CurveUtil ~= nil and Enum.LuaCurveType ~= nil then
|
|
600
|
+
self.alphaCurve = C_CurveUtil.CreateCurve()
|
|
601
|
+
self.alphaCurve:SetType(Enum.LuaCurveType.Step)
|
|
602
|
+
self.alphaCurve:AddPoint(0, 1)
|
|
603
|
+
self.alphaCurve:AddPoint(1, 0)
|
|
604
|
+
end
|
|
605
|
+
bar:SetMinMaxValues(0, 1)
|
|
606
|
+
local lastStart
|
|
607
|
+
local lastTotal
|
|
608
|
+
local function refresh()
|
|
609
|
+
local active = self.IsActive and self:CanEmit(self:Remaining())
|
|
610
|
+
local ____this_9
|
|
611
|
+
____this_9 = options
|
|
612
|
+
local ____opt_8 = ____this_9.onActiveChange
|
|
613
|
+
if ____opt_8 ~= nil then
|
|
614
|
+
____opt_8(____this_9, active)
|
|
615
|
+
end
|
|
616
|
+
if not active then
|
|
617
|
+
return
|
|
618
|
+
end
|
|
619
|
+
if self.alphaCurve ~= nil then
|
|
620
|
+
bar:SetAlpha(UnitPowerPercent("player", 0, true, self.alphaCurve))
|
|
621
|
+
end
|
|
622
|
+
if lastStart ~= self.start or lastTotal ~= self.total then
|
|
623
|
+
timer:SetTimeFromStart(self.start, self.total)
|
|
624
|
+
bar:SetTimerDuration(timer, Enum.StatusBarInterpolation.Immediate, Enum.StatusBarTimerDirection.RemainingTime)
|
|
625
|
+
lastStart = self.start
|
|
626
|
+
lastTotal = self.total
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
self.bindings:add(refresh)
|
|
630
|
+
if self.unsubscribe == nil then
|
|
631
|
+
self.unsubscribe = self:observe(function(____, event, payload, mana) return self:OnManaEvent(event, payload, mana) end)
|
|
632
|
+
end
|
|
633
|
+
refresh(nil)
|
|
634
|
+
return function()
|
|
635
|
+
self.bindings:delete(refresh)
|
|
636
|
+
if self.bindings.size == 0 then
|
|
637
|
+
local ____opt_10 = self.unsubscribe
|
|
638
|
+
if ____opt_10 ~= nil then
|
|
639
|
+
____opt_10(self)
|
|
640
|
+
end
|
|
641
|
+
self.unsubscribe = nil
|
|
642
|
+
self:Stop()
|
|
643
|
+
end
|
|
644
|
+
end
|
|
645
|
+
end
|
|
646
|
+
function ManaRegenTimer.prototype.Listen(self)
|
|
647
|
+
end
|
|
648
|
+
function ManaRegenTimer.prototype.Dispose(self)
|
|
649
|
+
self.disposed = true
|
|
650
|
+
self:Stop()
|
|
651
|
+
self.bindings:clear()
|
|
652
|
+
local ____opt_12 = self.unsubscribe
|
|
653
|
+
if ____opt_12 ~= nil then
|
|
654
|
+
____opt_12(self)
|
|
655
|
+
end
|
|
656
|
+
self.unsubscribe = nil
|
|
657
|
+
end
|
|
658
|
+
__TS__SetDescriptor(
|
|
659
|
+
ManaRegenTimer.prototype,
|
|
660
|
+
"Phase",
|
|
661
|
+
{get = function(self)
|
|
662
|
+
return self.phase
|
|
663
|
+
end},
|
|
664
|
+
true
|
|
665
|
+
)
|
|
666
|
+
__TS__SetDescriptor(
|
|
667
|
+
ManaRegenTimer.prototype,
|
|
668
|
+
"IsActive",
|
|
669
|
+
{get = function(self)
|
|
670
|
+
return self.phase ~= "inactive"
|
|
671
|
+
end},
|
|
672
|
+
true
|
|
673
|
+
)
|
|
674
|
+
return ____exports
|