- remove "load flight"/"save flight" dialogs, and
- use a file selector instead - file-select.xml: handle non-existing files correctly
This commit is contained in:
parent
fc6748ab95
commit
abdc416f32
5 changed files with 29 additions and 93 deletions
|
@ -336,6 +336,30 @@ var FileSelector = {
|
|||
};
|
||||
|
||||
|
||||
##
|
||||
# Save/load flight menu functions.
|
||||
#
|
||||
var save_flight_sel = nil;
|
||||
var save_flight = func {
|
||||
var save = func(n) fgcommand("save", props.Node.new({ file: n.getValue() }));
|
||||
if (save_flight_sel == nil)
|
||||
save_flight_sel = FileSelector.new(save, "Save Flight", "Save",
|
||||
["*.sav"], getprop("/sim/fg-home"), "flight.sav");
|
||||
save_flight_sel.open();
|
||||
}
|
||||
|
||||
|
||||
var load_flight_sel = nil;
|
||||
var load_flight = func {
|
||||
var load = func fgcommand("load", props.Node.new({ file: cmdarg().getValue() }));
|
||||
if (load_flight_sel == nil)
|
||||
load_flight_sel = FileSelector.new(load, "Load Flight", "Load",
|
||||
["*.sav"], getprop("/sim/fg-home"), "flight.sav");
|
||||
load_flight_sel.open();
|
||||
}
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Open property browser with given target path.
|
||||
#
|
||||
|
|
|
@ -236,9 +236,7 @@
|
|||
file_input();
|
||||
var p = string.fixpath(current.dir ~ "/" ~ current.file);
|
||||
var stat = io.stat(p);
|
||||
if (stat == nil)
|
||||
return;
|
||||
path.setValue(io.isdir(stat[2]) ? p ~ "/" : p);
|
||||
path.setValue(stat != nil and io.isdir(stat[2]) ? p ~ "/" : p);
|
||||
file.setValue(current.file);
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
<name>load_flight</name>
|
||||
<layout>vbox</layout>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
|
||||
<text><label>File Name:</label></text>
|
||||
<input>
|
||||
<halign>fill</halign>
|
||||
<stretch>true</stretch>
|
||||
<property>/tmp/flight/file</property>
|
||||
</input>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
<button>
|
||||
<legend>Load</legend>
|
||||
<equal>true</equal>
|
||||
<default>true</default>
|
||||
<binding><command>dialog-apply</command></binding>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
fgcommand("load", props.globals.getNode("/tmp/flight") );
|
||||
</script>
|
||||
</binding>
|
||||
<binding><command>dialog-close</command></binding>
|
||||
</button>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
<button>
|
||||
<legend>Cancel</legend>
|
||||
<equal>true</equal>
|
||||
<key>Esc</key>
|
||||
<binding><command>dialog-close</command></binding>
|
||||
</button>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
</group>
|
||||
</PropertyList>
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
<name>save_flight</name>
|
||||
<layout>vbox</layout>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
|
||||
<text><label>File Name:</label></text>
|
||||
<input>
|
||||
<halign>fill</halign>
|
||||
<stretch>true</stretch>
|
||||
<property>/tmp/flight/file</property>
|
||||
</input>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
<button>
|
||||
<legend>Save</legend>
|
||||
<equal>true</equal>
|
||||
<default>true</default>
|
||||
<binding><command>dialog-apply</command></binding>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
fgcommand("save", props.globals.getNode("/tmp/flight") );
|
||||
</script>
|
||||
</binding>
|
||||
<binding><command>dialog-close</command></binding>
|
||||
</button>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
<button>
|
||||
<legend>Cancel</legend>
|
||||
<equal>true</equal>
|
||||
<key>Esc</key>
|
||||
<binding><command>dialog-close</command></binding>
|
||||
</button>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
</group>
|
||||
</PropertyList>
|
|
@ -6,16 +6,16 @@
|
|||
<item>
|
||||
<label>Save</label>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>save_flight</dialog-name>
|
||||
<command>nasal</command>
|
||||
<script>gui.save_flight()</script>
|
||||
</binding>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<label>Load</label>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>load_flight</dialog-name>
|
||||
<command>nasal</command>
|
||||
<script>gui.load_flight()</script>
|
||||
</binding>
|
||||
</item>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue