mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Added tasks to campaign editor; fixed/added campaign editor level click/double-click handling; improved campaign editor level Treema status view formatting.
This commit is contained in:
parent
370dff606d
commit
1440584633
7 changed files with 84 additions and 19 deletions
|
@ -107,8 +107,11 @@ _.extend CampaignSchema.properties, {
|
||||||
level: { type: 'string', links: [{rel: 'db', href: '/db/level/{($)}/version'}], format: 'latest-version-original-reference' }
|
level: { type: 'string', links: [{rel: 'db', href: '/db/level/{($)}/version'}], format: 'latest-version-original-reference' }
|
||||||
type: { enum: ['heroes', 'items', 'levels'] }
|
type: { enum: ['heroes', 'items', 'levels'] }
|
||||||
}}
|
}}
|
||||||
|
|
||||||
campaign: c.shortString title: 'Campaign', description: 'Which campaign this level is part of (like "desert").', format: 'hidden' # Automatically set by campaign editor.
|
campaign: c.shortString title: 'Campaign', description: 'Which campaign this level is part of (like "desert").', format: 'hidden' # Automatically set by campaign editor.
|
||||||
|
|
||||||
|
tasks: c.array {title: 'Tasks', description: 'Tasks to be completed for this level.'}, c.task
|
||||||
|
|
||||||
#- normal properties
|
#- normal properties
|
||||||
position: c.point2d()
|
position: c.point2d()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,13 @@
|
||||||
max-height: 100%
|
max-height: 100%
|
||||||
overflow: scroll
|
overflow: scroll
|
||||||
|
|
||||||
|
.completion
|
||||||
|
position: absolute
|
||||||
|
right: 0
|
||||||
|
|
||||||
#right-column
|
#right-column
|
||||||
position: absolute
|
position: absolute
|
||||||
top: 0
|
top: 0
|
||||||
bottom: 0
|
bottom: 0
|
||||||
right: 0
|
right: 0
|
||||||
width: 75%
|
width: 75%
|
||||||
|
|
||||||
#campaign-level-view
|
|
||||||
position: absolute
|
|
||||||
top: 0
|
|
||||||
left: 0
|
|
||||||
right: 0
|
|
||||||
bottom: 0
|
|
||||||
background-color: white
|
|
||||||
z-index: 3
|
|
13
app/styles/editor/campaign/campaign-level-view.sass
Normal file
13
app/styles/editor/campaign/campaign-level-view.sass
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#campaign-level-view
|
||||||
|
background-color: white
|
||||||
|
position: absolute
|
||||||
|
top: 0
|
||||||
|
left: 0
|
||||||
|
right: 0
|
||||||
|
z-index: 3
|
||||||
|
|
||||||
|
.tasks
|
||||||
|
padding: 15px
|
||||||
|
|
||||||
|
.button.close
|
||||||
|
font-size: 63px
|
|
@ -1,4 +1,17 @@
|
||||||
.jumbotron
|
.jumbotron
|
||||||
.button.close(type="button", aria-hidden="true") ×
|
.button.close(type="button", aria-hidden="true") ×
|
||||||
h1= level.get('name')
|
h1
|
||||||
|
span.spr= level.get('name')
|
||||||
|
a(href="/editor/level/#{level.get('slug')}", target="_blank") (edit)
|
||||||
p= level.get('description')
|
p= level.get('description')
|
||||||
|
|
||||||
|
h2 TODO: actually put useful stuff in here
|
||||||
|
|
||||||
|
if level.get('tasks')
|
||||||
|
.tasks
|
||||||
|
h3 Tasks (read only)
|
||||||
|
ul.list-unstyled
|
||||||
|
for task in level.get('tasks')
|
||||||
|
li
|
||||||
|
input(type='checkbox', checked=task.complete)
|
||||||
|
span.spl= task.name
|
||||||
|
|
|
@ -164,6 +164,7 @@ module.exports = class CampaignEditorView extends RootView
|
||||||
@listenTo @campaignView, 'level-moved', @onCampaignLevelMoved
|
@listenTo @campaignView, 'level-moved', @onCampaignLevelMoved
|
||||||
@listenTo @campaignView, 'adjacent-campaign-moved', @onAdjacentCampaignMoved
|
@listenTo @campaignView, 'adjacent-campaign-moved', @onAdjacentCampaignMoved
|
||||||
@listenTo @campaignView, 'level-clicked', @onCampaignLevelClicked
|
@listenTo @campaignView, 'level-clicked', @onCampaignLevelClicked
|
||||||
|
@listenTo @campaignView, 'level-double-clicked', @onCampaignLevelDoubleClicked
|
||||||
@insertSubView @campaignView
|
@insertSubView @campaignView
|
||||||
|
|
||||||
onTreemaChanged: (e, nodes) =>
|
onTreemaChanged: (e, nodes) =>
|
||||||
|
@ -188,8 +189,7 @@ module.exports = class CampaignEditorView extends RootView
|
||||||
path = node.getPath()
|
path = node.getPath()
|
||||||
return unless _.string.startsWith path, '/levels/'
|
return unless _.string.startsWith path, '/levels/'
|
||||||
original = path.split('/')[2]
|
original = path.split('/')[2]
|
||||||
level = @supermodel.getModelByOriginal Level, original
|
@openCampaignLevelView @supermodel.getModelByOriginal Level, original
|
||||||
@insertSubView new CampaignLevelView({}, level)
|
|
||||||
|
|
||||||
onCampaignLevelMoved: (e) ->
|
onCampaignLevelMoved: (e) ->
|
||||||
path = "levels/#{e.levelOriginal}/position"
|
path = "levels/#{e.levelOriginal}/position"
|
||||||
|
@ -204,6 +204,14 @@ module.exports = class CampaignEditorView extends RootView
|
||||||
levelTreema.select()
|
levelTreema.select()
|
||||||
# levelTreema.open()
|
# levelTreema.open()
|
||||||
|
|
||||||
|
onCampaignLevelDoubleClicked: (levelOriginal) ->
|
||||||
|
@openCampaignLevelView @supermodel.getModelByOriginal Level, levelOriginal
|
||||||
|
|
||||||
|
openCampaignLevelView: (level) ->
|
||||||
|
@insertSubView campaignLevelView = new CampaignLevelView({}, level)
|
||||||
|
@listenToOnce campaignLevelView, 'hidden', => @$el.find('#campaign-view').show()
|
||||||
|
@$el.find('#campaign-view').hide()
|
||||||
|
|
||||||
updateRewardsForLevel: (level, rewards) ->
|
updateRewardsForLevel: (level, rewards) ->
|
||||||
achievements = @supermodel.getModels(Achievement)
|
achievements = @supermodel.getModels(Achievement)
|
||||||
achievements = (a for a in achievements when a.get('related') is level.get('original'))
|
achievements = (a for a in achievements when a.get('related') is level.get('original'))
|
||||||
|
@ -250,7 +258,27 @@ class LevelsNode extends TreemaObjectNode
|
||||||
class LevelNode extends TreemaObjectNode
|
class LevelNode extends TreemaObjectNode
|
||||||
valueClass: 'treema-level'
|
valueClass: 'treema-level'
|
||||||
buildValueForDisplay: (valEl, data) ->
|
buildValueForDisplay: (valEl, data) ->
|
||||||
@buildValueForDisplaySimply valEl, data.name
|
name = data.name
|
||||||
|
if data.requiresSubscription
|
||||||
|
name = "[P] " + name
|
||||||
|
|
||||||
|
status = ''
|
||||||
|
el = 'strong'
|
||||||
|
if data.adminOnly
|
||||||
|
status += " (disabled)"
|
||||||
|
el = 'span'
|
||||||
|
else if data.adventurer
|
||||||
|
status += " (adventurer)"
|
||||||
|
|
||||||
|
completion = ''
|
||||||
|
if data.tasks
|
||||||
|
completion = "#{(t for t in data.tasks when t.complete).length} / #{data.tasks.length}"
|
||||||
|
|
||||||
|
valEl.append $("<#{el}></#{el}>").addClass('treema-shortened').text name
|
||||||
|
if status
|
||||||
|
valEl.append $('<em class="spl"></em>').text status
|
||||||
|
if completion
|
||||||
|
valEl.append $('<span class="completion"></span>').text completion
|
||||||
|
|
||||||
populateData: ->
|
populateData: ->
|
||||||
return if @data.name?
|
return if @data.name?
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
CocoView = require 'views/core/CocoView'
|
CocoView = require 'views/core/CocoView'
|
||||||
|
Level = require 'models/Level'
|
||||||
|
|
||||||
module.exports = class CampaignLevelView extends CocoView
|
module.exports = class CampaignLevelView extends CocoView
|
||||||
id: 'campaign-level-view'
|
id: 'campaign-level-view'
|
||||||
|
@ -9,11 +10,15 @@ module.exports = class CampaignLevelView extends CocoView
|
||||||
|
|
||||||
constructor: (options, @level) ->
|
constructor: (options, @level) ->
|
||||||
super(options)
|
super(options)
|
||||||
|
@fullLevel = new Level _id: @level.id
|
||||||
|
@fullLevel.fetch()
|
||||||
|
@listenToOnce @fullLevel, 'sync', => @render?()
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
c = super()
|
c = super()
|
||||||
c.level = @level
|
c.level = if @fullLevel.loaded then @fullLevel else @level
|
||||||
c
|
c
|
||||||
|
|
||||||
onClickClose: ->
|
onClickClose: ->
|
||||||
@$el.addClass('hidden')
|
@$el.addClass('hidden')
|
||||||
|
@trigger 'hidden'
|
||||||
|
|
|
@ -34,6 +34,7 @@ module.exports = class CampaignView extends RootView
|
||||||
events:
|
events:
|
||||||
'click .map-background': 'onClickMap'
|
'click .map-background': 'onClickMap'
|
||||||
'click .level a': 'onClickLevel'
|
'click .level a': 'onClickLevel'
|
||||||
|
'dblclick .level a': 'onDoubleClickLevel'
|
||||||
'click .level-info-container .start-level': 'onClickStartLevel'
|
'click .level-info-container .start-level': 'onClickStartLevel'
|
||||||
'mouseenter .level a': 'onMouseEnterLevel'
|
'mouseenter .level a': 'onMouseEnterLevel'
|
||||||
'mouseleave .level a': 'onMouseLeaveLevel'
|
'mouseleave .level a': 'onMouseLeaveLevel'
|
||||||
|
@ -236,8 +237,9 @@ module.exports = class CampaignView extends RootView
|
||||||
@$levelInfo?.hide()
|
@$levelInfo?.hide()
|
||||||
levelElement = $(e.target).parents('.level')
|
levelElement = $(e.target).parents('.level')
|
||||||
levelSlug = levelElement.data('level-slug')
|
levelSlug = levelElement.data('level-slug')
|
||||||
|
levelOriginal = levelElement.data('level-original')
|
||||||
if @editorMode
|
if @editorMode
|
||||||
return @trigger 'level-clicked', levelSlug
|
return @trigger 'level-clicked', levelOriginal
|
||||||
level = _.find _.values(@campaign.get('levels')), slug: levelSlug
|
level = _.find _.values(@campaign.get('levels')), slug: levelSlug
|
||||||
if application.isIPadApp
|
if application.isIPadApp
|
||||||
@$levelInfo = @$el.find(".level-info-container[data-level-slug=#{levelSlug}]").show()
|
@$levelInfo = @$el.find(".level-info-container[data-level-slug=#{levelSlug}]").show()
|
||||||
|
@ -256,6 +258,12 @@ module.exports = class CampaignView extends RootView
|
||||||
@startLevel levelElement
|
@startLevel levelElement
|
||||||
window.tracker?.trackEvent 'Clicked Level', category: 'World Map', levelID: levelSlug, ['Google Analytics']
|
window.tracker?.trackEvent 'Clicked Level', category: 'World Map', levelID: levelSlug, ['Google Analytics']
|
||||||
|
|
||||||
|
onDoubleClickLevel: (e) ->
|
||||||
|
return unless @editorMode
|
||||||
|
levelElement = $(e.target).parents('.level')
|
||||||
|
levelOriginal = levelElement.data('level-original')
|
||||||
|
@trigger 'level-double-clicked', levelOriginal
|
||||||
|
|
||||||
onClickStartLevel: (e) ->
|
onClickStartLevel: (e) ->
|
||||||
levelElement = $(e.target).parents('.level-info-container')
|
levelElement = $(e.target).parents('.level-info-container')
|
||||||
@startLevel levelElement
|
@startLevel levelElement
|
||||||
|
|
Loading…
Reference in a new issue