From aad582df7076088e4b6fc8f1f66ea11b56a94555 Mon Sep 17 00:00:00 2001 From: PizZaKatZe Date: Mon, 6 Dec 2021 21:16:53 +0100 Subject: [PATCH 1/2] Display map link in map credits if provided --- docs/maps/wa-maps.md | 8 ++++---- front/src/Components/Menu/AboutRoomSubMenu.svelte | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/maps/wa-maps.md b/docs/maps/wa-maps.md index 70581a57..819d632e 100644 --- a/docs/maps/wa-maps.md +++ b/docs/maps/wa-maps.md @@ -98,13 +98,13 @@ The exception is the "collides" property that can only be set on tiles, but not By setting properties on the map itself, you can help visitors know more about the creators of the map. The following *map* properties are supported: -* `mapName` (string) -* `mapDescription` (string) -* `mapCopyright` (string) +* `mapName` (string): The name of your map +* `mapLink` (string): A link to your map, for example a repository +* `mapDescription` (string): A short description of your map +* `mapCopyright` (string): Copyright notice And *each tileset* can also have a property called `tilesetCopyright` (string). Resulting in a "credit" page in the menu looking like this: ![](images/mapProperties.png){.document-img} - diff --git a/front/src/Components/Menu/AboutRoomSubMenu.svelte b/front/src/Components/Menu/AboutRoomSubMenu.svelte index 666183e0..0fd51ce7 100644 --- a/front/src/Components/Menu/AboutRoomSubMenu.svelte +++ b/front/src/Components/Menu/AboutRoomSubMenu.svelte @@ -8,6 +8,7 @@ let expandedTilesetCopyright = false; let mapName: string = ""; + let mapLink: string = ""; let mapDescription: string = ""; let mapCopyright: string = "The map creator did not declare a copyright for the map."; let tilesetCopyright: string[] = []; @@ -18,6 +19,10 @@ if (propertyName !== undefined && typeof propertyName.value === "string") { mapName = propertyName.value; } + const propertyLink = gameScene.mapFile.properties.find((property) => property.name === "mapLink"); + if (propertyLink !== undefined && typeof propertyLink.value === "string") { + mapLink = propertyLink.value; + } const propertyDescription = gameScene.mapFile.properties.find( (property) => property.name === "mapDescription" ); @@ -48,6 +53,9 @@

{mapName}

{mapDescription}

+ {#if mapLink} +

> link to this map <

+ {/if}

(expandedMapCopyright = !expandedMapCopyright)}> Copyrights of the map

From 80794975aab5f9fbc476e0f8876b1465f56a52fb Mon Sep 17 00:00:00 2001 From: PizZaKatZe Date: Sat, 11 Dec 2021 22:24:28 +0100 Subject: [PATCH 2/2] Add new layer property `audioCopyright` --- docs/maps/wa-maps.md | 3 +- .../Components/Menu/AboutRoomSubMenu.svelte | 32 +++++++++++++++++-- maps/tests/Properties/mapProperties.json | 8 ++++- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/docs/maps/wa-maps.md b/docs/maps/wa-maps.md index 819d632e..6e84a251 100644 --- a/docs/maps/wa-maps.md +++ b/docs/maps/wa-maps.md @@ -103,7 +103,8 @@ The following *map* properties are supported: * `mapDescription` (string): A short description of your map * `mapCopyright` (string): Copyright notice -And *each tileset* can also have a property called `tilesetCopyright` (string). +Each *tileset* can also have a property called `tilesetCopyright` (string). +If you are using audio files in your map, you can declare a layer property `audioCopyright` (string). Resulting in a "credit" page in the menu looking like this: diff --git a/front/src/Components/Menu/AboutRoomSubMenu.svelte b/front/src/Components/Menu/AboutRoomSubMenu.svelte index 0fd51ce7..2bbb4d3c 100644 --- a/front/src/Components/Menu/AboutRoomSubMenu.svelte +++ b/front/src/Components/Menu/AboutRoomSubMenu.svelte @@ -6,12 +6,14 @@ let expandedMapCopyright = false; let expandedTilesetCopyright = false; + let expandedAudioCopyright = false; let mapName: string = ""; let mapLink: string = ""; let mapDescription: string = ""; let mapCopyright: string = "The map creator did not declare a copyright for the map."; let tilesetCopyright: string[] = []; + let audioCopyright: string[] = []; onMount(() => { if (gameScene.mapFile.properties !== undefined) { @@ -41,7 +43,18 @@ (property) => property.name === "tilesetCopyright" ); if (propertyTilesetCopyright !== undefined && typeof propertyTilesetCopyright.value === "string") { - tilesetCopyright = [...tilesetCopyright, propertyTilesetCopyright.value]; //Assignment needed to trigger Svelte's reactivity + // Assignment needed to trigger Svelte's reactivity + tilesetCopyright = [...tilesetCopyright, propertyTilesetCopyright.value]; + } + } + } + + for (const layer of gameScene.mapFile.layers) { + if (layer.type && layer.type === "tilelayer" && layer.properties) { + const propertyAudioCopyright = layer.properties.find((property) => property.name === "audioCopyright"); + if (propertyAudioCopyright !== undefined && typeof propertyAudioCopyright.value === "string") { + // Assignment needed to trigger Svelte's reactivity + audioCopyright = [...audioCopyright, propertyAudioCopyright.value]; } } } @@ -68,8 +81,21 @@

{copyright}

{:else}

- The map creator did not declare a copyright for the tilesets. Warning, This doesn't mean that those - tilesets have no license. + The map creator did not declare a copyright for the tilesets. This doesn't mean that those tilesets + have no license. +

+ {/each} +
+

(expandedAudioCopyright = !expandedAudioCopyright)}> + Copyrights of audio files +

+ diff --git a/maps/tests/Properties/mapProperties.json b/maps/tests/Properties/mapProperties.json index a58c002f..34178e38 100644 --- a/maps/tests/Properties/mapProperties.json +++ b/maps/tests/Properties/mapProperties.json @@ -8,6 +8,12 @@ "id":1, "name":"start", "opacity":1, + "properties":[ + { + "name":"audioCopyright", + "type":"string", + "value":"Copyright 2021 John Doe" + }], "type":"tilelayer", "visible":true, "width":10, @@ -124,4 +130,4 @@ "type":"map", "version":1.4, "width":10 -} \ No newline at end of file +}