From f1adeec7cc27926a03a64e5c78ee850c8bb9acc0 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Sun, 29 Jul 2012 22:44:14 +0100 Subject: [PATCH] Enhancements to the Fuel and Payload dialog - Fraction of each tank capacity displayed, along with pounds and gallons - Total fuel is now displayed - CofG displayed if available even if /limits/ not defined (bug fix) - Tanks of capacity 0 ignored (bug fix) - Some layout improvements. Addresses issue #778 --- Nasal/gui.nas | 119 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 35 deletions(-) diff --git a/Nasal/gui.nas b/Nasal/gui.nas index af885646e..a7ad1d040 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -856,47 +856,55 @@ var showWeightDialog = func { var contentArea = dialog[name].addChild("group"); contentArea.set("layout", "hbox"); + contentArea.set("default-padding", 10); + + dialog[name].addChild("empty"); + + var limits = dialog[name].addChild("group"); + limits.set("layout", "table"); + limits.set("halign", "center"); + var row = 0; + + var massLimits = props.globals.getNode("/limits/mass-and-balance"); + + var tablerow = func(name, node, format ) { + + var n = isa( node, props.Node ) ? node : massLimits.getNode( node ); + if( n == nil ) return; + + var label = limits.addChild("text"); + label.set("row", row); + label.set("col", 0); + label.set("halign", "right"); + label.set("label", name ~ ":"); + + var val = limits.addChild("text"); + val.set("row", row); + val.set("col", 1); + val.set("halign", "left"); + val.set("label", "0123457890123456789"); + val.set("format", format); + val.set("property", n.getPath()); + val.set("live", 1); + + row += 1; + } var grossWgt = props.globals.getNode(fdmdata.grosswgt); if(grossWgt != nil) { - var gwg = dialog[name].addChild("group"); - gwg.set("layout", "hbox"); - gwg.addChild("empty").set("stretch", 1); - gwg.addChild("text").set("label", "Gross Weight:"); - var txt = gwg.addChild("text"); - txt.set("label", "0123456789"); - txt.set("format", "%.0f lb"); - txt.set("property", fdmdata.grosswgt); - txt.set("live", 1); - gwg.addChild("empty").set("stretch", 1); + tablerow("Gross Weight", grossWgt, "%.0f lb"); } - var massLimits = props.globals.getNode("/limits/mass-and-balance"); if(massLimits != nil ) { + tablerow("Max. Ramp Weight", "maximum-ramp-mass-lbs", "%.0f lb" ); + tablerow("Max. Takeoff Weight", "maximum-takeoff-mass-lbs", "%.0f lb" ); + tablerow("Max. Landing Weight", "maximum-landing-mass-lbs", "%.0f lb" ); + tablerow("Max. Zero Fuel Weight", "maximum-zero-fuel-mass-lbs", "%.0f lb" ); + } - var weightitem = func( group, name, node, format ) { - group.set("layout", "hbox"); - var n = isa( node, props.Node ) ? node : massLimits.getNode( node ); - if( n == nil ) return; - group.addChild("empty").set("stretch", 1); - group.addChild("text").set("label", name ~ ":" ); - var txt = group.addChild("text"); - txt.set("label", ""); - txt.set("format", format ); - txt.set("property", n.getPath() ); - txt.set("live", 1); - group.addChild("empty").set("stretch", 1); - } - weightitem( dialog[name].addChild("group"), "Max. Ramp Weight", "maximum-ramp-mass-lbs", "%.0f lb" ); - weightitem( dialog[name].addChild("group"), "Max. Takeoff Weight", "maximum-takeoff-mass-lbs", "%.0f lb" ); - weightitem( dialog[name].addChild("group"), "Max. Landing Weight", "maximum-landing-mass-lbs", "%.0f lb" ); - weightitem( dialog[name].addChild("group"), "Max. Zero Fuel Weight", "maximum-zero-fuel-mass-lbs", "%.0f lb" ); - - if( fdmdata.cg != nil ) { - var n = massLimits.getNode("cg/dimension"); - weightitem( dialog[name].addChild("group"), "CG", fdmdata.cg, "%.1f " ~ (n == nil ? "in" : n.getValue())); - } - weightitem = nil; + if( fdmdata.cg != nil ) { + var n = props.globals.getNode("/limits/mass-and-balance/cg/dimension"); + tablerow("Center of Gravity", fdmdata.cg, "%.1f " ~ (n == nil ? "in" : n.getValue())); } dialog[name].addChild("hrule"); @@ -934,6 +942,7 @@ var showWeightDialog = func { tcell(fuelTable, "text", 0, 0).set("label", "Tank"); tcell(fuelTable, "text", 0, 3).set("label", "Pounds"); tcell(fuelTable, "text", 0, 4).set("label", "Gallons"); + tcell(fuelTable, "text", 0, 5).set("label", "Fraction"); var tanks = props.globals.getNode("/consumables/fuel").getChildren("tank"); for(var i=0; i