mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Hooked up the CampaignView to show adjacent campaigns based on the data.
This commit is contained in:
parent
0cd85d7aba
commit
efc83b88d0
5 changed files with 30 additions and 22 deletions
|
@ -27,10 +27,10 @@ _.extend CampaignSchema.properties, {
|
|||
format: 'campaign'
|
||||
properties: {
|
||||
#- denormalized from other Campaigns, either updated automatically or fetched dynamically
|
||||
id: { type: 'string', format: 'hidden' }
|
||||
name: { type: 'string', format: 'hidden' }
|
||||
description: { type: 'string', format: 'hidden' }
|
||||
i18n: { type: 'object', format: 'hidden' }
|
||||
original: { type: 'string', format: 'hidden' }
|
||||
slug: { type: 'string', format: 'hidden' }
|
||||
|
||||
#- normal properties
|
||||
|
|
|
@ -38,7 +38,7 @@ block outer_content
|
|||
#campaign-treema
|
||||
|
||||
#right-column
|
||||
#world-map-view
|
||||
#campaign-view
|
||||
#campaign-level-view
|
||||
|
||||
block footer
|
||||
|
|
|
@ -40,15 +40,10 @@
|
|||
.campaign-label= campaign.get('name')
|
||||
if isIPadApp && !level.disabled && !level.locked
|
||||
button.btn.btn-success.btn-lg.start-level(data-i18n="common.play") Play
|
||||
if mapType === 'dungeon' && forestIsAvailable
|
||||
a#forest-link.glyphicon.glyphicon-share-alt.campaign-switch(href="/play/forest", data-i18n="[title]play.campaign_forest")
|
||||
if mapType === 'forest'
|
||||
a#dungeon-link.glyphicon.glyphicon-share-alt.campaign-switch(href="/play/dungeon", data-i18n="[title]play.campaign_dungeon")
|
||||
if desertIsAvailable
|
||||
a#desert-link.glyphicon.glyphicon-share-alt.campaign-switch(href="/play/desert", data-i18n="[title]play.campaign_desert")
|
||||
if mapType === 'desert'
|
||||
a#forest-back-link.glyphicon.glyphicon-share-alt.campaign-switch(href="/play/forest", data-i18n="[title]play.campaign_forest")
|
||||
|
||||
|
||||
for adjacentCampaign in adjacentCampaigns
|
||||
a
|
||||
span.glyphicon.glyphicon-share-alt.campaign-switch(href="/play/"+adjacentCampaign.slug, style=adjacentCampaign.style, title=adjacentCampaign.name)
|
||||
|
||||
.game-controls.header-font
|
||||
button.btn.items(data-toggle='coco-modal', data-target='play/modal/PlayItemsModal', data-i18n="[title]play.items")
|
||||
|
|
|
@ -3,7 +3,7 @@ Campaign = require 'models/Campaign'
|
|||
Level = require 'models/Level'
|
||||
Achievement = require 'models/Achievement'
|
||||
ThangType = require 'models/ThangType'
|
||||
WorldMapView = require 'views/play/WorldMapView'
|
||||
CampaignView = require 'views/play/CampaignView'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
treemaExt = require 'core/treema-ext'
|
||||
utils = require 'core/utils'
|
||||
|
@ -16,7 +16,7 @@ module.exports = class CampaignEditorView extends RootView
|
|||
template: require 'templates/editor/campaign/campaign-editor-view'
|
||||
className: 'editor'
|
||||
|
||||
constructor: (options, campaignHandle) ->
|
||||
constructor: (options, @campaignHandle) ->
|
||||
super(options)
|
||||
|
||||
# MIGRATION CODE
|
||||
|
@ -38,7 +38,7 @@ module.exports = class CampaignEditorView extends RootView
|
|||
# @campaign = new Campaign(campaign)
|
||||
#------------------------------------------------
|
||||
|
||||
@campaign = new Campaign({_id:campaignHandle})
|
||||
@campaign = new Campaign({_id:@campaignHandle})
|
||||
|
||||
#--------------- temporary migration to change thang type slugs to originals
|
||||
#- should keep around though for loading the names of items and heroes that are referenced
|
||||
|
@ -65,14 +65,14 @@ module.exports = class CampaignEditorView extends RootView
|
|||
|
||||
@levels = new CocoCollection([], {
|
||||
model: Level
|
||||
url: "/db/campaign/#{campaignHandle}/levels"
|
||||
url: "/db/campaign/#{@campaignHandle}/levels"
|
||||
project: Campaign.denormalizedLevelProperties
|
||||
})
|
||||
@supermodel.loadCollection(@levels, 'levels')
|
||||
|
||||
@achievements = new CocoCollection([], {
|
||||
model: Achievement
|
||||
url: "/db/campaign/#{campaignHandle}/achievements"
|
||||
url: "/db/campaign/#{@campaignHandle}/achievements"
|
||||
project: achievementProject
|
||||
})
|
||||
@supermodel.loadCollection(@achievements, 'achievements')
|
||||
|
@ -179,9 +179,9 @@ module.exports = class CampaignEditorView extends RootView
|
|||
@treema.open()
|
||||
@treema.childrenTreemas.levels?.open()
|
||||
|
||||
worldMapView = new WorldMapView({supermodel: @supermodel, editorMode: true}, 'dungeon')
|
||||
worldMapView.highlightElement = _.noop # make it stop
|
||||
@insertSubView worldMapView
|
||||
campaignView = new CampaignView({editorMode: true, supermodel: @supermodel}, @campaignHandle)
|
||||
campaignView.highlightElement = _.noop # make it stop
|
||||
@insertSubView campaignView
|
||||
|
||||
onTreemaChanged: (e, nodes) =>
|
||||
for node in nodes
|
||||
|
|
|
@ -12,6 +12,7 @@ storage = require 'core/storage'
|
|||
AuthModal = require 'views/core/AuthModal'
|
||||
SubscribeModal = require 'views/core/SubscribeModal'
|
||||
Level = require 'models/Level'
|
||||
utils = require 'core/utils'
|
||||
|
||||
trackedHourOfCode = false
|
||||
|
||||
|
@ -46,8 +47,8 @@ module.exports = class WorldMapView extends RootView
|
|||
options ?= {}
|
||||
|
||||
@campaign = new Campaign({_id:@terrain})
|
||||
@supermodel.loadModel(@campaign, 'campaign')
|
||||
|
||||
@campaign = @supermodel.loadModel(@campaign, 'campaign').model
|
||||
|
||||
@editorMode = options.editorMode
|
||||
@nextLevel = @getQueryVariable 'next'
|
||||
@levelStatusMap = {}
|
||||
|
@ -135,7 +136,7 @@ module.exports = class WorldMapView extends RootView
|
|||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.campaign = @campaign
|
||||
context.levels = _.values($.extend {}, @campaign.get('levels'))
|
||||
context.levels = _.values($.extend true, {}, @campaign.get('levels'))
|
||||
for level in context.levels
|
||||
level.position ?= { x: 10, y: 10 }
|
||||
level.locked = not me.ownsLevel level.original
|
||||
|
@ -164,6 +165,18 @@ module.exports = class WorldMapView extends RootView
|
|||
context.desertIsAvailable = Level.levels['the-mighty-sand-yak'] in (me.get('earned')?.levels or [])
|
||||
context.requiresSubscription = @requiresSubscription
|
||||
context.editorMode = @editorMode
|
||||
context.adjacentCampaigns = _.filter _.values(_.cloneDeep(@campaign.get('adjacentCampaigns') or {})), (ac) ->
|
||||
return false if ac.showIfUnlocked and ac.showIfUnlocked not in (me.get('unlocked')?.levels or [])
|
||||
ac.name = utils.i18n ac, 'name'
|
||||
ac.description = utils.i18n ac, 'description'
|
||||
styles = []
|
||||
styles.push "color: #{ac.color}" if ac.color
|
||||
styles.push "transform: rotate(#{ac.rotation}deg)" if ac.rotation
|
||||
ac.position ?= { x: 10, y: 10 }
|
||||
styles.push "left: #{ac.position.x}%"
|
||||
styles.push "top: #{ac.position.y}%"
|
||||
ac.style = styles.join('; ')
|
||||
return true
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
|
|
Loading…
Reference in a new issue