some improvements with registering menu actions
This commit is contained in:
parent
5aba99403e
commit
2322f5f76d
@ -134,6 +134,18 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setClickable(clickable: boolean = true): void {
|
||||||
|
if (clickable) {
|
||||||
|
this.setInteractive({
|
||||||
|
hitArea: new Phaser.Geom.Circle(0, 0, interactiveRadius),
|
||||||
|
hitAreaCallback: Phaser.Geom.Circle.Contains, //eslint-disable-line @typescript-eslint/unbound-method
|
||||||
|
useHandCursor: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.disableInteractive();
|
||||||
|
}
|
||||||
|
|
||||||
public getPosition(): { x: number, y: number } {
|
public getPosition(): { x: number, y: number } {
|
||||||
return { x: this.x, y: this.y };
|
return { x: this.x, y: this.y };
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||||||
public userId: number;
|
public userId: number;
|
||||||
public readonly activationRadius: number;
|
public readonly activationRadius: number;
|
||||||
|
|
||||||
|
private registeredActions: { actionName: string, callback: Function }[];
|
||||||
private visitCardUrl: string | null;
|
private visitCardUrl: string | null;
|
||||||
private isActionsMenuInitialized: boolean = false;
|
private isActionsMenuInitialized: boolean = false;
|
||||||
private actionsMenuStoreUnsubscriber: Unsubscriber;
|
private actionsMenuStoreUnsubscriber: Unsubscriber;
|
||||||
@ -43,13 +44,16 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||||||
direction,
|
direction,
|
||||||
moving,
|
moving,
|
||||||
1,
|
1,
|
||||||
!!visitCardUrl,
|
true,
|
||||||
companion,
|
companion,
|
||||||
companionTexturePromise
|
companionTexturePromise
|
||||||
);
|
);
|
||||||
|
|
||||||
//set data
|
//set data
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
this.registeredActions = [];
|
||||||
|
this.registerDefaultActionsMenuActions();
|
||||||
|
this.setClickable(this.registeredActions.length > 0);
|
||||||
this.activationRadius = activationRadius ?? 96;
|
this.activationRadius = activationRadius ?? 96;
|
||||||
this.visitCardUrl = visitCardUrl;
|
this.visitCardUrl = visitCardUrl;
|
||||||
this.actionsMenuStoreUnsubscriber = actionsMenuStore.subscribe((value: ActionsMenuData | undefined) => {
|
this.actionsMenuStoreUnsubscriber = actionsMenuStore.subscribe((value: ActionsMenuData | undefined) => {
|
||||||
@ -71,6 +75,19 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public registerActionsMenuAction(action: { actionName: string, callback: Function }): void {
|
||||||
|
this.registeredActions.push(action);
|
||||||
|
this.updateIsClickable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unregisterActionsMenuAction(actionName: string) {
|
||||||
|
const index = this.registeredActions.findIndex(action => action.actionName === actionName);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.registeredActions.splice(index, 1);
|
||||||
|
}
|
||||||
|
this.updateIsClickable();
|
||||||
|
}
|
||||||
|
|
||||||
public activate(): void {
|
public activate(): void {
|
||||||
this.toggleActionsMenu();
|
this.toggleActionsMenu();
|
||||||
}
|
}
|
||||||
@ -81,33 +98,31 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateIsClickable(): void {
|
||||||
|
this.setClickable(this.registeredActions.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
private toggleActionsMenu(): void {
|
private toggleActionsMenu(): void {
|
||||||
if (this.isActionsMenuInitialized) {
|
if (this.isActionsMenuInitialized) {
|
||||||
actionsMenuStore.clear();
|
actionsMenuStore.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
actionsMenuStore.initialize(this.playerName);
|
actionsMenuStore.initialize(this.playerName);
|
||||||
for (const action of this.getActionsMenuActions()) {
|
for (const action of this.registeredActions) {
|
||||||
actionsMenuStore.addAction(action.actionName, action.callback);
|
actionsMenuStore.addAction(action.actionName, action.callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getActionsMenuActions(): { actionName: string, callback: Function }[] {
|
private registerDefaultActionsMenuActions(): void {
|
||||||
return [
|
if (this.visitCardUrl) {
|
||||||
{
|
this.registeredActions.push({
|
||||||
actionName: "Visiting Card",
|
actionName: "Visiting Card",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
requestVisitCardsStore.set(this.visitCardUrl);
|
requestVisitCardsStore.set(this.visitCardUrl);
|
||||||
actionsMenuStore.clear();
|
actionsMenuStore.clear();
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
{
|
}
|
||||||
actionName: "Log Hello",
|
|
||||||
callback: () => {
|
|
||||||
console.log('HELLO');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bindEventHandlers(): void {
|
private bindEventHandlers(): void {
|
||||||
|
@ -26,7 +26,6 @@ function createActionsMenuStore() {
|
|||||||
removeAction: (actionName: string) => {
|
removeAction: (actionName: string) => {
|
||||||
update((data) => {
|
update((data) => {
|
||||||
const actionIndex = data?.actions.findIndex(action => action.actionName === actionName);
|
const actionIndex = data?.actions.findIndex(action => action.actionName === actionName);
|
||||||
console.log(actionIndex);
|
|
||||||
if (actionIndex !== undefined && actionIndex != -1) {
|
if (actionIndex !== undefined && actionIndex != -1) {
|
||||||
data?.actions.splice(actionIndex, 1);
|
data?.actions.splice(actionIndex, 1);
|
||||||
}
|
}
|
||||||
|
188
maps/tests/ActionsMenu/actions_menu_test.json
Normal file
188
maps/tests/ActionsMenu/actions_menu_test.json
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
{ "compressionlevel":-1,
|
||||||
|
"height":30,
|
||||||
|
"infinite":false,
|
||||||
|
"layers":[
|
||||||
|
{
|
||||||
|
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||||
|
"height":30,
|
||||||
|
"id":1,
|
||||||
|
"name":"floor",
|
||||||
|
"opacity":1,
|
||||||
|
"properties":[
|
||||||
|
{
|
||||||
|
"name":"openWebsite",
|
||||||
|
"type":"string",
|
||||||
|
"value":"script.php"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"openWebsiteAllowApi",
|
||||||
|
"type":"bool",
|
||||||
|
"value":true
|
||||||
|
}],
|
||||||
|
"type":"tilelayer",
|
||||||
|
"visible":true,
|
||||||
|
"width":30,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data":[24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
"height":30,
|
||||||
|
"id":2,
|
||||||
|
"name":"start",
|
||||||
|
"opacity":1,
|
||||||
|
"type":"tilelayer",
|
||||||
|
"visible":true,
|
||||||
|
"width":30,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"draworder":"topdown",
|
||||||
|
"id":3,
|
||||||
|
"name":"floorLayer",
|
||||||
|
"objects":[
|
||||||
|
{
|
||||||
|
"height":115.775966464835,
|
||||||
|
"id":1,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"text":
|
||||||
|
{
|
||||||
|
"fontfamily":"MS Shell Dlg 2",
|
||||||
|
"pixelsize":21,
|
||||||
|
"text":"Set Viewport - Move the camera to the given point. It will be locked if Lock checkbox is checked",
|
||||||
|
"wrap":true
|
||||||
|
},
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":315.4375,
|
||||||
|
"x":68.4021076998051,
|
||||||
|
"y":160.733918128655
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":115.776,
|
||||||
|
"id":4,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"text":
|
||||||
|
{
|
||||||
|
"fontfamily":"MS Shell Dlg 2",
|
||||||
|
"pixelsize":21,
|
||||||
|
"text":"Follow Player - Camera will start following the player if doesn't do this already",
|
||||||
|
"wrap":true
|
||||||
|
},
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":315.438,
|
||||||
|
"x":64.7309301350722,
|
||||||
|
"y":256.224715416861
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":30.8202477876106,
|
||||||
|
"id":8,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"text":
|
||||||
|
{
|
||||||
|
"fontfamily":"MS Shell Dlg 2",
|
||||||
|
"pixelsize":21,
|
||||||
|
"text":"x: 16 y: 16",
|
||||||
|
"wrap":true
|
||||||
|
},
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":111.991330228225,
|
||||||
|
"x":39.0206367023754,
|
||||||
|
"y":2.47529762459247
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":30.8202,
|
||||||
|
"id":9,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"text":
|
||||||
|
{
|
||||||
|
"fontfamily":"MS Shell Dlg 2",
|
||||||
|
"pixelsize":21,
|
||||||
|
"text":"x: 464 y: 432",
|
||||||
|
"wrap":true
|
||||||
|
},
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":149.997520726595,
|
||||||
|
"x":483.920662086633,
|
||||||
|
"y":417.193532976246
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":113.333333333333,
|
||||||
|
"id":10,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"text":
|
||||||
|
{
|
||||||
|
"fontfamily":"MS Shell Dlg 2",
|
||||||
|
"pixelsize":21,
|
||||||
|
"text":"Top: 256\/512 Center: 496\/655 Width: 480 Height: 286",
|
||||||
|
"wrap":true
|
||||||
|
},
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":172,
|
||||||
|
"x":256,
|
||||||
|
"y":512
|
||||||
|
}],
|
||||||
|
"opacity":1,
|
||||||
|
"type":"objectgroup",
|
||||||
|
"visible":true,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
}],
|
||||||
|
"nextlayerid":7,
|
||||||
|
"nextobjectid":11,
|
||||||
|
"orientation":"orthogonal",
|
||||||
|
"properties":[
|
||||||
|
{
|
||||||
|
"name":"openWebsite",
|
||||||
|
"type":"string",
|
||||||
|
"value":"script.php"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"openWebsiteAllowApi",
|
||||||
|
"type":"bool",
|
||||||
|
"value":true
|
||||||
|
}],
|
||||||
|
"renderorder":"right-down",
|
||||||
|
"tiledversion":"1.7.2",
|
||||||
|
"tileheight":32,
|
||||||
|
"tilesets":[
|
||||||
|
{
|
||||||
|
"columns":11,
|
||||||
|
"firstgid":1,
|
||||||
|
"image":"..\/tileset1.png",
|
||||||
|
"imageheight":352,
|
||||||
|
"imagewidth":352,
|
||||||
|
"margin":0,
|
||||||
|
"name":"tileset1",
|
||||||
|
"spacing":0,
|
||||||
|
"tilecount":121,
|
||||||
|
"tileheight":32,
|
||||||
|
"tilewidth":32
|
||||||
|
}],
|
||||||
|
"tilewidth":32,
|
||||||
|
"type":"map",
|
||||||
|
"version":"1.6",
|
||||||
|
"width":30
|
||||||
|
}
|
50
maps/tests/ActionsMenu/script.php
Normal file
50
maps/tests/ActionsMenu/script.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<script src="<?php echo $_SERVER["FRONT_URL"] ?>/iframe_api.js"></script>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
//@ts-ignore
|
||||||
|
WA.camera.onCameraUpdate((worldView) => console.log(worldView));
|
||||||
|
WA.onInit().then(() => {
|
||||||
|
console.log('After WA init');
|
||||||
|
const setCameraButton = document.getElementById('setCameraButton');
|
||||||
|
const followPlayerButton = document.getElementById('followPlayerButton');
|
||||||
|
const xField = document.getElementById('x');
|
||||||
|
const yField = document.getElementById('y');
|
||||||
|
const widthField = document.getElementById('width');
|
||||||
|
const heightField = document.getElementById('height');
|
||||||
|
const smoothField = document.getElementById('smooth');
|
||||||
|
const lockField = document.getElementById('lock');
|
||||||
|
|
||||||
|
setCameraButton.addEventListener('click', () => {
|
||||||
|
WA.camera.set(
|
||||||
|
parseInt(xField.value),
|
||||||
|
parseInt(yField.value),
|
||||||
|
widthField.value ? parseInt(widthField.value) : undefined,
|
||||||
|
heightField.value ? parseInt(heightField.value) : undefined,
|
||||||
|
lockField.checked,
|
||||||
|
smoothField.checked,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
followPlayerButton.addEventListener('click', () => {
|
||||||
|
WA.camera.followPlayer(smoothField.checked);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
X: <input type="text" id="x" value="496" /><br/>
|
||||||
|
Y: <input type="text" id="y" value="655" /><br/>
|
||||||
|
width: <input type="text" id="width" value="480" /><br/>
|
||||||
|
height: <input type="text" id="height" value="286" /><br/>
|
||||||
|
Smooth: <input type="checkbox" id="smooth" value=1 /><br/>
|
||||||
|
Lock: <input type="checkbox" id="lock" value=1 /><br/>
|
||||||
|
|
||||||
|
<button id="setCameraButton">Set Camera</button>
|
||||||
|
<button id="followPlayerButton">Follow Player</button>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -137,6 +137,17 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<h2>Game features</h2>
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="radio" name="test-iframe-api"> Success <input type="radio" name="test-iframe-api"> Failure <input type="radio" name="test-iframe-api" checked> Pending
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="#" class="testLink" data-testmap="ActionsMenu/actions_menu_test.json" target="_blank">Test adding actions to player's ActionsMenu dynamically</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
<h2>Iframe API</h2>
|
<h2>Iframe API</h2>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user