diff --git a/backend/src/main/java/fr/zelytra/session/SessionSocket.java b/backend/src/main/java/fr/zelytra/session/SessionSocket.java index 63690cd4..c3022ff8 100644 --- a/backend/src/main/java/fr/zelytra/session/SessionSocket.java +++ b/backend/src/main/java/fr/zelytra/session/SessionSocket.java @@ -185,6 +185,7 @@ private void handleUpdateMessage(Player player) { foundedplayer.setReady(player.isReady()); foundedplayer.setStatus(player.getStatus()); + foundedplayer.setDevice(player.getDevice()); sessionManager.broadcastDataToSession(player.getSessionId(), MessageType.UPDATE, fleet); diff --git a/backend/src/main/java/fr/zelytra/session/player/Player.java b/backend/src/main/java/fr/zelytra/session/player/Player.java index 1cfe85a2..066f1d21 100644 --- a/backend/src/main/java/fr/zelytra/session/player/Player.java +++ b/backend/src/main/java/fr/zelytra/session/player/Player.java @@ -22,6 +22,8 @@ public class Player { private String clientVersion; + private PlayerDevice device; + // Constructor public Player() { } @@ -84,6 +86,14 @@ public void setClientVersion(String clientVersion) { this.clientVersion = clientVersion; } + public PlayerDevice getDevice() { + return device; + } + + public void setDevice(PlayerDevice device) { + this.device = device; + } + @Override public String toString() { return this.username; diff --git a/backend/src/main/java/fr/zelytra/session/player/PlayerDevice.java b/backend/src/main/java/fr/zelytra/session/player/PlayerDevice.java new file mode 100644 index 00000000..da22636e --- /dev/null +++ b/backend/src/main/java/fr/zelytra/session/player/PlayerDevice.java @@ -0,0 +1,7 @@ +package fr.zelytra.session.player; + +public enum PlayerDevice { + XBOX, + PLAYSTATION, + MICROSOFT +} diff --git a/backend/src/test/java/fr/zelytra/session/SessionSocketTest.java b/backend/src/test/java/fr/zelytra/session/SessionSocketTest.java index 4f68b1b2..7b725a02 100644 --- a/backend/src/test/java/fr/zelytra/session/SessionSocketTest.java +++ b/backend/src/test/java/fr/zelytra/session/SessionSocketTest.java @@ -55,17 +55,6 @@ void setup() throws URISyntaxException, DeploymentException, IOException { ContainerProvider.getWebSocketContainer().connectToServer(betterFleetClient, uri); } - @Test - void onOpen_PlayerConnect_PlayerShouldNotBeInTheTimeOutList() throws IOException, InterruptedException, EncodeException { - Player player = new Player(); - player.setUsername("Player 1"); - player.setClientVersion(appVersion); - betterFleetClient.sendMessage(MessageType.CONNECT, player); - - assertTrue(betterFleetClient.getLatch().await(1, TimeUnit.SECONDS)); - assertEquals(1, SessionSocket.sessionTimeoutTasks.size()); - } - @Test void stressTest() throws IOException, InterruptedException, EncodeException, DeploymentException { List fakePlayers = generateFakePlayer(50); diff --git a/webapp/src/App.vue b/webapp/src/App.vue index f1ce024e..c5fe07b7 100644 --- a/webapp/src/App.vue +++ b/webapp/src/App.vue @@ -29,7 +29,7 @@ import {LocalKey} from "@/objects/stores/LocalStore.ts"; import {onMounted, onUnmounted, watch} from "vue"; import FirstLogin from "@/vue/templates/FirstLogin.vue"; import AlertComponent from "@/vue/alert/AlertComponent.vue"; -import {PlayerStates} from "@/objects/Player.ts"; +import {PlayerDevice, PlayerStates} from "@/objects/Player.ts"; import {Fleet} from "@/objects/Fleet.ts"; import {invoke} from "@tauri-apps/api/tauri"; import {RustSotServer} from "@/objects/SotServer.ts"; @@ -74,6 +74,7 @@ onMounted(() => { isReady: false, status: PlayerStates.CLOSED, username: "", + device : PlayerDevice.MICROSOFT }); }); @@ -104,7 +105,7 @@ watch(()=>UserStore.player.countDown, () => { height: 100vh; overflow: hidden; overflow-y: auto; - padding: 7px 10px; + padding: 12px; width: 100%; box-sizing: border-box; position: relative; diff --git a/webapp/src/assets/icons/microsoft.svg b/webapp/src/assets/icons/microsoft.svg new file mode 100644 index 00000000..54eceff1 --- /dev/null +++ b/webapp/src/assets/icons/microsoft.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/webapp/src/assets/icons/playstation.svg b/webapp/src/assets/icons/playstation.svg new file mode 100644 index 00000000..1a06153b --- /dev/null +++ b/webapp/src/assets/icons/playstation.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/webapp/src/assets/icons/xbox.svg b/webapp/src/assets/icons/xbox.svg new file mode 100644 index 00000000..198e3ee3 --- /dev/null +++ b/webapp/src/assets/icons/xbox.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/webapp/src/assets/locales/fr.json b/webapp/src/assets/locales/fr.json index 1ba14c8e..bd0f0f41 100644 --- a/webapp/src/assets/locales/fr.json +++ b/webapp/src/assets/locales/fr.json @@ -62,6 +62,9 @@ }, "appName": "Better Fleet", "config": { + "device": { + "label": "Plateformes" + }, "devmode": "Activer le mode développeur", "lang": { "label": "Langue" @@ -110,6 +113,22 @@ "es": "Español", "fr": "Français" }, + "modal": { + "confirm": { + "launch": { + "cancel": "Annuler", + "confirm": "Levez l'ancre", + "content": "Pas tout les joueurs sont prêt ! Êtes vous sûr de vouloir levez l’ancre ?", + "title": "ATTENTION !" + }, + "leave": { + "cancel": "Annuler", + "confirm": "Quitter la session", + "content": "Êtes vous sûr de vouloir quitter la session ?", + "title": "QUITTER LA SESSION" + } + } + }, "session": { "choice": { "createComment": "Goûte à la liberté de régner sur les flots en pirate !", diff --git a/webapp/src/components/Config.vue b/webapp/src/components/Config.vue index 90f4bf5b..3bca9fd4 100644 --- a/webapp/src/components/Config.vue +++ b/webapp/src/components/Config.vue @@ -33,6 +33,10 @@ :label="t('config.lang.label')" v-model:data="langOptions" /> + @@ -78,12 +82,17 @@ import fr from "@/assets/icons/locales/fr.svg"; import de from "@/assets/icons/locales/de.svg"; import es from "@/assets/icons/locales/es.svg"; import en from "@/assets/icons/locales/en.svg"; +import xbox from "@/assets/icons/xbox.svg"; +import microsoft from "@/assets/icons/microsoft.svg"; +import playstation from "@/assets/icons/playstation.svg"; import {UserStore} from "@/objects/stores/UserStore.ts"; import {onBeforeRouteLeave} from "vue-router"; import {AlertProvider, AlertType} from "@/vue/alert/Alert.ts"; +import {PlayerDevice} from "@/objects/Player.ts"; const {t, availableLocales} = useI18n(); const langOptions = ref({data: []}); +const deviceOptions = ref({data: []}); const devMode = ref(false); const username = ref(UserStore.player.username); const alerts = inject("alertProvider"); @@ -97,6 +106,30 @@ onMounted(() => { }); } + deviceOptions.value.data.push({ + display: "Microsoft", + id: PlayerDevice.MICROSOFT, + image: getDeviceImgUrl('microsoft') + }) + deviceOptions.value.data.push({ + display: "Xbox", + id: PlayerDevice.XBOX, + image: getDeviceImgUrl('xbox') + }) + deviceOptions.value.data.push({ + display: "PlayStation", + id: PlayerDevice.PLAYSTATION, + image: getDeviceImgUrl('playstation') + }) + + if (UserStore.player.device) { + deviceOptions.value.selectedValue = deviceOptions.value.data.filter((x) => + x.id == UserStore.player.device + )[0] + } else { + deviceOptions.value.selectedValue = deviceOptions.value.data[0] + } + if (UserStore.player.lang) { langOptions.value.selectedValue = langOptions.value.data.filter( (x) => x.id == UserStore.player.lang, @@ -110,6 +143,13 @@ watch(langOptions.value, () => { UserStore.setLang(langOptions.value.selectedValue!.id); }); +watch(deviceOptions.value, () => { + UserStore.player.device = deviceOptions.value.selectedValue!.id as PlayerDevice; + if (UserStore.player.fleet && UserStore.player.fleet.sessionId){ + UserStore.player.fleet.updateToSession() + } +}); + onBeforeRouteLeave((_to, _from, next) => { if (username.value.length == 0 || username.value.length >= 16) { if (UserStore.player.countDown) { @@ -145,6 +185,19 @@ function getImgUrl(iconName: string): string { return en; } } + +function getDeviceImgUrl(iconName: string): string { + switch (iconName) { + case "microsoft": + return microsoft; + case "xbox": + return xbox; + case "playstation": + return playstation; + default: + return microsoft; + } +} \ No newline at end of file diff --git a/webapp/src/vue/form/SingleSelect.vue b/webapp/src/vue/form/SingleSelect.vue index 59880deb..0c2bed3e 100644 --- a/webapp/src/vue/form/SingleSelect.vue +++ b/webapp/src/vue/form/SingleSelect.vue @@ -7,7 +7,7 @@