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

{
  "namespace": "smithing_table",

  //---------------------------------------------------------------------------
  // #region icon and text area (top quarter of screen)
  //---------------------------------------------------------------------------

  "smithing_image": {
    "type": "image"
  },

  "ingot_image@smithing_table.smithing_image": {
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "layer": 1,
    "offset": [ 1, 1 ],
    "size": [ 16, 16 ],
    "texture": "textures/ui/ingot_image"
  },

  "smithing_icon": {
    "type": "image",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "texture": "textures/ui/smithing_icon",
    "size": [ 30, 30 ],
    "layer": 1
  },

  "upgrade_label": {
    "type": "label",
    "color": "$title_text_color",
    "anchor_from": "center",
    "anchor_to": "center",
    "size": [ "80%", "30%" ],
    "offset": [ "30%", 0 ],
    "layer": 1,
    "text": "container.smithing_table.upgrade"
  },

  // panel to position the top quarter of screen
  "icon_and_text_panel": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "65%", "40%" ],
    "offset": [ "7%", 0 ],
    "controls": [
      { "smithing_icon_panel@smithing_table.smithing_icon_panel": { } },
      { "upgrade_label@smithing_table.upgrade_label": { } }
    ]
  },

  // panel to position the icon
  "smithing_icon_panel": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      { "smithing_icon@smithing_table.smithing_icon": { } }
    ]
  },


  //#endregion

  //---------------------------------------------------------------------------
  // #region recipe (input, material and results) area (2nd quarter of screen)
  //---------------------------------------------------------------------------

  "plus_sign_icon": {
    "type": "image",
    "texture": "textures/ui/smithing-table-plus",
    "size": [ 13, 13 ]
  },

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

  "cross_out_icon": {
    "type": "image",
    "texture": "textures/ui/crossout",
    "size": [ 18, 12 ],
    "bindings": [
      {
        "binding_name": "#cross_out_icon",
        "binding_name_override": "#visible"
      }
    ]
  },

  //#endregion

  "smithing_table_output_slot_button@common.container_slot_button_prototype": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.smithing_table_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.smithing_table_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.smithing_table_take_half_place_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.smithing_table_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.smithing_table_coalesce_stack",
        "mapping_type": "double_pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.smithing_table_coalesce_stack",
        "mapping_type": "double_pressed"
      },
      {
        "to_button_id": "button.container_slot_hovered",
        "mapping_type": "pressed"
      }
    ]
  },

  "smithing_table_item_slot": {
    "type": "panel",
    "controls": [
      {
        "container_item@common.container_item": {
          "anchor_to": "center",
          "anchor_from": "center"
        }
      }
    ]
  },

  "recipe_grid": {
    "type": "grid",
    "size": [ "83.5%", "90%" ],
    "anchor_from": "center",
    "anchor_to": "center",
    "grid_dimensions": [ 5, 1 ],
    "controls": [
      {
        "input_item_slot@smithing_table.smithing_table_item_slot": {
          "grid_position": [ 0, 0 ],
          "$item_collection_name": "smithing_table_input_items",

          "$focus_id_binding_type": "none",
          "$focus_id": "smithing_table_input",

          "$focus_override_right_binding_type": "none",
          "$focus_override_right": "smithing_table_material"
        }
      },
      {
        "plus": {
          "type": "panel",
          "grid_position": [ 1, 0 ],
          "controls": [
            { "plus_sign_icon@smithing_table.plus_sign_icon": {} }
          ]
        }
      },
      {
        "material_item_slot@smithing_table.smithing_table_item_slot": {
          "grid_position": [ 2, 0 ],
          "$item_collection_name": "smithing_table_material_items",
          "$cell_overlay_ref": "smithing_table.ingot_image",

          "$focus_id_binding_type": "none",
          "$focus_id": "smithing_table_material",

          "$focus_override_left_binding_type": "none",
          "$focus_override_left": "smithing_table_input",

          "$focus_override_right_binding_type": "none",
          "$focus_override_right": "smithing_table_result"
        }
      },
      {
        "yields": {
          "type": "panel",
          "grid_position": [ 3, 0 ],
          "controls": [
            { "arrow_icon@smithing_table.arrow_icon": {} },
            {
              "cross_out_icon@smithing_table.cross_out_icon": {
                "layer": 1
              }
            }
          ]
        }
      },
      {
        "result_item_slot@smithing_table.smithing_table_item_slot": {
          "grid_position": [ 4, 0 ],
          "$item_collection_name": "smithing_table_result_items",
          "$button_ref": "smithing_table.smithing_table_output_slot_button",

          "$focus_id_binding_type": "none",
          "$focus_id": "smithing_table_result",

          "$focus_override_left_binding_type": "none",
          "$focus_override_left": "smithing_table_material"
        }
      }
    ]
  },

  "recipe_panel": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "100%", "60%" ],
    "offset": [ 0, "40%" ],
    "controls": [
      { "recipe_grid@smithing_table.recipe_grid": { } }
    ]
  },

  // #endregion

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

  "top_half_panel": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "100% - 14px", "50% - 14px" ],
    "offset": [ 7, 7 ],
    "controls": [
      { "icon_and_text_panel@smithing_table.icon_and_text_panel": { } },
      { "recipe_panel@smithing_table.recipe_panel": { } }
    ]
  },

  "smithing_table_panel": {
    "type": "panel",
    "controls": [
      { "container_gamepad_helpers@common.container_gamepad_helpers": {} },
      {
        "flying_item_renderer@common.flying_item_renderer": {
          "layer": 8
        }
      },
      { "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": {} },
            {
              "smithing_table_screen_inventory": {
                "type": "panel",
                "layer": 2,
                "controls": [
                  { "top_half_panel@smithing_table.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": {} }
          ]
        }
      }
    ]
  },
  "smithing_table_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": "smithing_table.smithing_table_panel",
        "$screen_bg_content": "common.screen_background"
      },
      {
        "requires": "$pocket_screen",
        "$screen_content": "smithing_table_pocket.smithing_table_panel"
      }
    ]
  }
}

// #endregion