Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
New Release 06/02/2024 (workadventure#3718)
Browse files Browse the repository at this point in the history
# Changes
2 new features developed and in beta test 🔥

## Room list
### Play
 - Create component to show the room list
 - Create API to get the room list from pusher and map storage
 - Hydrate room list to usable map object

### Map storage
Inject MapListService service into the MapManager. The service profit to update:
 - WAM description to return the number of area and entity to exploration mode;
 - Update name, description or picture from the map editor;

## Explorer mode
### Play
- unlock the following user camera to move on the map and discorder the room,
- create a search mode. The user can search an item (zone or object) put by the map editor,
- item details: when the 478156 click the item detail, the information like interaction, name, image, description… is displayed,

### Test
- create test to put items on the room and use search explorer mode to find it.
  • Loading branch information
gparant authored Feb 16, 2024
1 parent 43503b1 commit 8e21dad
Show file tree
Hide file tree
Showing 91 changed files with 3,222 additions and 442 deletions.
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ services:
ADMIN_API_TOKEN: "$ADMIN_API_TOKEN"
API_URL: back:50051
DISABLE_ANONYMOUS: $DISABLE_ANONYMOUS
#Map editor
PUBLIC_MAP_STORAGE_URL: "http://map-storage.workadventure.localhost"
INTERNAL_MAP_STORAGE_URL: "http://map-storage:3000"
ENABLE_OPENAPI_ENDPOINT: "true"
Expand Down
160 changes: 156 additions & 4 deletions docs/schema/1.0/wam.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,36 @@
"type"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"id": {
"$ref": "#/definitions/WAMFileFormat/properties/entities/additionalProperties/properties/properties/items/anyOf/0/properties/id"
},
"buttonLabel": {
"$ref": "#/definitions/WAMFileFormat/properties/entities/additionalProperties/properties/properties/items/anyOf/0/properties/buttonLabel"
},
"hideButtonLabel": {
"$ref": "#/definitions/WAMFileFormat/properties/entities/additionalProperties/properties/properties/items/anyOf/0/properties/hideButtonLabel"
},
"type": {
"type": "string",
"const": "entityDescriptionProperties"
},
"description": {
"type": "string"
},
"searchable": {
"type": "boolean",
"default": false
}
},
"required": [
"id",
"type"
],
"additionalProperties": false
}
]
}
Expand Down Expand Up @@ -442,6 +472,36 @@
"speakerZoneName"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"id": {
"$ref": "#/definitions/WAMFileFormat/properties/entities/additionalProperties/properties/properties/items/anyOf/0/properties/id"
},
"buttonLabel": {
"$ref": "#/definitions/WAMFileFormat/properties/entities/additionalProperties/properties/properties/items/anyOf/0/properties/buttonLabel"
},
"hideButtonLabel": {
"$ref": "#/definitions/WAMFileFormat/properties/entities/additionalProperties/properties/properties/items/anyOf/0/properties/hideButtonLabel"
},
"type": {
"type": "string",
"const": "areaDescriptionProperties"
},
"description": {
"type": "string"
},
"searchable": {
"type": "boolean",
"default": false
}
},
"required": [
"id",
"type"
],
"additionalProperties": false
}
]
}
Expand Down Expand Up @@ -520,20 +580,112 @@
"type": "object",
"properties": {
"name": {
"type": "string",
"anyOf": [
{
"anyOf": [
{
"not": {}
},
{
"type": "string"
}
]
},
{
"type": "null"
}
],
"description": "The name of the map."
},
"description": {
"type": "string",
"anyOf": [
{
"anyOf": [
{
"not": {}
},
{
"type": "string"
}
]
},
{
"type": "null"
}
],
"description": "A description of the map. Can be used in social networks when sharing a link to the map."
},
"copyright": {
"type": "string",
"anyOf": [
{
"anyOf": [
{
"not": {}
},
{
"type": "string"
}
]
},
{
"type": "null"
}
],
"description": "Copyright notice for this map. Can be a link to a license. Parts of this map like tilesets or images can have their own copyright."
},
"thumbnail": {
"type": "string",
"anyOf": [
{
"anyOf": [
{
"not": {}
},
{
"type": "string"
}
]
},
{
"type": "null"
}
],
"description": "URL to a thumbnail image. This image will be used in social networks when sharing a link to the map."
},
"areasSearchable": {
"anyOf": [
{
"anyOf": [
{
"not": {}
},
{
"type": "number"
}
]
},
{
"type": "null"
}
],
"description": "Number of areas define as searchable by the map editor for the exploration mode."
},
"entitiesSearchable": {
"anyOf": [
{
"anyOf": [
{
"not": {}
},
{
"type": "number"
}
]
},
{
"type": "null"
}
],
"description": "Number of entities define as searchable by the map editor for the exploration mode."
}
},
"additionalProperties": false,
Expand Down
3 changes: 2 additions & 1 deletion libs/map-editor/src/Commands/Command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { v4 as uuidv4 } from "uuid";
import { WAMFileFormat } from "../types";

export abstract class Command {
public readonly commandId: string;
Expand All @@ -7,6 +8,6 @@ export abstract class Command {
this.commandId = commandId ?? uuidv4();
}

public abstract execute(): Promise<void>;
public abstract execute(): Promise<void | undefined | WAMFileFormat>;
//public abstract undo(): Promise<void>;
}
6 changes: 3 additions & 3 deletions libs/map-editor/src/Commands/Entity/UpdateEntityCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { WAMEntityData } from "../../types";
import type { WAMEntityData, WAMFileFormat } from "../../types";
import type { GameMap } from "../../GameMap/GameMap";
import { Command } from "../Command";

Expand Down Expand Up @@ -29,10 +29,10 @@ export class UpdateEntityCommand extends Command {
this.newConfig = structuredClone(dataToModify);
}

public execute(): Promise<void> {
public execute(): Promise<undefined | WAMFileFormat> {
if (!this.gameMap.getGameMapEntities()?.updateEntity(this.entityId, this.newConfig)) {
throw new Error(`MapEditorError: Could not execute UpdateEntity Command. Entity ID: ${this.entityId}`);
}
return Promise.resolve();
return Promise.resolve(this.gameMap.getGameMapEntities()?.wamFile);
}
}
34 changes: 34 additions & 0 deletions libs/map-editor/src/Commands/WAM/UpdateWAMMetadataCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { ModifiyWAMMetadataMessage } from "@workadventure/messages";
import { WAMFileFormat } from "../../types";
import { Command } from "../Command";

export class UpdateWAMMetadataCommand extends Command {
constructor(
protected wam: WAMFileFormat,
protected modifiyWAMMetadataMessage: ModifiyWAMMetadataMessage,
id?: string
) {
super(id);
}

execute(): Promise<WAMFileFormat> {
if (!this.wam.metadata) {
this.wam.metadata = {};
}
this.wam.metadata.name = this.modifiyWAMMetadataMessage.name;
this.wam.metadata.description = this.modifiyWAMMetadataMessage.description;
this.wam.metadata.thumbnail = this.modifiyWAMMetadataMessage.thumbnail;
this.wam.metadata.copyright = this.modifiyWAMMetadataMessage.copyright;

if (!this.wam.vendor) {
this.wam.vendor = {
tags: Array<string>(),
};
}
(this.wam.vendor as { tags: Array<string> }).tags =
this.modifiyWAMMetadataMessage.tags && this.modifiyWAMMetadataMessage.tags.length > 0
? this.modifiyWAMMetadataMessage.tags.split(",")
: [];
return Promise.resolve(this.wam);
}
}
4 changes: 4 additions & 0 deletions libs/map-editor/src/GameMap/GameMapEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ export class GameMapEntities {
public getEntities(): Record<string, WAMEntityData> {
return this.wam.entities;
}

get wamFile(): WAMFileFormat {
return this.wam;
}
}
1 change: 1 addition & 0 deletions libs/map-editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./Commands/Entity/UpdateEntityCommand";
export * from "./Commands/Entity/CreateEntityCommand";
export * from "./Commands/Entity/DeleteEntityCommand";
export * from "./Commands/WAM/UpdateWAMSettingCommand";
export * from "./Commands/WAM/UpdateWAMMetadataCommand";
export * from "./Commands/Command";
// MapFetcher is not exported because it is using Node imports that are not available in the browser
//export * from "./MapFetcher";
Expand Down
32 changes: 31 additions & 1 deletion libs/map-editor/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ export const ListenerMegaphonePropertyData = PropertyBase.extend({
chatEnabled: z.boolean().default(false),
});

export const EntityDescriptionPropertyData = PropertyBase.extend({
type: z.literal("entityDescriptionProperties"),
description: z.string().optional(),
searchable: z.boolean().default(false),
});

export const AreaDescriptionPropertyData = PropertyBase.extend({
type: z.literal("areaDescriptionProperties"),
description: z.string().optional(),
searchable: z.boolean().default(false),
});

export const AreaDataProperty = z.discriminatedUnion("type", [
StartPropertyData,
ExitPropertyData,
Expand All @@ -116,6 +128,7 @@ export const AreaDataProperty = z.discriminatedUnion("type", [
OpenWebsitePropertyData,
SpeakerMegaphonePropertyData,
ListenerMegaphonePropertyData,
AreaDescriptionPropertyData,
]);

export const AreaDataProperties = z.array(AreaDataProperty);
Expand All @@ -142,6 +155,7 @@ export const EntityDataProperty = z.discriminatedUnion("type", [
JitsiRoomPropertyData,
PlayAudioPropertyData,
OpenWebsitePropertyData,
EntityDescriptionPropertyData,
]);

export const EntityDataProperties = z.array(EntityDataProperty);
Expand Down Expand Up @@ -187,24 +201,38 @@ export const WAMEntityData = EntityData.omit({ prefab: true, id: true });
export type WAMEntityData = z.infer<typeof WAMEntityData>;

export const WAMMetadata = z.object({
name: z.string().optional().describe("The name of the map."),
name: z.string().optional().nullable().describe("The name of the map."),
description: z
.string()
.optional()
.nullable()
.describe("A description of the map. Can be used in social networks when sharing a link to the map."),
copyright: z
.string()
.optional()
.nullable()
.describe(
"Copyright notice for this map. Can be a link to a license. Parts of this map like tilesets or images can have their own copyright."
),
thumbnail: z
.string()
.optional()
.nullable()
.describe(
"URL to a thumbnail image. This image will be used in social networks when sharing a link to the map."
),
areasSearchable: z
.number()
.optional()
.nullable()
.describe("Number of areas define as searchable by the map editor for the exploration mode."),
entitiesSearchable: z
.number()
.optional()
.nullable()
.describe("Number of entities define as searchable by the map editor for the exploration mode."),
});
export type WAMMetadata = z.infer<typeof WAMMetadata>;

export const WAMVendor = z
.unknown()
Expand Down Expand Up @@ -288,6 +316,8 @@ export type MapsCacheSingleMapFormat = z.infer<typeof MapsCacheSingleMapFormat>;
export type MapsCacheFileFormat = z.infer<typeof MapsCacheFileFormat>;
export type SpeakerMegaphonePropertyData = z.infer<typeof SpeakerMegaphonePropertyData>;
export type ListenerMegaphonePropertyData = z.infer<typeof ListenerMegaphonePropertyData>;
export type EntityDescriptionPropertyData = z.infer<typeof EntityDescriptionPropertyData>;
export type AreaDescriptionPropertyData = z.infer<typeof AreaDescriptionPropertyData>;

export enum GameMapProperties {
ALLOW_API = "allowApi",
Expand Down
Loading

0 comments on commit 8e21dad

Please sign in to comment.