{
  "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_without_bonus": {
                "type": "label",
                "layer": 3,
                "offset": [ 0, 1 ],
                "text": "#coins_without_bonus",
                "color": "$coin_color",
                "bindings": [
                  {
                    "binding_name": "#coins_without_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": {
          "type": "image",
          "size": [ "100%", "116.67%x" ],
          "anchor_from": "top_middle",
          "anchor_to": "top_middle",
          "layer": 2,
          "bilinear": true,
          "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"
            }
          ]
        }
      },
      {
        "bonus_coins_stack@coin_purchase.bonus_coins_stack": {}
      }
    ]
  },

  "bonus_coins_stack": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100% - 4px", "100%c" ],
    "offset": [ 0, 2 ],
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "layer": 2,
    "controls": [
      {
        "price_panel": {
          "type": "panel",
          "layer": 1,
          "size": [ "100%", "100%c" ],
          "controls": [
            {
              "coins_stack_panel@coin_purchase.coins_stack_panel": {
                "layer": 3
              }
            }
          ]
        }
      },
      {
        "plus_label": {
          "type": "panel",
          "size": [ "100%", 10 ],
          "controls": [
            {
              "plus_label": {
                "type": "label",
                "size": [ "default", 10 ],
                "layer": 1,
                "text": "+",
                "color": "$store_white_text_color"
              }
            }
          ],
          "bindings": [
            {
              "binding_name": "#bonus_coins_visible",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "coin_purchase_grid"
            }
          ]
        }
      },
      {
        "non_bonus_padding": {
          "type": "panel",
          "size": [ "100%", 21 ],
          "bindings": [
            {
              "binding_name": "(not #bonus_coins_visible)",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "coin_purchase_grid"
            }
          ]
        }
      },
      {
        "bonus_label_panel": {
          "type": "panel",
          "size": [ "100%", 10 ],
          "bindings": [
            {
              "binding_name": "#bonus_coins_visible",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "coin_purchase_grid"
            }
          ],
          "controls": [
            {
              "bonus_label": {
                "type": "label",
                "size": [ "default", "100%" ],
                "text": "store.coin.bonus",
                "color": "$coin_color",
                "layer": 6
              }
            }
          ]
        }
      },
      {
        "padding_0": {
          "type": "panel",
          "size": [ "100%", 1 ]
        }
      },
      {
        "bonus_coin_panel": {
          "type": "stack_panel",
          "orientation": "horizontal",
          "size": [ "100%", 11 ],
          "layer": 7,
          "bindings": [
            {
              "binding_name": "#bonus_coins_visible",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "coin_purchase_grid"
            }
          ],
          "controls": [
            {
              "fill_panel_0": {
                "type": "panel",
                "size": [ "fill", "100%" ]
              }
            },
            {
              "bonus_coin_label_panel": {
                "type": "panel",
                "size": [ "100%c", "100%" ],
                "controls": [
                  {
                    "bonus_coins": {
                      "type": "label",
                      "layer": 3,
                      "text": "#bonus_coins",
                      "color": "$coin_color",
                      "size": [ "default", 10 ],
                      "bindings": [
                        {
                          "binding_name": "#bonus_coins",
                          "binding_type": "collection",
                          "binding_collection_name": "coin_purchase_grid"
                        }
                      ]
                    }
                  }
                ]
              }
            },
            {
              "coin_panel": {
                "type": "panel",
                "size": [ "100%c", "100%" ],
                "controls": [
                  {
                    "coin@common_store.coin_icon": {
                    }
                  }
                ]
              }
            },
            {
              "fill_panel_1": {
                "type": "panel",
                "size": [ "fill", "100%" ]
              }
            }
          ]
        }
      },
      {
        "padding_1": {
          "type": "panel",
          "size": [ "100%", 2 ]
        }
      },
      {
        "currency_panel": {
          "type": "panel",
          "size": [ "100%", 10 ],
          "controls": [
            {
              "currency_price_panel": {
                "type": "image",
                "size": [ "100% + 6px", 10 ],
                "texture": "textures/ui/bonus_banner",
                "controls": [
                  {
                    "price@coin_purchase.price": {
                      "$price_color": "$coin_bonus_price_color",
                      "$price_visible": "(not #debug_price_visible)"
                    }
                  },
                  {
                    "debug_price@coin_purchase.price": {
                      "$price_color": "$c_color_format", // Red
                      "$price_visible": "#debug_price_visible"

                    }
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "padding_2": {
          "type": "panel",
          "size": [ "100%", 1 ]
        }
      }
    ]
  },

  "price": {
    "type": "label",
    "size": [ "default", 10 ],    
    "color": "$price_color",
    "text": "#price_text",
    "layer": 5,
    "text_alignment": "center",
    "font_type": "smooth",
    "bindings": [
      {
        "binding_name": "$price_visible",
        "binding_name_override": "#visible",
        "binding_collection_name": "coin_purchase_grid",
        "binding_type": "collection"
      },
      {
        "binding_type": "collection",
        "binding_collection_name": "coin_purchase_grid",
        "binding_name": "#price_text"
      }
    ]
  },

  "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",
    "$grid_item_size": [ "fill", "100%" ],
    "controls": [
      { "offer_item@coin_purchase.offer_item": {} }
    ]
  },

  "not_enough_coins": {
    "type": "label",
    "size": [ "100%", "default" ],
    "color": "$store_white_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"
      }
    ]
  },

  "faq_button@common_buttons.light_text_button": {
    "type": "button",
    "size": [ "100%", "25px" ],
    "$button_focus_precedence": 10,
    "ignored": "(not $show_tokens_faq_button)",
    "$pressed_button_name": "$button_action",
    "$button_action": "button.faq_screen",
    "$focus_id": "faq_button",
    "$button_text": "store.tokens.faq"
  },

  "divider_panel": {
    "type": "panel",
    "size": [ "100%", "100%c" ],
    "ignored": "(not $show_tokens_faq_button)",
    "controls": [
      {
        "divider": {
          "type": "image",
          "size": [ "100% - 6px", 1 ],
          "texture": "textures/ui/divider2",
          "tiled": "x",
          "alpha": 0.6
        }
      }
    ]
  },

  "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",
          "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%", "fill" ],
          "bindings": [
            {
              "binding_name": "#coin_offer_size"
            },
            {
              "binding_name": "#has_coin_offers",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "divider_panel@coin_purchase.divider_panel": {}
      },
      {
        "faq_button@coin_purchase.faq_button": {}
      }
    ]
  },

  "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"
      }
    ],
    "$screen_animations": [
      "@common.screen_exit_animation_push_fade",
      "@common.screen_exit_animation_pop_fade",
      "@common.screen_entrance_animation_push_fade",
      "@common.screen_entrance_animation_pop_fade"
    ],
    "$background_animations": [
      "@common.screen_exit_animation_push_fade",
      "@common.screen_exit_animation_pop_fade",
      "@common.screen_entrance_animation_push_fade",
      "@common.screen_entrance_animation_pop_fade"
    ],
    "force_render_below": true,
    "$screen_content": "coin_purchase.coin_purchase_screen_content",
    "$screen_background_control": "coin_purchase.background"
  },

  "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 ],
          "$text_name": "#window_title_text",
          "$title_text_binding_type": "global",
          "$child_control": "coin_purchase.main_panel",
          "$close_button_visible_binding_name": "#close_visible",
          "layer": 2,
          "variables": [
            {
              "requires": "($show_tokens_faq_button and $show_need_more_coins_string)",
              "$window_size": "$purchase_coin_screen_size_extended_not_enough"
            },
            {
              "requires": "(not $show_tokens_faq_button and not $show_need_more_coins_string)",
              "$window_size": "$purchase_coin_screen_size"
            },
            {
              "requires": "(not $show_tokens_faq_button and $show_need_more_coins_string)",
              "$window_size": "$purchase_coin_screen_size_not_enough"
            },
            {
              "requires": "($show_tokens_faq_button and not $show_need_more_coins_string)",
              "$window_size": "$purchase_coin_screen_size_extended"
            }
          ],
          "size": "$window_size"
        }
      }
    ]
  },

  "background@common.screen_background": {
    "alpha": 0.65,
    "layer": 1
  }
}