@overmvp/kumi 0.3.0 → 0.4.0
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/animation/index.ts +4 -0
- package/animation/motion-policy.ts +20 -0
- package/animation/slide.ts +61 -0
- package/animation/spring.ts +75 -0
- package/animation/staggered-reveal.ts +34 -0
- package/builder/css-gradients.mjs +74 -0
- package/builder/css-mask-assets.mjs +52 -0
- package/builder/css-mask-assets.test.mjs +31 -0
- package/builder/css-v1.mjs +73 -22
- package/builder/css-v1.test.mjs +42 -2
- package/builder/src/compiler.rs +25 -0
- package/builder/src/lua_upvalues.rs +641 -0
- package/builder/src/main.rs +1 -0
- package/builder/style-modules.mjs +21 -3
- package/builder/style-modules.test.mjs +24 -0
- package/builder/style-states.mjs +6 -4
- package/package.json +1 -1
- package/router/index.ts +1 -0
- package/router/link.tsx +32 -0
- package/scripts/addon-build.mjs +15 -2
- package/scripts/addon-project.mjs +22 -11
- package/src/bindings.ts +10 -4
- package/src/context.ts +31 -7
- package/src/css-tokens.ts +11 -2
- package/src/css-v1.ts +3 -0
- package/src/elements.ts +9 -0
- package/src/flex-layout.ts +26 -5
- package/src/frame-scheduler.ts +3 -1
- package/src/index.ts +2 -2
- package/src/keyed-list.ts +9 -6
- package/src/module-ui.ts +18 -2
- package/src/module.ts +12 -3
- package/src/reactivity.ts +14 -1
- package/src/style-classes.ts +22 -1
- package/src/style-states.ts +13 -6
- package/state/setup-store.ts +3 -3
- package/templates/addon/.agents/skills/kumi-ui/SKILL.md +1 -1
- package/templates/addon/.claude/skills/kumi-ui/SKILL.md +1 -1
- package/templates/addon/AGENTS.md +1 -1
- package/templates/addon/kumi.config.ts +17 -17
- package/templates/addon/src/app/layout/{AppWindow.module.scss → AppWindow.module.css} +10 -12
- package/templates/addon/src/modules/greeting/ui/{Greeting.module.scss → Greeting.module.css} +9 -11
- package/templates/addon/src/modules/playtime/ui/{Playtime.module.scss → Playtime.module.css} +3 -5
- package/templates/addon/src/shared/styles/tokens.css +13 -0
- package/templates/addon/src/shared/ui/{Controls.module.scss → Controls.module.css} +18 -20
- package/wow/action-button.ts +26 -1
- package/wow/addon-manifest.ts +2 -0
- package/wow/animation.ts +3 -14
- package/wow/app-ui.ts +19 -10
- package/wow/css-background-image.ts +75 -0
- package/wow/css-box.ts +7 -5
- package/wow/css-image-mask.ts +32 -0
- package/wow/css-surfaces.ts +78 -31
- package/wow/element-events.ts +33 -13
- package/wow/heal-prediction.ts +2 -4
- package/wow/index.ts +2 -1
- package/wow/layout-view.ts +18 -9
- package/wow/module-replacements.ts +103 -0
- package/wow/pointer-click.ts +35 -0
- package/wow/protected-view.ts +49 -13
- package/wow/rounded-texture.ts +9 -4
- package/wow/state-paint.ts +5 -14
- package/wow/texture-fill.ts +10 -0
- package/wow/unit-cast.ts +6 -4
- package/wow/view.ts +287 -175
- package/templates/addon/src/shared/styles/_tokens.scss +0 -12
package/wow/animation.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { RuntimeScope } from "../src/runtime";
|
|
|
3
3
|
import { fail, ok, type Result } from "../src/result";
|
|
4
4
|
import { currentScope } from "../src/reactive-scope";
|
|
5
5
|
import { nativeSmoothing } from "../animation/ease";
|
|
6
|
+
import { isReducedMotion, type MotionMode } from "../animation/motion-policy";
|
|
6
7
|
import { finalAlpha, planAnimation, type AlphaStep, type AnimationPlan, type AnimationSpec, type AnimationStep, type FlipBookStep,
|
|
7
8
|
type MoveStep, type PlannedStep, type RegionAnimation, type RegionStep, type RotateStep, type ScaleStep } from "../animation/spec";
|
|
8
9
|
import { scaleFactors } from "../animation/cycle";
|
|
@@ -24,13 +25,7 @@ export interface AnimationTarget {
|
|
|
24
25
|
/** The region type a spec needs: rotation and flipbooks work on textures only. */
|
|
25
26
|
export type TargetOf<Step extends AnimationStep> = [Exclude<Step, RegionStep>] extends [never] ? AnimationTarget : Texture;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
export type MotionMode = "full" | "reduced";
|
|
29
|
-
|
|
30
|
-
export interface AnimationDefaults {
|
|
31
|
-
/** Read on every play of an animation that has no `motion` option of its own. */
|
|
32
|
-
motion?: (this: void) => MotionMode;
|
|
33
|
-
}
|
|
28
|
+
export { configureAnimations, type AnimationDefaults, type MotionMode } from "../animation/motion-policy";
|
|
34
29
|
|
|
35
30
|
export interface NativeAnimationOptions {
|
|
36
31
|
/**
|
|
@@ -89,12 +84,6 @@ export interface AnimationControl extends AnimationPlayback {
|
|
|
89
84
|
}
|
|
90
85
|
|
|
91
86
|
const looping = { repeat: "REPEAT", bounce: "BOUNCE" } as const;
|
|
92
|
-
let defaults: AnimationDefaults = {};
|
|
93
|
-
|
|
94
|
-
/** Set application-wide defaults, such as the reduced motion setting of the player's profile. */
|
|
95
|
-
export function configureAnimations(this: void, options: AnimationDefaults): void {
|
|
96
|
-
defaults = { ...options as OwnedRecord<AnimationDefaults> };
|
|
97
|
-
}
|
|
98
87
|
|
|
99
88
|
function applyTiming(animation: NativeAnimation, step: PlannedStep) {
|
|
100
89
|
animation.SetOrder(1);
|
|
@@ -205,7 +194,7 @@ function build(target: AnimationTarget, spec: AnimationSpec, options: Omit<Nativ
|
|
|
205
194
|
if (options.speed !== undefined) group.SetAnimationSpeedMultiplier(options.speed);
|
|
206
195
|
|
|
207
196
|
function reduced() {
|
|
208
|
-
return (options.motion
|
|
197
|
+
return isReducedMotion(options.motion);
|
|
209
198
|
}
|
|
210
199
|
|
|
211
200
|
function skipToEnd() {
|
package/wow/app-ui.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext } from "../src/context";
|
|
2
2
|
import { createElement } from "../src/elements";
|
|
3
|
-
import { installModuleUi, modulePages, type ModulePage, type ModuleUi, type ModuleView, type ModuleWindow, type ViewComponent } from "../src/module-ui";
|
|
3
|
+
import { installModuleUi, modulePages, type ModulePage, type ModuleReplacement, type ModuleUi, type ModuleView, type ModuleWindow, type ViewComponent } from "../src/module-ui";
|
|
4
4
|
import type { OwnedReadonlyArray, OwnedRecord } from "../src/owned-collections";
|
|
5
5
|
import { computed } from "../src/reactive-scope";
|
|
6
6
|
import { ref, type ReadonlyRef } from "../src/reactivity";
|
|
@@ -10,13 +10,14 @@ import { withRouterHost, type RoutePage, type RouterHost } from "../router/route
|
|
|
10
10
|
import { defineStore, readonly } from "../state/setup-store";
|
|
11
11
|
import type { EventApi } from "./contract";
|
|
12
12
|
import type { FrameStrata } from "./frame-layer";
|
|
13
|
+
import { mountModuleReplacements } from "./module-replacements";
|
|
13
14
|
import { createNativePanel } from "./panel-host";
|
|
14
15
|
import { mountProtectedView } from "./protected-view";
|
|
15
16
|
import type { NativeViewOptions } from "./view";
|
|
16
17
|
|
|
17
18
|
/** App-wide options for every view Kumi mounts: textures, fonts, control skins and media queries. */
|
|
18
19
|
export type AppTheme = Omit<NativeViewOptions, "rootLayer" | "bindings" | "manualTextBindings" | "layoutDiagnostics" | "regionsOnly"
|
|
19
|
-
| "rootBackdrop" | "rootScale" | "unanchoredRoot" | "portalRoot">;
|
|
20
|
+
| "rootBackdrop" | "rootScale" | "unanchoredRoot" | "portalRoot" | "unprotectedOnly">;
|
|
20
21
|
|
|
21
22
|
interface FileRouter {
|
|
22
23
|
readonly pages: OwnedReadonlyArray<{ readonly path: string; readonly title?: string; readonly order?: number }>;
|
|
@@ -174,15 +175,23 @@ export function useViewHost(this: void): ViewHost {
|
|
|
174
175
|
return host;
|
|
175
176
|
}
|
|
176
177
|
|
|
177
|
-
function mountView(context: AppContext, component
|
|
178
|
+
function mountView(context: AppContext, { component, strata = "MEDIUM", combatUpdates }: ModuleView, scope: RuntimeScope): Result<void> {
|
|
178
179
|
const mounted = mountProtectedView(context.runtime, scope, (_view, refresh, pixel) => {
|
|
179
180
|
const rendered = viewContext.run({ refresh, pixel }, () => createElement(component, {}), scope.protect);
|
|
180
181
|
if (!rendered.ok) throw new Error(formatFailure(rendered));
|
|
181
182
|
return rendered.value;
|
|
182
|
-
}, { ...context.theme as OwnedRecord<NativeViewOptions>, rootLayer: { strata: strata as FrameStrata } });
|
|
183
|
+
}, { ...context.theme as OwnedRecord<NativeViewOptions>, rootLayer: { strata: strata as FrameStrata }, combatUpdates });
|
|
183
184
|
return mounted.ok ? ok(undefined) : mounted;
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
function mountViews(context: AppContext, id: string, views: OwnedReadonlyArray<ViewComponent | ModuleView>, scope: RuntimeScope): Result<void> {
|
|
188
|
+
for (const view of views) {
|
|
189
|
+
const mounted = mountView(context, typeof view === "function" ? { component: view } : view, scope);
|
|
190
|
+
if (!mounted.ok) return fail("Module " + id + ": " + mounted.reason);
|
|
191
|
+
}
|
|
192
|
+
return ok(undefined);
|
|
193
|
+
}
|
|
194
|
+
|
|
186
195
|
function mountUi(id: string, ui: ModuleUi, scope: RuntimeScope): Result<void> {
|
|
187
196
|
const context = app;
|
|
188
197
|
if (context === undefined) return fail("Module " + id + " declares UI but the addon is not running");
|
|
@@ -200,13 +209,13 @@ function mountUi(id: string, ui: ModuleUi, scope: RuntimeScope): Result<void> {
|
|
|
200
209
|
});
|
|
201
210
|
if (!released.ok) return released;
|
|
202
211
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
const views = (ui.views ?? []) as OwnedReadonlyArray<ViewComponent | ModuleView>;
|
|
213
|
+
const replacements = ui.replaces as OwnedReadonlyArray<ModuleReplacement> | undefined;
|
|
214
|
+
if (replacements !== undefined && replacements.length > 0) {
|
|
215
|
+
return mountModuleReplacements(context.runtime, scope, id, replacements,
|
|
216
|
+
viewScope => mountViews(context, id, views, viewScope));
|
|
208
217
|
}
|
|
209
|
-
return
|
|
218
|
+
return mountViews(context, id, views, scope);
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
/** @internal Called by startAddon before the root module activates. */
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { fail, ok, type Result } from "../src/result";
|
|
2
|
+
import { sameBackgroundImage, type StatePaint } from "../src/style-states";
|
|
3
|
+
import { resolveStyleValue, type StyleEnvironment } from "../src/style-variables";
|
|
4
|
+
import type { RGBA } from "../utils/colors";
|
|
5
|
+
import { readCssColor } from "./css-color";
|
|
6
|
+
import type { Texture } from "./frames";
|
|
7
|
+
import { api, reveal } from "./native";
|
|
8
|
+
|
|
9
|
+
type BackgroundImage = StatePaint["backgroundImage"];
|
|
10
|
+
|
|
11
|
+
export function cssTexturePath(path: string): string {
|
|
12
|
+
const local = path.startsWith("./") ? path.slice(2) : path;
|
|
13
|
+
return local.split("/").join("\\");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function gradientStop(input: string, environment: StyleEnvironment | undefined): Result<RGBA> {
|
|
17
|
+
const resolved = resolveStyleValue(input, environment);
|
|
18
|
+
if (!resolved.ok) return resolved;
|
|
19
|
+
const literal = reveal(resolved.value);
|
|
20
|
+
const color = literal === "transparent" ? [0, 0, 0, 0] as RGBA
|
|
21
|
+
: literal === "black" ? [0, 0, 0, 1] as RGBA
|
|
22
|
+
: literal === "white" ? [1, 1, 1, 1] as RGBA
|
|
23
|
+
: literal === undefined ? undefined : readCssColor(literal);
|
|
24
|
+
return color === undefined ? fail(`Invalid CSS gradient color ${input}`) : ok(color);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function sameColor(previous: RGBA | undefined, next: RGBA) {
|
|
28
|
+
return previous !== undefined && previous[0] === next[0] && previous[1] === next[1]
|
|
29
|
+
&& previous[2] === next[2] && previous[3] === next[3];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function createBackgroundPainter(texture: Texture, show: (this: void, visible: boolean) => void, environment?: StyleEnvironment) {
|
|
33
|
+
let previous: BackgroundImage;
|
|
34
|
+
let minColor: RGBA | undefined;
|
|
35
|
+
let maxColor: RGBA | undefined;
|
|
36
|
+
|
|
37
|
+
return function paint(this: void, image?: BackgroundImage): Result<void> {
|
|
38
|
+
if (image !== undefined && "gradient" in image) {
|
|
39
|
+
const { axis, min, max } = image.gradient;
|
|
40
|
+
const low = gradientStop(min, environment);
|
|
41
|
+
if (!low.ok) return low;
|
|
42
|
+
const high = gradientStop(max, environment);
|
|
43
|
+
if (!high.ok) return high;
|
|
44
|
+
const a = low.value, b = high.value;
|
|
45
|
+
if (sameBackgroundImage(previous, image) && sameColor(minColor, a) && sameColor(maxColor, b)) return ok(undefined);
|
|
46
|
+
|
|
47
|
+
const createColor = api.CreateColor;
|
|
48
|
+
if (typeof createColor !== "function" || typeof texture.SetGradient !== "function") {
|
|
49
|
+
return fail("CSS linear gradients require native texture gradients");
|
|
50
|
+
}
|
|
51
|
+
if (previous !== undefined && "atlas" in previous) texture.SetTexCoord(0, 1, 0, 1);
|
|
52
|
+
texture.SetColorTexture(1, 1, 1, 1);
|
|
53
|
+
// A fully transparent CSS stop takes the hue of its neighbor.
|
|
54
|
+
const start = a[3] === 0 ? createColor(b[0], b[1], b[2], 0) : createColor(...a);
|
|
55
|
+
const end = b[3] === 0 ? createColor(a[0], a[1], a[2], 0) : createColor(...b);
|
|
56
|
+
texture.SetGradient(axis, start, end);
|
|
57
|
+
minColor = a;
|
|
58
|
+
maxColor = b;
|
|
59
|
+
show(true);
|
|
60
|
+
} else {
|
|
61
|
+
if (sameBackgroundImage(previous, image)) return ok(undefined);
|
|
62
|
+
if (previous !== undefined && "gradient" in previous) texture.SetVertexColor(1, 1, 1, 1);
|
|
63
|
+
if (image === undefined) show(false);
|
|
64
|
+
else if ("path" in image) {
|
|
65
|
+
if (previous !== undefined && "atlas" in previous) texture.SetTexCoord(0, 1, 0, 1);
|
|
66
|
+
show(texture.SetTexture(cssTexturePath(image.path)) !== false);
|
|
67
|
+
} else {
|
|
68
|
+
texture.SetAtlas(image.atlas, false);
|
|
69
|
+
show(true);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
previous = image;
|
|
73
|
+
return ok(undefined);
|
|
74
|
+
};
|
|
75
|
+
}
|
package/wow/css-box.ts
CHANGED
|
@@ -19,8 +19,8 @@ type Inset = readonly [top: number, right: number, bottom: number, left: number]
|
|
|
19
19
|
type Content = { readonly frame: Frame; readonly layout?: NativeLayoutGroup };
|
|
20
20
|
|
|
21
21
|
export function hasCssSurface(this: void, style: NativeStyle, paint?: NativePaintState): boolean {
|
|
22
|
-
return style.border !== undefined || style.backgroundImage !== undefined ||
|
|
23
|
-
|
|
22
|
+
return style.border !== undefined || style.backgroundImage !== undefined || paint?.usesBackgroundImage === true
|
|
23
|
+
|| (style.borderRadius !== undefined && (style.backgroundColor !== undefined || paint?.usesBackgroundColor === true));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function mountCssSurface(this: void, scope: RuntimeScope, frame: Frame, style: NativeStyle, paint: NativePaintState | undefined,
|
|
@@ -32,7 +32,8 @@ export function mountCssSurface(this: void, scope: RuntimeScope, frame: Frame, s
|
|
|
32
32
|
const fixedBorderRadius = rounded?.borderOutline !== undefined && style.border !== undefined ? fixedRadius : undefined;
|
|
33
33
|
const created = createCssSurface(scope, frame, {
|
|
34
34
|
rounded, environment, nativeRoundedArt, color: style.backgroundColor !== undefined || paint?.usesBackgroundColor === true,
|
|
35
|
-
image, fixedFillRadius, fixedBorderRadius,
|
|
35
|
+
image, maskImage: style.maskImage, fixedFillRadius, fixedBorderRadius,
|
|
36
|
+
liveOutline: live !== undefined && style.border !== undefined && style.borderRadius !== undefined,
|
|
36
37
|
borderState: style.border !== undefined && paint?.usesBorderColor === true,
|
|
37
38
|
fixedBorder: live === undefined ? style.border : undefined,
|
|
38
39
|
borderPaint: style.borderPaint,
|
|
@@ -81,11 +82,12 @@ function padding(style: NativeStyle | undefined, live?: ReadCssStyle, decorative
|
|
|
81
82
|
return ok([top + bt, (right ?? top) + br, (bottom ?? top) + bb, (left ?? right ?? top) + bl]);
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
export function includeCssBorderPadding(this: void, scope: RuntimeScope, props:
|
|
85
|
+
export function includeCssBorderPadding<Props extends Pick<FrameProps, "style">>(this: void, scope: RuntimeScope, props: Props,
|
|
86
|
+
live?: ReadCssStyle, decorativeBorder = false): Props {
|
|
85
87
|
const style = props.style;
|
|
86
88
|
if (decorativeBorder || style?.border === undefined) return props;
|
|
87
89
|
const adjusted = scope.computedResult(() => padding(style, live), "CSS border padding");
|
|
88
|
-
return { ...props as OwnedRecord<
|
|
90
|
+
return { ...props as OwnedRecord<Props>, style: { ...style as OwnedRecord<NativeStyle>, padding: adjusted } };
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
function insetContent(scope: RuntimeScope, frame: Frame, style: NativeStyle, live?: ReadCssStyle, decorativeBorder = false): Result<Frame> {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CssV1Style } from "../src/css-v1";
|
|
2
|
+
import { fail, ok, type Result } from "../src/result";
|
|
3
|
+
import type { RuntimeScope } from "../src/runtime";
|
|
4
|
+
import { cssTexturePath } from "./css-background-image";
|
|
5
|
+
import type { Frame, MaskTexture, Texture } from "./frames";
|
|
6
|
+
|
|
7
|
+
export function mountImageMask(scope: RuntimeScope, parent: Frame, texture: Texture, source: NonNullable<CssV1Style["maskImage"]>): Result<void> {
|
|
8
|
+
if (typeof parent.CreateMaskTexture !== "function" || typeof texture.AddMaskTexture !== "function"
|
|
9
|
+
|| typeof texture.RemoveMaskTexture !== "function") return fail("CSS mask-image requires native texture masks");
|
|
10
|
+
|
|
11
|
+
let mask: MaskTexture | undefined;
|
|
12
|
+
let attached = false;
|
|
13
|
+
const cleanup = scope.onDispose(() => {
|
|
14
|
+
if (mask === undefined) return;
|
|
15
|
+
if (attached) texture.RemoveMaskTexture(mask);
|
|
16
|
+
mask.Hide();
|
|
17
|
+
});
|
|
18
|
+
if (!cleanup.ok) return cleanup;
|
|
19
|
+
const applied = scope.protect(() => {
|
|
20
|
+
const target = parent.CreateMaskTexture();
|
|
21
|
+
mask = target;
|
|
22
|
+
const path = cssTexturePath(source.path);
|
|
23
|
+
if (target.SetTexture(path, "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE") === false) {
|
|
24
|
+
return fail(`Could not load CSS mask image ${source.path}`);
|
|
25
|
+
}
|
|
26
|
+
target.SetAllPoints(texture);
|
|
27
|
+
texture.AddMaskTexture(target);
|
|
28
|
+
attached = true;
|
|
29
|
+
return ok(undefined);
|
|
30
|
+
});
|
|
31
|
+
return applied.ok ? applied.value : applied;
|
|
32
|
+
}
|
package/wow/css-surfaces.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CssBorder, CssBorderPaintPlan, CssSide } from "../src/css-v1";
|
|
1
|
+
import type { CssBorder, CssBorderPaintPlan, CssSide, CssV1Style } from "../src/css-v1";
|
|
2
2
|
import type { OwnedArray, OwnedReadonlyArray } from "../src/owned-collections";
|
|
3
3
|
import { ref } from "../src/reactivity";
|
|
4
4
|
import { fail, ok, type Result } from "../src/result";
|
|
@@ -6,7 +6,9 @@ import type { RuntimeScope } from "../src/runtime";
|
|
|
6
6
|
import type { StatePaint } from "../src/style-states";
|
|
7
7
|
import { resolveStyleValue, type StyleEnvironment } from "../src/style-variables";
|
|
8
8
|
import type { RGBA } from "../utils/colors";
|
|
9
|
+
import { createBackgroundPainter } from "./css-background-image";
|
|
9
10
|
import { readCssColor } from "./css-color";
|
|
11
|
+
import { mountImageMask } from "./css-image-mask";
|
|
10
12
|
import type { Frame, MaskTexture, Texture } from "./frames";
|
|
11
13
|
import { isSecret, reveal } from "./native";
|
|
12
14
|
import { physicalPixelScale, snapPixel } from "./pixel";
|
|
@@ -38,12 +40,15 @@ export interface CssSurfaceOptions {
|
|
|
38
40
|
readonly environment?: StyleEnvironment;
|
|
39
41
|
readonly color?: boolean;
|
|
40
42
|
readonly image?: boolean;
|
|
43
|
+
readonly maskImage?: CssV1Style["maskImage"];
|
|
41
44
|
readonly borderState?: boolean;
|
|
42
45
|
/** Fixed authored border. Its widths still follow the physical display scale. */
|
|
43
46
|
readonly fixedBorder?: CssBorder;
|
|
44
47
|
/** Immutable solid fill, without an image or a border to clip. */
|
|
45
48
|
readonly fixedFillRadius?: number;
|
|
46
49
|
readonly fixedBorderRadius?: number;
|
|
50
|
+
/** A live style can select sliced art whenever its current border is uniform. */
|
|
51
|
+
readonly liveOutline?: boolean;
|
|
47
52
|
readonly borderPaint?: CssBorderPaintPlan;
|
|
48
53
|
readonly pixelSize?: (this: void) => number;
|
|
49
54
|
}
|
|
@@ -60,7 +65,7 @@ export interface CssSurface {
|
|
|
60
65
|
write(this: void, side: CssSide, red: number, green: number, blue: number, alpha: number): void;
|
|
61
66
|
};
|
|
62
67
|
setBackgroundColor(this: void, r: number, g: number, b: number, a: number): void;
|
|
63
|
-
setBackgroundImage(this: void, image?: BackgroundImage): void
|
|
68
|
+
setBackgroundImage(this: void, image?: BackgroundImage): Result<void>;
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
export const borderSides = ["top", "right", "bottom", "left"] as const;
|
|
@@ -154,14 +159,17 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
154
159
|
let previousRadius = 0;
|
|
155
160
|
let artworkRadius: number | undefined;
|
|
156
161
|
let slicedFill = false;
|
|
157
|
-
const
|
|
158
|
-
&&
|
|
162
|
+
const fixedOutline = options.fixedBorderRadius !== undefined && uniformBorder?.ok === true
|
|
163
|
+
&& sameInsets(uniformBorder.value.insets, onePixelInsets);
|
|
164
|
+
const nativeOutline = artwork === undefined && options.image !== true && options.pixelSize !== undefined
|
|
165
|
+
&& (fixedOutline || options.liveOutline === true) ? options.rounded?.borderOutline : undefined;
|
|
159
166
|
let canSlice = nativeOutline !== undefined && canPlaceOutline() && typeof frame.GetSize === "function"
|
|
160
167
|
&& typeof frame.HasScript === "function" && typeof frame.HookScript === "function"
|
|
161
168
|
&& reveal(frame.HasScript("OnSizeChanged")) === true;
|
|
162
169
|
let sliceUnavailable = false;
|
|
163
170
|
let sliceActive = false;
|
|
164
171
|
let sliceRadius: number | undefined, sliceScale: number | undefined;
|
|
172
|
+
let sliceFillRadius: number | undefined;
|
|
165
173
|
let lastSizeWidth: number | undefined, lastSizeHeight: number | undefined;
|
|
166
174
|
let minOutlineSize: number | undefined;
|
|
167
175
|
|
|
@@ -173,9 +181,12 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
173
181
|
|
|
174
182
|
function borderSizeChanged(this: void, width: number, height: number) {
|
|
175
183
|
const previous = outlineFits();
|
|
184
|
+
const shortSide = lastSizeWidth === undefined || lastSizeHeight === undefined ? undefined : Math.min(lastSizeWidth, lastSizeHeight);
|
|
176
185
|
lastSizeWidth = reveal(width);
|
|
177
186
|
lastSizeHeight = reveal(height);
|
|
178
|
-
return !sliceUnavailable && minOutlineSize !== undefined && outlineFits() !== previous
|
|
187
|
+
return !sliceUnavailable && minOutlineSize !== undefined && (outlineFits() !== previous
|
|
188
|
+
|| nativeOutline?.resolveFill !== undefined && lastSizeWidth !== undefined && lastSizeHeight !== undefined
|
|
189
|
+
&& Math.min(lastSizeWidth, lastSizeHeight) !== shortSide);
|
|
179
190
|
}
|
|
180
191
|
|
|
181
192
|
function canPlaceOutline() {
|
|
@@ -374,23 +385,61 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
374
385
|
&& typeof texture.SetSnapToPixelGrid === "function" && typeof texture.SetTexelSnappingBias === "function";
|
|
375
386
|
}
|
|
376
387
|
|
|
388
|
+
function restoreFill() {
|
|
389
|
+
if (color === undefined || sliceFillRadius === undefined) return;
|
|
390
|
+
const texture = color.texture;
|
|
391
|
+
texture.SetIgnoreParentScale(false);
|
|
392
|
+
texture.SetScale(1);
|
|
393
|
+
texture.SetTextureSliceMargins(0, 0, 0, 0);
|
|
394
|
+
texture.SetColorTexture(1, 1, 1, 1);
|
|
395
|
+
if (colorR !== undefined && colorG !== undefined && colorB !== undefined && colorA !== undefined) {
|
|
396
|
+
texture.SetVertexColor(colorR, colorG, colorB, colorA);
|
|
397
|
+
}
|
|
398
|
+
sliceFillRadius = undefined;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function setPixelFill(deviceRadius: number, scale: number) {
|
|
402
|
+
if (color === undefined || nativeOutline === undefined) return;
|
|
403
|
+
const texture = color.texture;
|
|
404
|
+
if (sliceFillRadius !== deviceRadius) {
|
|
405
|
+
const asset = nativeOutline.resolveFill?.(deviceRadius);
|
|
406
|
+
if (asset === undefined || texture.SetTexture(asset) === false) return restoreFill();
|
|
407
|
+
texture.SetIgnoreParentScale(true);
|
|
408
|
+
texture.SetTexelSnappingBias(0);
|
|
409
|
+
texture.SetSnapToPixelGrid(true);
|
|
410
|
+
texture.SetTextureSliceMargins(deviceRadius, deviceRadius, deviceRadius, deviceRadius);
|
|
411
|
+
texture.SetTextureSliceMode(nativeOutline.stretched);
|
|
412
|
+
if (colorR !== undefined && colorG !== undefined && colorB !== undefined && colorA !== undefined) {
|
|
413
|
+
texture.SetVertexColor(colorR, colorG, colorB, colorA);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (sliceFillRadius !== deviceRadius || sliceScale !== scale) texture.SetScale(scale);
|
|
417
|
+
sliceFillRadius = deviceRadius;
|
|
418
|
+
}
|
|
419
|
+
|
|
377
420
|
function setPixelOutline(pixel: number, radius: number) {
|
|
378
421
|
minOutlineSize = undefined;
|
|
379
422
|
if (nativeOutline === undefined || sliceUnavailable || radius <= pixel || !canPlaceOutline()) return false;
|
|
380
423
|
const scale = physicalPixelScale();
|
|
381
424
|
if (scale === undefined) return false;
|
|
382
|
-
|
|
383
|
-
const asset = nativeOutline.resolve(deviceRadius);
|
|
384
|
-
if (asset === undefined) return false;
|
|
425
|
+
let deviceRadius = Math.round(radius / pixel);
|
|
385
426
|
if (lastSizeWidth === undefined || lastSizeHeight === undefined) {
|
|
386
427
|
const [width, height] = frame.GetSize();
|
|
387
428
|
lastSizeWidth = reveal(width);
|
|
388
429
|
lastSizeHeight = reveal(height);
|
|
389
430
|
}
|
|
431
|
+
// A small surface can share a slightly smaller radius between fill and outline.
|
|
432
|
+
if (nativeOutline.resolveFill !== undefined && lastSizeWidth !== undefined && lastSizeHeight !== undefined
|
|
433
|
+
&& lastSizeWidth > 0 && lastSizeHeight > 0) {
|
|
434
|
+
const shortSide = Math.min(lastSizeWidth, lastSizeHeight);
|
|
435
|
+
deviceRadius = Math.min(deviceRadius, Math.floor((shortSide / pixel - 1) / 2));
|
|
436
|
+
}
|
|
390
437
|
// Both caps must fit even after the client rounds the vertices to display pixels.
|
|
391
|
-
minOutlineSize = (2 * deviceRadius + 1) * pixel;
|
|
438
|
+
minOutlineSize = (2 * Math.max(2, deviceRadius) + 1) * pixel;
|
|
392
439
|
const fit = outlineFits();
|
|
393
440
|
if (fit !== "ready") return fit === "pending";
|
|
441
|
+
const asset = nativeOutline.resolve(deviceRadius);
|
|
442
|
+
if (asset === undefined) return false;
|
|
394
443
|
|
|
395
444
|
if (outline === undefined) {
|
|
396
445
|
outline = makeLayer("BORDER", -8, false, false);
|
|
@@ -412,6 +461,7 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
412
461
|
texture.SetTextureSliceMode(nativeOutline.stretched);
|
|
413
462
|
sliceRadius = deviceRadius;
|
|
414
463
|
}
|
|
464
|
+
setPixelFill(deviceRadius, scale);
|
|
415
465
|
if (sliceScale !== scale) {
|
|
416
466
|
texture.SetScale(scale);
|
|
417
467
|
sliceScale = scale;
|
|
@@ -462,13 +512,17 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
462
512
|
const insets: Insets = pixel === undefined ? logical : [snap(logical[0]), snap(logical[1]), snap(logical[2]), snap(logical[3])];
|
|
463
513
|
const configured = scope.protect(() => {
|
|
464
514
|
const edge = colors.top;
|
|
465
|
-
|
|
515
|
+
const uniform = edge !== undefined && (combined
|
|
516
|
+
|| borderSides.every(side => colors[side]?.literal === edge.literal));
|
|
517
|
+
if (canSlice && pixel !== undefined && edge !== undefined && uniform && sameInsets(logical, onePixelInsets)) {
|
|
466
518
|
const sliced = scope.protect(() => setPixelOutline(pixel, radius));
|
|
467
519
|
if (!sliced.ok) sliceUnavailable = true;
|
|
468
520
|
if (sliced.ok && sliced.value) {
|
|
469
|
-
const masked = setMask(color === undefined ? undefined : radius);
|
|
521
|
+
const masked = setMask(color === undefined || sliceFillRadius !== undefined ? undefined : radius);
|
|
470
522
|
if (!masked.ok) return masked;
|
|
471
|
-
if (!sliceActive)
|
|
523
|
+
if (!sliceActive) {
|
|
524
|
+
for (const side of borderSides) for (const part of edges[side] as OwnedArray<SurfaceTexture>) shown(part, false);
|
|
525
|
+
}
|
|
472
526
|
sliceActive = true;
|
|
473
527
|
if (outline !== undefined) {
|
|
474
528
|
const [r, g, b, a] = borderState?.drawn.top ?? edge.rgba;
|
|
@@ -481,6 +535,7 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
481
535
|
}
|
|
482
536
|
const switching = sliceActive;
|
|
483
537
|
if (switching && outline !== undefined) shown(outline, false);
|
|
538
|
+
restoreFill();
|
|
484
539
|
sliceActive = false;
|
|
485
540
|
if (switching || radius !== previousRadius || !sameInsets(previousInsets, insets)) {
|
|
486
541
|
const masked = setMask(radius > 0 ? radius : insets.some(value => value > 0) ? 0 : undefined);
|
|
@@ -525,7 +580,7 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
525
580
|
drawn[2] = blue;
|
|
526
581
|
drawn[3] = alpha;
|
|
527
582
|
if (sliceActive || artwork !== undefined) {
|
|
528
|
-
if (outline !== undefined) tint(outline, red, green, blue, alpha);
|
|
583
|
+
if (outline !== undefined && side === "top") tint(outline, red, green, blue, alpha);
|
|
529
584
|
return;
|
|
530
585
|
}
|
|
531
586
|
const parts = edges[side] as OwnedArray<SurfaceTexture>;
|
|
@@ -544,24 +599,6 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
544
599
|
colorA = a;
|
|
545
600
|
}
|
|
546
601
|
|
|
547
|
-
let path: string | undefined, atlas: string | undefined;
|
|
548
|
-
function setBackgroundImage(next?: BackgroundImage) {
|
|
549
|
-
if (!scope.isActive() || image === undefined) return;
|
|
550
|
-
const nextPath = next !== undefined && "path" in next ? next.path : undefined;
|
|
551
|
-
const nextAtlas = next !== undefined && "atlas" in next ? next.atlas : undefined;
|
|
552
|
-
if (path === nextPath && atlas === nextAtlas) return;
|
|
553
|
-
if (nextPath !== undefined) {
|
|
554
|
-
const local = nextPath.startsWith("./") ? nextPath.slice(2) : nextPath;
|
|
555
|
-
if (atlas !== undefined) image.texture.SetTexCoord(0, 1, 0, 1);
|
|
556
|
-
shown(image, image.texture.SetTexture(local.split("/").join("\\")) !== false);
|
|
557
|
-
} else if (nextAtlas !== undefined) {
|
|
558
|
-
image.texture.SetAtlas(nextAtlas, false);
|
|
559
|
-
shown(image, true);
|
|
560
|
-
} else shown(image, false);
|
|
561
|
-
path = nextPath;
|
|
562
|
-
atlas = nextAtlas;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
602
|
function release() {
|
|
566
603
|
for (const layer of layers) {
|
|
567
604
|
shown(layer, false);
|
|
@@ -595,6 +632,16 @@ export function createCssSurface(this: void, scope: RuntimeScope, frame: Frame,
|
|
|
595
632
|
scope.protect(release);
|
|
596
633
|
return cleanup;
|
|
597
634
|
}
|
|
635
|
+
const background = image;
|
|
636
|
+
const paintImage = background === undefined ? undefined
|
|
637
|
+
: createBackgroundPainter(background.texture, visible => shown(background, visible), options.environment);
|
|
638
|
+
if (background !== undefined && options.maskImage !== undefined) {
|
|
639
|
+
const applied = mountImageMask(scope, frame, background.texture, options.maskImage);
|
|
640
|
+
if (!applied.ok) return applied;
|
|
641
|
+
}
|
|
642
|
+
function setBackgroundImage(next?: BackgroundImage): Result<void> {
|
|
643
|
+
return scope.isActive() && paintImage !== undefined ? paintImage(next) : ok(undefined);
|
|
644
|
+
}
|
|
598
645
|
const responsiveBorder = canSlice ? {
|
|
599
646
|
resize: borderSizeChanged,
|
|
600
647
|
useFallback: () => { canSlice = false; },
|
package/wow/element-events.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ElementEventCoordinator } from "./element-event-coordinator";
|
|
|
9
9
|
import type { Button, CommonScripts, Frame } from "./frames";
|
|
10
10
|
import { hookButtonClick, hookScript } from "./native-hooks";
|
|
11
11
|
import { api, isSecret, reveal } from "./native";
|
|
12
|
+
import { createPointerClickGate } from "./pointer-click";
|
|
12
13
|
import { createProtectedLayoutUpdate } from "./protected-layout";
|
|
13
14
|
import { protect } from "./protect";
|
|
14
15
|
import { hitViewNode, type LogicalNode } from "./view-nodes";
|
|
@@ -27,7 +28,7 @@ export interface ElementStyleInput {
|
|
|
27
28
|
set(this: void, state: StyleState, active: boolean): void;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
type ElementInput = ElementEvents & { onShow?(this: void): void; onHide?(this: void): void };
|
|
31
|
+
type ElementInput = ElementEvents & { clickMaxDuration?: number; onShow?(this: void): void; onHide?(this: void): void };
|
|
31
32
|
type HitRegion = Pick<Frame, "IsVisible" | "IsMouseOver" | "IsForbidden">;
|
|
32
33
|
type HitCandidate = Partial<HitRegion> & { mouseHit?(this: object): boolean | undefined; value?: HitCandidate };
|
|
33
34
|
type ScopeFactory = (this: void) => RuntimeScope;
|
|
@@ -104,6 +105,12 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
104
105
|
if (!hasElementInput(input) && !hover && !activeStyle && disabledStyle === undefined) return;
|
|
105
106
|
if (!canChange(frame)) return fail("Element input target is inaccessible or restricted");
|
|
106
107
|
if (input.tooltip !== undefined && host?.tooltip === undefined) return fail("Element tooltip requires the host tooltip port");
|
|
108
|
+
const clickMaxDuration = input.clickMaxDuration;
|
|
109
|
+
if (clickMaxDuration !== undefined && (!Number.isFinite(clickMaxDuration) || clickMaxDuration <= 0)) {
|
|
110
|
+
return fail("Button clickMaxDuration must be a positive number of seconds");
|
|
111
|
+
}
|
|
112
|
+
const gate = button !== undefined && input.onClick !== undefined && clickMaxDuration !== undefined
|
|
113
|
+
? createPointerClickGate(clickMaxDuration) : undefined;
|
|
107
114
|
const outside = input.onClickOutside !== undefined || input.onDismiss !== undefined || input.ignoreOutside === true;
|
|
108
115
|
const coordinator = host?.coordinator;
|
|
109
116
|
if (outside && coordinator === undefined) return fail("Outside dismissal requires the shared element event coordinator");
|
|
@@ -121,14 +128,14 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
121
128
|
|
|
122
129
|
const restorers = ownedArray<Cancel>();
|
|
123
130
|
const motion = hover || activeStyle || input.onPointerEnter !== undefined || input.onPointerLeave !== undefined || input.tooltip !== undefined;
|
|
124
|
-
const pressed = activeStyle || (button === undefined && input.onClick !== undefined) ? ownedSet<MouseButton>() : undefined;
|
|
131
|
+
const pressed = activeStyle || gate !== undefined || (button === undefined && input.onClick !== undefined) ? ownedSet<MouseButton>() : undefined;
|
|
125
132
|
const observesVisibility = pressed !== undefined || outside || input.onShow !== undefined || input.onHide !== undefined
|
|
126
133
|
|| input.tooltip !== undefined || hover;
|
|
127
134
|
let hoveredTip: Cancel | undefined;
|
|
128
135
|
let visible = false;
|
|
129
136
|
let active = true;
|
|
130
137
|
let ownCleanup: RuntimeScope | undefined;
|
|
131
|
-
let request: (
|
|
138
|
+
let deferred: { readonly scope: RuntimeScope; readonly request: (this: void) => Result<void> } | undefined;
|
|
132
139
|
|
|
133
140
|
function live() { return active && owner.isActive(); }
|
|
134
141
|
|
|
@@ -147,6 +154,7 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
147
154
|
const visibleValue = typeof frame.IsVisible === "function" ? reveal(frame.IsVisible()) : reveal(frame.IsShown());
|
|
148
155
|
const shown = visibleValue === true;
|
|
149
156
|
if (!shown) {
|
|
157
|
+
gate?.clear();
|
|
150
158
|
if (pressed !== undefined) pressed.clear();
|
|
151
159
|
if (activeStyle) style?.set("active", false);
|
|
152
160
|
if (hover) style?.set("hover", false);
|
|
@@ -185,7 +193,7 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
185
193
|
restorers.length = 0;
|
|
186
194
|
const temporary = ownCleanup;
|
|
187
195
|
ownCleanup = undefined;
|
|
188
|
-
|
|
196
|
+
deferred = undefined;
|
|
189
197
|
temporary?.dispose();
|
|
190
198
|
return failure;
|
|
191
199
|
}
|
|
@@ -215,7 +223,7 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
215
223
|
handler => hookButtonClick(button, handler, owner), (_self, raw) => {
|
|
216
224
|
if (!live() || isSecret(raw)) return;
|
|
217
225
|
const event = readClickEvent(raw === undefined ? "LeftButton" : raw);
|
|
218
|
-
if (event !== undefined) click(event);
|
|
226
|
+
if (event !== undefined && (gate === undefined || gate.accept(event.button))) click(event);
|
|
219
227
|
}, hookOnly, restorers);
|
|
220
228
|
if (failure !== undefined) return failure;
|
|
221
229
|
}
|
|
@@ -224,16 +232,20 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
224
232
|
if (!live() || reveal(frame.IsMouseOver()) !== true) return;
|
|
225
233
|
const key = readMouseButton(raw);
|
|
226
234
|
if (key === undefined) return;
|
|
235
|
+
gate?.press(key);
|
|
227
236
|
pressed.add(key);
|
|
228
237
|
if (activeStyle) style?.set("active", true);
|
|
229
238
|
}) ?? listen("OnDragStart", () => {
|
|
230
239
|
if (!live()) return;
|
|
240
|
+
gate?.drag();
|
|
231
241
|
pressed.clear();
|
|
232
242
|
if (activeStyle) style?.set("active", false);
|
|
233
243
|
}) ?? listen("OnMouseUp", (_self, raw) => {
|
|
234
244
|
if (!live()) return;
|
|
235
245
|
const key = readMouseButton(raw);
|
|
236
|
-
if (key === undefined
|
|
246
|
+
if (key === undefined) return;
|
|
247
|
+
gate?.release(key);
|
|
248
|
+
if (!pressed.delete(key)) return;
|
|
237
249
|
const over = reveal(frame.IsMouseOver()) === true;
|
|
238
250
|
if (activeStyle) style?.set("active", over && pressed.size > 0);
|
|
239
251
|
if (button !== undefined || input.onClick === undefined || !over || reveal(frame.IsDragging?.()) === true) return;
|
|
@@ -292,13 +304,18 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
292
304
|
|
|
293
305
|
function reconcile(): Result<void> {
|
|
294
306
|
if (protectedFrame(frame)) {
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
307
|
+
if (deferred === undefined || !deferred.scope.isActive()) {
|
|
308
|
+
const hostScope = coordinator?.scope;
|
|
309
|
+
const lifetime = hostScope?.isActive() === true ? hostScope : (ownCleanup = newScope());
|
|
297
310
|
const queue = createProtectedLayoutUpdate(update, { scope: lifetime, label: "Element input scripts" });
|
|
298
|
-
if (!queue.ok) {
|
|
299
|
-
|
|
311
|
+
if (!queue.ok) {
|
|
312
|
+
ownCleanup?.dispose();
|
|
313
|
+
ownCleanup = undefined;
|
|
314
|
+
return queue;
|
|
315
|
+
}
|
|
316
|
+
deferred = { scope: lifetime, request: queue.value.request };
|
|
300
317
|
}
|
|
301
|
-
return request();
|
|
318
|
+
return deferred.request();
|
|
302
319
|
}
|
|
303
320
|
const configured = protect(update);
|
|
304
321
|
return configured.ok ? configured.value ?? ok(undefined) : configured;
|
|
@@ -308,8 +325,11 @@ export function bindElementEvents(this: void, frame: Frame, input: ElementInput,
|
|
|
308
325
|
active = false;
|
|
309
326
|
closeTip();
|
|
310
327
|
lease?.cancel();
|
|
311
|
-
if (restorers.length === 0
|
|
312
|
-
|
|
328
|
+
if (restorers.length === 0) {
|
|
329
|
+
report(restore());
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
report(deferred?.scope.isActive() === true ? deferred.request() : reconcile());
|
|
313
333
|
});
|
|
314
334
|
if (!cleanup.ok) return cleanup;
|
|
315
335
|
const result = reconcile();
|
package/wow/heal-prediction.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { fail, ok, type Result } from "../src/result";
|
|
|
3
3
|
import { createFrame, type Frame, type FrameParent, type StatusBar, type Texture } from "./frames";
|
|
4
4
|
import { api, isSecret, reveal, type SecretValue } from "./native";
|
|
5
5
|
import { protectNative } from "./protect";
|
|
6
|
+
import { setTextureFill } from "./texture-fill";
|
|
6
7
|
|
|
7
8
|
type Amount = number | SecretValue<number>;
|
|
8
9
|
type Mask = Parameters<Texture["AddMaskTexture"]>[0];
|
|
@@ -63,10 +64,7 @@ function paint(overlay: Overlay, fallback: Color, style?: HealPredictionStyle):
|
|
|
63
64
|
const assetChanged = color === undefined || overlay.asset !== asset;
|
|
64
65
|
if (assetChanged) {
|
|
65
66
|
const tiled = asset !== undefined;
|
|
66
|
-
|
|
67
|
-
else overlay.fill.SetTexture(white);
|
|
68
|
-
overlay.fill.SetHorizTile(tiled);
|
|
69
|
-
overlay.fill.SetVertTile(tiled);
|
|
67
|
+
setTextureFill(overlay.fill, asset ?? white, tiled, tiled);
|
|
70
68
|
overlay.asset = asset;
|
|
71
69
|
}
|
|
72
70
|
if (assetChanged || color === undefined || color[0] !== r || color[1] !== g || color[2] !== b || color[3] !== a) {
|