... | ... |
@@ -191,6 +191,7 @@ var buttonsClass = { |
191 | 191 |
data.settings.units.pressure = 'inhg'; |
192 | 192 |
else |
193 | 193 |
data.settings.units.pressure = 'hpa'; |
194 |
+ zkv.getNode('save/pressure', 1).setValue(data.settings.units.pressure); |
|
194 | 195 |
me.device.display.updateBARO(); |
195 | 196 |
} |
196 | 197 |
}, |
... | ... |
@@ -211,6 +212,9 @@ var buttonsClass = { |
211 | 212 |
units.altitude.from_ft = FT2M; |
212 | 213 |
units.altitude.from_m = 1; |
213 | 214 |
} |
215 |
+ foreach (var from; keys(units.altitude)) |
|
216 |
+ zkv.getNode('save/altitude', 1).setDoubleValue(from, units.altitude[from]); |
|
217 |
+ |
|
214 | 218 |
} |
215 | 219 |
}, |
216 | 220 |
{text: 'Distance :', type: 'normal', scrollgroup: 2}, |
... | ... |
@@ -230,6 +234,8 @@ var buttonsClass = { |
230 | 234 |
units.distance.from_nm = NM2M / 1000; |
231 | 235 |
units.distance.from_m = 0.001; |
232 | 236 |
} |
237 |
+ foreach (var from; keys(units.distance)) |
|
238 |
+ zkv.getNode('save/distance', 1).setDoubleValue(from, units.distance[from]); |
|
233 | 239 |
} |
234 | 240 |
}, |
235 | 241 |
{text: 'Speed :', type: 'normal', scrollgroup: 3}, |
... | ... |
@@ -249,6 +255,8 @@ var buttonsClass = { |
249 | 255 |
units.speed.from_kt = KT2MPS * 3.6; |
250 | 256 |
units.speed.from_kmh = 1; |
251 | 257 |
} |
258 |
+ foreach (var from; keys(units.speed)) |
|
259 |
+ zkv.getNode('save/speed', 1).setDoubleValue(from, units.speed[from]); |
|
252 | 260 |
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide', 'Vne']) { |
253 | 261 |
var speed = alerts.getValue(v) * units.speed.from_kt; |
254 | 262 |
data[v] = speed != nil ? speed : 9999; |
... | ... |
@@ -272,6 +280,8 @@ var buttonsClass = { |
272 | 280 |
units.vspeed.from_fpm = FT2M; |
273 | 281 |
units.vspeed.from_mpm = 1; |
274 | 282 |
} |
283 |
+ foreach (var from; keys(units.vspeed)) |
|
284 |
+ zkv.getNode('save/vspeed', 1).setDoubleValue(from, units.vspeed[from]); |
|
275 | 285 |
} |
276 | 286 |
}, |
277 | 287 |
{text: 'Temperat. :', type: 'normal', scrollgroup: 5}, |
... | ... |
@@ -284,10 +294,14 @@ var buttonsClass = { |
284 | 294 |
if (u == '°C') { |
285 | 295 |
units.temperature.from_C = func (c) return c; |
286 | 296 |
units.temperature.from_F = func (f) return (f - 32) / 1.8; |
297 |
+ zkv.getNode('save/temperature', 1).setValue('from_C', 'units.temperature.from_C = func (c) return c;'); |
|
298 |
+ zkv.getNode('save/temperature', 1).setValue('from_F', 'units.temperature.from_F = func (f) return (f - 32) / 1.8;'); |
|
287 | 299 |
} |
288 | 300 |
else { |
289 | 301 |
units.temperature.from_C = func (c) return c * 1.8 + 32; |
290 | 302 |
units.temperature.from_F = func (f) return f; |
303 |
+ zkv.getNode('save/temperature', 1).setValue('from_C', 'units.temperature.from_C = func (c) return c * 1.8 + 32;'); |
|
304 |
+ zkv.getNode('save/temperature', 1).setValue('from_F', 'units.temperature.from_F = func (f) return f;'); |
|
291 | 305 |
} |
292 | 306 |
} |
293 | 307 |
}, |
... | ... |
@@ -305,7 +319,14 @@ var buttonsClass = { |
305 | 319 |
me.device.windows.draw( windowId, {autogeom: 1}, obj_infos, {lines: 3, columns: 2}); |
306 | 320 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
307 | 321 |
me.device.knobs.FmsInner = me.device.knobs.MenuSettings; |
308 |
- me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
322 |
+ me.device.buttons.ENT = func (a = 0) { |
|
323 |
+ if (a) return; |
|
324 |
+ me.device.buttons.ValidateTMRREF(); |
|
325 |
+ var settings_file = getprop('/sim/fg-home') ~'/aircraft-data/zkv1000.xml'; |
|
326 |
+ if (io.stat(settings_file) != nil) |
|
327 |
+ fgcommand('loadxml', props.Node.new({ filename: settings_file, targetnode: zkv.getNode('_save', 1).getPath() })); |
|
328 |
+ props.copy(zkv.getNode('save'), zkv.getNode('_save/' ~ getprop('/sim/aircraft'), 1), 1); |
|
329 |
+ } |
|
309 | 330 |
me.device.buttons.CLR = func { |
310 | 331 |
me.device.windows.del(windowId); |
311 | 332 |
me.device.knobs.FmsOuter = func; |
... | ... |
@@ -313,6 +334,12 @@ var buttonsClass = { |
313 | 334 |
foreach (var b; ['ENT', 'CLR']) |
314 | 335 |
me.device.buttons[b] = func; |
315 | 336 |
me.device.buttons.MENU = me.device.buttons.GlobalParams; |
337 |
+ if (zkv.getNode('save') != nil) { |
|
338 |
+ fgcommand('savexml', props.Node.new({ filename: getprop('/sim/fg-home') ~'/aircraft-data/zkv1000.xml', |
|
339 |
+ sourcenode: zkv.getNode('_save').getPath() })); |
|
340 |
+ zkv.getNode('_save').remove(); |
|
341 |
+ zkv.getNode('save').remove(); |
|
342 |
+ } |
|
316 | 343 |
} |
317 | 344 |
me.device.buttons.MENU = me.device.buttons.CLR; |
318 | 345 |
}, |
... | ... |
@@ -246,9 +246,36 @@ var load_multikey = func { |
246 | 246 |
multikey.init(); |
247 | 247 |
} |
248 | 248 |
|
249 |
+var load_settings = func { |
|
250 |
+ var settings_file = getprop('/sim/fg-home') ~ '/aircraft-data/zkv1000.xml'; |
|
251 |
+ if (io.stat(settings_file) != nil) { |
|
252 |
+ fgcommand('loadxml', props.Node.new({ filename: settings_file, targetnode: zkv.getNode('save', 1).getPath() })); |
|
253 |
+ var xmlsettings = zkv.getNode('save/' ~ getprop('/sim/aircraft')); |
|
254 |
+ if (xmlsettings != nil) { |
|
255 |
+ foreach (var domain; keys(units)) |
|
256 |
+ foreach (var from; keys(units[domain])) { |
|
257 |
+ if (xmlsettings.getNode(domain) != nil) { |
|
258 |
+ var unit_value = xmlsettings.getNode(domain).getValue(from); |
|
259 |
+ if (unit_value != nil) { |
|
260 |
+ if (typeof(units[domain][from]) == 'scalar') |
|
261 |
+ units[domain][from] = unit_value; |
|
262 |
+ if (typeof(units[domain][from]) == 'func') { |
|
263 |
+ units[domain][from] = compile(unit_value); |
|
264 |
+ units[domain][from](0); |
|
265 |
+ } |
|
266 |
+ } |
|
267 |
+ } |
|
268 |
+ } |
|
269 |
+ data.settings.units.pressure = xmlsettings.getNode('pressure').getValue(); |
|
270 |
+ } |
|
271 |
+ zkv.getNode('save').remove(); |
|
272 |
+ } |
|
273 |
+} |
|
274 |
+ |
|
249 | 275 |
var zkv1000_init = func { |
250 | 276 |
removelistener(init); |
251 | 277 |
init_props(); |
278 |
+ load_settings(); |
|
252 | 279 |
load_multikey(); |
253 | 280 |
load_nasal(); |
254 | 281 |
msg('loaded'); |