mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 13:47:33 +01:00
Added supression support for pet/mount modals and added mount modal (#9882)
* Added supression support for pet/mount modals and added mount modal * Moved create animal * Fixed raise pet logic * Added suppresion for stable hatch modal * Fixed click paw and added growl * Fixed confirm. Fixed mount name * Suppresed confirmation
This commit is contained in:
@@ -351,7 +351,10 @@ export default {
|
|||||||
},
|
},
|
||||||
hatchPet (potion, egg) {
|
hatchPet (potion, egg) {
|
||||||
this.$store.dispatch('common:hatch', {egg: egg.key, hatchingPotion: potion.key});
|
this.$store.dispatch('common:hatch', {egg: egg.key, hatchingPotion: potion.key});
|
||||||
this.$root.$emit('hatchedPet::open', createAnimal(egg, potion, 'pet', this.content, this.user.items));
|
this.text(this.$t('hatchedPet', {egg: egg.key, potion: potion.key}));
|
||||||
|
if (this.user.preferences.suppressModals.hatchPet) return;
|
||||||
|
const newPet = createAnimal(egg, potion, 'pet', this.content, this.user.items);
|
||||||
|
this.$root.$emit('hatchedPet::open', newPet);
|
||||||
},
|
},
|
||||||
onDragEnd () {
|
onDragEnd () {
|
||||||
this.currentDraggingPotion = null;
|
this.currentDraggingPotion = null;
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
|
b-modal#hatchedPet-modal(:hide-header="true")
|
||||||
b-modal#hatchedPet-modal(
|
|
||||||
:hide-header="true"
|
|
||||||
)
|
|
||||||
div.content(v-if="pet != null")
|
div.content(v-if="pet != null")
|
||||||
div.dialog-header.title(v-once) {{ $t('hatchedPetGeneric') }}
|
div.dialog-header.title(v-once) {{ $t('hatchedPetGeneric') }}
|
||||||
|
|
||||||
|
|
||||||
div.inner-content
|
div.inner-content
|
||||||
div.pet-background
|
div.pet-background
|
||||||
div(:class="pet.class")
|
div(:class="pet.class")
|
||||||
|
|
||||||
h4.title {{ pet.name }}
|
h4.title {{ pet.name }}
|
||||||
div.text(v-if="!hideText", v-markdown="$t('hatchedPetHowToUse')")
|
div.text(v-if="!hideText", v-markdown="$t('hatchedPetHowToUse')")
|
||||||
|
|
||||||
button.btn.btn-primary(@click="close()") {{ $t('onward') }}
|
button.btn.btn-primary(@click="close()") {{ $t('onward') }}
|
||||||
|
|
||||||
div.clearfix(slot="modal-footer")
|
div.clearfix(slot="modal-footer")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -56,7 +48,6 @@
|
|||||||
color: $purple-200;
|
color: $purple-200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -82,7 +73,6 @@
|
|||||||
this.pet = item;
|
this.pet = item;
|
||||||
this.$root.$emit('bv::show::modal', 'hatchedPet-modal');
|
this.$root.$emit('bv::show::modal', 'hatchedPet-modal');
|
||||||
},
|
},
|
||||||
|
|
||||||
close () {
|
close () {
|
||||||
this.$emit('closed', this.item);
|
this.$emit('closed', this.item);
|
||||||
this.$root.$emit('bv::hide::modal', 'hatchedPet-modal');
|
this.$root.$emit('bv::hide::modal', 'hatchedPet-modal');
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
:checked="hideMissing",
|
:checked="hideMissing",
|
||||||
@change="updateHideMissing"
|
@change="updateHideMissing"
|
||||||
)
|
)
|
||||||
|
|
||||||
.standard-page
|
.standard-page
|
||||||
.clearfix
|
.clearfix
|
||||||
h1.float-left.mb-4.page-header(v-once) {{ $t('stable') }}
|
h1.float-left.mb-4.page-header(v-once) {{ $t('stable') }}
|
||||||
@@ -196,7 +195,6 @@
|
|||||||
@itemDragStart="onDragStart($event, context.item)",
|
@itemDragStart="onDragStart($event, context.item)",
|
||||||
@itemClick="onFoodClicked($event, context.item)"
|
@itemClick="onFoodClicked($event, context.item)"
|
||||||
)
|
)
|
||||||
|
|
||||||
b-modal#welcome-modal(
|
b-modal#welcome-modal(
|
||||||
:ok-only="true",
|
:ok-only="true",
|
||||||
:ok-title="$t('gotIt')",
|
:ok-title="$t('gotIt')",
|
||||||
@@ -208,7 +206,6 @@
|
|||||||
div.npc_matt
|
div.npc_matt
|
||||||
h1.page-header(v-once) {{ $t('welcomeStable') }}
|
h1.page-header(v-once) {{ $t('welcomeStable') }}
|
||||||
div.content-text(v-once) {{ $t('welcomeStableText') }}
|
div.content-text(v-once) {{ $t('welcomeStableText') }}
|
||||||
|
|
||||||
b-modal#hatching-modal(
|
b-modal#hatching-modal(
|
||||||
@change="resetHatchablePet($event)"
|
@change="resetHatchablePet($event)"
|
||||||
)
|
)
|
||||||
@@ -218,7 +215,6 @@
|
|||||||
div(:class="'Pet_HatchingPotion_'+hatchablePet.potionKey")
|
div(:class="'Pet_HatchingPotion_'+hatchablePet.potionKey")
|
||||||
div.potionEggBackground
|
div.potionEggBackground
|
||||||
div(:class="'Pet_Egg_'+hatchablePet.eggKey")
|
div(:class="'Pet_Egg_'+hatchablePet.eggKey")
|
||||||
|
|
||||||
h4.title {{ hatchablePet.name }}
|
h4.title {{ hatchablePet.name }}
|
||||||
div.text(v-html="$t('hatchDialogText', { potionName: hatchablePet.potionName, eggName: hatchablePet.eggName, petName: hatchablePet.name })")
|
div.text(v-html="$t('hatchDialogText', { potionName: hatchablePet.potionName, eggName: hatchablePet.eggName, petName: hatchablePet.name })")
|
||||||
|
|
||||||
@@ -243,6 +239,7 @@
|
|||||||
div.food-icon(:class="'Pet_Food_'+currentDraggingFood.key")
|
div.food-icon(:class="'Pet_Food_'+currentDraggingFood.key")
|
||||||
div.popover
|
div.popover
|
||||||
div.popover-content {{ $t('clickOnPetToFeed', {foodName: currentDraggingFood.text() }) }}
|
div.popover-content {{ $t('clickOnPetToFeed', {foodName: currentDraggingFood.text() }) }}
|
||||||
|
mount-raised-modal
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang='scss' scoped>
|
<style lang='scss' scoped>
|
||||||
@@ -494,6 +491,7 @@
|
|||||||
import MountItem from './mountItem.vue';
|
import MountItem from './mountItem.vue';
|
||||||
import FoodItem from './foodItem';
|
import FoodItem from './foodItem';
|
||||||
import HatchedPetDialog from './hatchedPetDialog';
|
import HatchedPetDialog from './hatchedPetDialog';
|
||||||
|
import MountRaisedModal from './mountRaisedModal';
|
||||||
import Drawer from 'client/components/ui/drawer';
|
import Drawer from 'client/components/ui/drawer';
|
||||||
import toggleSwitch from 'client/components/ui/toggleSwitch';
|
import toggleSwitch from 'client/components/ui/toggleSwitch';
|
||||||
import StarBadge from 'client/components/ui/starBadge';
|
import StarBadge from 'client/components/ui/starBadge';
|
||||||
@@ -533,6 +531,7 @@
|
|||||||
CountBadge,
|
CountBadge,
|
||||||
DrawerSlider,
|
DrawerSlider,
|
||||||
HatchedPetDialog,
|
HatchedPetDialog,
|
||||||
|
MountRaisedModal,
|
||||||
},
|
},
|
||||||
directives: {
|
directives: {
|
||||||
resize: ResizeDirective,
|
resize: ResizeDirective,
|
||||||
@@ -543,10 +542,8 @@
|
|||||||
return {
|
return {
|
||||||
viewOptions: {},
|
viewOptions: {},
|
||||||
hideMissing: false,
|
hideMissing: false,
|
||||||
|
|
||||||
searchText: null,
|
searchText: null,
|
||||||
searchTextThrottled: '',
|
searchTextThrottled: '',
|
||||||
|
|
||||||
// sort has the translation-keys as values
|
// sort has the translation-keys as values
|
||||||
selectedSortBy: 'standard',
|
selectedSortBy: 'standard',
|
||||||
sortByItems: [
|
sortByItems: [
|
||||||
@@ -555,7 +552,6 @@
|
|||||||
'sortByColor',
|
'sortByColor',
|
||||||
'sortByHatchable',
|
'sortByHatchable',
|
||||||
],
|
],
|
||||||
|
|
||||||
icons: Object.freeze({
|
icons: Object.freeze({
|
||||||
information: svgInformation,
|
information: svgInformation,
|
||||||
close: svgClose,
|
close: svgClose,
|
||||||
@@ -573,7 +569,6 @@
|
|||||||
watch: {
|
watch: {
|
||||||
searchText: _throttle(function throttleSearch () {
|
searchText: _throttle(function throttleSearch () {
|
||||||
let search = this.searchText.toLowerCase();
|
let search = this.searchText.toLowerCase();
|
||||||
|
|
||||||
this.searchTextThrottled = search;
|
this.searchTextThrottled = search;
|
||||||
}, 250),
|
}, 250),
|
||||||
},
|
},
|
||||||
@@ -584,8 +579,8 @@
|
|||||||
currentMount: 'user.data.items.currentMount',
|
currentMount: 'user.data.items.currentMount',
|
||||||
userItems: 'user.data.items',
|
userItems: 'user.data.items',
|
||||||
hideDialog: 'user.data.flags.tutorial.common.mounts',
|
hideDialog: 'user.data.flags.tutorial.common.mounts',
|
||||||
|
user: 'user.data',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
petGroups () {
|
petGroups () {
|
||||||
let petGroups = [
|
let petGroups = [
|
||||||
{
|
{
|
||||||
@@ -676,7 +671,6 @@
|
|||||||
|
|
||||||
return mountGroups;
|
return mountGroups;
|
||||||
},
|
},
|
||||||
|
|
||||||
drawerTabs () {
|
drawerTabs () {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -751,7 +745,6 @@
|
|||||||
|
|
||||||
return animals;
|
return animals;
|
||||||
},
|
},
|
||||||
|
|
||||||
listAnimals (animalGroup, type, hideMissing, sort, searchText) {
|
listAnimals (animalGroup, type, hideMissing, sort, searchText) {
|
||||||
let animals = this.getAnimalList(animalGroup, type);
|
let animals = this.getAnimalList(animalGroup, type);
|
||||||
let isPetList = type === 'pet';
|
let isPetList = type === 'pet';
|
||||||
@@ -805,7 +798,6 @@
|
|||||||
|
|
||||||
return animalRows;
|
return animalRows;
|
||||||
},
|
},
|
||||||
|
|
||||||
countOwnedAnimals (animalGroup, type) {
|
countOwnedAnimals (animalGroup, type) {
|
||||||
let animals = this.getAnimalList(animalGroup, type);
|
let animals = this.getAnimalList(animalGroup, type);
|
||||||
|
|
||||||
@@ -817,7 +809,6 @@
|
|||||||
|
|
||||||
return `${countOwned.length}/${countAll}`;
|
return `${countOwned.length}/${countAll}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
pets (animalGroup, hideMissing, sortBy, searchText) {
|
pets (animalGroup, hideMissing, sortBy, searchText) {
|
||||||
let pets = this.listAnimals(animalGroup, 'pet', hideMissing, sortBy, searchText);
|
let pets = this.listAnimals(animalGroup, 'pet', hideMissing, sortBy, searchText);
|
||||||
|
|
||||||
@@ -835,7 +826,6 @@
|
|||||||
|
|
||||||
return groupBy(pets, groupKey);
|
return groupBy(pets, groupKey);
|
||||||
},
|
},
|
||||||
|
|
||||||
mounts (animalGroup, hideMissing, sortBy, searchText) {
|
mounts (animalGroup, hideMissing, sortBy, searchText) {
|
||||||
let mounts = this.listAnimals(animalGroup, 'mount', hideMissing, sortBy, searchText);
|
let mounts = this.listAnimals(animalGroup, 'mount', hideMissing, sortBy, searchText);
|
||||||
|
|
||||||
@@ -853,7 +843,6 @@
|
|||||||
|
|
||||||
return groupBy(mounts, groupKey);
|
return groupBy(mounts, groupKey);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPetItemClass (pet) {
|
getPetItemClass (pet) {
|
||||||
if (pet.isOwned()) {
|
if (pet.isOwned()) {
|
||||||
return `Pet Pet-${pet.key} ${pet.eggKey}`;
|
return `Pet Pet-${pet.key} ${pet.eggKey}`;
|
||||||
@@ -869,31 +858,25 @@
|
|||||||
|
|
||||||
return 'GreyedOut PixelPaw';
|
return 'GreyedOut PixelPaw';
|
||||||
},
|
},
|
||||||
|
|
||||||
hasDrawerTabItems (index) {
|
hasDrawerTabItems (index) {
|
||||||
return this.drawerTabs && this.drawerTabs[index].items.length !== 0;
|
return this.drawerTabs && this.drawerTabs[index].items.length !== 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
updateHideMissing (newVal) {
|
updateHideMissing (newVal) {
|
||||||
this.hideMissing = newVal;
|
this.hideMissing = newVal;
|
||||||
},
|
},
|
||||||
|
|
||||||
selectPet (item) {
|
selectPet (item) {
|
||||||
this.$store.dispatch('common:equip', {key: item.key, type: 'pet'});
|
this.$store.dispatch('common:equip', {key: item.key, type: 'pet'});
|
||||||
},
|
},
|
||||||
|
|
||||||
selectMount (item) {
|
selectMount (item) {
|
||||||
this.$store.dispatch('common:equip', {key: item.key, type: 'mount'});
|
this.$store.dispatch('common:equip', {key: item.key, type: 'mount'});
|
||||||
},
|
},
|
||||||
|
|
||||||
hatchPet (pet) {
|
hatchPet (pet) {
|
||||||
this.$store.dispatch('common:hatch', {egg: pet.eggKey, hatchingPotion: pet.potionKey});
|
|
||||||
|
|
||||||
this.closeHatchPetDialog();
|
this.closeHatchPetDialog();
|
||||||
// this.$root.$emit('hatchedPet::open', pet);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
this.$store.dispatch('common:hatch', {egg: pet.eggKey, hatchingPotion: pet.potionKey});
|
||||||
|
this.text(this.$t('hatchedPet', {egg: pet.eggKey, potion: pet.potionKey}));
|
||||||
|
},
|
||||||
onDragStart (ev, food) {
|
onDragStart (ev, food) {
|
||||||
this.currentDraggingFood = food;
|
this.currentDraggingFood = food;
|
||||||
|
|
||||||
@@ -903,7 +886,6 @@
|
|||||||
|
|
||||||
dragEvent.dataTransfer.setDragImage(itemRef, -20, -20);
|
dragEvent.dataTransfer.setDragImage(itemRef, -20, -20);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDragOver (ev, pet) {
|
onDragOver (ev, pet) {
|
||||||
if (!pet.isAllowedToFeed()) {
|
if (!pet.isAllowedToFeed()) {
|
||||||
ev.dropable = false;
|
ev.dropable = false;
|
||||||
@@ -911,7 +893,6 @@
|
|||||||
this.highlightPet = pet.key;
|
this.highlightPet = pet.key;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async onDrop (ev, pet) {
|
async onDrop (ev, pet) {
|
||||||
this.highlightPet = '';
|
this.highlightPet = '';
|
||||||
|
|
||||||
@@ -922,11 +903,9 @@
|
|||||||
this.currentDraggingFood = null;
|
this.currentDraggingFood = null;
|
||||||
this.highlightPet = '';
|
this.highlightPet = '';
|
||||||
},
|
},
|
||||||
|
|
||||||
onDragLeave () {
|
onDragLeave () {
|
||||||
this.highlightPet = '';
|
this.highlightPet = '';
|
||||||
},
|
},
|
||||||
|
|
||||||
petClicked (pet) {
|
petClicked (pet) {
|
||||||
if (this.currentDraggingFood !== null) {
|
if (this.currentDraggingFood !== null) {
|
||||||
if (pet.isAllowedToFeed()) {
|
if (pet.isAllowedToFeed()) {
|
||||||
@@ -944,18 +923,22 @@
|
|||||||
if (!pet.isHatchable()) {
|
if (!pet.isHatchable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// opens the hatch dialog
|
|
||||||
this.hatchablePet = pet;
|
|
||||||
|
|
||||||
|
if (this.user.preferences.suppressModals.raisePet) {
|
||||||
|
this.hatchPet(pet);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirm
|
||||||
|
this.hatchablePet = pet;
|
||||||
this.$root.$emit('bv::show::modal', 'hatching-modal');
|
this.$root.$emit('bv::show::modal', 'hatching-modal');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async feedAction (petKey, foodKey) {
|
async feedAction (petKey, foodKey) {
|
||||||
const result = await this.$store.dispatch('common:feed', {pet: petKey, food: foodKey});
|
const result = await this.$store.dispatch('common:feed', {pet: petKey, food: foodKey});
|
||||||
|
if (result.message) this.text(result.message);
|
||||||
if (result.message) {
|
if (this.user.preferences.suppressModals.raisePet) return;
|
||||||
this.text(result.message);
|
if (this.user.items.pets[petKey] === -1) this.$root.$emit('habitica::mount-raised', petKey);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
closeHatchPetDialog () {
|
closeHatchPetDialog () {
|
||||||
this.$root.$emit('bv::hide::modal', 'hatching-modal');
|
this.$root.$emit('bv::hide::modal', 'hatching-modal');
|
||||||
@@ -986,7 +969,6 @@
|
|||||||
lastMouseMoveEvent = $event;
|
lastMouseMoveEvent = $event;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hideFlag () {
|
hideFlag () {
|
||||||
this.$store.dispatch('user:set', {
|
this.$store.dispatch('user:set', {
|
||||||
'flags.tutorial.common.mounts': true,
|
'flags.tutorial.common.mounts': true,
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<template lang="pug">
|
||||||
|
b-modal#mount-raised-modal(:hide-header="true")
|
||||||
|
div.content(v-if="mount != null")
|
||||||
|
div.dialog-header.title(v-once) {{ $t('raisedPet', {pet: mount.text()}) }}
|
||||||
|
div.inner-content
|
||||||
|
div.pet-background
|
||||||
|
.mount(:class="`Mount_Icon_${mount.key}`")
|
||||||
|
h4.title {{ mount.text() }}
|
||||||
|
button.btn.btn-primary.onward(@click="close()") {{ $t('onward') }}
|
||||||
|
div.clearfix(slot="modal-footer")
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import '~client/assets/scss/colors.scss';
|
||||||
|
@import '~client/assets/scss/modal.scss';
|
||||||
|
|
||||||
|
#mount-raised-modal {
|
||||||
|
@include centeredModal();
|
||||||
|
|
||||||
|
.modal-dialog {
|
||||||
|
width: 330px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inner-content {
|
||||||
|
margin: 24px auto auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pet-background {
|
||||||
|
width: 112px;
|
||||||
|
height: 112px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: $gray-700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mount {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-header {
|
||||||
|
color: $purple-200;
|
||||||
|
}
|
||||||
|
|
||||||
|
.onward {
|
||||||
|
margin-top: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import markdownDirective from 'client/directives/markdown';
|
||||||
|
import {mountInfo} from 'common/script/content/stable';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
mount: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
directives: {
|
||||||
|
markdown: markdownDirective,
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.$root.$on('habitica::mount-raised', this.openDialog);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
this.$root.$off('habitica::mount-raised', this.openDialog);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
openDialog (mountKey) {
|
||||||
|
this.mount = mountInfo[mountKey];
|
||||||
|
this.$root.$emit('bv::show::modal', 'mount-raised-modal');
|
||||||
|
},
|
||||||
|
close () {
|
||||||
|
this.$root.$emit('bv::hide::modal', 'mount-raised-modal');
|
||||||
|
this.mount = null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
hideText: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -26,7 +26,6 @@ export function hatch (store, params) {
|
|||||||
export async function feed (store, params) {
|
export async function feed (store, params) {
|
||||||
const user = store.state.user.data;
|
const user = store.state.user.data;
|
||||||
feedOp(user, {params});
|
feedOp(user, {params});
|
||||||
|
|
||||||
const response = await axios
|
const response = await axios
|
||||||
.post(`/api/v3/user/feed/${params.pet}/${params.food}`);
|
.post(`/api/v3/user/feed/${params.pet}/${params.food}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
Reference in New Issue
Block a user