Improved dialog nasal file attached. Just drop it into $FG_ROOT/Nasal/ again.
It does monitor the property /sim/rendering/blackout and turns the screen
black accordingly. And it offers three commands for Nasal context:

  black.open();
  black.close();
  black.toggle();

m.
dialog = nil;
state = 0;
switch = props.globals.getNode("/sim/rendering/blackout", 1);
switch.setBoolValue(state);

open = func {
        name = "blackout";
        dialog = gui.Widget.new();
        dialog.set("name", name);
        dialog.set("width", props.globals.getNode("/sim/startup/xsize"));
        dialog.set("height", props.globals.getNode("/sim/startup/ysize"));

        color = dialog.prop().getNode("color", 1);
        color.getNode("red", 1).setValue(0);
        color.getNode("green", 1).setValue(0);
        color.getNode("blue", 1).setValue(0);
        color.getNode("alpha", 1).setValue(1);

        fgcommand("dialog-new", dialog.prop());
        gui.showDialog(name);
        switch.setBoolValue(state = 1);
}

close = func {
        if (dialog != nil) {
                fgcommand("dialog-close", props.Node.new({ "dialog-name" : 
"blackout" }));
                dialog = nil;
                switch.setBoolValue(state = 0);
        }
}

toggle = func { if (dialog == nil) { open() } else { close() } }

loop = func {
        s = switch.getValue();
        if (s and !state) {
                open();
        } elsif (!s and state) {
                close();
        }
        settimer(loop, 0.2);
}

settimer(loop, 0);

_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to