@s2script/sdk 0.23.0 → 0.25.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/menu.d.ts +9 -5
- package/package.json +1 -1
- package/plugin.d.ts +8 -3
- package/topmenu.d.ts +20 -3
- package/votes.d.ts +4 -2
package/menu.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/** @s2script/menu — interactive player menus (chat + center backends). NO runtime code (injected at load). */
|
|
2
2
|
|
|
3
|
+
/** How a menu becomes interactive. Unknown values coerce to `"immediate"`. */
|
|
4
|
+
export type MenuActivation = "immediate" | "tab";
|
|
5
|
+
|
|
3
6
|
/** The display backend a {@link Menu} renders through — the value of {@link Menu.style}. */
|
|
4
7
|
export declare const enum MenuStyle {
|
|
5
8
|
/** Chat-log backend: numbered lines printed to chat, picked by typing the number. */
|
|
6
9
|
Chat = "chat",
|
|
7
|
-
/** CS2
|
|
10
|
+
/** CS2 HUD sheet (both styles paint the same center sheet on CS2). */
|
|
8
11
|
Center = "center",
|
|
9
12
|
}
|
|
10
13
|
/** Why a menu closed without a selection — the {@link MenuCancelEvent.reason}. */
|
|
@@ -48,7 +51,7 @@ export interface MenuCancelEvent {
|
|
|
48
51
|
* import { Menu, MenuStyle } from "@s2script/sdk/menu";
|
|
49
52
|
* const m = new Menu("s2script Menu Demo");
|
|
50
53
|
* m.style = MenuStyle.Center;
|
|
51
|
-
* m.freezePlayer = true; // freeze movement while the
|
|
54
|
+
* m.freezePlayer = true; // freeze movement while the HUD menu is open
|
|
52
55
|
* m.addItem("hp", "Heal to 100");
|
|
53
56
|
* m.addItem("noclip", "Toggle Noclip");
|
|
54
57
|
* m.onSelect(e => { console.log(`picked ${e.info} (slot ${e.slot})`); });
|
|
@@ -62,10 +65,11 @@ export declare class Menu {
|
|
|
62
65
|
style: MenuStyle;
|
|
63
66
|
/** Append an auto Exit control (default true). */
|
|
64
67
|
exitButton: boolean;
|
|
65
|
-
/** When true, a renderer that supports it (the CS2
|
|
66
|
-
* while the menu is open and restores it on close
|
|
67
|
-
* The chat renderer ignores it. Default false (movement allowed, the normal behavior). */
|
|
68
|
+
/** When true, a renderer that supports it (the CS2 HUD renderer) freezes the player's movement
|
|
69
|
+
* while the menu is open and restores it on close. Default false. */
|
|
68
70
|
freezePlayer: boolean;
|
|
71
|
+
/** `"immediate"` (default) arms cursor on open. `"tab"` paints first and waits for Tab. */
|
|
72
|
+
activation: MenuActivation;
|
|
69
73
|
/** (info, display) — `info` is returned to onSelect; `display` is shown. */
|
|
70
74
|
addItem(info: string, display: string, opts?: { disabled?: boolean }): void;
|
|
71
75
|
/** Register the callback fired when a player picks an item. Replaces any previous handler. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s2script/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"license": "MIT OR Apache-2.0",
|
|
5
5
|
"description": "s2script SDK — the builtin capability types (imported as @s2script/sdk/entity, …) plus the `s2s` CLI for building Source 2 / CS2 plugins.",
|
|
6
6
|
"type": "module",
|
package/plugin.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { EntityRef, OutputEvent } from "./entity";
|
|
|
12
12
|
import type { CommandHandler } from "./commands";
|
|
13
13
|
import type { Config } from "./config";
|
|
14
14
|
import type { PublishHandle } from "./interfaces";
|
|
15
|
-
import type { TopMenuItem } from "./topmenu";
|
|
15
|
+
import type { TopMenuItem, TopMenuTab } from "./topmenu";
|
|
16
16
|
import type { PrecacheContext } from "./sound";
|
|
17
17
|
import type { UserCmdView } from "./usercmd";
|
|
18
18
|
|
|
@@ -133,9 +133,14 @@ export interface CtxConfig {
|
|
|
133
133
|
}
|
|
134
134
|
/** TopMenu (adminmenu) contribution on this plugin's load-scope ({@link PluginContext.topmenu}). */
|
|
135
135
|
export interface CtxTopMenu {
|
|
136
|
-
/** Add (or reuse) a top-level menu category. */
|
|
136
|
+
/** Add (or reuse) a top-level menu category. Same as {@link CtxTopMenu.addTab} with `id === title`. */
|
|
137
137
|
addCategory(name: string): void;
|
|
138
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Declare this plugin's dashboard tab. The hub (`sm_admin` / `sm_menu`) paints one tab per
|
|
140
|
+
* distinct id that still has a visible item. Call before {@link CtxTopMenu.addItem}.
|
|
141
|
+
*/
|
|
142
|
+
addTab(tab: TopMenuTab): void;
|
|
143
|
+
/** Add an item under a tab id (or a legacy shared category name). */
|
|
139
144
|
addItem(category: string, item: TopMenuItem): void;
|
|
140
145
|
}
|
|
141
146
|
|
package/topmenu.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
/** @s2script/topmenu — the extensible admin/top menu registry. NO runtime code (injected at load). */
|
|
2
2
|
|
|
3
|
+
export type TopMenuSheet = "admin" | "menu";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A plugin-owned dashboard tab. `id` is the {@link TopMenuItem} grouping key (`addItem` first
|
|
7
|
+
* argument); `title` is what the hub paints on the tab bar.
|
|
8
|
+
*/
|
|
9
|
+
export interface TopMenuTab {
|
|
10
|
+
/** Stable id, e.g. `"playercommands"`. A duplicate id updates the title. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Tab label. Defaults to {@link TopMenuTab.id}. */
|
|
13
|
+
title?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
/** A single registered top-menu entry (an admin command surfaced in the adminmenu). */
|
|
4
17
|
export interface TopMenuItem {
|
|
5
18
|
/** Plugin-namespaced unique id, e.g. "playercommands:slap". A duplicate id replaces. */
|
|
@@ -8,15 +21,19 @@ export interface TopMenuItem {
|
|
|
8
21
|
name: string;
|
|
9
22
|
/** Required ADMFLAG bit mask (adminmenu hides items the caller lacks flags for). */
|
|
10
23
|
flags: number;
|
|
24
|
+
/** Sheets in which this item is rendered. Defaults to the admin sheet. */
|
|
25
|
+
sheets?: TopMenuSheet[];
|
|
11
26
|
/** Runs in THIS plugin's context when an admin selects the item; receives the admin's 0-based slot. */
|
|
12
27
|
onSelect: (adminSlot: number) => void;
|
|
13
28
|
}
|
|
14
29
|
/** A handler-free copy of the whole registry — what a menu renderer reads to build the display. */
|
|
15
30
|
export interface TopMenuSnapshot {
|
|
16
|
-
/**
|
|
31
|
+
/** Tab ids, in registration order. Same sequence as {@link TopMenuSnapshot.tabs}. */
|
|
17
32
|
categories: string[];
|
|
18
|
-
/**
|
|
19
|
-
|
|
33
|
+
/** Dashboard tabs with display titles. `addCategory(name)` is `{ id: name, title: name }`. */
|
|
34
|
+
tabs: { id: string; title: string }[];
|
|
35
|
+
/** Every registered item's metadata (no `onSelect`), tagged with its tab id (`category`). */
|
|
36
|
+
items: { id: string; category: string; name: string; flags: number; sheets: TopMenuSheet[] }[];
|
|
20
37
|
}
|
|
21
38
|
/**
|
|
22
39
|
* The shared admin/top-menu registry — renderers read {@link TopMenu.snapshot} and dispatch picks
|
package/votes.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface VoteConfig {
|
|
|
17
17
|
options: string[];
|
|
18
18
|
/** seconds. */
|
|
19
19
|
duration: number;
|
|
20
|
-
/** show a live center tally (
|
|
20
|
+
/** show a live center tally (ignored when a tally renderer is registered — CS2 always paints the rail). */
|
|
21
21
|
showLiveTally?: boolean;
|
|
22
22
|
/** Called once when the vote ends (or is exhausted), with the tallied {@link VoteResult}. It may start a new vote (the lock is released first). */
|
|
23
23
|
onEnd: (result: VoteResult) => void;
|
|
@@ -32,6 +32,8 @@ export interface VoteTally {
|
|
|
32
32
|
total: number;
|
|
33
33
|
/** Seconds remaining before the vote ends. */
|
|
34
34
|
secondsLeft: number;
|
|
35
|
+
/** This slot's 0-based cast, or null if they have not voted yet. */
|
|
36
|
+
choice: number | null;
|
|
35
37
|
}
|
|
36
38
|
/** A live-tally display backend for votes — registered via {@link Vote.registerTallyRenderer}. */
|
|
37
39
|
export interface VoteTallyRenderer {
|
|
@@ -61,6 +63,6 @@ export declare const Vote: {
|
|
|
61
63
|
isActive(): boolean;
|
|
62
64
|
/** Abort the active vote (no onEnd). */
|
|
63
65
|
cancel(): void;
|
|
64
|
-
/** Register the live-tally renderer (the CS2
|
|
66
|
+
/** Register the live-tally renderer (the CS2 right-side rail). */
|
|
65
67
|
registerTallyRenderer(renderer: VoteTallyRenderer): void;
|
|
66
68
|
};
|