mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-04 18:03:45 -04:00
Fixed up SpectateView for hero ladder games. Addd player names to their heroes in spectate and observation mode. Fixed #1679.
This commit is contained in:
parent
a8dc353f86
commit
991a374da2
5 changed files with 27 additions and 9 deletions
app
lib/surface
views/play
|
@ -474,6 +474,8 @@ module.exports = Lank = class Lank extends CocoClass
|
||||||
bar.scaleX = healthPct / @options.floatingLayer.resolutionFactor
|
bar.scaleX = healthPct / @options.floatingLayer.resolutionFactor
|
||||||
if @thang.showsName
|
if @thang.showsName
|
||||||
@setNameLabel(if @thang.health <= 0 then '' else @thang.id)
|
@setNameLabel(if @thang.health <= 0 then '' else @thang.id)
|
||||||
|
else if @options.playerName
|
||||||
|
@setNameLabel @options.playerName
|
||||||
|
|
||||||
configureMouse: ->
|
configureMouse: ->
|
||||||
@sprite.cursor = 'pointer' if @thang?.isSelectable
|
@sprite.cursor = 'pointer' if @thang?.isSelectable
|
||||||
|
|
|
@ -163,6 +163,8 @@ module.exports = class LankBoss extends CocoClass
|
||||||
|
|
||||||
options = @createLankOptions thang: thang
|
options = @createLankOptions thang: thang
|
||||||
options.resolutionFactor = if thangType.get('kind') is 'Floor' then 2 else SPRITE_RESOLUTION_FACTOR
|
options.resolutionFactor = if thangType.get('kind') is 'Floor' then 2 else SPRITE_RESOLUTION_FACTOR
|
||||||
|
if @options.playerNames and /Hero Placeholder/.test thang.id
|
||||||
|
options.playerName = @options.playerNames[thang.team]
|
||||||
lank = new Lank thangType, options
|
lank = new Lank thangType, options
|
||||||
@listenTo lank, 'sprite:mouse-up', @onLankMouseUp
|
@listenTo lank, 'sprite:mouse-up', @onLankMouseUp
|
||||||
@addLank lank, null, layer
|
@addLank lank, null, layer
|
||||||
|
|
|
@ -113,7 +113,7 @@ module.exports = Surface = class Surface extends CocoClass
|
||||||
canvasHeight = parseInt @normalCanvas.attr('height'), 10
|
canvasHeight = parseInt @normalCanvas.attr('height'), 10
|
||||||
@screenLayer.addChild new Letterbox canvasWidth: canvasWidth, canvasHeight: canvasHeight
|
@screenLayer.addChild new Letterbox canvasWidth: canvasWidth, canvasHeight: canvasHeight
|
||||||
|
|
||||||
@lankBoss = new LankBoss camera: @camera, webGLStage: @webGLStage, surfaceTextLayer: @surfaceTextLayer, world: @world, thangTypes: @options.thangTypes, choosing: @options.choosing, navigateToSelection: @options.navigateToSelection, showInvisible: @options.showInvisible
|
@lankBoss = new LankBoss camera: @camera, webGLStage: @webGLStage, surfaceTextLayer: @surfaceTextLayer, world: @world, thangTypes: @options.thangTypes, choosing: @options.choosing, navigateToSelection: @options.navigateToSelection, showInvisible: @options.showInvisible, playerNames: @options.playerNames
|
||||||
@countdownScreen = new CountdownScreen camera: @camera, layer: @screenLayer, showsCountdown: @world.showsCountdown
|
@countdownScreen = new CountdownScreen camera: @camera, layer: @screenLayer, showsCountdown: @world.showsCountdown
|
||||||
@playbackOverScreen = new PlaybackOverScreen camera: @camera, layer: @screenLayer
|
@playbackOverScreen = new PlaybackOverScreen camera: @camera, layer: @screenLayer
|
||||||
@normalStage.addChildAt @playbackOverScreen.dimLayer, 0 # Put this below the other layers, actually, so we can more easily read text on the screen.
|
@normalStage.addChildAt @playbackOverScreen.dimLayer, 0 # Put this below the other layers, actually, so we can more easily read text on the screen.
|
||||||
|
@ -549,8 +549,9 @@ module.exports = Surface = class Surface extends CocoClass
|
||||||
@normalStage.scaleY *= newHeight / oldHeight
|
@normalStage.scaleY *= newHeight / oldHeight
|
||||||
@camera.onResize newWidth, newHeight
|
@camera.onResize newWidth, newHeight
|
||||||
if @options.spectateGame
|
if @options.spectateGame
|
||||||
# Since normalCanvas is absolutely positioned, it needs help aligning with webGLCanvas. But not further than +149px (1920px screen).
|
# Since normalCanvas is absolutely positioned, it needs help aligning with webGLCanvas.
|
||||||
@normalCanvas.css 'left', Math.min 149, @webGLCanvas.offset().left
|
offset = @webGLCanvas.offset().left - ($('#page-container').innerWidth() - $('#canvas-wrapper').innerWidth()) / 2
|
||||||
|
@normalCanvas.css 'left', offset
|
||||||
|
|
||||||
#- Camera focus on hero
|
#- Camera focus on hero
|
||||||
focusOnHero: ->
|
focusOnHero: ->
|
||||||
|
|
|
@ -187,13 +187,13 @@ module.exports = class SpectateLevelView extends RootView
|
||||||
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
||||||
|
|
||||||
insertSubviews: ->
|
insertSubviews: ->
|
||||||
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, spectateView: true, spectateOpponentCodeLanguage: @otherSession?.get('submittedCodeLanguage'), level: @level
|
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, otherSession: @otherSession, thangs: @world.thangs, supermodel: @supermodel, spectateView: true, spectateOpponentCodeLanguage: @otherSession?.get('submittedCodeLanguage'), level: @level
|
||||||
@insertSubView new PlaybackView {}
|
@insertSubView new PlaybackView session: @session, level: @level
|
||||||
|
|
||||||
@insertSubView new GoldView {}
|
@insertSubView new GoldView {}
|
||||||
@insertSubView new HUDView {}
|
@insertSubView new HUDView {level: @level}
|
||||||
worldName = utils.i18n @level.attributes, 'name'
|
worldName = utils.i18n @level.attributes, 'name'
|
||||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, spectateGame: true}
|
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, spectateGame: true}
|
||||||
|
|
||||||
# callbacks
|
# callbacks
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ module.exports = class SpectateLevelView extends RootView
|
||||||
initSurface: ->
|
initSurface: ->
|
||||||
webGLSurface = $('canvas#webgl-surface', @$el)
|
webGLSurface = $('canvas#webgl-surface', @$el)
|
||||||
normalSurface = $('canvas#normal-surface', @$el)
|
normalSurface = $('canvas#normal-surface', @$el)
|
||||||
@surface = new Surface(@world, normalSurface, webGLSurface, thangTypes: @supermodel.getModels(ThangType), playJingle: not @isEditorPreview, spectateGame: true, wizards: @level.get('type', true) isnt 'hero')
|
@surface = new Surface @world, normalSurface, webGLSurface, thangTypes: @supermodel.getModels(ThangType), playJingle: not @isEditorPreview, spectateGame: true, wizards: @level.get('type', true) is 'ladder', playerNames: @findPlayerNames()
|
||||||
worldBounds = @world.getBounds()
|
worldBounds = @world.getBounds()
|
||||||
bounds = [{x:worldBounds.left, y:worldBounds.top}, {x:worldBounds.right, y:worldBounds.bottom}]
|
bounds = [{x:worldBounds.left, y:worldBounds.top}, {x:worldBounds.right, y:worldBounds.bottom}]
|
||||||
@surface.camera.setBounds(bounds)
|
@surface.camera.setBounds(bounds)
|
||||||
|
@ -215,6 +215,12 @@ module.exports = class SpectateLevelView extends RootView
|
||||||
@surface.camera.zoomTo({x: (worldBounds.right - worldBounds.left) / 2, y: (worldBounds.top - worldBounds.bottom) / 2}, 0.1, 0)
|
@surface.camera.zoomTo({x: (worldBounds.right - worldBounds.left) / 2, y: (worldBounds.top - worldBounds.bottom) / 2}, 0.1, 0)
|
||||||
_.delay zoom, 4000 # call it later for some reason (TODO: figure this out)
|
_.delay zoom, 4000 # call it later for some reason (TODO: figure this out)
|
||||||
|
|
||||||
|
findPlayerNames: ->
|
||||||
|
playerNames = {}
|
||||||
|
for session in [@session, @otherSession] when session?.get('team')
|
||||||
|
playerNames[session.get('team')] = session.get('creatorName') or 'Anoner'
|
||||||
|
playerNames
|
||||||
|
|
||||||
initGoalManager: ->
|
initGoalManager: ->
|
||||||
@goalManager = new GoalManager(@world, @level.get('goals'))
|
@goalManager = new GoalManager(@world, @level.get('goals'))
|
||||||
@god.setGoalManager @goalManager
|
@god.setGoalManager @goalManager
|
||||||
|
|
|
@ -305,12 +305,19 @@ module.exports = class PlayLevelView extends RootView
|
||||||
initSurface: ->
|
initSurface: ->
|
||||||
webGLSurface = $('canvas#webgl-surface', @$el)
|
webGLSurface = $('canvas#webgl-surface', @$el)
|
||||||
normalSurface = $('canvas#normal-surface', @$el)
|
normalSurface = $('canvas#normal-surface', @$el)
|
||||||
@surface = new Surface(@world, normalSurface, webGLSurface, thangTypes: @supermodel.getModels(ThangType), playJingle: not @isEditorPreview, wizards: not (@level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop']))
|
@surface = new Surface(@world, normalSurface, webGLSurface, thangTypes: @supermodel.getModels(ThangType), playJingle: not @isEditorPreview, wizards: not (@level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop']), observing: @observing, playerNames: @findPlayerNames())
|
||||||
worldBounds = @world.getBounds()
|
worldBounds = @world.getBounds()
|
||||||
bounds = [{x: worldBounds.left, y: worldBounds.top}, {x: worldBounds.right, y: worldBounds.bottom}]
|
bounds = [{x: worldBounds.left, y: worldBounds.top}, {x: worldBounds.right, y: worldBounds.bottom}]
|
||||||
@surface.camera.setBounds(bounds)
|
@surface.camera.setBounds(bounds)
|
||||||
@surface.camera.zoomTo({x: 0, y: 0}, 0.1, 0)
|
@surface.camera.zoomTo({x: 0, y: 0}, 0.1, 0)
|
||||||
|
|
||||||
|
findPlayerNames: ->
|
||||||
|
return {} unless @observing
|
||||||
|
playerNames = {}
|
||||||
|
for session in [@session, @otherSession] when session?.get('team')
|
||||||
|
playerNames[session.get('team')] = session.get('creatorName') or 'Anoner'
|
||||||
|
playerNames
|
||||||
|
|
||||||
# Once Surface is Loaded ####################################################
|
# Once Surface is Loaded ####################################################
|
||||||
|
|
||||||
onLevelStarted: ->
|
onLevelStarted: ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue