From ca6c95b0f7d658af9e4ff9bd752132e8fafcea2b Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Mon, 1 Dec 2014 13:46:55 -0800 Subject: [PATCH] Migrated getting nextLevelURL to the new campaign organization. --- app/lib/LevelLoader.coffee | 2 +- app/views/play/level/PlayLevelView.coffee | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/app/lib/LevelLoader.coffee b/app/lib/LevelLoader.coffee index 92c31e165..40743699c 100644 --- a/app/lib/LevelLoader.coffee +++ b/app/lib/LevelLoader.coffee @@ -176,7 +176,7 @@ module.exports = class LevelLoader extends CocoClass for obj in objUniq articleVersions url = "/db/article/#{obj.original}/version/#{obj.majorVersion}" @maybeLoadURL url, Article, 'article' - if obj = @level.get 'nextLevel' + if obj = @level.get 'nextLevel' # TODO: update to get next level from campaigns, not this old property url = "/db/level/#{obj.original}/version/#{obj.majorVersion}" @maybeLoadURL url, Level, 'level' diff --git a/app/views/play/level/PlayLevelView.coffee b/app/views/play/level/PlayLevelView.coffee index 06d744abf..13a7464f9 100644 --- a/app/views/play/level/PlayLevelView.coffee +++ b/app/views/play/level/PlayLevelView.coffee @@ -417,7 +417,6 @@ module.exports = class PlayLevelView extends RootView onShowVictory: (e) -> $('#level-done-button').show() unless @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop'] @showVictory() if e.showModal - setTimeout(@preloadNextLevel, 3000) return if @victorySeen @victorySeen = true victoryTime = (new Date()) - @loadEndTime @@ -457,14 +456,10 @@ module.exports = class PlayLevelView extends RootView viewClass: PlayLevelView, viewArgs: [{supermodel: if @hasReceivedMemoryWarning then null else @supermodel}, nextLevelID]} - getNextLevel: -> - return null unless nextLevelOriginal = @level.get('nextLevel')?.original - levels = @supermodel.getModels(Level) - return l for l in levels when l.get('original') is nextLevelOriginal - getNextLevelID: -> - return null unless nextLevel = @getNextLevel() - nextLevelID = nextLevel.get('slug') or nextLevel.id + for campaign in require('views/play/WorldMapView').campaigns + for level in campaign.levels + return level.nextLevels?.continue if level.id is @level.get('slug') getNextLevelURL: -> return null unless @getNextLevelID() @@ -483,14 +478,6 @@ module.exports = class PlayLevelView extends RootView @bus.removeFirebaseData => @bus.disconnect() - preloadNextLevel: => - # TODO: Loading models in the middle of gameplay causes stuttering. Most of the improvement in loading time is simply from passing the supermodel from this level to the next, but if we can find a way to populate the level early without it being noticeable, that would be even better. -# return if @destroyed -# return if @preloaded -# nextLevel = @getNextLevel() -# @supermodel.populateModel nextLevel -# @preloaded = true - onSessionWillSave: (e) -> # Something interesting has happened, so (at a lower frequency), we'll save a screenshot. #@saveScreenshot e.session