@vespura/vmenu-plugin 0.0.0-stage → 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.md +678 -0
- package/README.md +44 -2
- package/dist/client.js +1907 -0
- package/dist/server.js +267 -0
- package/dist/types/client/diff.d.ts +4 -0
- package/dist/types/client/gate.d.ts +24 -0
- package/dist/types/client/host.d.ts +18 -0
- package/dist/types/client/index.d.ts +14 -0
- package/dist/types/client/item.d.ts +71 -0
- package/dist/types/client/items.d.ts +96 -0
- package/dist/types/client/key.d.ts +38 -0
- package/dist/types/client/menu.d.ts +142 -0
- package/dist/types/client/playerActions.d.ts +68 -0
- package/dist/types/client/plugin.d.ts +113 -0
- package/dist/types/client/preferences.d.ts +2 -0
- package/dist/types/client/settings.d.ts +49 -0
- package/dist/types/client/themes.d.ts +36 -0
- package/dist/types/client/translations.d.ts +10 -0
- package/dist/types/fivem.d.ts +14 -0
- package/dist/types/format.d.ts +1 -0
- package/dist/types/iife.d.ts +2 -0
- package/dist/types/protocol.d.ts +270 -0
- package/dist/types/server/declaration.d.ts +31 -0
- package/dist/types/server/index.d.ts +5 -0
- package/dist/types/server/server.d.ts +30 -0
- package/dist/types/signal.d.ts +12 -0
- package/dist/types/text.d.ts +20 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/vmenu.js +2096 -0
- package/package.json +42 -4
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { type Unsubscribe } from '../signal';
|
|
2
|
+
import { type TextLike } from '../text';
|
|
3
|
+
import { PluginItem, type ItemOptions } from './item';
|
|
4
|
+
import { PluginButton, PluginCheckbox, PluginConfirmButton, PluginConfirmList, PluginDynamicList, PluginList, PluginSeparator, PluginSlider, PluginSubmenu } from './items';
|
|
5
|
+
import { PluginKey } from './key';
|
|
6
|
+
/** Extra properties for a confirm button or confirm list. */
|
|
7
|
+
export interface ConfirmOptions extends ItemOptions {
|
|
8
|
+
/** What the row asks before its second press. */
|
|
9
|
+
confirmationDescription?: TextLike;
|
|
10
|
+
}
|
|
11
|
+
/** Extra properties for a checkbox. */
|
|
12
|
+
export interface CheckboxOptions extends ItemOptions {
|
|
13
|
+
/** Whether the box starts ticked. */
|
|
14
|
+
checked?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Saves the player's choice in this resource's key value store and restores it on the next start.
|
|
17
|
+
* Pass a stable `id` along with it: generated ids follow creation order, so reordering your code
|
|
18
|
+
* would hand a saved value to the wrong box.
|
|
19
|
+
*/
|
|
20
|
+
persist?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Extra properties for a list. */
|
|
23
|
+
export interface ListOptions extends ItemOptions {
|
|
24
|
+
/** The option selected at the start, counted from 0. */
|
|
25
|
+
selectedIndex?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Extra properties for a slider. */
|
|
28
|
+
export interface SliderOptions extends ItemOptions {
|
|
29
|
+
/** Draws a mark in the middle of the bar. */
|
|
30
|
+
showDivider?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Extra properties for a submenu row. */
|
|
33
|
+
export interface SubmenuOptions extends ItemOptions {
|
|
34
|
+
/** The new menu's title. Falls back to the row's text. */
|
|
35
|
+
title?: TextLike;
|
|
36
|
+
/** The bar under the new menu's banner. */
|
|
37
|
+
subtitle?: TextLike;
|
|
38
|
+
}
|
|
39
|
+
/** Extra properties for a key. */
|
|
40
|
+
export interface KeyOptions {
|
|
41
|
+
/** A controller button, for example "RUP_INDEX". Without one the key shows no button while the player uses a controller. */
|
|
42
|
+
defaultButton?: string;
|
|
43
|
+
/** What the game's key settings list it as. Falls back to the text. */
|
|
44
|
+
description?: TextLike;
|
|
45
|
+
/** A game control index to suppress while the menu is open, for a default key the game already uses. */
|
|
46
|
+
shadowedControl?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One of your plugin's menus: the root under your row in vMenu's Plugins menu, or a submenu. Rows
|
|
50
|
+
* added before connecting ride along with the registration, rows added later appear live.
|
|
51
|
+
*/
|
|
52
|
+
export declare class PluginMenu {
|
|
53
|
+
private readonly plugin;
|
|
54
|
+
private readonly itemList;
|
|
55
|
+
private readonly keyList;
|
|
56
|
+
private titleValue?;
|
|
57
|
+
private subtitleValue?;
|
|
58
|
+
private readonly opened;
|
|
59
|
+
private readonly closed;
|
|
60
|
+
private readonly indexChanged;
|
|
61
|
+
private insertIndex?;
|
|
62
|
+
private filterFn?;
|
|
63
|
+
/** The menu's id, how vMenu refers to it. */
|
|
64
|
+
get id(): string;
|
|
65
|
+
/** Every row, in order. */
|
|
66
|
+
get items(): readonly PluginItem[];
|
|
67
|
+
/** Every key of this menu. */
|
|
68
|
+
get keys(): readonly PluginKey[];
|
|
69
|
+
/** Whether `filter` is hiding rows right now. */
|
|
70
|
+
get isFiltered(): boolean;
|
|
71
|
+
/** The title in the menu's banner. */
|
|
72
|
+
get title(): TextLike | undefined;
|
|
73
|
+
set title(value: TextLike | undefined);
|
|
74
|
+
/** The bar under the banner. */
|
|
75
|
+
get subtitle(): TextLike | undefined;
|
|
76
|
+
set subtitle(value: TextLike | undefined);
|
|
77
|
+
/** Called when the player opens this menu. */
|
|
78
|
+
onOpened(handler: () => void): Unsubscribe;
|
|
79
|
+
/** Called when the player leaves this menu, including into a submenu. */
|
|
80
|
+
onClosed(handler: () => void): Unsubscribe;
|
|
81
|
+
/** Called when the cursor moves, with the old and new row index counted from 0. Chatty. */
|
|
82
|
+
onIndexChanged(handler: (oldIndex: number, newIndex: number) => void): Unsubscribe;
|
|
83
|
+
/** Adds a row the player presses. */
|
|
84
|
+
addButton(text: TextLike, options?: ItemOptions): PluginButton;
|
|
85
|
+
/** Adds a row that asks for a second press before it does anything. */
|
|
86
|
+
addConfirmButton(text: TextLike, options?: ConfirmOptions): PluginConfirmButton;
|
|
87
|
+
/** Adds a row with a tick box. */
|
|
88
|
+
addCheckbox(text: TextLike, options?: CheckboxOptions): PluginCheckbox;
|
|
89
|
+
/** Adds a row the player scrolls through a set of options on. */
|
|
90
|
+
addList(text: TextLike, values: readonly TextLike[], options?: ListOptions): PluginList;
|
|
91
|
+
/** Adds a list that asks for a second press before it does anything. */
|
|
92
|
+
addConfirmList(text: TextLike, values: readonly TextLike[], options?: ListOptions & ConfirmOptions): PluginConfirmList;
|
|
93
|
+
/** Adds a row with a bar the player drags between `min` and `max`. */
|
|
94
|
+
addSlider(text: TextLike, min: number, max: number, position: number, options?: SliderOptions): PluginSlider;
|
|
95
|
+
/** Adds a row whose value your code works out each time the player scrolls it, through `changeRequested`. */
|
|
96
|
+
addDynamicList(text: TextLike, initialValue: string, options?: ItemOptions): PluginDynamicList;
|
|
97
|
+
/** Adds a row that only shows text, used to split a menu into sections. */
|
|
98
|
+
addSeparator(text: TextLike, options?: ItemOptions): PluginSeparator;
|
|
99
|
+
/** Adds a row that opens a new menu, reached through the returned row's `menu`. */
|
|
100
|
+
addSubmenu(text: TextLike, options?: SubmenuOptions): PluginSubmenu;
|
|
101
|
+
/**
|
|
102
|
+
* Adds a key that works while this menu is open, with an instructional button at the bottom of the
|
|
103
|
+
* screen. Keep the id stable: it names the binding in the player's key settings, so changing it
|
|
104
|
+
* loses a key they picked themselves.
|
|
105
|
+
* @param id Letters, digits and underscores, unique within your plugin.
|
|
106
|
+
* @param text The instructional button's label.
|
|
107
|
+
* @param defaultKey A keyboard key name as the game knows it, for example "X" or "F5".
|
|
108
|
+
*/
|
|
109
|
+
addKey(id: string, text: TextLike, defaultKey: string, options?: KeyOptions): PluginKey;
|
|
110
|
+
/**
|
|
111
|
+
* Rows added inside `add` go in at `index`, counted from 0, one after another, instead of at the
|
|
112
|
+
* bottom. Adding goes back to the bottom once `add` returns.
|
|
113
|
+
*/
|
|
114
|
+
insertAt(index: number, add: () => void): void;
|
|
115
|
+
/** Moves a row of this menu to `index`, counted from 0. A submenu row keeps its menu, and the highlighted row stays highlighted. */
|
|
116
|
+
move(item: PluginItem, index: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* Shows only the rows `keep` answers true for. Rows added later are checked too: inside a batch
|
|
119
|
+
* when the batch ends, so properties set right after adding count, otherwise as they come in. Call
|
|
120
|
+
* it again after changing what it looks at.
|
|
121
|
+
*/
|
|
122
|
+
filter(keep: (item: PluginItem) => boolean): void;
|
|
123
|
+
/** Shows every row again after `filter`. */
|
|
124
|
+
clearFilter(): void;
|
|
125
|
+
/** Removes one row. For a submenu row, everything beneath it goes too. */
|
|
126
|
+
remove(item: PluginItem): void;
|
|
127
|
+
/** Removes every row. */
|
|
128
|
+
clear(): void;
|
|
129
|
+
/** Opens this menu on screen, closing whatever vMenu menu was open. */
|
|
130
|
+
open(): void;
|
|
131
|
+
/** Closes this plugin's menu if one is open. */
|
|
132
|
+
close(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Moves the cursor to a row of this menu, as if the player had moved there. Does nothing for a
|
|
135
|
+
* hidden row or one from another menu.
|
|
136
|
+
*/
|
|
137
|
+
select(item: PluginItem): void;
|
|
138
|
+
private newNode;
|
|
139
|
+
private attach;
|
|
140
|
+
private removeLocal;
|
|
141
|
+
private subscribeMenuEvent;
|
|
142
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Unsubscribe } from '../signal';
|
|
2
|
+
import { type TextLike } from '../text';
|
|
3
|
+
import { PluginItem, type ItemOptions } from './item';
|
|
4
|
+
import { PluginSeparator } from './items';
|
|
5
|
+
/**
|
|
6
|
+
* The player a player action was used on, read from vMenu's Online Players snapshot. The snapshot
|
|
7
|
+
* can be stale and the player may have left, so your server side must check the target still exists
|
|
8
|
+
* before acting on it.
|
|
9
|
+
*/
|
|
10
|
+
export interface PlayerTarget {
|
|
11
|
+
/** The player's server id. */
|
|
12
|
+
readonly serverId: number;
|
|
13
|
+
/** The player's name as vMenu showed it. */
|
|
14
|
+
readonly name: string;
|
|
15
|
+
}
|
|
16
|
+
/** A player action the player presses. */
|
|
17
|
+
export declare class PluginPlayerButton extends PluginItem {
|
|
18
|
+
private readonly selected;
|
|
19
|
+
/** Called when the action is used on a player, with that player as the target. */
|
|
20
|
+
onSelected(handler: (target: PlayerTarget) => void): Unsubscribe;
|
|
21
|
+
}
|
|
22
|
+
/** A player action that asks for a second press before it does anything. */
|
|
23
|
+
export declare class PluginPlayerConfirmButton extends PluginItem {
|
|
24
|
+
private confirmationDescriptionValue?;
|
|
25
|
+
private readonly confirmed;
|
|
26
|
+
/** What the row asks before its second press. Empty uses vMenu's own wording. */
|
|
27
|
+
get confirmationDescription(): TextLike | undefined;
|
|
28
|
+
set confirmationDescription(value: TextLike | undefined);
|
|
29
|
+
/** Called on the confirming second press, with the targeted player. */
|
|
30
|
+
onConfirmed(handler: (target: PlayerTarget) => void): Unsubscribe;
|
|
31
|
+
}
|
|
32
|
+
/** A player action with a set of options. */
|
|
33
|
+
export declare class PluginPlayerList extends PluginItem {
|
|
34
|
+
private readonly selected;
|
|
35
|
+
/** The current selection, counted from 0. Shared across every player the menu shows, since the same rows serve them all. */
|
|
36
|
+
get selectedIndex(): number;
|
|
37
|
+
set selectedIndex(value: number);
|
|
38
|
+
/** Replaces the options, optionally moving the selection at the same time. */
|
|
39
|
+
setOptions(options: readonly TextLike[], selectedIndex?: number): void;
|
|
40
|
+
/** Called when the action is used on a player, with the target and the chosen index. */
|
|
41
|
+
onSelected(handler: (target: PlayerTarget, index: number) => void): Unsubscribe;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Actions vMenu adds to the "Plugin Actions" submenu of every player's entry in its Online Players
|
|
45
|
+
* menu. The same rows serve every player, and the target is handed to your handler when one fires.
|
|
46
|
+
*/
|
|
47
|
+
export declare class PluginPlayerActions {
|
|
48
|
+
private readonly plugin;
|
|
49
|
+
private readonly itemList;
|
|
50
|
+
/** Every action, in order. */
|
|
51
|
+
get items(): readonly PluginItem[];
|
|
52
|
+
/** Adds an action the player presses. */
|
|
53
|
+
addButton(text: TextLike, options?: ItemOptions): PluginPlayerButton;
|
|
54
|
+
/** Adds an action that asks for a second press. */
|
|
55
|
+
addConfirmButton(text: TextLike, options?: ItemOptions & {
|
|
56
|
+
confirmationDescription?: TextLike;
|
|
57
|
+
}): PluginPlayerConfirmButton;
|
|
58
|
+
/** Adds an action with a set of options. */
|
|
59
|
+
addList(text: TextLike, values: readonly TextLike[], options?: ItemOptions & {
|
|
60
|
+
selectedIndex?: number;
|
|
61
|
+
}): PluginPlayerList;
|
|
62
|
+
/** Adds a row that only shows text. */
|
|
63
|
+
addSeparator(text: TextLike, options?: ItemOptions): PluginSeparator;
|
|
64
|
+
/** Removes one action from every player's entry. */
|
|
65
|
+
remove(item: PluginItem): void;
|
|
66
|
+
private newNode;
|
|
67
|
+
private attach;
|
|
68
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type RegisterResult } from '../protocol';
|
|
2
|
+
import { type Unsubscribe } from '../signal';
|
|
3
|
+
import { type TextLike } from '../text';
|
|
4
|
+
import type { PluginHost } from './host';
|
|
5
|
+
import { PluginMenu } from './menu';
|
|
6
|
+
import { PluginPlayerActions } from './playerActions';
|
|
7
|
+
import { PluginSettings } from './settings';
|
|
8
|
+
import { PluginThemes } from './themes';
|
|
9
|
+
import { PluginTranslations } from './translations';
|
|
10
|
+
/** How a notification is coloured in vMenu's notification area. */
|
|
11
|
+
export type NotifyStyle = 'info' | 'success' | 'warning' | 'error';
|
|
12
|
+
/** One suggestion row the input box offers while the player types. */
|
|
13
|
+
export interface PromptSuggestion {
|
|
14
|
+
/** What lands in the box when the suggestion is picked. */
|
|
15
|
+
value: string;
|
|
16
|
+
/** What the player reads in the list. The value is shown when left out. */
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One question for vMenu's input box. */
|
|
20
|
+
export interface PluginPrompt {
|
|
21
|
+
title: TextLike;
|
|
22
|
+
/** The longest answer allowed, 60 when left out. vMenu caps it at 500. */
|
|
23
|
+
maxLength?: number;
|
|
24
|
+
/** What the box starts with. */
|
|
25
|
+
initialValue?: string;
|
|
26
|
+
suggestions?: readonly PromptSuggestion[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Your plugin's client side entry point. Create it once, declare your menus, translations and
|
|
30
|
+
* settings, then call `connect`. It registers again by itself whenever vMenu restarts, so everything
|
|
31
|
+
* you declared and changed since is restored.
|
|
32
|
+
*/
|
|
33
|
+
export declare class VMenuPlugin implements PluginHost {
|
|
34
|
+
private readonly displayName;
|
|
35
|
+
private readonly itemsById;
|
|
36
|
+
private readonly menusById;
|
|
37
|
+
private readonly keysById;
|
|
38
|
+
private readonly pendingPrompts;
|
|
39
|
+
private readonly pendingItems;
|
|
40
|
+
private readonly pendingMenus;
|
|
41
|
+
private readonly dirtyFilters;
|
|
42
|
+
private readonly registrationAnswered;
|
|
43
|
+
private readonly disconnected;
|
|
44
|
+
private firstResult?;
|
|
45
|
+
private resolveFirst?;
|
|
46
|
+
private batchOps?;
|
|
47
|
+
private batchDepth;
|
|
48
|
+
private nextItem;
|
|
49
|
+
private nextMenu;
|
|
50
|
+
private nextPrompt;
|
|
51
|
+
private handlersRegistered;
|
|
52
|
+
private connected;
|
|
53
|
+
/** The resource this plugin runs in, its identity towards vMenu. */
|
|
54
|
+
readonly resource: string;
|
|
55
|
+
/** The sanitized identity used inside permission and convar names. */
|
|
56
|
+
readonly id: string;
|
|
57
|
+
/** Extra line under the resource name in your row's description, as a translation key. */
|
|
58
|
+
descriptionKey?: string;
|
|
59
|
+
/** Your plugin's convar settings. */
|
|
60
|
+
readonly settings: PluginSettings;
|
|
61
|
+
/** Your plugin's translation tables. */
|
|
62
|
+
readonly translations: PluginTranslations;
|
|
63
|
+
/** The look of vMenu's menus for this player. */
|
|
64
|
+
readonly themes: PluginThemes;
|
|
65
|
+
/** The menu behind your row in vMenu's Plugins menu. */
|
|
66
|
+
readonly rootMenu: PluginMenu;
|
|
67
|
+
/** Actions added to every player's entry of vMenu's Online Players menu. */
|
|
68
|
+
readonly playerActions: PluginPlayerActions;
|
|
69
|
+
private constructor();
|
|
70
|
+
/** Creates the plugin. One per resource: a second call returns the first instance. */
|
|
71
|
+
static create(displayName: TextLike): VMenuPlugin;
|
|
72
|
+
/** Whether vMenu currently has this plugin registered. */
|
|
73
|
+
get isConnected(): boolean;
|
|
74
|
+
/** Called on every registration answer, including automatic re-registrations. */
|
|
75
|
+
onRegistrationAnswered(handler: (result: RegisterResult) => void): Unsubscribe;
|
|
76
|
+
/** Called when vMenu stops, after which the plugin waits to register again. */
|
|
77
|
+
onDisconnected(handler: () => void): Unsubscribe;
|
|
78
|
+
/**
|
|
79
|
+
* Registers with vMenu. The promise resolves on vMenu's first answer, which can be a while when
|
|
80
|
+
* vMenu starts later than your resource. It never rejects: a refusal arrives as a result with
|
|
81
|
+
* `accepted` false.
|
|
82
|
+
*/
|
|
83
|
+
connect(): Promise<RegisterResult>;
|
|
84
|
+
/** Shows a message through vMenu's notification area, credited to your resource. */
|
|
85
|
+
notify(style: NotifyStyle, text: TextLike, durationMs?: number): void;
|
|
86
|
+
/** Asks the player for text through vMenu's input box. Resolves to null if they cancelled or the box was unavailable. */
|
|
87
|
+
getText(title: TextLike, options?: {
|
|
88
|
+
maxLength?: number;
|
|
89
|
+
initialValue?: string;
|
|
90
|
+
suggestions?: readonly PromptSuggestion[];
|
|
91
|
+
}): Promise<string | null>;
|
|
92
|
+
/** Asks several questions one after another. Resolves to null if the player cancelled any of them. */
|
|
93
|
+
getTexts(prompts: readonly PluginPrompt[]): Promise<string[] | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Groups every change made inside `changes` into one update, so many small changes cost vMenu a
|
|
96
|
+
* single repaint. Nesting is fine: only the outermost batch sends. The batch ends when `changes`
|
|
97
|
+
* returns, so changes made after an `await` inside it are sent on their own.
|
|
98
|
+
*/
|
|
99
|
+
batch<T>(changes: () => T): T;
|
|
100
|
+
private endBatch;
|
|
101
|
+
private markFilterDirty;
|
|
102
|
+
private carriedByPendingAdd;
|
|
103
|
+
private send;
|
|
104
|
+
private ensureHandlers;
|
|
105
|
+
private sendRegistration;
|
|
106
|
+
private buildRequest;
|
|
107
|
+
private onRegisterResult;
|
|
108
|
+
private onCallback;
|
|
109
|
+
private itemOrUndefined;
|
|
110
|
+
private onPromptResult;
|
|
111
|
+
private cancelPendingPrompts;
|
|
112
|
+
private onResourceStop;
|
|
113
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One of your plugin's convar settings. The full convar name is
|
|
3
|
+
* `vMenu.Enhanced.Plugins.<Id>.<Name>`, set by the server owner with `setr`, and readable here
|
|
4
|
+
* because replicated convars reach every resource.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class PluginSetting<T> {
|
|
7
|
+
/** The short name you declared. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The composed convar name a server owner sets. */
|
|
10
|
+
readonly fullName: string;
|
|
11
|
+
/** The value used while the server owner has not set the convar. */
|
|
12
|
+
readonly defaultValue: T;
|
|
13
|
+
/** The current value, read from the convar every time. */
|
|
14
|
+
abstract get value(): T;
|
|
15
|
+
protected raw(fallback: string): string;
|
|
16
|
+
}
|
|
17
|
+
/** A setting that is on or off. Gates can use it through `Gate.setting`. */
|
|
18
|
+
export declare class PluginBoolSetting extends PluginSetting<boolean> {
|
|
19
|
+
get value(): boolean;
|
|
20
|
+
}
|
|
21
|
+
/** A whole number setting. */
|
|
22
|
+
export declare class PluginIntSetting extends PluginSetting<number> {
|
|
23
|
+
get value(): number;
|
|
24
|
+
}
|
|
25
|
+
/** A decimal number setting. */
|
|
26
|
+
export declare class PluginFloatSetting extends PluginSetting<number> {
|
|
27
|
+
get value(): number;
|
|
28
|
+
}
|
|
29
|
+
/** A text setting. An empty convar falls back to the default. */
|
|
30
|
+
export declare class PluginStringSetting extends PluginSetting<string> {
|
|
31
|
+
get value(): string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Your plugin's settings. Declaring one here lets your menu gate on it and lets vMenu track it for
|
|
35
|
+
* live refresh. Declare the same settings in your server script too, so they appear in the template
|
|
36
|
+
* vMenu writes for the server owner.
|
|
37
|
+
*/
|
|
38
|
+
export declare class PluginSettings {
|
|
39
|
+
private readonly prefix;
|
|
40
|
+
/** Declares an on or off setting. */
|
|
41
|
+
bool(name: string, defaultValue: boolean, description: string): PluginBoolSetting;
|
|
42
|
+
/** Declares a whole number setting. */
|
|
43
|
+
int(name: string, defaultValue: number, description: string): PluginIntSetting;
|
|
44
|
+
/** Declares a decimal number setting. */
|
|
45
|
+
float(name: string, defaultValue: number, description: string): PluginFloatSetting;
|
|
46
|
+
/** Declares a text setting. */
|
|
47
|
+
string(name: string, defaultValue: string, description: string): PluginStringSetting;
|
|
48
|
+
private declare;
|
|
49
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Unsubscribe } from '../signal';
|
|
2
|
+
/** One of vMenu's looks. Hand the `id` to `themes.set` to put the menus in it, and show the `name` to the player. */
|
|
3
|
+
export interface PluginTheme {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
/** Whether this is the theme on screen right now. */
|
|
7
|
+
readonly isCurrent: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The look of vMenu's menus, as seen by this player only. vMenu hands the list over right after the
|
|
11
|
+
* plugin registers and again on every change, so read `available` from `onChanged` rather than
|
|
12
|
+
* straight after connecting. A theme set here lasts as long as the client runs.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PluginThemes {
|
|
15
|
+
private readonly plugin;
|
|
16
|
+
private availableValue;
|
|
17
|
+
private currentIdValue?;
|
|
18
|
+
private configuredIdValue?;
|
|
19
|
+
private overriddenValue;
|
|
20
|
+
private readonly changed;
|
|
21
|
+
/** Every theme vMenu offers, in the order it lists them. Empty until vMenu has sent them. */
|
|
22
|
+
get available(): readonly PluginTheme[];
|
|
23
|
+
/** The id of the theme on screen, undefined until vMenu has said what it is. */
|
|
24
|
+
get currentId(): string | undefined;
|
|
25
|
+
/** The id the server's own setting asks for, which is where `reset` goes. */
|
|
26
|
+
get configuredId(): string | undefined;
|
|
27
|
+
/** Whether a plugin is overriding the server's setting for this player right now. */
|
|
28
|
+
get isOverridden(): boolean;
|
|
29
|
+
/** Called whenever the list or the theme on screen changed, including when somebody else changed it. */
|
|
30
|
+
onChanged(handler: () => void): Unsubscribe;
|
|
31
|
+
/** Puts vMenu's menus in a theme for this player. An id vMenu does not know is ignored. */
|
|
32
|
+
set(themeId: string): void;
|
|
33
|
+
/** Drops the override and goes back to the theme the server's setting asks for. */
|
|
34
|
+
reset(): void;
|
|
35
|
+
private send;
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Your plugin's translation tables: language code to key to text. An English table under "en" is
|
|
3
|
+
* required as soon as any of your texts use keys, and it is the fallback whenever the selected
|
|
4
|
+
* language has no entry. vMenu follows its selected language live.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PluginTranslations {
|
|
7
|
+
private readonly plugin;
|
|
8
|
+
/** Adds or extends one language's table. Later entries win over earlier ones. */
|
|
9
|
+
add(languageCode: string, entries: Readonly<Record<string, string>>): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const currentResource: () => string;
|
|
2
|
+
export declare const emitLocal: (eventName: string, ...args: unknown[]) => void;
|
|
3
|
+
export declare const onLocal: (eventName: string, handler: (...args: any[]) => void) => void;
|
|
4
|
+
export declare const getConvar: (name: string, fallback: string) => string;
|
|
5
|
+
export declare const getKvp: (key: string) => string | undefined;
|
|
6
|
+
export declare const setKvp: (key: string, value: string) => void;
|
|
7
|
+
export declare const isAceAllowed: (playerSource: string, object: string) => boolean;
|
|
8
|
+
export declare const log: {
|
|
9
|
+
info: (resource: string, message: string) => void;
|
|
10
|
+
warn: (resource: string, message: string) => void;
|
|
11
|
+
error: (resource: string, message: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function parseJson<T>(json: unknown): T | undefined;
|
|
14
|
+
export declare function sanitizeId(resource: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatFloat(value: number): string;
|