mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -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: ->
|
||||
me.off 'change:music', @onMusicSettingChanged, @
|
||||
@fadeOutCurrentMusic()
|
||||
super()
|
||||
|
|
|
@ -5,6 +5,8 @@ CocoCollection = require 'collections/CocoCollection'
|
|||
AudioPlayer = require 'lib/AudioPlayer'
|
||||
PlayLevelModal = require 'views/play/modal/PlayLevelModal'
|
||||
ThangType = require 'models/ThangType'
|
||||
MusicPlayer = require 'lib/surface/MusicPlayer'
|
||||
storage = require 'lib/storage'
|
||||
|
||||
class LevelSessionsCollection extends CocoCollection
|
||||
url: ''
|
||||
|
@ -37,6 +39,9 @@ module.exports = class WorldMapView extends RootView
|
|||
@getLevelPlayCounts()
|
||||
$(window).on 'resize', @onWindowResize
|
||||
@playAmbientSound()
|
||||
@probablyCachedMusic = storage.load("loaded-menu-music-#{@terrain}")
|
||||
musicDelay = if @probablyCachedMusic then 1000 else 10000
|
||||
@playMusicTimeout = _.delay (=> @playMusic() unless @destroyed), musicDelay
|
||||
@preloadTopHeroes()
|
||||
@hadEverChosenHero = me.get('heroConfig')?.thangType
|
||||
|
||||
|
@ -45,6 +50,8 @@ module.exports = class WorldMapView extends RootView
|
|||
if ambientSound = @ambientSound
|
||||
# Doesn't seem to work; stops immediately.
|
||||
createjs.Tween.get(ambientSound).to({volume: 0.0}, 1500).call -> ambientSound.stop()
|
||||
@musicPlayer?.destroy()
|
||||
clearTimeout @playMusicTimeout
|
||||
super()
|
||||
|
||||
getLevelPlayCounts: ->
|
||||
|
@ -202,6 +209,12 @@ module.exports = class WorldMapView extends RootView
|
|||
@ambientSound = createjs.Sound.play src, loop: -1, volume: 0.1
|
||||
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: ->
|
||||
for heroID in ['captain', 'knight']
|
||||
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'
|
||||
@showLoading()
|
||||
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()
|
||||
hasGoneFullScreenOnce = true
|
||||
@updateConfig =>
|
||||
|
|
Loading…
Reference in a new issue