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.
- package/build/cjs/global/abstract-global.d.ts +3 -0
- package/build/cjs/global/abstract-global.js +6 -0
- package/build/cjs/global/content-menu/leave-seat.d.ts +4 -0
- package/build/cjs/global/content-menu/leave-seat.js +17 -0
- package/build/cjs/index.d.ts +2 -0
- package/build/cjs/index.js +2 -0
- package/build/cjs/ui/player-name-take-seat.js +6 -5
- package/build/esm/global/abstract-global.d.ts +3 -0
- package/build/esm/global/abstract-global.js +2 -0
- package/build/esm/global/content-menu/leave-seat.d.ts +4 -0
- package/build/esm/global/content-menu/leave-seat.js +13 -0
- package/build/esm/index.d.ts +2 -0
- package/build/esm/index.js +2 -0
- package/build/esm/ui/player-name-take-seat.js +6 -5
- package/package.json +1 -1
|
@@ -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;
|
package/build/cjs/index.d.ts
CHANGED
package/build/cjs/index.js
CHANGED
|
@@ -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.
|
|
48
|
-
|
|
49
|
-
|
|
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,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
|
+
}
|
package/build/esm/index.d.ts
CHANGED
package/build/esm/index.js
CHANGED
|
@@ -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.
|
|
45
|
-
|
|
46
|
-
|
|
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);
|