public var connection:Connection; // server connection
public const TILESPRITE:uint=0;
- public const WAYSPRITE:uint=1;
- public const POISPRITE:uint=12;
- public const NAMESPRITE:uint=13;
+ public const GPSSPRITE:uint=1;
+ public const WAYSPRITE:uint=2;
+ public const POISPRITE:uint=13;
+ public const NAMESPRITE:uint=14;
// ------------------------------------------------------------------------------------------
// Map constructor function
} // | | |
s.addChild(t); // | |
s.addChild(getPaintSprite()); // | 3 names
- s.addChild(getHitSprite()); // | 4 entity hit tests
+ s.addChild(getPaintSprite()); // | 4 nodes
+ s.addChild(getHitSprite()); // | 5 entity hit tests
addChild(s); // |
}
addChild(getPaintSprite()); // 12 - POIs
if (sl.pointStyles[sublayer]) {
var s:PointStyle=sl.pointStyles[sublayer];
-// if ((s is PointStyle) && s.icon && s.icon!="")
r=true;
if (s.icon_image!=iconname) {
// 'load' icon (actually just from library)
if (map.ruleset.images[s.icon_image]) {
-// l=map.getChildAt(map.POISPRITE);
-// Sprite(l).addChild(map.ruleset.images[s.icon_image]);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedIcon);
loader.loadBytes(map.ruleset.images[s.icon_image]);
if (sl.textStyles[sublayer]) {
var t:TextStyle=sl.textStyles[sublayer];
-// if ((s is TextStyle) && s.tag && tags[s.tag])
// create name sprite
if (!name) {
name=new Sprite();
gridFitType: GridFitType.NONE
};
public var nameformat:TextFormat;
+
+ private const FILLSPRITE:uint=0;
+ private const CASINGSPRITE:uint=1;
+ private const STROKESPRITE:uint=2;
+ private const NAMESPRITE:uint=3;
+ private const NODESPRITE:uint=4;
+ private const CLICKSPRITE:uint=5;
public function WayUI(way:Way, map:Map) {
for (var stateKey:String in stateClasses) {
tags[":"+stateKey] = stateKey;
}
+ if (way.isArea()) { tags[':area']='yes'; }
// Remove all currently existing sprites
while (sprites.length>0) {
// Stroke
if (s.width) {
- stroke=new Shape(); addToLayer(stroke,2,sublayer);
+ stroke=new Shape(); addToLayer(stroke,STROKESPRITE,sublayer);
stroke.graphics.moveTo(x0,y0);
s.applyStrokeStyle(stroke.graphics);
if (s.dashes && s.dashes.length>0) { dashedLine(stroke.graphics,s.dashes); }
// Fill
if (s.fill_color || s.fill_image) {
- fill=new Shape(); addToLayer(fill,0);
+ fill=new Shape(); addToLayer(fill,FILLSPRITE);
fill.graphics.moveTo(x0,y0);
if (s.fill_image) { new WayBitmapFiller(this,fill.graphics,s); }
else { s.applyFill(fill.graphics); }
// Casing
if (s.casing_width) {
- casing=new Shape(); addToLayer(casing,1);
+ casing=new Shape(); addToLayer(casing,CASINGSPRITE);
casing.graphics.moveTo(x0,y0);
s.applyCasingStyle(casing.graphics);
if (s.casing_dashes && s.casing_dashes.length>0) { dashedLine(casing.graphics,s.casing_dashes); }
if (sl.textStyles[sublayer]) {
var t:TextStyle=sl.textStyles[sublayer];
- roadname=new Sprite(); addToLayer(roadname,3);
+ roadname=new Sprite(); addToLayer(roadname,NAMESPRITE);
nameformat = t.getTextFormat();
var a:String=tags[t.text];
if (a) {
}
}
+ // ** draw icons
+ for (var i:uint = 0; i < way.length; i++) {
+ var node:Node = way.getNode(i);
+ if (node.hasTags()) {
+ map.connection.registerPOI(node);
+ }
+ }
+
+
// ** ShieldStyle to do
}
var def:Sprite = new Sprite();
def.graphics.lineStyle(0.5, 0x808080, 1, false, "normal");
solidLine(def.graphics);
- addToLayer(def, 2);
+ addToLayer(def, STROKESPRITE); // ** this probably needs a sublayer
drawn=true;
}
if ( stateClasses["showNodes"] != null ) {
var nodes:Sprite = new Sprite();
drawNodes(nodes.graphics);
- addToLayer(nodes, 3);
+ addToLayer(nodes, NODESPRITE);
}
if (!drawn) { return; }
hitzone = new Sprite();
hitzone.graphics.lineStyle(4, 0x000000, 1, false, "normal", CapsStyle.ROUND, JointStyle.ROUND);
solidLine(hitzone.graphics);
- addToLayer(hitzone, 4);
+ addToLayer(hitzone, CLICKSPRITE);
hitzone.visible = false;
if ( listenSprite == null ) {
listenSprite.addEventListener(MouseEvent.MOUSE_MOVE, mouseEvent);
}
listenSprite.hitArea = hitzone;
- addToLayer(listenSprite, 4);
+ addToLayer(listenSprite, CLICKSPRITE);
listenSprite.buttonMode = true;
listenSprite.mouseEnabled = true;
// Draw name along path
// based on code by Tom Carden
- // ** needs styling
private function writeNameOnPath(s:Sprite,a:String,textOffset:Number=0):void {
dispatchEvent(e);
}
- protected function registerPOI(node:Node):void {
+ public function registerPOI(node:Node):void {
if ( pois.indexOf(node) < 0 ) {
pois.push(node);
sendEvent(new EntityEvent(NEW_POI, node));
private static const COLOR:RegExp=/color$/;
private static const BOLD:RegExp=/^bold$/i;
private static const ITALIC:RegExp=/^italic|oblique$/i;
+ private static const UNDERLINE:RegExp=/^underline$/i;
private static const CAPS:RegExp=/^uppercase$/i;
private static const CENTER:RegExp=/^center$/i;
xs.sublayer=10;
// Munge special values
- if (t['font_weight'] ) { t['font_bold' ] = t['font_weight' ].match(BOLD ) ? true : false; }
- if (t['font_style'] ) { t['font_italic'] = t['font_style' ].match(ITALIC) ? true : false; }
- if (t['text_position'] ) { t['text_center'] = t['text_position'].match(CENTER) ? true : false; }
+ if (t['font_weight'] ) { t['font_bold' ] = t['font_weight' ].match(BOLD ) ? true : false; }
+ if (t['font_style'] ) { t['font_italic'] = t['font_style' ].match(ITALIC) ? true : false; }
+ if (t['text_decoration']) { t['font_underline'] = t['text_decoration'].match(UNDERLINE) ? true : false; }
+ if (t['text_position'] ) { t['text_center'] = t['text_position' ].match(CENTER) ? true : false; }
if (t['text_transform']) {
// ** needs other transformations, e.g. lower-case, sentence-case
if (t['text_transform'].match(CAPS)) { t['font_caps']=true; } else { t['font_caps']=false; }
public var width:Number;
public var color:Number;
public var opacity:Number;
- public var dashes:Array;
+ public var dashes:Array=[];
public var linecap:String;
public var linejoin:String;
public var casing_width:Number;
public var casing_color:Number;
public var casing_opacity:Number;
- public var casing_dashes:Array;
+ public var casing_dashes:Array=[];
override public function get properties():Array {
return [
import flash.utils.ByteArray;
import flash.net.*;
+ import net.systemeD.halcyon.Globals;
public class Style {
public function setPropertyFromString(k:String,v:*):Boolean {
if (!this.hasOwnProperty(k)) { return false; }
if (v is Eval) { evals[k]=v; v=1; }
+
+ // Arrays don't return a proper typeof, so check manually
+ // Note that undefined class variables always have typeof=object,
+ // so we need to declare them as empty arrays (cf ShapeStyle)
+ if (this[k] is Array) {
+ // Split comma-separated array and coerce as numbers
+ this[k]=v.split(',').map(function(el:Object,index:int,array:Array):Number { return Number(el); });
+ edited=true; return true;
+ }
+
+ // Check for other object types
switch (typeof(this[k])) {
case "number": this[k]=Number(v) ; edited=true; return true;
- case "object": // **for some reason, typeof(string class variables) returns "object".
+ case "object": // **for now, just assume objects are undefined strings
// We'll probably need to fix this in future if we have more complex
// properties
case "string": this[k]=String(v) ; edited=true; return true;
public var font_family:String;
public var font_bold:Boolean;
public var font_italic:Boolean;
+ public var font_underline:Boolean;
public var font_caps:Boolean;
public var font_size:uint;
public var text_color:uint;
public var text_halo_color:uint;
public var text_halo_radius:uint=0;
public var text_center:Boolean;
+ public var letter_spacing:uint;
override public function get properties():Array {
return [
'font_family','font_bold','font_italic','font_caps','font_size',
'text_color','text_offset','max_width',
- 'text','text_halo_color','text_halo_radius','text_center'
+ 'text','text_halo_color','text_halo_radius','text_center',
+ 'letter_spacing'
];
}
public function getTextFormat():TextFormat {
- return new TextFormat(font_family ? font_family: "DejaVu",
- font_size ? font_size : 8,
- text_color ? text_color : 0,
- font_bold ? font_bold : false,
- font_italic ? font_italic: false);
+ var tf:TextFormat=new TextFormat(font_family ? font_family : "DejaVu",
+ font_size ? font_size : 8,
+ text_color ? text_color : 0,
+ font_bold ? font_bold : false,
+ font_italic ? font_italic : false,
+ font_underline ? font_underline: false);
+ tf.letterSpacing=(letter_spacing ? letter_spacing : 0);
+ return tf;
}
public function getHaloFilter():Array {