{
  "namespace": "gameplay",

  //---------------------------------------------------------------------------
  // Bundle controls
  //---------------------------------------------------------------------------

  "bundle_selected_item_icon@common.item_renderer": {
    "size": "$item_renderer_size",
    "offset": "$item_renderer_offset",
    "layer": 51,
    "bindings": [
      {
        "binding_name": "#bundle_selected_item_visible",
        "binding_name_override": "#visible",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name"
      },
      {
        "binding_name": "#bundle_item_renderer_data",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name",
        "binding_condition": "$item_renderer_binding_condition"
      }
    ]
  },

  "bundle_open_icon_back@common.item_renderer": {
    "size": "$item_renderer_size",
    "offset": "$item_renderer_offset",
    "layer": 52,
    "bindings": [
      {
        "binding_name": "#bundle_selected_item_visible",
        "binding_name_override": "#visible",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name"
      },
      {
        "binding_name": "#bundle_open_back",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name",
        "binding_condition": "$item_renderer_binding_condition"
      }
    ]
  },

  "bundle_open_icon_front@common.item_renderer": {
    "size": "$item_renderer_size",
    "offset": "$item_renderer_offset",
    "layer": 53,
    "bindings": [
      {
        "binding_name": "#bundle_selected_item_visible",
        "binding_name_override": "#visible",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name"
      },
      {
        "binding_name": "#bundle_open_front",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name",
        "binding_condition": "$item_renderer_binding_condition"
      }
    ]
  },

  "bundle_selected_item_background": {
    "type": "panel",
    "size": [ "100%+3px", "100%+3px" ],
    "controls": [
      {
        "bundle_selected_item_background_colour_green@common.highlight_slot": {
          "layer": 1,
          "alpha": 1.0,
          "size": [ "100%-5px", "100%-5px" ],
          "bindings": [
            {
              "binding_name": "(not #using_touch)",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "bundle_selected_item_background_colour": {
          "type": "image",
          "texture": "textures/ui/recipe_book_touch_cell_selected",
          "layer": 1,
          "size": [ "100%", "100%" ],
          "bindings": [
            {
              "binding_name": "#using_touch",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "bundle_selected_item_frame@common.pocket_ui_highlight_slot": {
          "layer": 4,
          "bindings": [
            {
              "binding_name": "#using_touch",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "bundle_selected_item_panel": {
    "type": "panel",
    "size": [ "100% - 4px", "100% - 4px" ],
    "layer": 1,
    "controls": [
      {
        "bundle_selected_item_background@gameplay.bundle_selected_item_background": {
          "size": [ "100% + 7px", "100% + 7px" ],
          "layer": 1
        }
      },
      {
        "bundle_open_icon_back@gameplay.bundle_open_icon_back": {
          "layer": 2
        }
      },
      {
        "bundle_selected_item_icon@gameplay.bundle_selected_item_icon": {
          "layer": 3
        }
      },
      {
        "bundle_open_icon_front@gameplay.bundle_open_icon_front": {
          "layer": 4
        }
      },
      {
        "storage_bar@common.storage_bar": {
          "layer": 5
        }
      }
    ],
    "bindings": [
      {
        "binding_name": "#bundle_selected_item_visible",
        "binding_name_override": "#visible",
        "binding_type": "collection",
        "binding_collection_name": "$item_collection_name"
      }
    ]
  },

  "bundle_slot_panel": {
    "type": "panel",
    "size": [ "100%", "100%" ],
    "layer": 1,
    "controls": [
      {
        "bundle_selected_item_panel@gameplay.bundle_selected_item_panel": {
          "layer": 1
        }
      }
    ]
  },

  "bundle_cell_image": {
    "type": "panel",
    "controls": [
      {
        "background_panel": {
          "type": "panel",
          "controls": [
            {
              "item_background": {
                "type": "image",
                "texture": "textures/ui/bundle_item_background",
                "layer": 1,
                "size": [ "100%", "100%" ]
              }
            }
          ]
        }
      },
      {
        "highlight_panel": {
          "type": "panel",
          "controls": [
            {
              "bundle_selected_item_background_colour_green@common.highlight_slot": {
                "layer": 1,
                "alpha": 1.0,
                "size": [ "100%", "100%" ],
                "visible": false,
                "bindings": [
                  {
                    "binding_name": "(not #using_touch)",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            },
            {
              "bundle_selected_item_background_border_white": {
                "type": "image",
                "texture": "textures/ui/focus_border_white",
                "layer": 2,
                "alpha": 1.0,
                "size": [ "100%", "100%" ],
                "visible": false,
                "bindings": [
                  {
                    "binding_name": "(not #using_touch)",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            },
            {
              "bundle_selected_item_background_colour_blue@common.cell_image_selected": {
                "layer": 1,
                "visible": false,
                "bindings": [
                  {
                    "binding_name": "#using_touch",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            }
          ],
          "bindings": [
            {
              "binding_name": "#is_selected_bundle_item_slot",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name"
            }
          ]
        }
      }
    ]
  },

  "bundle_tooltip_slot_button@common.container_slot_button_prototype": {
    "$pressed_button_name": "button.tapped_bundle_item_icon",
    "size": [ "100%", "100%" ],
    "sound_name": "random.click",
    "sound_volume": 1.0,
    "sound_pitch": 1.0,
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.hide_bundle_tooltip",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_back",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed",
        "ignored": "(not $is_ps4)"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_auto_place",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop_all",
        "to_button_id": "$pressed_button_name",
        "mapping_type": "pressed"
      }
    ]
  },

  "bundle_tooltip_slot_pocket": {
    "type": "panel",
    "size": [ 30, 30 ],
    "controls": [
      {
        "item_in_bundle_tooltip_pocket@common.pocket_ui_container_item": {
          "size": [ 28, 28 ],
          "$background_images|default": "gameplay.bundle_cell_image",
          "$button_ref|default": "gameplay.bundle_tooltip_slot_button",
          "bindings": [
            {
              "binding_name": "#show_bundle_item_slot",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name"
            }
          ]
        }
      },
      {
        "more_hidden_items_label": {
          "size": [ "default", 10 ],
          "type": "label",
          "color": "$item_stack_count_color",
          "layer": 2,
          "text": "#more_hidden_items_text",
          "bindings": [
            {
              "binding_name": "#is_hidden_items_label",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name"
            },
            {
              "binding_name": "#more_hidden_items_text",
              "binding_condition": "visible"
            }
          ]
        }
      }
    ]
  },

  "bundle_tooltip_slot_classic": {
    "type": "panel",
    "size": [ 20, 20 ],
    "controls": [
      {
        "item_in_bundle_tooltip_pocket@common.container_item": {
          "size": [ 18, 18 ],
          "$background_images|default": "gameplay.bundle_cell_image",
          "$button_ref|default": "gameplay.bundle_tooltip_slot_button",
          "bindings": [
            {
              "binding_name": "#show_bundle_item_slot",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name"
            }
          ]
        }
      },
      {
        "more_hidden_items_label": {
          "size": [ "default", 10 ],
          "type": "label",
          "color": "$item_stack_count_color",
          "layer": 2,
          "text": "#more_hidden_items_text",
          "bindings": [
            {
              "binding_name": "#is_hidden_items_label",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name"
            },
            {
              "binding_name": "#more_hidden_items_text",
              "binding_condition": "visible"
            }
          ]
        }
      }
    ]
  },

  "bundle_tooltip": {
    "type": "panel",
    "size": [ "100%cm", "100%cm" ],
    "min_size": "$tooltip_size",
    "layer": 50,
    "controls": [
      {
        "background": {
          "type": "image",
          "texture": "textures/ui/purpleBorder",
          "layer": 1,
          "size": [ "100%sm + 10px", "100%sm + 10px" ],
          "anchor_from": "top_left",
          "anchor_to": "top_left",
          "controls": [
            {
              "empty_button@common.button": {
                "$pressed_button_name": "button.tapped_bundle_tooltip",
                "size": [ "100%", "100%" ],
                "layer": 1,
                "$empty_button_enabled|default": false,
                "enabled": "$empty_button_enabled",
                "controls": [
                  { "default@common.empty_panel": {} },
                  { "hover@common.empty_panel": {} },
                  { "pressed@common.empty_panel": {} }
                ],
                "variables": [
                  {
                    "requires": "$touch",
                    "$empty_button_enabled": true
                  },
                  {
                    "requires": "(not $touch)",
                    "$empty_button_enabled": false
                  }
                ]
              }
            },
            {
              "selected_item_tooltip@common.item_panel_image": {
                "alpha": 1,
                "anchor_to": "bottom_middle",
                "anchor_from": "top_middle",
                "visible": "#visible",
                "controls": [
                  {
                    "item_text_label@common.item_text_label": {
                      "alpha": 1,
                      "text": "#selected_bundle_item_text",
                      "bindings": [
                        {
                          "binding_name": "#selected_bundle_item_text",
                          "binding_condition": "visible"
                        }
                      ]
                    }
                  }
                ],
                "bindings": [
                  {
                    "binding_name": "#bundle_has_selected_item",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "header_stack": {
          "type": "stack_panel",
          "orientation": "horizontal",
          "size": [ "default", 15 ],
          "offset": [ 5, 5 ],
          "anchor_from": "top_left",
          "anchor_to": "top_left",
          "layer": 2,
          "controls": [
            {
              "bundle_label": {
                "type": "label",
                "color": "$main_header_text_color",
                "min_size": "$bundle_label_size",
                "layer": 4,
                "anchor_from": "top_left",
                "anchor_to": "top_left",
                "text": "#bundle_name",
                "enable_profanity_filter": true,
                "bindings": [
                  {
                    "binding_name": "#bundle_name",
                    "binding_condition": "visible"
                  }
                ],
                "variables": [
                  {
                    "requires": "$desktop_screen",
                    "$bundle_label_size": [ 77, "default" ]
                  },
                  {
                    "requires": "$pocket_screen",
                    "$bundle_label_size": [ 117, "default" ]
                  }
                ]
              }
            },
            {
              "close_button@common.close_button": {
                "$pressed_button_name": "button.hide_bundle_tooltip",
                "size": [ 8, 8 ],
                "layer": 2,
                "button_mappings": [
                  {
                    "to_button_id": "$pressed_button_name",
                    "mapping_type": "pressed"
                  },
                  {
                    "from_button_id": "button.menu_ok",
                    "to_button_id": "$pressed_button_name",
                    "mapping_type": "focused"
                  },
                  {
                    "from_button_id": "button.menu_select",
                    "to_button_id": "$pressed_button_name",
                    "mapping_type": "pressed"
                  },
                  {
                    "from_button_id": "button.menu_up",
                    "to_button_id": "$pressed_button_name",
                    "mapping_type": "global"
                  }
                ],
                "controls": [
                  {
                    "default@common.close_button_panel": {
                      "$close_button_texture": "textures/ui/close_button_default_light",
                      "$button_alpha": "$default_button_alpha"

                    }
                  },
                  {
                    "hover@common.close_button_panel": {
                      "$close_button_texture": "textures/ui/close_button_hover_light"
                    }
                  },
                  {
                    "pressed@common.close_button_panel": {
                      "$close_button_texture": "textures/ui/close_button_pressed_light"
                    }
                  }
                ],
                "bindings": [
                  {
                    "binding_name": "#show_bundle_tooltip_pocket",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "wrapper": {
          "type": "panel",
          "anchor_to": "top_left",
          "anchor_from": "top_left",
          "size": [ "100%sm", "100%c" ],
          "controls": [
            {
              "vertical_layout_stack": {
                "type": "stack_panel",
                "orientation": "vertical",
                "size": [ "100%", "100%c" ],
                "anchor_from": "top_left",
                "anchor_to": "top_left",
                "layer": 2,
                "controls": [
                  {
                    "header_padding": {
                      "type": "panel",
                      "layer": 3,
                      "size": [ 0, 18 ],
                      "offset": [ 5, 100 ]
                    }
                  },
                  {
                    "horisontal_layout_stack": {
                      "type": "stack_panel",
                      "orientation": "horizontal",
                      "size": [ "100%", "100%c" ],
                      "layer": 3,
                      "controls": [
                        {
                          "left_padding": {
                            "type": "panel",
                            "size": "$tooltip_body_padding_size",
                            "layer": 4
                          }
                        },
                        {
                          "body_stack": {
                            "type": "stack_panel",
                            "orientation": "vertical",
                            "size": [ "100%c", "100%c" ],
                            "anchor_from": "bottom_left",
                            "anchor_to": "bottom_left",
                            "layer": 4,
                            "controls": [
                              {
                                "item_grid": {
                                  "type": "grid",
                                  "layer": 3,
                                  "grid_dimension_binding": "#bundle_tooltip_grid_dimensions",
                                  "collection_name": "bundle_items",
                                  "grid_item_template": "$bundle_tooltip_slot_type",
                                  "$item_collection_name": "bundle_items",
                                  "bindings": [
                                    {
                                      "binding_name": "#bundle_tooltip_grid_dimensions",
                                      "binding_condition": "always_when_visible"
                                    }
                                  ],
                                  "variables": [
                                    {
                                      "requires": "$desktop_screen",
                                      "$bundle_tooltip_slot_type": "gameplay.bundle_tooltip_slot_classic"
                                    },
                                    {
                                      "requires": "$pocket_screen",
                                      "$bundle_tooltip_slot_type": "gameplay.bundle_tooltip_slot_pocket"
                                    }
                                  ]
                                }
                              },
                              {
                                "info_message": {
                                  "type": "label",
                                  "layer": 3,
                                  "color": "$bundle_info_description_color",
                                  "text": "item.bundle.empty.description",
                                  "size": "$info_message_size",

                                  "bindings": [
                                    {
                                      "binding_name": "#is_selected_bundle_empty",
                                      "binding_name_override": "#visible"
                                    }
                                  ],
                                  "variables": [
                                    {
                                      "requires": "$desktop_screen",
                                      "$info_message_size": [ 77, "default" ]
                                    },
                                    {
                                      "requires": "$pocket_screen",
                                      "$info_message_size": [ 117, "default" ]
                                    }
                                  ]
                                }
                              },
                              {
                                "footer_panel": {
                                  "type": "panel",
                                  "layer": 3,
                                  "anchor_from": "bottom_middle",
                                  "anchor_to": "bottom_middle",
                                  "size": "$tooltip_footer_size",
                                  "controls": [
                                    {
                                      "weight_bar": {
                                        "type": "panel",
                                        "layer": 4,
                                        "anchor_from": "bottom_middle",
                                        "anchor_to": "bottom_middle",
                                        "offset": [ 0, 3 ],
                                        "size": "$weight_bar_size",
                                        "controls": [
                                          {
                                            "empty_message": {
                                              "type": "label",
                                              "color": "$sub_header_text_color",
                                              "layer": 5,
                                              "text": "item.bundle.empty",
                                              "shadow": true,
                                              "bindings": [
                                                {
                                                  "binding_name": "#is_selected_bundle_empty",
                                                  "binding_name_override": "#visible"
                                                }
                                              ]
                                            }
                                          },
                                          {
                                            "weight_bar_fill": {
                                              "type": "image",
                                              "layer": 5,
                                              "texture": "textures/ui/container_weight_bar_fill",
                                              "clip_direction": "left",
                                              "clip_pixelperfect": false,
                                              "bindings": [
                                                {
                                                  "binding_name": "#bundle_weight_bar_ratio",
                                                  "binding_name_override": "#clip_ratio",
                                                  "binding_condition": "always_when_visible"
                                                },
                                                {
                                                  "binding_name": "(not #is_selected_bundle_full)",
                                                  "binding_name_override": "#visible"
                                                }
                                              ]
                                            }
                                          },
                                          {
                                            "weight_bar_full": {
                                              "type": "image",
                                              "layer": 5,
                                              "texture": "textures/ui/container_weight_bar_full",
                                              "controls": [
                                                {
                                                  "full_label": {
                                                    "type": "label",
                                                    "color": "$sub_header_text_color",
                                                    "layer": 2,
                                                    "text": "item.bundle.full",
                                                    "shadow": true
                                                  }
                                                }
                                              ],
                                              "bindings": [
                                                {
                                                  "binding_name": "#is_selected_bundle_full",
                                                  "binding_name_override": "#visible"
                                                }
                                              ]
                                            }
                                          },
                                          {
                                            "weight_bar_border": {
                                              "type": "image",
                                              "texture": "textures/ui/empty_stack_progress_bar",
                                              "layer": 5
                                            }
                                          }
                                        ],
                                        "variables": [
                                          {
                                            "requires": "$desktop_screen",
                                            "$weight_bar_size": [ 76, 12 ]
                                          },
                                          {
                                            "requires": "$pocket_screen",
                                            "$weight_bar_size": [ 112, 12 ]
                                          }
                                        ]
                                      }
                                    }
                                  ]
                                }
                              }
                            ]
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ],
    "variables": [
      {
        "requires": "$desktop_screen",
        "$tooltip_size": [ 86, 58 ],
        "$tooltip_body_padding_size": [ "50% - 34px", 1 ],
        "$tooltip_footer_size": [ 76, 15 ]
      },
      {
        "requires": "$pocket_screen",
        "$tooltip_size": [ 127, 60 ],
        "$tooltip_body_padding_size": [ "50% - 54px", 1 ],
        "$tooltip_footer_size": [ 112, 15 ]
      }
    ],
    "bindings": [
      {
        "binding_name": "#show_bundle_tooltip_hover",
        "binding_name_override": "#visible",
        "binding_condition": "always"
      }
    ]
  },

  "bundle_touch_tooltip@gameplay.bundle_tooltip": {
    "offset": [ 0, "-36px" ],
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "bindings": [
      {
        "binding_name": "#show_bundle_tooltip_pocket",
        "binding_name_override": "#visible"
      }
    ]
  },

  "bundle_tooltip_factory_wrapper": {
    "type": "panel",
    "controls": [
      { "bundle_cursor_tooltip@gameplay.bundle_cursor_tooltip": {} }
    ]
  },

  "bundle_cursor_tooltip": {
    "type": "custom",
    "renderer": "bundle_tooltip_renderer",
    "size": [ "100%cm", "100%cm" ],
    "layer": 20,
    "controls": [
      { "tooltip@gameplay.bundle_tooltip": {} }
    ]
  }
}
