kaplay-plugin-ui 1.0.0 → 1.0.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/README.md +61 -24
- package/dist/plugin.cjs +50 -131
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +185 -66
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +185 -66
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +51 -130
- package/dist/plugin.mjs.map +1 -1
- package/dist/plugin.umd.js +50 -131
- package/dist/plugin.umd.js.map +1 -1
- package/dist/plugin.umd.min.js +1 -1
- package/dist/plugin.umd.min.js.map +1 -1
- package/global.d.ts +53 -2
- package/package.json +2 -2
package/dist/plugin.d.cts
CHANGED
|
@@ -1,20 +1,180 @@
|
|
|
1
|
-
import { Color
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Color, KAPLAYCtx, Vec2 } from "kaplay";
|
|
2
|
+
declare function createButton(k: KAPLAYCtx, theme: Theme, text: string, opt: ButtonOpt & {
|
|
3
|
+
pos?: Vec2;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
color?: string | Color;
|
|
6
|
+
hoverColor?: string | Color;
|
|
7
|
+
pressedColor?: string | Color;
|
|
8
|
+
textColor?: string | Color;
|
|
9
|
+
}): {
|
|
10
|
+
label: import("kaplay").GameObj<import("kaplay").ColorComp | import("kaplay").AnchorComp | import("kaplay").TextComp>;
|
|
11
|
+
add<T>(comps?: import("kaplay").CompList<T> | import("kaplay").GameObj<T>): import("kaplay").GameObj<T>;
|
|
12
|
+
readd<T>(obj: import("kaplay").GameObj<T>): import("kaplay").GameObj<T>;
|
|
13
|
+
remove(obj: import("kaplay").GameObj): void;
|
|
14
|
+
removeAll(tag: import("kaplay").Tag): void;
|
|
15
|
+
removeAll(): void;
|
|
16
|
+
get(tag: import("kaplay").Tag | import("kaplay").Tag[], opts?: import("kaplay").GetOpt): import("kaplay").GameObj[];
|
|
17
|
+
query(opt: import("kaplay").QueryOpt): import("kaplay").GameObj[];
|
|
18
|
+
parent: import("kaplay").GameObj | null;
|
|
19
|
+
children: import("kaplay").GameObj[];
|
|
20
|
+
tags: string[];
|
|
21
|
+
fixedUpdate(): void;
|
|
22
|
+
update(): void;
|
|
23
|
+
draw(): void;
|
|
24
|
+
drawInspect: () => void;
|
|
25
|
+
clearEvents: () => void;
|
|
26
|
+
use(comp: import("kaplay").Comp | import("kaplay").Tag): void;
|
|
27
|
+
unuse(comp: import("kaplay").Tag): void;
|
|
28
|
+
has(compId: string | string[], op?: "and" | "or"): boolean;
|
|
29
|
+
tag(tag: import("kaplay").Tag | import("kaplay").Tag[]): void;
|
|
30
|
+
untag(tag: import("kaplay").Tag | import("kaplay").Tag[]): void;
|
|
31
|
+
is(tag: import("kaplay").Tag | import("kaplay").Tag[], op?: "and" | "or"): boolean;
|
|
32
|
+
on(event: import("kaplay").GameObjEventNames | (string & {}), action: (...args: any) => void): import("kaplay").KEventController;
|
|
33
|
+
trigger(event: string, ...args: any): void;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
c(id: string): import("kaplay").Comp | null;
|
|
36
|
+
inspect(): import("kaplay").GameObjInspect;
|
|
37
|
+
onAdd(action: () => void): import("kaplay").KEventController;
|
|
38
|
+
onUpdate(action: () => void): import("kaplay").KEventController;
|
|
39
|
+
onFixedUpdate(action: () => void): import("kaplay").KEventController;
|
|
40
|
+
onDraw(action: () => void): import("kaplay").KEventController;
|
|
41
|
+
onDestroy(action: () => void): import("kaplay").KEventController;
|
|
42
|
+
onUse(action: (id: string) => void): import("kaplay").KEventController;
|
|
43
|
+
onUnuse(action: (id: string) => void): import("kaplay").KEventController;
|
|
44
|
+
onTag(action: (tag: string) => void): import("kaplay").KEventController;
|
|
45
|
+
onUntag(action: (tag: string) => void): import("kaplay").KEventController;
|
|
46
|
+
exists(): boolean;
|
|
47
|
+
isAncestorOf(obj: import("kaplay").GameObj): boolean;
|
|
48
|
+
transform: import("kaplay").Mat4;
|
|
49
|
+
hidden: boolean;
|
|
50
|
+
paused: boolean;
|
|
51
|
+
id: import("kaplay").GameObjID | null;
|
|
52
|
+
canvas: import("kaplay").FrameBuffer | null;
|
|
53
|
+
onKeyDown: KAPLAYCtx["onKeyDown"];
|
|
54
|
+
onKeyPress: KAPLAYCtx["onKeyPress"];
|
|
55
|
+
onKeyPressRepeat: KAPLAYCtx["onKeyPressRepeat"];
|
|
56
|
+
onKeyRelease: KAPLAYCtx["onKeyRelease"];
|
|
57
|
+
onCharInput: KAPLAYCtx["onCharInput"];
|
|
58
|
+
onMouseDown: KAPLAYCtx["onMouseDown"];
|
|
59
|
+
onMousePress: KAPLAYCtx["onMousePress"];
|
|
60
|
+
onMouseRelease: KAPLAYCtx["onMouseRelease"];
|
|
61
|
+
onMouseMove: KAPLAYCtx["onMouseMove"];
|
|
62
|
+
onTouchStart: KAPLAYCtx["onTouchStart"];
|
|
63
|
+
onTouchMove: KAPLAYCtx["onTouchMove"];
|
|
64
|
+
onTouchEnd: KAPLAYCtx["onTouchEnd"];
|
|
65
|
+
onScroll: KAPLAYCtx["onScroll"];
|
|
66
|
+
onGamepadButtonDown: KAPLAYCtx["onGamepadButtonDown"];
|
|
67
|
+
onGamepadButtonPress: KAPLAYCtx["onGamepadButtonPress"];
|
|
68
|
+
onGamepadButtonRelease: KAPLAYCtx["onGamepadButtonRelease"];
|
|
69
|
+
onGamepadStick: KAPLAYCtx["onGamepadStick"];
|
|
70
|
+
onButtonDown: KAPLAYCtx["onButtonDown"];
|
|
71
|
+
onButtonPress: KAPLAYCtx["onButtonPress"];
|
|
72
|
+
onButtonRelease: KAPLAYCtx["onButtonRelease"];
|
|
73
|
+
radius?: number | [number, number, number, number] | undefined;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
renderArea: () => import("kaplay").Rect;
|
|
77
|
+
pos: Vec2;
|
|
78
|
+
move: {
|
|
79
|
+
(xVel: number, yVel: number): void;
|
|
80
|
+
(vel: Vec2): void;
|
|
81
|
+
};
|
|
82
|
+
moveBy: {
|
|
83
|
+
(dx: number, dy: number): void;
|
|
84
|
+
(d: Vec2): void;
|
|
85
|
+
};
|
|
86
|
+
moveTo: {
|
|
87
|
+
(dest: Vec2, speed?: number): void;
|
|
88
|
+
(x: number, y: number, speed?: number): void;
|
|
89
|
+
};
|
|
90
|
+
screenPos: (newPos?: Vec2) => Vec2 | null;
|
|
91
|
+
worldPos: (newPos?: Vec2) => Vec2 | null;
|
|
92
|
+
toScreen: (this: import("kaplay").GameObj<import("kaplay").PosComp | import("kaplay").FixedComp>, p: Vec2) => Vec2;
|
|
93
|
+
toWorld: (this: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
94
|
+
fromScreen: (this: import("kaplay").GameObj<import("kaplay").PosComp | import("kaplay").FixedComp>, p: Vec2) => Vec2;
|
|
95
|
+
fromWorld: (this: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
96
|
+
toOther: (this: import("kaplay").GameObj<import("kaplay").PosComp>, other: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
97
|
+
fromOther: (this: import("kaplay").GameObj<import("kaplay").PosComp>, other: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
98
|
+
area: {
|
|
99
|
+
shape: import("kaplay").Shape | null;
|
|
100
|
+
scale: Vec2;
|
|
101
|
+
offset: Vec2;
|
|
102
|
+
cursor: import("kaplay").Cursor | null;
|
|
103
|
+
};
|
|
104
|
+
collisionIgnore: import("kaplay").Tag[];
|
|
105
|
+
isClicked: () => boolean;
|
|
106
|
+
isHovering: () => boolean;
|
|
107
|
+
checkCollision: (other: import("kaplay").GameObj<import("kaplay").AreaComp>) => import("kaplay").Collision | null;
|
|
108
|
+
getCollisions: () => import("kaplay").Collision[];
|
|
109
|
+
isColliding: (o: import("kaplay").GameObj<import("kaplay").AreaComp>) => boolean;
|
|
110
|
+
isOverlapping: (o: import("kaplay").GameObj<import("kaplay").AreaComp>) => boolean;
|
|
111
|
+
onClick: (f: () => void, btn?: import("kaplay").MouseButton) => import("kaplay").KEventController;
|
|
112
|
+
onHover: (action: () => void) => import("kaplay").KEventController;
|
|
113
|
+
onHoverUpdate: (action: () => void) => import("kaplay").KEventController;
|
|
114
|
+
onHoverEnd: (action: () => void) => import("kaplay").KEventController;
|
|
115
|
+
onCollide: {
|
|
116
|
+
(tag: import("kaplay").Tag, f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => void): import("kaplay").KEventController;
|
|
117
|
+
(f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => void): import("kaplay").KEventController;
|
|
118
|
+
};
|
|
119
|
+
onCollideUpdate: {
|
|
120
|
+
(tag: import("kaplay").Tag, f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => import("kaplay").KEventController): import("kaplay").KEventController;
|
|
121
|
+
(f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => void): import("kaplay").KEventController;
|
|
122
|
+
};
|
|
123
|
+
onCollideEnd: {
|
|
124
|
+
(tag: import("kaplay").Tag, f: (obj: import("kaplay").GameObj) => void): import("kaplay").KEventController;
|
|
125
|
+
(f: (obj: import("kaplay").GameObj) => void): void;
|
|
126
|
+
};
|
|
127
|
+
hasPoint: (p: Vec2) => boolean;
|
|
128
|
+
resolveCollision: (obj: import("kaplay").GameObj) => void;
|
|
129
|
+
localArea: () => import("kaplay").Shape;
|
|
130
|
+
worldArea: () => import("kaplay").Polygon;
|
|
131
|
+
screenArea: () => import("kaplay").Polygon;
|
|
132
|
+
scale: Vec2;
|
|
133
|
+
scaleTo: {
|
|
134
|
+
(s: number): void;
|
|
135
|
+
(s: Vec2): void;
|
|
136
|
+
(sx: number, sy: number): void;
|
|
137
|
+
};
|
|
138
|
+
scaleBy: {
|
|
139
|
+
(s: number): void;
|
|
140
|
+
(s: Vec2): void;
|
|
141
|
+
(sx: number, sy: number): void;
|
|
142
|
+
};
|
|
143
|
+
color: Color;
|
|
144
|
+
anchor: import("kaplay").Anchor | Vec2;
|
|
145
|
+
};
|
|
146
|
+
declare module 'kaplay' {
|
|
147
|
+
interface KAPLAYCtx {
|
|
148
|
+
addButton: AddButton;
|
|
149
|
+
getTheme: GetTheme;
|
|
150
|
+
setTheme: SetTheme;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
type AddButton = (text?: string, opt?: ButtonOpt & {
|
|
154
|
+
pos?: Vec2;
|
|
155
|
+
onClick?: () => void;
|
|
156
|
+
color?: string | Color;
|
|
157
|
+
hoverColor?: string | Color;
|
|
158
|
+
pressedColor?: string | Color;
|
|
159
|
+
textColor?: string | Color;
|
|
160
|
+
}) => ReturnType<typeof createButton>;
|
|
161
|
+
type GetTheme = () => Theme;
|
|
162
|
+
type SetTheme = (theme: DeepPartial<Theme>) => void;
|
|
4
163
|
/** Recursively partial version of a type. */
|
|
5
164
|
type DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K]; };
|
|
165
|
+
/** Theme config. */
|
|
6
166
|
interface Theme {
|
|
7
167
|
palette: {
|
|
8
|
-
primary: Color;
|
|
9
|
-
secondary: Color;
|
|
10
|
-
background: Color;
|
|
11
|
-
surface: Color;
|
|
12
|
-
text: Color;
|
|
13
|
-
textSecondary: Color;
|
|
14
|
-
hover: Color;
|
|
15
|
-
pressed: Color;
|
|
16
|
-
disabled: Color;
|
|
17
|
-
error: Color;
|
|
168
|
+
primary: string | Color;
|
|
169
|
+
secondary: string | Color;
|
|
170
|
+
background: string | Color;
|
|
171
|
+
surface: string | Color;
|
|
172
|
+
text: string | Color;
|
|
173
|
+
textSecondary: string | Color;
|
|
174
|
+
hover: string | Color;
|
|
175
|
+
pressed: string | Color;
|
|
176
|
+
disabled: string | Color;
|
|
177
|
+
error: string | Color;
|
|
18
178
|
};
|
|
19
179
|
typography: {
|
|
20
180
|
fontFamily: string;
|
|
@@ -40,70 +200,29 @@ interface Theme {
|
|
|
40
200
|
borderRadius: number;
|
|
41
201
|
};
|
|
42
202
|
tooltip: {
|
|
43
|
-
background: Color;
|
|
44
|
-
textColor: Color;
|
|
203
|
+
background: string | Color;
|
|
204
|
+
textColor: string | Color;
|
|
45
205
|
delay: number;
|
|
46
206
|
};
|
|
47
207
|
};
|
|
48
208
|
}
|
|
49
|
-
/**
|
|
50
|
-
interface
|
|
209
|
+
/** Button options. */
|
|
210
|
+
interface ButtonOpt {
|
|
51
211
|
width?: number;
|
|
52
212
|
height?: number;
|
|
53
213
|
size?: number;
|
|
54
214
|
font?: string;
|
|
55
|
-
fill?: Color;
|
|
56
|
-
textColor?: Color;
|
|
215
|
+
fill?: string | Color;
|
|
216
|
+
textColor?: string | Color;
|
|
57
217
|
radius?: number;
|
|
58
|
-
hoverFill?: Color;
|
|
59
|
-
pressedFill?: Color;
|
|
60
|
-
}
|
|
61
|
-
/** The `button` component. */
|
|
62
|
-
interface ButtonComp extends Comp {
|
|
63
|
-
id: 'button';
|
|
64
|
-
text: string;
|
|
65
|
-
width: number;
|
|
66
|
-
height: number;
|
|
67
|
-
renderArea(): Rect;
|
|
68
|
-
setStyle(opt: Partial<ButtonCompOpt>): void;
|
|
69
|
-
}
|
|
70
|
-
export declare function createButtonComponent(k: KAPLAYCtx, theme: Theme, text: string, opt: ButtonCompOpt): ButtonComp;
|
|
71
|
-
export declare function createButtonObject(k: KAPLAYCtx, theme: Theme, text: string, opt: ButtonCompOpt & {
|
|
72
|
-
pos?: Vec2;
|
|
73
|
-
onClick?: () => void;
|
|
74
|
-
color?: Color;
|
|
75
|
-
hoverColor?: Color;
|
|
76
|
-
pressedColor?: Color;
|
|
77
|
-
textColor?: Color;
|
|
78
|
-
}): GameObj;
|
|
79
|
-
declare module 'kaplay' {
|
|
80
|
-
interface KAPLAYCtx {
|
|
81
|
-
button: (text?: string, opt?: ButtonCompOpt) => ButtonComp;
|
|
82
|
-
addButton: (text?: string, opt?: ButtonCompOpt & {
|
|
83
|
-
pos?: Vec2;
|
|
84
|
-
onClick?: () => void;
|
|
85
|
-
color?: Color;
|
|
86
|
-
hoverColor?: Color;
|
|
87
|
-
pressedColor?: Color;
|
|
88
|
-
textColor?: Color;
|
|
89
|
-
}) => GameObj;
|
|
90
|
-
setTheme: (theme: DeepPartial<Theme>) => void;
|
|
91
|
-
getTheme: () => Theme;
|
|
92
|
-
}
|
|
218
|
+
hoverFill?: string | Color;
|
|
219
|
+
pressedFill?: string | Color;
|
|
93
220
|
}
|
|
94
221
|
/** KAPLAY UI plugin. */
|
|
95
222
|
export declare function uiPlugin(k: KAPLAYCtx, theme?: DeepPartial<Theme>): {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
onClick?: () => void;
|
|
100
|
-
color?: Color;
|
|
101
|
-
hoverColor?: Color;
|
|
102
|
-
pressedColor?: Color;
|
|
103
|
-
textColor?: Color;
|
|
104
|
-
}) => GameObj;
|
|
105
|
-
setTheme: (next: DeepPartial<Theme>) => void;
|
|
106
|
-
getTheme: () => Theme;
|
|
223
|
+
addButton: AddButton;
|
|
224
|
+
setTheme: SetTheme;
|
|
225
|
+
getTheme: GetTheme;
|
|
107
226
|
};
|
|
108
|
-
export
|
|
227
|
+
export {};
|
|
109
228
|
//# sourceMappingURL=plugin.d.cts.map
|
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/button.ts","../src/types.ts","../src/plugin.ts"],"mappings":";iBAKgB,aACd,GAAG,WACH,OAAO,OACP,cACA,KAAK;EACH,MAAM;EACN;EACA,iBAAiB;EACjB,sBAAsB;EACtB,wBAAwB;EACxB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAmDuj0M,GAAA,wBAAA,mCAAA,YAAG,sCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA34hJ,sBAAA,KAAA,IAAA,sBAAA,SAAA,uBAAC,sCAAA;KAA8K,IAAA,sBAAA,SAAA,uBAAC,sCAAA;;;KAAsN,sBAAA,KAAA,IAAA,sBAAA,SAAA,uBAAC,+BAAA,oCAAA;KAAuM,IAAA,sBAAA,SAAA,uBAAC,sCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;YC7D3wzD;IACR,WAAW;IACX,UAAU;IACV,UAAU;;;KAIF,aACV,eACA,MAAM;EACJ,MAAM;EACN;EACA,iBAAiB;EACjB,sBAAsB;EACtB,wBAAwB;EACxB,qBAAqB;MAEpB,kBAAkB;KAEX,iBAAiB;KAEjB,YAAY,OAAO,YAAY;;KAG/B,YAAY,QACrB,WAAW,KAAK,EAAE,oBAAoB,YAAY,EAAE,MAAM,EAAE;;UAI9C;EACf;IACE,kBAAkB;IAClB,oBAAoB;IACpB,qBAAqB;IACrB,kBAAkB;IAClB,eAAe;IACf,wBAAwB;IACxB,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;;EAElB;IACE;IACA;IACA;IACA;;EAEF;IACE;;EAEF;EACA;IACE;MACE;MACA;MACA;MACA;MACA;MACA;;IAEF;MACE;MACA;;IAEF;MACE,qBAAqB;MACrB,oBAAoB;MACpB;;;;;UAMW;EACf;EACA;EACA;EACA;EACA,gBAAgB;EAChB,qBAAqB;EACrB;EACA,qBAAqB;EACrB,uBAAuB;;;wBC3ET,SAAS,GAAG,WAAW,QAAO,YAAY"}
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,20 +1,180 @@
|
|
|
1
|
-
import { Color
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Color, KAPLAYCtx, Vec2 } from "kaplay";
|
|
2
|
+
declare function createButton(k: KAPLAYCtx, theme: Theme, text: string, opt: ButtonOpt & {
|
|
3
|
+
pos?: Vec2;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
color?: string | Color;
|
|
6
|
+
hoverColor?: string | Color;
|
|
7
|
+
pressedColor?: string | Color;
|
|
8
|
+
textColor?: string | Color;
|
|
9
|
+
}): {
|
|
10
|
+
label: import("kaplay").GameObj<import("kaplay").ColorComp | import("kaplay").AnchorComp | import("kaplay").TextComp>;
|
|
11
|
+
add<T>(comps?: import("kaplay").CompList<T> | import("kaplay").GameObj<T>): import("kaplay").GameObj<T>;
|
|
12
|
+
readd<T>(obj: import("kaplay").GameObj<T>): import("kaplay").GameObj<T>;
|
|
13
|
+
remove(obj: import("kaplay").GameObj): void;
|
|
14
|
+
removeAll(tag: import("kaplay").Tag): void;
|
|
15
|
+
removeAll(): void;
|
|
16
|
+
get(tag: import("kaplay").Tag | import("kaplay").Tag[], opts?: import("kaplay").GetOpt): import("kaplay").GameObj[];
|
|
17
|
+
query(opt: import("kaplay").QueryOpt): import("kaplay").GameObj[];
|
|
18
|
+
parent: import("kaplay").GameObj | null;
|
|
19
|
+
children: import("kaplay").GameObj[];
|
|
20
|
+
tags: string[];
|
|
21
|
+
fixedUpdate(): void;
|
|
22
|
+
update(): void;
|
|
23
|
+
draw(): void;
|
|
24
|
+
drawInspect: () => void;
|
|
25
|
+
clearEvents: () => void;
|
|
26
|
+
use(comp: import("kaplay").Comp | import("kaplay").Tag): void;
|
|
27
|
+
unuse(comp: import("kaplay").Tag): void;
|
|
28
|
+
has(compId: string | string[], op?: "and" | "or"): boolean;
|
|
29
|
+
tag(tag: import("kaplay").Tag | import("kaplay").Tag[]): void;
|
|
30
|
+
untag(tag: import("kaplay").Tag | import("kaplay").Tag[]): void;
|
|
31
|
+
is(tag: import("kaplay").Tag | import("kaplay").Tag[], op?: "and" | "or"): boolean;
|
|
32
|
+
on(event: import("kaplay").GameObjEventNames | (string & {}), action: (...args: any) => void): import("kaplay").KEventController;
|
|
33
|
+
trigger(event: string, ...args: any): void;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
c(id: string): import("kaplay").Comp | null;
|
|
36
|
+
inspect(): import("kaplay").GameObjInspect;
|
|
37
|
+
onAdd(action: () => void): import("kaplay").KEventController;
|
|
38
|
+
onUpdate(action: () => void): import("kaplay").KEventController;
|
|
39
|
+
onFixedUpdate(action: () => void): import("kaplay").KEventController;
|
|
40
|
+
onDraw(action: () => void): import("kaplay").KEventController;
|
|
41
|
+
onDestroy(action: () => void): import("kaplay").KEventController;
|
|
42
|
+
onUse(action: (id: string) => void): import("kaplay").KEventController;
|
|
43
|
+
onUnuse(action: (id: string) => void): import("kaplay").KEventController;
|
|
44
|
+
onTag(action: (tag: string) => void): import("kaplay").KEventController;
|
|
45
|
+
onUntag(action: (tag: string) => void): import("kaplay").KEventController;
|
|
46
|
+
exists(): boolean;
|
|
47
|
+
isAncestorOf(obj: import("kaplay").GameObj): boolean;
|
|
48
|
+
transform: import("kaplay").Mat4;
|
|
49
|
+
hidden: boolean;
|
|
50
|
+
paused: boolean;
|
|
51
|
+
id: import("kaplay").GameObjID | null;
|
|
52
|
+
canvas: import("kaplay").FrameBuffer | null;
|
|
53
|
+
onKeyDown: KAPLAYCtx["onKeyDown"];
|
|
54
|
+
onKeyPress: KAPLAYCtx["onKeyPress"];
|
|
55
|
+
onKeyPressRepeat: KAPLAYCtx["onKeyPressRepeat"];
|
|
56
|
+
onKeyRelease: KAPLAYCtx["onKeyRelease"];
|
|
57
|
+
onCharInput: KAPLAYCtx["onCharInput"];
|
|
58
|
+
onMouseDown: KAPLAYCtx["onMouseDown"];
|
|
59
|
+
onMousePress: KAPLAYCtx["onMousePress"];
|
|
60
|
+
onMouseRelease: KAPLAYCtx["onMouseRelease"];
|
|
61
|
+
onMouseMove: KAPLAYCtx["onMouseMove"];
|
|
62
|
+
onTouchStart: KAPLAYCtx["onTouchStart"];
|
|
63
|
+
onTouchMove: KAPLAYCtx["onTouchMove"];
|
|
64
|
+
onTouchEnd: KAPLAYCtx["onTouchEnd"];
|
|
65
|
+
onScroll: KAPLAYCtx["onScroll"];
|
|
66
|
+
onGamepadButtonDown: KAPLAYCtx["onGamepadButtonDown"];
|
|
67
|
+
onGamepadButtonPress: KAPLAYCtx["onGamepadButtonPress"];
|
|
68
|
+
onGamepadButtonRelease: KAPLAYCtx["onGamepadButtonRelease"];
|
|
69
|
+
onGamepadStick: KAPLAYCtx["onGamepadStick"];
|
|
70
|
+
onButtonDown: KAPLAYCtx["onButtonDown"];
|
|
71
|
+
onButtonPress: KAPLAYCtx["onButtonPress"];
|
|
72
|
+
onButtonRelease: KAPLAYCtx["onButtonRelease"];
|
|
73
|
+
radius?: number | [number, number, number, number] | undefined;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
renderArea: () => import("kaplay").Rect;
|
|
77
|
+
pos: Vec2;
|
|
78
|
+
move: {
|
|
79
|
+
(xVel: number, yVel: number): void;
|
|
80
|
+
(vel: Vec2): void;
|
|
81
|
+
};
|
|
82
|
+
moveBy: {
|
|
83
|
+
(dx: number, dy: number): void;
|
|
84
|
+
(d: Vec2): void;
|
|
85
|
+
};
|
|
86
|
+
moveTo: {
|
|
87
|
+
(dest: Vec2, speed?: number): void;
|
|
88
|
+
(x: number, y: number, speed?: number): void;
|
|
89
|
+
};
|
|
90
|
+
screenPos: (newPos?: Vec2) => Vec2 | null;
|
|
91
|
+
worldPos: (newPos?: Vec2) => Vec2 | null;
|
|
92
|
+
toScreen: (this: import("kaplay").GameObj<import("kaplay").PosComp | import("kaplay").FixedComp>, p: Vec2) => Vec2;
|
|
93
|
+
toWorld: (this: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
94
|
+
fromScreen: (this: import("kaplay").GameObj<import("kaplay").PosComp | import("kaplay").FixedComp>, p: Vec2) => Vec2;
|
|
95
|
+
fromWorld: (this: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
96
|
+
toOther: (this: import("kaplay").GameObj<import("kaplay").PosComp>, other: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
97
|
+
fromOther: (this: import("kaplay").GameObj<import("kaplay").PosComp>, other: import("kaplay").GameObj<import("kaplay").PosComp>, p: Vec2) => Vec2;
|
|
98
|
+
area: {
|
|
99
|
+
shape: import("kaplay").Shape | null;
|
|
100
|
+
scale: Vec2;
|
|
101
|
+
offset: Vec2;
|
|
102
|
+
cursor: import("kaplay").Cursor | null;
|
|
103
|
+
};
|
|
104
|
+
collisionIgnore: import("kaplay").Tag[];
|
|
105
|
+
isClicked: () => boolean;
|
|
106
|
+
isHovering: () => boolean;
|
|
107
|
+
checkCollision: (other: import("kaplay").GameObj<import("kaplay").AreaComp>) => import("kaplay").Collision | null;
|
|
108
|
+
getCollisions: () => import("kaplay").Collision[];
|
|
109
|
+
isColliding: (o: import("kaplay").GameObj<import("kaplay").AreaComp>) => boolean;
|
|
110
|
+
isOverlapping: (o: import("kaplay").GameObj<import("kaplay").AreaComp>) => boolean;
|
|
111
|
+
onClick: (f: () => void, btn?: import("kaplay").MouseButton) => import("kaplay").KEventController;
|
|
112
|
+
onHover: (action: () => void) => import("kaplay").KEventController;
|
|
113
|
+
onHoverUpdate: (action: () => void) => import("kaplay").KEventController;
|
|
114
|
+
onHoverEnd: (action: () => void) => import("kaplay").KEventController;
|
|
115
|
+
onCollide: {
|
|
116
|
+
(tag: import("kaplay").Tag, f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => void): import("kaplay").KEventController;
|
|
117
|
+
(f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => void): import("kaplay").KEventController;
|
|
118
|
+
};
|
|
119
|
+
onCollideUpdate: {
|
|
120
|
+
(tag: import("kaplay").Tag, f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => import("kaplay").KEventController): import("kaplay").KEventController;
|
|
121
|
+
(f: (obj: import("kaplay").GameObj, col?: import("kaplay").Collision) => void): import("kaplay").KEventController;
|
|
122
|
+
};
|
|
123
|
+
onCollideEnd: {
|
|
124
|
+
(tag: import("kaplay").Tag, f: (obj: import("kaplay").GameObj) => void): import("kaplay").KEventController;
|
|
125
|
+
(f: (obj: import("kaplay").GameObj) => void): void;
|
|
126
|
+
};
|
|
127
|
+
hasPoint: (p: Vec2) => boolean;
|
|
128
|
+
resolveCollision: (obj: import("kaplay").GameObj) => void;
|
|
129
|
+
localArea: () => import("kaplay").Shape;
|
|
130
|
+
worldArea: () => import("kaplay").Polygon;
|
|
131
|
+
screenArea: () => import("kaplay").Polygon;
|
|
132
|
+
scale: Vec2;
|
|
133
|
+
scaleTo: {
|
|
134
|
+
(s: number): void;
|
|
135
|
+
(s: Vec2): void;
|
|
136
|
+
(sx: number, sy: number): void;
|
|
137
|
+
};
|
|
138
|
+
scaleBy: {
|
|
139
|
+
(s: number): void;
|
|
140
|
+
(s: Vec2): void;
|
|
141
|
+
(sx: number, sy: number): void;
|
|
142
|
+
};
|
|
143
|
+
color: Color;
|
|
144
|
+
anchor: import("kaplay").Anchor | Vec2;
|
|
145
|
+
};
|
|
146
|
+
declare module 'kaplay' {
|
|
147
|
+
interface KAPLAYCtx {
|
|
148
|
+
addButton: AddButton;
|
|
149
|
+
getTheme: GetTheme;
|
|
150
|
+
setTheme: SetTheme;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
type AddButton = (text?: string, opt?: ButtonOpt & {
|
|
154
|
+
pos?: Vec2;
|
|
155
|
+
onClick?: () => void;
|
|
156
|
+
color?: string | Color;
|
|
157
|
+
hoverColor?: string | Color;
|
|
158
|
+
pressedColor?: string | Color;
|
|
159
|
+
textColor?: string | Color;
|
|
160
|
+
}) => ReturnType<typeof createButton>;
|
|
161
|
+
type GetTheme = () => Theme;
|
|
162
|
+
type SetTheme = (theme: DeepPartial<Theme>) => void;
|
|
4
163
|
/** Recursively partial version of a type. */
|
|
5
164
|
type DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K]; };
|
|
165
|
+
/** Theme config. */
|
|
6
166
|
interface Theme {
|
|
7
167
|
palette: {
|
|
8
|
-
primary: Color;
|
|
9
|
-
secondary: Color;
|
|
10
|
-
background: Color;
|
|
11
|
-
surface: Color;
|
|
12
|
-
text: Color;
|
|
13
|
-
textSecondary: Color;
|
|
14
|
-
hover: Color;
|
|
15
|
-
pressed: Color;
|
|
16
|
-
disabled: Color;
|
|
17
|
-
error: Color;
|
|
168
|
+
primary: string | Color;
|
|
169
|
+
secondary: string | Color;
|
|
170
|
+
background: string | Color;
|
|
171
|
+
surface: string | Color;
|
|
172
|
+
text: string | Color;
|
|
173
|
+
textSecondary: string | Color;
|
|
174
|
+
hover: string | Color;
|
|
175
|
+
pressed: string | Color;
|
|
176
|
+
disabled: string | Color;
|
|
177
|
+
error: string | Color;
|
|
18
178
|
};
|
|
19
179
|
typography: {
|
|
20
180
|
fontFamily: string;
|
|
@@ -40,70 +200,29 @@ interface Theme {
|
|
|
40
200
|
borderRadius: number;
|
|
41
201
|
};
|
|
42
202
|
tooltip: {
|
|
43
|
-
background: Color;
|
|
44
|
-
textColor: Color;
|
|
203
|
+
background: string | Color;
|
|
204
|
+
textColor: string | Color;
|
|
45
205
|
delay: number;
|
|
46
206
|
};
|
|
47
207
|
};
|
|
48
208
|
}
|
|
49
|
-
/**
|
|
50
|
-
interface
|
|
209
|
+
/** Button options. */
|
|
210
|
+
interface ButtonOpt {
|
|
51
211
|
width?: number;
|
|
52
212
|
height?: number;
|
|
53
213
|
size?: number;
|
|
54
214
|
font?: string;
|
|
55
|
-
fill?: Color;
|
|
56
|
-
textColor?: Color;
|
|
215
|
+
fill?: string | Color;
|
|
216
|
+
textColor?: string | Color;
|
|
57
217
|
radius?: number;
|
|
58
|
-
hoverFill?: Color;
|
|
59
|
-
pressedFill?: Color;
|
|
60
|
-
}
|
|
61
|
-
/** The `button` component. */
|
|
62
|
-
interface ButtonComp extends Comp {
|
|
63
|
-
id: 'button';
|
|
64
|
-
text: string;
|
|
65
|
-
width: number;
|
|
66
|
-
height: number;
|
|
67
|
-
renderArea(): Rect;
|
|
68
|
-
setStyle(opt: Partial<ButtonCompOpt>): void;
|
|
69
|
-
}
|
|
70
|
-
export declare function createButtonComponent(k: KAPLAYCtx, theme: Theme, text: string, opt: ButtonCompOpt): ButtonComp;
|
|
71
|
-
export declare function createButtonObject(k: KAPLAYCtx, theme: Theme, text: string, opt: ButtonCompOpt & {
|
|
72
|
-
pos?: Vec2;
|
|
73
|
-
onClick?: () => void;
|
|
74
|
-
color?: Color;
|
|
75
|
-
hoverColor?: Color;
|
|
76
|
-
pressedColor?: Color;
|
|
77
|
-
textColor?: Color;
|
|
78
|
-
}): GameObj;
|
|
79
|
-
declare module 'kaplay' {
|
|
80
|
-
interface KAPLAYCtx {
|
|
81
|
-
button: (text?: string, opt?: ButtonCompOpt) => ButtonComp;
|
|
82
|
-
addButton: (text?: string, opt?: ButtonCompOpt & {
|
|
83
|
-
pos?: Vec2;
|
|
84
|
-
onClick?: () => void;
|
|
85
|
-
color?: Color;
|
|
86
|
-
hoverColor?: Color;
|
|
87
|
-
pressedColor?: Color;
|
|
88
|
-
textColor?: Color;
|
|
89
|
-
}) => GameObj;
|
|
90
|
-
setTheme: (theme: DeepPartial<Theme>) => void;
|
|
91
|
-
getTheme: () => Theme;
|
|
92
|
-
}
|
|
218
|
+
hoverFill?: string | Color;
|
|
219
|
+
pressedFill?: string | Color;
|
|
93
220
|
}
|
|
94
221
|
/** KAPLAY UI plugin. */
|
|
95
222
|
export declare function uiPlugin(k: KAPLAYCtx, theme?: DeepPartial<Theme>): {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
onClick?: () => void;
|
|
100
|
-
color?: Color;
|
|
101
|
-
hoverColor?: Color;
|
|
102
|
-
pressedColor?: Color;
|
|
103
|
-
textColor?: Color;
|
|
104
|
-
}) => GameObj;
|
|
105
|
-
setTheme: (next: DeepPartial<Theme>) => void;
|
|
106
|
-
getTheme: () => Theme;
|
|
223
|
+
addButton: AddButton;
|
|
224
|
+
setTheme: SetTheme;
|
|
225
|
+
getTheme: GetTheme;
|
|
107
226
|
};
|
|
108
|
-
export
|
|
227
|
+
export {};
|
|
109
228
|
//# sourceMappingURL=plugin.d.mts.map
|
package/dist/plugin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/button.ts","../src/types.ts","../src/plugin.ts"],"mappings":";iBAKgB,aACd,GAAG,WACH,OAAO,OACP,cACA,KAAK;EACH,MAAM;EACN;EACA,iBAAiB;EACjB,sBAAsB;EACtB,wBAAwB;EACxB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAmDuj0M,GAAA,wBAAA,mCAAA,YAAG,sCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA34hJ,sBAAA,KAAA,IAAA,sBAAA,SAAA,uBAAC,sCAAA;KAA8K,IAAA,sBAAA,SAAA,uBAAC,sCAAA;;;KAAsN,sBAAA,KAAA,IAAA,sBAAA,SAAA,uBAAC,+BAAA,oCAAA;KAAuM,IAAA,sBAAA,SAAA,uBAAC,sCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;YC7D3wzD;IACR,WAAW;IACX,UAAU;IACV,UAAU;;;KAIF,aACV,eACA,MAAM;EACJ,MAAM;EACN;EACA,iBAAiB;EACjB,sBAAsB;EACtB,wBAAwB;EACxB,qBAAqB;MAEpB,kBAAkB;KAEX,iBAAiB;KAEjB,YAAY,OAAO,YAAY;;KAG/B,YAAY,QACrB,WAAW,KAAK,EAAE,oBAAoB,YAAY,EAAE,MAAM,EAAE;;UAI9C;EACf;IACE,kBAAkB;IAClB,oBAAoB;IACpB,qBAAqB;IACrB,kBAAkB;IAClB,eAAe;IACf,wBAAwB;IACxB,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;;EAElB;IACE;IACA;IACA;IACA;;EAEF;IACE;;EAEF;EACA;IACE;MACE;MACA;MACA;MACA;MACA;MACA;;IAEF;MACE;MACA;;IAEF;MACE,qBAAqB;MACrB,oBAAoB;MACpB;;;;;UAMW;EACf;EACA;EACA;EACA;EACA,gBAAgB;EAChB,qBAAqB;EACrB;EACA,qBAAqB;EACrB,uBAAuB;;;wBC3ET,SAAS,GAAG,WAAW,QAAO,YAAY"}
|