mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
fix(modals): SM modal fixes
Fixes #6253, allows quest pets to appear in hatching and raising modals, and makes code for deciding whether or not to show a generic levelup modal a bit more readable per comments on #6042.
This commit is contained in:
@@ -116,7 +116,7 @@ habitrpg.controller("InventoryCtrl",
|
|||||||
if (!$window.confirm(window.env.t('hatchAPot', {potion: potName, egg: eggName}))) return;
|
if (!$window.confirm(window.env.t('hatchAPot', {potion: potName, egg: eggName}))) return;
|
||||||
user.ops.hatch({params:{egg:egg.key, hatchingPotion:potion.key}});
|
user.ops.hatch({params:{egg:egg.key, hatchingPotion:potion.key}});
|
||||||
if (!user.preferences.suppressModals.hatchPet) {
|
if (!user.preferences.suppressModals.hatchPet) {
|
||||||
$rootScope.hatchedPet = {egg: eggName, potion: potName, eggKey: egg.key, pet: 'Pet-' + egg.key + '-' + potion.key};
|
$rootScope.hatchedPet = {egg: eggName, potion: potName, potionKey:potion.key, eggKey: egg.key, pet: 'Pet-' + egg.key + '-' + potion.key};
|
||||||
$rootScope.openModal('hatchPet', {controller: 'InventoryCtrl', size: 'sm'});
|
$rootScope.openModal('hatchPet', {controller: 'InventoryCtrl', size: 'sm'});
|
||||||
}
|
}
|
||||||
$scope.selectedEgg = null;
|
$scope.selectedEgg = null;
|
||||||
@@ -150,7 +150,7 @@ habitrpg.controller("InventoryCtrl",
|
|||||||
// Feeding Pet
|
// Feeding Pet
|
||||||
if ($scope.selectedFood) {
|
if ($scope.selectedFood) {
|
||||||
var food = $scope.selectedFood;
|
var food = $scope.selectedFood;
|
||||||
var startingMounts = $scope.mountCount;
|
var startingMounts = Stats.totalCount(user.items.mounts);
|
||||||
if (food.key === 'Saddle') {
|
if (food.key === 'Saddle') {
|
||||||
if (!$window.confirm(window.env.t('useSaddle', {pet: petDisplayName}))) return;
|
if (!$window.confirm(window.env.t('useSaddle', {pet: petDisplayName}))) return;
|
||||||
} else if (!$window.confirm(window.env.t('feedPet', {name: petDisplayName, article: food.article, text: food.text()}))) {
|
} else if (!$window.confirm(window.env.t('feedPet', {name: petDisplayName, article: food.article, text: food.text()}))) {
|
||||||
@@ -160,7 +160,7 @@ habitrpg.controller("InventoryCtrl",
|
|||||||
$scope.selectedFood = null;
|
$scope.selectedFood = null;
|
||||||
|
|
||||||
_updateDropAnimalCount(user.items);
|
_updateDropAnimalCount(user.items);
|
||||||
if ($scope.mountCount > startingMounts && !user.preferences.suppressModals.raisePet) {
|
if (Stats.totalCount(user.items.mounts) > startingMounts && !user.preferences.suppressModals.raisePet) {
|
||||||
$rootScope.raisedPet = {displayName: petDisplayName, spriteName: pet, egg: egg, potion: potion}
|
$rootScope.raisedPet = {displayName: petDisplayName, spriteName: pet, egg: egg, potion: potion}
|
||||||
$rootScope.openModal('raisePet', {controller:'InventoryCtrl',size:'sm'});
|
$rootScope.openModal('raisePet', {controller:'InventoryCtrl',size:'sm'});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,14 +60,19 @@ habitrpg.controller('NotificationCtrl',
|
|||||||
Notification.mp(mana);
|
Notification.mp(mana);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Levels that already display modals and should not trigger generic Level Up
|
||||||
|
var unlockLevels = {
|
||||||
|
'3': 'drop system',
|
||||||
|
'10': 'class system',
|
||||||
|
'50': 'Orb of Rebirth'
|
||||||
|
}
|
||||||
|
|
||||||
$rootScope.$watch('user.stats.lvl', function(after, before) {
|
$rootScope.$watch('user.stats.lvl', function(after, before) {
|
||||||
if (after <= before) return;
|
if (after <= before) return;
|
||||||
Notification.lvl();
|
Notification.lvl();
|
||||||
$rootScope.playSound('Level_Up');
|
$rootScope.playSound('Level_Up');
|
||||||
if (User.user._tmp && User.user._tmp.drop && (User.user._tmp.drop.type === 'Quest')) return;
|
if (User.user._tmp && User.user._tmp.drop && (User.user._tmp.drop.type === 'Quest')) return;
|
||||||
if (after === 3) return; // Drop system unlock. FIXME can we do this without hardcoding?
|
if (unlockLevels['' + after]) return;
|
||||||
if (after === 10) return; // Class system unlock. FIXME as above
|
|
||||||
if (after === 50) return; // Orb of Rebirth unlock FIXME as above
|
|
||||||
if (!User.user.preferences.suppressModals.levelUp) $rootScope.openModal('levelUp', {controller:'UserCtrl', size:'sm'});
|
if (!User.user.preferences.suppressModals.levelUp) $rootScope.openModal('levelUp', {controller:'UserCtrl', size:'sm'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ script(type='text/ng-template', id='modals/hatchPet.html')
|
|||||||
+generatedAvatar
|
+generatedAvatar
|
||||||
p=env.t('earnedCompanion')
|
p=env.t('earnedCompanion')
|
||||||
br
|
br
|
||||||
button.btn.btn-primary(ng-click='choosePet(hatchedPet.eggKey, hatchedPet.potion); $close()')=env.t('displayNow')
|
button.btn.btn-primary(ng-click='choosePet(hatchedPet.eggKey, hatchedPet.potionKey); $close()')=env.t('displayNow')
|
||||||
button.btn.btn-default(ng-click='$close()')=env.t('displayLater')
|
button.btn.btn-default(ng-click='$close()')=env.t('displayLater')
|
||||||
.checkbox
|
.checkbox
|
||||||
label(style='display:inline-block')=env.t('dontShowAgain')
|
label(style='display:inline-block')=env.t('dontShowAgain')
|
||||||
|
|||||||
Reference in New Issue
Block a user