{
  "namespace": "world_templates",

  "horizontal_padding": {
    "type": "panel",
    "size": [ 2, "100%" ]
  },

  //---------------------------------------------------------------------------
  // Images
  //---------------------------------------------------------------------------

  "world_icon": {
    "type": "image",
    "texture": "textures/ui/worldsIcon",
    "size": [ 16, 17 ]
  },

  "realms_icon": {
    "type": "image",
    "texture": "textures/ui/realmsIcon",
    "size": [ 11, 14 ]
  },

  "label_background": {
    "type": "image",
    "texture": "textures/ui/mainbanners"
  },

  "lock_icon": {
    "type": "image",
    "texture": "textures/ui/lock"
  },

  //---------------------------------------------------------------------------
  // TOGGLES
  //---------------------------------------------------------------------------

  "new_world_toggle@common_toggles.dark_image_toggle": {
    "size": [ "100%", "100%" ],
    "$toggle_name": "world_toggle",
    "$button_content": "world_templates.world_button_content",
    "$world_icon": "world_templates.world_icon",
    "$button_label": "selectTemplate.world",
    "$radio_toggle_group": true,
    "$toggle_group_forced_index": 0,
    "$toggle_group_default_selected": "$default_tab"
  },

  "new_realm_toggle@common_toggles.dark_image_toggle": {
    "size": [ "100% + 1px", "100%" ],
    "$toggle_name": "world_toggle",
    "$button_content": "world_templates.world_button_content",
    "$world_icon": "world_templates.realms_icon",
    "$button_label": "selectTemplate.realm",
    "$radio_toggle_group": true,
    "$toggle_group_forced_index": 1,
    "$toggle_group_default_selected": "$default_tab"
  },

  "world_button_content": {
    "type": "stack_panel",
    "size": [ "100% - 9px", "100% - 4px" ],
    "orientation": "horizontal",
    "controls": [
      { "horizontal_padding_0@world_templates.horizontal_padding": {} },
      {
        "icon_panel": {
          "type": "panel",
          "size": [ "100%c", "100%" ],
          "controls": [
            { "$world_icon@$world_icon": {} }
          ]
        }
      },
      {
        "horizontal_padding_1@world_templates.horizontal_padding": {
          "type": "panel",
          "size": [ 8, "100%" ]
        }
      },
      {
        "world_button_label_panel": {
          "type": "panel",
          "size": [ "fill", "100%" ],
          "controls": [
            { "world_button_label@world_templates.world_button_label": {} }
          ]
        }
      },
      { "horizontal_padding_2@world_templates.horizontal_padding": {} }
    ]
  },

  "world_button_label": {
    "type": "label",
    "color": "$dark_button_default_text_color",
    "size": [ "default", 10 ],
    "max_size": [ "100%", 10 ],
    "text": "$button_label",
    "text_alignment": "left",
    "anchor_from": "left_middle",
    "anchor_to": "left_middle",
    "layer": 1
  },

  //---------------------------------------------------------------------------
  // BUTTONS
  //---------------------------------------------------------------------------

  "common_button_template@common_buttons.light_glyph_button": {},

  "generate_random@common_buttons.light_text_button": {
    "size": [ "100%", 30 ],
    "$pressed_button_name": "button.generate_random",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "default_focus_precedence": 1,
    "$button_text": "#generate_random_button_text",
    "$button_text_binding_type": "global",
    "focus_change_left": "FOCUS_OVERRIDE_STOP",
    "focus_change_right": "FOCUS_OVERRIDE_STOP",
    "bindings": [
      {
        "binding_name": "#generate_random_button_enabled",
        "binding_name_override": "#enabled"
      }
    ]
  },

  "help_button@common_buttons.dark_text_button": {
    "$pressed_button_name": "button.help",
    "$button_text": "selectTemplate.help"
  },

  "grid_button_content_template": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100%", "100%c" ],
    "controls": [
      {
        "content@$button_content": {
          "layer": 1
        }
      }
    ]
  },

  "label_content_template": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100%", "100%c" ],
    "controls": [
      {
        "label_panel": {
          "type": "panel",
          "size": [ "100%", 10 ],
          "anchor_from": "top_left",
          "anchor_to": "top_left",
          "layer": 1,
          "controls": [
            {
              "label_panel_layout": {
                "type": "panel",
                "anchor_from": "top_left",
                "anchor_to": "top_left",
                "size": [ "100% - 4px", 10 ],
                "offset": [ 1, 0 ],
                "controls": [
                  {
                    "label": {
                      "type": "label",
                      "color": "$body_text_color",
                      "size": [ "100%", 10 ],
                      "anchor_from": "top_left",
                      "anchor_to": "top_left",
                      "layer": 1,
                      "shadow": false,
                      "text": "$label_content_label"
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "my_templates_label@world_templates.label_content_template": {
    "$label_content_label": "selectTemplate.myTemplates"
  },

  "generate_random_button@world_templates.grid_button_content_template": {
    "size": [ "100%", "100%c + 2px" ],
    "$button_content": "world_templates.generate_random"
  },

  "realms_templates_info@world_templates.label_background": {
    "size": [ "100%", "100%c + 8px" ],
    "controls": [
      {
        "info_label": {
          "type": "label",
          "color": "$body_text_color",
          "max_size": [ "100% - 4px", "default" ],
          "text": "#realms_info_text",
          "layer": 1,
          "bindings": [
            {
              "binding_name": "#realms_info_text",
              "binding_type": "global",
              "binding_condition": "always_when_visible"
            }
          ]
        }
      }
    ],
    "bindings": [
      {
        "binding_name": "#realms_info_visible",
        "binding_name_override": "#visible"
      }
    ]
  },

  //---------------------------------------------------------------------------
  // LOCAL WORLD GRID
  //---------------------------------------------------------------------------

  "world_list_text": {
    "type": "label",
    "color": "$dark_button_secondary_default_text_color",
    "shadow": false
  },

  "world_template_screenshot": {
    "type": "image",
    "size": [ "100%c + 2px", "100%" ],
    "texture": "$border_texture",
    "anchor_from": "left_middle",
    "anchor_to": "left_middle",
    "layer": 1,
    "controls": [
      {
        "picture": {
          "type": "image",
          "layer": 1,
          "force_texture_reload": true,
          "texture": "#screenshot_texture",
          "zip_folder": "#screenshot_zip_folder",
          "texture_file_system": "#screenshot_file_system",
          "size": [ "173.91%y", "100% - 2px" ],
          "$screenshot_texture_name|default": "#screenshot_texture",
          "$screenshot_zip_folder|default": "#screenshot_zip_folder",
          "$screenshot_zip_folder_binding_type|default": "collection",
          "$screenshot_file_system|default": "#screenshot_file_system",
          "bindings": [
            {
              "binding_collection_name": "$collection_name",
              "binding_name": "$screenshot_texture_name",
              "binding_name_override": "#texture",
              "binding_type": "collection"
            },
            {
              "binding_collection_name": "$collection_name",
              "binding_name": "$screenshot_zip_folder",
              "binding_name_override": "#zip_folder",
              "binding_type": "$screenshot_zip_folder_binding_type"
            },
            {
              "binding_collection_name": "$collection_name",
              "binding_name": "$screenshot_file_system",
              "binding_name_override": "#texture_file_system",
              "binding_type": "collection"
            }
          ]
        }
      }
    ]
  },

  "world_template_name@world_templates.world_list_text": {
    "text": "$world_template_name_binding_name",
    "color": "$dark_button_default_text_color",
    "$world_template_name_binding_name|default": "#world_template_name",
    "bindings": [
      {
        "binding_name": "$world_template_name_binding_name",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "visible"
      }
    ]
  },

  "world_template_description@world_templates.world_list_text": {
    "text": "$world_template_description_binding_name",
    "$world_template_description_binding_name|default": "#world_template_description",
    "bindings": [
      {
        "binding_name": "$world_template_description_binding_name",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "visible"
      }
    ]
  },

  "world_template_version@world_templates.world_list_text": {
    "text": "#world_template_version",
    "bindings": [
      {
        "binding_name": "#world_template_version",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "visible"
      }
    ]
  },

  "template_download_text@world_templates.world_list_text": {
    "text": "#template_download_text",
    "bindings": [
      {
        "binding_name": "#template_download_text",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "visible"
      },
      {
        "binding_name": "#download_text_visible",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_name_override": "#visible"
      }
    ]
  },

  "world_template_text_panel": {
    "type": "panel",
    "controls": [
      {
        "text_indent": {
          "type": "panel",
          "size": [ "100% - 4px", "100% - 4px" ],
          "offset": [ 1, 0 ],
          "controls": [
            {
              "top_side": {
                "type": "stack_panel",
                "orientation": "horizontal",
                "size": [ "100%", "50%" ],
                "anchor_from": "top_left",
                "anchor_to": "top_left",
                "controls": [
                  {
                    "world_template_name@world_templates.world_template_name": {
                      "size": [ "fill", 10 ],
                      "layer": 1
                    }
                  },
                  {
                    "download_text_label@world_templates.template_download_text": {
                      "size": [ "default", 10 ],
                      "layer": 1
                    }
                  }
                ]
              }
            },
            {
              "bottom_side": {
                "anchor_from": "bottom_left",
                "anchor_to": "bottom_left",
                "type": "stack_panel",
                "orientation": "horizontal",
                "size": [ "100%", "50%" ],
                "controls": [
                  {
                    "world_template_description@world_templates.world_template_description": {
                      "size": [ "fill", 10 ],
                      "layer": 1
                    }
                  },
                  {
                    "world_template_version@world_templates.world_template_version": {
                      "size": [ "default", 10 ],
                      "layer": 1
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "world_template_content_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%", "100%" ],
    "$lock_not_visible|default": true,
    "variables": [
      {
        "requires": "$default_state",
        "$border_texture": "textures/ui/default_indent"
      },
      {
        "requires": "$hover_state",
        "$border_texture": "textures/ui/world_screenshot_focus_border"
      },
      {
        "requires": "$pressed_state",
        "$border_texture": "textures/ui/world_screenshot_focus_border"
      },
      {
        "requires": "$locked_state",
        "$border_texture": "textures/ui/default_indent"
      }
    ],
    "controls": [
      {
        "world_template_screenshot@world_templates.world_template_screenshot": {}
      },
      {
        "world_template_text_panel@world_templates.world_template_text_panel": {
          "size": [ "fill", "100%" ]
        }
      },
      {
        "lock_panel": {
          "type": "panel",
          "size": [ "100%c + 4px", "100%" ],
          "ignored": "$lock_not_visible",
          "controls": [
            {
              "lock_icon@world_templates.lock_icon": {
                "size": [ 8, 8 ]
              }
            }
          ]
        }
      }
    ]
  },

  "world_template_item_button@common_buttons.dark_content_button": {
    "$button_content": "world_templates.world_template_content_panel",
    "bindings": [
      {
        "binding_type": "collection_details",
        "binding_collection_name": "$collection_name",
        "binding_collection_prefix": "$collection_prefix"
      }
    ]
  },

  "world_template_item": {
    "type": "stack_panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "layer": 1,
    "size": [ "100%", 30 ],
    "orientation": "horizontal",    
    "controls": [
      {
        "world_template_item_button@world_templates.world_template_item_button": {
          "size": [ "fill", "100% + 1px" ],
          "anchor_from": "top_left",
          "anchor_to": "top_left",
          "focus_change_left": "FOCUS_OVERRIDE_STOP",
          "focus_change_right": "FOCUS_OVERRIDE_STOP",
          "layer": 1
        }
      }
    ]
  },

  "world_template_item_grid": {
    "type": "grid",
    "size": [ "100%", "default" ],
    "layer": 1,
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "grid_item_template": "world_templates.world_template_item",
    "grid_dimension_binding": "#world_template_item_grid_dimension",
    "collection_name": "world_templates",
    "$collection_name": "world_templates",
    "$collection_prefix|default": "",
    "$pressed_button_name": "button.menu_world_template_clicked",
    "bindings": [
      {
        "binding_name": "#world_template_item_grid_dimension"
      }
    ]
  },

  //---------------------------------------------------------------------------
  // NO OWNED ITEMS TEXT
  //---------------------------------------------------------------------------

  "no_owned_templates_text_label": {
    "type": "label",
    "color": "$dark_button_secondary_default_text_color",
    "shadow": false
  },

  "no_owned_templates_text@world_templates.no_owned_templates_text_label": {
    "text": "selectTemplate.noTemplates",
    "color": "$dark_button_default_text_color"
  },

  "no_template_content_owned": {
    "type": "image",
    "texture": "textures/ui/Banners",
    "size": [ "100%", "100%c + 4px" ],
    "min_size": [ "100%", 30 ],
    "controls": [
      {
        "no_template_content_owned_text_panel@world_templates.no_owned_templates_text": {
          "text_alignment": "left",
          "size": [ "100% - 4px", "default" ],
          "offset": [ 0, 0 ],
          "layer": 1
        }
      }
    ]
  },

  //---------------------------------------------------------------------------
  // SCROLL
  //---------------------------------------------------------------------------

  "common_scrolling_panel@common.scrolling_panel": {
    "layer": 1,
    "$scrolling_pane_size": [ "100% - 1px", "100%" ],
    "$scrolling_content": "$scrolling_content",
    "$scroll_size": [ 5, "100% - 4px" ],
    "$show_background": false,
    "anchor_from": "top_right",
    "anchor_to": "top_right"
  },

  "common_content": {
    "type": "input_panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left"
  },

  "scrolling_offsets@world_templates.common_scrolling_panel": {
    "size": [ "100% - 4px", "100%" ],
    "max_size": [ 280, "100%" ],
    "offset": [ 2, 0 ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle"
  },

  "template_scroll_content@world_templates.common_content": {
    "controls": [
      {
        "scrolling_panel@world_templates.scrolling_offsets": {
          "layer": 1,
          "$scrolling_content": "world_templates.template_scroll_panel"
        }
      }
    ]
  },

  "common_scroll_pane": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "100% - 4px", "100%c" ],
    "offset": [ 2, 0 ]
  },

  "template_scroll_panel@world_templates.common_scroll_pane": {
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      {
        "world_template_screen_content_stack_panel@world_templates.world_template_screen_content_stack_panel": {
          "anchor_from": "top_left",
          "anchor_to": "top_left"
        }
      },
      {
        "header_panel_bottom_padding": {
          "type": "panel",
          "size": [ "100%", 5 ]
        }
      }
    ]
  },

  //---------------------------------------------------------------------------
  // SCREEN CONTENT
  //---------------------------------------------------------------------------

  "header_panel": {
    "type": "stack_panel",
    "size": [ "100%", 30 ],
    "orientation": "horizontal",
    "ignored": "$hide_top_bar",
    "controls": [
      {
        "new_world_panel": {
          "type": "panel",
          "size": [ "50% - 50%y", "100% + 1px" ],
          "controls": [
            { "new_world_toggle@world_templates.new_world_toggle": {} }
          ]
        }
      },
      {
        "new_realm_panel": {
          "type": "panel",
          "size": [ "50% - 50%y", "100% + 1px" ],
          "controls": [
            { "new_realm_toggle@world_templates.new_realm_toggle": {} }
          ]
        }
      },
      {
        "help_button@world_templates.help_button": {
          "size": [ "100%y", "100%  + 1px" ]
        }
      }
    ]
  },

  "world_template_screen_content_stack_panel": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100%", "100%c" ],
    "controls": [
      {
        "padding_0": {
          "type": "panel",
          "size": [ "100%", 2 ]
        }
      },
      { "header_panel@world_templates.header_panel": {} },
      {
        "header_panel_bottom_padding": {
          "type": "panel",
          "size": [ "100%", 4 ]
        }
      },
      { "generate_random_panel@world_templates.generate_random_button": {} },
      {
        "generate_random_button_bottom_padding": {
          "type": "panel",
          "size": [ "100%", 2 ]
        }
      },
      {
        "template_list_panel": {
          "type": "stack_panel",
          "orientation": "vertical",
          "size": [ "100%", "100%c" ],
          "bindings": [
            {
              "binding_name": "#template_list_visible",
              "binding_name_override": "#visible"
            }
          ],
          "controls": [
            { "my_templates_label_panel@world_templates.my_templates_label": {} },
            { "world_template_item_grid@world_templates.world_template_item_grid": {} },
            {
              "template_list_bottom_padding": {
                "type": "panel",
                "size": [ "100%", 4 ]
              }
            }
          ]
        }
      },
      {
        "education_template_panel": {
          "type": "stack_panel",
          "orientation": "vertical",
          "ignored": true,
          "size": [ "100%", "100%c" ],
          "controls": [
            {
              "suggested_content_offers_title_label@resource_packs.suggested_content_offers_title_label": {
                "size": [ "100%", "10px" ],
                "$suggested_content_offers_label_text": "selectTemplate.suggestedContent.title",
                "$suggested_content_offers_binding_type": "none",
                "bindings": [
                  {
                    "binding_name": "#education_template_visible",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            },
            {
              "education_template_grid": {
                "type": "grid",
                "size": [ "100%", "default" ],
                "grid_item_template": "world_templates.world_template_item",
                "grid_dimension_binding": "#education_template_item_grid_dimension",
                "$collection_name": "#education_template_collection",
                "collection_name": "#education_template_collection",
                "$collection_prefix|default": "",
                "$pressed_button_name": "button.select_template",
                "$world_template_description_binding_name": "#created_by_label",
                "$world_template_name_binding_name": "#title_label",
                "$screenshot_texture_name": "#template_texture_name",
                "$screenshot_file_system": "#template_texture_file_system",
                "bindings": [
                  {
                    "binding_name": "#education_template_item_grid_dimension"
                  },
                  {
                    "binding_name": "#education_template_visible",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            },
            {
              "see_more_templates_button@common_buttons.dark_text_button": {
                "size": [ "100%", 30 ],
                "$pressed_button_name": "button.see_more_templates",
                "$button_text": "selectTemplate.suggestedContent.button"
              }
            }
          ]
        }
      },
      {
        "suggested_content_panel": {
          "type": "stack_panel",
          "orientation": "vertical",
          "ignored": "$education_edition",
          "size": [ "100%", "100%c" ],
          "bindings": [
            {
              "binding_name": "#suggested_content_visible",
              "binding_name_override": "#visible"
            }
          ],
          "controls": [
            {
              "suggested_content_offers_title_label@resource_packs.suggested_content_offers_title_label": {
                "size": [ "100%", "10px" ],
                "$suggested_content_offers_label_text": "selectTemplate.suggestedContent.title",
                "$suggested_content_offers_binding_type": "none",
                "bindings": [
                  {
                    "binding_name": "(not #realms_info_visible)",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            },
            {
              "suggested_template_grid": {
                "type": "grid",
                "size": [ "100%", "default" ],
                "layer": 1,
                "grid_item_template": "world_templates.world_template_item",
                "grid_dimension_binding": "#suggested_offers_item_grid_dimension",
                "collection_name": "#suggested_offers_collection",
                "$collection_name": "#suggested_offers_collection",
                "$collection_prefix": "offers",
                "$pressed_button_name": "button.select_offer",
                "$world_template_description_binding_name": "#created_by_label",
                "$world_template_name_binding_name": "#title_label",
                "$screenshot_texture_name": "#offer_texture_name",
                "$screenshot_file_system": "#offer_texture_file_system",
                "$screenshot_zip_folder_binding_type": "none",
                "$lock_not_visible": false,
                "bindings": [
                  {
                    "binding_name": "(not #realms_info_visible)",
                    "binding_name_override": "#visible"
                  },
                  {
                    "binding_name": "#suggested_offers_item_grid_dimension"
                  }
                ]
              }
            },
            {
              "see_more_templates_button@common_buttons.dark_text_button": {
                "size": [ "100%", 30 ],
                "$pressed_button_name": "button.more_suggested_content_offers",
                "$button_text": "selectTemplate.suggestedContent.button",
                "focus_change_left": "FOCUS_OVERRIDE_STOP",
                "focus_change_right": "FOCUS_OVERRIDE_STOP",                
                "bindings": [
                  {
                    "binding_name": "(not #realms_info_visible)",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "realms_info_panel": {
          "type": "stack_panel",
          "orientation": "vertical",
          "ignored": "$education_edition",
          "size": [ "100%", "100%c" ],
          "visible": "#realms_info_visible",
          "controls": [
            {
              "padding": {
                "type": "panel",
                "size": [ "100%", 2 ]
              }
            },
            { "realms_templates_info@world_templates.realms_templates_info": {} }
          ]
        }
      }
    ]
  },

  //--------------------------------------------------------------------------------
  // Screen
  //--------------------------------------------------------------------------------

  "world_templates_screen@common.base_screen": {
    "$screen_header_title_visible": false,
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      }
    ],
    "$default_text_color": [ 0.3, 0.3, 0.3 ],
    "$screen_content": "world_templates.world_templates_picker_content",
    "$header_safezone_control": "common_store.store_top_bar_filler",
    "$header_bar_control": "common_store.store_top_bar",
    "$is_full_screen_layout": true
  },

  "world_templates_picker_content": {
    "type": "panel",
    "size": [ "100%", "100%" ],
    "controls": [
      {
        "background@common.fullscreen_header": {
          "$back_button_has_title": true,
          "$button_text": "selectTemplate.create",
          "$child_control": "world_templates.template_scroll_content",
          "$show_close_button": true
        }
      }
    ]
  }
}