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

{
  "namespace": "mob_effect",
  //---------------------------------------------------------------------------
  // Controls - General
  //---------------------------------------------------------------------------
  "effect_background": {
    "type": "image",
    "texture": "textures/ui/effect_background"
  },
  //---------------------------------------------------------------------------
  // Controls - Right Handed
  //---------------------------------------------------------------------------
  "main_background": {
    "type": "image",
    "size": "$mob_effect_screen_size",
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "offset": [ -4, 4 ],
    "texture": "textures/ui/mob_effect_background"
  },
  "button_background": {
    "type": "image",
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "size": [ 25, 25 ],
    "offset": [ "-90%", 4 ],
    "texture": "textures/ui/pocket_tab_left_side"
  },
  "effect_name": {
    "type": "label",
    "color": "$dark_button_default_text_color",
    "shadow": true,
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "offset": [ 27, 5 ],
    "text_alignment": "left",
    "text": "#mob_effect_name",
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#mob_effect_name",
        "binding_collection_name": "mob_effects_collection",
        "binding_condition": "visible"
      }
    ]
  },
  "effect_timer": {
    "type": "label",
    "anchor_from": "bottom_left",
    "anchor_to": "bottom_left",
    "offset": [ 27, -5 ],
    "text": "#mob_effect_timer",
    "color": "$dark_button_secondary_default_text_color",
    "text_alignment": "left",
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#mob_effect_timer",
        "binding_collection_name": "mob_effects_collection",
        "binding_condition": "always_when_visible"
      }
    ]
  },
  "effect_icon": {
    "type": "image",
    "size": [ "60%", "60%" ],
    "offset": [ -105, -1 ],
    "texture": "#texture",
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#texture",
        "binding_collection_name": "mob_effects_collection",
        "binding_condition": "visible"
      }
    ]
  },
  "mob_effect_grid_panel": {
    "type": "panel",
    "size": [ "100%", "100%c" ],
    "controls": [
      {
        "mob_effect_grid@mob_effect.mob_effect_grid": { }
      }
    ]
  },
  "mob_effect_grid": {
    "type": "grid",
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "size": [ 300, "default" ],
    "offset": [ "-45% + 175px", 0 ],
    "grid_item_template": "mob_effect.mob_effect_grid_item",
    "grid_dimension_binding": "#mob_effect_grid_size",
    "collection_name": "mob_effects_collection",
    "bindings": [
      {
        "binding_name": "#mob_effect_grid_size"
      }
    ]
  },
  //---------------------------------------------------------------------------
  // Controls - Left Handed
  //---------------------------------------------------------------------------
  "main_background_left_handed": {
    "type": "image",
    "size": "$mob_effect_screen_size",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "offset": [ 4, 4 ],
    "texture": "textures/ui/mob_effect_background"
  },
  "button_background_left_handed": {
    "type": "image",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ 25, 25 ],
    "offset": [ "90% + 2px", 4 ],
    "texture": "textures/ui/pocket_tab_right_side"
  },
  "effect_name_left_handed": {
    "type": "label",
    "color": "$dark_button_default_text_color",
    "shadow": true,
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "offset": [ -27, 5 ],
    "text_alignment": "left",
    "text": "#mob_effect_name",
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#mob_effect_name",
        "binding_collection_name": "mob_effects_collection",
        "binding_condition": "visible"
      }
    ]
  },
  "effect_timer_left_handed": {
    "type": "label",
    "anchor_from": "bottom_right",
    "anchor_to": "bottom_right",
    "offset": [ -27, -5 ],
    "text": "#mob_effect_timer",
    "color": "$light_button_secondary_default_text_color",
    "text_alignment": "left",
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#mob_effect_timer",
        "binding_collection_name": "mob_effects_collection",
        "binding_condition": "always_when_visible"
      }
    ]
  },
  "effect_icon_left_handed": {
    "type": "image",
    "size": [ "60%", "60%" ],
    "offset": [ 45, -1 ],
    "texture": "#texture",
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#texture",
        "binding_collection_name": "mob_effects_collection",
        "binding_condition": "visible"
      }
    ]
  },
  "mob_effect_grid_panel_left_handed": {
    "type": "panel",
    "size": [ "100%", "100%c" ],
    "controls": [
      {
        "mob_effect_grid@mob_effect.mob_effect_grid_left_handed": {
        }
      }
    ]
  },
  "mob_effect_grid_left_handed": {
    "type": "grid",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ 150, "default" ],
    "offset": [ "45% - 60px", 4 ],
    "grid_item_template": "mob_effect.mob_effect_grid_item",
    "grid_dimension_binding": "#mob_effect_grid_size",
    "collection_name": "mob_effects_collection",
    "bindings": [
      {
        "binding_name": "#mob_effect_grid_size"
      }
    ]
  },


  //---------------------------------------------------------------------------
  // CONTENT - General
  //---------------------------------------------------------------------------
  "mob_effect_grid_item": {
    "type": "panel",
    "size": [ 240, 30 ],
    "controls": [
      { "bg@mob_effect.effect_background": { } },
      { "name@mob_effect.effect_name": { "layer": 1 } },
      { "timer@mob_effect.effect_timer": { "layer": 1 } },
      { "icon@mob_effect.effect_icon": { "layer": 1 } }
    ]
  },
  //---------------------------------------------------------------------------
  // CONTENT - Right Handed
  //---------------------------------------------------------------------------
  "mob_effect_list_content_panel": {
    "type": "panel",
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "size": [ "100%", "90% - 4px" ],
    "clips_children": true,
    "offset": [ -4, 4 ],
    "controls": [
      {
        "scrolling_panel@common.scrolling_panel": {
          "size": [ "100%-2px", "100%-2px" ],
          "offset": [ "default", "4px" ],
          "anchor_from": "top_middle",
          "anchor_to": "top_middle",
          "$scrolling_content": "mob_effect.mob_effect_grid_panel",
          "$show_background": false,
          "$scroll_size": [ "8px", "100%" ],
          "$scrolling_pane_size": [ "100%", "100%-2px" ],
          "$scroll_box_mouse_image_control": "common-classic.button_state_default",
          "$always_handle_scrolling": true
        }
      }
    ]
  },
  "mob_effect_screen_close_button@common.legacy_pocket_close_button": {
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "size": [ 18, 18 ],
    "offset": [ "-90% - 3px", 7.5 ],
    "$pressed_button_name": "button.menu_continue"
  },
  "close_button_panel": {
    "type": "panel",
    "controls": [
      { "bg@mob_effect.button_background": { } },
      { "close_button@mob_effect.mob_effect_screen_close_button": { } }
    ]
  },
  "mob_effect_content": {
    "type": "panel",
    "controls": [
      { "bg@mob_effect.main_background": { } },
      { "close_panel@mob_effect.close_button_panel": { } },
      { "content_panel@mob_effect.mob_effect_list_content_panel": { } }
    ]
  },
  //---------------------------------------------------------------------------
  // CONTENT - Left Handed
  //---------------------------------------------------------------------------
  "mob_effect_list_content_panel_left_handed": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "90%", "90% - 4px" ],
    "clips_children": true,
    "offset": [ -4, 4 ],
    "controls": [
      {
        "scrolling_panel@common.scrolling_panel": {
          "$scrolling_content": "mob_effect.mob_effect_grid_panel_left_handed",
          "$show_background": false,
          "$scroll_size": [ "8px", "100% - 4px" ],
          "$scrolling_pane_size|default": [ "100%", "default" ],
          "$scroll_box_mouse_image_control": "common-classic.button_state_default",
          "anchor_from": "top_middle",
          "anchor_to": "top_middle",
          "offset": [ "default", "2px" ]
        }
      }
    ]
  },
  "mob_effect_screen_close_button_left_handed@common.legacy_pocket_close_button": {
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ 18, 18 ],
    "offset": [ "90% + 4px", 7.5 ],
    "$pressed_button_name": "button.menu_continue"
  },
  "close_button_panel_left_handed": {
    "type": "panel",
    "controls": [
      { "l_bg@mob_effect.button_background_left_handed": { } },
      { "l_close_button@mob_effect.mob_effect_screen_close_button_left_handed": { } }
    ]
  },
  "mob_effect_content_left_handed": {
    "type": "panel",
    "controls": [
      { "l_bg@mob_effect.main_background_left_handed": { } },
      { "l_close_panel@mob_effect.close_button_panel_left_handed": { } },
      { "l_content_panel@mob_effect.mob_effect_list_content_panel_left_handed": { } }
    ]
  },

  //---------------------------------------------------------------------------
  // Screen
  //---------------------------------------------------------------------------
  "main_screen": {
    "type": "panel",
    "variables": [
      {
        "requires": "(not $is_left_handed)",
        "$main_panel": "mob_effect.mob_effect_content"
      },
      {
        "requires": "$is_left_handed",
        "$main_panel": "mob_effect.mob_effect_content_left_handed"
      }
    ],
    "controls": [
      { "main_screen@$main_panel": { } }
    ]
  },
  "mob_effect_screen@common.base_screen": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_continue",
        "mapping_type": "global"
      },
	    {
		    "from_button_id": "button.mobeffects",
		    "to_button_id": "button.menu_continue",
		    "mapping_type": "global"
	    }
    ],
    "close_on_player_hurt": true,
    "$screen_content": "mob_effect.main_screen"
  }
}