diff --git a/public/assets/icons/loading-icon1.svg b/public/assets/icons/loading-icon1.svg new file mode 100644 index 0000000..ea54de3 --- /dev/null +++ b/public/assets/icons/loading-icon1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/assets/icons/loading-icon2.svg b/public/assets/icons/loading-icon2.svg new file mode 100644 index 0000000..fa56388 --- /dev/null +++ b/public/assets/icons/loading-icon2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 832afdf..10285f8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,13 +18,12 @@ import Game from '@/components/Game.vue' const screen: Ref = ref('login') const socket = useSocketStore() -socket.$subscribe( - (mutation, state) => { +socket.$subscribe((mutation, state) => { if (!state.connection) { screen.value = 'login' } - if (state.connection) { + if (state.token && state.connection) { screen.value = 'characters' if (state.character) { diff --git a/src/assets/scss/main.scss b/src/assets/scss/main.scss index 88e553d..f9af2fc 100644 --- a/src/assets/scss/main.scss +++ b/src/assets/scss/main.scss @@ -16,12 +16,12 @@ body { } h1, h2, h3, h4, h5, h6, button, a { - font-family: "Poppins"; + font-family: "Poppins", serif; color: $white; } p, span, li, label { - font-family: "Inter"; + font-family: "Inter", serif; color: $white; } button, a { @@ -37,6 +37,10 @@ button, input { button { text-align: center; + &.w-full { + width: 100%; + } + &.btn-cyan { background-color: rgba($cyan, 0.5); border: 1px solid $white; diff --git a/src/components/screens/Characters.vue b/src/components/screens/Characters.vue index 0cfef1b..2efa61e 100644 --- a/src/components/screens/Characters.vue +++ b/src/components/screens/Characters.vue @@ -1,7 +1,7 @@ - + {{ character.name }} @@ -23,8 +23,13 @@ + + + + + - + PLAY @@ -55,18 +60,26 @@ diff --git a/src/components/utilities/Modal.vue b/src/components/utilities/Modal.vue index c1f80c1..af4cfc4 100644 --- a/src/components/utilities/Modal.vue +++ b/src/components/utilities/Modal.vue @@ -45,9 +45,7 @@ const properties = defineProps({ } }) -watch( - () => properties.isModalOpen, - (value) => { +watch(() => properties.isModalOpen, (value) => { isModalOpenRef.value = value } ) @@ -124,6 +122,16 @@ const stopDrag = () => { isDragging.value = false } +watch(() => properties.modalWidth, (value) => { + width.value = value + } +) + +watch(() => properties.modalHeight, (value) => { + height.value = value + } +) + onMounted(() => { addEventListener('mousemove', drag) addEventListener('mouseup', stopDrag) @@ -142,13 +150,11 @@ onUnmounted(() => { // Make sure modal doesn't go off screen -watch( - () => x.value, (value) => { +watch(() => x.value, (value) => { if (value < 0) { x.value = 0 } else if (value + width.value > window.innerWidth) { x.value = window.innerWidth - width.value } } ) -watch( - () => y.value, (value) => { +watch(() => y.value, (value) => { if (value < 0) { y.value = 0 } else if (value + height.value > window.innerHeight) { y.value = window.innerHeight - height.value } } ) diff --git a/src/components/utilities/gmTools/GmUtilityWindow.vue b/src/components/utilities/gmTools/GmUtilityWindow.vue index 37e5a11..3175a38 100644 --- a/src/components/utilities/gmTools/GmUtilityWindow.vue +++ b/src/components/utilities/gmTools/GmUtilityWindow.vue @@ -1,14 +1,27 @@ - + GM tools - + + Zone manager + Player manager + Item manager + NPC manager + \ No newline at end of file + + + \ No newline at end of file diff --git a/src/services/authentication.ts b/src/services/authentication.ts index 83a9e69..c874e6d 100644 --- a/src/services/authentication.ts +++ b/src/services/authentication.ts @@ -7,8 +7,7 @@ export async function register(username: string, password: string, socketStore = try { const response = await axios.post(`${config.server_endpoint}/register`, { username, password }) useCookies().set('token', response.data.token as string) - await socketStore.setupSocketConnection() - return { success: true } + return { success: true, token: response.data.token} } catch (error: any) { return { error: error.response.data.message } } @@ -18,8 +17,7 @@ export async function login(username: string, password: string, socketStore = us try { const response = await axios.post(`${config.server_endpoint}/login`, { username, password }) useCookies().set('token', response.data.token as string) - await socketStore.setupSocketConnection() - return { success: true } + return { success: true, token: response.data.token} } catch (error: any) { return { error: error.response.data.message } } diff --git a/src/stores/socket.ts b/src/stores/socket.ts index fde5f35..f23a15b 100644 --- a/src/stores/socket.ts +++ b/src/stores/socket.ts @@ -6,17 +6,19 @@ import type { Character, User } from '@/types' export const useSocketStore: StoreDefinition = defineStore('socket', { state: () => ({ + token: '' as string | null, connection: null as Socket | null, user: null as User | null, character: null as Character | null }), getters: { + getToken: (state: any) => state.token as string, getConnection: (state: any) => state.connection as Socket, getUser: (state: any) => state.user as User, getCharacter: (state: any) => state.character as Character }, actions: { - setupSocketConnection() { + initConnection() { this.connection = io(config.server_endpoint, { withCredentials: true, transports: ['websocket'], @@ -27,7 +29,7 @@ export const useSocketStore: StoreDefinition = defineStore('socket', { this.connection.emit('login') // set user - this.connection.on('login', (user: User) => { + this.connection.on('logged_in', (user: User) => { this.setUser(user) }) @@ -43,11 +45,15 @@ export const useSocketStore: StoreDefinition = defineStore('socket', { this.connection.disconnect() this.connection = null + this.token = null this.user = null this.character = null useCookies().remove('token') }, + setToken(token: string) { + this.token = token + }, setUser(user: User | null) { this.user = user },