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

{
  "namespace": "stonecutter",

  //---------------------------------------------------------------------------
  // #region common images
  //---------------------------------------------------------------------------

  "stonecutter_label": {
    "type": "label",
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "color": "$title_text_color",
    "layer": 1,
    "text": "container.stonecutter"
  },

  "arrow_icon": {
    "type": "image",
    "texture": "textures/ui/arrow_large",
    "size": [ 18, 12 ]
  },

  "stone_cell_image": {
    "type": "image",
    "layer": 1,
    "bindings": [
      {
        "binding_name": "#stone_cell_background_texture",
        "binding_name_override": "#texture",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "always_when_visible"
      }
    ]
  },

  "container_cell_image": {
    "type": "image",
    "$cell_images_binding_condition|default": "visible",
    "size": "$cell_image_size",
    "$cell_image_size|default": [ "default", "default" ],

    "bindings": [
      {
        "binding_name": "#container_cell_background_texture",
        "binding_name_override": "#texture",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name",
        "binding_condition": "$cell_images_binding_condition"
      }
    ]
  },

  "toolbar_background": {
    "type": "image",
    "texture": "textures/ui/toolbar_background"
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region pattern book
  //---------------------------------------------------------------------------

  "highlight_slot_panel": {
    "type": "panel",
    "controls": [
      {
        "highlight@common.highlight_slot": {
          "layer": 1,
          "bindings": [
            {
              "binding_name": "(not #using_touch)",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "white_border@common.white_border_slot": {
          "layer": 1,
          "bindings": [
            {
              "binding_name": "(not #using_touch)",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "stone_slot_button": {
    "type": "button",

    "$focus_id|default": "",
    "$focus_override_down|default": "",
    "$focus_override_up|default": "",
    "$focus_override_left|default": "",
    "$focus_override_right|default": "",

    "$focus_id_binding_type|default": "collection",
    "$focus_override_down_binding_type|default": "collection",
    "$focus_override_up_binding_type|default": "collection",
    "$focus_override_left_binding_type|default": "collection",
    "$focus_override_right_binding_type|default": "collection",

    "focus_identifier": "$focus_id",
    "focus_change_down": "$focus_override_down",
    "focus_change_up": "$focus_override_up",
    "focus_change_left": "$focus_override_left",
    "focus_change_right": "$focus_override_right",
    "focus_enabled": true,
    "focus_wrap_enabled": false,
    "focus_magnet_enabled": true,
    "$highlight_control|default": "stonecutter.highlight_slot_panel",

    "sound_name": "random.click",
    "sound_volume": 1.0,
    "sound_pitch": 1.0,

    "default_focus_precedence": 1,
    "hover_control": "hover",
    "layer": 1,
    "bindings": [
      {
        "binding_type": "collection_details",
        "binding_collection_name": "$collection_name",
        "binding_condition": "once"
      },
      {
        "binding_type": "$focus_id_binding_type",
        "binding_name": "#focus_identifier",
        "binding_name_override": "#focus_identifier",
        "binding_collection_name": "$collection_name",
        "binding_condition": "once"
      },
      {
        "binding_type": "$focus_override_down_binding_type",
        "binding_name": "#focus_change_down",
        "binding_name_override": "#focus_change_down",
        "binding_collection_name": "$collection_name",
        "binding_condition": "once"
      },
      {
        "binding_type": "$focus_override_up_binding_type",
        "binding_name": "#focus_change_up",
        "binding_name_override": "#focus_change_up",
        "binding_collection_name": "$collection_name",
        "binding_condition": "once"
      },
      {
        "binding_type": "$focus_override_left_binding_type",
        "binding_name": "#focus_change_left",
        "binding_name_override": "#focus_change_left",
        "binding_collection_name": "$collection_name",
        "binding_condition": "once"
      },
      {
        "binding_type": "$focus_override_right_binding_type",
        "binding_name": "#focus_change_right",
        "binding_name_override": "#focus_change_right",
        "binding_collection_name": "$collection_name",
        "binding_condition": "once"
      }
    ],
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_auto_place",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop_all",
        "to_button_id": "button.stone_select",
        "mapping_type": "pressed"
      },
      {
        "to_button_id": "button.container_slot_hovered",
        "mapping_type": "pressed"
      }
    ],
    "controls": [
      {
        "hover@$highlight_control": {}
      }
    ]
  },

  "item_panel": {
    "type": "panel",
    "$item_renderer_panel_size|default": [ 26, 26 ],
    "size": "$item_renderer_panel_size",
    "$item_collection_name": "$collection_name",
    "$stack_count_required|default": true,
    "controls": [
      {
        "item_renderer@common.item_renderer": {
          "$item_renderer_size|default": [ 16, 16 ],
          "size": "$item_renderer_size",
          "layer": 1,
          "bindings": [
            {
              "binding_name": "#item_id_aux",
              "binding_condition": "visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name"
            }
          ],
          "controls": [
            {
              "stack_count_label@common.stack_count_label": {
                "layer": 2,
                "bindings": [
                  {
                    "binding_name": "#item_stack_count",
                    "binding_name_override": "#inventory_stack_count",
                    "binding_condition": "visible",
                    "binding_type": "collection",
                    "binding_collection_name": "$item_collection_name"
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "stone_button": {
    "layer": 2,
    "type": "input_panel",
    "size": [ 18, 18 ],
    "$button_ref|default": "stonecutter.stone_slot_button",
    "$banner_pattern_ref|default": "stonecutter.item_panel",
    "$background_images|default": "stonecutter.stone_cell_image",
    "$background_image_control_name|default": "bg",

    "controls": [
      {
        "$background_image_control_name@$background_images": {
          "layer": 1
        }
      },
      {
        "banner_pattern@$banner_pattern_ref": {
          "layer": 6
        }
      },
      { "item_button_ref@$button_ref": {} }
    ]
  },

  "scroll_grid": {
    "type": "grid",
    "size": [ "100%", "default" ],
    "layer": 1,
    "anchor_to": "top_left",
    "anchor_from": "top_left",

    "$binding_condition|default": "visible",
    "$grid_item_template|default": "stonecutter.stone_button",

    "collection_name": "$collection_name",
    "grid_rescaling_type": "horizontal",
    "grid_item_template": "$grid_item_template",
    "bindings": [
      {
        "binding_name": "#stone_selector_total_items",
        "binding_name_override": "#maximum_grid_items",
        "binding_condition": "$binding_condition",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name"
      }
    ]
  },

  "scroll_grid_panel@common.root_panel": {
    "type": "input_panel",
    "size": [ "100%", "100%c + 2px" ],
    "controls": [
      { "grid@stonecutter.scroll_grid": {} }
    ]
  },

  "scroll_panel@common.container_scroll_panel": {
    "size": [ "100% - 12px", "100% - 12px" ],

    "$scrolling_content": "stonecutter.scroll_grid_panel",
    "$collection_name": "stones"
  },

  "stone_book_panel@common.root_panel": {
    "size": [ 146, 166 ],
    "controls": [
      {
        "bg@common.common_panel": {
          "$show_close_button": false
        }
      },
      { "scroll_panel@stonecutter.scroll_panel": {} }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region top half item slots
  //---------------------------------------------------------------------------

  "result_slot_button@common.no_coalesce_container_slot_button": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.stonecutter_result_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.stonecutter_result_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.stonecutter_result_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.stonecutter_result_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_auto_place",
        "to_button_id": "button.container_auto_place",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "button.container_auto_place",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop",
        "to_button_id": "button.drop_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop_all",
        "to_button_id": "button.drop_all",
        "mapping_type": "pressed"
      },
      {
        "to_button_id": "button.container_slot_hovered",
        "mapping_type": "pressed"
      }
    ]
  },

  "input_item_slot@common.container_item": {
    "anchor_from": "center",
    "anchor_to": "center",
    "$item_collection_name": "stonecutter_input_items"
  },

  "result_item_slot@common.container_item": {
    "anchor_from": "center",
    "anchor_to": "center",
    "$item_collection_name": "stonecutter_result_items",
    "$button_ref": "stonecutter.result_slot_button",
    "$cell_image_size": [ 26, 26 ],
    "size": [ 26, 26 ]
  },

  "input_slots_stack_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%c", "100%cm" ],
    "controls": [
      { "input_item_slot@stonecutter.input_item_slot": {} }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region right panel, inventory and stonecutter crafting
  //---------------------------------------------------------------------------

  "top_half_stack_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%c", "100%cm" ],
    "controls": [
      {
        "input_slots_holder": {
          "type": "panel",
          "size": [ "100%c", "100%c" ],
          "inherit_max_sibling_height": true,
          "controls": [
            { "input_slots_stack_panel@stonecutter.input_slots_stack_panel": {} }
          ]
        }
      },
      {
        "padding_1": {
          "type": "panel",
          "size": [ 14, 0 ]
        }
      },
      {
        "arrow_holder": {
          "type": "panel",
          "size": [ 18, 12 ],
          "inherit_max_sibling_height": true,
          "controls": [
            {
              "arrow_icon@stonecutter.arrow_icon": {
                "bindings": [
                  {
                    "binding_name": "#has_input_item",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "padding_2": {
          "type": "panel",
          "size": [ 14, 0 ]
        }
      },
      {
        "result_item_slot_holder": {
          "type": "panel",
          "size": [ "100%c", "100%c" ],
          "inherit_max_sibling_height": true,
          "controls": [
            { "result_item_slot@stonecutter.result_item_slot": {} }
          ]
        }
      }
    ]
  },

  "top_half_panel": {
    "type": "panel",
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "size": [ "100% - 14px", "50% - 22px" ],
    "offset": [ 0, 15 ],
    "controls": [
      { "top_half_stack_panel@stonecutter.top_half_stack_panel": {} }
    ]
  },

  "right_panel@common.root_panel": {
    "layer": 1,
    "controls": [
      {
        "common_panel@common.common_panel": {
          "$show_close_button": false
        }
      },
      {
        "stonecutter_screen_inventory": {
          "type": "panel",
          "layer": 2,
          "controls": [
            {
              "stonecutter_label@stonecutter.stonecutter_label": {
                "offset": [ 0, 5 ]
              }
            },
            { "top_half_panel@stonecutter.top_half_panel": {} },
            { "inventory_panel_bottom_half_with_label@common.inventory_panel_bottom_half_with_label": {} },
            { "hotbar_grid@common.hotbar_grid_template": {} }
          ]
        }
      }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region screen
  //---------------------------------------------------------------------------

  "help_button@common.help_button": {
    "layer": 5,
    "$focus_id": "help_button",
    "$focus_override_up": "FOCUS_OVERRIDE_STOP"
  },

  "toolbar_panel@common.root_panel": {
    "size": [ "100%c", 20 ],
    "controls": [
      {
        "toolbar_background@stonecutter.toolbar_background": {
          "size": [ "100%cm", "100% + 8px" ],
          "offset": [ 0, -3 ],
          "anchor_from": "top_right",
          "anchor_to": "top_right",

          "controls": [
            {
              "toolbar_stack_panel": {
                "type": "stack_panel",
                "orientation": "horizontal",

                "size": [ "default", "100% - 8px" ],
                "offset": [ 0, 3 ],
                "anchor_from": "top_middle",
                "anchor_to": "top_middle",

                "controls": [
                  {
                    "padding_1": {
                      "type": "panel",
                      "size": [ 6, 0 ]
                    }
                  },
                  {
                    "help_button_panel": {
                      "type": "panel",
                      "size": [ "100%c", "100%" ],
                      "controls": [
                        { "help_button@stonecutter.help_button": {} }
                      ]
                    }
                  },
                  {
                    "close_button_panel": {
                      "type": "panel",
                      "size": [ "100%c", "100%" ],
                      "bindings": [
                        {
                          "binding_name": "#close_button_visible",
                          "binding_name_override": "#visible"
                        }
                      ],
                      "controls": [
                        {
                          "close_button@common.light_close_button": {
                            "size": [ "100%cm", "100%cm" ],
                            "offset": [ 0, 0 ],
                            "anchor_from": "center",
                            "anchor_to": "center"
                          }
                        }
                      ]
                    }
                  },
                  {
                    "padding_2": {
                      "type": "panel",
                      "size": [ 6, 0 ]
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "toolbar_anchor": {
    "type": "panel",
    "size": [ 0, 0 ],
    "inherit_max_sibling_height": true,
    "controls": [
      {
        "toolbar_panel@stonecutter.toolbar_panel": {
          "anchor_from": "top_right",
          "anchor_to": "bottom_right"
        }
      }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region screen
  //---------------------------------------------------------------------------

  "center_fold@common.root_panel": {
    "size": [ 4, 166 ],
    "controls": [
      {
        "center_bg": {
          "type": "image",
          "texture": "textures/ui/recipe_back_panel",
          "size": [ "100% + 8px", "100% - 6px" ]
        }
      }
    ]
  },

  "screen_stack_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%c", "100%cm" ],
    "controls": [
      { "stone_book_panel@stonecutter.stone_book_panel": {} },
      { "center_fold@stonecutter.center_fold": {} },
      { "right_panel@stonecutter.right_panel": {} },
      { "toolbar_anchor@stonecutter.toolbar_anchor": {} }
    ]
  },

  "stonecutter_panel": {
    "type": "panel",
    "controls": [
      { "screen_stack_panel@stonecutter.screen_stack_panel": {} },

      { "container_gamepad_helpers@common.container_gamepad_helpers": {} },
      { "selected_item_details_factory@common.selected_item_details_factory": {} },
      { "inventory_selected_icon_button@common.inventory_selected_icon_button": {} },
      { "inventory_take_progress_icon_button@common.inventory_take_progress_icon_button": {} },
      {
        "flying_item_renderer@common.flying_item_renderer": {
          "layer": 8
        }
      }
    ]
  },

  "stonecutter_screen@common.inventory_screen_common": {
    "close_on_player_hurt": true,
    "$screen_bg_content": "common.screen_background",

    "button_mappings": "$button_mappings",

    "variables": [
      {
        "requires": "$desktop_screen",
        "$screen_content": "stonecutter.stonecutter_panel"
      },
      {
        "requires": "$pocket_screen",
        "$screen_content": "stonecutter_pocket.stonecutter_panel",
        "$button_mappings": [
          {
            "from_button_id": "button.menu_cancel",
            "to_button_id": "button.menu_exit",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_inventory_cancel",
            "to_button_id": "button.menu_exit",
            "mapping_type": "global"
          },
          {
            "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"
          },
          {
            "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_select",
            "to_button_id": "button.cursor_drop_all",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.menu_secondary_select",
            "to_button_id": "button.cursor_drop_one",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.menu_ok",
            "to_button_id": "button.cursor_drop_all",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.controller_select",
            "to_button_id": "button.cursor_drop_one",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.controller_secondary_select",
            "to_button_id": "button.cursor_drop_all",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.menu_tab_left",
            "to_button_id": "button.left_panel_tab_decrement",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_tab_right",
            "to_button_id": "button.menu_tab_right",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_alternate_tab_left",
            "to_button_id": "button.left_panel_tab_increment",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_alternate_tab_right",
            "to_button_id": "button.menu_alternate_tab_right",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.controller_secondary_select_left",
            "to_button_id": "button.controller_secondary_select_left",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_clear",
            "to_button_id": "button.menu_clear",
            "mapping_type": "focused"
          }
        ]
      }
    ],

    "$button_mappings|default": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_inventory_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      },
      {
        "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"
      },
      {
        "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_select",
        "to_button_id": "button.cursor_drop_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.cursor_drop_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.cursor_drop_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.cursor_drop_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "button.cursor_drop_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select_left",
        "to_button_id": "button.focus_left",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.controller_secondary_select_right",
        "to_button_id": "button.focus_right",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.chat",
        "to_button_id": "button.chat",
        "mapping_type": "global"
      }
    ]
  }
}

// #endregion