mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Implemented placeholders for a bunch of sound triggers.
This commit is contained in:
parent
9b8b30f3c5
commit
8de75024fc
10 changed files with 36 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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($('<i></i>').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
|
||||
|
|
|
@ -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: =>
|
||||
|
|
|
@ -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: ->
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = $('<button type="button" data-dismiss="modal" aria-hidden="true" class="close">×</button>')
|
||||
$('.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) =>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue