mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Added a bunch of button click sound triggers.
This commit is contained in:
parent
09d67a8189
commit
24ac3050bd
23 changed files with 70 additions and 24 deletions
|
@ -31,6 +31,7 @@ module.exports = class HomeView extends RootView
|
|||
c
|
||||
|
||||
onClickBeginnerCampaign: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
window.tracker?.trackEvent 'Homepage', Action: 'Play'
|
||||
|
|
|
@ -51,15 +51,15 @@ module.exports = class GameMenuModal extends ModalView
|
|||
firstView = (@subviews.options_view)
|
||||
firstView.$el.addClass 'active'
|
||||
firstView.onShown?()
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-open', volume: 1
|
||||
@playSound 'game-menu-open'
|
||||
@$el.find('.nano:visible').nanoScroller()
|
||||
|
||||
onTabShown: (e) ->
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-tab-switch', volume: 1
|
||||
@playSound 'game-menu-tab-switch'
|
||||
@subviews[e.target.hash.substring(1).replace(/-/g, '_')].onShown?()
|
||||
|
||||
onHidden: ->
|
||||
super()
|
||||
subview.onHidden?() for subviewKey, subview of @subviews
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
||||
@playSound 'game-menu-close'
|
||||
Backbone.Mediator.publish 'music-player:exit-menu', {}
|
||||
|
|
|
@ -44,11 +44,11 @@ module.exports = class LevelGuideView extends CocoView
|
|||
@$el.find('.nav-tabs li:first').addClass('active')
|
||||
@$el.find('.tab-content .tab-pane:first').addClass('active')
|
||||
@$el.find('.nav-tabs a').click(@clickTab)
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'guide-open', volume: 1
|
||||
@playSound 'guide-open'
|
||||
|
||||
clickTab: (e) =>
|
||||
@$el.find('li.active').removeClass('active')
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'guide-tab-switch', volume: 1
|
||||
@playSound 'guide-tab-switch'
|
||||
|
||||
afterInsert: ->
|
||||
super()
|
||||
|
|
|
@ -205,10 +205,12 @@ module.exports = class InventoryModal extends ModalView
|
|||
|
||||
onItemSlotClick: (e) ->
|
||||
return if @remainingRequiredEquipment?.length # Don't let them select a slot if we need them to first equip some require gear.
|
||||
@playSound 'menu-button-click'
|
||||
@selectItemSlot($(e.target).closest('.item-slot'))
|
||||
|
||||
onUnequippedItemClick: (e) ->
|
||||
return if @justDoubleClicked
|
||||
@playSound 'menu-button-click'
|
||||
itemEl = $(e.target).closest('.item')
|
||||
@selectUnequippedItem(itemEl)
|
||||
|
||||
|
@ -224,6 +226,7 @@ module.exports = class InventoryModal extends ModalView
|
|||
onClickUnequipItemViewed: -> @unequipSelectedItem()
|
||||
|
||||
onClickEquipItemButton: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
itemEl = $(e.target).closest('.item')
|
||||
@selectUnequippedItem(itemEl)
|
||||
@equipSelectedItem()
|
||||
|
@ -403,11 +406,13 @@ module.exports = class InventoryModal extends ModalView
|
|||
super()
|
||||
|
||||
onClickChooseHero: ->
|
||||
@playSound 'menu-button-click'
|
||||
@hide()
|
||||
@trigger 'choose-hero-click'
|
||||
|
||||
onClickPlayLevel: (e) ->
|
||||
return if @$el.find('#play-level-button').prop 'disabled'
|
||||
@playSound 'menu-button-click'
|
||||
@showLoading()
|
||||
ua = navigator.userAgent.toLowerCase()
|
||||
unless hasGoneFullScreenOnce or (/safari/.test(ua) and not /chrome/.test(ua)) or $(window).height() >= 658 # Min vertical resolution needed at 1366px wide
|
||||
|
@ -440,7 +445,7 @@ module.exports = class InventoryModal extends ModalView
|
|||
else
|
||||
callback?()
|
||||
|
||||
#- TODO: DRY this between PlayItemsModal and InventoryModal
|
||||
#- TODO: DRY this between PlayItemsModal and InventoryModal and PlayHeroesModal
|
||||
|
||||
onUnlockButtonClicked: (e) ->
|
||||
e.stopPropagation()
|
||||
|
@ -448,8 +453,10 @@ module.exports = class InventoryModal extends ModalView
|
|||
item = @items.get(button.data('item-id'))
|
||||
affordable = item.affordable
|
||||
if not affordable
|
||||
@playSound 'menu-button-click'
|
||||
@askToBuyGems button
|
||||
else if button.hasClass('confirm')
|
||||
@playSound 'menu-button-unlock-end'
|
||||
purchase = Purchase.makeFor(item)
|
||||
purchase.save()
|
||||
|
||||
|
@ -475,6 +482,7 @@ module.exports = class InventoryModal extends ModalView
|
|||
|
||||
Backbone.Mediator.publish 'store:item-purchased', item: item, itemSlug: item.get('slug')
|
||||
else
|
||||
@playSound 'menu-button-unlock-start'
|
||||
button.addClass('confirm').text($.i18n.t('play.confirm'))
|
||||
@$el.one 'click', (e) ->
|
||||
button.removeClass('confirm').text($.i18n.t('play.unlock')) if e.target isnt button[0]
|
||||
|
@ -496,6 +504,7 @@ module.exports = class InventoryModal extends ModalView
|
|||
popover?.$tip?.i18n()
|
||||
|
||||
onBuyGemsPromptButtonClicked: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
@openModalView new BuyGemsModal()
|
||||
|
||||
onClickedSomewhere: (e) ->
|
||||
|
|
|
@ -162,6 +162,7 @@ module.exports = class MultiplayerView extends CocoView
|
|||
@render?()
|
||||
|
||||
onCreateRealTimeGame: ->
|
||||
@playSound 'menu-button-click'
|
||||
s = @realTimeSessions.create {
|
||||
creator: @session.get('creator')
|
||||
creatorName: @session.get('creatorName')
|
||||
|
@ -184,6 +185,7 @@ module.exports = class MultiplayerView extends CocoView
|
|||
|
||||
onJoinRealTimeGame: (e) ->
|
||||
return if @currentRealTimeSession
|
||||
@playSound 'menu-button-click'
|
||||
item = @$el.find(e.target).data('item')
|
||||
@currentRealTimeSession = @realTimeSessions.get(item.id)
|
||||
@currentRealTimeSession.on 'change', @onCurrentRealTimeSessionChanged
|
||||
|
@ -209,6 +211,7 @@ module.exports = class MultiplayerView extends CocoView
|
|||
@render()
|
||||
|
||||
onLeaveRealTimeGame: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
if @currentRealTimeSession
|
||||
@currentRealTimeSession.off 'change', @onCurrentRealTimeSessionChanged
|
||||
@currentRealTimeSession = null
|
||||
|
|
|
@ -63,6 +63,7 @@ module.exports = class OptionsView extends CocoView
|
|||
me.set 'volume', volume
|
||||
@$el.find('#option-volume-value').text (volume * 100).toFixed(0) + '%'
|
||||
Backbone.Mediator.publish 'level:set-volume', volume: volume
|
||||
@playSound 'menu-button-click' # Could have another volume-indicating noise
|
||||
|
||||
onHidden: ->
|
||||
if @playerName and @playerName isnt me.get('name')
|
||||
|
@ -109,6 +110,7 @@ module.exports = class OptionsView extends CocoView
|
|||
|
||||
onEditProfilePhoto: (e) ->
|
||||
return if window.application.isIPadApp # TODO: have an iPad-native way of uploading a photo, since we don't want to load FilePicker on iPad (memory)
|
||||
@playSound 'menu-button-click'
|
||||
photoContainer = @$el.find('.profile-photo')
|
||||
onSaving = =>
|
||||
photoContainer.addClass('saving')
|
||||
|
|
|
@ -19,6 +19,7 @@ module.exports = class SaveLoadView extends CocoView
|
|||
super()
|
||||
|
||||
onSaveGranularityChanged: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
toShow = $(e.target).val()
|
||||
@$el.find('.save-list, .save-pane').hide()
|
||||
@$el.find('.save-list.' + toShow + ', .save-pane.' + toShow).show()
|
||||
|
|
|
@ -428,7 +428,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
d.msRequestFullscreen or
|
||||
(if d.webkitRequestFullscreen then -> d.webkitRequestFullscreen Element.ALLOW_KEYBOARD_INPUT else null)
|
||||
req?.call d
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'full-screen-start', volume: 1 if req
|
||||
@playSound 'full-screen-start' if req
|
||||
else
|
||||
nah = document.exitFullscreen or
|
||||
document.mozCancelFullScreen or
|
||||
|
@ -436,9 +436,12 @@ module.exports = class CocoView extends Backbone.View
|
|||
document.msExitFullscreen or
|
||||
document.webkitExitFullscreen
|
||||
nah?.call document
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'full-screen-end', volume: 1 if nah
|
||||
@playSound 'full-screen-end' if req
|
||||
return
|
||||
|
||||
playSound: (trigger, volume=1) ->
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: trigger, volume: volume
|
||||
|
||||
mobileRELong = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i
|
||||
mobileREShort = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i
|
||||
|
||||
|
|
|
@ -50,23 +50,27 @@ module.exports = class AuthModal extends ModalView
|
|||
_.delay (=> $('input:visible:first', @$el).focus()), 500
|
||||
|
||||
onSignupInstead: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
@mode = 'signup'
|
||||
@previousFormInputs = forms.formToObject @$el
|
||||
@render()
|
||||
_.delay application.router.renderLoginButtons, 500
|
||||
|
||||
onLoginInstead: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
@mode = 'login'
|
||||
@previousFormInputs = forms.formToObject @$el
|
||||
@render()
|
||||
_.delay application.router.renderLoginButtons, 500
|
||||
|
||||
onSubmitForm: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
e.preventDefault()
|
||||
if @mode is 'login' then @loginAccount() else @createAccount()
|
||||
false
|
||||
|
||||
checkAge: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
$('#signup-button', @$el).prop 'disabled', not $(e.target).prop('checked')
|
||||
|
||||
loginAccount: ->
|
||||
|
@ -116,6 +120,7 @@ module.exports = class AuthModal extends ModalView
|
|||
forms.setErrorToProperty @$el, 'name', "That name is taken! How about #{newName}?", true
|
||||
|
||||
onGitHubLoginClicked: ->
|
||||
@playSound 'menu-button-click'
|
||||
Backbone.Mediator.publish 'auth:log-in-with-github', {}
|
||||
|
||||
gplusAuthSteps: [
|
||||
|
@ -126,6 +131,7 @@ module.exports = class AuthModal extends ModalView
|
|||
]
|
||||
|
||||
onClickGPlusLogin: ->
|
||||
@playSound 'menu-button-click'
|
||||
step.done = false for step in @gplusAuthSteps
|
||||
handler = application.gplusHandler
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ module.exports = class ContactModal extends ModalView
|
|||
'click #contact-submit-button': 'contact'
|
||||
|
||||
contact: ->
|
||||
@playSound 'menu-button-click'
|
||||
forms.clearFormAlerts @$el
|
||||
contactMessage = forms.formToObject @$el
|
||||
res = tv4.validateMultiple contactMessage, contactSchema
|
||||
|
|
|
@ -28,6 +28,7 @@ module.exports = class RecoverModal extends ModalView
|
|||
super options
|
||||
|
||||
recoverAccount: (e) =>
|
||||
@playSound 'menu-button-click'
|
||||
forms.clearFormAlerts(@$el)
|
||||
email = (forms.formToObject @$el).email
|
||||
return unless email
|
||||
|
|
|
@ -48,6 +48,7 @@ module.exports = class LadderSubmissionView extends CocoView
|
|||
|
||||
rankSession: (e) ->
|
||||
return unless @session.readyToRank()
|
||||
@playSound 'menu-button-click'
|
||||
@setRankingButtonText 'submitting'
|
||||
success = =>
|
||||
@setRankingButtonText 'submitted' unless @destroyed
|
||||
|
@ -87,4 +88,5 @@ module.exports = class LadderSubmissionView extends CocoView
|
|||
transpiledCode
|
||||
|
||||
onHelpSimulate: ->
|
||||
@playSound 'menu-button-click'
|
||||
$('a[href="#simulate"]').tab('show')
|
||||
|
|
|
@ -49,6 +49,7 @@ module.exports = class LevelFlagsView extends CocoView
|
|||
|
||||
onFlagSelected: (e) ->
|
||||
return unless @realTime
|
||||
@playSound 'menu-button-click' if e.color
|
||||
color = if e.color is @flagColor then null else e.color
|
||||
@flagColor = color
|
||||
Backbone.Mediator.publish 'level:flag-color-selected', color: color
|
||||
|
@ -57,6 +58,7 @@ module.exports = class LevelFlagsView extends CocoView
|
|||
|
||||
onStageMouseDown: (e) ->
|
||||
return unless @flagColor and @realTime
|
||||
@playSound 'menu-button-click' # TODO: different flag placement sound?
|
||||
pos = x: e.worldPos.x, y: e.worldPos.y
|
||||
delay = if @realTimeFlags then multiplayerFlagDelay else 0
|
||||
now = @world.dt * @world.frames.length
|
||||
|
|
|
@ -72,6 +72,7 @@ module.exports = class LevelLoadingView extends CocoView
|
|||
@$el.find('.start-level-button').removeClass 'secret'
|
||||
|
||||
startUnveiling: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
Backbone.Mediator.publish 'level:loading-view-unveiling', {}
|
||||
_.delay @onClickStartLevel, 1000 # If they never mouse-up for the click (or a modal shows up and interrupts the click), do it anyway.
|
||||
|
||||
|
|
|
@ -293,6 +293,7 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
levelInfo?.nextLevels?[type] # 'more_practice', 'skip_ahead', 'continue'
|
||||
|
||||
onClickContinue: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
nextLevelLink = @continueLevelLink
|
||||
if me.getBranchingGroup() is 'all-practice' and @morePracticeLevelLink
|
||||
nextLevelLink = @morePracticeLevelLink
|
||||
|
@ -307,6 +308,7 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
@$el.find('.next-levels-prompt').show()
|
||||
|
||||
onClickNextLevelBranch: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
e.preventDefault()
|
||||
route = $(e.target).data('href') or "/play/#{@getNextLevelCampaign()}"
|
||||
application.tracker?.trackEvent 'Branch Selected', level: @level.get('slug'), label: @level.get('slug'), branch: $(e.target).data('branch-key'), branchingGroup: me.getBranchingGroup(), route: route
|
||||
|
@ -314,6 +316,7 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
Backbone.Mediator.publish 'router:navigate', route: route, viewClass: require('views/play/WorldMapView'), viewArgs: [{supermodel: if @options.hasReceivedMemoryWarning then null else @supermodel}, @getNextLevelCampaign()]
|
||||
|
||||
onClickReturnToLadder: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
e.preventDefault()
|
||||
route = $(e.target).data('href')
|
||||
# Preserve the supermodel as we navigate back to the ladder.
|
||||
|
|
|
@ -9,6 +9,7 @@ module.exports = class ReloadLevelModal extends ModalView
|
|||
'click #restart-level-confirm-button': 'onClickRestart'
|
||||
|
||||
onClickRestart: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
if key.shift
|
||||
Backbone.Mediator.publish 'level:restart', {}
|
||||
else
|
||||
|
|
|
@ -83,6 +83,7 @@ module.exports = class ProblemAlertView extends CocoView
|
|||
@onRemoveClicked()
|
||||
|
||||
onRemoveClicked: ->
|
||||
@playSound 'menu-button-click'
|
||||
@$el.hide()
|
||||
|
||||
onWindowResize: (e) =>
|
||||
|
|
|
@ -48,6 +48,7 @@ module.exports = class BuyGemsModal extends ModalView
|
|||
@render()
|
||||
|
||||
onClickProductButton: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
productID = $(e.target).closest('button').val()
|
||||
product = _.find @products, { id: productID }
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = class PlayAccountModal extends ModalView
|
|||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-open', volume: 1
|
||||
@playSound 'game-menu-open'
|
||||
@accountSettingsView = new AccountSettingsView()
|
||||
@insertSubView(@accountSettingsView)
|
||||
@listenTo @accountSettingsView, 'input-changed', @onInputChanged
|
||||
|
@ -31,7 +31,7 @@ module.exports = class PlayAccountModal extends ModalView
|
|||
|
||||
onHidden: ->
|
||||
super()
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
||||
@playSound 'game-menu-close'
|
||||
|
||||
onInputChanged: ->
|
||||
@$el.find('#save-button')
|
||||
|
|
|
@ -92,8 +92,8 @@ module.exports = class PlayAchievementsModal extends ModalView
|
|||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-open', volume: 1
|
||||
@playSound 'game-menu-open'
|
||||
|
||||
onHidden: ->
|
||||
super()
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
||||
@playSound 'game-menu-close'
|
||||
|
|
|
@ -225,9 +225,10 @@ module.exports = class PlayHeroesModal extends ModalView
|
|||
button = $(e.target).closest('button')
|
||||
affordable = @visibleHero.get('gems') <= me.gems()
|
||||
if not affordable
|
||||
@playSound 'menu-button-click'
|
||||
@askToBuyGems button
|
||||
else if button.hasClass('confirm')
|
||||
|
||||
@playSound 'menu-button-unlock-end'
|
||||
purchase = Purchase.makeFor(@visibleHero)
|
||||
purchase.save()
|
||||
|
||||
|
@ -246,6 +247,7 @@ module.exports = class PlayHeroesModal extends ModalView
|
|||
|
||||
Backbone.Mediator.publish 'store:hero-purchased', hero: @visibleHero, heroSlug: @visibleHero.get('slug')
|
||||
else
|
||||
@playSound 'menu-button-unlock-start'
|
||||
button.addClass('confirm').text($.i18n.t('play.confirm'))
|
||||
@$el.one 'click', (e) ->
|
||||
button.removeClass('confirm').text($.i18n.t('play.unlock')) if e.target isnt button[0]
|
||||
|
@ -267,6 +269,7 @@ module.exports = class PlayHeroesModal extends ModalView
|
|||
popover?.$tip?.i18n()
|
||||
|
||||
onBuyGemsPromptButtonClicked: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
@openModalView new BuyGemsModal()
|
||||
|
||||
onClickedSomewhere: (e) ->
|
||||
|
|
|
@ -127,6 +127,7 @@ module.exports = class PlayItemsModal extends ModalView
|
|||
|
||||
onItemClicked: (e) ->
|
||||
return if $(e.target).closest('.unlock-button').length
|
||||
@playSound 'menu-button-click'
|
||||
itemEl = $(e.target).closest('.item')
|
||||
wasSelected = itemEl.hasClass('selected')
|
||||
@$el.find('.item.selected').removeClass('selected')
|
||||
|
@ -141,6 +142,7 @@ module.exports = class PlayItemsModal extends ModalView
|
|||
@itemDetailsView.setItem(item)
|
||||
|
||||
onTabClicked: (e) ->
|
||||
@playSound 'game-menu-tab-switch'
|
||||
$($(e.target).attr('href')).find('.nano').nanoScroller({alwaysVisible: true})
|
||||
|
||||
onUnlockButtonClicked: (e) ->
|
||||
|
@ -149,9 +151,10 @@ module.exports = class PlayItemsModal extends ModalView
|
|||
item = @idToItem[button.data('item-id')]
|
||||
affordable = item.affordable
|
||||
if not affordable
|
||||
@playSound 'menu-button-click'
|
||||
@askToBuyGems button
|
||||
else if button.hasClass('confirm')
|
||||
|
||||
@playSound 'menu-button-unlock-end'
|
||||
purchase = Purchase.makeFor(item)
|
||||
purchase.save()
|
||||
|
||||
|
@ -169,6 +172,7 @@ module.exports = class PlayItemsModal extends ModalView
|
|||
|
||||
Backbone.Mediator.publish 'store:item-purchased', item: item, itemSlug: item.get('slug')
|
||||
else
|
||||
@playSound 'menu-button-unlock-start'
|
||||
button.addClass('confirm').text($.i18n.t('play.confirm'))
|
||||
@$el.one 'click', (e) ->
|
||||
button.removeClass('confirm').text($.i18n.t('play.unlock')) if e.target isnt button[0]
|
||||
|
@ -189,6 +193,7 @@ module.exports = class PlayItemsModal extends ModalView
|
|||
popover?.$tip?.i18n()
|
||||
|
||||
onBuyGemsPromptButtonClicked: (e) ->
|
||||
@playSound 'menu-button-click'
|
||||
@openModalView new BuyGemsModal()
|
||||
|
||||
onClickedSomewhere: (e) ->
|
||||
|
|
|
@ -21,8 +21,8 @@ module.exports = class PlaySettingsModal extends ModalView
|
|||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-open', volume: 1
|
||||
@playSound 'game-menu-open'
|
||||
|
||||
onHidden: ->
|
||||
super()
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
||||
@playSound 'game-menu-close'
|
||||
|
|
Loading…
Reference in a new issue