forked from noxious/client
Finished saving sprite logic
This commit is contained in:
@ -43,26 +43,26 @@
|
||||
<option :value="true">Yes</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-field-half">
|
||||
<div class="form-field-half" v-if="action.isAnimated">
|
||||
<label for="is-looping">Is looping</label>
|
||||
<select v-model="action.isLooping" class="input-cyan" name="is-looping">
|
||||
<option :value="false">No</option>
|
||||
<option :value="true">Yes</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-field-full">
|
||||
<div class="form-field-full" v-if="action.isAnimated">
|
||||
<label for="frame-speed">Frame speed</label>
|
||||
<input v-model.number="action.frameSpeed" class="input-cyan" type="number" step="any" name="frame-speed" placeholder="Frame speed" />
|
||||
</div>
|
||||
<div class="form-field-half">
|
||||
<div class="form-field-half" v-if="action.isAnimated">
|
||||
<label for="frame-width">Frame width</label>
|
||||
<input v-model.number="action.frameWidth" class="input-cyan" type="number" step="any" name="frame-width" placeholder="Frame width" />
|
||||
</div>
|
||||
<div class="form-field-half">
|
||||
<div class="form-field-half" v-if="action.isAnimated">
|
||||
<label for="frame-height">Frame height</label>
|
||||
<input v-model.number="action.frameHeight" class="input-cyan" type="number" step="any" name="frame-height" placeholder="Frame height" />
|
||||
</div>
|
||||
<SpriteActionsInput v-model="action.images" />
|
||||
<SpriteActionsInput v-model="action.sprites" />
|
||||
</form>
|
||||
</template>
|
||||
</Accordion>
|
||||
@ -124,18 +124,19 @@ function saveSprite() {
|
||||
const updatedSprite = {
|
||||
id: selectedSprite.value.id,
|
||||
name: spriteName.value,
|
||||
spriteActions: spriteActions.value.map((action) => {
|
||||
spriteActions: spriteActions.value?.map((action) => {
|
||||
return {
|
||||
action: action.action,
|
||||
sprites: action.sprites,
|
||||
origin_x: action.origin_x,
|
||||
origin_y: action.origin_y,
|
||||
isAnimated: action.isAnimated,
|
||||
isLooping: action.isLooping,
|
||||
frameSpeed: action.frameSpeed,
|
||||
frameWidth: action.frameWidth,
|
||||
frameHeight: action.frameHeight,
|
||||
isAnimated: action.isAnimated,
|
||||
isLooping: action.isLooping
|
||||
}
|
||||
})
|
||||
}) ?? []
|
||||
}
|
||||
|
||||
gameStore.connection?.emit('gm:sprite:update', updatedSprite, (response: boolean) => {
|
||||
@ -147,30 +148,28 @@ function saveSprite() {
|
||||
})
|
||||
}
|
||||
|
||||
function uuidv4() {
|
||||
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))).toString(16))
|
||||
}
|
||||
|
||||
function addNewImage() {
|
||||
if (!selectedSprite.value) return
|
||||
|
||||
function uuidv4() {
|
||||
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))).toString(16))
|
||||
}
|
||||
|
||||
const newImage: SpriteAction = {
|
||||
id: uuidv4(), // Temporary ID, should be replaced by server-generated ID
|
||||
spriteId: selectedSprite.value.id,
|
||||
sprite: selectedSprite.value,
|
||||
action: 'new_action',
|
||||
sprites: [],
|
||||
origin_x: 0,
|
||||
origin_y: 0,
|
||||
isAnimated: false,
|
||||
isLooping: false,
|
||||
frameSpeed: 0,
|
||||
frameWidth: 0,
|
||||
frameHeight: 0,
|
||||
isAnimated: false,
|
||||
spriteId: selectedSprite.value.id,
|
||||
sprite: selectedSprite.value,
|
||||
isLooping: false
|
||||
}
|
||||
|
||||
console.log(newImage)
|
||||
|
||||
// spriteimages value can be undefined
|
||||
if (!spriteActions.value) {
|
||||
spriteActions.value = []
|
||||
}
|
||||
|
Reference in New Issue
Block a user