1
0
Fork 0

mouse walk -> operation mode: with Ctrl modifier down, don't move the

ufo position, but the selected objects: ctrl-mmb left/right/up/down move
the objects left/right/away/nearer, and ctrl-mmb-lmb l/r/u/d rotate them
all around the active object ('m'-key marker!) or raise/lower them.

(the gear-key 'g' can for now be used as a Ctrl replacement for people
with 2 button mouse; will probably be moved to a better place ...)
This commit is contained in:
mfranz 2008-05-08 20:11:39 +00:00
parent 59d9f53e57
commit e5b1c408dc

View file

@ -62,8 +62,8 @@ setlistener("/sim/signals/screenshot", func(n) {
var lastelev = nil; var lastelev = nil;
var mouse = { savex: nil, savey: nil }; var mouse = { savex: nil, savey: nil };
setlistener("/sim/startup/xsize", func(n) mouse.centerx = n.getValue() / 2, 1); setlistener("/sim/startup/xsize", func(n) mouse.centerx = int(n.getValue() / 2), 1);
setlistener("/sim/startup/ysize", func(n) mouse.centery = n.getValue() / 2, 1); setlistener("/sim/startup/ysize", func(n) mouse.centery = int(n.getValue() / 2), 1);
setlistener("/sim/mouse/hide-cursor", func(n) mouse.hide = n.getValue(), 1); setlistener("/sim/mouse/hide-cursor", func(n) mouse.hide = n.getValue(), 1);
setlistener("/devices/status/mice/mouse/x", func(n) mouse.x = n.getValue(), 1); setlistener("/devices/status/mice/mouse/x", func(n) mouse.x = n.getValue(), 1);
setlistener("/devices/status/mice/mouse/y", func(n) mouse.y = n.getValue(), 1); setlistener("/devices/status/mice/mouse/y", func(n) mouse.y = n.getValue(), 1);
@ -88,22 +88,42 @@ setlistener("/devices/status/mice/mouse/button[1]", func(n) {
mouse.loop = func { mouse.loop = func {
if (!mouse.mode and mouse.mmb) { if (mouse.mode or !mouse.mmb)
return settimer(mouse.loop, 0);
var dx = mouse.x - mouse.centerx; var dx = mouse.x - mouse.centerx;
var dy = mouse.y - mouse.centery; var dy = mouse.y - mouse.centery;
if (!dx and !dy)
return settimer(mouse.loop, 0);
if (dx or dy) { var speed = KbdShift.getValue() ? 1 : 0.1;
var hdg = getprop("/orientation/heading-deg"); var progress = 1.7;
var powx = npow(dx, progress) * speed;
var powy = -npow(dy, progress) * speed;
if (KbdCtrl.getValue()) { # operation
if (dx) {
if (mouse.lmb or gear_key_down)
modelmgr.adjust("bearing", dx * 0.2);
else
modelmgr.adjust("transversal", powx);
}
if (dy) {
if (mouse.lmb or gear_key_down)
modelmgr.adjust("altitude", powy);
else
modelmgr.adjust("longitudinal", powy);
}
} else { # navigation
var pos = geo.aircraft_position(); var pos = geo.aircraft_position();
var ctrl = KbdCtrl.getValue(); var hdg = getprop("/orientation/heading-deg");
var elev = getprop("/position/ground-elev-ft"); var elev = getprop("/position/ground-elev-ft");
var dalt = elev - lastelev; var dalt = elev - lastelev;
lastelev = elev; lastelev = elev;
var speed = KbdShift.getValue() ? 1 : 0.1;
var progress = 1.7;
if (dx) { if (dx) {
var powx = npow(dx, progress) * speed;
if (mouse.lmb or gear_key_down) if (mouse.lmb or gear_key_down)
pos.apply_course_distance(hdg + 90, powx); pos.apply_course_distance(hdg + 90, powx);
else else
@ -111,19 +131,17 @@ mouse.loop = func {
} }
if (dy) { if (dy) {
var powy = npow(dy, progress) * speed;
if (mouse.lmb or gear_key_down) if (mouse.lmb or gear_key_down)
dalt -= powy; dalt += powy;
else else
pos.apply_course_distance(hdg + 180, powy); pos.apply_course_distance(hdg, powy);
} }
setprop("/position/latitude-deg", pos.lat()); setprop("/position/latitude-deg", pos.lat());
setprop("/position/longitude-deg", pos.lon()); setprop("/position/longitude-deg", pos.lon());
setprop("/position/altitude-ft", getprop("/position/altitude-ft") + dalt); setprop("/position/altitude-ft", getprop("/position/altitude-ft") + dalt);
}
gui.setCursor(mouse.centerx, mouse.centery); gui.setCursor(mouse.centerx, mouse.centery);
}
}
settimer(mouse.loop, 0); settimer(mouse.loop, 0);
} }
@ -405,6 +423,8 @@ var ModelMgr = {
m.marker = Model.new("Aircraft/ufo/Models/marker.ac", geo.Coord.new().set_xyz(0, 0, 0)); m.marker = Model.new("Aircraft/ufo/Models/marker.ac", geo.Coord.new().set_xyz(0, 0, 0));
m.marker.hide(); m.marker.hide();
m.modelpath = path; m.modelpath = path;
if (m.active != nil)
m.marker.move(m.active.pos);
if (path != "Aircraft/ufo/Models/cursor.ac") if (path != "Aircraft/ufo/Models/cursor.ac")
status_dialog.open(); status_dialog.open();
@ -450,7 +470,7 @@ var ModelMgr = {
select : func() { select : func() {
if (!size(me.models)) { if (!size(me.models)) {
me.active = nil; me.active = nil;
me.marker.move(geo.Coord.new().set_xyz(0, 0, 0)); me.marker.hide();
return; return;
} }
var min_dist = 10 * ERAD; var min_dist = 10 * ERAD;
@ -585,6 +605,7 @@ var ModelMgr = {
tmp.getNode("longitude-deg").getValue(), tmp.getNode("longitude-deg").getValue(),
tmp.getNode("elevation-ft").getValue() * FT2M); tmp.getNode("elevation-ft").getValue() * FT2M);
append(me.models, me.active = Model.new(tmp.getNode("path").getValue(), c, tmp)); append(me.models, me.active = Model.new(tmp.getNode("path").getValue(), c, tmp));
#me.marker.move(me.active.pos);
} }
} }
}, },
@ -620,6 +641,15 @@ var ModelMgr = {
foreach (var m; me.models) foreach (var m; me.models)
m.selected and m.roll.set(m.roll.get() + value * 6); m.selected and m.roll.set(m.roll.get() + value * 6);
} elsif (name == "bearing") {
foreach (var m; me.models)
if (m.selected) {
var course = me.active.pos.course_to(m.pos);
var dist = me.active.pos.distance_to(m.pos);
m.apply_course_distance(course, -dist);
m.apply_course_distance(course + value * 4, dist);
m.hdg.set(m.hdg.get() + value * 4);
}
} }
me.marker.move(me.active.pos); me.marker.move(me.active.pos);
}, },