{
  "namespace": "coin_purchase",

  "black_image": {
    "type": "image",
    "texture": "textures/ui/Black"
  },

  "banner_fill": {
    "type": "image",
    "texture": "textures/ui/Banners"
  },

  "coins_stack_panel": {
    "type": "stack_panel",
    "layer": 1,
    "orientation": "horizontal",
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "size": [ "default", 13 ],
    "controls": [
      {
        "text_padding": {
          "type": "panel",
          "size": [ "100%c", "100%c" ],
          "controls": [
            {
              "coins_with_bonus": {
                "type": "label",
                "layer": 3,
                "offset": [ 0, 1 ],
                "text": "#coins_with_bonus",
                "color": "$coin_color",
                "bindings": [
                  {
                    "binding_name": "#coins_with_bonus",
                    "binding_type": "collection",
                    "binding_collection_name": "coin_purchase_grid"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "coin@common_store.coin_icon": {}
      }
    ]

  },

  "button_content": {
    "type": "panel",
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "size": [ "100%", "100%" ],
    "controls": [
      {
        "image_panel": {
          "type": "panel",
          "size": [ "100%", "100% - 3px" ],
          "offset": [ 0, -3 ],
          "controls": [
            {
              "image": {
                "type": "image",
                "size": [ "100%", "100% - 4px" ],
                "anchor_from": "top_middle",
                "anchor_to": "top_middle",
                "layer": 2,
                "bindings": [
                  {
                    "binding_type": "collection",
                    "binding_collection_name": "coin_purchase_grid",
                    "binding_name": "#coin_offer_texture_name",
                    "binding_name_override": "#texture"
                  },
                  {
                    "binding_type": "collection",
                    "binding_collection_name": "coin_purchase_grid",
                    "binding_name": "#coin_offer_texture_file_system",
                    "binding_name_override": "#texture_file_system"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "price": {
          "type": "label",
          "size": [ "100%", 23 ],
          "color": "$body_text_color",
          "text": "#price_text",
          "anchor_from": "bottom_middle",
          "anchor_to": "bottom_middle",
          "layer": 5,
          "text_alignment": "center",
          "bindings": [
            {
              "binding_type": "collection",
              "binding_collection_name": "coin_purchase_grid",
              "binding_name": "#price_text"
            }
          ],
          "controls": [
            {
              "price_panel": {
                "type": "panel",
                "layer": 1,
                "anchor_from": "top_middle",
                "anchor_to": "bottom_middle",
                "size": [ "100%", "100%c" ],
                "offset": [ 0, 1 ],
                "controls": [
                  {
                    "coins_stack_panel@coin_purchase.coins_stack_panel": {
                      "layer": 3
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "offer_panel@common_buttons.light_content_button": {
    "$button_size_override": [ "100%", "100%" ],
    "$button_content": "coin_purchase.button_content",
    "$pressed_button_name": "button.purchase_coins",
    "$anchor": "top_left",
    "bindings": [
      {
        "binding_type": "collection_details",
        "binding_collection_name": "coin_purchase_grid"
      }
    ]
  },

  "offer_item": {
    "type": "panel",
    "anchor_from": "center",
    "anchor_to": "center",
    "size": [ "100% - 2px", "100% - 2px" ],
    "controls": [
      {
        "offer_panel@coin_purchase.offer_panel": {
          "layer": 3
        }
      }
    ]
  },
  "offer_grid_item": {
    "type": "panel",
    "size": "$grid_item_size",
    "$default_button_texture": "textures/ui/coin_button_borderless",
    "$hover_button_texture": "textures/ui/coin_button_borderless",
    "$pressed_button_texture": "textures/ui/coin_button_borderless_pressed",
    "controls": [
      { "offer_item@coin_purchase.offer_item": {} }
    ],
    "variables": [
      {
        "requires": "$show_need_more_coins_string",
        "$grid_item_size": [ "fill", "100% - 11px" ]
      },
      {
        "requires": "(not $show_need_more_coins_string)",
        "$grid_item_size": [ "fill", "100%" ]
      }

    ]
  },

  "not_enough_coins": {
    "type": "label",
    "size": [ "100%", "default" ],
    "color": "$generic_button_text_color",
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "text_alignment": "center",
    "layer": 3,
    "text": "#coins_text",
    "bindings": [
      {
        "binding_name": "#coins_required_for_purchase",
        "binding_name_override": "#coins_text"
      },
      {
        "binding_name": "#show_missing_coins",
        "binding_name_override": "#visible"
      }
    ]
  },

  "coin_purchase_panel": {
    "type": "stack_panel",
    "layer": 1,
    "size": [ "100%", "100%" ],
    "orientation": "vertical",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      {
        "not_enough_coins_panel": {
          "type": "panel",
          "ignored": "#needs_more_coins",
          "anchor_from": "top_middle",
          "anchor_to": "top_middle",
          "size": [ "100%", "100%c" ],
          "visible": "$show_need_more_coins_string",
          "controls": [
            { "not_enough_coins@coin_purchase.not_enough_coins": {} }
          ]
        }
      },
      {
        "coin_purchase_grid": {
          "type": "grid",
          "grid_item_template": "coin_purchase.offer_grid_item",
          "grid_dimension_binding": "#coin_offer_size",
          "collection_name": "coin_purchase_grid",
          "size": [ "100%", "100%" ],
          "bindings": [
            {
              "binding_name": "#coin_offer_size"
            },
            {
              "binding_name": "#has_coin_offers",
              "binding_name_override": "#visible"
            }
          ]

        }
      }
    ]
  },

    "main_panel": {
      "type": "panel",
      "layer": 1,
      "size": [ "100%", "100%" ],
      "anchor_from": "top_left",
      "anchor_to": "top_left",
      "controls": [
        {
          "coin_purchase_panel@coin_purchase.coin_purchase_panel": {
            "layer": 2
          }
        },
          {
            "progress_loading@common_store.progress_loading": {
              "layer": 100, // Make this on top
              "bindings": [
                {
                  "binding_name": "#coin_loading_visible",
                  "binding_name_override": "#visible"
                }
              ]
            }
          },
          {
            "no_offers_panel": {
              "type": "label",
              "size": [ "100%", "100%" ],
              "text": "store.minecoin.notavailable",
              "color": "$generic_button_text_color",
              "bindings": [
                {
                  "binding_name": "(not #has_coin_offers)",
                  "binding_name_override": "#visible"
                }
              ]
            }
          }
          ]
        },

    "coin_purchase_screen@common.base_screen": {
      "button_mappings": [
        {
          "from_button_id": "button.menu_cancel",
          "to_button_id": "button.menu_exit",
          "mapping_type": "global"
        }
      ],
      "force_render_below": true,
      "$screen_content": "coin_purchase.coin_purchase_screen_content"
    },

    "coin_purchase_screen_content": {
      "type": "panel",
      "controls": [
        {
          "dialog@common_dialogs.main_panel_no_buttons": {
            "$title_panel": "common_dialogs.standard_title_label",
            "$title_size": [ "100% - 14px", 10 ],
            "size": "$purchase_coin_screen_size",
            "$text_name": "#window_title_text",
            "$title_text_binding_type": "global",
            "$child_control": "coin_purchase.main_panel",
            "layer": 2
          }
        },
        {
          "background@common.screen_background": {
            "alpha": 0.65,
            "layer": 1
          }
        }
      ]
    }

  }