mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Started playing menu music on WorldMapView. Only go full-screen on squat windows where we really need it (see #1669).
This commit is contained in:
parent
5c40f99d99
commit
9826311656
3 changed files with 15 additions and 1 deletions
|
@ -77,4 +77,5 @@ module.exports = class MusicPlayer extends CocoClass
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
me.off 'change:music', @onMusicSettingChanged, @
|
me.off 'change:music', @onMusicSettingChanged, @
|
||||||
|
@fadeOutCurrentMusic()
|
||||||
super()
|
super()
|
||||||
|
|
|
@ -5,6 +5,8 @@ CocoCollection = require 'collections/CocoCollection'
|
||||||
AudioPlayer = require 'lib/AudioPlayer'
|
AudioPlayer = require 'lib/AudioPlayer'
|
||||||
PlayLevelModal = require 'views/play/modal/PlayLevelModal'
|
PlayLevelModal = require 'views/play/modal/PlayLevelModal'
|
||||||
ThangType = require 'models/ThangType'
|
ThangType = require 'models/ThangType'
|
||||||
|
MusicPlayer = require 'lib/surface/MusicPlayer'
|
||||||
|
storage = require 'lib/storage'
|
||||||
|
|
||||||
class LevelSessionsCollection extends CocoCollection
|
class LevelSessionsCollection extends CocoCollection
|
||||||
url: ''
|
url: ''
|
||||||
|
@ -37,6 +39,9 @@ module.exports = class WorldMapView extends RootView
|
||||||
@getLevelPlayCounts()
|
@getLevelPlayCounts()
|
||||||
$(window).on 'resize', @onWindowResize
|
$(window).on 'resize', @onWindowResize
|
||||||
@playAmbientSound()
|
@playAmbientSound()
|
||||||
|
@probablyCachedMusic = storage.load("loaded-menu-music-#{@terrain}")
|
||||||
|
musicDelay = if @probablyCachedMusic then 1000 else 10000
|
||||||
|
@playMusicTimeout = _.delay (=> @playMusic() unless @destroyed), musicDelay
|
||||||
@preloadTopHeroes()
|
@preloadTopHeroes()
|
||||||
@hadEverChosenHero = me.get('heroConfig')?.thangType
|
@hadEverChosenHero = me.get('heroConfig')?.thangType
|
||||||
|
|
||||||
|
@ -45,6 +50,8 @@ module.exports = class WorldMapView extends RootView
|
||||||
if ambientSound = @ambientSound
|
if ambientSound = @ambientSound
|
||||||
# Doesn't seem to work; stops immediately.
|
# Doesn't seem to work; stops immediately.
|
||||||
createjs.Tween.get(ambientSound).to({volume: 0.0}, 1500).call -> ambientSound.stop()
|
createjs.Tween.get(ambientSound).to({volume: 0.0}, 1500).call -> ambientSound.stop()
|
||||||
|
@musicPlayer?.destroy()
|
||||||
|
clearTimeout @playMusicTimeout
|
||||||
super()
|
super()
|
||||||
|
|
||||||
getLevelPlayCounts: ->
|
getLevelPlayCounts: ->
|
||||||
|
@ -202,6 +209,12 @@ module.exports = class WorldMapView extends RootView
|
||||||
@ambientSound = createjs.Sound.play src, loop: -1, volume: 0.1
|
@ambientSound = createjs.Sound.play src, loop: -1, volume: 0.1
|
||||||
createjs.Tween.get(@ambientSound).to({volume: 1.0}, 1000)
|
createjs.Tween.get(@ambientSound).to({volume: 1.0}, 1000)
|
||||||
|
|
||||||
|
playMusic: ->
|
||||||
|
@musicPlayer = new MusicPlayer()
|
||||||
|
musicFile = {Dungeon: '/music/music-menu-dungeon', Grass: '/music/music-menu-grass'}[@terrain]
|
||||||
|
Backbone.Mediator.publish 'music-player:play-music', play: true, file: musicFile
|
||||||
|
storage.save("loaded-menu-music-#{@terrain}", true) unless @probablyCachedMusic
|
||||||
|
|
||||||
preloadTopHeroes: ->
|
preloadTopHeroes: ->
|
||||||
for heroID in ['captain', 'knight']
|
for heroID in ['captain', 'knight']
|
||||||
url = "/db/thang.type/#{ThangType.heroes[heroID]}/version"
|
url = "/db/thang.type/#{ThangType.heroes[heroID]}/version"
|
||||||
|
|
|
@ -106,7 +106,7 @@ module.exports = class PlayLevelModal extends ModalView
|
||||||
return if @$el.find('#play-level-button').prop 'disabled'
|
return if @$el.find('#play-level-button').prop 'disabled'
|
||||||
@showLoading()
|
@showLoading()
|
||||||
ua = navigator.userAgent.toLowerCase()
|
ua = navigator.userAgent.toLowerCase()
|
||||||
unless hasGoneFullScreenOnce or (/safari/.test(ua) and not /chrome/.test(ua))
|
unless hasGoneFullScreenOnce or (/safari/.test(ua) and not /chrome/.test(ua)) or $(window).height() >= 658 # Min vertical resolution needed at 1366px wide
|
||||||
@toggleFullscreen()
|
@toggleFullscreen()
|
||||||
hasGoneFullScreenOnce = true
|
hasGoneFullScreenOnce = true
|
||||||
@updateConfig =>
|
@updateConfig =>
|
||||||
|
|
Loading…
Reference in a new issue