print("*** LOADING rwr.nas ... ***"); var lineWidth = 3; RWRCanvas = { new: func (_ident, root, center, diameter) { var rwr = {parents: [RWRCanvas]}; rwr.max_icons = 12; var radius = diameter/2; rwr.inner_radius = radius*0.30; rwr.outer_radius = radius*0.75; rwr.circle_radius_big = radius*0.5; rwr.circle_radius_small = radius*0.125; var tick_long = radius*0.25; var tick_short = tick_long*0.5; var font = int(0.08*diameter); var colorG = [0.3,1,0.3]; var colorLG = [0,0.5,0]; rwr.fadeTime = 7;#seconds rwr.rootCenter = root.createChild("group") .setTranslation(center[0],center[1]); var rootOffset = root.createChild("group") .setTranslation(center[0]-diameter/2,center[1]-diameter/2); # root.createChild("path") # .moveTo(0, diameter/2) # .arcSmallCW(diameter/2, diameter/2, 0, diameter, 0) # .arcSmallCW(diameter/2, diameter/2, 0, -diameter, 0) # .setStrokeLineWidth(lineWidth) # .setColor(1, 1, 1); rootOffset.createChild("path") .moveTo(diameter/2-rwr.circle_radius_small, diameter/2) .arcSmallCW(rwr.circle_radius_small, rwr.circle_radius_small, 0, rwr.circle_radius_small*2, 0) .arcSmallCW(rwr.circle_radius_small, rwr.circle_radius_small, 0, -rwr.circle_radius_small*2, 0) .setStrokeLineWidth(lineWidth) .setColor(colorLG); rootOffset.createChild("path") .moveTo(diameter/2-rwr.circle_radius_big, diameter/2) .arcSmallCW(rwr.circle_radius_big, rwr.circle_radius_big, 0, rwr.circle_radius_big*2, 0) .arcSmallCW(rwr.circle_radius_big, rwr.circle_radius_big, 0, -rwr.circle_radius_big*2, 0) .setStrokeLineWidth(lineWidth) .setColor(colorLG); rootOffset.createChild("path") .moveTo(diameter/2-rwr.circle_radius_small/2, diameter/2) .lineTo(diameter/2+rwr.circle_radius_small/2, diameter/2) .moveTo(diameter/2, diameter/2-rwr.circle_radius_small/2) .lineTo(diameter/2, diameter/2+rwr.circle_radius_small/2) .setStrokeLineWidth(lineWidth) .setColor(colorLG); rootOffset.createChild("path") .moveTo(0,diameter*0.5) .horiz(tick_long) .moveTo(diameter,diameter*0.5) .horiz(-tick_long) .moveTo(diameter*0.5,0) .vert(tick_long) .moveTo(diameter*0.5,diameter) .vert(-tick_long) .setStrokeLineWidth(lineWidth) .setColor(colorLG); rwr.rootCenter.createChild("path") .moveTo(radius*math.cos(30*D2R),radius*math.sin(-30*D2R)) .lineTo((radius-tick_short)*math.cos(30*D2R),(radius-tick_short)*math.sin(-30*D2R)) .moveTo(radius*math.cos(60*D2R),radius*math.sin(-60*D2R)) .lineTo((radius-tick_short)*math.cos(60*D2R),(radius-tick_short)*math.sin(-60*D2R)) .moveTo(radius*math.cos(30*D2R),radius*math.sin(30*D2R)) .lineTo((radius-tick_short)*math.cos(30*D2R),(radius-tick_short)*math.sin(30*D2R)) .moveTo(radius*math.cos(60*D2R),radius*math.sin(60*D2R)) .lineTo((radius-tick_short)*math.cos(60*D2R),(radius-tick_short)*math.sin(60*D2R)) .moveTo(-radius*math.cos(30*D2R),radius*math.sin(-30*D2R)) .lineTo(-(radius-tick_short)*math.cos(30*D2R),(radius-tick_short)*math.sin(-30*D2R)) .moveTo(-radius*math.cos(60*D2R),radius*math.sin(-60*D2R)) .lineTo(-(radius-tick_short)*math.cos(60*D2R),(radius-tick_short)*math.sin(-60*D2R)) .moveTo(-radius*math.cos(30*D2R),radius*math.sin(30*D2R)) .lineTo(-(radius-tick_short)*math.cos(30*D2R),(radius-tick_short)*math.sin(30*D2R)) .moveTo(-radius*math.cos(60*D2R),radius*math.sin(60*D2R)) .lineTo(-(radius-tick_short)*math.cos(60*D2R),(radius-tick_short)*math.sin(60*D2R)) .setStrokeLineWidth(lineWidth) .setColor(colorLG); rwr.texts = setsize([],rwr.max_icons); for (var i = 0;i0) me.parent_obj.update(notification.rwrList, "normal"); else if (notification["rwrList16"] != nil) me.parent_obj.update(notification.rwrList16, "link16"); return emesary.Transmitter.ReceiptStatus_OK; } return emesary.Transmitter.ReceiptStatus_NotProcessed; }; emesary.GlobalTransmitter.Register(rwr.recipient); return rwr; }, update: func (list, type) { #printf("list %d", size(list)); me.elapsed = getprop("sim/time/elapsed-sec"); var sorter = func(a, b) { if(a[1] > b[1]){ return -1; # A should before b in the returned vector }elsif(a[1] == b[1]){ return 0; # A is equivalent to b }else{ return 1; # A should after b in the returned vector } } me.sortedlist = sort(list, sorter); me.newList = []; me.i = 0; me.prio = 0; me.newsound = 0; me.unk = 0; foreach(me.contact; me.sortedlist) { me.typ=me.lookupType[me.contact[0].get_model()]; if (me.i > me.max_icons-1) { break; } if (me.typ == nil) { if (me.contact[0].propNode.getName() != "multiplayer") { # AI planes are allowed to be unknowns me.typ = me.AIRCRAFT_UNKNOWN; me.unk = 1; } else { continue; } } #print("show "~me.i~" "~me.typ~" "~contact[0].get_model()~" "~contact[1]); me.threat = me.contact[1];#print(me.threat); if (me.threat > 0.5 and me.typ != me.AIRCRAFT_UNKNOWN and me.typ != me.ASSET_AI) { me.threat = me.inner_radius;# inner circle } elsif (me.threat > 0) { me.threat = me.outer_radius;# outer circle } else { continue; } if (me.contact[0].get_range() > 170) { continue; } me.dev = -geo.normdeg180(me.contact[0].get_bearing()-getprop("orientation/heading-deg"))+90; me.x = math.cos(me.dev*D2R)*me.threat; me.y = -math.sin(me.dev*D2R)*me.threat; me.texts[me.i].setTranslation(me.x,me.y); me.texts[me.i].setText(me.typ); me.texts[me.i].show(); if (me.prio == 0 and me.typ != me.ASSET_AI and me.typ != me.AIRCRAFT_UNKNOWN) {# me.symbol_priority.setTranslation(me.x,me.y); me.symbol_priority.show(); me.prio = 1; } if (!(me.typ == me.ASSET_GARGOYLE or me.typ == me.ASSET_BUK or me.typ == me.ASSET_PAC2 or me.typ == me.ASSET_FRIGATE) and me.contact[0].get_Speed()>60) { #air-borne me.symbol_hat[me.i].setTranslation(me.x,me.y); me.symbol_hat[me.i].show(); } else { me.symbol_hat[me.i].hide(); } if (me.contact[0].get_Callsign()==getprop("sound/rwr-launch") and 10*(me.elapsed-int(me.elapsed))>5) {#blink 2Hz me.symbol_launch[me.i].setTranslation(me.x,me.y); me.symbol_launch[me.i].show(); } else { me.symbol_launch[me.i].hide(); } me.popupNew = me.elapsed; foreach(me.old; me.shownList) { if(me.old[0].getUnique()==me.contact[0].getUnique()) { me.popupNew = me.old[1]; break; } } if (me.popupNew == me.elapsed) { me.newsound = 1; } if (me.popupNew > me.elapsed-me.fadeTime) { me.symbol_new[me.i].setTranslation(me.x,me.y); me.symbol_new[me.i].show(); me.symbol_new[me.i].update(); } else { me.symbol_new[me.i].hide(); } #printf("display %s %d",contact[0].get_Callsign(), me.threat); append(me.newList, [me.contact[0],me.popupNew]); me.i += 1; } me.shownList = me.newList; if (me.newsound == 1) setprop("sound/rwr-new", !getprop("sound/rwr-new")); for (;me.i