diff --git a/app/schemas/models/level.coffee b/app/schemas/models/level.coffee index 728261c64..cec974734 100644 --- a/app/schemas/models/level.coffee +++ b/app/schemas/models/level.coffee @@ -300,6 +300,7 @@ _.extend LevelSchema.properties, free: {type: 'boolean', title: 'Free', description: 'Whether this video is freely available to all players without a subscription.'} url: c.url {title: 'URL', description: 'Link to the video on Vimeo.'} replayable: {type: 'boolean', title: 'Replayable', description: 'Whether this (hero) level infinitely scales up its difficulty and can be beaten over and over for greater rewards.'} + buildTime: {type: 'number', description: 'How long it has taken to build this level.'} # Admin flags adventurer: { type: 'boolean' } diff --git a/app/views/editor/level/LevelEditView.coffee b/app/views/editor/level/LevelEditView.coffee index ff7892796..fd29a7554 100644 --- a/app/views/editor/level/LevelEditView.coffee +++ b/app/views/editor/level/LevelEditView.coffee @@ -63,6 +63,10 @@ module.exports = class LevelEditView extends RootView @files = new DocumentFiles(@levelLoader.level) @supermodel.loadCollection(@files, 'file_names') + destroy: -> + clearInterval @timerIntervalID + super() + showLoading: ($el) -> $el ?= @$el.find('.outer-content') super($el) @@ -73,6 +77,7 @@ module.exports = class LevelEditView extends RootView _.defer => @world = @levelLoader.world @render() + @timerIntervalID = setInterval @incrementBuildTime, 1000 getRenderData: (context={}) -> context = super(context) @@ -192,3 +197,7 @@ module.exports = class LevelEditView extends RootView return if @initializedDocs @initializedDocs = true @$el.find('a[href="#components-documentation-view"]').click() + + incrementBuildTime: => + return if application.userIsIdle + @level.set('buildTime', (@level.get('buildTime') ? 0) + 1) diff --git a/server/levels/level_handler.coffee b/server/levels/level_handler.coffee index 501d56159..d55751b16 100644 --- a/server/levels/level_handler.coffee +++ b/server/levels/level_handler.coffee @@ -56,6 +56,7 @@ LevelHandler = class LevelHandler extends Handler 'helpVideos' 'campaign' 'replayable' + 'buildTime' ] postEditableProperties: ['name']