From e17146bdfaf4e7b04a92f1c4f10e53a8e80f3fb9 Mon Sep 17 00:00:00 2001 From: mfranz Date: Sat, 15 Apr 2006 20:21:41 +0000 Subject: [PATCH] - make deleting work even when 'flashing' of selected object is in progress - fix object counter (which did often not go down to zero) --- Aircraft/ufo/ufo.nas | 54 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/Aircraft/ufo/ufo.nas b/Aircraft/ufo/ufo.nas index 86e61f985..46bcae815 100644 --- a/Aircraft/ufo/ufo.nas +++ b/Aircraft/ufo/ufo.nas @@ -480,6 +480,9 @@ Dynamic = { m.node.getNode("pitch-deg-prop", 1).setValue(adjust.outNode("pitch").getPath()); m.node.getNode("roll-deg-prop", 1).setValue(adjust.outNode("roll").getPath()); m.load(); + m.flash_count = 0; + m.visible = 1; + m.on_flash_exit_func = func {}; return m; }, del : func { @@ -489,11 +492,11 @@ Dynamic = { } }, make_static : func { - var static = Static.new(me.path, adjust.legendN.getValue(), + me.del(); + me.flash(0); + return Static.new(me.path, adjust.legendN.getValue(), adjust.get("lon"), adjust.get("lat"), adjust.get("elev"), adjust.get("hdg"), adjust.get("pitch"), adjust.get("roll")); - me.del(); - return static; }, distance_from : func(xyz) { var lon = adjust.get("lon"); @@ -501,6 +504,7 @@ Dynamic = { return coord_dist_sq(xyz, lonlat2xyz([lon, lat])); }, get_data : func { + me.flash(0); var n = props.Node.new(); n.getNode("path", 1).setValue(me.path); props.copy(props.globals.getNode("/data/adjust"), n); @@ -508,6 +512,28 @@ Dynamic = { me.add_derived_props(n); return n; }, + flash : func(v, fun = nil) { + me.flash_count = v; + if (fun != nil) { + me.on_flash_exit_func = fun; + } + me._flash_(); + }, + _flash_ : func { + if (!me.visible) { + adjust.set("elev", adjust.get("elev") + 10000); + me.visible = 1; + } elsif (me.flash_count) { + adjust.set("elev", adjust.get("elev") - 10000); + me.visible = 0; + } + if (me.flash_count) { + me.flash_count -= 1; + settimer(func { me._flash_() }, 0.3); + } else { + me.on_flash_exit_func(); + } + }, }; @@ -590,21 +616,10 @@ ModelMgr = { me.static = left; } } - if (me.dynamic == nil) { # last one removed - return; + if (me.dynamic != nil) { # last one removed + me.dynamic.flash(4); } - me.flash(); - }, - flash : func { - me.block = 1; - var t = 0.33; - me.display_status(me.dynamic.path, 1); - settimer(func { adjust.set("elev", adjust.get("elev") - 10000) }, t); - settimer(func { adjust.set("elev", adjust.get("elev") + 10000) }, t * 2); - settimer(func { adjust.set("elev", adjust.get("elev") - 10000) }, t * 3); - settimer(func { adjust.set("elev", adjust.get("elev") + 10000) }, t * 4); - settimer(func { me.block = 0 }, t * 4.5); - settimer(func { me.display_status(me.modelpath) }, 5); + me.display_status(me.modelpath); }, remove_selected : func { if (me.block) { @@ -620,9 +635,8 @@ ModelMgr = { me.modelpath = path; me.display_status(path); }, - display_status : func(p, m = 0) { - var count = me.dynamic != nil; - count += size(me.static); + display_status : func(p) { + var count = (me.dynamic == nil ? 0 : 1) + size(me.static); setprop("/sim/model/ufo/status", "(" ~ count ~ ") " ~ p); }, get_data : func {