melonjs 20.12.0 → 20.13.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/README.md +2 -1
- package/build/camera/camera2d.d.ts +2 -0
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/effects/fade_effect.d.ts.map +1 -1
- package/build/geometries/ellipse.d.ts +3 -0
- package/build/geometries/ellipse.d.ts.map +1 -1
- package/build/geometries/line.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts +2 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/index.d.ts +13 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5409 -1500
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts +48 -14
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +1 -1
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXUtils.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXRenderer.d.ts +1 -1
- package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -1
- package/build/loader/loader.d.ts +55 -11
- package/build/loader/loader.d.ts.map +1 -1
- package/build/math/color.d.ts.map +1 -1
- package/build/math/math.d.ts +6 -1
- package/build/math/math.d.ts.map +1 -1
- package/build/math/observableVector2d.d.ts +6 -6
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +8 -8
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/particles/emitter.d.ts +15 -3
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +6 -0
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +22 -5
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +14 -4
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/raycast.d.ts.map +1 -1
- package/build/physics/world.d.ts.map +1 -1
- package/build/renderable/container.d.ts +40 -6
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +4 -2
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +12 -3
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +147 -4
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/text/textmetrics.d.ts +10 -2
- package/build/renderable/text/textmetrics.d.ts.map +1 -1
- package/build/renderable/text/textstyle.d.ts.map +1 -1
- package/build/renderable/ui/panelpaint.d.ts +5 -1
- package/build/renderable/ui/panelpaint.d.ts.map +1 -1
- package/build/renderable/ui/progressbar.d.ts +267 -95
- package/build/renderable/ui/progressbar.d.ts.map +1 -1
- package/build/renderable/ui/uibaseelement.d.ts +436 -50
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
- package/build/renderable/ui/uicheckbox.d.ts +383 -0
- package/build/renderable/ui/uicheckbox.d.ts.map +1 -0
- package/build/renderable/ui/uifocus.d.ts +6 -0
- package/build/renderable/ui/uifocus.d.ts.map +1 -0
- package/build/renderable/ui/uilabel.d.ts +31 -0
- package/build/renderable/ui/uilabel.d.ts.map +1 -0
- package/build/renderable/ui/uipanel.d.ts +589 -116
- package/build/renderable/ui/uipanel.d.ts.map +1 -1
- package/build/renderable/ui/uiskin.d.ts +25 -0
- package/build/renderable/ui/uiskin.d.ts.map +1 -0
- package/build/renderable/ui/uislider.d.ts +518 -0
- package/build/renderable/ui/uislider.d.ts.map +1 -0
- package/build/renderable/ui/uispriteelement.d.ts +161 -85
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- package/build/renderable/ui/uitextbutton.d.ts +369 -63
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/pool.d.ts.map +1 -1
- package/build/system/save.d.ts +2 -1
- package/build/system/save.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +5 -2
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/utils/fetchdata.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +0 -5
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +20 -4
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +26 -3
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/utils/tessellation.d.ts +11 -0
- package/build/video/utils/tessellation.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +3 -6
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +3 -6
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs/SKILL.md +3 -3
- package/skills/melonjs-audio/SKILL.md +7 -5
- package/skills/melonjs-camera-and-drawing/SKILL.md +41 -1
- package/skills/melonjs-effects-and-shaders/SKILL.md +1 -0
- package/skills/melonjs-events/SKILL.md +3 -1
- package/skills/melonjs-getting-started/SKILL.md +1 -2
- package/skills/melonjs-input/SKILL.md +38 -2
- package/skills/melonjs-loading-assets/SKILL.md +53 -12
- package/skills/melonjs-math/SKILL.md +14 -3
- package/skills/melonjs-particles-and-trails/SKILL.md +72 -8
- package/skills/melonjs-physics/SKILL.md +53 -4
- package/skills/melonjs-plugins/SKILL.md +7 -2
- package/skills/melonjs-renderables/SKILL.md +7 -0
- package/skills/melonjs-scenes-and-state/SKILL.md +15 -0
- package/skills/melonjs-sprites-and-animation/SKILL.md +14 -0
- package/skills/melonjs-tilemaps/SKILL.md +96 -2
- package/skills/melonjs-ui-and-text/SKILL.md +560 -23
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import type Camera2d from "../../camera/camera2d.ts";
|
|
2
|
+
import type Renderer from "../../video/renderer.js";
|
|
3
|
+
import type { Paint } from "./panelpaint.ts";
|
|
4
|
+
import type { UIJuiceSettings } from "./uibaseelement.ts";
|
|
5
|
+
import UIBaseElement from "./uibaseelement.ts";
|
|
6
|
+
import type { UILabel } from "./uilabel.ts";
|
|
7
|
+
import type { UISkin } from "./uiskin.ts";
|
|
8
|
+
/**
|
|
9
|
+
* The art of a skinned {@link UICheckbox}: one atlas region per state.
|
|
10
|
+
*
|
|
11
|
+
* Only `on` and `off` are needed. Each region is drawn as a square of
|
|
12
|
+
* {@link UICheckboxSettings#boxSize} pixels (the height of `off` by
|
|
13
|
+
* default). Every region named is looked up when the checkbox is built, so
|
|
14
|
+
* a misspelt name throws there.
|
|
15
|
+
* @category UI
|
|
16
|
+
* @example
|
|
17
|
+
* // two regions: the rest fall back to them
|
|
18
|
+
* const skin = { atlas, on: "green_boxCheckmark", off: "grey_boxCheckmark" };
|
|
19
|
+
*/
|
|
20
|
+
export interface UICheckboxSkin extends UISkin {
|
|
21
|
+
/** the region drawn when checked */
|
|
22
|
+
on: string;
|
|
23
|
+
/** the region drawn when not checked */
|
|
24
|
+
off: string;
|
|
25
|
+
/** the region drawn when checked and under the pointer; `on` if left out */
|
|
26
|
+
hoverOn?: string;
|
|
27
|
+
/**
|
|
28
|
+
* the region drawn when not checked and under the pointer; `off` if left
|
|
29
|
+
* out
|
|
30
|
+
*/
|
|
31
|
+
hoverOff?: string;
|
|
32
|
+
/**
|
|
33
|
+
* the region drawn when checked and disabled; `on` at half opacity if
|
|
34
|
+
* left out
|
|
35
|
+
*/
|
|
36
|
+
disabledOn?: string;
|
|
37
|
+
/**
|
|
38
|
+
* the region drawn when not checked and disabled; `off` at half opacity
|
|
39
|
+
* if left out
|
|
40
|
+
*/
|
|
41
|
+
disabledOff?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The settings {@link UICheckbox} takes. All are optional.
|
|
45
|
+
*
|
|
46
|
+
* The colour settings are for the drawn look and are ignored when a `skin`
|
|
47
|
+
* is given.
|
|
48
|
+
* @category UI
|
|
49
|
+
*/
|
|
50
|
+
export interface UICheckboxSettings extends UIJuiceSettings {
|
|
51
|
+
/**
|
|
52
|
+
* whether it starts checked
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
checked?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* the text next to the box, the same in both states; `labelOn` and
|
|
58
|
+
* `labelOff` replace it for one state each
|
|
59
|
+
*/
|
|
60
|
+
label?: string;
|
|
61
|
+
/** the text while checked; `label` if left out */
|
|
62
|
+
labelOn?: string;
|
|
63
|
+
/** the text while not checked; `label` if left out */
|
|
64
|
+
labelOff?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Called with the new state when the user checks or unchecks it (click,
|
|
67
|
+
* tap, or Enter with the focus). Never called when `checked` is set or
|
|
68
|
+
* `toggle()` is called from code. See {@link UICheckbox#onChange}.
|
|
69
|
+
*/
|
|
70
|
+
onChange?: (checked: boolean, checkbox: UICheckbox) => void;
|
|
71
|
+
/**
|
|
72
|
+
* whether it answers input; a disabled checkbox is drawn faded, or with
|
|
73
|
+
* the skin's `disabledOn` / `disabledOff` regions
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* the side of the box, in pixels; with a skin, the height of its `off`
|
|
79
|
+
* region by default
|
|
80
|
+
* @default 24
|
|
81
|
+
*/
|
|
82
|
+
boxSize?: number;
|
|
83
|
+
/**
|
|
84
|
+
* a radio group name: checkboxes sharing it have one checked at a time,
|
|
85
|
+
* and are drawn round. See {@link UICheckbox#group}.
|
|
86
|
+
*/
|
|
87
|
+
group?: string;
|
|
88
|
+
/**
|
|
89
|
+
* a CSS font family, or the name of a loaded bitmap font
|
|
90
|
+
* @default "sans-serif"
|
|
91
|
+
*/
|
|
92
|
+
font?: string;
|
|
93
|
+
/**
|
|
94
|
+
* the label's text height, in pixels; two thirds of `boxSize`, and at
|
|
95
|
+
* least 12, by default
|
|
96
|
+
*/
|
|
97
|
+
fontSize?: number;
|
|
98
|
+
/**
|
|
99
|
+
* the label's colour
|
|
100
|
+
* @default "#000000"
|
|
101
|
+
*/
|
|
102
|
+
labelFillStyle?: string;
|
|
103
|
+
/**
|
|
104
|
+
* the space between the box and the label, in pixels
|
|
105
|
+
* @default 8
|
|
106
|
+
*/
|
|
107
|
+
labelGap?: number;
|
|
108
|
+
/**
|
|
109
|
+
* the box's fill when not checked (drawn look); also the tick's colour
|
|
110
|
+
* @default "#ffffff"
|
|
111
|
+
*/
|
|
112
|
+
boxColor?: Paint;
|
|
113
|
+
/**
|
|
114
|
+
* the box's fill when not checked and under the pointer (drawn look)
|
|
115
|
+
* @default "#e4eefb"
|
|
116
|
+
*/
|
|
117
|
+
boxHoverColor?: Paint;
|
|
118
|
+
/**
|
|
119
|
+
* the box's fill and outline when checked, and a radio button's dot
|
|
120
|
+
* (drawn look)
|
|
121
|
+
* @default "#2a7de1"
|
|
122
|
+
*/
|
|
123
|
+
checkColor?: Paint;
|
|
124
|
+
/**
|
|
125
|
+
* the box's outline when not checked (drawn look)
|
|
126
|
+
* @default "#3a3a3a"
|
|
127
|
+
*/
|
|
128
|
+
borderColor?: Paint;
|
|
129
|
+
/**
|
|
130
|
+
* the outline's thickness, in pixels (drawn look); `0` for none
|
|
131
|
+
* @default 2
|
|
132
|
+
*/
|
|
133
|
+
borderWidth?: number;
|
|
134
|
+
/**
|
|
135
|
+
* the box's corner radius, in pixels (drawn look); ignored by a radio
|
|
136
|
+
* button, which is round
|
|
137
|
+
* @default 4
|
|
138
|
+
*/
|
|
139
|
+
radius?: number;
|
|
140
|
+
/** draw the box from atlas regions instead of the drawn look */
|
|
141
|
+
skin?: UICheckboxSkin;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A checkbox with a text label, for an on/off option such as music, sound
|
|
145
|
+
* or full screen. Give several the same `group` and they become radio
|
|
146
|
+
* buttons: one choice out of a few, such as a difficulty level.
|
|
147
|
+
*
|
|
148
|
+
* ## Look
|
|
149
|
+
* - Drawn with shapes by default, so it needs no art: a square with a tick,
|
|
150
|
+
* or a circle with a dot for a radio button. The colour settings
|
|
151
|
+
* (`boxColor`, `checkColor`, `borderColor`...) change it.
|
|
152
|
+
* - Skinned: pass a {@link UICheckboxSkin} of atlas regions, one per state
|
|
153
|
+
* (`on`, `off`, and optionally `hoverOn`, `hoverOff`, `disabledOn`,
|
|
154
|
+
* `disabledOff`).
|
|
155
|
+
*
|
|
156
|
+
* ## Label
|
|
157
|
+
* `label` is the text next to the box. `labelOn` and `labelOff` give it a
|
|
158
|
+
* different text in each state ("Music ON" / "Music OFF"). The
|
|
159
|
+
* {@link UICheckbox#labelOn} and {@link UICheckbox#labelOff} properties
|
|
160
|
+
* change the text later, and the widget resizes to fit. It is as wide as the box
|
|
161
|
+
* plus the longer of the two texts, so it does not change size as it
|
|
162
|
+
* toggles. The label is part of the widget: clicking it toggles the box too.
|
|
163
|
+
*
|
|
164
|
+
* ## State and onChange
|
|
165
|
+
* The state is {@link UICheckbox#checked}. `onChange` is called only when
|
|
166
|
+
* the player changes it. Setting `checked`, or calling `toggle()`, from code
|
|
167
|
+
* never calls it: restore saved settings by setting `checked`, without
|
|
168
|
+
* running the code a click would (starting the music twice, saving again).
|
|
169
|
+
*
|
|
170
|
+
* ## Radio groups
|
|
171
|
+
* Checkboxes with the same {@link UICheckbox#group} name have one checked
|
|
172
|
+
* at a time: checking one unchecks the others, and clicking the checked one
|
|
173
|
+
* leaves it checked. A checkbox belongs to its group from the moment it is
|
|
174
|
+
* made until it is destroyed (removing it from the world for good destroys
|
|
175
|
+
* it), so the group holds one choice before it is ever shown, and
|
|
176
|
+
* {@link UICheckbox.checkedIn} answers straight away. A checked one joining
|
|
177
|
+
* a group unchecks the others already there.
|
|
178
|
+
*
|
|
179
|
+
* ## Keyboard and gamepad
|
|
180
|
+
* It can take the focus ({@link UIBaseElement#focus}). With the focus,
|
|
181
|
+
* Enter, Space or the pad's A button toggles it, as a click does, and calls
|
|
182
|
+
* `onChange`.
|
|
183
|
+
*
|
|
184
|
+
* Set `enabled` to `false` to turn it off: it ignores input and is drawn
|
|
185
|
+
* faded, or with the skin's disabled regions.
|
|
186
|
+
* @category UI
|
|
187
|
+
* @example
|
|
188
|
+
* // a settings toggle, drawn, with no assets
|
|
189
|
+
* const subtitles = new UICheckbox(40, 60, {
|
|
190
|
+
* label: "Subtitles",
|
|
191
|
+
* checked: settings.subtitles,
|
|
192
|
+
* onChange: (on) => {
|
|
193
|
+
* settings.subtitles = on;
|
|
194
|
+
* },
|
|
195
|
+
* });
|
|
196
|
+
* panel.addChild(subtitles);
|
|
197
|
+
* @example
|
|
198
|
+
* // a label that follows the state
|
|
199
|
+
* const music = new UICheckbox(40, 100, {
|
|
200
|
+
* labelOn: "Music ON",
|
|
201
|
+
* labelOff: "Music OFF",
|
|
202
|
+
* checked: true,
|
|
203
|
+
* onChange: (on) => {
|
|
204
|
+
* on ? audio.playTrack("theme") : audio.stopTrack();
|
|
205
|
+
* },
|
|
206
|
+
* });
|
|
207
|
+
* panel.addChild(music);
|
|
208
|
+
* @example
|
|
209
|
+
* // a radio group, and reading the choice
|
|
210
|
+
* const levels = new Map();
|
|
211
|
+
* for (const [i, level] of ["easy", "normal", "hard"].entries()) {
|
|
212
|
+
* const radio = new UICheckbox(40, 140 + i * 32, {
|
|
213
|
+
* label: level,
|
|
214
|
+
* group: "difficulty",
|
|
215
|
+
* checked: level === "normal",
|
|
216
|
+
* onChange: () => console.log("picked", level),
|
|
217
|
+
* });
|
|
218
|
+
* levels.set(radio, level);
|
|
219
|
+
* panel.addChild(radio);
|
|
220
|
+
* }
|
|
221
|
+
* // later, e.g. when OK is clicked
|
|
222
|
+
* const difficulty = levels.get(UICheckbox.checkedIn("difficulty"));
|
|
223
|
+
* @example
|
|
224
|
+
* // skinned from an atlas, with a bitmap font
|
|
225
|
+
* const sfx = new UICheckbox(40, 260, {
|
|
226
|
+
* label: "Sound effects",
|
|
227
|
+
* font: "kenpixel",
|
|
228
|
+
* fontSize: 14,
|
|
229
|
+
* skin: { atlas, on: "green_boxCheckmark", off: "grey_boxCheckmark" },
|
|
230
|
+
* });
|
|
231
|
+
* @example
|
|
232
|
+
* // restoring saved settings without calling onChange
|
|
233
|
+
* save.add({ music: true });
|
|
234
|
+
* music.checked = save.music; // the look updates, onChange is not called
|
|
235
|
+
* save.music ? audio.playTrack("theme") : audio.stopTrack(); // applied once
|
|
236
|
+
*/
|
|
237
|
+
export default class UICheckbox extends UIBaseElement {
|
|
238
|
+
/**
|
|
239
|
+
* Called with the new state when the user checks or unchecks it: a
|
|
240
|
+
* click or tap on the box or its label, or Enter, Space or the pad's A
|
|
241
|
+
* with the focus.
|
|
242
|
+
*
|
|
243
|
+
* Never called when {@link UICheckbox#checked} is set, or
|
|
244
|
+
* {@link UICheckbox#toggle} is called, from code. In a radio group only
|
|
245
|
+
* the button the user picked is called; the one unchecked to make room
|
|
246
|
+
* is not. Not called while the checkbox is disabled.
|
|
247
|
+
* @example
|
|
248
|
+
* sfx.onChange = (on) => {
|
|
249
|
+
* settings.sfx = on;
|
|
250
|
+
* };
|
|
251
|
+
*/
|
|
252
|
+
onChange: ((checked: boolean, checkbox: UICheckbox) => void) | undefined;
|
|
253
|
+
/**
|
|
254
|
+
* The radio group this checkbox belongs to, or `undefined` for a plain
|
|
255
|
+
* checkbox.
|
|
256
|
+
*
|
|
257
|
+
* Checkboxes sharing a group have one checked at a time: checking one
|
|
258
|
+
* unchecks the others, and clicking the checked one leaves it checked.
|
|
259
|
+
* A radio button is drawn round, with a dot. A checkbox is in its group
|
|
260
|
+
* from when it is made until it is destroyed. Changing `group`
|
|
261
|
+
* moves it to the new group straight away, and if it is checked it
|
|
262
|
+
* unchecks the others there.
|
|
263
|
+
*/
|
|
264
|
+
get group(): string | undefined;
|
|
265
|
+
set group(value: string | undefined);
|
|
266
|
+
/** the box's fill when not checked, and the tick's colour (drawn look) */
|
|
267
|
+
boxColor: Paint;
|
|
268
|
+
/** the box's fill when not checked and under the pointer (drawn look) */
|
|
269
|
+
boxHoverColor: Paint;
|
|
270
|
+
/**
|
|
271
|
+
* the box's fill and outline when checked, and a radio button's dot
|
|
272
|
+
* (drawn look)
|
|
273
|
+
*/
|
|
274
|
+
checkColor: Paint;
|
|
275
|
+
/** the box's outline when not checked (drawn look) */
|
|
276
|
+
borderColor: Paint;
|
|
277
|
+
/** the outline's thickness, in pixels (drawn look); `0` for none */
|
|
278
|
+
borderWidth: number;
|
|
279
|
+
/** the box's corner radius, in pixels (drawn look; not for a radio button) */
|
|
280
|
+
radius: number;
|
|
281
|
+
/** the side of the box, in pixels */
|
|
282
|
+
readonly boxSize: number;
|
|
283
|
+
/** the space between the box and the label, in pixels */
|
|
284
|
+
readonly labelGap: number;
|
|
285
|
+
/**
|
|
286
|
+
* The text object drawn next to the box, or `undefined` when there is no
|
|
287
|
+
* text. Change the text through {@link UICheckbox#labelOn} and
|
|
288
|
+
* {@link UICheckbox#labelOff}, which also resize the widget.
|
|
289
|
+
*/
|
|
290
|
+
label: UILabel | undefined;
|
|
291
|
+
/** the atlas regions it is drawn from, or `undefined` for the drawn look */
|
|
292
|
+
readonly skin: UICheckboxSkin | undefined;
|
|
293
|
+
/** @ignore */
|
|
294
|
+
private _checked;
|
|
295
|
+
/** @ignore */
|
|
296
|
+
private _labelOn;
|
|
297
|
+
/** @ignore */
|
|
298
|
+
private _labelOff;
|
|
299
|
+
/** how a label is made, for one added after construction */
|
|
300
|
+
private readonly _labelStyle;
|
|
301
|
+
/** @ignore */
|
|
302
|
+
private _group;
|
|
303
|
+
/** how its group holds it */
|
|
304
|
+
private readonly _ref;
|
|
305
|
+
/** @ignore */
|
|
306
|
+
private readonly _painter;
|
|
307
|
+
/** @ignore */
|
|
308
|
+
private readonly _skin;
|
|
309
|
+
/** @ignore */
|
|
310
|
+
private _joined;
|
|
311
|
+
/**
|
|
312
|
+
* @param x - left edge
|
|
313
|
+
* @param y - top edge
|
|
314
|
+
* @param settings - see {@link UICheckboxSettings}
|
|
315
|
+
*/
|
|
316
|
+
constructor(x: number, y: number, settings?: UICheckboxSettings);
|
|
317
|
+
/**
|
|
318
|
+
* Whether it is checked.
|
|
319
|
+
*
|
|
320
|
+
* Setting it updates the look and the label, and does NOT call
|
|
321
|
+
* `onChange`: restoring saved settings this way does not run the code a
|
|
322
|
+
* click would. Checking a radio button unchecks the others in its group,
|
|
323
|
+
* silently too.
|
|
324
|
+
* @example
|
|
325
|
+
* // show the saved state when the menu opens
|
|
326
|
+
* music.checked = save.music;
|
|
327
|
+
*/
|
|
328
|
+
get checked(): boolean;
|
|
329
|
+
set checked(value: boolean);
|
|
330
|
+
/**
|
|
331
|
+
* The text shown while checked. Setting it updates the label and
|
|
332
|
+
* resizes the widget to fit; set both this and
|
|
333
|
+
* {@link UICheckbox#labelOff} to change a single `label`.
|
|
334
|
+
* @example
|
|
335
|
+
* music.labelOn = "Music: on";
|
|
336
|
+
* music.labelOff = "Music: off";
|
|
337
|
+
*/
|
|
338
|
+
get labelOn(): string;
|
|
339
|
+
set labelOn(value: string);
|
|
340
|
+
/**
|
|
341
|
+
* The text shown while not checked. Setting it updates the label and
|
|
342
|
+
* resizes the widget to fit.
|
|
343
|
+
*/
|
|
344
|
+
get labelOff(): string;
|
|
345
|
+
set labelOff(value: string);
|
|
346
|
+
/**
|
|
347
|
+
* Flip it from code, as a click would. Like setting
|
|
348
|
+
* {@link UICheckbox#checked}, this does not call `onChange`. A checked
|
|
349
|
+
* radio button stays checked, as it does when clicked; set `checked` to
|
|
350
|
+
* `false` to uncheck it on purpose.
|
|
351
|
+
* @returns the new state
|
|
352
|
+
*/
|
|
353
|
+
toggle(): boolean;
|
|
354
|
+
/**
|
|
355
|
+
* The checked checkbox of a radio group: the player's choice.
|
|
356
|
+
*
|
|
357
|
+
* It answers as soon as the checkboxes are made, before they are added
|
|
358
|
+
* to the world.
|
|
359
|
+
* @param group - the group name
|
|
360
|
+
* @returns the checked member, or `undefined` when none is checked
|
|
361
|
+
* @example
|
|
362
|
+
* const picked = UICheckbox.checkedIn("difficulty");
|
|
363
|
+
* console.log(picked?.labelOn); // the text of the checked radio button
|
|
364
|
+
*/
|
|
365
|
+
static checkedIn(group: string): UICheckbox | undefined;
|
|
366
|
+
/**
|
|
367
|
+
* Enter, Space or the pad's A let go with the focus here: toggle, and
|
|
368
|
+
* call `onChange`, as a click does.
|
|
369
|
+
*/
|
|
370
|
+
focusRelease(): void;
|
|
371
|
+
/**
|
|
372
|
+
* Draw the box, then the label.
|
|
373
|
+
* @param renderer - the renderer to draw with
|
|
374
|
+
* @param viewport - the camera being drawn through
|
|
375
|
+
*/
|
|
376
|
+
draw(renderer: Renderer, viewport?: Camera2d): void;
|
|
377
|
+
/**
|
|
378
|
+
* Hand back what it borrowed.
|
|
379
|
+
* @ignore
|
|
380
|
+
*/
|
|
381
|
+
onDestroyEvent(): void;
|
|
382
|
+
}
|
|
383
|
+
//# sourceMappingURL=uicheckbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uicheckbox.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/uicheckbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK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OAGG;IACM,cAAc;CAOvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uifocus.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/uifocus.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import BitmapText from "../text/bitmaptext.js";
|
|
2
|
+
import Text from "../text/text.js";
|
|
3
|
+
/**
|
|
4
|
+
* The text a widget draws: a CSS font through {@link Text}, or a loaded
|
|
5
|
+
* bitmap font through {@link BitmapText}.
|
|
6
|
+
* @category UI
|
|
7
|
+
*/
|
|
8
|
+
export type UILabel = Text | BitmapText;
|
|
9
|
+
/** how a widget's label is drawn */
|
|
10
|
+
export interface UILabelOptions {
|
|
11
|
+
/** what it says */
|
|
12
|
+
text: string;
|
|
13
|
+
/**
|
|
14
|
+
* A CSS font family, or the name of a loaded bitmap font. A name with
|
|
15
|
+
* both a font image and font data in the loader is drawn as a bitmap
|
|
16
|
+
* font; anything else is a CSS font.
|
|
17
|
+
*/
|
|
18
|
+
font: string;
|
|
19
|
+
/**
|
|
20
|
+
* the height of the text, in pixels; a bitmap font is scaled to it from
|
|
21
|
+
* its own line height
|
|
22
|
+
*/
|
|
23
|
+
fontSize: number;
|
|
24
|
+
/** the text colour; a bitmap font is tinted with it */
|
|
25
|
+
fillStyle: string;
|
|
26
|
+
/** horizontal alignment about the label's position */
|
|
27
|
+
textAlign: string;
|
|
28
|
+
/** vertical alignment about the label's position */
|
|
29
|
+
textBaseline: string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=uilabel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uilabel.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/uilabel.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG,UAAU,CAAC;AAExC,oCAAoC;AACpC,MAAM,WAAW,cAAc;IAC9B,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;CACrB"}
|