@rpgjs/server 5.0.0-alpha.8 → 5.0.0-beta.1
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/dist/Gui/DialogGui.d.ts +5 -0
- package/dist/Gui/GameoverGui.d.ts +23 -0
- package/dist/Gui/Gui.d.ts +6 -0
- package/dist/Gui/MenuGui.d.ts +22 -3
- package/dist/Gui/NotificationGui.d.ts +1 -2
- package/dist/Gui/SaveLoadGui.d.ts +13 -0
- package/dist/Gui/ShopGui.d.ts +28 -3
- package/dist/Gui/TitleGui.d.ts +23 -0
- package/dist/Gui/index.d.ts +10 -1
- package/dist/Player/BattleManager.d.ts +44 -32
- package/dist/Player/ClassManager.d.ts +24 -4
- package/dist/Player/ComponentManager.d.ts +100 -7
- package/dist/Player/Components.d.ts +345 -0
- package/dist/Player/EffectManager.d.ts +50 -4
- package/dist/Player/ElementManager.d.ts +77 -4
- package/dist/Player/GoldManager.d.ts +1 -1
- package/dist/Player/GuiManager.d.ts +233 -5
- package/dist/Player/ItemFixture.d.ts +1 -1
- package/dist/Player/ItemManager.d.ts +431 -4
- package/dist/Player/MoveManager.d.ts +301 -34
- package/dist/Player/ParameterManager.d.ts +364 -28
- package/dist/Player/Player.d.ts +558 -14
- package/dist/Player/SkillManager.d.ts +187 -13
- package/dist/Player/StateManager.d.ts +75 -4
- package/dist/Player/VariableManager.d.ts +62 -4
- package/dist/RpgServer.d.ts +278 -63
- package/dist/RpgServerEngine.d.ts +2 -1
- package/dist/decorators/event.d.ts +46 -0
- package/dist/decorators/map.d.ts +299 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +17920 -29866
- package/dist/index.js.map +1 -1
- package/dist/logs/log.d.ts +2 -3
- package/dist/module-CaCW1SDh.js +11018 -0
- package/dist/module-CaCW1SDh.js.map +1 -0
- package/dist/module.d.ts +43 -1
- package/dist/node/connection.d.ts +51 -0
- package/dist/node/index.d.ts +5 -0
- package/dist/node/index.js +551 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/map.d.ts +16 -0
- package/dist/node/room.d.ts +21 -0
- package/dist/node/transport.d.ts +28 -0
- package/dist/node/types.d.ts +47 -0
- package/dist/presets/index.d.ts +0 -9
- package/dist/rooms/BaseRoom.d.ts +132 -0
- package/dist/rooms/lobby.d.ts +10 -2
- package/dist/rooms/map.d.ts +1359 -32
- package/dist/services/save.d.ts +43 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/localStorage.d.ts +23 -0
- package/package.json +25 -10
- package/src/Gui/DialogGui.ts +19 -4
- package/src/Gui/GameoverGui.ts +39 -0
- package/src/Gui/Gui.ts +23 -1
- package/src/Gui/MenuGui.ts +155 -6
- package/src/Gui/NotificationGui.ts +1 -2
- package/src/Gui/SaveLoadGui.ts +60 -0
- package/src/Gui/ShopGui.ts +146 -16
- package/src/Gui/TitleGui.ts +39 -0
- package/src/Gui/index.ts +15 -2
- package/src/Player/BattleManager.ts +39 -56
- package/src/Player/ClassManager.ts +82 -74
- package/src/Player/ComponentManager.ts +401 -37
- package/src/Player/Components.ts +380 -0
- package/src/Player/EffectManager.ts +50 -96
- package/src/Player/ElementManager.ts +74 -152
- package/src/Player/GuiManager.ts +284 -149
- package/src/Player/ItemManager.ts +747 -341
- package/src/Player/MoveManager.ts +1532 -750
- package/src/Player/ParameterManager.ts +636 -106
- package/src/Player/Player.ts +1273 -79
- package/src/Player/SkillManager.ts +558 -197
- package/src/Player/StateManager.ts +131 -258
- package/src/Player/VariableManager.ts +85 -157
- package/src/RpgServer.ts +293 -62
- package/src/decorators/event.ts +61 -0
- package/src/decorators/map.ts +343 -0
- package/src/index.ts +11 -1
- package/src/logs/log.ts +10 -3
- package/src/module.ts +126 -3
- package/src/node/connection.ts +254 -0
- package/src/node/index.ts +22 -0
- package/src/node/map.ts +328 -0
- package/src/node/room.ts +63 -0
- package/src/node/transport.ts +532 -0
- package/src/node/types.ts +61 -0
- package/src/presets/index.ts +1 -10
- package/src/rooms/BaseRoom.ts +232 -0
- package/src/rooms/lobby.ts +25 -7
- package/src/rooms/map.ts +2682 -206
- package/src/services/save.ts +147 -0
- package/src/storage/index.ts +1 -0
- package/src/storage/localStorage.ts +76 -0
- package/tests/battle.spec.ts +375 -0
- package/tests/change-map.spec.ts +72 -0
- package/tests/class.spec.ts +274 -0
- package/tests/custom-websocket.spec.ts +127 -0
- package/tests/effect.spec.ts +219 -0
- package/tests/element.spec.ts +221 -0
- package/tests/event.spec.ts +80 -0
- package/tests/gold.spec.ts +99 -0
- package/tests/item.spec.ts +609 -0
- package/tests/module.spec.ts +38 -0
- package/tests/move.spec.ts +601 -0
- package/tests/node-transport.spec.ts +223 -0
- package/tests/player-param.spec.ts +45 -0
- package/tests/prediction-reconciliation.spec.ts +182 -0
- package/tests/random-move.spec.ts +65 -0
- package/tests/skill.spec.ts +658 -0
- package/tests/state.spec.ts +467 -0
- package/tests/variable.spec.ts +185 -0
- package/tests/world-maps.spec.ts +896 -0
- package/vite.config.ts +36 -3
- package/dist/Player/Event.d.ts +0 -0
- package/src/Player/Event.ts +0 -0
package/src/Player/GuiManager.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { RpgPlayer } from "./Player";
|
|
2
|
-
import { Gui, DialogGui, MenuGui, ShopGui, NotificationGui } from "../Gui";
|
|
2
|
+
import { Gui, DialogGui, MenuGui, ShopGui, NotificationGui, SaveLoadGui, GameoverGui } from "../Gui";
|
|
3
3
|
import { DialogOptions, Choice } from "../Gui/DialogGui";
|
|
4
|
-
import {
|
|
4
|
+
import { SaveLoadOptions, SaveSlot } from "../Gui/SaveLoadGui";
|
|
5
|
+
import { MenuGuiOptions } from "../Gui/MenuGui";
|
|
6
|
+
import { GameoverGuiOptions, GameoverGuiSelection } from "../Gui/GameoverGui";
|
|
7
|
+
import { Constructor, PlayerCtor } from "@rpgjs/common";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* GUI Manager Mixin
|
|
8
|
-
*
|
|
11
|
+
*
|
|
9
12
|
* Provides graphical user interface management capabilities to any class. This mixin handles
|
|
10
13
|
* dialog boxes, menus, notifications, shops, and custom GUI components. It manages the
|
|
11
14
|
* complete GUI system including opening, closing, and data passing between client and server.
|
|
12
|
-
*
|
|
15
|
+
*
|
|
13
16
|
* @param Base - The base class to extend with GUI management
|
|
14
17
|
* @returns Extended class with GUI management methods
|
|
15
|
-
*
|
|
18
|
+
*
|
|
16
19
|
* @example
|
|
17
20
|
* ```ts
|
|
18
21
|
* class MyPlayer extends WithGuiManager(BasePlayer) {
|
|
@@ -21,129 +24,25 @@ import { PlayerCtor } from "@rpgjs/common";
|
|
|
21
24
|
* // GUI system is automatically initialized
|
|
22
25
|
* }
|
|
23
26
|
* }
|
|
24
|
-
*
|
|
27
|
+
*
|
|
25
28
|
* const player = new MyPlayer();
|
|
26
29
|
* await player.showText('Hello World!');
|
|
27
30
|
* player.callMainMenu();
|
|
28
31
|
* ```
|
|
29
32
|
*/
|
|
30
|
-
export function WithGuiManager<TBase extends PlayerCtor>(
|
|
31
|
-
|
|
33
|
+
export function WithGuiManager<TBase extends PlayerCtor>(
|
|
34
|
+
Base: TBase
|
|
35
|
+
): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> &
|
|
36
|
+
IGuiManager {
|
|
37
|
+
class GuiManagerMixin extends Base {
|
|
32
38
|
_gui: { [id: string]: Gui } = {};
|
|
33
39
|
|
|
34
|
-
/**
|
|
35
|
-
* Show a text. This is a graphical interface already built. Opens the GUI named `rpg-dialog`
|
|
36
|
-
*
|
|
37
|
-
* ```ts
|
|
38
|
-
* player.showText('Hello World')
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* The method returns a promise. It is resolved when the dialog box is closed.
|
|
42
|
-
*
|
|
43
|
-
* ```ts
|
|
44
|
-
* await player.showText('Hello World')
|
|
45
|
-
* // dialog box is closed, then ...
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* **Option: position**
|
|
49
|
-
*
|
|
50
|
-
* You can define how the dialog box is displayed:
|
|
51
|
-
* - top
|
|
52
|
-
* - middle
|
|
53
|
-
* - bottom
|
|
54
|
-
*
|
|
55
|
-
* (bottom by default)
|
|
56
|
-
*
|
|
57
|
-
* ```ts
|
|
58
|
-
* player.showText('Hello World', {
|
|
59
|
-
* position: 'top'
|
|
60
|
-
* })
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* **Option: fullWidth**
|
|
64
|
-
*
|
|
65
|
-
* `boolean` (true by default)
|
|
66
|
-
*
|
|
67
|
-
* Indicate that the dialog box will take the full width of the screen.
|
|
68
|
-
*
|
|
69
|
-
* ```ts
|
|
70
|
-
* player.showText('Hello World', {
|
|
71
|
-
* fullWidth: true
|
|
72
|
-
* })
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* **Option: autoClose**
|
|
76
|
-
*
|
|
77
|
-
* `boolean` (false by default)
|
|
78
|
-
*
|
|
79
|
-
* If false, the user will have to press Enter to close the dialog box.
|
|
80
|
-
*
|
|
81
|
-
* ```ts
|
|
82
|
-
* player.showText('Hello World', {
|
|
83
|
-
* autoClose: true
|
|
84
|
-
* })
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* **Option: typewriterEffect**
|
|
88
|
-
*
|
|
89
|
-
* `boolean` (true by default)
|
|
90
|
-
*
|
|
91
|
-
* Performs a typewriter effect
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* player.showText('Hello World', {
|
|
95
|
-
* typewriterEffect: false
|
|
96
|
-
* })
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* **Option: talkWith**
|
|
100
|
-
*
|
|
101
|
-
* `RpgPlayer` (nothing by default)
|
|
102
|
-
*
|
|
103
|
-
* If you specify the event or another player, the other player will stop his or her movement and look in the player's direction.
|
|
104
|
-
*
|
|
105
|
-
* ```ts
|
|
106
|
-
* // Code in an event
|
|
107
|
-
* player.showText('Hello World', {
|
|
108
|
-
* talkWith: this
|
|
109
|
-
* })
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* @title Show Text
|
|
113
|
-
* @method player.showText(text,options)
|
|
114
|
-
* @param {string} text
|
|
115
|
-
* @param {object} [options] the different options, see usage below
|
|
116
|
-
* @returns {Promise}
|
|
117
|
-
* @memberof GuiManager
|
|
118
|
-
*/
|
|
119
40
|
showText(msg: string, options: DialogOptions = {}): Promise<any> {
|
|
120
41
|
const gui = new DialogGui(<any>this);
|
|
121
42
|
this._gui[gui.id] = gui;
|
|
122
43
|
return gui.openDialog(msg, options);
|
|
123
44
|
}
|
|
124
45
|
|
|
125
|
-
/**
|
|
126
|
-
* Shows a dialog box with a choice. Opens the GUI named `rpg-dialog`
|
|
127
|
-
*
|
|
128
|
-
* ```ts
|
|
129
|
-
* const choice = await player.showChoices('What color do you prefer?', [
|
|
130
|
-
* { text: 'Black', value: 'black' },
|
|
131
|
-
* { text: 'Rather the blue', value: 'blue' },
|
|
132
|
-
* { text: 'I don\'t have a preference!', value: 'none' }
|
|
133
|
-
* ])
|
|
134
|
-
*
|
|
135
|
-
* // If the player selects the first
|
|
136
|
-
* console.log(choice) // { text: 'Black', value: 'black' }
|
|
137
|
-
* ```
|
|
138
|
-
*
|
|
139
|
-
* @title Show Choices
|
|
140
|
-
* @method player.showChoices(text,choices)
|
|
141
|
-
* @param {string} text
|
|
142
|
-
* @param {Array<{ text: string, value: any }>} choices
|
|
143
|
-
* @param {object} [options] Same options as the openDialog method
|
|
144
|
-
* @returns {Promise<Choice | null>}
|
|
145
|
-
* @memberof GuiManager
|
|
146
|
-
*/
|
|
147
46
|
showChoices(
|
|
148
47
|
msg: string,
|
|
149
48
|
choices: Choice[],
|
|
@@ -158,44 +57,44 @@ export function WithGuiManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
158
57
|
});
|
|
159
58
|
}
|
|
160
59
|
|
|
161
|
-
/**
|
|
162
|
-
* Displays a notification . Opens the GUI named `rpg-notification`
|
|
163
|
-
*
|
|
164
|
-
* @title Displays a notification
|
|
165
|
-
* @method player.showNotification()
|
|
166
|
-
* @param {string} message - The message to display in the notification
|
|
167
|
-
* @param {object} options - An object containing options for the notification
|
|
168
|
-
* @param {number} options.time - The time to display the notification for (in ms). Default: 2000ms
|
|
169
|
-
* @param {string} options.icon - The icon to display in the notification. Put the identifier of the spritesheet (defined on the client side)
|
|
170
|
-
* @param {string} options.sound - The sound to play when the notification is shown. Set the sound ID (defined on the client side)
|
|
171
|
-
* @returns {void}
|
|
172
|
-
* @memberof GuiManager
|
|
173
|
-
*/
|
|
174
60
|
showNotification(
|
|
175
61
|
message: string,
|
|
176
|
-
options: { time?: number; icon?: string; sound?: string } = {}
|
|
62
|
+
options: { time?: number; icon?: string; sound?: string; type?: "info" | "warn" | "error" } = {}
|
|
177
63
|
): Promise<any> {
|
|
178
|
-
|
|
179
|
-
this._gui[gui.id] = gui;
|
|
180
|
-
const data = {
|
|
64
|
+
this.emit('notification', {
|
|
181
65
|
message,
|
|
182
66
|
...options,
|
|
183
|
-
};
|
|
184
|
-
return
|
|
67
|
+
});
|
|
68
|
+
return Promise.resolve(true);
|
|
185
69
|
}
|
|
186
70
|
|
|
187
|
-
|
|
188
|
-
* Calls main menu. Opens the GUI named `rpg-main-menu`
|
|
189
|
-
*
|
|
190
|
-
* @title Call Main Menu
|
|
191
|
-
* @method player.callMainMenu()
|
|
192
|
-
* @returns {void}
|
|
193
|
-
* @memberof GuiManager
|
|
194
|
-
*/
|
|
195
|
-
callMainMenu() {
|
|
71
|
+
callMainMenu(options: MenuGuiOptions = {}) {
|
|
196
72
|
const gui = new MenuGui(<any>this);
|
|
197
73
|
this._gui[gui.id] = gui;
|
|
198
|
-
return gui.open();
|
|
74
|
+
return gui.open(options);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
callGameover(options: GameoverGuiOptions = {}): Promise<GameoverGuiSelection | null> {
|
|
78
|
+
const gui = new GameoverGui(<any>this);
|
|
79
|
+
this._gui[gui.id] = gui;
|
|
80
|
+
return gui.open(options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
showSaveLoad(slots: SaveSlot[] = [], options: SaveLoadOptions = {}): Promise<number | null> {
|
|
84
|
+
const gui = new SaveLoadGui(<any>this);
|
|
85
|
+
this._gui[gui.id] = gui;
|
|
86
|
+
return gui.open(slots, options).then((index) => {
|
|
87
|
+
if (typeof index !== 'number') return null;
|
|
88
|
+
return index;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
showSave(slots: SaveSlot[] = [], options: SaveLoadOptions = {}): Promise<number | null> {
|
|
93
|
+
return this.showSaveLoad(slots, { ...options, mode: 'save' });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
showLoad(slots: SaveSlot[] = [], options: SaveLoadOptions = {}): Promise<number | null> {
|
|
97
|
+
return this.showSaveLoad(slots, { ...options, mode: 'load' });
|
|
199
98
|
}
|
|
200
99
|
|
|
201
100
|
/**
|
|
@@ -206,7 +105,13 @@ export function WithGuiManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
206
105
|
* @returns {void}
|
|
207
106
|
* @memberof GuiManager
|
|
208
107
|
*/
|
|
209
|
-
callShop(items: any[]
|
|
108
|
+
callShop(items: any[] | {
|
|
109
|
+
items: any[]
|
|
110
|
+
sell?: Record<string, number> | Array<{ id: string; multiplier: number }>
|
|
111
|
+
sellMultiplier?: number
|
|
112
|
+
message?: string
|
|
113
|
+
face?: { id: string; expression?: string }
|
|
114
|
+
}) {
|
|
210
115
|
const gui = new ShopGui(<any>this);
|
|
211
116
|
this._gui[gui.id] = gui;
|
|
212
117
|
return gui.open(items);
|
|
@@ -253,6 +158,10 @@ export function WithGuiManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
253
158
|
return gui;
|
|
254
159
|
}
|
|
255
160
|
|
|
161
|
+
getGui(guiId: string) {
|
|
162
|
+
return this._gui[guiId];
|
|
163
|
+
}
|
|
164
|
+
|
|
256
165
|
/**
|
|
257
166
|
* Closes the GUI and removes it from memory
|
|
258
167
|
*
|
|
@@ -330,11 +239,237 @@ export function WithGuiManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
330
239
|
const _players = players || this;
|
|
331
240
|
this._attachedGui(_players as RpgPlayer[], false);
|
|
332
241
|
}
|
|
333
|
-
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return GuiManagerMixin as unknown as any;
|
|
334
245
|
}
|
|
335
246
|
|
|
336
247
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
248
|
+
* Interface for GUI management capabilities
|
|
249
|
+
* Defines the methods that will be available on the player
|
|
339
250
|
*/
|
|
340
|
-
export
|
|
251
|
+
export interface IGuiManager {
|
|
252
|
+
/**
|
|
253
|
+
* Show a text. This is a graphical interface already built. Opens the GUI named `rpg-dialog`
|
|
254
|
+
*
|
|
255
|
+
* ```ts
|
|
256
|
+
* player.showText('Hello World')
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* The method returns a promise. It is resolved when the dialog box is closed.
|
|
260
|
+
*
|
|
261
|
+
* ```ts
|
|
262
|
+
* await player.showText('Hello World')
|
|
263
|
+
* // dialog box is closed, then ...
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* **Option: position**
|
|
267
|
+
*
|
|
268
|
+
* You can define how the dialog box is displayed:
|
|
269
|
+
* - top
|
|
270
|
+
* - middle
|
|
271
|
+
* - bottom
|
|
272
|
+
*
|
|
273
|
+
* (bottom by default)
|
|
274
|
+
*
|
|
275
|
+
* ```ts
|
|
276
|
+
* player.showText('Hello World', {
|
|
277
|
+
* position: 'top'
|
|
278
|
+
* })
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* **Option: fullWidth**
|
|
282
|
+
*
|
|
283
|
+
* `boolean` (true by default)
|
|
284
|
+
*
|
|
285
|
+
* Indicate that the dialog box will take the full width of the screen.
|
|
286
|
+
*
|
|
287
|
+
* ```ts
|
|
288
|
+
* player.showText('Hello World', {
|
|
289
|
+
* fullWidth: true
|
|
290
|
+
* })
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* **Option: autoClose**
|
|
294
|
+
*
|
|
295
|
+
* `boolean` (false by default)
|
|
296
|
+
*
|
|
297
|
+
* If false, the user will have to press Enter to close the dialog box.
|
|
298
|
+
*
|
|
299
|
+
* ```ts
|
|
300
|
+
* player.showText('Hello World', {
|
|
301
|
+
* autoClose: true
|
|
302
|
+
* })
|
|
303
|
+
* ```
|
|
304
|
+
*
|
|
305
|
+
* **Option: typewriterEffect**
|
|
306
|
+
*
|
|
307
|
+
* `boolean` (true by default)
|
|
308
|
+
*
|
|
309
|
+
* Performs a typewriter effect
|
|
310
|
+
*
|
|
311
|
+
* ```ts
|
|
312
|
+
* player.showText('Hello World', {
|
|
313
|
+
* typewriterEffect: false
|
|
314
|
+
* })
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* **Option: talkWith**
|
|
318
|
+
*
|
|
319
|
+
* `RpgPlayer` (nothing by default)
|
|
320
|
+
*
|
|
321
|
+
* If you specify the event or another player, the other player will stop his or her movement and look in the player's direction.
|
|
322
|
+
*
|
|
323
|
+
* ```ts
|
|
324
|
+
* // Code in an event
|
|
325
|
+
* player.showText('Hello World', {
|
|
326
|
+
* talkWith: this
|
|
327
|
+
* })
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @title Show Text
|
|
331
|
+
* @method player.showText(text,options)
|
|
332
|
+
* @param {string} text
|
|
333
|
+
* @param {object} [options] the different options, see usage below
|
|
334
|
+
* @returns {Promise}
|
|
335
|
+
* @memberof GuiManager
|
|
336
|
+
*/
|
|
337
|
+
showText(msg: string, options?: DialogOptions): Promise<any>;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Shows a dialog box with a choice. Opens the GUI named `rpg-dialog`
|
|
341
|
+
*
|
|
342
|
+
* ```ts
|
|
343
|
+
* const choice = await player.showChoices('What color do you prefer?', [
|
|
344
|
+
* { text: 'Black', value: 'black' },
|
|
345
|
+
* { text: 'Rather the blue', value: 'blue' },
|
|
346
|
+
* { text: 'I don\'t have a preference!', value: 'none' }
|
|
347
|
+
* ])
|
|
348
|
+
*
|
|
349
|
+
* // If the player selects the first
|
|
350
|
+
* console.log(choice) // { text: 'Black', value: 'black' }
|
|
351
|
+
* ```
|
|
352
|
+
*
|
|
353
|
+
* @title Show Choices
|
|
354
|
+
* @method player.showChoices(text,choices)
|
|
355
|
+
* @param {string} text
|
|
356
|
+
* @param {Array<{ text: string, value: any }>} choices
|
|
357
|
+
* @param {object} [options] Same options as the openDialog method
|
|
358
|
+
* @returns {Promise<Choice | null>}
|
|
359
|
+
* @memberof GuiManager
|
|
360
|
+
*/
|
|
361
|
+
showChoices(
|
|
362
|
+
msg: string,
|
|
363
|
+
choices: Choice[],
|
|
364
|
+
options?: DialogOptions
|
|
365
|
+
): Promise<Choice | null>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Displays a notification . Opens the GUI named `rpg-notification`
|
|
369
|
+
*
|
|
370
|
+
* @title Displays a notification
|
|
371
|
+
* @method player.showNotification()
|
|
372
|
+
* @param {string} message - The message to display in the notification
|
|
373
|
+
* @param {object} options - An object containing options for the notification
|
|
374
|
+
* @param {number} options.time - The time to display the notification for (in ms). Default: 2000ms
|
|
375
|
+
* @param {string} options.icon - The icon to display in the notification. Put the identifier of the spritesheet (defined on the client side)
|
|
376
|
+
* @param {string} options.sound - The sound to play when the notification is shown. Set the sound ID (defined on the client side)
|
|
377
|
+
* @returns {void}
|
|
378
|
+
* @memberof GuiManager
|
|
379
|
+
*/
|
|
380
|
+
showNotification(
|
|
381
|
+
message: string,
|
|
382
|
+
options?: { time?: number; icon?: string; sound?: string; type?: "info" | "warn" | "error" }
|
|
383
|
+
): Promise<any>;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Display a save/load slots screen. Opens the GUI named `rpg-save`
|
|
387
|
+
*
|
|
388
|
+
* ```ts
|
|
389
|
+
* const index = await player.showSaveLoad(slots, { mode: 'save' })
|
|
390
|
+
* ```
|
|
391
|
+
*
|
|
392
|
+
* @title Show Save/Load
|
|
393
|
+
* @method player.showSaveLoad(slots,options)
|
|
394
|
+
* @param {Array<object>} slots
|
|
395
|
+
* @param {object} [options]
|
|
396
|
+
* @returns {Promise<number | null>}
|
|
397
|
+
* @memberof GuiManager
|
|
398
|
+
*/
|
|
399
|
+
showSaveLoad(slots?: SaveSlot[], options?: SaveLoadOptions): Promise<number | null>;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Display a save slots screen. Opens the GUI named `rpg-save`
|
|
403
|
+
*
|
|
404
|
+
* ```ts
|
|
405
|
+
* const index = await player.showSave(slots)
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* @title Show Save
|
|
409
|
+
* @method player.showSave(slots,options)
|
|
410
|
+
* @param {Array<object>} slots
|
|
411
|
+
* @param {object} [options]
|
|
412
|
+
* @returns {Promise<number | null>}
|
|
413
|
+
* @memberof GuiManager
|
|
414
|
+
*/
|
|
415
|
+
showSave(slots?: SaveSlot[], options?: SaveLoadOptions): Promise<number | null>;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Display a load slots screen. Opens the GUI named `rpg-save`
|
|
419
|
+
*
|
|
420
|
+
* ```ts
|
|
421
|
+
* const index = await player.showLoad(slots)
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* @title Show Load
|
|
425
|
+
* @method player.showLoad(slots,options)
|
|
426
|
+
* @param {Array<object>} slots
|
|
427
|
+
* @param {object} [options]
|
|
428
|
+
* @returns {Promise<number | null>}
|
|
429
|
+
* @memberof GuiManager
|
|
430
|
+
*/
|
|
431
|
+
showLoad(slots?: SaveSlot[], options?: SaveLoadOptions): Promise<number | null>;
|
|
432
|
+
/**
|
|
433
|
+
* Calls main menu. Opens the GUI named `rpg-main-menu`
|
|
434
|
+
*
|
|
435
|
+
* @title Call Main Menu
|
|
436
|
+
* @method player.callMainMenu(options)
|
|
437
|
+
* @param {object} [options]
|
|
438
|
+
* @returns {void}
|
|
439
|
+
* @memberof GuiManager
|
|
440
|
+
*/
|
|
441
|
+
callMainMenu(options?: MenuGuiOptions): void;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Calls game over menu. Opens the GUI named `rpg-gameover`
|
|
445
|
+
*
|
|
446
|
+
* ```ts
|
|
447
|
+
* const selection = await player.callGameover()
|
|
448
|
+
* if (selection?.id === 'title') {
|
|
449
|
+
* await player.gui('rpg-title-screen').open()
|
|
450
|
+
* }
|
|
451
|
+
* if (selection?.id === 'load') {
|
|
452
|
+
* await player.showLoad()
|
|
453
|
+
* }
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* @title Call Game Over Menu
|
|
457
|
+
* @method player.callGameover(options)
|
|
458
|
+
* @param {object} [options]
|
|
459
|
+
* @returns {Promise<GameoverGuiSelection | null>}
|
|
460
|
+
* @memberof GuiManager
|
|
461
|
+
*/
|
|
462
|
+
callGameover(options?: GameoverGuiOptions): Promise<GameoverGuiSelection | null>;
|
|
463
|
+
callShop(items: any[] | {
|
|
464
|
+
items: any[]
|
|
465
|
+
sell?: Record<string, number> | Array<{ id: string; multiplier: number }>
|
|
466
|
+
sellMultiplier?: number
|
|
467
|
+
message?: string
|
|
468
|
+
face?: { id: string; expression?: string }
|
|
469
|
+
}): void;
|
|
470
|
+
gui(guiId: string): Gui;
|
|
471
|
+
getGui(guiId: string): Gui;
|
|
472
|
+
removeGui(guiId: string, data?: any): void;
|
|
473
|
+
showAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
|
|
474
|
+
hideAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
|
|
475
|
+
}
|