ttpg-darrell 1.0.7 → 1.0.8

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.
@@ -0,0 +1,3 @@
1
+ export declare abstract class AbstractGlobal {
2
+ abstract init(): void;
3
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractGlobal = void 0;
4
+ class AbstractGlobal {
5
+ }
6
+ exports.AbstractGlobal = AbstractGlobal;
@@ -0,0 +1,4 @@
1
+ import { AbstractGlobal } from "../abstract-global";
2
+ export declare class LeaveSeat implements AbstractGlobal {
3
+ init(): void;
4
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LeaveSeat = void 0;
4
+ const api_1 = require("@tabletop-playground/api");
5
+ class LeaveSeat {
6
+ init() {
7
+ const actionName = "*Leave seat";
8
+ const tooltip = "Switch to spectator";
9
+ api_1.world.addCustomAction(actionName, tooltip);
10
+ api_1.globalEvents.onCustomAction.add((player, identifier) => {
11
+ if (identifier === actionName) {
12
+ player.switchSlot(-1);
13
+ }
14
+ });
15
+ }
16
+ }
17
+ exports.LeaveSeat = LeaveSeat;
@@ -1,3 +1,5 @@
1
+ export * from "./global/abstract-global";
2
+ export * from "./global/content-menu/leave-seat";
1
3
  export * from "./locale/locale";
2
4
  export * from "./nsid/nsid";
3
5
  export * from "./setup/abstract-setup";
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./global/abstract-global"), exports);
18
+ __exportStar(require("./global/content-menu/leave-seat"), exports);
17
19
  __exportStar(require("./locale/locale"), exports);
18
20
  __exportStar(require("./nsid/nsid"), exports);
19
21
  __exportStar(require("./setup/abstract-setup"), exports);
@@ -4,6 +4,9 @@ exports.PlayerNameTakeSeat = void 0;
4
4
  const api_1 = require("@tabletop-playground/api");
5
5
  class PlayerNameTakeSeat {
6
6
  constructor(gameObject) {
7
+ if (!gameObject) {
8
+ throw new Error("missing gameObject");
9
+ }
7
10
  this._gameObject = gameObject;
8
11
  this._nameText = new api_1.Text()
9
12
  .setBold(true)
@@ -16,13 +19,11 @@ class PlayerNameTakeSeat {
16
19
  this._widgetSwitcher = new api_1.WidgetSwitcher()
17
20
  .addChild(this._takeSeatButton)
18
21
  .addChild(this._nameBorder);
19
- this._widgetSwitcher.setActiveIndex(1);
20
22
  this._ui = new api_1.UIElement();
21
23
  this._ui.presentationStyle = api_1.UIPresentationStyle.ViewAligned;
22
24
  this._ui.useTransparency = true;
23
25
  this._ui.useWidgetSize = true;
24
26
  this._ui.widget = this._widgetSwitcher;
25
- this._gameObject.addUI(this._ui);
26
27
  this._takeSeatButton.onClicked.add((button, player) => {
27
28
  const thisSlot = this._gameObject.getOwningPlayerSlot();
28
29
  if (thisSlot < 0) {
@@ -44,9 +45,9 @@ class PlayerNameTakeSeat {
44
45
  api_1.globalEvents.onPlayerLeft.remove(eventHandler);
45
46
  api_1.globalEvents.onPlayerSwitchedSlots.remove(eventHandler);
46
47
  });
47
- this.setColor(gameObject.getPrimaryColor())
48
- .setFontSize(PlayerNameTakeSeat.DEFAULT_FONT_SIZE)
49
- ._updatePlayerStatus();
48
+ this._gameObject.addUI(this._ui);
49
+ this.setColor(gameObject.getPrimaryColor()).setFontSize(PlayerNameTakeSeat.DEFAULT_FONT_SIZE);
50
+ this._updatePlayerStatus();
50
51
  }
51
52
  setColor(color) {
52
53
  this._nameText.setTextColor(color);
@@ -0,0 +1,3 @@
1
+ export declare abstract class AbstractGlobal {
2
+ abstract init(): void;
3
+ }
@@ -0,0 +1,2 @@
1
+ export class AbstractGlobal {
2
+ }
@@ -0,0 +1,4 @@
1
+ import { AbstractGlobal } from "../abstract-global";
2
+ export declare class LeaveSeat implements AbstractGlobal {
3
+ init(): void;
4
+ }
@@ -0,0 +1,13 @@
1
+ import { globalEvents, world } from "@tabletop-playground/api";
2
+ export class LeaveSeat {
3
+ init() {
4
+ const actionName = "*Leave seat";
5
+ const tooltip = "Switch to spectator";
6
+ world.addCustomAction(actionName, tooltip);
7
+ globalEvents.onCustomAction.add((player, identifier) => {
8
+ if (identifier === actionName) {
9
+ player.switchSlot(-1);
10
+ }
11
+ });
12
+ }
13
+ }
@@ -1,3 +1,5 @@
1
+ export * from "./global/abstract-global";
2
+ export * from "./global/content-menu/leave-seat";
1
3
  export * from "./locale/locale";
2
4
  export * from "./nsid/nsid";
3
5
  export * from "./setup/abstract-setup";
@@ -1,3 +1,5 @@
1
+ export * from "./global/abstract-global";
2
+ export * from "./global/content-menu/leave-seat";
1
3
  export * from "./locale/locale";
2
4
  export * from "./nsid/nsid";
3
5
  export * from "./setup/abstract-setup";
@@ -1,6 +1,9 @@
1
1
  import { Border, Button, Text, TextJustification, UIElement, UIPresentationStyle, Vector, WidgetSwitcher, globalEvents, world, } from "@tabletop-playground/api";
2
2
  export class PlayerNameTakeSeat {
3
3
  constructor(gameObject) {
4
+ if (!gameObject) {
5
+ throw new Error("missing gameObject");
6
+ }
4
7
  this._gameObject = gameObject;
5
8
  this._nameText = new Text()
6
9
  .setBold(true)
@@ -13,13 +16,11 @@ export class PlayerNameTakeSeat {
13
16
  this._widgetSwitcher = new WidgetSwitcher()
14
17
  .addChild(this._takeSeatButton)
15
18
  .addChild(this._nameBorder);
16
- this._widgetSwitcher.setActiveIndex(1);
17
19
  this._ui = new UIElement();
18
20
  this._ui.presentationStyle = UIPresentationStyle.ViewAligned;
19
21
  this._ui.useTransparency = true;
20
22
  this._ui.useWidgetSize = true;
21
23
  this._ui.widget = this._widgetSwitcher;
22
- this._gameObject.addUI(this._ui);
23
24
  this._takeSeatButton.onClicked.add((button, player) => {
24
25
  const thisSlot = this._gameObject.getOwningPlayerSlot();
25
26
  if (thisSlot < 0) {
@@ -41,9 +42,9 @@ export class PlayerNameTakeSeat {
41
42
  globalEvents.onPlayerLeft.remove(eventHandler);
42
43
  globalEvents.onPlayerSwitchedSlots.remove(eventHandler);
43
44
  });
44
- this.setColor(gameObject.getPrimaryColor())
45
- .setFontSize(PlayerNameTakeSeat.DEFAULT_FONT_SIZE)
46
- ._updatePlayerStatus();
45
+ this._gameObject.addUI(this._ui);
46
+ this.setColor(gameObject.getPrimaryColor()).setFontSize(PlayerNameTakeSeat.DEFAULT_FONT_SIZE);
47
+ this._updatePlayerStatus();
47
48
  }
48
49
  setColor(color) {
49
50
  this._nameText.setTextColor(color);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ttpg-darrell",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "TTPG TypeScript library",
5
5
  "main": "./build/cjs/index.js",
6
6
  "module": "./build/esm/index.js",