From 6c48660922ecd8c9e3f852e047d05473f4db0935 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Sat, 1 Mar 2014 16:57:29 -0800 Subject: [PATCH] No save button when there's nothing to save. Messing with AudioPlayer playSound API a bit. --- app/lib/AudioPlayer.coffee | 5 +++-- app/lib/surface/CocoSprite.coffee | 2 +- app/templates/editor/level/save.jade | 4 ++++ app/views/editor/level/save_view.coffee | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/lib/AudioPlayer.coffee b/app/lib/AudioPlayer.coffee index 122509dcc..b5eb4f70d 100644 --- a/app/lib/AudioPlayer.coffee +++ b/app/lib/AudioPlayer.coffee @@ -78,8 +78,9 @@ class AudioPlayer extends CocoClass @preloadInterfaceSounds [name] unless filename of cache @soundsToPlayWhenLoaded[name] = volume - playSound: (name, volume=1) -> - createjs.Sound.play name, {volume: (me.get('volume') ? 1) * volume} + playSound: (name, volume=1, delay=0) -> + instance = createjs.Sound.play name, {volume: (me.get('volume') ? 1) * volume, delay: delay} + instance # # TODO: load Interface sounds somehow, somewhere, somewhen diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index 29ee32371..008519599 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -475,6 +475,6 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass return null unless sound delay = if withDelay and sound.delay then 1000 * sound.delay / createjs.Ticker.getFPS() else 0 name = AudioPlayer.nameForSoundReference sound - instance = createjs.Sound.play name, "none", delay, 0, 0, volume + instance = AudioPlayer.playSound name, volume, delay # console.log @thang?.id, "played sound", name, "with delay", delay, "volume", volume, "and got sound instance", instance instance diff --git a/app/templates/editor/level/save.jade b/app/templates/editor/level/save.jade index 8ada52b23..00e9e43f2 100644 --- a/app/templates/editor/level/save.jade +++ b/app/templates/editor/level/save.jade @@ -52,3 +52,7 @@ block modal-body-content label.control-label(for=id + "-version-is-major") Major Changes? input(id=id + "-version-is-major", name="version-is-major", type="checkbox") span.help-block (Could this update break anything depending on this System?) + +if noSaveButton + block modal-footer-content + button.btn(data-dismiss="modal", data-i18n="common.cancel") Cancel diff --git a/app/views/editor/level/save_view.coffee b/app/views/editor/level/save_view.coffee index a1f0ee01b..4edf03ca0 100644 --- a/app/views/editor/level/save_view.coffee +++ b/app/views/editor/level/save_view.coffee @@ -23,6 +23,7 @@ module.exports = class LevelSaveView extends SaveVersionModal context.levelNeedsSave = @level.hasLocalChanges() context.modifiedComponents = _.filter @supermodel.getModels(LevelComponent), @shouldSaveEntity context.modifiedSystems = _.filter @supermodel.getModels(LevelSystem), @shouldSaveEntity + context.noSaveButton = context.levelNeedsSave or context.modifiedComponents.length or context.modifiedSystems.length context shouldSaveEntity: (m) ->