forked from noxious/client
npm run format
This commit is contained in:
parent
7b1dcf7ce3
commit
fb18841c91
@ -14,11 +14,11 @@ import Loading from '@/components/screens/Loading.vue'
|
||||
import Login from '@/components/screens/Login.vue'
|
||||
import MapEditor from '@/components/screens/MapEditor.vue'
|
||||
import BackgroundImageLoader from '@/components/utilities/BackgroundImageLoader.vue'
|
||||
import Debug from '@/components/utilities/Debug.vue'
|
||||
import Notifications from '@/components/utilities/Notifications.vue'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useMapEditorStore } from '@/stores/mapEditorStore'
|
||||
import { computed, onMounted, onUnmounted, watch } from 'vue'
|
||||
import Debug from '@/components/utilities/Debug.vue'
|
||||
|
||||
const gameStore = useGameStore()
|
||||
const mapEditorStore = useMapEditorStore()
|
||||
|
@ -16,11 +16,11 @@ import ChatBubble from '@/components/game/character/partials/ChatBubble.vue'
|
||||
import Healthbar from '@/components/game/character/partials/Healthbar.vue'
|
||||
import { loadSpriteTextures } from '@/composables/gameComposable'
|
||||
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/mapComposable'
|
||||
import { CharacterTypeStorage } from '@/storage/storages'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useMapStore } from '@/stores/mapStore'
|
||||
import { Container, refObj, Sprite, useScene } from 'phavuer'
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { CharacterTypeStorage } from '@/storage/storages'
|
||||
|
||||
// import CharacterChest from '@/components/game/character/partials/CharacterChest.vue'
|
||||
|
||||
|
@ -5,16 +5,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { MapCharacter, mapLoadData, UUID, Map } from '@/application/types'
|
||||
import type { Map, MapCharacter, mapLoadData, UUID } from '@/application/types'
|
||||
import Characters from '@/components/game/map/Characters.vue'
|
||||
import MapTiles from '@/components/game/map/MapTiles.vue'
|
||||
import MapObjects from '@/components/game/map/PlacedMapObjects.vue'
|
||||
import { loadMapTilesIntoScene } from '@/composables/mapComposable'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useMapStore } from '@/stores/mapStore'
|
||||
import { useScene } from 'phavuer'
|
||||
import { onUnmounted, ref, shallowRef } from 'vue'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
|
||||
const scene = useScene()
|
||||
const gameStore = useGameStore()
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import config from '@/application/config'
|
||||
import type { UUID } from '@/application/types'
|
||||
import { unduplicateArray } from '@/application/utilities'
|
||||
import Controls from '@/components/utilities/Controls.vue'
|
||||
import { FlattenMapArray, loadMapTilesIntoScene, setLayerTiles } from '@/composables/mapComposable'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
import { useMapStore } from '@/stores/mapStore'
|
||||
import { useScene } from 'phavuer'
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
import type { UUID } from '@/application/types'
|
||||
|
||||
const emit = defineEmits(['tileMap:create'])
|
||||
|
||||
|
@ -124,9 +124,9 @@
|
||||
import config from '@/application/config'
|
||||
import { type CharacterHair, type Character as CharacterT, type Map } from '@/application/types'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import { CharacterHairStorage } from '@/storage/storages'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { CharacterHairStorage } from '@/storage/storages'
|
||||
|
||||
const gameStore = useGameStore()
|
||||
const isLoading = ref<boolean>(true)
|
||||
@ -137,7 +137,6 @@ const newCharacterName = ref<string>('')
|
||||
const characterHairs = ref<CharacterHair[]>([])
|
||||
const selectedHairId = ref<number | null>(null)
|
||||
|
||||
|
||||
// Fetch characters
|
||||
setTimeout(() => {
|
||||
gameStore.connection?.emit('character:list')
|
||||
|
@ -17,27 +17,18 @@
|
||||
<script setup lang="ts" async>
|
||||
import config from '@/application/config'
|
||||
import type { HttpResponse, MapObject } from '@/application/types'
|
||||
import type { BaseStorage } from '@/storage/baseStorage'
|
||||
import { CharacterHairStorage, CharacterTypeStorage, MapObjectStorage, MapStorage, SpriteStorage, TileStorage } from '@/storage/storages'
|
||||
// import type { Map } from '@/application/types'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { ref } from 'vue'
|
||||
import type { BaseStorage } from '@/storage/baseStorage'
|
||||
import {
|
||||
CharacterHairStorage,
|
||||
CharacterTypeStorage,
|
||||
MapObjectStorage,
|
||||
MapStorage, SpriteStorage,
|
||||
TileStorage
|
||||
} from '@/storage/storages'
|
||||
|
||||
const gameStore = useGameStore()
|
||||
|
||||
const totalItems = ref(0)
|
||||
const currentItem = ref(0)
|
||||
|
||||
async function downloadAndStore<T extends { id: string }>(
|
||||
endpoint: string,
|
||||
storage: BaseStorage<T>
|
||||
) {
|
||||
async function downloadAndStore<T extends { id: string }>(endpoint: string, storage: BaseStorage<T>) {
|
||||
const request = await fetch(`${config.server_endpoint}/cache/${endpoint}`)
|
||||
const response = (await request.json()) as HttpResponse<T[]>
|
||||
|
||||
|
@ -1,17 +1,9 @@
|
||||
<template>
|
||||
|
||||
</template>
|
||||
<template></template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted } from 'vue'
|
||||
import {
|
||||
CharacterHairStorage,
|
||||
CharacterTypeStorage,
|
||||
MapObjectStorage,
|
||||
MapStorage, SpriteStorage,
|
||||
TileStorage
|
||||
} from '@/storage/storages'
|
||||
import { CharacterHairStorage, CharacterTypeStorage, MapObjectStorage, MapStorage, SpriteStorage, TileStorage } from '@/storage/storages'
|
||||
import { TextureStorage } from '@/storage/textureStorage'
|
||||
import { onMounted, onUnmounted } from 'vue'
|
||||
|
||||
const mapStorage = new MapStorage()
|
||||
const tileStorage = new TileStorage()
|
||||
@ -25,8 +17,7 @@ let currentString = ''
|
||||
|
||||
async function handleKeyPress(event: KeyboardEvent) {
|
||||
// Ignore if typing in input/textarea
|
||||
if (document.activeElement?.tagName.toUpperCase() === 'INPUT' ||
|
||||
document.activeElement?.tagName.toUpperCase() === 'TEXTAREA') {
|
||||
if (document.activeElement?.tagName.toUpperCase() === 'INPUT' || document.activeElement?.tagName.toUpperCase() === 'TEXTAREA') {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type { TextureData } from '@/application/types'
|
||||
import { SpriteStorage } from '@/storage/storages'
|
||||
import { TextureStorage } from '@/storage/textureStorage'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { SpriteStorage } from '@/storage/storages'
|
||||
|
||||
const textureLoadingPromises = new Map<string, Promise<boolean>>()
|
||||
|
||||
|
@ -34,32 +34,19 @@ export function useGamePointerHandlers(scene: Phaser.Scene, layer: Phaser.Tilema
|
||||
|
||||
if (!gameStore.game.isPlayerDraggingCamera) return
|
||||
|
||||
const distance = Phaser.Math.Distance.Between(
|
||||
pointerStartPosition.value.x,
|
||||
pointerStartPosition.value.y,
|
||||
pointer.x,
|
||||
pointer.y
|
||||
)
|
||||
const distance = Phaser.Math.Distance.Between(pointerStartPosition.value.x, pointerStartPosition.value.y, pointer.x, pointer.y)
|
||||
|
||||
// If the distance is less than the drag threshold, return
|
||||
// We do this to prevent the camera from scrolling too quickly
|
||||
if (distance <= dragThreshold) return
|
||||
|
||||
camera.setScroll(
|
||||
camera.scrollX - (pointer.x - pointer.prevPosition.x) / camera.zoom,
|
||||
camera.scrollY - (pointer.y - pointer.prevPosition.y) / camera.zoom
|
||||
)
|
||||
camera.setScroll(camera.scrollX - (pointer.x - pointer.prevPosition.x) / camera.zoom, camera.scrollY - (pointer.y - pointer.prevPosition.y) / camera.zoom)
|
||||
}
|
||||
|
||||
function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
||||
gameStore.setPlayerDraggingCamera(false)
|
||||
|
||||
const distance = Phaser.Math.Distance.Between(
|
||||
pointerStartPosition.value.x,
|
||||
pointerStartPosition.value.y,
|
||||
pointer.x,
|
||||
pointer.y
|
||||
)
|
||||
const distance = Phaser.Math.Distance.Between(pointerStartPosition.value.x, pointerStartPosition.value.y, pointer.x, pointer.y)
|
||||
|
||||
// If the distance is greater than the drag threshold, return
|
||||
// We do this to prevent the camera from scrolling too quickly
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { Tile, Map, MapObject } from '@/application/types'
|
||||
import type { Map, MapObject, Tile } from '@/application/types'
|
||||
import { BaseStorage } from '@/storage/baseStorage'
|
||||
|
||||
export class MapStorage extends BaseStorage<Map> {
|
||||
@ -41,4 +41,3 @@ export class CharacterHairStorage extends BaseStorage<any> {
|
||||
super('characterHairs', 'id, name, createdAt, updatedAt')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,10 @@ export const useGameStore = defineStore('game', {
|
||||
return state.game.loadedTextures
|
||||
},
|
||||
isAssetLoaded: (state) => {
|
||||
return (key: string) => { return state.game.loadedTextures.includes(key)}
|
||||
},
|
||||
return (key: string) => {
|
||||
return state.game.loadedTextures.includes(key)
|
||||
}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
addNotification(notification: Notification) {
|
||||
|
@ -15,7 +15,7 @@ export const useMapStore = defineStore('map', {
|
||||
},
|
||||
getCharacterCount: (state) => {
|
||||
return state.characters.length
|
||||
},
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
setMapId(mapId: UUID) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user