<?xml version="1.0"?>

<PropertyList>
	<name>devel-extensions</name>
	<modal>false</modal>
	<layout>vbox</layout>
  <nasal>
    <open>
      <![CDATA[
          var osg_debug = [
            [0, "- Off"],
            [1, "- Show Frame Rate"],
            [2, "+ Viewer Graph"],
            [3, "+ Camera"],
            [4, "+ Viewer Scene"],
          ];
          var osg_stats = cmdarg().getChildren("group")[1].getChildren("combo")[0];
          var i = 0;
          
          foreach (var s; osg_debug) {
                    var nm = s[0] ~ " " ~ s[1];
#print("setting node to ",nm);
                    osg_stats.getNode("value[" ~ i ~ "]", 1).setValue(nm);
                    if (i == getprop("/sim/rendering/on-screen-statistics"))
                      setprop("/sim/gui/dialogs/devel-extensions/on-screen-statistics",nm);
                    i += 1;
                }
  
                var updateOSG_stats = func(n) {
                  var sel_mode = n.getValue();
                  if( sel_mode == nil ) return;
                  print("\nupdate OSG debug ",sel_mode);
  
                  foreach (var s; osg_debug)
                  {
                    if(s[0] == sel_mode)
                    {
                    print(" >> ",s[1]);
                    setprop("/sim/gui/dialogs/devel-extensions/on-screen-statistics", s[0] ~ " " ~ s[1]);
                    gui.dialog_update("devel-extensions", "OSGdebug");
                      break;
                    }
                  }
#  print("OSG Debug ",getprop("/sim/gui/dialogs/devel-extensions/on-screen-statistics"));
                };
            
            # listen for results arriving
            setlistener("/sim/rendering/on-screen-statistics", updateOSG_stats);
            ]]>
    </open>

    <close>
    </close>
  </nasal>
  
  <!--new debug dialog

    multiplayer debug checkboxes
    loopback
    log outgoing properties 2
    dump & 4
    trace incoming properties.

    log level / systems.

    osg debug (0,1,2,3,4)

    reload shaders.-->
    <text>
		<label>Configure Development Extensions</label>
	</text>

	<hrule/>

	<group>
		<layout>vbox</layout>
		<halign>left</halign>

		<checkbox>
			<halign>left</halign>
			<label>Enable development dialog widgets (HUD and rendering dialog)</label>
			<property>/sim/gui/devel-widgets</property>
			<binding>
				<command>dialog-apply</command>
			</binding>
		</checkbox>

		<checkbox>
			<halign>left</halign>
			<label>Enable '/'-key property handler (see $FG_ROOT/Nasal/prop_key_handler.nas)</label>
			<property>/sim/input/property-key-handler</property>
			<binding>
				<command>dialog-apply</command>
			</binding>
		</checkbox>
	</group>
    <group>
        <layout>vbox</layout>

        <!--muultiplayer debug checkboxes
        loopback
        log outgoing properties 2
        dump & 4
        trace incoming properties.-->
        <halign>center</halign>
        <checkbox>
            <halign>left</halign>
            <label>Local loopback of model</label>
            <property>/sim/gui/debug/multiplayer-loopback</property>
            <binding>
                <command>dialog-apply</command>
            </binding>
            <binding>
                <command>nasal</command>
                <script>
            <![CDATA[
                    setprop("/sim/multiplay/debug-level", (getprop("/sim/multiplay/debug-level") or 0) ^ 1);
                    setprop("/sim/gui/debug/multiplayer-loopback", getprop("/sim/multiplay/debug-level") & 1);
            ]]>
                </script>
            </binding>
        </checkbox>

       <combo>
        <row>5</row>
        <col>1</col>
        <pref-width>300</pref-width>
        <halign>left</halign>
        <name>OSGdebug</name>
         <label>OSG statistics</label>
         <property>/sim/gui/dialogs/devel-extensions/on-screen-statistics</property>
        <editable>false</editable>
        <binding>
          <command>dialog-apply</command>
        </binding>
        <binding>
          <command>nasal</command>
          <script>
            <![CDATA[
            print("OSG Debug ",getprop("/sim/gui/dialogs/devel-extensions/on-screen-statistics"));
              var selval = substr(getprop("/sim/gui/dialogs/devel-extensions/on-screen-statistics"),0,1);
              print("Set osg debug ",selval);
              setprop("/sim/rendering/on-screen-statistics", selval);
            ]]>
          </script>
        </binding>
      </combo>
    </group>
  <group>
    <layout>hbox</layout>
    <halign>center</halign>
    <button>
		<legend>New Canvas Map</legend>
		<binding>
			<command>nasal</command>
			<script>canvas.MapStructure_selfTest();</script>
		</binding>
    </button>
  </group>
  <group>
    <layout>hbox</layout>
    <halign>left</halign>
    <button>
      <legend>Reload GUI</legend>
      <name>reload-gui</name>
      <binding>
        <command>reinit</command>
        <subsystem>gui</subsystem>
      </binding>
    </button>
    <button>
      <name>reload-input</name>
      <legend>Reload Input</legend>
      <binding>
        <command>reinit</command>
        <subsystem>input</subsystem>
      </binding>
    </button>

    <button>
      <name>reload-hud</name>
      <legend>Reload Hud</legend>
      <binding>
        <command>reinit</command>
        <subsystem>hud</subsystem>
      </binding>
    </button>

    <button>
      <name>reload-panel</name>
      <legend>Reload Panel</legend>
      <binding>
        <command>panel-load</command>
      </binding>
    </button>
  </group>
  <group>
    <layout>hbox</layout>
    <halign>let</halign>
    <button>
      <name>reload-autopilot</name>
      <legend>Reload Autopilot</legend>
      <binding>
        <command>reinit</command>
        <subsystem>xml-autopilot</subsystem>
      </binding>
    </button>

    <button>
      <name>reload-network</name>
      <legend>Reload Network</legend>
      <binding>
        <command>reinit</command>
        <subsystem>io</subsystem>
      </binding>
    </button>

    <button>
      <name>reload-model</name>
      <legend>Reload Aircraft Model</legend>
      <binding>
        <command>reinit</command>
        <subsystem>aircraft-model</subsystem>
      </binding>
    </button>
    
  </group>
  <group>
    <layout>hbox</layout>
    <halign>left</halign>
    <button>
      <name>reload-shaders</name>
      <legend>Reload Shaders</legend>
      <binding>
        <command>reload-shaders</command>
      </binding>
    </button>
    <button>
      <name>reload-materials</name>
      <legend>Reload Materials</legend>
      <binding>
        <command>reload-materials</command>
      </binding>
    </button>

    <button>
      <width>20</width>
      <name>reload-scenery</name>
      <legend>Reload Scenery</legend>
      <binding>
        <command>reinit</command>
        <subsystem>scenery</subsystem>
      </binding>
    </button>

  </group>
  <button>
		<legend>Close</legend>
		<default>true</default>
		<key>Esc</key>
		<binding>
			<command>dialog-apply</command>
		</binding>
		<binding>
			<command>dialog-close</command>
		</binding>
	</button>
</PropertyList>