/********************************************************
+*   (c) Mojang. All rights reserved                       *
+*   (c) Microsoft. All rights reserved.                   *
+*********************************************************/

{
  "namespace": "server_form",

  "third_party_server_screen@common.base_screen": {
    "$screen_content": "server_form.main_screen_content",
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      }
    ]
  },

  "main_screen_content": {
    "type": "panel",
    "size": [0, 0],
    "controls": [
        {
          "server_form_factory": {
              "type": "factory",
              "control_ids": {
              "long_form": "@server_form.long_form",
              "custom_form": "@server_form.custom_form"
          }
        }
      }
    ]
  },

  "long_form@common_dialogs.main_panel_no_buttons": {
    "$title_panel": "common_dialogs.standard_title_label",
    "$title_size": [ "100% - 14px", 10 ],
    "size": [225, 200],
    "$text_name": "#title_text",
    "$title_text_binding_type": "none",
    "$child_control": "server_form.long_form_panel",
    "layer": 2
  },

  "long_form_panel" : {
    "type": "stack_panel",
    "size": ["100%", "100%"],
    "orientation": "vertical",
    "layer": 1,
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      
      {
        "scrolling_panel@common.scrolling_panel": {
          "anchor_to": "top_left",
          "anchor_from": "top_left",
          "$show_background": false,
          "size": [ "100%", "100%" ],
          "$scrolling_content": "server_form.long_form_scrolling_content",
          "$scroll_size": [ 5, "100% - 4px" ],
          "$scrolling_pane_size": [ "100% - 4px", "100% - 2px" ],
          "$scrolling_pane_offset": [ 2, 0 ],
          "$scroll_bar_right_padding_size": [ 0, 0 ]
        }
      }
    ]
  },

  "long_form_scrolling_content": {
    "type": "stack_panel",
    "size": [ "100% - 4px", "100%c" ],
    "orientation": "vertical",
    "anchor_from": "top_left",
    "anchor_to": "top_left",

    "controls": [
      {
        "label_offset_panel": {
          "type": "panel",
          "size": ["100%", "100%c"],
          "controls": [
            {
              "main_label": {
                "type": "label",
                "offset": [2,2],
                "color": "$main_header_text_color",
                "size": ["100%", "default"],
                "anchor_from": "top_left",
                "anchor_to": "top_left",
                "text": "#form_text"
              }
            }
          ]
        }
      },
      {
        "padding": {
          "type": "panel",
          "size": [ "100%", 4 ]
        }
      },
      {
        "wrapping_panel": {
          "type": "panel",
          "size": [ "100%", "100%c" ],
          "controls": [
            {
              "long_form_dynamic_buttons_panel@server_form.long_form_dynamic_buttons_panel": {}
            }
          ]
        }
      }
    ]
  },

  "long_form_dynamic_buttons_panel": {
    "type": "stack_panel",
    "size": ["100% - 4px", "100%c"],
    "offset": [2,0],
    "orientation": "vertical",
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",

    "factory":{
      "name": "buttons",
      "control_name": "server_form.dynamic_button"
    },

    "collection_name": "form_buttons",
    "bindings": [
      {
        "binding_name": "#form_button_length",
        "binding_name_override": "#collection_length"
      }
    ]
  },

  "dynamic_button": {
    "type": "stack_panel",
    "size": ["100%", 32],
    "orientation": "horizontal",
    "controls":[
      {
        "panel_name": {
          "type": "panel",
          "size": [34, "100%c"],
          "bindings": [
            {
              "binding_type": "view",
              "source_control_name": "image",
              "resolve_sibling_scope": true,
              "source_property_name": "(not (#texture = ''))",
              "target_property_name": "#visible"
            }
          ],

          "controls": [
            {
              "image": {
                "type": "image",
                "layer": 2,
                "size": [32, 32],
                "offset": [-2, 0],
                "bindings":[
                  {
                    "binding_name": "#form_button_texture",
                    "binding_name_override": "#texture",
                    "binding_type": "collection",
                    "binding_collection_name": "form_buttons"
                  },
                  {
                    "binding_name": "#form_button_texture_file_system",
                    "binding_name_override": "#texture_file_system",
                    "binding_type": "collection",
                    "binding_collection_name": "form_buttons"
                  },
                  {
                    "binding_type": "view",
                    "source_property_name": "(not ((#texture = '') or (#texture = 'loading')))",
                    "target_property_name": "#visible"
                  }
                ]
              }
            },
            {
              "progress@progress.progress_loading_bars": {
                "size": [30, 4],
                "offset": [-2, 16],
                "bindings":[
                  {
                    "binding_type": "view",
                    "source_control_name": "image",
                    "resolve_sibling_scope": true,
                    "source_property_name": "(#texture = 'loading')",
                    "target_property_name": "#visible"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "form_button@common_buttons.light_text_button": {
          "$pressed_button_name": "button.form_button_click",
          "anchor_from": "top_left",
          "anchor_to": "top_left",
          "size": [ "fill", 32 ],
          "$button_text": "#form_button_text",
          "$button_text_binding_type": "collection",
          "$button_text_grid_collection_name": "form_buttons",
          "$button_text_max_size": [ "100%", 20 ],
          "bindings": [
            {
              "binding_type": "collection_details",
              "binding_collection_name": "form_buttons"
            }
          ]
        }
      }
    ]
  },


  "custom_form@common_dialogs.main_panel_no_buttons": {
    "$title_panel": "common_dialogs.standard_title_label",
    "$title_size": [ "100% - 14px", 10 ],
    "size": [225, 200],
    "$text_name": "#title_text",
    "$title_text_binding_type": "none",
    "$child_control": "server_form.custom_form_panel",
    "layer": 2
  },

  "custom_form_panel@common.scrolling_panel" : {
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "$show_background": false,
    "size": [ "100%", "100%" ],
    "$scrolling_content": "server_form.custom_form_scrolling_content",
    "$scroll_size": [ 5, "100% - 4px" ],
    "$scrolling_pane_size": [ "100% - 4px", "100% - 2px" ],
    "$scrolling_pane_offset": [ 2, 0 ],
    "$scroll_bar_right_padding_size": [ 0, 0 ]
  },

  "generated_contents": {
    "type": "stack_panel",
    "size": ["100%", "100%c"],
    "orientation": "vertical",
    "anchor_from": "top_left",
    "anchor_to": "top_left",

    "factory":{
      "name": "buttons",
      "control_ids": {
        "label": "@server_form.custom_label",
        "toggle": "@server_form.custom_toggle",
        "slider": "@server_form.custom_slider",
        "step_slider": "@server_form.custom_step_slider",
        "dropdown": "@server_form.custom_dropdown",
        "input": "@server_form.custom_input"
      }
    },

    "collection_name": "custom_form",
    "bindings": [
      {
        "binding_name": "#custom_form_length",
        "binding_name_override": "#collection_length"
      }
    ]
  },

  "custom_form_scrolling_content": {
    "type": "stack_panel",
    "size": ["100% - 4px", "100%c"],
    "offset": [2,0],
    "orientation": "vertical",
    "anchor_from": "top_left",
    "anchor_to": "top_left",

    "controls": [
      {
        "generated_form@server_form.generated_contents": {}
      },
      {
        "submit_button@common_buttons.light_text_button": {
          "$pressed_button_name": "button.submit_custom_form",
          "anchor_from": "top_left",
          "anchor_to": "top_left",
          "size": [ "100%", 32 ],
          "$button_text": "#submit_text",
          "$button_text_binding_type": "global",
          "$button_binding_condition": "once",

          "bindings": [
            {
              "binding_name": "#submit_button_visible",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]    
  },

  "custom_label@settings_common.option_group_label": {
    "$text": "#custom_text",
    "$text_bindings":[
      {
        "binding_name": "#custom_text",
        "binding_type": "collection",
        "binding_collection_name": "custom_form"
      }
    ]
  },

  "custom_toggle@settings_common.option_toggle": {
    "$option_label": "#custom_text",
    "$toggle_name": "custom_toggle",
    "$toggle_state_binding_name": "#custom_toggle_state",
    "$option_binding_name": "#custom_toggle_state",
    "$toggle_binding_type": "collection",
    "$toggle_enabled_binding_name": "#custom_toggle_enabled",
    "$toggle_enabled_binding_type": "collection",
    "$toggle_grid_collection_name": "custom_form",
    "$label_bindings": [
      {
        "binding_name": "#custom_text",
        "binding_type": "collection",
        "binding_collection_name": "custom_form"
      }
    ]
  },

  "custom_slider@settings_common.option_slider": {
    "$option_label": "#custom_slider_text",
    "$slider_name": "custom_slider",
    "$slider_value_binding_name": "#custom_slider_value",
    "$slider_tts_text_value": "#custom_slider_text_value",
    "$slider_binding_type": "collection",
    "$slider_collection_name": "custom_form",
    "$slider_enabled_binding_name": "#custom_slider_enabled",
    "$slider_enabled_binding_type": "collection",
    "$label_bindings": [
      {
        "binding_name": "#custom_slider_text",
        "binding_type": "collection",
        "binding_collection_name": "custom_form"
      }
    ]
  },

  "custom_step_slider@server_form.custom_slider": {
    "$option_label": "#custom_slider_step_text",
    "$slider_name": "custom_slider_step",
    "$slider_value_binding_name": "#custom_slider_step_value",
    "$slider_tts_text_value": "#custom_slider_step_text_value",
    "$slider_steps_binding_type": "collection",
    "$slider_steps_binding_name": "#custom_slider_steps",
    "$label_bindings": [
      {
        "binding_name": "#custom_slider_step_text",
        "binding_type": "collection",
        "binding_collection_name": "custom_form"
      }
    ]
  },

  "custom_dropdown": {
    "type": "panel",
    "size": ["100%", "100%c"],
    "controls": [
      {
        "dropdown@settings_common.option_dropdown": {
          "$option_label": "#custom_text",
          "$dropdown_content": "server_form.custom_dropdown_content",
          "$dropdown_area": "generated_form",
          "$dropdown_name": "custom_dropdown",
          "$toggle_binding_type": "collection",
          "$toggle_grid_collection_name": "custom_form",
          "$options_dropdown_toggle_label_binding": "#dropdown_option_text",
          "$options_dropdown_toggle_label_binding_type": "collection",
          "$options_dropdown_toggle_label_binding_collection_name": "custom_form",
          "$dropdown_scroll_content_size": [ "100%", "200%" ],
          "$label_bindings": [
            {
              "binding_name": "#custom_text",
              "binding_type": "collection",
              "binding_collection_name": "custom_form"
            }
          ]
        }
      }
    ]
  },

  "custom_dropdown_content@settings_common.option_radio_dropdown_group": {
    "$radio_buttons": [],

    "$radio_factory":{
      "name": "buttons",
      "control_name": "server_form.custom_dropdown_radio"
    },

    "$radio_collection_name": "custom_dropdown",
    "$radio_bindings": [
      {
        "binding_name": "#custom_dropdown_length",
        "binding_type": "collection",
        "binding_name_override": "#collection_length",
        "binding_collection_name": "custom_form"
      }
    ]
  },

  "custom_dropdown_radio@settings_common.radio_with_label": {
    "$toggle_name": "custom_dropdown_radio_toggle",
    "$toggle_state_binding_name": "#custom_radio_toggled",
    "$toggle_binding_type": "collection",
    "$toggle_grid_collection_name": "custom_dropdown",
    "$toggle_collection_details_type": "collection_details",

    "$radio_label_text": "#custom_radio_text",
    "$radio_label_bindings": [
      {
        "binding_name": "#custom_radio_text",
        "binding_type": "collection",
        "binding_collection_name": "custom_dropdown"
      },
      {
        "binding_type": "collection_details"
      }
    ]
  },

  "custom_input@settings_common.option_text_edit": {
    "$option_label": "#custom_text",
    "$option_place_holder_text": "#custom_placeholder_text",
    "$text_edit_box_placeholder_content_binding_name": "$option_place_holder_text",
    "$text_edit_box_placeholder_content_binding_type": "collection",
    "$text_edit_box_grid_collection_name": "custom_form",

    "$max_text_edit_length": 100,

    "$text_edit_box_content_binding_type": "collection",
    "$text_edit_box_content_binding_name": "#custom_input_text",

    "$option_binding_name": "#custom_input_text",
    "$text_box_enabled_binding_name": "#custom_input_enabled",
    "$text_box_name": "custom_input",
    "$label_bindings": [
      {
        "binding_name": "#custom_text",
        "binding_type": "collection",
        "binding_collection_name": "custom_form"
      }
    ]
  }
}
