/********************************************************
+*   (c) Mojang. All rights reserved                       *
+*   (c) Microsoft. All rights reserved.                   *
+*********************************************************/
{
  "namespace": "grindstone",

  "title_label": {
    "type": "label",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "text": "container.repairAndDisenchant",
    "color": "$title_text_color"
  },

  "arrow_icon": {
    "type": "image",
    "texture": "textures/ui/arrow_large",
    "size": [ 22, 15 ]
  },

  "cross_out_icon": {
    "type": "image",
    "texture": "textures/ui/crossout",
    "size": [ 15, 15 ],
    "bindings": [
      {
        "binding_name": "#cross_out_icon",
        "binding_name_override": "#visible"
      }
    ]
  },

  "grindstone_output_slot_button@common.container_slot_button_prototype": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.grindstone_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.grindstone_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_back",
        "to_button_id": "button.grindstone_take_all_place_all",
        "mapping_type": "pressed",
        "ignored": "(not $is_ps4)"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.grindstone_take_half_place_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.grindstone_take_half_place_one",
        "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"
      },
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.grindstone_coalesce_stack",
        "mapping_type": "double_pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.grindstone_coalesce_stack",
        "mapping_type": "double_pressed"
      },
      {
        "to_button_id": "button.container_slot_hovered",
        "mapping_type": "pressed"
      }
    ]
  },

  "grindstone_item_slot": {
    "type": "panel",
    "size": [ "100%c", "100%c" ],
    "controls": [
      {
        "container_item@common.container_item": {
          "anchor_to": "center",
          "anchor_from": "center"
        }
      }
    ]
  },

  "grindstone_middle_panel": {
    "type": "panel",
    "size": [ 18, 41 ],
    "controls": [
      {
        "input_item_slot@grindstone.grindstone_item_slot": {
          "anchor_from": "top_middle",
          "anchor_to": "top_middle",
          "offset": [ 0, 1 ],
          "$item_collection_name": "grindstone_input_items",

          "$focus_id_binding_type": "none",
          "$focus_id": "grindstone_input",

          "$focus_override_down_binding_type": "none",
          "$focus_override_down": "grindstone_additional",

          "$focus_override_right_binding_type": "none",
          "$focus_override_right": "grindstone_result"
        }
      },
      {
        "additional_item_slot@grindstone.grindstone_item_slot": {
          "anchor_from": "bottom_middle",
          "anchor_to": "bottom_middle",
          "offset": [ 0, -1 ],
          "$item_collection_name": "grindstone_additional_items",

          "$focus_id_binding_type": "none",
          "$focus_id": "grindstone_additional",

          "$focus_override_up_binding_type": "none",
          "$focus_override_up": "grindstone_input",

          "$focus_override_right_binding_type": "none",
          "$focus_override_right": "grindstone_result"
        }
      }
    ]
  },

  "grindstone_slots_panel": {
    "type": "panel",
    "size": [ 90, 56 ],
    "controls": [
      {
        "grindstone_middle_panel@grindstone.grindstone_middle_panel": {
          "anchor_from": "left_middle",
          "anchor_to": "left_middle"
        }
      },
      {
        "yields": {
          "type": "panel",
          "anchor_from": "center",
          "anchor_to": "center",
          "size": [ 22, 15 ],
          "controls": [
            { "arrow_icon@grindstone.arrow_icon": {} },
            {
              "cross_out_icon@grindstone.cross_out_icon": {
                "layer": 1
              }
            }
          ]
        }
      },
      {
        "result_item_slot@grindstone.grindstone_item_slot": {
          "anchor_from": "right_middle",
          "anchor_to": "right_middle",
          "$item_collection_name": "grindstone_result_items",
          "$button_ref": "grindstone.grindstone_output_slot_button",

          "$focus_id_binding_type": "none",
          "$focus_id": "grindstone_result",

          "$focus_override_left_binding_type": "none",
          "$focus_override_left": "grindstone_additional"
        }
      }
    ]
  },

  "top_half_panel": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "100% - 8px", "50% - 8px" ],
    "offset": [ 4, 6 ],
    "controls": [
      {
        "title_label@grindstone.title_label": {
          "offset": [ 4, 2 ]
        }
      },
      {
        "grindstone_slots_panel@grindstone.grindstone_slots_panel": {
          "offset": [ 0, 4 ]
        }
      }
    ]
  },

  "grindstone_panel": {
    "type": "panel",
    "controls": [
      { "container_gamepad_helpers@common.container_gamepad_helpers": {} },
      { "selected_item_details_factory@common.selected_item_details_factory": {} },
      { "item_lock_notification_factory@common.item_lock_notification_factory": {} },
      {
        "root_panel@common.root_panel": {
          "layer": 1,
          "controls": [
            { "common_panel@common.common_panel": {} },
            {
              "grindstone_screen_inventory": {
                "type": "panel",
                "layer": 2,
                "controls": [
                  { "top_half_panel@grindstone.top_half_panel": {} },
                  { "inventory_panel_bottom_half_with_label@common.inventory_panel_bottom_half_with_label": {} },
                  { "hotbar_grid@common.hotbar_grid_template": {} },
                  { "inventory_take_progress_icon_button@common.inventory_take_progress_icon_button": {} }
                ]
              }
            },
            { "inventory_selected_icon_button@common.inventory_selected_icon_button": {} },
            { "gamepad_cursor@common.gamepad_cursor_button": {} }
          ]
        }
      },
      { "flying_item_renderer@common.flying_item_renderer": { "layer": 15 } }
    ]
  },

  "grindstone_screen@common.inventory_screen_common": {
    "$close_on_player_hurt|default": true,
    "close_on_player_hurt": "$close_on_player_hurt",
    "variables": [
      {
        "requires": "$desktop_screen",
        "$screen_content": "grindstone.grindstone_panel",
        "$screen_bg_content": "common.screen_background",
        "$screen_background_alpha": 0.4
      },
      {
        "requires": "$pocket_screen",
        "$screen_content": "grindstone_pocket.grindstone_panel",
        "$screen_bg_content": "common.screen_background",
        "$screen_background_alpha": 0.4
      }
    ]
  }
}
