diff --git a/CHANGELOG.md b/CHANGELOG.md index 204455df..bfc7778f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ - Use `WA.state.[any variable]: unknown` to access directly any variable (this is a shortcut to using `WA.state.loadVariable` and `WA.state.saveVariable`) - Users blocking now relies on UUID rather than ID. A blocked user that leaves a room and comes back will stay blocked. - The text chat was redesigned to be prettier and to use more features : - - The chat is now persistent bewteen discussions and always accesible + - The chat is now persistent between discussions and always accessible - The chat now tracks incoming and outcoming users in your conversation - The chat allows your to see the visit card of users - You can close the chat window with the escape key diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 491dd4af..e907fcb7 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -104,6 +104,15 @@ export class GameRoom { public getUserById(id: number): User | undefined { return this.users.get(id); } + public getUsersByUuid(uuid: string): User[] { + const userList: User[] = []; + for (const user of this.users.values()) { + if (user.uuid === uuid) { + userList.push(user); + } + } + return userList; + } public join(socket: UserSocket, joinRoomMessage: JoinRoomMessage): User { const positionMessage = joinRoomMessage.getPositionmessage(); diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index c34c1ef1..4f911637 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -21,7 +21,7 @@ interface ZoneDescriptor { } export class PositionNotifier { - // TODO: we need a way to clean the zones if noone is in the zone and noone listening (to free memory!) + // TODO: we need a way to clean the zones if no one is in the zone and no one listening (to free memory!) private zones: Zone[][] = []; diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index 3eef30e1..8dbde018 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -57,7 +57,7 @@ const roomManager: IRoomManagerServer = { room = gameRoom; user = myUser; } else { - //Connexion may have been closed before the init was finished, so we have to manually disconnect the user. + //Connection may have been closed before the init was finished, so we have to manually disconnect the user. socketManager.leaveRoom(gameRoom, myUser); } }) diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 2b8efc9b..78761732 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -701,8 +701,8 @@ export class SocketManager { return; } - const recipient = room.getUserByUuid(recipientUuid); - if (recipient === undefined) { + const recipients = room.getUsersByUuid(recipientUuid); + if (recipients.length === 0) { console.error( "In sendAdminMessage, could not find user with id '" + recipientUuid + @@ -711,14 +711,16 @@ export class SocketManager { return; } - const sendUserMessage = new SendUserMessage(); - sendUserMessage.setMessage(message); - sendUserMessage.setType("ban"); //todo: is the type correct? + for (const recipient of recipients) { + const sendUserMessage = new SendUserMessage(); + sendUserMessage.setMessage(message); + sendUserMessage.setType("ban"); //todo: is the type correct? - const serverToClientMessage = new ServerToClientMessage(); - serverToClientMessage.setSendusermessage(sendUserMessage); + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setSendusermessage(sendUserMessage); - recipient.socket.write(serverToClientMessage); + recipient.socket.write(serverToClientMessage); + } } public async banUser(roomId: string, recipientUuid: string, message: string): Promise { @@ -732,8 +734,8 @@ export class SocketManager { return; } - const recipient = room.getUserByUuid(recipientUuid); - if (recipient === undefined) { + const recipients = room.getUsersByUuid(recipientUuid); + if (recipients.length === 0) { console.error( "In banUser, could not find user with id '" + recipientUuid + @@ -742,19 +744,21 @@ export class SocketManager { return; } - // Let's leave the room now. - room.leave(recipient); + for (const recipient of recipients) { + // Let's leave the room now. + room.leave(recipient); - const banUserMessage = new BanUserMessage(); - banUserMessage.setMessage(message); - banUserMessage.setType("banned"); + const banUserMessage = new BanUserMessage(); + banUserMessage.setMessage(message); + banUserMessage.setType("banned"); - const serverToClientMessage = new ServerToClientMessage(); - serverToClientMessage.setBanusermessage(banUserMessage); + const serverToClientMessage = new ServerToClientMessage(); + serverToClientMessage.setBanusermessage(banUserMessage); - // Let's close the connection when the user is banned. - recipient.socket.write(serverToClientMessage); - recipient.socket.end(); + // Let's close the connection when the user is banned. + recipient.socket.write(serverToClientMessage); + recipient.socket.end(); + } } async sendAdminRoomMessage(roomId: string, message: string, type: string) { diff --git a/docs/maps/text.md b/docs/maps/text.md new file mode 100644 index 00000000..df3b2660 --- /dev/null +++ b/docs/maps/text.md @@ -0,0 +1,35 @@ +{.section-title.accent.text-primary} +# Writing text on a map + +## Solution 1: design a specific tileset (recommended) + +If you want to write some text on a map, our recommendation is to create a tileset that contains +your text. You will obtain the most pleasant graphical result with this result, since you will be able +to control the fonts you use, and you will be able to disable the antialiasing of the font to get a +"crispy" result easily. + +## Solution 2: using a "text" object in Tiled + +On "object" layers, Tiled has support for "Text" objects. You can use these objects to add some +text on your map. + +WorkAdventure will do its best to display the text properly. However, you need to know that: + +- Tiled displays your system fonts. +- Computers have different sets of fonts. Therefore, browsers never rely on system fonts +- Which means if you select a font in Tiled, it is quite unlikely it will render properly in WorkAdventure + +To circumvent this problem, in your text object in Tiled, you can add an additional property: `font-family`. + +The `font-family` property can contain any "web-font" that can be loaded by your browser. + +{.alert.alert-info} +**Pro-tip:** By default, WorkAdventure uses the **'"Press Start 2P"'** font, which is a great pixelated +font that has support for a variety of accents. It renders great when used at *8px* size. + +
+
+ +
The "font-family" property
+
+
diff --git a/docs/maps/wa-maps.md b/docs/maps/wa-maps.md index d7a349c5..0eb94dbf 100644 --- a/docs/maps/wa-maps.md +++ b/docs/maps/wa-maps.md @@ -56,7 +56,7 @@ A few things to notice: ## Building walls and "collidable" areas -By default, the characters can traverse any tiles. If you want to prevent your characeter from going through a tile (like a wall or a desktop), you must make this tile "collidable". You can do this by settings the `collides` property on a given tile. +By default, the characters can traverse any tiles. If you want to prevent your character from going through a tile (like a wall or a desktop), you must make this tile "collidable". You can do this by settings the `collides` property on a given tile. To make a tile "collidable", you should: diff --git a/front/dist/index.tmpl.html b/front/dist/index.tmpl.html index 30ea8353..187e513a 100644 --- a/front/dist/index.tmpl.html +++ b/front/dist/index.tmpl.html @@ -34,6 +34,7 @@ WorkAdventure +
diff --git a/front/dist/resources/service-worker.html b/front/dist/resources/service-worker.html new file mode 100644 index 00000000..45615b1a --- /dev/null +++ b/front/dist/resources/service-worker.html @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + WorkAdventure PWA + + + + + WorkAdventure logo +

Charging your workspace ...

+ + + \ No newline at end of file diff --git a/front/dist/resources/service-worker.js b/front/dist/resources/service-worker.js index e496f7fc..d9509b6f 100644 --- a/front/dist/resources/service-worker.js +++ b/front/dist/resources/service-worker.js @@ -48,6 +48,14 @@ self.addEventListener('fetch', function(event) { ); }); -self.addEventListener('activate', function(event) { - //TODO activate service worker +self.addEventListener('wait', function(event) { + //TODO wait +}); + +self.addEventListener('update', function(event) { + //TODO update +}); + +self.addEventListener('beforeinstallprompt', (e) => { + //TODO change prompt }); \ No newline at end of file diff --git a/front/dist/static/images/favicons/manifest.json b/front/dist/static/images/favicons/manifest.json index 30d08769..9f9e9af1 100644 --- a/front/dist/static/images/favicons/manifest.json +++ b/front/dist/static/images/favicons/manifest.json @@ -128,11 +128,12 @@ "type": "image\/png" } ], - "start_url": "/", + "start_url": "/resources/service-worker.html", "background_color": "#000000", "display_override": ["window-control-overlay", "minimal-ui"], "display": "standalone", - "scope": "/", + "orientation": "portrait-primary", + "scope": "/resources/", "lang": "en", "theme_color": "#000000", "shortcuts": [ diff --git a/front/src/Components/Chat/Chat.svelte b/front/src/Components/Chat/Chat.svelte index e39d1a59..a636205b 100644 --- a/front/src/Components/Chat/Chat.svelte +++ b/front/src/Components/Chat/Chat.svelte @@ -3,9 +3,12 @@ import { chatMessagesStore, chatVisibilityStore } from "../../Stores/ChatStore"; import ChatMessageForm from './ChatMessageForm.svelte'; import ChatElement from './ChatElement.svelte'; - import { afterUpdate, beforeUpdate } from "svelte"; + import {afterUpdate, beforeUpdate} from "svelte"; + import {HtmlUtils} from "../../WebRtc/HtmlUtils"; let listDom: HTMLElement; + let chatWindowElement: HTMLElement; + let handleFormBlur: { blur():void }; let autoscroll: boolean; beforeUpdate(() => { @@ -16,6 +19,12 @@ if (autoscroll) listDom.scrollTo(0, listDom.scrollHeight); }); + function onClick(event: MouseEvent) { + if (HtmlUtils.isClickedOutside(event, chatWindowElement)) { + handleFormBlur.blur(); + } + } + function closeChat() { chatVisibilityStore.set(false); } @@ -26,10 +35,10 @@ } - + -