From 160abde2a6657ff424c21d09e294006963b3db6b Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Tue, 30 Oct 2018 20:19:10 +0100 Subject: [PATCH] LOD dialogs rework. Big rework of the Adjust LOD ranges dialog to hopefully make it easier to understand, and harder to setup so that models aren't visible by accident. All range entry is now via sliders. The sliders are deltas from the previous value. There is now the option to specifically choose either low detail or high detail AI/MP models. *NOTE* that for models without a fallback index the low detail model will be the blue yellow glider. There is now clear indication of what happens for the Meters or Pixel modes. Added a defaults button that will restore a reasonable set of default values. The properties that were used have been renamed to ensure that sensible defaults will be picked, ideally we'd have a way to migrate things like this but I don't think we do, so this is a reasonable alternative. --- defaults.xml | 26 +- gui/dialogs/rendering.xml | 11 - gui/dialogs/static-lod.xml | 819 +++++++++++++++++++++++++++---------- 3 files changed, 627 insertions(+), 229 deletions(-) diff --git a/defaults.xml b/defaults.xml index d40f7d2f5..4f1f59aea 100644 --- a/defaults.xml +++ b/defaults.xml @@ -160,19 +160,22 @@ Started September 2000 by David Megginson, david@megginson.com --> 180.0 - 1500 - 9000 - 30000 - false - 3000 - 10000 - 50 + 1500 + 7500 + 21000 + false + 400 + 0 + 200 true true @@ -509,6 +512,7 @@ Started September 2000 by David Megginson, david@megginson.com Huds/default.xml Huds/NTPS.xml Huds/minimal.xml + Huds/developer.xml false diff --git a/gui/dialogs/rendering.xml b/gui/dialogs/rendering.xml index 3dd4ddd12..22beeb2ed 100644 --- a/gui/dialogs/rendering.xml +++ b/gui/dialogs/rendering.xml @@ -238,17 +238,6 @@ - - left - - mpmodels - /sim/multiplay/use-detailed-models - - dialog-apply - mpmodels - - - 1 diff --git a/gui/dialogs/static-lod.xml b/gui/dialogs/static-lod.xml index 27a9be3c7..9ff5963d8 100644 --- a/gui/dialogs/static-lod.xml +++ b/gui/dialogs/static-lod.xml @@ -1,204 +1,582 @@ - - - + + - - + if (getprop("/sim/rendering/static-lod/aimp-detailed") < 0) + setprop("/sim/gui/dialogs/static-lod/aimp-mp-mode", "High Detail only"); + else if (getprop("/sim/rendering/static-lod/aimp-detailed") == getprop("/sim/rendering/static-lod/aimp-bare")) + setprop("/sim/gui/dialogs/static-lod/aimp-mp-mode", "Low Detail only"); + else + setprop("/sim/gui/dialogs/static-lod/aimp-mp-mode", "Specify Ranges"); - static-lod - vbox + update_enabling = func{ + var mode = getprop("/sim/gui/dialogs/static-lod/aimp-mp-mode"); + if (mode == "Low Detail only") { + setprop("/sim/gui/dialogs/static-lod/aimp-mp-bare-enabled", 1); + setprop("/sim/gui/dialogs/static-lod/aimp-mp-detailed-enabled", 0); + } else if (mode == "High Detail only") { + setprop("/sim/gui/dialogs/static-lod/aimp-mp-bare-enabled", 0); + setprop("/sim/gui/dialogs/static-lod/aimp-mp-detailed-enabled", 0); + } else { + setprop("/sim/gui/dialogs/static-lod/aimp-mp-bare-enabled", 1); + setprop("/sim/gui/dialogs/static-lod/aimp-mp-detailed-enabled", 1); + } - - hbox - 1 +# if (!getprop("/sim/rendering/static-lod/aimp-bare") and !getprop("/sim/rendering/static-lod/aimp-detailed")) { +# setprop("/sim/rendering/static-lod/aimp-bare", 0); +# setprop("/sim/rendering/static-lod/aimp-detailed",100); +# } + return mode; + }; - - - + reload_sliders = func(reload) { + if (!reload) + return ; + var current_dialog = getprop("/sim/gui/dialogs/current-dialog"); + fgcommand("dialog-close", dlgLOD); + fgcommand("dialog-show", dlgLOD); + if (current_dialog != "") { + var show_node = props.Node.new({"dialog-name": current_dialog}); + fgcommand("dialog-show", show_node); + } + } + ; - 1 + update_scenery_text = func{ + var detailed = getprop("/sim/rendering/static-lod/detailed"); + var bare = getprop("/sim/rendering/static-lod/bare-delta"); + var rough = getprop("/sim/rendering/static-lod/rough-delta"); + setprop("/sim/rendering/static-lod/detailed-description", sprintf("from %5.0fm to %5.0fm",0, detailed)); + setprop("/sim/rendering/static-lod/rough-delta-description", sprintf("from %5.0fm to %5.0fm",detailed, rough+detailed)); + setprop("/sim/rendering/static-lod/bare-delta-description", sprintf("from %5.0fm to %5.0fm",rough+detailed,rough+bare+detailed)); + }; - - + update_description = func(mode){ - + var descD = ""; + var descB = ""; + var descW = ""; - - table - center + if (getprop("sim/rendering/static-lod/aimp-range-mode-distance")) { + if (mode == "Low Detail only") { + if (getprop("/sim/rendering/static-lod/aimp-bare")>0) { + descD = sprintf("visible when viewpoint within\n%.0f meters", getprop("/sim/rendering/static-lod/aimp-detailed")); + } else { + descB = "always visible"; + } + } else if (mode == "High Detail only") { + descW = "Always visible regardless of distance"; + } else { + descW = ""; + descD = sprintf("0 to %.0fm from viewpoint", getprop("/sim/rendering/static-lod/aimp-detailed")); + descB = sprintf("%.0fm to %.0fm", getprop("/sim/rendering/static-lod/aimp-detailed"), getprop("/sim/rendering/static-lod/aimp-detailed")+getprop("/sim/rendering/static-lod/aimp-bare")); + var lowDetailRange = getprop("/sim/rendering/static-lod/aimp-detailed") + getprop("/sim/rendering/static-lod/aimp-bare") ; + if (lowDetailRange < 1000) + descW = sprintf("WARNING: Low Detail too close, nothing drawn over %.0fm", lowDetailRange); - - 013 - - + } + } else { + if (mode == "Low Detail only") { + if (getprop("/sim/rendering/static-lod/aimp-bare")>0) { + descD = sprintf("visible when larger than\n%.0f pixels in size on screen", getprop("/sim/rendering/static-lod/aimp-detailed")); + descB = ""; + descW = sprintf("WARNING: When smaller than %.0f pixels nothing will be drawn", getprop("/sim/rendering/static-lod/aimp-bare")); + } else { + descW = ""; + descD = ""; + descB = "always visible"; + } + } else if (mode == "High Detail only") { + descW = "Always visible regardless of distance"; + } else { + descW = ""; + if (getprop("/sim/rendering/static-lod/aimp-bare")>0) + descW = sprintf("WARNING: Below %.0f pixels in size nothing will be drawn", getprop("/sim/rendering/static-lod/aimp-bare")); + descD = sprintf("above %.0f pixels in size", getprop("/sim/rendering/static-lod/aimp-detailed")); + descB = sprintf("above %.0f pixels in size", getprop("/sim/rendering/static-lod/aimp-bare")); + } + } + setprop("/sim/gui/dialogs/static-lod/aimp-detailed-description", descD); + setprop("/sim/gui/dialogs/static-lod/aimp-bare-description", descB); + setprop("/sim/gui/dialogs/static-lod/aimp-bare-description1", descW); - - 11 - - - - 12 - - - - 13 - - + }; + # returns non zero if the value was adjusted and it can be adjusted (can_reload) + adjustValue = func(id, nodeId, value, can_reload){ + var node = nodeId.getNode(id); + if (node != nil) { + var cv = node.getValue(); + if (cv != value) { + node.setValue(value); + if (can_reload) + reload_sliders(1); + } + } + return 0; # no need to reload. + } - - 20 - right - - + update_ai_mp = func(can_reload) { + var mode = update_enabling (); + var distance_mode = getprop("sim/rendering/static-lod/aimp-range-mode-distance"); + update_description(mode); + if (mode == "Low Detail only") { + setprop("/sim/rendering/static-lod/aimp-detailed",getprop("/sim/rendering/static-lod/aimp-bare")); + can_reload = adjustValue("max", ai_mp_bare, 2000, can_reload); + reload_sliders(can_reload); + } else if (mode == "High Detail only") { +# setprop("/sim/rendering/static-lod/aimp-bare", 0); +# setprop("/sim/rendering/static-lod/aimp-detailed",-1); + } else { + if (!distance_mode) { + if (getprop("/sim/rendering/static-lod/aimp-bare") > getprop("/sim/rendering/static-lod/aimp-detailed")){ + setprop("/sim/rendering/static-lod/aimp-bare", getprop("/sim/rendering/static-lod/aimp-detailed")-1 ) ; + } + can_reload = adjustValue("max", ai_mp_detailed, 2000, can_reload); + can_reload = adjustValue("max", ai_mp_bare, getprop("/sim/rendering/static-lod/aimp-detailed"), can_reload); + } else { + can_reload = adjustValue("max", ai_mp_detailed, 3000, can_reload); + can_reload = adjustValue("max", ai_mp_bare, 3000, can_reload); + } + } + } + update_aimp_mode = func{ + var new_mode = getprop("/sim/gui/dialogs/static-lod/aimp-mp-mode"); + if (new_mode != current_ai_mp_mode) { + + if (current_ai_mp_mode == "Specify Ranges") { + current_detailed = getprop("/sim/rendering/static-lod/aimp-detailed"); + current_bare =getprop("/sim/rendering/static-lod/aimp-bare"); + } + if (current_ai_mp_mode == "Low Detail only" or current_ai_mp_mode == "High Detail only") { + if (current_detailed != nil) + setprop("/sim/rendering/static-lod/aimp-detailed", current_detailed ); + if (current_bare != nil) + setprop("/sim/rendering/static-lod/aimp-bare",current_bare); + } + if (new_mode == "High Detail only") { + setprop("/sim/rendering/static-lod/aimp-detailed", -1); + setprop("/sim/rendering/static-lod/aimp-bare",0); + } else if (new_mode == "Low Detail only"){ + setprop("/sim/rendering/static-lod/aimp-detailed", 0); + setprop("/sim/rendering/static-lod/aimp-bare",0); + } + current_ai_mp_mode = new_mode; + } + update_description(update_enabling()); + } +# setlistener("/sim/gui/dialogs/static-lod/aimp-mp-mode", func(v){ +# },0 ,0); - - 21 - fill - /sim/rendering/static-lod/detailed - + update_scenery_text (); + update_ai_mp (0); - - 22 - fill - /sim/rendering/static-lod/rough - - - 23 - fill - /sim/rendering/static-lod/bare - + ]]> + + - - 30 - right - - + static-lod + vbox - - 31 - fill - /sim/rendering/static-lod/ai-detailed - + + hbox + + 1 + - - 32 - fill - /sim/rendering/static-lod/ai-bare - + + + - - 3 - 3 - left - pixel - sim/gui/dialogs/static-lod/mode/pixel - true - - - property-assign - sim/gui/dialogs/static-lod/mode/distance - 0 - - - property-assign - sim/gui/dialogs/static-lod/mode/pixel - 1 - - - property-assign - sim/rendering/static-lod/ai-range-mode-pixel - 1 - - + + 1 + - - 3 - 4 - left - distance - sim/gui/dialogs/static-lod/mode/distance - true - - - property-assign - sim/gui/dialogs/static-lod/mode/distance - 1 - - - property-assign - sim/gui/dialogs/static-lod/mode/pixel - 0 - - - property-assign - sim/rendering/static-lod/ai-range-mode-pixel - 0 - - + + - - 40 - right - - + - - 41 - fill - /sim/rendering/static-lod/ai-interior - + + table + center - - + + 0 + 1 + center + + - + + 1 + 0 + + + + 1 + 1 + 300 + 14 + scenery-detailed + /sim/rendering/static-lod/detailed + 1 + 0 + 5000 + + dialog-apply + scenery-detailed + + + nasal + + + - - hbox - 10 - true - - true - - true - - true - - + + + + dialog-close + + + + true + + + + true + + + + + true + + + + - - - -