<?xml version="1.0"?>

<?FlightGear-tr context="dialog-view"?>
<?FlightGear-tr id="other-views-heading-label" text="Other Views"?>
<?FlightGear-tr id="aircraft-specific-views-heading-label"
                text='"%s" Specific Views'
                comment="%s = name of the selected aircraft"?>
<?FlightGear-tr id="unnamed-view-number-n" text="unnamed view %d"
                comment="%d = view number"?>

<PropertyList>
  <name>view</name>
  <ui-version>2</ui-version>
  <title translate="y">
    view-options-title
    <?FlightGear-tr text="View Options" comment="This is the dialog title."?>
  </title>

  <nasal>
    <open>
      var tr = FGTranslate.new().getResource("dialog-view");

      var group = gui.findElementByName(cmdarg(), "active-views");
      var ac = getprop("/sim/aircraft");
      group.removeChildren("checkbox");
      group.removeChildren("hrule");
      group.removeChildren("text");

      var t = group.getChild("text", 0, 1);
      # Translatable string 'standard-views-heading-label' is defined in the
      # dialog XML config below.
      t.getNode("label", 1).setValue(tr.get("standard-views-heading-label"));
      t.getNode("halign", 1).setValue("left");


      var mode = 0;
      foreach (var v; view.views) {
        var index = v.getIndex();
        var enabled = v.initNode("enabled", 1, "BOOL");
        var name = v.getNode("name");
        if (name != nil) {
          if (index >= 200) {
            if (mode != 2) {
              mode = 2;
              group.getChild("empty", 1, 1).getChild("stretch", 0, 1).setValue(1);
              var t = group.getChild("text", 1, 1);
              t.getNode("label", 1).setValue(
                tr.get("other-views-heading-label"));
            }

          } elsif (index >= 100) {
            aircraft.data.add(enabled);
            if (mode != 1) {
              mode = 1;
              group.getChild("empty", 0, 1).getChild("stretch", 0, 1).setValue(1);
              var t = group.getChild("text", 1, 1);
              t.getNode("label", 1).setValue(
                sprintf(tr.get("aircraft-specific-views-heading-label"), ac));
              t.getNode("halign", 1).setValue("left");
            }
          }

          var target = group.getChild("checkbox", index, 1);
          props.copy(group.getNode("checkbox-template"), target);
          var nameValue = name != nil ? name.getValue() : nil;
          target.getNode("label").setValue(
            nameValue != nil ? nameValue :
            sprintf("** " ~ tr.get("unnamed-view-number-n") ~ " **", index));
          target.getNode("property").setValue(enabled.getPath());
        }
      }
    </open>
  </nasal>

  <modal>false</modal>
  <layout>vbox</layout>

  <group>
    <layout>hbox</layout>

    <group>
      <layout>vbox</layout>
      <valign>top</valign>

      <text>
        <label translate="y">
          select-active-views-instruction
          <?FlightGear-tr text="Select Active Views"?>
        </label>
      </text>

      <group>
        <layout>vbox</layout>
        <halign>center</halign>
        <name>active-views</name>

        <text>
          <halign>left</halign>
          <label translate="y">
            standard-views-heading-label
            <?FlightGear-tr text="Standard Views"?>
          </label>
        </text>

        <checkbox-template>
          <halign>left</halign>
          <label><!----></label>
          <property><!----></property>
          <binding>
            <command>dialog-apply</command>
          </binding>
        </checkbox-template>
      </group>
    </group>

    <vrule/>

    <group>
      <layout>vbox</layout>
      <halign>center</halign>
      <valign>top</valign>

      <text>
        <label translate="y">
          display-options-heading-label
          <?FlightGear-tr text="Display Options"?>
        </label>
      </text>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-frame-rate-checkbox
          <?FlightGear-tr text="Show frame rate"?>
        </label>
        <property>/sim/rendering/fps-display</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-frame-spacing-checkbox
          <?FlightGear-tr text="Show frame spacing"?>
        </label>
        <property>/sim/rendering/frame-latency-display</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-chat-messages-checkbox
          <?FlightGear-tr text="Show chat messages"?>
        </label>
        <property>/sim/multiplay/chat-display</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <group>
        <layout>hbox</layout>

        <text>
          <label translate="y">
            selection-of-chat-and-event-log-position
            <?FlightGear-tr
              text="Chat and event log position (requires restart):"?>
          </label>
        </text>

        <combo>
          <name>chatlocation</name>
          <property>/sim/gui/chat-box-location</property>
          <item>
            <label translate="y">
              chatlocation-default
              <?FlightGear-tr text="default"
                comment="Chat and event log position"?>
            </label>
            <value>default</value>
          </item>
          <item>
            <label translate="y">
              chatlocation-left
              <?FlightGear-tr text="left"
                comment="Chat and event log position"?>
            </label>
            <value>left</value>
          </item>
          <binding>
            <command>dialog-apply</command>
            <object-name>chatlocation</object-name>
          </binding>
        </combo>

      </group>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-popup-messages-checkbox
          <?FlightGear-tr text="Show popup messages"?>
        </label>
        <!-- generalising this property for all popups -->
        <property>/sim/view-name-popup</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-popup-when-cycling-mouse-behaviour-checkbox
          <?FlightGear-tr text="Show popup when cycling mouse behaviour"?>
        </label>
        <property>/sim/mouse/cycle-mode-popup</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
        <enable><property>/sim/view-name-popup</property></enable>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-tooltips-checkbox
          <?FlightGear-tr text="Show tooltips"?>
        </label>
        <property>/sim/mouse/tooltips-enabled</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
          <halign>left</halign>
          <label translate="y">
            show-tooltip-on-mouse-press-checkbox
            <?FlightGear-tr text="Show tooltip on mouse press"?>
          </label>
        <property>/sim/mouse/click-shows-tooltip</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-2D-panel-checkbox
          <?FlightGear-tr text="Show 2D panel"?>
        </label>
        <property>/sim/panel/visibility</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          hide-2D-panel-in-non-centered-view-checkbox
          <?FlightGear-tr text="Hide 2D panel in non-centered view"?>
        </label>
        <property>/sim/panel/hide-nonzero-heading-offset</property>
        <enable>
          <property>/sim/panel/visibility</property>
        </enable>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          hide-2D-panel-in-non-cockpit-view-checkbox
          <?FlightGear-tr text="Hide 2D panel in non-cockpit view"?>
        </label>
        <property>/sim/panel/hide-nonzero-view</property>
        <enable>
          <property>/sim/panel/visibility</property>
        </enable>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          autohide-menubar-checkkox
          <?FlightGear-tr text="Autohide menubar"?>
        </label>
        <property>/sim/menubar/autovisibility/enabled</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <group>
        <layout>hbox</layout>
        <halign>left</halign>
        <padding>0</padding>

        <checkbox>
          <label translate="y">
            autohide-cursor-in-label
            <?FlightGear-tr
              text="Autohide cursor in"
              comment="This is followed by a input field allowing one to enter a number of seconds"?>
          </label>
          <property>/sim/mouse/hide-cursor</property>
          <binding>
            <command>dialog-apply</command>
          </binding>
        </checkbox>

        <input>
          <live>true</live>
          <pref-width>40</pref-width>
          <pref-height>10</pref-height>
          <enable>
            <property>/sim/mouse/hide-cursor</property>
          </enable>
          <property>/sim/mouse/cursor-timeout-sec</property>
          <binding>
            <command>dialog-apply</command>
          </binding>
        </input>

        <text>
          <label>sec.</label>
          <format translate="y">
            format-string-for-cursor-timeout-sec
            <?FlightGear-tr text="second(s)" has-plural="true"?>
          </format>
          <property>/sim/mouse/cursor-timeout-sec</property>
          <live>true</live>
        </text>
      </group>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          legacy-multiplayer-view-selector-checkbox
          <?FlightGear-tr text="Legacy multiplayer view selector"?>
        </label>
        <property>/sim/menubar/legacy-multiplayer-view-selector/enabled</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-pilot-model-checkbox
          <?FlightGear-tr
            text="Show Pilot Model"
            comment="This option is not always visible (it depends on a property)."
          ?>
        </label>
        <property>/sim/rendering/pilot-model/enabled</property>
        <visible>
          <equals>
            <property>/sim/rendering/pilot-model/available</property>
            <value>1</value>
          </equals>
        </visible>

        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

    </group>

    <vrule/>

    <group>
      <layout>vbox</layout>
      <halign>center</halign>
      <valign>top</valign>

      <text>
        <label translate="y">
          marker-pins-heading-label
          <?FlightGear-tr text="Marker Pins"?>
        </label>
      </text>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-marker-pins-general-toggle-checkbox
          <?FlightGear-tr text="Show"?>
        </label>
        <property>/sim/marker-pins/master</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <hrule/>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-airport-marker-pins-checkbox
          <?FlightGear-tr text="Airports"?>
        </label>
        <property>/sim/marker-pins/airports</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-navaid-marker-pins-checkbox
          <?FlightGear-tr text="Navaids"?>
        </label>
        <property>/sim/marker-pins/navaids</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-fix-marker-pins-checkbox
          <?FlightGear-tr text="Fixes"?>
        </label>
        <property>/sim/marker-pins/fixes</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-POI-marker-pins-checkbox
          <?FlightGear-tr text="POI" comment="POI = Points Of Interest"?>
        </label>
        <property>/sim/marker-pins/pois</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

      <hrule/>

      <checkbox>
        <halign>left</halign>
        <label translate="y">
          show-traffic-marker-pins-checkbox
          <?FlightGear-tr text="Traffic"?>
        </label>
        <property>/sim/marker-pins/traffic</property>
        <binding>
          <command>dialog-apply</command>
        </binding>
      </checkbox>

    </group>

  </group>

  <hrule/>

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

</PropertyList>
