mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Moving levels and adjacent campaign links around in the CampaignView saves the new position to the CampaignEditorView.
This commit is contained in:
parent
efc83b88d0
commit
a31b385a4d
3 changed files with 24 additions and 11 deletions
|
@ -8,19 +8,19 @@
|
|||
each level in levels
|
||||
if !level.hidden
|
||||
- var next = nextLevel && level.slug === nextLevel;
|
||||
div(style="left: #{level.position.x}%; bottom: #{level.position.y}%; background-color: #{level.color}", class="level" + (next ? " next" : "") + (level.disabled ? " disabled" : "") + (level.locked ? " locked" : "") + " " + levelStatusMap[level.id] || "", data-level-id=level.id, title=level.name + (level.disabled ? ' (Coming Soon to Adventurers)' : ''))
|
||||
div(style="left: #{level.position.x}%; bottom: #{level.position.y}%; background-color: #{level.color}", class="level" + (next ? " next" : "") + (level.disabled ? " disabled" : "") + (level.locked ? " locked" : "") + " " + levelStatusMap[level.original] || "", data-level-id=level.original, title=level.name + (level.disabled ? ' (Coming Soon to Adventurers)' : ''))
|
||||
if level.unlocksHero && !level.unlockedHero
|
||||
img.hero-portrait(src=level.unlocksHero.img)
|
||||
a(href=level.type == 'hero' ? '#' : level.disabled ? "/play" : "/play/#{level.levelPath || 'level'}/#{level.id}", disabled=level.disabled, data-level-id=level.id, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
a(href=level.type == 'hero' ? '#' : level.disabled ? "/play" : "/play/#{level.levelPath || 'level'}/#{level.original}", disabled=level.disabled, data-level-id=level.original, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
if level.requiresSubscription
|
||||
img.star(src="/images/pages/play/star.png")
|
||||
if levelStatusMap[level.id] === 'complete'
|
||||
if levelStatusMap[level.original] === 'complete'
|
||||
img.banner(src="/images/pages/play/level-banner-complete.png")
|
||||
if levelStatusMap[level.id] === 'started'
|
||||
if levelStatusMap[level.original] === 'started'
|
||||
img.banner(src="/images/pages/play/level-banner-started.png")
|
||||
div(style="left: #{level.x}%; bottom: #{level.y}%", class="level-shadow" + (next ? " next" : "") + " " + levelStatusMap[level.id] || "")
|
||||
.level-info-container(data-level-id=level.id, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
div(class="level-info " + (levelStatusMap[level.id] || ""))
|
||||
div(style="left: #{level.x}%; bottom: #{level.y}%", class="level-shadow" + (next ? " next" : "") + " " + levelStatusMap[level.original] || "")
|
||||
.level-info-container(data-level-id=level.original, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
div(class="level-info " + (levelStatusMap[level.original] || ""))
|
||||
h3= level.name + (level.disabled ? " (Coming soon!)" : (level.locked ? " (Locked)" : ""))
|
||||
.level-description= level.description
|
||||
if level.disabled
|
||||
|
@ -30,7 +30,7 @@
|
|||
strong(data-i18n="play.awaiting_levels_adventurer") Sign up as an Adventurer
|
||||
span.spl(data-i18n="play.awaiting_levels_adventurer_suffix") to be the first to play new levels.
|
||||
|
||||
- var playCount = levelPlayCountMap[level.id]
|
||||
- var playCount = levelPlayCountMap[level.original]
|
||||
if playCount && playCount.sessions > 20
|
||||
div
|
||||
span.spr #{playCount.sessions}
|
||||
|
@ -43,7 +43,7 @@
|
|||
|
||||
for adjacentCampaign in adjacentCampaigns
|
||||
a
|
||||
span.glyphicon.glyphicon-share-alt.campaign-switch(href="/play/"+adjacentCampaign.slug, style=adjacentCampaign.style, title=adjacentCampaign.name)
|
||||
span.glyphicon.glyphicon-share-alt.campaign-switch(href="/play/"+adjacentCampaign.slug, style=adjacentCampaign.style, title=adjacentCampaign.name, data-campaign-id=adjacentCampaign.id)
|
||||
|
||||
.game-controls.header-font
|
||||
button.btn.items(data-toggle='coco-modal', data-target='play/modal/PlayItemsModal', data-i18n="[title]play.items")
|
||||
|
|
|
@ -181,6 +181,8 @@ module.exports = class CampaignEditorView extends RootView
|
|||
|
||||
campaignView = new CampaignView({editorMode: true, supermodel: @supermodel}, @campaignHandle)
|
||||
campaignView.highlightElement = _.noop # make it stop
|
||||
@listenTo campaignView, 'level-moved', @onCampaignLevelMoved
|
||||
@listenTo campaignView, 'adjacent-campaign-moved', @onAdjacentCampaignMoved
|
||||
@insertSubView campaignView
|
||||
|
||||
onTreemaChanged: (e, nodes) =>
|
||||
|
@ -202,6 +204,14 @@ module.exports = class CampaignEditorView extends RootView
|
|||
|
||||
@toSave.add @campaign
|
||||
|
||||
onCampaignLevelMoved: (e) ->
|
||||
path = "levels/#{e.levelOriginal}/position"
|
||||
@treema.set path, e.position
|
||||
|
||||
onAdjacentCampaignMoved: (e) ->
|
||||
path = "adjacentCampaigns/#{e.campaignID}/position"
|
||||
@treema.set path, e.position
|
||||
|
||||
updateRewardsForLevel: (level, rewards) ->
|
||||
achievements = @supermodel.getModels(Achievement)
|
||||
achievements = (a for a in achievements when a.get('related') is level.get('original'))
|
||||
|
|
|
@ -184,13 +184,16 @@ module.exports = class WorldMapView extends RootView
|
|||
@onWindowResize()
|
||||
unless application.isIPadApp
|
||||
_.defer => @$el?.find('.game-controls .btn').tooltip() # Have to defer or i18n doesn't take effect.
|
||||
@$el.find('.level').tooltip().each ->
|
||||
view = @
|
||||
@$el.find('.level, .campaign-switch').tooltip().each ->
|
||||
return unless me.isAdmin()
|
||||
$(@).draggable().on 'dragstop', ->
|
||||
bg = $('.map-background')
|
||||
x = ($(@).offset().left - bg.offset().left + $(@).outerWidth() / 2) / bg.width()
|
||||
y = 1 - ($(@).offset().top - bg.offset().top + $(@).outerHeight() / 2) / bg.height()
|
||||
console.log "#{$(@).data('level-id')}\n x: #{(100 * x).toFixed(2)}\n y: #{(100 * y).toFixed(2)}\n"
|
||||
e = { position: { x: (100 * x), y: (100 * y) }, levelOriginal: $(@).data('level-id'), campaignID: $(@).data('campaign-id') }
|
||||
view.trigger 'level-moved', e if e.levelOriginal
|
||||
view.trigger 'adjacent-campaign-moved', e if e.campaignID
|
||||
@$el.addClass _.string.slugify @terrain
|
||||
@updateVolume()
|
||||
@updateHero()
|
||||
|
|
Loading…
Reference in a new issue