fix node-drawing bug and add little restriction POI icon
authorRichard Fairhurst <richard@systemed.net>
Wed, 7 Jul 2010 15:45:37 +0000 (15:45 +0000)
committerRichard Fairhurst <richard@systemed.net>
Wed, 7 Jul 2010 15:45:37 +0000 (15:45 +0000)
TODO.txt
net/systemeD/halcyon/MapPaint.as
net/systemeD/halcyon/NodeUI.as
resources/icons/restriction.png [new file with mode: 0644]
resources/potlatch.css

index 6755aca..d82ba0f 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -22,6 +22,7 @@ Potlatch 2: main outstanding issues
 
 == Tag editing ==
 
+** Finish turn restriction editor
 * initialiseEditors is quite slow (typically 150ms)
 * If a select name is too long then, the select menu seems to give a horizontal scrollbar instead of the name of the item e.g. cuisine#Coffee Shop
 * Bug where the wrong feature is used, when an item that is dragged from the list when an POI has no icon.
index 85d7da6..cadc457 100644 (file)
@@ -60,7 +60,7 @@ package net.systemeD.halcyon {
                        var l:DisplayObject;
                        var o:DisplayObject;
                        var index:String, ix:Number;
-                       if (!sublayerIndex[sublayer]) {
+                       if (!sublayerIndex.hasOwnProperty(sublayer)) {
                                // work out which position to add at
                                var lowestAbove:Number=VERYBIG;
                                var lowestAbovePos:int=-1;
index fbce463..1f5264c 100644 (file)
@@ -15,7 +15,7 @@ package net.systemeD.halcyon {
        public class NodeUI extends EntityUI {
                
                public var loaded:Boolean=false;
-               private var iconname:String='';                         // name of icon
+               private var iconnames:Object={};                        // name of icon on each sublayer
                private var heading:Number=0;                           // heading within way
                private var rotation:Number=0;                          // rotation applied to this POI
                private static const NO_LAYER:int=-99999;
@@ -51,7 +51,7 @@ package net.systemeD.halcyon {
                        var inWay:Boolean=entity.hasParentWays;
                        var hasStyles:Boolean=sl.hasStyles();
                        
-                       removeSprites(); iconname='';
+                       removeSprites(); iconnames={};
                        return renderFromStyle(sl,tags);
                }
 
@@ -68,8 +68,7 @@ package net.systemeD.halcyon {
                                        interactive||=s.interactive;
                                        r=true;
                                        if (s.rotation) { rotation=s.rotation; }
-
-                                       if (s.icon_image!=iconname) {
+                                       if (s.icon_image!=iconnames[sublayer]) {
                                                if (s.icon_image=='square') {
                                                        // draw square
                                                        icon=new Sprite();
@@ -77,7 +76,7 @@ package net.systemeD.halcyon {
                                                        w=styleIcon(icon,sl,sublayer);
                                                        icon.graphics.drawRect(0,0,w,w);
                                                        if (s.interactive) { maxwidth=Math.max(w,maxwidth); }
-                                                       iconname='_square';
+                                                       iconnames[sublayer]='_square';
 
                                                } else if (s.icon_image=='circle') {
                                                        // draw circle
@@ -86,15 +85,15 @@ package net.systemeD.halcyon {
                                                        w=styleIcon(icon,sl,sublayer);
                                                        icon.graphics.drawCircle(w,w,w);
                                                        if (s.interactive) { maxwidth=Math.max(w,maxwidth); }
-                                                       iconname='_circle';
+                                                       iconnames[sublayer]='_circle';
 
                                                } else if (paint.ruleset.images[s.icon_image]) {
                                                        // 'load' icon (actually just from library)
-                                                       var loader:Loader = new Loader();
-                                                       loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void { 
-                                                               loadedIcon(e,sublayer); } );
+                                                       var loader:ExtendedLoader = new ExtendedLoader();
+                                                       loader.info['sublayer']=sublayer;
+                                                       loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedIcon);
                                                        loader.loadBytes(paint.ruleset.images[s.icon_image]);
-                                                       iconname=s.icon_image;
+                                                       iconnames[sublayer]=s.icon_image;
                                                }
                                        }
                                }
@@ -120,7 +119,7 @@ package net.systemeD.halcyon {
                }
 
 
-               private function styleIcon(icon:Sprite, sl:StyleList, sublayer:uint):Number {
+               private function styleIcon(icon:Sprite, sl:StyleList, sublayer:Number):Number {
                        loaded=true;
 
                        // get colours
@@ -149,8 +148,9 @@ package net.systemeD.halcyon {
                        setListenSprite(NODECLICKSPRITE, hitzone);
                }
 
-               private function loadedIcon(event:Event,sublayer:uint):void {
+               private function loadedIcon(event:Event):void {
                        var icon:Sprite=new Sprite();
+                       var sublayer:Number=event.target.loader.info['sublayer'];
                        addToLayer(icon,STROKESPRITE,sublayer);
                        icon.addChild(Bitmap(event.target.content));
                        addHitSprite(icon.width);
diff --git a/resources/icons/restriction.png b/resources/icons/restriction.png
new file mode 100644 (file)
index 0000000..45671d4
Binary files /dev/null and b/resources/icons/restriction.png differ
index fc3035b..b0a5da7 100644 (file)
@@ -140,6 +140,8 @@ way :hover  { z-index: 2; width: eval('_width+10'); color: #ffff99; }
 way :selected { z-index: 2; width: eval('_width+10'); color: yellow; opacity: 0.7;}
 way !:drawn { z-index:10; width: 0.5; color: gray; } 
 
+relation[type=restriction] node { z-index:11; icon-image: icons/restriction.png; }
+
 node :selectedway { z-index: 9; icon-image: square; icon-width: 8; color: red; }
 node :hoverway { z-index: 9; icon-image: square; icon-width: 7; color: blue; }
 node !:drawn :poi { z-index: 2; icon-image: circle; icon-width: 4; color: green; casing-color: black; casing-width: 1; }