gtac-types 0.0.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/LICENSE +201 -0
- package/README.md +435 -0
- package/bin/gtac.js +35 -0
- package/index.js +6 -0
- package/lib/build.js +186 -0
- package/package.json +51 -0
- package/src/index.d.ts +22 -0
- package/src/runtime/shared/constants.ts +146 -0
- package/src/runtime/shared/utils.ts +26 -0
- package/src/types/client/animations.d.ts +902 -0
- package/src/types/client/events.d.ts +809 -0
- package/src/types/client/functions.d.ts +715 -0
- package/src/types/client/gta.d.ts +724 -0
- package/src/types/client/natives.d.ts +1091 -0
- package/src/types/element.d.ts +853 -0
- package/src/types/event.d.ts +100 -0
- package/src/types/misc.d.ts +256 -0
- package/src/types/resource.d.ts +252 -0
- package/src/types/server/client.d.ts +144 -0
- package/src/types/server/events.d.ts +407 -0
- package/src/types/server/functions.d.ts +890 -0
- package/src/types/vec.d.ts +594 -0
- package/src/types/xml.d.ts +232 -0
- package/templates/meta.xml +4 -0
- package/templates/tsconfig.json +12 -0
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC Client-Side Function Declarations
|
|
3
|
+
*
|
|
4
|
+
* Defines all client-side global functions and interfaces available in the
|
|
5
|
+
* GTA Connected client runtime. Includes player queries, element management,
|
|
6
|
+
* GUI creation, audio playback, font rendering, key binding, command handlers,
|
|
7
|
+
* file I/O, network events, and the `lucasFont` rendering API.
|
|
8
|
+
*
|
|
9
|
+
* All declarations are global — no import required.
|
|
10
|
+
*
|
|
11
|
+
* @module types/client/functions
|
|
12
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Get the local player and print their name
|
|
16
|
+
* console.log("I am: " + localPlayer.name);
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create a GUI window
|
|
20
|
+
* const window = gui.createWindow("My Window");
|
|
21
|
+
* window.visible = true;
|
|
22
|
+
* window.size = new Vec2(400, 300);
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
// ===== Player & Client References =====
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reference to the local player element controlled by this client.
|
|
29
|
+
* This is the player character the user sees and controls.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* localPlayer.health = 100;
|
|
33
|
+
* localPlayer.giveWeapon(22, 50, true);
|
|
34
|
+
*/
|
|
35
|
+
declare var localPlayer: Player;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Reference to this client's own `Client` object.
|
|
39
|
+
* Use this for local client identification in network events.
|
|
40
|
+
*/
|
|
41
|
+
declare var localClient: Client;
|
|
42
|
+
|
|
43
|
+
// ===== Client Queries =====
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns all connected `Client` objects (including `localClient`).
|
|
47
|
+
*
|
|
48
|
+
* @returns Array of all `Client` instances currently connected to the server.
|
|
49
|
+
*/
|
|
50
|
+
declare function getClients(): Client[];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Finds a client by their display name.
|
|
54
|
+
*
|
|
55
|
+
* @param name - The client's display name to search for.
|
|
56
|
+
* @returns The matching `Client`, or `null` if no client has that name.
|
|
57
|
+
*/
|
|
58
|
+
declare function getClient(name: string): Client | null;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Gets the `Client` associated with a specific `Player` element.
|
|
62
|
+
*
|
|
63
|
+
* @param player - The `Player` element to look up.
|
|
64
|
+
* @returns The `Client` controlling that player.
|
|
65
|
+
*/
|
|
66
|
+
declare function getClientFromPlayerElement(player: Player): Client;
|
|
67
|
+
|
|
68
|
+
// ===== Element Counting & Querying =====
|
|
69
|
+
|
|
70
|
+
/** Returns the total number of `Player` elements on the server. */
|
|
71
|
+
declare function getPlayerCount(): number;
|
|
72
|
+
|
|
73
|
+
/** Returns all `Player` elements. @returns Array of `Player`. */
|
|
74
|
+
declare function getPlayers(): Player[];
|
|
75
|
+
|
|
76
|
+
/** Returns all `Vehicle` elements. @returns Array of `Vehicle`. */
|
|
77
|
+
declare function getVehicles(): Vehicle[];
|
|
78
|
+
|
|
79
|
+
/** Returns the total number of `Vehicle` elements. */
|
|
80
|
+
declare function getVehicleCount(): number;
|
|
81
|
+
|
|
82
|
+
/** Returns all `Ped` elements. @returns Array of `Ped`. */
|
|
83
|
+
declare function getPeds(): Ped[];
|
|
84
|
+
|
|
85
|
+
/** Returns the total number of `Ped` elements. */
|
|
86
|
+
declare function getPedCount(): number;
|
|
87
|
+
|
|
88
|
+
/** Returns all `Blip` elements. @returns Array of `Blip`. */
|
|
89
|
+
declare function getBlips(): Blip[];
|
|
90
|
+
|
|
91
|
+
/** Returns the total number of `Blip` elements. */
|
|
92
|
+
declare function getBlipCount(): number;
|
|
93
|
+
|
|
94
|
+
/** Returns all `Pickup` elements. @returns Array of `Pickup`. */
|
|
95
|
+
declare function getPickups(): Pickup[];
|
|
96
|
+
|
|
97
|
+
/** Returns the total number of `Pickup` elements. */
|
|
98
|
+
declare function getPickupCount(): number;
|
|
99
|
+
|
|
100
|
+
/** Returns all `Object` elements. @returns Array of `Object`. */
|
|
101
|
+
declare function getObjects(): Object[];
|
|
102
|
+
|
|
103
|
+
/** Returns the total number of `Object` elements. */
|
|
104
|
+
declare function getObjectCount(): number;
|
|
105
|
+
|
|
106
|
+
/** Returns all `Building` elements. @returns Array of `Building`. */
|
|
107
|
+
declare function getBuildings(): Building[];
|
|
108
|
+
|
|
109
|
+
/** Returns the total number of `Building` elements. */
|
|
110
|
+
declare function getBuildingCount(): number;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Gets all elements matching a given type string.
|
|
114
|
+
*
|
|
115
|
+
* @param type - The element type string (e.g. `"player"`, `"vehicle"`, `"blip"`).
|
|
116
|
+
* @returns Array of `Element` of the specified type.
|
|
117
|
+
*/
|
|
118
|
+
declare function getElementsByType(type: string): Element[];
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Finds an element by its numeric ID.
|
|
122
|
+
*
|
|
123
|
+
* @param id - The element's unique ID.
|
|
124
|
+
* @returns The matching `Element`, or `null` if no element has that ID.
|
|
125
|
+
*/
|
|
126
|
+
declare function getElementFromId(id: number): Element | null;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Finds an element by its display name.
|
|
130
|
+
*
|
|
131
|
+
* @param name - The element name to search for.
|
|
132
|
+
* @returns The matching `Element`, or `null` if no element has that name.
|
|
133
|
+
*/
|
|
134
|
+
declare function getElementFromName(name: string): Element | null;
|
|
135
|
+
|
|
136
|
+
// ===== Element Management =====
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Destroys an element, removing it from the game world.
|
|
140
|
+
* Safely accepts `null` — passing `null` is a no-op, which supports guarded
|
|
141
|
+
* destruction patterns without null checks.
|
|
142
|
+
*
|
|
143
|
+
* @param element - The element to destroy, or `null` (no-op).
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* // Safe destruction pattern
|
|
147
|
+
* destroyElement(myBlip); // works
|
|
148
|
+
* destroyElement(null); // no error, no-op
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // Guarded destruction
|
|
152
|
+
* const blip = gta.createBlip(pos, 0);
|
|
153
|
+
* destroyElement(blip);
|
|
154
|
+
* destroyElement(blip); // safe — blip is already destroyed but no crash
|
|
155
|
+
*/
|
|
156
|
+
declare function destroyElement(element: Element | null): void;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Cancels the current event within an event handler.
|
|
160
|
+
* Equivalent to calling `event.preventDefault()` on a `CancellableEvent`,
|
|
161
|
+
* but usable from any event handler context without explicit event access.
|
|
162
|
+
*/
|
|
163
|
+
declare function cancelEvent(): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Displays a message in the game's chat window or on-screen messaging area.
|
|
167
|
+
*
|
|
168
|
+
* @param text - The message text to display.
|
|
169
|
+
*/
|
|
170
|
+
declare function message(text: string): void;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns the current screen resolution as a 2D vector.
|
|
174
|
+
*
|
|
175
|
+
* @returns A `Vec2` where `x` = screen width in pixels, `y` = screen height in pixels.
|
|
176
|
+
*/
|
|
177
|
+
declare function getScreenResolution(): Vec2;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Converts individual RGBA components into a single packed colour number.
|
|
181
|
+
*
|
|
182
|
+
* @param r - Red component (0–255).
|
|
183
|
+
* @param g - Green component (0–255).
|
|
184
|
+
* @param b - Blue component (0–255).
|
|
185
|
+
* @param a - Alpha component (0–255, where 0 = fully transparent, 255 = fully opaque).
|
|
186
|
+
* @returns A single packed colour number (format: ARGB).
|
|
187
|
+
*/
|
|
188
|
+
declare function toColour(r: number, g: number, b: number, a: number): number;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Constant identifying the current game as GTA Vice City.
|
|
192
|
+
* Used for runtime game-type checks to determine which game is running.
|
|
193
|
+
*/
|
|
194
|
+
declare var GAME_GTA_VC: number;
|
|
195
|
+
|
|
196
|
+
// ===== File I/O =====
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Opens a file and returns an object with `read()` and `close()` methods.
|
|
200
|
+
* Simplified file API for quick reading without the full FileObject workflow.
|
|
201
|
+
*
|
|
202
|
+
* @param path - File path (relative to resource root).
|
|
203
|
+
* @returns An object with `read` and `close` methods, or `null` if the file cannot be opened.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* const file = openFile("config.txt");
|
|
207
|
+
* if (file) {
|
|
208
|
+
* const content = file.read();
|
|
209
|
+
* console.log(content);
|
|
210
|
+
* file.close();
|
|
211
|
+
* }
|
|
212
|
+
*/
|
|
213
|
+
declare function openFile(path: string): {
|
|
214
|
+
read(size?: number): string;
|
|
215
|
+
close(): void;
|
|
216
|
+
} | null;
|
|
217
|
+
|
|
218
|
+
/** Checks if a file exists on disk. @param path - File path. @returns `true` if the file exists. */
|
|
219
|
+
declare function fileExists(path: string): boolean;
|
|
220
|
+
|
|
221
|
+
/** Opens a file for reading/writing. @param path - File path. @returns `FileObject` handle or `null` on failure. */
|
|
222
|
+
declare function fileOpen(path: string): FileObject | null;
|
|
223
|
+
|
|
224
|
+
/** Closes an open file. @param file - The `FileObject` to close. */
|
|
225
|
+
declare function fileClose(file: FileObject): void;
|
|
226
|
+
|
|
227
|
+
/** Reads the entire content of an open file. @param file - The `FileObject` to read from. @returns File content as a string. */
|
|
228
|
+
declare function fileRead(file: FileObject): string;
|
|
229
|
+
|
|
230
|
+
/** Writes data to an open file. @param file - The `FileObject` to write to. @param data - The string data to write. */
|
|
231
|
+
declare function fileWrite(file: FileObject, data: string): void;
|
|
232
|
+
|
|
233
|
+
/** Deletes a file from disk. @param path - File path. @returns `true` on success, `false` on failure. */
|
|
234
|
+
declare function fileDelete(path: string): boolean;
|
|
235
|
+
|
|
236
|
+
/** Gets the size of an open file in bytes. @param file - The `FileObject`. @returns File size in bytes. */
|
|
237
|
+
declare function fileGetSize(file: FileObject): number;
|
|
238
|
+
|
|
239
|
+
/** Gets the absolute path of an open file. @param file - The `FileObject`. @returns The absolute file path string. */
|
|
240
|
+
declare function fileGetPath(file: FileObject): string;
|
|
241
|
+
|
|
242
|
+
// ===== Key Binding =====
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Binds a key to a handler function. The handler receives a `KeyEvent`
|
|
246
|
+
* with information about press/release and the key code.
|
|
247
|
+
*
|
|
248
|
+
* @param key - The key name to bind (e.g. `"F1"`, `"Escape"`, `"T"`).
|
|
249
|
+
* @param handler - Callback invoked with a `KeyEvent` when the key is pressed or released.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* bindKey("F5", function(event) {
|
|
253
|
+
* if (!event.isUp()) {
|
|
254
|
+
* message("F5 pressed!");
|
|
255
|
+
* }
|
|
256
|
+
* });
|
|
257
|
+
*/
|
|
258
|
+
declare function bindKey(
|
|
259
|
+
key: string,
|
|
260
|
+
handler: (keyEvent: KeyEvent) => void
|
|
261
|
+
): void;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Unbinds a previously bound key, removing its handler.
|
|
265
|
+
*
|
|
266
|
+
* @param key - The key name to unbind.
|
|
267
|
+
*/
|
|
268
|
+
declare function unbindKey(key: string): void;
|
|
269
|
+
|
|
270
|
+
// ===== Command Handlers =====
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Registers a handler for a chat command (e.g. `/help`).
|
|
274
|
+
* The handler is invoked when a player types the command in chat.
|
|
275
|
+
*
|
|
276
|
+
* @param name - Command name without the leading slash (e.g. `"help"`).
|
|
277
|
+
* @param handler - Callback receiving the command name and the full text after the command.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* addCommandHandler("heal", function(cmd, text) {
|
|
281
|
+
* localPlayer.health = 100;
|
|
282
|
+
* message("You have been healed!");
|
|
283
|
+
* });
|
|
284
|
+
*/
|
|
285
|
+
declare function addCommandHandler(
|
|
286
|
+
name: string,
|
|
287
|
+
handler: (cmd: string, text: string) => void
|
|
288
|
+
): void;
|
|
289
|
+
|
|
290
|
+
/** Checks whether a command handler exists for the given command name. @param name - Command name. @returns `true` if registered. */
|
|
291
|
+
declare function hasCommandHandler(name: string): boolean;
|
|
292
|
+
|
|
293
|
+
/** Removes a previously registered command handler. @param name - Command name to remove. */
|
|
294
|
+
declare function removeCommandHandler(name: string): void;
|
|
295
|
+
|
|
296
|
+
// ===== Network Events =====
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Registers a handler for a custom network event triggered by the server.
|
|
300
|
+
*
|
|
301
|
+
* @param name - The network event name to listen for.
|
|
302
|
+
* @param handler - Callback receiving any number of arguments from the server.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* addNetworkHandler("onWeatherChange", function(weatherId) {
|
|
306
|
+
* gta.setWeather(weatherId);
|
|
307
|
+
* });
|
|
308
|
+
*/
|
|
309
|
+
declare function addNetworkHandler(
|
|
310
|
+
name: string,
|
|
311
|
+
handler: (...args: any[]) => void
|
|
312
|
+
): void;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Sends a custom network event to the server.
|
|
316
|
+
*
|
|
317
|
+
* @param name - The network event name.
|
|
318
|
+
* @param args - Any number of arguments to send with the event.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* triggerNetworkEvent("onPlayerReady", localPlayer.name);
|
|
322
|
+
*/
|
|
323
|
+
declare function triggerNetworkEvent(name: string, ...args: any[]): void;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Removes a previously registered network event handler.
|
|
327
|
+
*
|
|
328
|
+
* @param name - The network event name.
|
|
329
|
+
* @param handler - The handler function to remove (must be the same function reference).
|
|
330
|
+
*/
|
|
331
|
+
declare function removeNetworkHandler(
|
|
332
|
+
name: string,
|
|
333
|
+
handler: (...args: any[]) => void
|
|
334
|
+
): void;
|
|
335
|
+
|
|
336
|
+
// ===== Chat =====
|
|
337
|
+
|
|
338
|
+
/** Enables or disables the chat input box. @param enabled - `true` to show, `false` to hide. */
|
|
339
|
+
declare function chatInputEnabled(enabled: boolean): void;
|
|
340
|
+
|
|
341
|
+
/** Enables or disables the chat window (message display area). @param enabled - `true` to show, `false` to hide. */
|
|
342
|
+
declare function chatWindowEnabled(enabled: boolean): void;
|
|
343
|
+
|
|
344
|
+
/** Alias for `chatWindowEnabled`. Enables or disables the chat window display. */
|
|
345
|
+
declare function setChatWindowEnabled(enabled: boolean): void;
|
|
346
|
+
|
|
347
|
+
// ===== Screen =====
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Screen dimension information and utility.
|
|
351
|
+
*/
|
|
352
|
+
declare var screen: {
|
|
353
|
+
/** Screen width in pixels. */
|
|
354
|
+
width: number;
|
|
355
|
+
/** Screen height in pixels. */
|
|
356
|
+
height: number;
|
|
357
|
+
/** Returns the current screen dimensions. @returns Object with `width` and `height`. */
|
|
358
|
+
getSize(): { width: number; height: number };
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// ===== Audio =====
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Represents a playable sound instance.
|
|
365
|
+
* Sounds can be created from local files or URLs and support playback control
|
|
366
|
+
* (play, pause, stop, seek, volume, loop).
|
|
367
|
+
*/
|
|
368
|
+
interface Sound {
|
|
369
|
+
/** Starts or resumes playback of the sound. */
|
|
370
|
+
play(): void;
|
|
371
|
+
/** Pauses playback. Can be resumed with `play()`. */
|
|
372
|
+
pause(): void;
|
|
373
|
+
/** Stops playback and resets position to the beginning. */
|
|
374
|
+
stop(): void;
|
|
375
|
+
/** Sets the volume level. @param vol - Volume (0.0 = mute, 1.0 = full). */
|
|
376
|
+
setVolume(vol: number): void;
|
|
377
|
+
/** Gets the current volume level. @returns Volume (0.0 to 1.0). */
|
|
378
|
+
getVolume(): number;
|
|
379
|
+
/** Sets the playback position. @param pos - Position in seconds. */
|
|
380
|
+
setPosition(pos: number): void;
|
|
381
|
+
/** Gets the current playback position. @returns Position in seconds. */
|
|
382
|
+
getPosition(): number;
|
|
383
|
+
/** Enables or disables looping. @param loop - `true` to loop the sound. */
|
|
384
|
+
setLooping(loop: boolean): void;
|
|
385
|
+
/** Checks if the sound is set to loop. @returns `true` if looping. */
|
|
386
|
+
isLooping(): boolean;
|
|
387
|
+
/** Checks if the sound is currently playing. @returns `true` if playing. */
|
|
388
|
+
isPlaying(): boolean;
|
|
389
|
+
/** Stops and permanently destroys the sound instance, freeing memory and resources. */
|
|
390
|
+
destroy(): void;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Audio creation and management API.
|
|
395
|
+
* Use this to create sound instances from local files or remote URLs.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* // Create and play a looping background music
|
|
399
|
+
* const bgm = audio.createSound("music/main_theme.ogg");
|
|
400
|
+
* bgm.setLooping(true);
|
|
401
|
+
* bgm.setVolume(0.5);
|
|
402
|
+
* bgm.play();
|
|
403
|
+
*/
|
|
404
|
+
declare var audio: {
|
|
405
|
+
/**
|
|
406
|
+
* Creates a sound from a local file path.
|
|
407
|
+
* @param path - Path to the audio file (relative to resource root).
|
|
408
|
+
* @returns A new `Sound` instance.
|
|
409
|
+
*/
|
|
410
|
+
createSound(path: string): Sound;
|
|
411
|
+
/**
|
|
412
|
+
* Creates a sound from a remote URL (downloads and plays the file).
|
|
413
|
+
* @param url - The URL of the audio file to download.
|
|
414
|
+
* @returns A new `Sound` instance.
|
|
415
|
+
*/
|
|
416
|
+
createSoundFromURL(url: string): Sound;
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
// ===== Font =====
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Represents a loaded font object for text rendering.
|
|
423
|
+
* Created via `font.create()` with a family name, size, and optional bold/italic styles.
|
|
424
|
+
*/
|
|
425
|
+
interface FontObject {
|
|
426
|
+
/** Font family name (e.g. "Arial", "Tahoma"). */
|
|
427
|
+
name: string;
|
|
428
|
+
/** Font size in points. */
|
|
429
|
+
size: number;
|
|
430
|
+
/** Whether the font weight is bold. */
|
|
431
|
+
bold: boolean;
|
|
432
|
+
/** Whether the font style is italic. */
|
|
433
|
+
italic: boolean;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Font creation API for loading and using fonts.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* const titleFont = font.create("Arial", 24, true, false);
|
|
441
|
+
*/
|
|
442
|
+
declare var font: {
|
|
443
|
+
/**
|
|
444
|
+
* Creates a new font object with the specified properties.
|
|
445
|
+
*
|
|
446
|
+
* @param name - Font family name (e.g. `"Arial"`, `"Tahoma"`).
|
|
447
|
+
* @param size - Font size in points.
|
|
448
|
+
* @param bold - Whether the font should be bold weight (optional, default `false`).
|
|
449
|
+
* @param italic - Whether the font should be italic style (optional, default `false`).
|
|
450
|
+
* @returns A new `FontObject` instance.
|
|
451
|
+
*/
|
|
452
|
+
create(
|
|
453
|
+
name: string,
|
|
454
|
+
size: number,
|
|
455
|
+
bold?: boolean,
|
|
456
|
+
italic?: boolean
|
|
457
|
+
): FontObject;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
// ===== GUI =====
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Base GUI element representing any UI component (label, button, window, etc.).
|
|
464
|
+
* GUI elements are positioned in screen space and have visual properties
|
|
465
|
+
* (colour, opacity, border, size) plus a generic key/value property store.
|
|
466
|
+
*/
|
|
467
|
+
interface GUIElement {
|
|
468
|
+
/** Whether the element is visible on screen. */
|
|
469
|
+
visible: boolean;
|
|
470
|
+
/** Screen position of the element as a `Vec2` (x, y in pixels). */
|
|
471
|
+
position: Vec2;
|
|
472
|
+
/** Dimensions of the element as a `Vec2` (width, height in pixels). */
|
|
473
|
+
size: Vec2;
|
|
474
|
+
/** Text content displayed in the element. */
|
|
475
|
+
text: string;
|
|
476
|
+
/** Font name used for text rendering within this element. */
|
|
477
|
+
font: string;
|
|
478
|
+
/** Text colour as an RGBA tuple (0–255 each component). */
|
|
479
|
+
color: RGBA;
|
|
480
|
+
/** Background fill colour as an RGBA tuple. */
|
|
481
|
+
backgroundColor: RGBA;
|
|
482
|
+
/** Border stroke colour as an RGBA tuple. */
|
|
483
|
+
borderColor: RGBA;
|
|
484
|
+
/** Border stroke width in pixels. */
|
|
485
|
+
borderWidth: number;
|
|
486
|
+
/** Border corner radius in pixels (0 = sharp square corners). */
|
|
487
|
+
borderRadius: number;
|
|
488
|
+
/** Opacity of the element (0.0 = fully transparent, 1.0 = fully opaque). */
|
|
489
|
+
opacity: number;
|
|
490
|
+
/** Z-index controlling draw order (higher values render on top). */
|
|
491
|
+
zIndex: number;
|
|
492
|
+
/**
|
|
493
|
+
* Sets a custom property on the GUI element (generic key/value store).
|
|
494
|
+
* @param name - Property name to set.
|
|
495
|
+
* @param value - Property value (any type).
|
|
496
|
+
*/
|
|
497
|
+
setProperty(name: string, value: any): void;
|
|
498
|
+
/**
|
|
499
|
+
* Gets a custom property value from the GUI element.
|
|
500
|
+
* @param name - Property name to retrieve.
|
|
501
|
+
* @returns The stored value, or `undefined` if not set.
|
|
502
|
+
*/
|
|
503
|
+
getProperty(name: string): any;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* A GUI element capable of rendering HTML content.
|
|
508
|
+
* Extends `GUIElement` with HTML/URL properties and the ability to
|
|
509
|
+
* execute JavaScript within the embedded HTML view.
|
|
510
|
+
*/
|
|
511
|
+
interface GUIHtmlElement extends GUIElement {
|
|
512
|
+
/** Raw HTML content string to display inline. */
|
|
513
|
+
html: string;
|
|
514
|
+
/** URL to load HTML content from. */
|
|
515
|
+
url: string;
|
|
516
|
+
/** Reloads the HTML content from the URL. */
|
|
517
|
+
reload(): void;
|
|
518
|
+
/**
|
|
519
|
+
* Executes JavaScript code within the context of the embedded HTML view/iframe.
|
|
520
|
+
* @param code - JavaScript code string to execute.
|
|
521
|
+
*/
|
|
522
|
+
executeJavaScript(code: string): void;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* A dedicated HTML view container for displaying web content.
|
|
527
|
+
* Similar to `GUIHtmlElement` but intended as a standalone viewport
|
|
528
|
+
* rather than an embedded element.
|
|
529
|
+
*/
|
|
530
|
+
interface GUIHtmlView {
|
|
531
|
+
/** Raw HTML content string to display. */
|
|
532
|
+
html: string;
|
|
533
|
+
/** URL to load HTML content from. */
|
|
534
|
+
url: string;
|
|
535
|
+
/** Reloads the HTML content from the URL. */
|
|
536
|
+
reload(): void;
|
|
537
|
+
/**
|
|
538
|
+
* Executes JavaScript code within the context of the HTML view.
|
|
539
|
+
* @param code - JavaScript code string to execute.
|
|
540
|
+
*/
|
|
541
|
+
executeJavaScript(code: string): void;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* A GUI page grouping multiple elements together.
|
|
546
|
+
* Pages allow organizing elements into logical screens that can be
|
|
547
|
+
* shown or hidden as a single unit.
|
|
548
|
+
*/
|
|
549
|
+
interface GUIPage {
|
|
550
|
+
/** Page title (optional, for display purposes). */
|
|
551
|
+
title: string;
|
|
552
|
+
/** Array of all `GUIElement` instances belonging to this page. */
|
|
553
|
+
elements: GUIElement[];
|
|
554
|
+
/**
|
|
555
|
+
* Adds an element to this page.
|
|
556
|
+
* @param el - The `GUIElement` to add to the page.
|
|
557
|
+
*/
|
|
558
|
+
addElement(el: GUIElement): void;
|
|
559
|
+
/**
|
|
560
|
+
* Removes an element from this page.
|
|
561
|
+
* @param el - The `GUIElement` to remove from the page.
|
|
562
|
+
*/
|
|
563
|
+
removeElement(el: GUIElement): void;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* A resizable, movable GUI window with a title bar and standard window controls.
|
|
568
|
+
* Extends `GUIElement` with window-specific behaviour: resize handles,
|
|
569
|
+
* title bar dragging, close/minimize/maximize buttons.
|
|
570
|
+
*/
|
|
571
|
+
interface GUIWindow extends GUIElement {
|
|
572
|
+
/** Window title displayed in the title bar. */
|
|
573
|
+
title: string;
|
|
574
|
+
/** Whether the user can resize the window by dragging its edges/corners. */
|
|
575
|
+
resizable: boolean;
|
|
576
|
+
/** Whether the user can move the window by dragging its title bar. */
|
|
577
|
+
movable: boolean;
|
|
578
|
+
/** Whether the window displays a close (X) button. */
|
|
579
|
+
closable: boolean;
|
|
580
|
+
/** Whether the window displays a minimize button. */
|
|
581
|
+
minimizable: boolean;
|
|
582
|
+
/** Whether the window displays a maximize button. */
|
|
583
|
+
maximizable: boolean;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* GUI creation and management API.
|
|
588
|
+
* Provides factory methods for creating GUI elements, windows, pages,
|
|
589
|
+
* HTML views, and controlling cursor visibility.
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* // Create a simple label
|
|
593
|
+
* const label = gui.createElement("label");
|
|
594
|
+
* label.text = "Hello World";
|
|
595
|
+
* label.position = new Vec2(100, 100);
|
|
596
|
+
* label.visible = true;
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* // Create and configure a window
|
|
600
|
+
* const win = gui.createWindow("Settings");
|
|
601
|
+
* win.size = new Vec2(400, 300);
|
|
602
|
+
* win.movable = true;
|
|
603
|
+
* win.visible = true;
|
|
604
|
+
*/
|
|
605
|
+
declare var gui: {
|
|
606
|
+
/**
|
|
607
|
+
* Creates a new GUI element of the specified type.
|
|
608
|
+
* @param type - Element type string (e.g. `"label"`, `"button"`, `"edit"`).
|
|
609
|
+
* @returns A new `GUIElement` instance.
|
|
610
|
+
*/
|
|
611
|
+
createElement(type: string): GUIElement;
|
|
612
|
+
/**
|
|
613
|
+
* Creates a GUI element that renders HTML content from a URL.
|
|
614
|
+
* @param url - URL of the HTML content to load.
|
|
615
|
+
* @returns A new `GUIHtmlElement` instance.
|
|
616
|
+
*/
|
|
617
|
+
createHtmlElement(url: string): GUIHtmlElement;
|
|
618
|
+
/**
|
|
619
|
+
* Creates a dedicated HTML viewport from a URL.
|
|
620
|
+
* @param url - URL of the HTML content to load.
|
|
621
|
+
* @returns A new `GUIHtmlView` instance.
|
|
622
|
+
*/
|
|
623
|
+
createHtmlView(url: string): GUIHtmlView;
|
|
624
|
+
/**
|
|
625
|
+
* Creates a new GUI page for grouping elements.
|
|
626
|
+
* @returns A new `GUIPage` instance.
|
|
627
|
+
*/
|
|
628
|
+
createPage(): GUIPage;
|
|
629
|
+
/**
|
|
630
|
+
* Creates a new GUI window with the given title.
|
|
631
|
+
* @param title - Window title text.
|
|
632
|
+
* @returns A new `GUIWindow` instance.
|
|
633
|
+
*/
|
|
634
|
+
createWindow(title: string): GUIWindow;
|
|
635
|
+
/**
|
|
636
|
+
* Shows or hides the mouse cursor.
|
|
637
|
+
* @param visible - `true` to show the cursor, `false` to hide it.
|
|
638
|
+
*/
|
|
639
|
+
setCursorVisible(visible: boolean): void;
|
|
640
|
+
/**
|
|
641
|
+
* Checks whether the mouse cursor is currently visible.
|
|
642
|
+
* @returns `true` if the cursor is visible, `false` if hidden.
|
|
643
|
+
*/
|
|
644
|
+
isCursorVisible(): boolean;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// ===== Lucas Font =====
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* LucasFont — a custom bitmap font renderer.
|
|
651
|
+
* Provides low-level text measurement and rendering using a Lucas font stream.
|
|
652
|
+
* Use `lucasFont.createFont()` to create instances from a data stream.
|
|
653
|
+
*/
|
|
654
|
+
interface LucasFont {
|
|
655
|
+
/**
|
|
656
|
+
* Measures the dimensions of a character string rendered with this font.
|
|
657
|
+
* @param char - The character or string to measure.
|
|
658
|
+
* @param arg1 - Unknown parameter (engine-specific).
|
|
659
|
+
* @param arg2 - Unknown parameter (engine-specific).
|
|
660
|
+
* @param arg3 - Unknown parameter (engine-specific).
|
|
661
|
+
* @param size - Font size for measurement.
|
|
662
|
+
* @returns A `Vec2` containing the width and height of the rendered text.
|
|
663
|
+
*/
|
|
664
|
+
measure(
|
|
665
|
+
char: string,
|
|
666
|
+
arg1: number,
|
|
667
|
+
arg2: number,
|
|
668
|
+
arg3: number,
|
|
669
|
+
size: number
|
|
670
|
+
): Vec2;
|
|
671
|
+
/**
|
|
672
|
+
* Renders a character or string at a screen position.
|
|
673
|
+
* @param char - The character or string to render.
|
|
674
|
+
* @param position - Screen position as a `Vec2`.
|
|
675
|
+
* @param arg3 - Unknown parameter (engine-specific).
|
|
676
|
+
* @param arg4 - Unknown parameter (engine-specific).
|
|
677
|
+
* @param arg5 - Unknown parameter (engine-specific).
|
|
678
|
+
* @param size - Font size for rendering.
|
|
679
|
+
* @param colour - Packed colour number (ARGB format).
|
|
680
|
+
*/
|
|
681
|
+
render(
|
|
682
|
+
char: string,
|
|
683
|
+
position: Vec2,
|
|
684
|
+
arg3: number,
|
|
685
|
+
arg4: number,
|
|
686
|
+
arg5: number,
|
|
687
|
+
size: number,
|
|
688
|
+
colour: number
|
|
689
|
+
): void;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Font type alias — `LucasFont` is the primary font implementation.
|
|
694
|
+
*/
|
|
695
|
+
type Font = LucasFont;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* LucasFont creation API.
|
|
699
|
+
* Provides a factory method for creating `LucasFont` instances from
|
|
700
|
+
* font data streams.
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* // Create and use a Lucas font
|
|
704
|
+
* const lf = lucasFont.createFont(fontStream, 16);
|
|
705
|
+
* lf.render("Hello", new Vec2(100, 100), 0, 0, 0, 16, 0xFFFFFFFF);
|
|
706
|
+
*/
|
|
707
|
+
declare var lucasFont: {
|
|
708
|
+
/**
|
|
709
|
+
* Creates a new `LucasFont` instance from a font data stream.
|
|
710
|
+
* @param stream - Font data stream (binary font file data).
|
|
711
|
+
* @param size - Default font size for rendering.
|
|
712
|
+
* @returns A new `LucasFont` instance.
|
|
713
|
+
*/
|
|
714
|
+
createFont(stream: unknown, size: number): LucasFont;
|
|
715
|
+
};
|