From dd87215012e90225890852c726b6a415d9f1c420 Mon Sep 17 00:00:00 2001
From: Dominik Kundel <dominik.kundel@gmail.com>
Date: Wed, 12 Mar 2014 11:26:56 +0100
Subject: [PATCH 1/6] Avoid overwriting gutter symbols of error, warning, info

---
 app/styles/play/level/tome/spell.sass | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/app/styles/play/level/tome/spell.sass b/app/styles/play/level/tome/spell.sass
index 16473b06d..ee545d9f7 100644
--- a/app/styles/play/level/tome/spell.sass
+++ b/app/styles/play/level/tome/spell.sass
@@ -58,7 +58,7 @@
       @include opacity(80)
       .ace_cursor
         @include opacity(20)
-    
+
     .ace_gutter
       background-color: rgba(255, 255, 255, 0.25)
       width: 40px
@@ -88,12 +88,12 @@
       background-size: 40px 40px
       @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 +112,3 @@
 
     .ace_text-layer .ace_comment
       color: darken(rgb(103, 164, 200), 5%)
-
-      

From 8990b9d194b9890829ed0b61391ef1c565c89bf8 Mon Sep 17 00:00:00 2001
From: Dominik Kundel <dominik.kundel@gmail.com>
Date: Thu, 13 Mar 2014 01:50:59 +0100
Subject: [PATCH 2/6] paste coordiante if click + shift

---
 app/lib/surface/CoordinateDisplay.coffee    | 9 +++++++++
 app/lib/surface/SpriteBoss.coffee           | 4 ++--
 app/views/play/level/tome/spell_view.coffee | 5 +++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/app/lib/surface/CoordinateDisplay.coffee b/app/lib/surface/CoordinateDisplay.coffee
index 7fe570b4e..a96f5f492 100644
--- a/app/lib/surface/CoordinateDisplay.coffee
+++ b/app/lib/surface/CoordinateDisplay.coffee
@@ -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) ->
@@ -38,6 +39,14 @@ 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
+    console.log 'position', wop 
+    Backbone.Mediator.publish 'surface:coordinate-selected', wop
+
   onZoomUpdated: (e) ->
     @hide()
     @show()
diff --git a/app/lib/surface/SpriteBoss.coffee b/app/lib/surface/SpriteBoss.coffee
index f84d52a28..56485d47c 100644
--- a/app/lib/surface/SpriteBoss.coffee
+++ b/app/lib/surface/SpriteBoss.coffee
@@ -238,14 +238,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) ->
diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee
index dd9875b16..2d8866df6 100644
--- a/app/views/play/level/tome/spell_view.coffee
+++ b/app/views/play/level/tome/spell_view.coffee
@@ -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'
@@ -420,6 +421,10 @@ 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}}"
+
   onStatementIndexUpdated: (e) ->
     return unless e.ace is @ace
     @highlightCurrentLine()

From 60214abb4180170f8aeb0cbb616f45788597c41f Mon Sep 17 00:00:00 2001
From: Dominik Kundel <dominik.kundel@gmail.com>
Date: Thu, 13 Mar 2014 02:50:09 +0100
Subject: [PATCH 3/6] Change cursor if moving on map with pressed 'shift'

---
 app/lib/surface/CoordinateDisplay.coffee | 5 ++++-
 app/styles/base.sass                     | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/app/lib/surface/CoordinateDisplay.coffee b/app/lib/surface/CoordinateDisplay.coffee
index a96f5f492..259090ae3 100644
--- a/app/lib/surface/CoordinateDisplay.coffee
+++ b/app/lib/surface/CoordinateDisplay.coffee
@@ -31,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)
@@ -44,7 +48,6 @@ module.exports = class CoordinateDisplay extends createjs.Container
     wop = @camera.canvasToWorld x: e.x, y: e.y
     wop.x = Math.round wop.x
     wop.y = Math.round wop.y
-    console.log 'position', wop 
     Backbone.Mediator.publish 'surface:coordinate-selected', wop
 
   onZoomUpdated: (e) ->
diff --git a/app/styles/base.sass b/app/styles/base.sass
index 58a8c7a13..6e33072b8 100644
--- a/app/styles/base.sass
+++ b/app/styles/base.sass
@@ -179,3 +179,6 @@ table.table
   border: 1px solid black
 .ui-slider-handle
   border: 1px solid black !important
+
+.flag-cursor
+  cursor: crosshair
\ No newline at end of file

From c01d29907d7b8eb95d55cce51e2799e38b143b8e Mon Sep 17 00:00:00 2001
From: Dominik Kundel <dominik.kundel@gmail.com>
Date: Thu, 13 Mar 2014 03:08:28 +0100
Subject: [PATCH 4/6] try to achieve higher contrast between background and
 'executing' line

---
 app/styles/play/level/tome/spell.sass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/styles/play/level/tome/spell.sass b/app/styles/play/level/tome/spell.sass
index ee545d9f7..5e480661c 100644
--- a/app/styles/play/level/tome/spell.sass
+++ b/app/styles/play/level/tome/spell.sass
@@ -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,6 +86,7 @@
 
     .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):not(.ace_warning):not(.ace_info)

From 5c97fea363ad8a046cc3093280ab76f21ae0d0df Mon Sep 17 00:00:00 2001
From: Dominik Kundel <dominik.kundel@gmail.com>
Date: Thu, 13 Mar 2014 03:38:34 +0100
Subject: [PATCH 5/6] fixed issue of multiple insertions due to multiple event
 handlers

---
 app/lib/surface/Surface.coffee | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/lib/surface/Surface.coffee b/app/lib/surface/Surface.coffee
index fd278b8cc..2c1655998 100644
--- a/app/lib/surface/Surface.coffee
+++ b/app/lib/surface/Surface.coffee
@@ -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'
 
@@ -320,6 +321,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))
 

From 4cbdc3cb4b3fe925d4360d94b00a43b57a676474 Mon Sep 17 00:00:00 2001
From: Dominik Kundel <dominik.kundel@gmail.com>
Date: Fri, 14 Mar 2014 00:52:18 +0100
Subject: [PATCH 6/6] highlight lines after insertion

---
 app/views/play/level/tome/spell_view.coffee | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee
index 2d8866df6..19567edad 100644
--- a/app/views/play/level/tome/spell_view.coffee
+++ b/app/views/play/level/tome/spell_view.coffee
@@ -424,6 +424,7 @@ module.exports = class SpellView extends View
   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