wuira 0.2.0 → 0.2.2
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 +23 -0
- package/README.md +32 -15
- package/lib/WuiraApp.d.ts +12 -0
- package/lib/WuiraApp.lua +425 -0
- package/lib/datasources/EditModeLayouts.d.ts +33 -0
- package/lib/datasources/EditModeLayouts.lua +689 -0
- package/lib/datasources/index.d.ts +2 -0
- package/lib/datasources/index.lua +4 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.lua +5 -0
- package/lib/platform/forever.d.ts +1 -0
- package/lib/rendering/decorations.d.ts +2 -0
- package/lib/rendering/decorations.lua +42 -0
- package/lib/rendering/layout.d.ts +16 -0
- package/lib/rendering/layout.lua +594 -0
- package/lib/rendering/progress.d.ts +2 -0
- package/lib/rendering/progress.lua +196 -0
- package/lib/rendering/secureButton.d.ts +2 -0
- package/lib/rendering/secureButton.lua +46 -0
- package/lib/rendering/types.d.ts +25 -0
- package/lib/rendering/types.lua +3 -0
- package/lib/rendering/updates.d.ts +3 -0
- package/lib/rendering/updates.lua +30 -0
- package/lib/rendering/visibility.d.ts +6 -0
- package/lib/rendering/visibility.lua +85 -0
- package/lib/rendering/widgets.d.ts +4 -0
- package/lib/rendering/widgets.lua +83 -0
- package/lib/wuira.d.ts +8 -4
- package/lib/wuira.lua +215 -27
- package/package.json +1 -1
- package/templates/addon/src/index.tsx +2 -2
- package/lib/ui/mount.d.ts +0 -5
- package/lib/ui/mount.lua +0 -1107
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
-- Lua Library inline imports
|
|
3
|
+
local __TS__Symbol, Symbol
|
|
4
|
+
do
|
|
5
|
+
local symbolMetatable = {__tostring = function(self)
|
|
6
|
+
return ("Symbol(" .. (self.description or "")) .. ")"
|
|
7
|
+
end}
|
|
8
|
+
function __TS__Symbol(description)
|
|
9
|
+
return setmetatable({description = description}, symbolMetatable)
|
|
10
|
+
end
|
|
11
|
+
Symbol = {
|
|
12
|
+
asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
|
|
13
|
+
dispose = __TS__Symbol("Symbol.dispose"),
|
|
14
|
+
iterator = __TS__Symbol("Symbol.iterator"),
|
|
15
|
+
hasInstance = __TS__Symbol("Symbol.hasInstance"),
|
|
16
|
+
species = __TS__Symbol("Symbol.species"),
|
|
17
|
+
toStringTag = __TS__Symbol("Symbol.toStringTag")
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
local function __TS__InstanceOf(obj, classTbl)
|
|
22
|
+
if type(classTbl) ~= "table" then
|
|
23
|
+
error("Right-hand side of 'instanceof' is not an object", 0)
|
|
24
|
+
end
|
|
25
|
+
if classTbl[Symbol.hasInstance] ~= nil then
|
|
26
|
+
return not not classTbl[Symbol.hasInstance](classTbl, obj)
|
|
27
|
+
end
|
|
28
|
+
if type(obj) == "table" then
|
|
29
|
+
local luaClass = obj.constructor
|
|
30
|
+
while luaClass ~= nil do
|
|
31
|
+
if luaClass == classTbl then
|
|
32
|
+
return true
|
|
33
|
+
end
|
|
34
|
+
luaClass = luaClass.____super
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
return false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
local function __TS__ObjectAssign(target, ...)
|
|
41
|
+
local sources = {...}
|
|
42
|
+
for i = 1, #sources do
|
|
43
|
+
local source = sources[i]
|
|
44
|
+
if type(source) == "table" then
|
|
45
|
+
for key in pairs(source) do
|
|
46
|
+
target[key] = source[key]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
return target
|
|
51
|
+
end
|
|
52
|
+
-- End of Lua Library inline imports
|
|
53
|
+
local ____exports = {}
|
|
54
|
+
local ____Resources = require("datasources.Resources")
|
|
55
|
+
local HP = ____Resources.HP
|
|
56
|
+
local ____statusBarTextures = require("ui.decorations.statusBarTextures")
|
|
57
|
+
local resolveStatusBarTexture = ____statusBarTextures.resolveStatusBarTexture
|
|
58
|
+
function ____exports.renderProgress(self, item, tree, onActiveChange)
|
|
59
|
+
local props = item.cell.props
|
|
60
|
+
local bar = item.frame
|
|
61
|
+
local ____opt_0 = props.foreground
|
|
62
|
+
local color = ____opt_0 and ____opt_0.color or props.color
|
|
63
|
+
local ____bar_SetStatusBarTexture_5 = bar.SetStatusBarTexture
|
|
64
|
+
local ____resolveStatusBarTexture_4 = resolveStatusBarTexture
|
|
65
|
+
local ____opt_2 = props.foreground
|
|
66
|
+
____bar_SetStatusBarTexture_5(
|
|
67
|
+
bar,
|
|
68
|
+
____resolveStatusBarTexture_4(nil, ____opt_2 and ____opt_2.texture or props.texture or "solid")
|
|
69
|
+
)
|
|
70
|
+
bar:SetStatusBarColor(color and color.r or 1, color and color.g or 1, color and color.b or 1, color and color.a or 1)
|
|
71
|
+
if props.foreground ~= nil then
|
|
72
|
+
local fill = bar:GetStatusBarTexture()
|
|
73
|
+
local ____fill_SetHorizTile_15 = fill.SetHorizTile
|
|
74
|
+
local ____props_foreground_tileX_14 = props.foreground.tileX
|
|
75
|
+
if ____props_foreground_tileX_14 == nil then
|
|
76
|
+
____props_foreground_tileX_14 = false
|
|
77
|
+
end
|
|
78
|
+
____fill_SetHorizTile_15(fill, ____props_foreground_tileX_14)
|
|
79
|
+
local ____fill_SetVertTile_17 = fill.SetVertTile
|
|
80
|
+
local ____props_foreground_tileY_16 = props.foreground.tileY
|
|
81
|
+
if ____props_foreground_tileY_16 == nil then
|
|
82
|
+
____props_foreground_tileY_16 = false
|
|
83
|
+
end
|
|
84
|
+
____fill_SetVertTile_17(fill, ____props_foreground_tileY_16)
|
|
85
|
+
fill:SetBlendMode(props.foreground.blendMode or "BLEND")
|
|
86
|
+
local uv = props.foreground.texCoords or ({0, 1, 0, 1})
|
|
87
|
+
fill:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
|
|
88
|
+
end
|
|
89
|
+
bar:SetOrientation(props.orientation == "vertical" and "VERTICAL" or "HORIZONTAL")
|
|
90
|
+
local ____bar_SetReverseFill_19 = bar.SetReverseFill
|
|
91
|
+
local ____props_reverse_18 = props.reverse
|
|
92
|
+
if ____props_reverse_18 == nil then
|
|
93
|
+
____props_reverse_18 = false
|
|
94
|
+
end
|
|
95
|
+
____bar_SetReverseFill_19(bar, ____props_reverse_18)
|
|
96
|
+
bar:SetMinMaxValues(props.min or 0, props.max or 100)
|
|
97
|
+
local source = item.cell.source or props.source
|
|
98
|
+
if source ~= nil then
|
|
99
|
+
local healPredictionBar
|
|
100
|
+
local absorbPredictionBar
|
|
101
|
+
if __TS__InstanceOf(source, HP) then
|
|
102
|
+
local function overlay(____, style, heal)
|
|
103
|
+
bar:SetClipsChildren(true)
|
|
104
|
+
local layer = CreateFrame("StatusBar", nil, bar)
|
|
105
|
+
local ____tree_frames_20 = tree.frames
|
|
106
|
+
____tree_frames_20[#____tree_frames_20 + 1] = layer
|
|
107
|
+
layer:EnableMouse(false)
|
|
108
|
+
layer:SetFrameLevel(bar:GetFrameLevel())
|
|
109
|
+
layer:SetSize(item.width, item.height)
|
|
110
|
+
layer:SetStatusBarTexture(resolveStatusBarTexture(nil, style.texture or "solid"))
|
|
111
|
+
local tint = style.color
|
|
112
|
+
layer:SetStatusBarColor(tint.r, tint.g, tint.b, tint.a or 0.5)
|
|
113
|
+
local texture = layer:GetStatusBarTexture()
|
|
114
|
+
texture:SetBlendMode(style.blendMode or "BLEND")
|
|
115
|
+
local ____texture_SetHorizTile_22 = texture.SetHorizTile
|
|
116
|
+
local ____style_tileX_21 = style.tileX
|
|
117
|
+
if ____style_tileX_21 == nil then
|
|
118
|
+
____style_tileX_21 = false
|
|
119
|
+
end
|
|
120
|
+
____texture_SetHorizTile_22(texture, ____style_tileX_21)
|
|
121
|
+
local ____texture_SetVertTile_24 = texture.SetVertTile
|
|
122
|
+
local ____style_tileY_23 = style.tileY
|
|
123
|
+
if ____style_tileY_23 == nil then
|
|
124
|
+
____style_tileY_23 = false
|
|
125
|
+
end
|
|
126
|
+
____texture_SetVertTile_24(texture, ____style_tileY_23)
|
|
127
|
+
local uv = style.texCoords or ({0, 1, 0, 1})
|
|
128
|
+
texture:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
|
|
129
|
+
local vertical = props.orientation == "vertical"
|
|
130
|
+
local ____props_reverse_25 = props.reverse
|
|
131
|
+
if ____props_reverse_25 == nil then
|
|
132
|
+
____props_reverse_25 = false
|
|
133
|
+
end
|
|
134
|
+
local reverse = ____props_reverse_25
|
|
135
|
+
layer:SetOrientation(vertical and "VERTICAL" or "HORIZONTAL")
|
|
136
|
+
local ____layer_SetReverseFill_27 = layer.SetReverseFill
|
|
137
|
+
local ____heal_26
|
|
138
|
+
if heal then
|
|
139
|
+
____heal_26 = reverse
|
|
140
|
+
else
|
|
141
|
+
____heal_26 = not reverse
|
|
142
|
+
end
|
|
143
|
+
____layer_SetReverseFill_27(layer, ____heal_26)
|
|
144
|
+
if heal then
|
|
145
|
+
local point = vertical and (reverse and "TOPLEFT" or "BOTTOMLEFT") or (reverse and "TOPRIGHT" or "TOPLEFT")
|
|
146
|
+
local relative = vertical and (reverse and "BOTTOMLEFT" or "TOPLEFT") or (reverse and "TOPLEFT" or "TOPRIGHT")
|
|
147
|
+
layer:SetPoint(
|
|
148
|
+
point,
|
|
149
|
+
bar:GetStatusBarTexture(),
|
|
150
|
+
relative,
|
|
151
|
+
0,
|
|
152
|
+
0
|
|
153
|
+
)
|
|
154
|
+
else
|
|
155
|
+
layer:SetAllPoints(bar)
|
|
156
|
+
end
|
|
157
|
+
return layer
|
|
158
|
+
end
|
|
159
|
+
local ____opt_28 = source.HealPrediction
|
|
160
|
+
if (____opt_28 and ____opt_28.IsAvailable) == true and props.healPrediction ~= false then
|
|
161
|
+
local ____props_healPrediction_32 = props.healPrediction
|
|
162
|
+
local ____opt_30 = props.healPrediction
|
|
163
|
+
healPredictionBar = overlay(
|
|
164
|
+
nil,
|
|
165
|
+
__TS__ObjectAssign({}, ____props_healPrediction_32, {color = ____opt_30 and ____opt_30.color or ({r = 0.4, g = 1, b = 0.5, a = 0.5})}),
|
|
166
|
+
true
|
|
167
|
+
)
|
|
168
|
+
end
|
|
169
|
+
local ____opt_33 = source.AbsorbPrediction
|
|
170
|
+
if (____opt_33 and ____opt_33.IsAvailable) == true and props.absorbPrediction ~= false then
|
|
171
|
+
local ____props_absorbPrediction_37 = props.absorbPrediction
|
|
172
|
+
local ____opt_35 = props.absorbPrediction
|
|
173
|
+
absorbPredictionBar = overlay(
|
|
174
|
+
nil,
|
|
175
|
+
__TS__ObjectAssign({}, ____props_absorbPrediction_37, {color = ____opt_35 and ____opt_35.color or ({r = 0.8, g = 0.9, b = 1, a = 0.55})}),
|
|
176
|
+
false
|
|
177
|
+
)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
local dispose = source:BindTo(bar, {
|
|
181
|
+
min = props.min,
|
|
182
|
+
max = props.max,
|
|
183
|
+
current = props.current or props.value,
|
|
184
|
+
onActiveChange = onActiveChange,
|
|
185
|
+
healPredictionBar = healPredictionBar,
|
|
186
|
+
absorbPredictionBar = absorbPredictionBar
|
|
187
|
+
})
|
|
188
|
+
if dispose ~= nil then
|
|
189
|
+
local ____tree_bindings_38 = tree.bindings
|
|
190
|
+
____tree_bindings_38[#____tree_bindings_38 + 1] = dispose
|
|
191
|
+
end
|
|
192
|
+
else
|
|
193
|
+
bar:SetValue(props.current or props.value or 0)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
return ____exports
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____SecureButton = require("platform.SecureButton")
|
|
4
|
+
local configureSecureButton = ____SecureButton.configureSecureButton
|
|
5
|
+
function ____exports.renderSecureButton(self, item, tree)
|
|
6
|
+
local props = item.cell.props
|
|
7
|
+
local ____tree_bindings_0 = tree.bindings
|
|
8
|
+
____tree_bindings_0[#____tree_bindings_0 + 1] = configureSecureButton(nil, item.frame, props)
|
|
9
|
+
if props.cooldown ~= nil then
|
|
10
|
+
local cooldown = CreateFrame("Cooldown", nil, item.frame, "CooldownFrameTemplate")
|
|
11
|
+
local ____tree_frames_1 = tree.frames
|
|
12
|
+
____tree_frames_1[#____tree_frames_1 + 1] = cooldown
|
|
13
|
+
cooldown:EnableMouse(false)
|
|
14
|
+
cooldown:SetAllPoints(item.frame)
|
|
15
|
+
cooldown:SetFrameLevel(item.frame:GetFrameLevel() + 2)
|
|
16
|
+
cooldown:SetDrawSwipe(true)
|
|
17
|
+
cooldown:SetDrawEdge(false)
|
|
18
|
+
local ____cooldown_SetDrawBling_3 = cooldown.SetDrawBling
|
|
19
|
+
local ____props_finishGlow_2 = props.finishGlow
|
|
20
|
+
if ____props_finishGlow_2 == nil then
|
|
21
|
+
____props_finishGlow_2 = false
|
|
22
|
+
end
|
|
23
|
+
____cooldown_SetDrawBling_3(cooldown, ____props_finishGlow_2)
|
|
24
|
+
cooldown:SetHideCountdownNumbers(false)
|
|
25
|
+
cooldown:SetSwipeColor(0, 0, 0, 0.7)
|
|
26
|
+
cooldown:GetCountdownFontString():SetFont("Fonts\\FRIZQT__.TTF", 13, "OUTLINE")
|
|
27
|
+
local ____tree_bindings_4 = tree.bindings
|
|
28
|
+
____tree_bindings_4[#____tree_bindings_4 + 1] = props.cooldown:BindCooldown(cooldown)
|
|
29
|
+
end
|
|
30
|
+
if props.binding ~= nil and props.showHotkey ~= false then
|
|
31
|
+
local overlay = CreateFrame("Frame", nil, item.frame)
|
|
32
|
+
local ____tree_frames_5 = tree.frames
|
|
33
|
+
____tree_frames_5[#____tree_frames_5 + 1] = overlay
|
|
34
|
+
overlay:EnableMouse(false)
|
|
35
|
+
overlay:SetAllPoints(item.frame)
|
|
36
|
+
overlay:SetFrameLevel(item.frame:GetFrameLevel() + 3)
|
|
37
|
+
local hotkey = overlay:CreateFontString(nil, "OVERLAY")
|
|
38
|
+
hotkey:SetAllPoints(overlay)
|
|
39
|
+
hotkey:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE")
|
|
40
|
+
hotkey:SetJustifyH("RIGHT")
|
|
41
|
+
hotkey:SetJustifyV("TOP")
|
|
42
|
+
hotkey:SetTextColor(1, 1, 1, 1)
|
|
43
|
+
hotkey:SetText(props.binding)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
return ____exports
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ICell } from "../ui/Cell";
|
|
2
|
+
import type { Decoration } from "../ui/decorations/Decoration";
|
|
3
|
+
import type { MeasuredCell } from "../ui/layout/measureLayout";
|
|
4
|
+
export interface RenderedCell {
|
|
5
|
+
cell: ICell;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
margin: MeasuredCell["margin"];
|
|
9
|
+
frame: wuiraNativeFrame;
|
|
10
|
+
parent: wuiraNativeFrame;
|
|
11
|
+
placement?: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface MountedTree {
|
|
17
|
+
frames: wuiraNativeFrame[];
|
|
18
|
+
cells: ICell[];
|
|
19
|
+
decorations: Decoration[];
|
|
20
|
+
bindings: (() => void)[];
|
|
21
|
+
protected: boolean;
|
|
22
|
+
pendingUnmount: boolean;
|
|
23
|
+
visibility: (() => void)[];
|
|
24
|
+
listener?: wuiraNativeFrame;
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
--- A separate driver keeps updates running even while the visual root is hidden.
|
|
4
|
+
function ____exports.startUpdates(self, parent, tree, updates)
|
|
5
|
+
if #updates == 0 then
|
|
6
|
+
return
|
|
7
|
+
end
|
|
8
|
+
local driver = CreateFrame("Frame", nil, parent)
|
|
9
|
+
local ____tree_frames_0 = tree.frames
|
|
10
|
+
____tree_frames_0[#____tree_frames_0 + 1] = driver
|
|
11
|
+
local elapsed = 0
|
|
12
|
+
driver:SetScript(
|
|
13
|
+
"OnUpdate",
|
|
14
|
+
function(_frame, delta)
|
|
15
|
+
elapsed = elapsed + delta
|
|
16
|
+
if elapsed < 0.05 then
|
|
17
|
+
return
|
|
18
|
+
end
|
|
19
|
+
elapsed = 0
|
|
20
|
+
for ____, update in ipairs(updates) do
|
|
21
|
+
update(nil)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
)
|
|
25
|
+
for ____, update in ipairs(updates) do
|
|
26
|
+
update(nil)
|
|
27
|
+
end
|
|
28
|
+
driver:Show()
|
|
29
|
+
end
|
|
30
|
+
return ____exports
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MountedTree, RenderedCell } from "./types";
|
|
2
|
+
export declare function bindVisibility(item: RenderedCell, tree: MountedTree, updates: (() => void)[], isProtected: () => boolean): {
|
|
3
|
+
refresh: () => void;
|
|
4
|
+
onActiveChange: (active: boolean) => void;
|
|
5
|
+
dynamic: boolean;
|
|
6
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
-- Lua Library inline imports
|
|
3
|
+
local function __TS__NumberIsFinite(value)
|
|
4
|
+
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
|
|
5
|
+
end
|
|
6
|
+
-- End of Lua Library inline imports
|
|
7
|
+
local ____exports = {}
|
|
8
|
+
function ____exports.bindVisibility(self, item, tree, updates, isProtected)
|
|
9
|
+
local sourceActive = true
|
|
10
|
+
local lastVisible
|
|
11
|
+
local visible = item.cell.props.visible
|
|
12
|
+
local condition = item.cell.props.condition
|
|
13
|
+
local function refreshVisibility()
|
|
14
|
+
if isProtected(nil) and InCombatLockdown() then
|
|
15
|
+
return
|
|
16
|
+
end
|
|
17
|
+
local ____sourceActive_2 = sourceActive
|
|
18
|
+
if ____sourceActive_2 then
|
|
19
|
+
local ____temp_1
|
|
20
|
+
if type(condition) == "function" then
|
|
21
|
+
____temp_1 = condition(nil)
|
|
22
|
+
else
|
|
23
|
+
local ____condition_0 = condition
|
|
24
|
+
if ____condition_0 == nil then
|
|
25
|
+
____condition_0 = true
|
|
26
|
+
end
|
|
27
|
+
____temp_1 = ____condition_0
|
|
28
|
+
end
|
|
29
|
+
____sourceActive_2 = ____temp_1
|
|
30
|
+
end
|
|
31
|
+
local allowed = ____sourceActive_2
|
|
32
|
+
local ____temp_6 = not issecretvalue(allowed) and allowed
|
|
33
|
+
if ____temp_6 then
|
|
34
|
+
local ____temp_5 = visible and visible(nil)
|
|
35
|
+
if ____temp_5 == nil then
|
|
36
|
+
____temp_5 = true
|
|
37
|
+
end
|
|
38
|
+
____temp_6 = ____temp_5
|
|
39
|
+
end
|
|
40
|
+
local value = ____temp_6
|
|
41
|
+
if value == lastVisible then
|
|
42
|
+
return
|
|
43
|
+
end
|
|
44
|
+
lastVisible = value
|
|
45
|
+
if value then
|
|
46
|
+
item.frame:Show()
|
|
47
|
+
else
|
|
48
|
+
item.frame:Hide()
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
local ____tree_visibility_7 = tree.visibility
|
|
52
|
+
____tree_visibility_7[#____tree_visibility_7 + 1] = refreshVisibility
|
|
53
|
+
local function onActiveChange(____, active)
|
|
54
|
+
sourceActive = active
|
|
55
|
+
refreshVisibility(nil)
|
|
56
|
+
end
|
|
57
|
+
local position = item.cell.props
|
|
58
|
+
if position.alpha ~= nil then
|
|
59
|
+
local alpha = position.alpha
|
|
60
|
+
local previous
|
|
61
|
+
local function refreshAlpha()
|
|
62
|
+
local value = type(alpha) == "function" and alpha(nil) or alpha
|
|
63
|
+
if issecretvalue(value) then
|
|
64
|
+
return
|
|
65
|
+
end
|
|
66
|
+
if not __TS__NumberIsFinite(value) or value < 0 or value > 1 then
|
|
67
|
+
error("Cell alpha must be between 0 and 1")
|
|
68
|
+
end
|
|
69
|
+
if value ~= previous then
|
|
70
|
+
item.frame:SetAlpha(value)
|
|
71
|
+
end
|
|
72
|
+
previous = value
|
|
73
|
+
end
|
|
74
|
+
refreshAlpha(nil)
|
|
75
|
+
if type(alpha) == "function" then
|
|
76
|
+
updates[#updates + 1] = refreshAlpha
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
return {
|
|
80
|
+
refresh = refreshVisibility,
|
|
81
|
+
onActiveChange = onActiveChange,
|
|
82
|
+
dynamic = visible ~= nil or type(condition) == "function"
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
return ____exports
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ICell } from "../ui/Cell";
|
|
2
|
+
import type { MountedTree, RenderedCell } from "./types";
|
|
3
|
+
export declare function createWidget(cell: ICell, parent: wuiraNativeFrame): wuiraNativeFrame;
|
|
4
|
+
export declare function renderWidget(item: RenderedCell, tree: MountedTree, updates: (() => void)[], onActiveChange: (active: boolean) => void): void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____SecureButton = require("platform.SecureButton")
|
|
4
|
+
local createSecureButton = ____SecureButton.createSecureButton
|
|
5
|
+
local ____secureButton = require("rendering.secureButton")
|
|
6
|
+
local renderSecureButton = ____secureButton.renderSecureButton
|
|
7
|
+
local ____progress = require("rendering.progress")
|
|
8
|
+
local renderProgress = ____progress.renderProgress
|
|
9
|
+
function ____exports.createWidget(self, cell, parent)
|
|
10
|
+
local frame = cell.kind == "progress" and CreateFrame("StatusBar", nil, parent) or (cell.kind == "secureButton" and createSecureButton(nil, parent, cell.props) or (cell.kind == "button" and CreateFrame("Button", nil, parent) or CreateFrame("Frame", nil, parent)))
|
|
11
|
+
frame:Hide()
|
|
12
|
+
local ____frame_EnableMouse_2 = frame.EnableMouse
|
|
13
|
+
local ____temp_1 = cell.kind == "secureButton" or cell.kind == "button"
|
|
14
|
+
if not ____temp_1 then
|
|
15
|
+
local ____cell_props_clickThrough_0 = cell.props.clickThrough
|
|
16
|
+
if ____cell_props_clickThrough_0 == nil then
|
|
17
|
+
____cell_props_clickThrough_0 = true
|
|
18
|
+
end
|
|
19
|
+
____temp_1 = not ____cell_props_clickThrough_0
|
|
20
|
+
end
|
|
21
|
+
____frame_EnableMouse_2(frame, ____temp_1)
|
|
22
|
+
return frame
|
|
23
|
+
end
|
|
24
|
+
function ____exports.renderWidget(self, item, tree, updates, onActiveChange)
|
|
25
|
+
if item.cell.kind == "secureButton" then
|
|
26
|
+
renderSecureButton(nil, item, tree)
|
|
27
|
+
end
|
|
28
|
+
if item.cell.kind == "button" then
|
|
29
|
+
local onClick = item.cell.props.onClick
|
|
30
|
+
local ____self_4 = item.frame
|
|
31
|
+
local ____self_4_SetScript_5 = ____self_4.SetScript
|
|
32
|
+
local ____temp_3
|
|
33
|
+
if onClick == nil then
|
|
34
|
+
____temp_3 = nil
|
|
35
|
+
else
|
|
36
|
+
____temp_3 = function() return onClick(nil) end
|
|
37
|
+
end
|
|
38
|
+
____self_4_SetScript_5(____self_4, "OnClick", ____temp_3)
|
|
39
|
+
local ____tree_bindings_6 = tree.bindings
|
|
40
|
+
____tree_bindings_6[#____tree_bindings_6 + 1] = function() return item.frame:SetScript("OnClick", nil) end
|
|
41
|
+
end
|
|
42
|
+
if item.cell.kind == "label" then
|
|
43
|
+
local props = item.cell.props
|
|
44
|
+
local label = item.frame:CreateFontString(nil, "OVERLAY")
|
|
45
|
+
label:SetAllPoints(item.frame)
|
|
46
|
+
label:SetFont(props.font or "Fonts\\FRIZQT__.TTF", props.fontSize or 12, "OUTLINE")
|
|
47
|
+
label:SetJustifyH(props.align or "LEFT")
|
|
48
|
+
label:SetJustifyV("MIDDLE")
|
|
49
|
+
local color = props.color
|
|
50
|
+
label:SetTextColor(color and color.r or 1, color and color.g or 1, color and color.b or 1, color and color.a or 1)
|
|
51
|
+
local text = props.text
|
|
52
|
+
if type(text) == "function" then
|
|
53
|
+
local previous
|
|
54
|
+
updates[#updates + 1] = function()
|
|
55
|
+
local value = text(nil)
|
|
56
|
+
if issecretvalue(value) or value ~= previous then
|
|
57
|
+
label:SetText(value)
|
|
58
|
+
end
|
|
59
|
+
if not issecretvalue(value) then
|
|
60
|
+
previous = value
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
label:SetText(text)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
if item.cell.kind == "icon" then
|
|
68
|
+
local props = item.cell.props
|
|
69
|
+
local texture = item.frame:CreateTexture(nil, "OVERLAY")
|
|
70
|
+
texture:SetAllPoints(item.frame)
|
|
71
|
+
local uv = props.texCoords or ({0, 1, 0, 1})
|
|
72
|
+
texture:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
|
|
73
|
+
texture:SetTexture(props.texture)
|
|
74
|
+
local ____opt_15 = props.textureSource
|
|
75
|
+
if ____opt_15 ~= nil then
|
|
76
|
+
____opt_15:BindTo(item.frame, texture, onActiveChange)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
if item.cell.kind == "progress" then
|
|
80
|
+
renderProgress(nil, item, tree, onActiveChange)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
return ____exports
|
package/lib/wuira.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { Cell } from "./ui/Cell";
|
|
2
2
|
import type { Anchor } from "./types/Position";
|
|
3
|
+
import { WuiraApp } from "./WuiraApp";
|
|
3
4
|
import type { CommandCallback } from "./platform/SlashCommands";
|
|
4
|
-
/**
|
|
5
|
-
export declare class
|
|
5
|
+
/** Static access to the current addon's application. Each addon owns its module instance. */
|
|
6
|
+
export declare class Wuira {
|
|
6
7
|
private constructor();
|
|
7
|
-
|
|
8
|
+
private static readonly application;
|
|
9
|
+
static get App(): WuiraApp;
|
|
8
10
|
static registerCommand(command: string, callback: CommandCallback): () => void;
|
|
9
|
-
static Mount(
|
|
11
|
+
static Mount(component: Cell | void | (() => Cell | void), anchor?: Anchor, parent?: wuiraNativeFrame): wuiraNativeFrame | undefined;
|
|
10
12
|
static Unmount(frame: wuiraNativeFrame): void;
|
|
11
13
|
}
|
|
14
|
+
/** Compatibility alias for existing addons. */
|
|
15
|
+
export { Wuira as wuira };
|