From 3e268e394c6c55e0baad341370d5d829d55d004a Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 24 Aug 2006 22:29:16 +0000 Subject: [PATCH] [Yes, Andy's writing code again. The world is ending.] An IRC discussion about shavlir's (really nice) harrier model showed that it had its own version of something like the Fuel & Weight dialog, developed because the existing subsystem only supported sliders and not "combo box" style selection for specific external stores. That seemed sub-optimal, so I spent a few hours extending the F&W dialog to do this and forward-ported the harrier to use it. Check the harrier-set.xml file for an example. Basically, the weight dialog reads a list of options for each weight listed under /sim/weight[n] and manages a "selected" proprty telling us which one is in use. The FDM code can then read out the weight-lb property as before, and the model animations can use the selected option to predicate drawing the appropriate 3D content. It seems to work pretty well. --- Nasal/gui.nas | 80 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/Nasal/gui.nas b/Nasal/gui.nas index 3151dbaad..0508fa4fa 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -421,6 +421,22 @@ showTutorialDialog = func { showDialog(name); } +# Checks the /sim/weight[n]/{selected|opt} values and sets the +# appropriate weights therefrom. Called from the F&W dialog. +var setWeightOpts = func { + foreach(w; props.globals.getNode("sim").getChildren("weight")) { + var selected = w.getNode("selected"); + if(selected != nil) { + foreach(opt; w.getChildren("opt")) { + if(opt.getNode("name", 1).getValue() == selected.getValue()) { + var lbs = opt.getNode("lbs", 1).getValue(); + w.getNode("weight-lb", 1).setValue(lbs); + break; + } + } + } + } +} ## # Dynamically generates a weight & fuel configuration dialog specific to @@ -482,10 +498,10 @@ showWeightDialog = func { ok.setBinding("dialog-close"); # Temporary helper function - tcell = func { - cell = arg[0].addChild(arg[1]); - cell.set("row", arg[2]); - cell.set("col", arg[3]); + tcell = func(parent, type, row, col) { + cell = parent.addChild(type); + cell.set("row", row); + cell.set("col", col); return cell; } @@ -561,23 +577,58 @@ showWeightDialog = func { wgts = props.globals.getNode("/sim").getChildren("weight"); for(i=0; i