@s2script/sdk 0.23.0 → 0.24.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 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 center-screen HTML backend: W/S move the cursor, E selects; re-painted each tick. */
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 WASD menu is open (nav still works)
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 center renderer) freezes the player's movement
66
- * while the menu is open and restores it on close — buttons still register, so WASD nav still works.
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.23.0",
3
+ "version": "0.24.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/topmenu.d.ts CHANGED
@@ -1,5 +1,7 @@
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
+
3
5
  /** A single registered top-menu entry (an admin command surfaced in the adminmenu). */
4
6
  export interface TopMenuItem {
5
7
  /** Plugin-namespaced unique id, e.g. "playercommands:slap". A duplicate id replaces. */
@@ -8,6 +10,8 @@ export interface TopMenuItem {
8
10
  name: string;
9
11
  /** Required ADMFLAG bit mask (adminmenu hides items the caller lacks flags for). */
10
12
  flags: number;
13
+ /** Sheets in which this item is rendered. Defaults to the admin sheet. */
14
+ sheets?: TopMenuSheet[];
11
15
  /** Runs in THIS plugin's context when an admin selects the item; receives the admin's 0-based slot. */
12
16
  onSelect: (adminSlot: number) => void;
13
17
  }
@@ -16,7 +20,7 @@ export interface TopMenuSnapshot {
16
20
  /** All category names, in registration order. */
17
21
  categories: string[];
18
22
  /** Every registered item's metadata (no `onSelect`), tagged with its category. */
19
- items: { id: string; category: string; name: string; flags: number }[];
23
+ items: { id: string; category: string; name: string; flags: number; sheets: TopMenuSheet[] }[];
20
24
  }
21
25
  /**
22
26
  * 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 (default false — the SM chat-only way). */
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 center-HTML renderer). */
66
+ /** Register the live-tally renderer (the CS2 right-side rail). */
65
67
  registerTallyRenderer(renderer: VoteTallyRenderer): void;
66
68
  };