{
  "namespace": "popup_dialog",

  //--------------------------------------------------------------------------------
  // Popup Dialog
  //--------------------------------------------------------------------------------

  "popup_dialog_bg": {
    "type": "image",
    "texture": "textures/ui/NormalButtonThin"
  },

  "popup_dialog_message": {
    "type": "label",
    "layer": 102,
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "size": [ "90%", "68%" ],
    "offset": [ 0, 4 ],
    "color": "$dark_body_text_color",
    "text": "$message_text"
  },

  "popup_dialog_button@common_buttons.light_text_button": {
    "layer": 101,
    "size": [ "40%", "20%" ]
  },

  "popup_dialog_button_with_binding@common_buttons.light_text_button": {
    "layer": 101,
    "size": [ "40%", "20%" ]
  },

  "popup_dialog_left_button@popup_dialog_button": {
    "$pressed_button_name": "$left_button_press",
    "$button_text": "$left_button_text",
    "anchor_from": "bottom_left",
    "anchor_to": "bottom_left",
    "offset": [ "6.5%", "-8%" ]
  },

  "popup_dialog_middle_button@popup_dialog_button": {
    "$pressed_button_name": "$middle_button_press",
    "$button_text": "$middle_button_text",
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "offset": [ 0, "-8%" ]
  },

  "popup_dialog_right_button@popup_dialog_button": {
    "$pressed_button_name": "$right_button_press",
    "$button_text": "$right_button_text",
    "anchor_from": "bottom_right",
    "anchor_to": "bottom_right",
    "offset": [ "-6.5%", "-8%" ]
  },

  "popup_dialog": {
    "type": "input_panel",
    "modal": true,
    "layer": 100,
    "size": [ 204, 140 ],
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "modal.escape",
        "mapping_type": "global"
      }
    ]
  },

  //--------------------------------------------------------------------------------
  // Modal Dialog Popup
  //--------------------------------------------------------------------------------

  "modal_background_image": {
    "type": "image",
    "texture": "textures/ui/normal_stroke_button",
    "layer": 1
  },

  "black_tint_image": {
    "type": "image",
    "texture": "textures/ui/Black",
    "layer": 1
  },

  "modal_title_text": {
    "type": "label",
    "$title_text_offset|default": [ 9, 9 ],
    "offset": "$title_text_offset",
    "size": [ "90%", 15 ],
    "$title_text_anchor|default": "top_left",
    "$title_text_alignment|default": "left",
    "anchor_to": "$title_text_anchor",
    "anchor_from": "$title_text_anchor",
    "text_alignment": "$title_text_alignment",
    "layer": 2,
    "text": "#text",
    "color": "$title_text_color",
    "shadow": false,
    "bindings": [
      {
        "binding_type": "view",
        "source_control_name": "$visibility_source_control_name",
        "source_property_name": "#modal_title_text",
        "target_property_name": "#text"
      }
    ]
  },

  "modal_label_text": {
    "type": "stack_panel",
    "size": [ "100% - 4px", "100%c" ],
    "anchor_to": "top_middle",
    "anchor_from": "top_middle",
    "offset": [ 2, 0 ],
    "controls": [
      {
        "padding": {
          "type": "panel",
          "layer": 2,
          "size": [ 0, 2 ]
        }
      },
      {
        "text": {
          "type": "label",
          "size": [ "100%", "default" ],
          "anchor_to": "top_middle",
          "anchor_from": "top_middle",
          "layer": 2,
          "text": "#text",
          "color": "$body_text_color",
          "font_type": "smooth",
          "shadow": false,
          "bindings": [
            {
              "binding_type": "view",
              "source_control_name": "$visibility_source_control_name",
              "source_property_name": "#modal_label_text",
              "target_property_name": "#text"
            }
          ]
        }
      }
    ]
  },

  "modal_label_panel@common.scrolling_panel": {
    "$scrolling_pane_size": [ "100% - 1px", "100% - 3px" ],
    "$scrolling_pane_offset": [ 2, 0 ],
    "$scrolling_content": "popup_dialog.modal_label_text",
    "$scroll_size": [ 5, "100% - 4px" ],
    "$show_background": false,
    "layer": 1,
    "offset": [ 0, 23 ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "$always_handle_scrolling": true
  },

  "modal_left_button@common_buttons.light_text_button": {
    "anchor_to": "top_middle",
    "anchor_from": "top_middle",
    "size": [ "100%", "50%-1px" ],
    "$pressed_button_name": "$popup_dialog_left_button_name",
    "$button_text": "#modal_left_button_text"
  },

  "modal_middle_button@common_buttons.light_text_button": {
    "anchor_to": "center",
    "anchor_from": "center",
    "size": [ "100%", "50%-1px" ],
    "$pressed_button_name": "$popup_dialog_middle_button_name",
    "$button_text": "#modal_middle_button_text"
  },

  "modal_rightcancel_button@common_buttons.light_text_button": {
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%", "50%-1px" ],
    "$pressed_button_name": "$popup_dialog_rightcancel_button_name",
    "$button_text": "#modal_rightcancel_button_text"
  },

  "three_buttons_panel": {
    "type": "panel",
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%-14px", 90 ],
    "offset": [ 0, -7 ],
    "controls": [
      {
        "left@popup_dialog.modal_left_button": {
          "size": [ "100%", "33% - 1px" ]
        }
      },
      {
        "middle@popup_dialog.modal_middle_button": {
          "size": [ "100%", "33% - 1px" ]
        }
      },
      {
        "right@popup_dialog.modal_rightcancel_button": {
          "size": [ "100%", "33% - 1px" ],
          "default_focus_precedence": 1
        }
      }
    ]
  },

  "destructive_three_buttons_panel": {
    "type": "panel",
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%-14px", 90 ],
    "offset": [ 0, -7 ],
    "controls": [
      {
        "left@popup_dialog.modal_left_button": {
          "size": [ "100%", "33% - 1px" ],
          "$hover_button_texture": "textures/ui/button_red",
          "$pressed_button_texture": "textures/ui/button_red_pressed"
        }
      },
      {
        "middle@popup_dialog.modal_middle_button": {
          "size": [ "100%", "33% - 1px" ],
          "$hover_button_texture": "textures/ui/button_red",
          "$pressed_button_texture": "textures/ui/button_red_pressed"
        }
      },
      {
        "right@popup_dialog.modal_rightcancel_button": {
          "size": [ "100%", "33% - 1px" ],
          "default_focus_precedence": 1
        }
      }
    ]
  },

  "two_buttons_panel": {
    "type": "panel",
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%-14px", 64 ],
    "offset": [ 0, -7 ],
    "controls": [
      { "left@popup_dialog.modal_left_button": {} },
      {
        "right@popup_dialog.modal_rightcancel_button": {
          "default_focus_precedence": 1
        }
      }
    ]
  },

  "destructive_two_buttons_panel": {
    "type": "panel",
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%-14px", 64 ],
    "offset": [ 0, -7 ],
    "controls": [
      {
        "left@popup_dialog.modal_left_button": {
          "$hover_button_texture": "textures/ui/button_red",
          "$pressed_button_texture": "textures/ui/button_red_pressed"
        }
      },
      {
        "right@popup_dialog.modal_rightcancel_button": {
          "default_focus_precedence": 1
        }
      }
    ]
  },

  "single_button_panel": {
    "type": "panel",
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%-14px", 30 ],
    "offset": [ 0, -7 ],
    "controls": [
      { "left@popup_dialog.modal_middle_button": { "size": [ "100%", "100%" ] } }
    ]
  },

  "modal_dialog_base": {
  },

  "modal_dialog_with_buttons": {
    "type": "panel",
    "anchor_to": "center",
    "anchor_from": "center",
    "size": "$modal_screen_size",
    "controls": [
      {
        "background_with_buttons@common.common_panel": {
          "$dialog_background": "$dialog_background_override",
          "$show_close_button": false,
          "$fill_alpha": 1
        }
      },
      { "title@popup_dialog.modal_title_text": {} },
      {
        "text_with_buttons@popup_dialog.modal_label_panel": {
          "size": "$modal_panel_label_size"
        }
      },
      {
        "button_panel@$button_panel": {}
      }
    ]
  },

  "modal_input_panel@common.input_panel": {
    "modal": true,
    "layer": 100,
    "$popup_dialog_escape_button_name|default": "popup_dialog.escape",
    "$popup_dialog_left_button_name|default": "popup_dialog.left_button",
    "$popup_dialog_middle_button_name|default": "popup_dialog.middle_button",
    "$popup_dialog_rightcancel_button_name|default": "popup_dialog.rightcancel_button",
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.menu_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.menu_secondary_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.menu_ok",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "$popup_dialog_escape_button_name",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_up",
        "to_button_id": "button.menu_up",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_down",
        "to_button_id": "button.menu_down",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_left",
        "to_button_id": "button.menu_left",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_right",
        "to_button_id": "button.menu_right",
        "mapping_type": "global",
        "scope": "view"
      }
    ],
    "controls": [
      {
        "black_tint_image@popup_dialog.black_tint_image": {
          "ignored": "$is_holographic",
          "alpha": 0.5
        }
      }
    ]
  },

  "modal_dialog_popup": {
    "type": "panel",
    "variables": [
      {
        "requires": "$three_buttons_visible",
        "$modal_screen_size": [ 214, 190 ],
        "$dialog_background_override": "dialog_background_hollow_6",
        "$button_panel": "popup_dialog.three_buttons_panel",
        "$modal_panel_label_size": ["100% - 16px", "100% - 124px"]
      },
      {
        "requires": "$destructive_three_buttons_visible",
        "$modal_screen_size": [ 214, 190 ],
        "$dialog_background_override": "dialog_background_hollow_6",
        "$button_panel": "popup_dialog.destructive_three_buttons_panel",
        "$modal_panel_label_size": ["100% - 16px", "100% - 124px"]
      },
      {
        "requires": "$two_buttons_visible",
        "$modal_screen_size": [ 214, 175 ],
        "$dialog_background_override": "dialog_background_hollow_1",
        "$button_panel": "popup_dialog.two_buttons_panel",
        "$modal_panel_label_size": ["100% - 16px", "100% - 96px"]
      },
      {
        "requires": "$destructive_two_buttons_visible",
        "$modal_screen_size": [ 214, 175 ],
        "$dialog_background_override": "dialog_background_hollow_1",
        "$button_panel": "popup_dialog.destructive_two_buttons_panel",
        "$modal_panel_label_size": [ "100% - 16px", "100% - 96px" ]
      },
      {
        "requires": "$single_button_visible",
        "$modal_screen_size": [ 214, 130 ],
        "$dialog_background_override": "dialog_background_hollow_2",
        "$button_panel": "popup_dialog.single_button_panel",
        "$modal_panel_label_size": ["100% - 16px", "100% - 62px"]
      },
      {
        "requires": "$no_buttons_visible",
        "$modal_screen_size": [ 214, 100 ],
        "$dialog_background_override": "dialog_background_hollow_3",
        "$button_panel": "common.empty_panel",
        "$modal_panel_label_size": [ "100% - 16px", "100% - 28px" ]
      }
    ],
    "controls": [
      {
        "modal_input@popup_dialog.modal_input_panel": {
          "$show_black_background|default": false,
          "controls": [
            {
              "modal_bg_buttons@popup_dialog.modal_dialog_with_buttons": {
                "$visibility_source_control_name|default": "modal_bg_buttons",
                "layer": 2
              }
            },
            {
              "black_background": {
                "type": "image",
                "texture": "textures/ui/realms_text_background",
                "ignored": "(not $show_black_background)",
                "layer": 1
              }
            }
          ]
        }
      }
    ]
  },


  //--------------------------------------------------------------------------------
  // Progress Dialog Popup
  //--------------------------------------------------------------------------------

  "progress_dialog_popup@popup_dialog.modal_dialog_popup": {
    "type": "input_panel",
    "size": [ 268, 95 ],
    "layer": 100,
    "modal": true,
    "$show_close_button|default": false,
    "$popup_dialog_left_button_name|default": "popup_dialog.first_button",
    "controls": [
      {
        "background@common.common_panel": {
          "$dialog_background": "dialog_background_hollow_2"
        }
      },
      { "title@popup_dialog.modal_title_text": {} },
      {
        "progress_content@popup_dialog.progress_content": {}
      },
      {
        "button@popup_dialog.single_button_panel": {
          "$visibility_source_control_name|default": "modal_bg_no_buttons",
          "bindings": [] //Get rid of default view binding
        }
      }
    ]
  },

  "progress_content": {
    "type": "stack_panel",
    "layer": 2,
    "size": [ "100% - 20px", "100% - 65px" ],
    "offset": [ 10, 23 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "orientation": "vertical",

    "controls": [
      {
        "progress_titles": {
          "type": "panel",
          "layer": 1,
          "size": [ "100%", 10 ],

          "controls": [
            { "current_progress_label@popup_dialog.current_progress_label": {} },
            { "total_progress_label@popup_dialog.total_progress_label": {} }
          ]
        }
      },
      {
        "progress_bar@popup_dialog.progress_bar_icon": {
          "layer": 1,
          "size": [ "100%", 5 ]
        }
      }
    ]
  },

  "progress_label": {
    "type": "label",
    "color": "$body_text_color",
    "size": [ "default", "100%" ],
    "text": "#progress_label",
    "bindings": [
      {
        "binding_name": "$label_binding_name",
        "binding_name_override": "#progress_label"
      }
    ]
  },

  "current_progress_label@popup_dialog.progress_label": {
    "layer": 1,
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "$label_binding_name": "#progress_current_label"
  },

  "total_progress_label@popup_dialog.progress_label": {
    "layer": 1,
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "$label_binding_name": "#progress_total_label"
  },

  "progress_bar_icon": {
    "type": "panel",
    "controls": [
      {
        "full_progress_bar_icon@popup_dialog.full_progress_bar_icon": {
          "layer": 2
        }
      },
      {
        "empty_progress_bar_icon@popup_dialog.empty_progress_bar_icon": {
          "layer": 1
        }
      },
      {
        "progress_bar_nub@popup_dialog.progress_bar_nub": {
          "size": [ "100% - 10px", 5 ],
          "layer": 3
        }
      }
    ]
  },

  "empty_progress_bar_icon": {
    "type": "image",
    "texture": "textures/ui/experiencebarempty"
  },

  "full_progress_bar_icon": {
    "type": "image",
    "texture": "textures/ui/experiencebarfull",
    "clip_direction": "left",
    "clip_pixelperfect": false,
    "$progress_bindings|default": [
      {
        "binding_name": "#progress_percentage",
        "binding_name_override": "#clip_ratio",
        "binding_type": "global"
      }
    ],
    "bindings": "$progress_bindings"
  },

  "progress_bar_nub": {
    "type": "image",
    "texture": "textures/ui/experiencenub",
    "tiled": true
  }
}