mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 05:53:39 -04:00
Merge pull request #541 from dkundel/master
Easy use of coordinates as discussed in #10 and minor fixes
This commit is contained in:
commit
42a8862fa9
6 changed files with 34 additions and 9 deletions
app
lib/surface
styles
views/play/level/tome
|
@ -4,6 +4,7 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
|||
'surface:mouse-moved': 'onMouseMove'
|
||||
'surface:mouse-out': 'onMouseOut'
|
||||
'surface:mouse-over': 'onMouseOver'
|
||||
'surface:stage-mouse-down': 'onMouseDown'
|
||||
'camera:zoom-updated': 'onZoomUpdated'
|
||||
|
||||
constructor: (options) ->
|
||||
|
@ -30,6 +31,10 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
|||
onMouseOut: (e) -> @mouseInBounds = false
|
||||
|
||||
onMouseMove: (e) ->
|
||||
if @mouseInBounds and key.shift
|
||||
$('#surface').addClass('flag-cursor') unless $('#surface').hasClass('flag-cursor')
|
||||
else if @mouseInBounds
|
||||
$('#surface').removeClass('flag-cursor') if $('#surface').hasClass('flag-cursor')
|
||||
wop = @camera.canvasToWorld x: e.x, y: e.y
|
||||
wop.x = Math.round(wop.x)
|
||||
wop.y = Math.round(wop.y)
|
||||
|
@ -38,6 +43,13 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
|||
@hide()
|
||||
@show() # debounced
|
||||
|
||||
onMouseDown: (e) ->
|
||||
return unless key.shift
|
||||
wop = @camera.canvasToWorld x: e.x, y: e.y
|
||||
wop.x = Math.round wop.x
|
||||
wop.y = Math.round wop.y
|
||||
Backbone.Mediator.publish 'surface:coordinate-selected', wop
|
||||
|
||||
onZoomUpdated: (e) ->
|
||||
@hide()
|
||||
@show()
|
||||
|
|
|
@ -240,14 +240,14 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
@dragged += 1
|
||||
|
||||
onSpriteMouseUp: (e) ->
|
||||
return if key.shift and @options.choosing
|
||||
return if key.shift #and @options.choosing
|
||||
return @dragged = 0 if @dragged > 3
|
||||
@dragged = 0
|
||||
sprite = if e.sprite?.thang?.isSelectable then e.sprite else null
|
||||
@selectSprite e, sprite
|
||||
|
||||
onStageMouseDown: (e) ->
|
||||
return if key.shift and @options.choosing
|
||||
return if key.shift #and @options.choosing
|
||||
@selectSprite e if e.onBackground
|
||||
|
||||
selectThang: (thangID, spellName=null) ->
|
||||
|
|
|
@ -117,7 +117,8 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@updateState true if @loaded
|
||||
# TODO: synchronize both ways of choosing whether to show coords (@world via UI System or @options via World Select modal)
|
||||
if @world.showCoordinates and @options.coords
|
||||
@surfaceTextLayer.addChild new CoordinateDisplay camera: @camera
|
||||
@coordinateDisplay = new CoordinateDisplay camera: @camera
|
||||
@surfaceTextLayer.addChild @coordinateDisplay
|
||||
@onFrameChanged()
|
||||
Backbone.Mediator.publish 'surface:world-set-up'
|
||||
|
||||
|
@ -322,6 +323,10 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@wasPlayingWhenCastingBegan = @playing
|
||||
Backbone.Mediator.publish 'level-set-playing', { playing: false }
|
||||
|
||||
if @coordinateDisplay?
|
||||
@surfaceTextLayer.removeChild @coordinateDisplay
|
||||
@coordinateDisplay.destroy()
|
||||
|
||||
createjs.Tween.removeTweens(@surfaceLayer)
|
||||
createjs.Tween.get(@surfaceLayer).to({alpha:0.9}, 1000, createjs.Ease.getPowOut(4.0))
|
||||
|
||||
|
|
|
@ -180,3 +180,6 @@ table.table
|
|||
border: 1px solid black
|
||||
.ui-slider-handle
|
||||
border: 1px solid black !important
|
||||
|
||||
.flag-cursor
|
||||
cursor: crosshair
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
@include opacity(80)
|
||||
.ace_cursor
|
||||
@include opacity(20)
|
||||
|
||||
|
||||
.ace_gutter
|
||||
background-color: rgba(255, 255, 255, 0.25)
|
||||
width: 40px
|
||||
|
@ -73,7 +73,7 @@
|
|||
.executing, .executed, .problem-marker-info, .problem-marker-warning, .problem-marker-error
|
||||
position: absolute
|
||||
.executing
|
||||
background-color: rgba(0, 255, 0, 0.20)
|
||||
background-color: rgba(50, 255, 80, 0.35)
|
||||
@include gradient-striped()
|
||||
.executed
|
||||
background-color: rgba(110, 110, 110, 0.12)
|
||||
|
@ -86,14 +86,15 @@
|
|||
|
||||
.executing:not(.ace_gutter-cell)
|
||||
background-size: 40px 40px
|
||||
text-shadow: 1px 1px 1px #000
|
||||
@include animation(progress-bar-stripes 2s linear infinite)
|
||||
|
||||
.ace_gutter-cell.executing:not(.ace_error)
|
||||
.ace_gutter-cell.executing:not(.ace_error):not(.ace_warning):not(.ace_info)
|
||||
margin-left: 1px
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowMjgwMTE3NDA3MjA2ODExOEE2REU4Q0M1MTM1MkIxRiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpBQjVEQUNDMzQ4RUIxMUUxOEVGRUUyNzFENDM3RDVFMCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpBQjVEQUNDMjQ4RUIxMUUxOEVGRUUyNzFENDM3RDVFMCIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgTWFjaW50b3NoIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QTU1MjE3RDIzMTIwNjgxMThEQkI4NTlBMjQ1QTEwOTUiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MDI4MDExNzQwNzIwNjgxMThBNkRFOENDNTEzNTJCMUYiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7SazaGAAAAiElEQVR42mL8//8/AzUBEwOVweA3kAWboI2jCyhgDwBx4ZH9ey5Qy4UOQHweaHg/EAtQ08sFUIMDqBmGCkC8HmgoCCtQM1ICoK5toGYsg8KzHmjo+UGbDj8AcSMwORkSnQ7xgA3QtPmApISNBTyAGrSBGl6eAMSGxBhGyIVkZT3G0fKQYgAQYACL+C2ZM6PC7AAAAABJRU5ErkJggg==)
|
||||
background-position: 0px center
|
||||
|
||||
.ace_gutter-cell.executed:not(.ace_error)
|
||||
.ace_gutter-cell.executed:not(.ace_error):not(.ace_warning):not(.ace_info)
|
||||
margin-left: 1px
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANhJREFUeNpi/P//PwM1ARMDlcHgMrA428MAiANQBEFhSA4uynIXAOJ+dHFKXDgfiDdSxctAbzYAqQ+9U3ccQJdjIcMwByCVD8SGFEcK0DAFILUeiCcCXfeAIgOBhglADfsAxBNwqSPFy/1AbADEiUDXfSApHQJdcx+I9yPxE4AUCB8AGrYAn62M6HkZ6rX3UG4jEG8A4vNQviO2mMXrQqh3GqHcemi4gcACQobhixRQoMNiUQEaEY1k52WoKwuRhHAmE6KTDdCADdDwu4AvmRCMlOFfwAIEGAD4On+N4aXlhgAAAABJRU5ErkJggg==)
|
||||
background-position: 0px center
|
||||
|
@ -112,5 +113,3 @@
|
|||
|
||||
.ace_text-layer .ace_comment
|
||||
color: darken(rgb(103, 164, 200), 5%)
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ module.exports = class SpellView extends View
|
|||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'surface:coordinate-selected': 'onCoordinateSelected'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:user-code-problem': 'onUserCodeProblem'
|
||||
'tome:manual-cast': 'onManualCast'
|
||||
|
@ -423,6 +424,11 @@ module.exports = class SpellView extends View
|
|||
@thang = e.selectedThang # update our thang to the current version
|
||||
@highlightCurrentLine()
|
||||
|
||||
onCoordinateSelected: (e) ->
|
||||
return unless e.x? and e.y?
|
||||
@ace.insert "{x: #{e.x}, y: #{e.y}}"
|
||||
@highlightCurrentLine()
|
||||
|
||||
onStatementIndexUpdated: (e) ->
|
||||
return unless e.ace is @ace
|
||||
@highlightCurrentLine()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue