diff --git a/app/views/game-menu/GameMenuModal.coffee b/app/views/game-menu/GameMenuModal.coffee index b2d1aca45..2881cc4a7 100644 --- a/app/views/game-menu/GameMenuModal.coffee +++ b/app/views/game-menu/GameMenuModal.coffee @@ -34,6 +34,7 @@ module.exports = class GameMenuModal extends ModalView @$el.toggleClas @insertSubView new submenuView @options for submenuView in submenuViews (if @options.showInventory then @subviews.inventory_view else @subviews.choose_hero_view).$el.addClass 'active' + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-open', volume: 1 onHidden: -> subview.onHidden?() for subviewKey, subview of @subviews diff --git a/app/views/game-menu/GuideView.coffee b/app/views/game-menu/GuideView.coffee index 8a4185396..39daf588f 100644 --- a/app/views/game-menu/GuideView.coffee +++ b/app/views/game-menu/GuideView.coffee @@ -14,3 +14,4 @@ module.exports = class GuideView extends CocoView afterRender: -> super() + #Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'guide-open', volume: 1 # no, only when the tab is activated diff --git a/app/views/kinds/RootView.coffee b/app/views/kinds/RootView.coffee index ebd44c0b5..78a03fc0b 100644 --- a/app/views/kinds/RootView.coffee +++ b/app/views/kinds/RootView.coffee @@ -134,6 +134,7 @@ module.exports = class RootView extends CocoView 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 else nah = document.exitFullscreen or document.mozCancelFullScreen or @@ -141,4 +142,5 @@ module.exports = class RootView extends CocoView document.msExitFullscreen or document.webkitExitFullscreen nah?.call document + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'full-screen-end', volume: 1 if nah return diff --git a/app/views/play/level/LevelGoalsView.coffee b/app/views/play/level/LevelGoalsView.coffee index cbc4c2075..15f0b5d7f 100644 --- a/app/views/play/level/LevelGoalsView.coffee +++ b/app/views/play/level/LevelGoalsView.coffee @@ -27,10 +27,9 @@ module.exports = class LevelGoalsView extends CocoView @mouseEntered = false @updatePlacement() - toggleCollapse: (e) -> - @$el.toggleClass('expanded').toggleClass('collapsed') - onNewGoalStates: (e) -> + firstRun = @previousGoalStatus? + @previousGoalStatus ?= {} @$el.find('.goal-status').addClass 'secret' classToShow = null classToShow = 'success' if e.overallStatus is 'success' @@ -38,7 +37,6 @@ module.exports = class LevelGoalsView extends CocoView classToShow ?= 'timed-out' if e.timedOut classToShow ?= 'incomplete' @$el.find('.goal-status.'+classToShow).removeClass 'secret' - list = $('#primary-goals-list', @$el) list.empty() goals = [] @@ -63,6 +61,10 @@ module.exports = class LevelGoalsView extends CocoView li.prepend($('').addClass(stateIconMap[state.status])) list.append(li) goals.push goal + if not firstRun and state.status is 'success' and @previousGoalStatus[goal.id] isnt 'success' + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'goal-success', volume: 1 + else if not firstRun and state.status is 'incomplete' and @previousGoalStatus[goal.id] is 'success' + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'goal-incomplete-again', volume: 1 @$el.removeClass('secret') if goals.length > 0 onSurfacePlaybackRestarted: -> @@ -84,12 +86,13 @@ module.exports = class LevelGoalsView extends CocoView @updatePlacement() updatePlacement: -> - if @playbackEnded or @mouseEntered - # expand - @$el.css('top', -10) - else - # collapse - @$el.css('top', 26 - @$el.outerHeight()) + expand = @playbackEnded or @mouseEntered + return if expand is @expanded + sound = if expand then 'goals-expand' else 'goals-collapse' + top = if expand then -10 else 26 - @$el.outerHeight() + @$el.css 'top', top + Backbone.Mediator.publish 'audio-player:play-sound', trigger: sound, volume: 1 if @expanded? + @expanded = expand onSetLetterbox: (e) -> @$el.toggle not e.on diff --git a/app/views/play/level/LevelLoadingView.coffee b/app/views/play/level/LevelLoadingView.coffee index acd15c67d..383d969c3 100644 --- a/app/views/play/level/LevelLoadingView.coffee +++ b/app/views/play/level/LevelLoadingView.coffee @@ -31,6 +31,7 @@ module.exports = class LevelLoadingView extends CocoView loadingDetails.css 'top', -loadingDetails.outerHeight(true) @$el.find('.left-wing').css left: '-100%', backgroundPosition: 'right -400px top 0' @$el.find('.right-wing').css right: '-100%', backgroundPosition: 'left -400px top 0' + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'loading-view-unveil', volume: 1 _.delay @onUnveilEnded, duration * 1000 onUnveilEnded: => diff --git a/app/views/play/level/LevelPlaybackView.coffee b/app/views/play/level/LevelPlaybackView.coffee index e3803913f..fcf691500 100644 --- a/app/views/play/level/LevelPlaybackView.coffee +++ b/app/views/play/level/LevelPlaybackView.coffee @@ -165,6 +165,7 @@ module.exports = class LevelPlaybackView extends CocoView @realTime = true @togglePlaybackControls false Backbone.Mediator.publish 'playback:real-time-playback-started', {} + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'real-time-playback-start', volume: 1 onRealTimeMultiplayerCast: (e) -> @realTime = true @@ -226,7 +227,9 @@ module.exports = class LevelPlaybackView extends CocoView @playing = (e ? {}).playing ? true button = @$el.find '#play-button' ended = button.hasClass 'ended' + changed = button.hasClass('playing') isnt @playing button.toggleClass('playing', @playing and not ended).toggleClass('paused', not @playing and not ended) + Backbone.Mediator.publish 'audio-player:play-sound', trigger: (if @playing then 'playback-play' else 'playback-pause'), volume: 1 return # don't stripe the bar bar = @$el.find '.scrubber .progress' bar.toggleClass('progress-striped', @playing and not ended).toggleClass('active', @playing and not ended) @@ -306,6 +309,7 @@ module.exports = class LevelPlaybackView extends CocoView return unless @realTime @realTime = false @togglePlaybackControls true + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'real-time-playback-end', volume: 1 onStopRealTimePlayback: (e) -> Backbone.Mediator.publish 'playback:real-time-playback-ended', {} @@ -323,14 +327,19 @@ module.exports = class LevelPlaybackView extends CocoView animate: 'slow' slide: (event, ui) => return if @shouldIgnore() + ++@slideCount + oldRatio = @getScrubRatio() @scrubTo ui.value / @sliderIncrements - @slideCount += 1 + if ratioChange = @getScrubRatio() - oldRatio + sound = "playback-scrub-slide-#{if ratioChange > 0 then 'forward' else 'back'}-#{@slideCount % 3}" + Backbone.Mediator.publish 'audio-player:play-sound', trigger: sound, volume: Math.min 1, Math.abs ratioChange * 50 start: (event, ui) => return if @shouldIgnore() @slideCount = 0 @wasPlaying = @playing Backbone.Mediator.publish 'level:set-playing', {playing: false} + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-start', volume: 1 stop: (event, ui) => return if @shouldIgnore() @@ -341,6 +350,8 @@ module.exports = class LevelPlaybackView extends CocoView @wasPlaying = false Backbone.Mediator.publish 'level:set-playing', {playing: false} @$el.find('.scrubber-handle').effect('bounce', {times: 2}) + else + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-end', volume: 1 ) getScrubRatio: -> diff --git a/app/views/play/level/modal/LevelGuideModal.coffee b/app/views/play/level/modal/LevelGuideModal.coffee index 0d54a71a7..d2b3c4b41 100644 --- a/app/views/play/level/modal/LevelGuideModal.coffee +++ b/app/views/play/level/modal/LevelGuideModal.coffee @@ -46,9 +46,11 @@ module.exports = class LevelGuideModal extends ModalView @$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 clickTab: (e) => @$el.find('li.active').removeClass('active') + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'guide-tab-switch', volume: 1 afterInsert: -> super() diff --git a/app/views/play/level/tome/SpellListTabEntryView.coffee b/app/views/play/level/tome/SpellListTabEntryView.coffee index 744b9d465..d00e3aa6f 100644 --- a/app/views/play/level/tome/SpellListTabEntryView.coffee +++ b/app/views/play/level/tome/SpellListTabEntryView.coffee @@ -89,6 +89,7 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView onDropdownClick: (e) -> return unless @controlsEnabled Backbone.Mediator.publish 'tome:toggle-spell-list', {} + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'spell-list-open', volume: 1 onCodeReload: (e) -> return unless @controlsEnabled diff --git a/app/views/play/level/tome/SpellPaletteEntryView.coffee b/app/views/play/level/tome/SpellPaletteEntryView.coffee index ca9270616..3f81a5d4c 100644 --- a/app/views/play/level/tome/SpellPaletteEntryView.coffee +++ b/app/views/play/level/tome/SpellPaletteEntryView.coffee @@ -48,6 +48,7 @@ module.exports = class SpellPaletteEntryView extends CocoView window.element = @$el @$el.on 'show.bs.popover', => Backbone.Mediator.publish 'tome:palette-hovered', thang: @thang, prop: @doc.name, entry: @ + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'spell-palette-entry-open', volume: 1 onMouseEnter: (e) -> # Make sure the doc has the updated Thang so it can regenerate its prop value @@ -71,6 +72,7 @@ module.exports = class SpellPaletteEntryView extends CocoView x = $('') $('.spell-palette-popover.popover').append x x.on 'click', @onClick + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'spell-palette-entry-pin', volume: 1 Backbone.Mediator.publish 'tome:palette-pin-toggled', entry: @, pinned: @popoverPinned onClick: (e) => diff --git a/app/views/play/level/tome/SpellView.coffee b/app/views/play/level/tome/SpellView.coffee index b1b7cadae..8f71c0c02 100644 --- a/app/views/play/level/tome/SpellView.coffee +++ b/app/views/play/level/tome/SpellView.coffee @@ -348,6 +348,7 @@ module.exports = class SpellView extends CocoView ] @onCodeChangeMetaHandler = => return if @eventsSuppressed + Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'code-change', volume: 0.5 @spell.hasChangedSignificantly @getSource(), @spellThang.aether.raw, (hasChanged) => if not @spellThang or hasChanged callback() for callback in onSignificantChange # Do these first