Small styling adjustment on buttons. Some zone editor stuff.

This commit is contained in:
Dennis Postma 2024-07-07 04:32:16 +02:00
parent 317906eab5
commit 89a781470b
7 changed files with 46 additions and 38 deletions

View File

@ -68,7 +68,7 @@ button {
@apply text-center; @apply text-center;
&.btn-cyan { &.btn-cyan {
@apply bg-cyan bg-opacity-50 border border-solid border-white rounded drop-shadow-20; @apply bg-cyan bg-opacity-50 border border-solid border-white border-opacity-25 rounded drop-shadow-20;
&.active, &.active,
&:hover { &:hover {
@ -77,7 +77,7 @@ button {
} }
&.btn-bordeaux { &.btn-bordeaux {
@apply bg-bordeaux bg-opacity-50 border border-solid border-white rounded drop-shadow-20; @apply bg-bordeaux bg-opacity-50 border border-solid border-white border-opacity-25 rounded drop-shadow-20;
&.active, &.active,
&:hover { &:hover {

View File

@ -24,7 +24,7 @@
<!-- Assets list --> <!-- Assets list -->
<div class="overflow-auto h-full w-[35%] flex flex-col relative" ref="elementToScroll" @scroll="onScroll"> <div class="overflow-auto h-full w-[35%] flex flex-col relative" ref="elementToScroll" @scroll="onScroll">
<TileList v-if="selectedCategory === 'tiles'" /> <TileList v-if="selectedCategory === 'tiles'" />
<ObjectList :name="selectedCategory" v-if="selectedCategory === 'objects'" /> <ObjectList v-if="selectedCategory === 'objects'" />
</div> </div>
<button class="left-[calc(50%_-_60px)] absolute bottom-2.5 min-w-[unset] w-[50px] h-[50px] rounded-lg bg-cyan bg-opacity-50 p-0 hover:bg-opacity-80" v-show="hasScrolled" @click="toTop"> <button class="left-[calc(50%_-_60px)] absolute bottom-2.5 min-w-[unset] w-[50px] h-[50px] rounded-lg bg-cyan bg-opacity-50 p-0 hover:bg-opacity-80" v-show="hasScrolled" @click="toTop">

View File

@ -12,7 +12,7 @@
<div class="h-[28px] w-[75px] max-w-[75px] flex justify-center"> <div class="h-[28px] w-[75px] max-w-[75px] flex justify-center">
<img class="h-[28px]" :src="`${config.server_endpoint}/assets/objects/${object.id}.png`" alt="Object" /> <img class="h-[28px]" :src="`${config.server_endpoint}/assets/objects/${object.id}.png`" alt="Object" />
</div> </div>
<span class="flex-shrink-0">{{ object.name }}</span> <span>{{ object.name }}</span>
</div> </div>
<div class="absolute left-0 bottom-0 w-full h-[1px] bg-cyan-200"></div> <div class="absolute left-0 bottom-0 w-full h-[1px] bg-cyan-200"></div>
</a> </a>
@ -64,7 +64,6 @@ const filteredObjects = computed(() => {
onMounted(() => { onMounted(() => {
socket.connection.emit('gm:object:list', {}, (response: Object[]) => { socket.connection.emit('gm:object:list', {}, (response: Object[]) => {
if (config.development) console.log(response)
assetManagerStore.setObjectList(response) assetManagerStore.setObjectList(response)
}) })
}) })

View File

@ -7,14 +7,15 @@
<input v-model="searchQuery" class="input-cyan w-full" placeholder="Search..." @input="handleSearch" /> <input v-model="searchQuery" class="input-cyan w-full" placeholder="Search..." @input="handleSearch" />
<div class="absolute left-0 bottom-0 w-full height-[1px] bg-cyan-200"></div> <div class="absolute left-0 bottom-0 w-full height-[1px] bg-cyan-200"></div>
</div> </div>
<a class="relative p-2.5 cursor-pointer flex gap-y-2.5 gap-x-5 flex-wrap" :class="{ 'bg-cyan bg-opacity-80': assetManagerStore.selectedTile === tile }" v-for="(tile, index) in filteredTiles" :key="index" @click="assetManagerStore.setSelectedTile(tile)"> <div>
<div class="flex items-center gap-2.5"> <a class="relative p-2.5 cursor-pointer flex gap-y-2.5 gap-x-5 flex-wrap w-full" :class="{ 'bg-cyan bg-opacity-80': assetManagerStore.selectedTile === tile }" v-for="(tile, index) in filteredTiles" :key="index" @click="assetManagerStore.setSelectedTile(tile)">
<!-- TODO make all img have same width so text aligns nicely --> <div class="flex items-center gap-2.5">
<img class="h-[28px]" :src="`${config.server_endpoint}/assets/tiles/${tile}.png`" alt="Tile" /> <img class="h-[28px]" :src="`${config.server_endpoint}/assets/tiles/${tile}.png`" alt="Tile" />
<span class="flex-shrink-0">{{ tile }}</span> <span class="">{{ tile }}</span>
</div> </div>
<div class="absolute left-0 bottom-0 w-full h-[1px] bg-cyan-200"></div> <div class="absolute left-0 bottom-0 w-full h-[1px] bg-cyan-200"></div>
</a> </a>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -62,7 +63,6 @@ const filteredTiles = computed(() => {
onMounted(() => { onMounted(() => {
socket.connection.emit('gm:tile:list', {}, (response: string[]) => { socket.connection.emit('gm:tile:list', {}, (response: string[]) => {
if (config.development) console.log(response)
assetManagerStore.setTileList(response) assetManagerStore.setTileList(response)
}) })
}) })

View File

@ -104,13 +104,13 @@ function paint(tile: Phaser.Tilemaps.Tile) {
} }
function save() { function save() {
if (!zoneEditorStore.name) return
socket.connection.emit('gm:zone_editor:zone:update', { socket.connection.emit('gm:zone_editor:zone:update', {
zoneId: socket.character.zoneId, zoneId: socket.character.zoneId,
name: zoneEditorStore.name, name: zoneEditorStore.name,
width: zoneEditorStore.width, width: zoneEditorStore.width,
height: zoneEditorStore.height, height: zoneEditorStore.height,
tiles: zoneEditorStore.tiles, tiles: tiles.gidMap,
objects: zoneEditorStore.objects
}) })
} }

View File

@ -2,7 +2,7 @@
<CreateZone @submit="fetchZones" v-if="zoneEditorStore.isCreateZoneModalShown" /> <CreateZone @submit="fetchZones" v-if="zoneEditorStore.isCreateZoneModalShown" />
<Teleport to="body"> <Teleport to="body">
<Modal @modal:close="() => zoneEditorStore.toggleZoneListModal()" :is-resizable="false" :is-modal-open="true" :modal-width="200" :modal-height="360"> <Modal @modal:close="() => zoneEditorStore.toggleZoneListModal()" :is-resizable="false" :is-modal-open="true" :modal-width="300" :modal-height="360">
<template #modalHeader> <template #modalHeader>
<h3 class="text-lg">Zones</h3> <h3 class="text-lg">Zones</h3>
</template> </template>
@ -13,10 +13,9 @@
</div> </div>
<div class="relative p-2.5 cursor-pointer flex gap-y-2.5 gap-x-5 flex-wrap" v-for="(zone, index) in zones" :key="zone.id"> <div class="relative p-2.5 cursor-pointer flex gap-y-2.5 gap-x-5 flex-wrap" v-for="(zone, index) in zones" :key="zone.id">
<div class="absolute left-0 top-0 w-full h-[1px] bg-cyan-200" v-if="index === 0"></div> <div class="absolute left-0 top-0 w-full h-[1px] bg-cyan-200" v-if="index === 0"></div>
<div class="flex items-center"> <div class="flex gap-3 items-center w-full">
<span>{{ zone.name }}</span> <span @click="() => loadZone(zone.id)">{{ zone.name }}</span>
<!-- @TODO : BUG , ml-auto no work --> <span class="ml-auto gap-1 flex">
<span class="ml-auto">
<button class="btn-bordeaux py-0.5 px-2.5" @click="() => deleteZone(zone.id)">X</button> <button class="btn-bordeaux py-0.5 px-2.5" @click="() => deleteZone(zone.id)">X</button>
</span> </span>
</div> </div>
@ -50,6 +49,13 @@ function fetchZones() {
}) })
} }
function loadZone(id: number) {
console.log('loadZone', id)
socket.connection.emit('gm:zone_editor:zone:load', { zoneId: id }, () => {
zoneEditorStore.toggleZoneListModal()
})
}
function deleteZone(id: number) { function deleteZone(id: number) {
socket.connection.emit('gm:zone_editor:zone:delete', { zoneId: id }, () => { socket.connection.emit('gm:zone_editor:zone:delete', { zoneId: id }, () => {
fetchZones() fetchZones()

View File

@ -4,32 +4,26 @@ import type { Object, ZoneObject } from '@/types'
export const useZoneEditorStore = defineStore('zoneEditor', { export const useZoneEditorStore = defineStore('zoneEditor', {
state: () => ({ state: () => ({
active: true, active: true,
isZoneListModalShown: false,
isCreateZoneModalShown: false,
name: '', name: '',
width: 10, width: 10,
height: 10, height: 10,
tool: 'move',
drawMode: 'tile',
tileList: [] as string[], tileList: [] as string[],
tiles: [] as string[][], tiles: [] as string[][],
objectList: [] as Object[], objectList: [] as Object[],
objects: [] as ZoneObject[], objects: [] as ZoneObject[],
tool: 'move',
drawMode: 'tile',
selectedTile: '', selectedTile: '',
selectedObject: null as Object | null, selectedObject: null as Object | null,
isZoneListModalShown: false,
isCreateZoneModalShown: false,
isSettingsModalShown: false isSettingsModalShown: false
}), }),
actions: { actions: {
toggleActive() { toggleActive() {
this.active = !this.active this.active = !this.active
}, },
toggleZoneListModal() {
this.isZoneListModalShown = !this.isZoneListModalShown
this.isCreateZoneModalShown = false
},
toggleCreateZoneModal() {
this.isCreateZoneModalShown = !this.isCreateZoneModalShown
},
setName(name: string) { setName(name: string) {
this.name = name this.name = name
}, },
@ -39,6 +33,12 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
setHeight(height: number) { setHeight(height: number) {
this.height = height this.height = height
}, },
setTool(tool: string) {
this.tool = tool
},
setDrawMode(mode: string) {
this.drawMode = mode
},
setTileList(tiles: string[]) { setTileList(tiles: string[]) {
this.tileList = tiles this.tileList = tiles
}, },
@ -57,12 +57,6 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
updateObject(index: number, object: ZoneObject) { updateObject(index: number, object: ZoneObject) {
this.objects[index] = object this.objects[index] = object
}, },
setTool(tool: string) {
this.tool = tool
},
setDrawMode(mode: string) {
this.drawMode = mode
},
setSelectedTile(tile: string) { setSelectedTile(tile: string) {
this.selectedTile = tile this.selectedTile = tile
}, },
@ -72,6 +66,13 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
toggleSettingsModal() { toggleSettingsModal() {
this.isSettingsModalShown = !this.isSettingsModalShown this.isSettingsModalShown = !this.isSettingsModalShown
}, },
toggleZoneListModal() {
this.isZoneListModalShown = !this.isZoneListModalShown
this.isCreateZoneModalShown = false
},
toggleCreateZoneModal() {
this.isCreateZoneModalShown = !this.isCreateZoneModalShown
},
reset() { reset() {
this.name = '' this.name = ''
this.width = 10 this.width = 10
@ -85,6 +86,8 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
this.selectedTile = '' this.selectedTile = ''
this.selectedObject = null this.selectedObject = null
this.isSettingsModalShown = false this.isSettingsModalShown = false
this.isZoneListModalShown = false
this.isCreateZoneModalShown = false
} }
} }
}) })