Browse Source

add function to remove planted crops on context / long press

master
Nero Ignis 3 years ago
parent
commit
da6a2b4039
  1. 2
      concept.md
  2. 28
      src/components/CropField.vue

2
concept.md

@ -6,7 +6,7 @@
- [ ] Watering of crops - [ ] Watering of crops
- [ ] Quick access on field for crops and later tools - [ ] Quick access on field for crops and later tools
- [ ] Switch system from field -> crop to crop -> fields - [ ] Switch system from field -> crop to crop -> fields
- [ ] Removing planted crops and regaining of removed crop - [x] Removing planted crops and regaining of removed crop
- [ ] Revision of crop-assets - [ ] Revision of crop-assets
- [x] Farm animals - [x] Farm animals
- [x] Animal products (egg, milk, wool, etc.) - [x] Animal products (egg, milk, wool, etc.)

28
src/components/CropField.vue

@ -3,6 +3,7 @@
<div class="row grass-border" id="field"> <div class="row grass-border" id="field">
<div :class="'crop-field '+(!field.data ? 'empty' : '')" <div :class="'crop-field '+(!field.data ? 'empty' : '')"
v-on:click="interactWithField(field)" v-on:click="interactWithField(field)"
v-on:contextmenu.prevent="removeCrop(field)"
v-for="field in fields" v-for="field in fields"
v-bind:key="field.id"> v-bind:key="field.id">
<img v-if="field.data" class="planted-field" :src="getCropAsset(field)"/> <img v-if="field.data" class="planted-field" :src="getCropAsset(field)"/>
@ -106,6 +107,33 @@ export default {
} else { } else {
return seed.assetsFolder + '1.png'; return seed.assetsFolder + '1.png';
} }
},
removeCrop(field) {
let view = this;
let seed = ItemService.getItemByID(field.data.seed_id);
iziToast.question({
title: 'Do you want to remove this '+seed.name+'?',
buttons: [
['<button><b>YES</b></button>', function (instance, toast) {
field.data = null;
view.$store.commit('addItemToInventory', {item: seed, quantity: 1});
iziToast.success({
title: 'Added removed '+seed.name+' back to inventory',
image: seed.icon
})
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
}, true],
['<button>NO</button>', function (instance, toast) {
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
}],
],
timeout: false
})
} }
} }
} }

Loading…
Cancel
Save