{
  "namespace": "select_world",

  //--------------------------------------------------------------------------------
  // Add-Ons Popup Flow
  //--------------------------------------------------------------------------------

  // Pop ups

  "popup_dialog__add_on_common@popup_dialog.popup_dialog": {
    "$message_text|default": "",
    "$popup_content|default": "common.empty_panel",

    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.close_popup",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_left",
        "to_button_id": "button.menu_left",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_right",
        "to_button_id": "button.menu_right",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_up",
        "to_button_id": "button.menu_up",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_down",
        "to_button_id": "button.menu_down",
        "mapping_type": "global",
        "scope": "view"
      }
    ]
  },

  "popup_dialog__add_on_common_no_buttons@select_world.popup_dialog__add_on_common": {
    "controls": [
      { "popup_dialog_bg@common.dialog_background_hollow_3": { "$fill_alpha": 1.0 } },
      { "popup_dialog_message@popup_dialog.popup_dialog_message": { "offset": [ 0, "8px" ] } },
      { "close_button@common.close_button": { "$close_button_to_button_id": "button.close_popup" } },
      { "add_on_popup_content_panel@select_world.add_on_popup_content_panel": {} }
    ]
  },

  "popup_dialog__add_on_common_two_buttons@select_world.popup_dialog__add_on_common": {
    "size": [ "146%y", "80%" ],
    "$copy_button_name|default": "button.none",
    "$copy_button_text|default": "",
    "$continue_button_name|default": "button.none",
    "$continue_button_text|default": "",
    "controls": [
      { "popup_dialog_bg@common.dialog_background_hollow_1": { "$fill_alpha": 1.0 } },
      { "popup_dialog_message@popup_dialog.popup_dialog_message": { "offset": [ 0, "8px" ] } },
      { "close_button@common.close_button": { "$close_button_to_button_id": "button.close_popup" } },
      { "add_on_popup_content_panel@select_world.add_on_popup_content_panel": {} },
      { "button_copy@select_world.add_on_button_copy": {} },
      { "button_continue@select_world.add_on_button_continue": {} }
    ]
  },

  "add_on_button_copy@common_buttons.light_text_button": {
    "size": [ "100% - 16px", 32 ],
    "offset": [ 0, -40 ],
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "$pressed_button_name": "$copy_button_name",
    "$button_text": "$copy_button_text"
  },

  "add_on_button_continue@common_buttons.light_text_button": {
    "size": [ "100% - 16px", 32 ],
    "offset": [ 0, -6 ],
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "$pressed_button_name": "$continue_button_name",
    "$button_text": "$continue_button_text"
  },

  "add_on_popup_content_panel": {
    "type": "panel",
    "size": [ "100% - 16px", "100% - 31px" ], // size and offset to align inside dialog_background_hollow_3 frame
    "offset": [ 0, "-8px" ],
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "layer": 10,
    "$popup_content:default": "",
    "controls": [
      { "popup_content@$popup_content": {} }
    ]
  },

  "popup_dialog__activate_add_on@select_world.popup_dialog__add_on_common_no_buttons": {
    "$message_text": "store.addon.newOrExistingTitle",
    "$popup_content": "select_world.new_or_existing_world_panel"
  },

  "popup_dialog__activate_add_on_select_world@select_world.popup_dialog__add_on_common_no_buttons": {
    "size": [ "146%y", "80%" ],
    "$message_text": "store.addon.selectWorldTitle",
    "$popup_content": "select_world.select_world_panel"
  },

  "popup_dialog__copy_local_world@select_world.popup_dialog__add_on_common_two_buttons": {
    "$message_text": "store.addon.update.local.title",
    "$popup_content": "select_world.copy_local_world_panel",
    "$copy_button_text": "store.addon.update.local.buttonCopy",
    "$continue_button_text": "store.addon.update.local.buttonContinue",
    "$continue_button_name": "button.navigate_edit_world",
    "$copy_button_name": "button.copy_local_world"
  },

  "popup_dialog__copy_realms_world@select_world.popup_dialog__add_on_common_two_buttons": {
    "$message_text": "store.addon.update.realms.title",
    "$popup_content": "select_world.copy_realms_world_panel",
    "$copy_button_text": "store.addon.update.realms.buttonCopy",
    "$continue_button_text": "store.addon.update.realms.buttonContinue",
    "$continue_button_name": "button.navigate_edit_realms_world",
    "$copy_button_name": "button.download_realms_world"
  },

  "copy_local_world_panel@common.vertical_stack_panel": {
    "size": [ "100% - 4px", "100%" ],
    "controls": [
      { "padding_top@common.empty_panel": { "size": [ "100%", "2px" ] } },
      {
        "text_box": {
          "type": "label",
          "size": [ "100%", "default" ],
          "font_type": "smooth",
          "color": "$body_text_color",
          "text": "store.addon.update.local.body1"
        }
      },
      { "padding_middle@common.empty_panel": { "size": [ "100%", "8px" ] } },
      {
        "text_box2": {
          "type": "label",
          "size": [ "100%", "default" ],
          "font_type": "smooth",
          "color": "$body_text_color",
          "text": "store.addon.update.local.body2"
        }
      }
    ]
  },

  "copy_realms_world_panel@common.vertical_stack_panel": {
    "size": [ "100% - 4px", "100%" ],
    "controls": [
      { "padding_top@common.empty_panel": { "size": [ "100%", "2px" ] } },
      {
        "text_box": {
          "type": "label",
          "size": [ "100%", "default" ],
          "font_type": "smooth",
          "color": "$body_text_color",
          "text": "store.addon.update.realms.body1"
        }
      },
      { "padding_middle@common.empty_panel": { "size": [ "100%", "8px" ] } },
      {
        "text_box2": {
          "type": "label",
          "size": [ "100%", "default" ],
          "font_type": "smooth",
          "color": "$body_text_color",
          "text": "store.addon.update.realms.body2"
        }
      }
    ]
  },

  // New or Existing World Pop Up Components

  "new_or_existing_world_panel@common.horizontal_stack_panel": {
    "size": [ "100%", "100%" ],
    "controls": [
      { "padding_left@common.empty_panel": { "size": [ "2px", "100%" ] } },
      {
        "world_icon_existing@select_world.world_icon_with_button": {
          "$button_text": "store.addon.choseExistingWorld",
          "$pressed_button_name": "button.addon_select_world",
          "$vert_stack_centering_content": "select_world.world_icon_existing",
          "$world_button_enabled": "#existing_world_button_enabled"
        }
      },
      { "padding_middle@common.empty_panel": { "size": [ "2px", "100%" ] } },
      {
        "world_icon_new@select_world.world_icon_with_button": {
          "$button_text": "store.addon.choseNewWorld",
          "$pressed_button_name": "button.navigate_create_new_world",
          "$vert_stack_centering_content": "select_world.world_icon_new"
        }
      },
      { "padding_right@common.empty_panel": { "size": [ "2px", "100%" ] } }
    ]
  },

  "world_icon_with_button@common.vertical_stack_panel": {
    "size": [ "fill", "100%c" ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "controls": [
      { "padding_top@common.empty_panel": { "size": [ "100%", "16px" ] } },
      { "world_icon@common.vert_stack_centering_panel": {} },
      {
        "button@common_buttons.light_text_button": {
          "size": [ "100%", 20 ],
          "$world_button_enabled|default": "#none",
          "enabled": "$world_button_enabled",
          "bindings": [
            {
              "binding_name": "$world_button_enabled",
              "binding_name_override": "#enabled",
              "binding_condition": "always",
              "binding_type": "global"
            }
          ]
        }
      },
      { "padding_bottom@common.empty_panel": { "size": [ "100%", "16px" ] } }
    ]
  },

  "world_icon_new": {
    "type": "image",
    "size": [ "100% - 2px", "57.7%x" ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "texture": "textures/ui/white_background",
    "color": "$light_button_default_text_color",
    "clip_direction": "left", // clipping variables needed for square image to fill rectangular space
    "clip_pixelperfect": true,
    "clip_ratio": 0.4376,
    "controls": [
      {
        "plus_button": {
          "type": "image",
          "size": [ "50%", "50%" ],
          "texture": "textures/ui/color_plus"
        }
      }
    ]
  },

  "world_icon_existing": {
    "type": "image",
    "size": [ "100% - 2px", "57.7%x" ], // Original texture size [ 260, 150 ]
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "texture": "#existing_world_icon",
    "bindings": [
      {
        "binding_name": "#existing_world_icon",
        "binding_name_override": "#texture",
        "binding_condition": "once"
      },
      {
        "binding_name": "#existing_world_icon_file_system",
        "binding_name_override": "#texture_file_system",
        "binding_condition": "once"
      }
    ]
  },

  // World List Pop Up Components

  "select_world_panel@common.scrolling_panel": {
    "size": [ "100%", "100%" ],
    "$scroll_view_port_size|default": [ "100% - 2px", "100% -2px" ],
    "$scroll_view_port_offset|default": [ 2, 2 ],
    "$scroll_view_port_size_touch|default": [ "100% - 2px", "100% - 2px" ],
    "$scroll_view_port_offset_touch|default": [ 2, 2 ],
    "$scrolling_content": "select_world.select_world_list",
    "$show_background": false
  },

  "select_world_list@common.vertical_stack_panel": {
    "size": [ "100%", "100%c" ],
    "$world_item_grid_template": "select_world.local_world_item_button",
    "$grid_item_layout": "select_world.realms_world_item_button",
    "$realms_worlds_collection_name": "personal_realms",
    "controls": [
      {
        "realms_world_label@common_dialogs.standard_title_label": {
          "$text_name": "#realms_worlds_title_with_count",
          "$title_text_color": "$body_text_color",
          "$title_binding_condition": "once",
          "$title_text_binding_type": "global"
        }
      },
      {
        "realms_world_list@play.realms_world_item_grid": {
          "$grid_name": "#realms_world_item_grid_dimension",
          "$local_world_upload": false,
          "$local_world_edit_button_visible": false
        }
      },
      { "padding_middle@common.empty_panel": { "size": [ "100%", "2px" ] } },
      {
        "local_world_label@common_dialogs.standard_title_label": {
          "$text_name": "#local_worlds_title_with_count",
          "$title_text_color": "$body_text_color",
          "$title_binding_condition|default": "once",
          "$title_text_binding_type|default": "global"
        }
      },
      {
        "local_world_list@play.local_world_item_grid": {
          "$local_world_upload": false,
          "$local_world_edit_button_visible": false
        }
      },
      { "padding_end@common.empty_panel": { "size": [ "100%", "2px" ] } }
    ]
  },

  "local_world_item_button@common_buttons.dark_content_button": {
    "size": [ "100%", "30px" ],
    "$pressed_button_name": "button.addon_copy_world_warning",
    "$worlds_collection_name": "local_worlds",
    "$world_image_binding_name": "#local_world_image",
    "$world_texture_source_binding_name": "#local_world_texture_source",
    "$world_supports_realmsplus_overlay": false,
    "$world_text_panel_control": "play.local_world_text_panel",
    "$button_content": "play.world_content_panel",
    "bindings": [
      {
        "binding_type": "collection_details",
        "binding_collection_name": "local_worlds"
      },
      {
        "binding_type": "collection",
        "binding_name": "#world_button_focus_identifier",
        "binding_name_override": "#focus_identifier",
        "binding_collection_name": "local_worlds"
      }
    ]
  },

  "realms_world_item_button@common_buttons.dark_content_button": {
    "size": [ "100%", "30px" ],
    "$pressed_button_name": "button.addon_copy_realms_warning",
    "$button_content": "play.realms_world_content_panel",
    "$world_header_text_binding_type": "#realms_world_title",
    "$world_details_text": "#realms_world_description",
    "$world_details_text_binding_type": "global",
    "$personal_realm_collection_name": "personal_realms",
    "$friend_realm_collection_name": "friends_realms",
    "bindings": [
      {
        "binding_type": "collection_details",
        "binding_collection_name": "$realms_worlds_collection_name"
      },
      {
        "binding_type": "collection",
        "binding_name": "#world_button_focus_identifier",
        "binding_name_override": "#focus_identifier",
        "binding_collection_name": "$realms_worlds_collection_name"
      },
      {
        "binding_name": "#cross_platform_enabled",
        "binding_name_override": "#enabled"
      }
    ]
  },

  //--------------------------------------------------------------------------------
  // Screen
  //--------------------------------------------------------------------------------

  "select_world_screen_content": {
    "type": "panel",
    "size": [ "100%", "100%" ],

    "controls": [
      //{
      //  "popup@select_world.popup_dialog__activate_add_on": {}
      //},
      {
        "popup_dialog_factory": {
          "type": "factory",
          "control_ids": {
            "activate_add_on": "@select_world.popup_dialog__activate_add_on",
            "popup_dialog__copy_local_world": "@select_world.popup_dialog__copy_local_world",
            "popup_dialog__copy_realms_world": "@select_world.popup_dialog__copy_realms_world",
            "activate_add_on_select_world": "@select_world.popup_dialog__activate_add_on_select_world"
          }
        }
      }
    ]
  },

  "select_world_popup_screen@common.base_screen": {
    "$safezone_screen_matrix_layer": 20,
    "$ignore_inventory_button": true,
    "force_render_below": true,

    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.try_exiting",
        "mapping_type": "global"
      }
    ],

    "$screen_content": "select_world.select_world_screen_content",
    "$is_full_screen_layout": false
  }
}
