mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-25 21:43:47 -04:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c3bd9cef80
5 changed files with 21 additions and 14 deletions
app
lib
templates/play/level/modal
views/play
|
@ -192,7 +192,7 @@ class Angel
|
|||
@worker.postMessage {func: 'abort'}
|
||||
|
||||
terminate: =>
|
||||
@worker.terminate()
|
||||
@worker?.terminate()
|
||||
@worker = null
|
||||
return if @dead
|
||||
@free()
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
span(data-i18n="play_level.multiplayer_hint") Click the link to select all, then press ⌘-C or Ctrl-C to copy the link.
|
||||
|
||||
p(data-i18n="play_level.multiplayer_coming_soon") More multiplayer features to come!
|
||||
|
||||
if playableTeams.length > 1
|
||||
#multiplayer-team-selection
|
||||
for team in playableTeams
|
||||
label(for="multiplayer_team_"+team)= team
|
||||
input(id="multiplayer_team_"+team, type="radio", name="multiplayer", value=team)
|
||||
|
||||
.modal-footer
|
||||
a(href='#', data-dismiss="modal", aria-hidden="true", data-i18n="modal.close").btn.btn-primary Close
|
||||
|
|
|
@ -31,6 +31,7 @@ module.exports = class ControlBarView extends View
|
|||
@worldName = options.worldName
|
||||
@session = options.session
|
||||
@level = options.level
|
||||
@playableTeams = options.playableTeams
|
||||
super options
|
||||
|
||||
setBus: (@bus) ->
|
||||
|
@ -55,7 +56,7 @@ module.exports = class ControlBarView extends View
|
|||
@openModalView(new DocsModal(options))
|
||||
|
||||
showMultiplayerModal: ->
|
||||
@openModalView(new MultiplayerModal(session: @session))
|
||||
@openModalView(new MultiplayerModal(session: @session, playableTeams: @playableTeams))
|
||||
|
||||
showRestartModal: ->
|
||||
@openModalView(new ReloadModal())
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
View = require 'views/kinds/ModalView'
|
||||
template = require 'templates/play/level/modal/multiplayer'
|
||||
{me} = require('lib/auth')
|
||||
|
||||
module.exports = class MultiplayerModal extends View
|
||||
id: 'level-multiplayer-modal'
|
||||
|
@ -13,6 +14,7 @@ module.exports = class MultiplayerModal extends View
|
|||
super(options)
|
||||
@session = options.session
|
||||
@session.on 'change:multiplayer', @updateLinkSection
|
||||
@playableTeams = options.playableTeams
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
|
@ -20,13 +22,17 @@ module.exports = class MultiplayerModal extends View
|
|||
'?session=' +
|
||||
@session.id)
|
||||
c.multiplayer = @session.get('multiplayer')
|
||||
c.playableTeams = @playableTeams
|
||||
c
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
@updateLinkSection()
|
||||
@$el.find('#multiplayer-team-selection input')
|
||||
.prop('checked', -> $(@).val() is me.team)
|
||||
.bind('change', -> Backbone.Mediator.publish 'level:set-team', team: $(@).val())
|
||||
|
||||
onClickLink: (e) =>
|
||||
onClickLink: (e) ->
|
||||
e.target.select()
|
||||
|
||||
updateLinkSection: =>
|
||||
|
|
|
@ -52,12 +52,12 @@ module.exports = class PlayLevelView extends View
|
|||
'level-enable-controls': 'onEnableControls'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:infinite-loop': 'onInfiniteLoop'
|
||||
'bus:connected': 'onBusConnected'
|
||||
'level-reload-from-data': 'onLevelReloadFromData'
|
||||
'play-next-level': 'onPlayNextLevel'
|
||||
'edit-wizard-settings': 'showWizardSettingsModal'
|
||||
'surface:world-set-up': 'onSurfaceSetUpNewWorld'
|
||||
'level:session-will-save': 'onSessionWillSave'
|
||||
'level:set-team': 'setTeam'
|
||||
|
||||
events:
|
||||
'click #level-done-button': 'onDonePressed'
|
||||
|
@ -123,7 +123,7 @@ module.exports = class PlayLevelView extends View
|
|||
@levelLoader.destroy()
|
||||
@levelLoader = null
|
||||
@loadingScreen.destroy()
|
||||
@setTeam @world.teamForPlayer 1 # We don't know which player we are; this will go away--temp TODO
|
||||
@setTeam @world.teamForPlayer _.size @session.get 'players' # TODO: players aren't initialized yet?
|
||||
@initSurface()
|
||||
@initGod()
|
||||
@initGoalManager()
|
||||
|
@ -157,7 +157,7 @@ module.exports = class PlayLevelView extends View
|
|||
@insertSubView new HUDView {}
|
||||
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
||||
worldName = @level.get('i18n')?[me.lang()]?.name ? @level.get('name')
|
||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel}
|
||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams}
|
||||
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
||||
|
||||
afterInsert: ->
|
||||
|
@ -360,13 +360,6 @@ module.exports = class PlayLevelView extends View
|
|||
@bus.setSession(@session)
|
||||
@bus.connect() if @session.get('multiplayer')
|
||||
|
||||
onBusConnected: ->
|
||||
# Need to set this team stuff before the Tome loads... let's think about this with Scott.
|
||||
#@setTeam @world.teamForPlayer(@bus.countPlayers()) unless me.team
|
||||
#$('#multiplayer-team-selection').toggle(@world.playableTeams.length > 1)
|
||||
# .find('input').prop('checked', -> $(@).val() is me.team)
|
||||
# .bind('change', @setTeam)
|
||||
|
||||
onSessionWillSave: (e) ->
|
||||
# Something interesting has happened, so (at a lower frequency), we'll save a screenshot.
|
||||
@saveScreenshot e.session
|
||||
|
@ -377,7 +370,8 @@ module.exports = class PlayLevelView extends View
|
|||
session.save {screenshot: screenshot}, {patch: true}
|
||||
|
||||
setTeam: (team) ->
|
||||
team = $(@).val() unless _.isString team
|
||||
team = team?.team unless _.isString team
|
||||
team ?= 'humans'
|
||||
me.team = team
|
||||
Backbone.Mediator.publish 'level:team-set', team: team
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue