mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-28 15:03:57 -04:00
Hooked up some menu music transitions to play menu music during HeroVictoryModal and GameMenuModal.
This commit is contained in:
parent
4c33b98e27
commit
79ed8b2470
6 changed files with 40 additions and 6 deletions
app
lib/surface
schemas/subscriptions
views
game-menu
play
|
@ -14,6 +14,8 @@ module.exports = class MusicPlayer extends CocoClass
|
||||||
'audio-player:loaded': 'onAudioLoaded'
|
'audio-player:loaded': 'onAudioLoaded'
|
||||||
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
||||||
'playback:real-time-playback-ended': 'onRealTimePlaybackEnded'
|
'playback:real-time-playback-ended': 'onRealTimePlaybackEnded'
|
||||||
|
'music-player:enter-menu': 'onEnterMenu'
|
||||||
|
'music-player:exit-menu': 'onExitMenu'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super arguments...
|
super arguments...
|
||||||
|
@ -35,9 +37,10 @@ module.exports = class MusicPlayer extends CocoClass
|
||||||
@standingBy = e
|
@standingBy = e
|
||||||
return
|
return
|
||||||
|
|
||||||
|
delay = e.delay ? 0
|
||||||
@standingBy = null
|
@standingBy = null
|
||||||
@fadeOutCurrentMusic()
|
@fadeOutCurrentMusic()
|
||||||
@startNewMusic(src) if e.play
|
@startNewMusic(src, delay) if e.play
|
||||||
|
|
||||||
restartCurrentMusic: ->
|
restartCurrentMusic: ->
|
||||||
return unless @currentMusic
|
return unless @currentMusic
|
||||||
|
@ -46,15 +49,16 @@ module.exports = class MusicPlayer extends CocoClass
|
||||||
|
|
||||||
fadeOutCurrentMusic: ->
|
fadeOutCurrentMusic: ->
|
||||||
return unless @currentMusic
|
return unless @currentMusic
|
||||||
|
createjs.Tween.removeTweens(@currentMusic)
|
||||||
f = -> @stop()
|
f = -> @stop()
|
||||||
createjs.Tween.get(@currentMusic).to({volume: 0.0}, CROSSFADE_LENGTH).call(f)
|
createjs.Tween.get(@currentMusic).to({volume: 0.0}, CROSSFADE_LENGTH).call(f)
|
||||||
|
|
||||||
startNewMusic: (src) ->
|
startNewMusic: (src, delay) ->
|
||||||
@currentMusic = createjs.Sound.play(src, 'none', 0, 0, -1, 0.3) if src
|
@currentMusic = createjs.Sound.play(src, 'none', 0, 0, -1, 0.3) if src
|
||||||
return unless @currentMusic
|
return unless @currentMusic
|
||||||
@currentMusic.volume = 0.0
|
@currentMusic.volume = 0.0
|
||||||
if me.get('music', true)
|
if me.get('music', true)
|
||||||
createjs.Tween.get(@currentMusic).to({volume: MUSIC_VOLUME}, CROSSFADE_LENGTH)
|
createjs.Tween.get(@currentMusic).wait(delay).to({volume: MUSIC_VOLUME}, CROSSFADE_LENGTH)
|
||||||
|
|
||||||
onMusicSettingChanged: ->
|
onMusicSettingChanged: ->
|
||||||
@updateMusicVolume()
|
@updateMusicVolume()
|
||||||
|
@ -74,6 +78,24 @@ module.exports = class MusicPlayer extends CocoClass
|
||||||
if @previousMusic
|
if @previousMusic
|
||||||
@currentMusic = @previousMusic
|
@currentMusic = @previousMusic
|
||||||
@restartCurrentMusic()
|
@restartCurrentMusic()
|
||||||
|
if @currentMusic.volume
|
||||||
|
createjs.Tween.get(@currentMusic).wait(5000).to({volume: MUSIC_VOLUME}, CROSSFADE_LENGTH)
|
||||||
|
|
||||||
|
onEnterMenu: (e) ->
|
||||||
|
return if @inMenu
|
||||||
|
@inMenu = true
|
||||||
|
@previousMusic = @currentMusic
|
||||||
|
terrain = (e.terrain ? 'Dungeon').toLowerCase()
|
||||||
|
file = "/music/music-menu-#{terrain}"
|
||||||
|
Backbone.Mediator.publish 'music-player:play-music', file: file, play: true, delay: 1000
|
||||||
|
|
||||||
|
onExitMenu: (e) ->
|
||||||
|
return unless @inMenu
|
||||||
|
@inMenu = false
|
||||||
|
@fadeOutCurrentMusic()
|
||||||
|
if @previousMusic
|
||||||
|
@currentMusic = @previousMusic
|
||||||
|
@restartCurrentMusic()
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
me.off 'change:music', @onMusicSettingChanged, @
|
me.off 'change:music', @onMusicSettingChanged, @
|
||||||
|
|
|
@ -18,6 +18,12 @@ module.exports =
|
||||||
'music-player:play-music': c.object {required: ['play']},
|
'music-player:play-music': c.object {required: ['play']},
|
||||||
play: {type: 'boolean'}
|
play: {type: 'boolean'}
|
||||||
file: {type: 'string'}
|
file: {type: 'string'}
|
||||||
|
delay: {type: 'integer', minimum: 0, format: 'milliseconds'}
|
||||||
|
|
||||||
|
'music-player:enter-menu': c.object {required: []},
|
||||||
|
terrain: {type: 'string'}
|
||||||
|
|
||||||
|
'music-player:exit-menu': c.object {}
|
||||||
|
|
||||||
'modal:opened': c.object {}
|
'modal:opened': c.object {}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ module.exports = class GameMenuModal extends ModalView
|
||||||
@options.showInventory = @options.level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop']
|
@options.showInventory = @options.level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop']
|
||||||
@options.levelID = @options.level.get('slug')
|
@options.levelID = @options.level.get('slug')
|
||||||
@options.startingSessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
|
@options.startingSessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
|
||||||
|
Backbone.Mediator.publish 'music-player:enter-menu', terrain: @options.level.get('terrain', true)
|
||||||
|
|
||||||
getRenderData: (context={}) ->
|
getRenderData: (context={}) ->
|
||||||
context = super(context)
|
context = super(context)
|
||||||
|
@ -50,6 +51,7 @@ module.exports = class GameMenuModal extends ModalView
|
||||||
patchingMe = @updateConfig()
|
patchingMe = @updateConfig()
|
||||||
me.patch() unless patchingMe # Might need to patch for options menu, too
|
me.patch() unless patchingMe # Might need to patch for options menu, too
|
||||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
|
||||||
|
Backbone.Mediator.publish 'music-player:exit-menu', {}
|
||||||
|
|
||||||
updateConfig: ->
|
updateConfig: ->
|
||||||
sessionHeroConfig = @options.startingSessionHeroConfig
|
sessionHeroConfig = @options.startingSessionHeroConfig
|
||||||
|
|
|
@ -860,7 +860,6 @@ hero = [
|
||||||
id: 'kithgard-gates'
|
id: 'kithgard-gates'
|
||||||
original: '541c9a30c6362edfb0f34479'
|
original: '541c9a30c6362edfb0f34479'
|
||||||
description: 'Escape the Kithgard dungeons and don\'t let the guardians get you.'
|
description: 'Escape the Kithgard dungeons and don\'t let the guardians get you.'
|
||||||
disabled: true
|
|
||||||
x: 89
|
x: 89
|
||||||
y: 82
|
y: 82
|
||||||
nextLevels:
|
nextLevels:
|
||||||
|
@ -873,7 +872,6 @@ hero = [
|
||||||
id: 'defence-of-plainswood'
|
id: 'defence-of-plainswood'
|
||||||
original: '541b67f71ccc8eaae19f3c62'
|
original: '541b67f71ccc8eaae19f3c62'
|
||||||
description: 'Protect the peasants from the pursuing ogres.'
|
description: 'Protect the peasants from the pursuing ogres.'
|
||||||
disabled: true
|
|
||||||
x: 95.31
|
x: 95.31
|
||||||
y: 88.26
|
y: 88.26
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,10 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
clearInterval @sequentialAnimationInterval
|
clearInterval @sequentialAnimationInterval
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
onHidden: ->
|
||||||
|
Backbone.Mediator.publish 'music-player:exit-menu', {}
|
||||||
|
super()
|
||||||
|
|
||||||
onAchievementsLoaded: ->
|
onAchievementsLoaded: ->
|
||||||
thangTypeOriginals = []
|
thangTypeOriginals = []
|
||||||
achievementIDs = []
|
achievementIDs = []
|
||||||
|
@ -149,6 +153,7 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
panel.delay(500)
|
panel.delay(500)
|
||||||
panel.queue(-> complete())
|
panel.queue(-> complete())
|
||||||
@animationComplete = not @animatedPanels.length
|
@animationComplete = not @animatedPanels.length
|
||||||
|
complete() if @animationComplete
|
||||||
if @level.get('type', true) is 'hero-ladder'
|
if @level.get('type', true) is 'hero-ladder'
|
||||||
@ladderSubmissionView = new LadderSubmissionView session: @session, level: @level
|
@ladderSubmissionView = new LadderSubmissionView session: @session, level: @level
|
||||||
@insertSubView @ladderSubmissionView, @$el.find('.ladder-submission-view')
|
@insertSubView @ladderSubmissionView, @$el.find('.ladder-submission-view')
|
||||||
|
@ -231,6 +236,7 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
clearInterval @sequentialAnimationInterval
|
clearInterval @sequentialAnimationInterval
|
||||||
@animationComplete = true
|
@animationComplete = true
|
||||||
@updateSavingProgressStatus()
|
@updateSavingProgressStatus()
|
||||||
|
Backbone.Mediator.publish 'music-player:enter-menu', terrain: @level.get('terrain', true)
|
||||||
|
|
||||||
updateSavingProgressStatus: ->
|
updateSavingProgressStatus: ->
|
||||||
return unless @animationComplete
|
return unless @animationComplete
|
||||||
|
|
|
@ -47,7 +47,7 @@ module.exports = class SpellPaletteEntryView extends CocoView
|
||||||
).on 'show.bs.popover', =>
|
).on 'show.bs.popover', =>
|
||||||
Backbone.Mediator.publish 'tome:palette-hovered', thang: @thang, prop: @doc.name, entry: @
|
Backbone.Mediator.publish 'tome:palette-hovered', thang: @thang, prop: @doc.name, entry: @
|
||||||
soundIndex = Math.floor(Math.random() * 4)
|
soundIndex = Math.floor(Math.random() * 4)
|
||||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: "spell-palette-entry-open-{soundIndex}", volume: 0.75
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: "spell-palette-entry-open-#{soundIndex}", volume: 0.75
|
||||||
|
|
||||||
onMouseEnter: (e) ->
|
onMouseEnter: (e) ->
|
||||||
# Make sure the doc has the updated Thang so it can regenerate its prop value
|
# Make sure the doc has the updated Thang so it can regenerate its prop value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue