diff --git a/docs/maps/entry-exit.md b/docs/maps/entry-exit.md index bd194138..6f98af93 100644 --- a/docs/maps/entry-exit.md +++ b/docs/maps/entry-exit.md @@ -1,7 +1,7 @@ {.section-title.accent.text-primary} # Entries and exits -https://www.youtube.com/watch?v=MuhVgu8H7U0 +[Building your map - Defined entries and exits](https://www.youtube.com/watch?v=MuhVgu8H7U0) ## Defining a default entry point diff --git a/docs/maps/index.md b/docs/maps/index.md index 7f5e7867..d018dd3c 100644 --- a/docs/maps/index.md +++ b/docs/maps/index.md @@ -14,7 +14,7 @@ WorkAdventure comes with a "map starter kit" that we recommend using to start de {.alert.alert-info} If you are looking to host your maps on your own webserver, be sure to read the [Self-hosting your map](hosting.md) guide. -[](https://www.youtube.com/watch?v=lu1IZgBJJD4) +[Building your map - Create your map](https://www.youtube.com/watch?v=lu1IZgBJJD4) ## Getting started diff --git a/docs/maps/meeting-rooms.md b/docs/maps/meeting-rooms.md index 719e0630..88db1621 100644 --- a/docs/maps/meeting-rooms.md +++ b/docs/maps/meeting-rooms.md @@ -1,7 +1,7 @@ {.section-title.accent.text-primary} # Meeting rooms -https://www.youtube.com/watch?v=cN9VMWHN0eo +[Building your map - Meeting room](https://www.youtube.com/watch?v=cN9VMWHN0eo) ## Opening a Jitsi meet when walking on the map diff --git a/docs/maps/menu.php b/docs/maps/menu.php index 9fb3428f..0bf0a7f9 100644 --- a/docs/maps/menu.php +++ b/docs/maps/menu.php @@ -5,64 +5,75 @@ $extraUtilsMenu = require __DIR__.'/../../scripting_api_extra_doc/menu_functions return [ [ 'title' => 'Getting started', - 'url' => '/map-building', - 'markdown' => 'maps.index' + 'url' => '/map-building/', + 'markdown' => 'maps.index', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/index.md', ], [ 'title' => 'WorkAdventure maps', - 'url' => '/map-building/wa-maps', - 'markdown' => 'maps.wa-maps' + 'url' => '/map-building/wa-maps.md', + 'markdown' => 'maps.wa-maps', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/wa-maps.md', ], [ 'title' => 'Entries and exits', 'url' => '/map-building/entry-exit.md', - 'markdown' => 'maps.entry-exit' + 'markdown' => 'maps.entry-exit', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/entry-exit.md', ], [ 'title' => 'Opening a website', 'url' => '/map-building/opening-a-website.md', - 'markdown' => 'maps.opening-a-website' + 'markdown' => 'maps.opening-a-website', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/opening-a-website.md', ], [ 'title' => 'Meeting rooms', 'url' => '/map-building/meeting-rooms.md', - 'markdown' => 'maps.meeting-rooms' + 'markdown' => 'maps.meeting-rooms', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/meeting-rooms.md', ], [ 'title' => 'Special zones', 'url' => '/map-building/special-zones.md', - 'markdown' => 'maps.special-zones' + 'markdown' => 'maps.special-zones', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/special-zones.md', ], [ 'title' => 'Animations', 'url' => '/map-building/animations.md', - 'markdown' => 'maps.animations' + 'markdown' => 'maps.animations', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/animations.md', ], [ 'title' => 'Integrated websites', 'url' => '/map-building/website-in-map.md', - 'markdown' => 'maps.website-in-map' + 'markdown' => 'maps.website-in-map', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/website-in-map.md', ], [ 'title' => 'Variables', 'url' => '/map-building/variables.md', - 'markdown' => 'maps.variables' + 'markdown' => 'maps.variables', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/variables.md', ], [ 'title' => 'Self-hosting your map', 'url' => '/map-building/hosting.md', - 'markdown' => 'maps.hosting' + 'markdown' => 'maps.hosting', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/hosting.md', ], $extraMenu, [ 'title' => 'Scripting maps', - 'url' => '/map-building/scripting', + 'url' => '/map-building/scripting.md', 'markdown' => 'maps.scripting', 'children' => [ [ 'title' => 'Using Typescript', 'url' => '/map-building/using-typescript.md', - 'markdown' => 'maps.using-typescript' + 'markdown' => 'maps.using-typescript', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/using-typescript.md', ], [ 'title' => 'API Reference', @@ -74,51 +85,61 @@ return [ 'title' => 'Initialization', 'url' => '/map-building/api-start.md', 'markdown' => 'maps.api-start', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-start.md', ], [ 'title' => 'Navigation', 'url' => '/map-building/api-nav.md', 'markdown' => 'maps.api-nav', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-nav.md', ], [ 'title' => 'Chat', 'url' => '/map-building/api-chat.md', 'markdown' => 'maps.api-chat', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-chat.md', ], [ 'title' => 'Room', 'url' => '/map-building/api-room.md', 'markdown' => 'maps.api-room', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-room.md', ], [ 'title' => 'State', 'url' => '/map-building/api-state.md', 'markdown' => 'maps.api-state', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-state.md', ], [ 'title' => 'Player', 'url' => '/map-building/api-player.md', 'markdown' => 'maps.api-player', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-player.md', ], [ 'title' => 'UI', 'url' => '/map-building/api-ui.md', 'markdown' => 'maps.api-ui', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-ui.md', ], [ 'title' => 'Sound', 'url' => '/map-building/api-sound.md', 'markdown' => 'maps.api-sound', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-sound.md', ], [ 'title' => 'Controls', 'url' => '/map-building/api-controls.md', 'markdown' => 'maps.api-controls', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-controls.md', ], [ 'title' => 'Deprecated', 'url' => '/map-building/api-deprecated.md', 'markdown' => 'maps.api-deprecated', + 'editUrl' => 'https://github.com/thecodingmachine/workadventure/edit/develop/docs/maps/api-deprecated.md', ], ] ], diff --git a/docs/maps/opening-a-website.md b/docs/maps/opening-a-website.md index 2ca54281..ec6c82d4 100644 --- a/docs/maps/opening-a-website.md +++ b/docs/maps/opening-a-website.md @@ -1,7 +1,7 @@ {.section-title.accent.text-primary} # Opening a website when walking on the map -https://www.youtube.com/watch?v=Me8cu5lLN3A +[Building your map - Opening a website](https://www.youtube.com/watch?v=Me8cu5lLN3A) ## The openWebsite property diff --git a/docs/maps/special-zones.md b/docs/maps/special-zones.md index fff4e730..30ebebab 100644 --- a/docs/maps/special-zones.md +++ b/docs/maps/special-zones.md @@ -3,7 +3,7 @@ ## Making a "silent" zone -https://www.youtube.com/watch?v=z7XLo06o-ow +[Building your map - Special zones](https://www.youtube.com/watch?v=z7XLo06o-ow) On your map, you can define special silent zones where nobody is allowed to talk. In these zones, users will not speak to each others, even if they are next to each others. diff --git a/front/src/Components/Menu/CreateMapSubMenu.svelte b/front/src/Components/Menu/CreateMapSubMenu.svelte index 6cce71ac..53399681 100644 --- a/front/src/Components/Menu/CreateMapSubMenu.svelte +++ b/front/src/Components/Menu/CreateMapSubMenu.svelte @@ -6,7 +6,7 @@ } function goToBuildingMap() { - const sparkHost = "https://workadventu.re/map-building"; + const sparkHost = "https://workadventu.re/map-building/"; window.open(sparkHost, "_blank"); } @@ -48,4 +48,4 @@ } } - \ No newline at end of file + diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index dc094a06..87efc804 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -137,17 +137,6 @@ class ConnectionManager { connexionType === GameConnexionTypes.empty ) { this.authToken = localUserStore.getAuthToken(); - //todo: add here some kind of warning if authToken has expired. - if (!this.authToken) { - await this.anonymousLogin(); - } else { - try { - await this.checkAuthUserConnexion(); - } catch (err) { - console.error(err); - } - } - this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null let roomPath: string; if (connexionType === GameConnexionTypes.empty) { @@ -172,7 +161,21 @@ class ConnectionManager { } //get detail map for anonymous login and set texture in local storage + //before set token of user we must load room and all information. For example the mandatory authentication could be require on current room this._currentRoom = await Room.createRoom(new URL(roomPath)); + + //todo: add here some kind of warning if authToken has expired. + if (!this.authToken && !this._currentRoom.authenticationMandatory) { + await this.anonymousLogin(); + } else { + try { + await this.checkAuthUserConnexion(); + } catch (err) { + console.error(err); + } + } + this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null + if (this._currentRoom.textures != undefined && this._currentRoom.textures.length > 0) { //check if texture was changed if (this.localUser.textures.length === 0) { diff --git a/front/src/Phaser/Game/StartPositionCalculator.ts b/front/src/Phaser/Game/StartPositionCalculator.ts index 0827b623..a5f96314 100644 --- a/front/src/Phaser/Game/StartPositionCalculator.ts +++ b/front/src/Phaser/Game/StartPositionCalculator.ts @@ -51,19 +51,28 @@ export class StartPositionCalculator { if (!selectedOrDefaultLayer) { selectedOrDefaultLayer = defaultStartLayerName; } + let foundLayer: ITiledMapLayer | null = null; for (const layer of this.gameMap.flatLayers) { + if (layer.type !== "tilelayer") continue; + //we want to prioritize the selectedLayer other the start layer if ( - (selectedOrDefaultLayer === layer.name || layer.name.endsWith("/" + selectedOrDefaultLayer)) && + (selectedOrDefaultLayer === layer.name || + selectedOrDefaultLayer === `#${layer.name}` || + layer.name.endsWith("/" + selectedOrDefaultLayer)) && layer.type === "tilelayer" && (selectedOrDefaultLayer === defaultStartLayerName || this.isStartLayer(layer)) ) { - const startPosition = this.startUser(layer, selectedLayer); - this.startPosition = { - x: startPosition.x + this.mapFile.tilewidth / 2, - y: startPosition.y + this.mapFile.tileheight / 2, - }; + foundLayer = layer; + break; } } + if (foundLayer) { + const startPosition = this.startUser(foundLayer, selectedLayer); + this.startPosition = { + x: startPosition.x + this.mapFile.tilewidth / 2, + y: startPosition.y + this.mapFile.tileheight / 2, + }; + } } private isStartLayer(layer: ITiledMapLayer): boolean { diff --git a/front/src/Phaser/Login/LoginScene.ts b/front/src/Phaser/Login/LoginScene.ts index 7421934d..6bba0290 100644 --- a/front/src/Phaser/Login/LoginScene.ts +++ b/front/src/Phaser/Login/LoginScene.ts @@ -25,7 +25,7 @@ export class LoginScene extends ResizableScene { if ( localUserStore.getAuthToken() == undefined && gameManager.currentStartedRoom && - gameManager.currentStartedRoom?.authenticationMandatory + gameManager.currentStartedRoom.authenticationMandatory ) { connectionManager.loadOpenIDScreen(); loginSceneVisibleIframeStore.set(true); diff --git a/maps/tests/index.html b/maps/tests/index.html index 3c9538d5..149e2868 100644 --- a/maps/tests/index.html +++ b/maps/tests/index.html @@ -55,6 +55,14 @@ Test start tile (S2) + + + Success Failure Pending + + + Test teleport into the map + + Success Failure Pending diff --git a/maps/tests/start-tile-teleport.json b/maps/tests/start-tile-teleport.json new file mode 100644 index 00000000..269d5ebc --- /dev/null +++ b/maps/tests/start-tile-teleport.json @@ -0,0 +1,166 @@ +{ "compressionlevel":-1, + "height":5, + "infinite":false, + "layers":[ + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":5, + "id":1, + "name":"start", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], + "height":5, + "id":4, + "name":"background", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0], + "height":5, + "id":7, + "name":"S2", + "opacity":1, + "properties":[ + { + "name":"startLayer", + "type":"bool", + "value":true + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":5, + "id":8, + "name":"S1", + "opacity":1, + "properties":[ + { + "name":"startLayer", + "type":"bool", + "value":true + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[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":5, + "id":5, + "name":"floor", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":5, + "id":6, + "name":"exitLayer-toS2", + "opacity":1, + "properties":[ + { + "name":"exitUrl", + "type":"string", + "value":".\/start-tile-teleport.json#S2" + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], + "height":5, + "id":9, + "name":"exitLayer-toS1", + "opacity":1, + "properties":[ + { + "name":"exitUrl", + "type":"string", + "value":".\/start-tile-teleport.json#S1" + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":3, + "name":"floorLayer", + "objects":[ + { + "height":66.6666666666667, + "id":1, + "name":"", + "rotation":0, + "text": + { + "fontfamily":"Sans Serif", + "pixelsize":11, + "text":"Go to X above S1 and teleport on S2\nGo to X above S2 and teleport on S1", + "wrap":true + }, + "type":"", + "visible":true, + "width":155.104166666667, + "x":3.28125, + "y":2.5 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextlayerid":10, + "nextobjectid":2, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.7.2", + "tileheight":32, + "tilesets":[ + { + "columns":2, + "firstgid":1, + "image":"function_tiles.png", + "imageheight":64, + "imagewidth":64, + "margin":0, + "name":"function_tiles", + "spacing":0, + "tilecount":4, + "tileheight":32, + "tilewidth":32 + }], + "tilewidth":32, + "type":"map", + "version":"1.6", + "width":5 +} \ No newline at end of file