how to add a menu entry to the menubar from a scenario (this entry would bring up the dialog)
I think what your looking for is the hook to whether or not the AI scenario is active.
That would be a listener looking for
/sim/ai/scenario="your scenario"
Sorry I don't know off hand the exact listener coding.
http://wiki.flightgear.org/Using_listeners_and_signals_with_NasalThere is an example in bomable.nas (
bomable add-on) as to how to create a dynamic (procedural) menu.
Below is what I adapted from bomable.nas. But this only adds the items to the existing FG menu. You could then have one of those items call your standalone dialog. Or it can all be created procedurally (again see bombable.nas)
- Code: Select all
var init_towCargo_dialog = func () {
#Set cargo_menuNum to -1 at initialization time.
#On reinit & some other times, this routine will be called again.
#So if cargo_menuNum != -1 we know not to seek out another new menu number
#Without this check, we'd get a new Cargo menu added each time FG reinits or re-positions.
if (cargo_menuNum==nil or cargo_menuNum==-1) {
#find the next open menu number
cargo_menuNum=97; #the default
for (var i=0;i<300;i+=1) {
p=props.globals.getNode("/sim/menubar/default/menu["~i~"]");
if ( typeof(p) == "nil" ) {
cargo_menuNum=i;
break;
}
}
}
#create GUI menubar items
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/enabled", 1).setBoolValue(1);
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/label", 1).setValue("CargoTow");
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/item/enabled", 1).setBoolValue(1);
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/item/label", 1).setValue("RealTime " ~ props.globals.getNode( "controls/cargo-realtime").getBoolValue());
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/item/binding/command", 1).setValue("nasal");
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/item/binding/script", 1).setValue(
'props.globals.getNode("controls/cargo-realtime" ).setBoolValue(!props.globals.getNode("controls/cargo-realtime" ).getBoolValue());
props.globals.getNode ("/sim/menubar/default/menu['~cargo_menuNum~']/item/label", 1).setValue("RealTime " ~ props.globals.getNode( "controls/cargo-realtime").getBoolValue());
fgcommand ("gui-redraw");'
);
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/item[1]/label", 1).setValue("Hook Assist");
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/item[1]/binding/command", 1).setValue("nasal");
props.globals.getNode ("/sim/menubar/default/menu["~cargo_menuNum~"]/item[1]/binding/script", 1).setValue('props.globals.getNode("controls/hook-assist").setBoolValue(!props.globals.getNode("controls/hook-assist").getBoolValue())');
fgcommand ("gui-redraw");
}
I have no experience or opinion on what is the best way to proceed.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q