<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
  <Frame name="ErrorRedirectOptionsFrame" toplevel="true" frameStrata="DIALOG" movable="true" enableMouse="true" hidden="true" parent="UIParent" enableKeyboard="true">
    <Size>
      <AbsDimension x="380" y="190"/>
    </Size>
    <Anchors>
      <Anchor point="CENTER"/>
    </Anchors>
    <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
      <BackgroundInsets>
        <AbsInset left="11" right="12" top="12" bottom="11"/>
      </BackgroundInsets>
      <TileSize>
        <AbsValue val="32"/>
      </TileSize>
      <EdgeSize>
        <AbsValue val="32"/>
      </EdgeSize>
    </Backdrop>
    <Layers>
      <Layer level="ARTWORK">
        <Texture name="ErrorRedirectOptionsFrameHeader" file="Interface\DialogFrame\UI-DialogBox-Header">
          <Size>
            <AbsDimension x="390" y="64"/>
          </Size>
          <Anchors>
            <Anchor point="TOP">
              <Offset>
                <AbsDimension x="0" y="12"/>
              </Offset>
            </Anchor>
          </Anchors>
        </Texture>
        <FontString name="ErrorRedirectOptionsFrameTitle" inherits="GameFontNormal">
          <Anchors>
            <Anchor point="TOP" relativeTo="ErrorRedirectOptionsFrameHeader">
              <Offset>
                <AbsDimension x="0" y="-14"/>
              </Offset>
            </Anchor>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
    <Frames>
      <Frame name="ErrorRedirectOptionsFrameCombo" inherits="UIDropDownMenuTemplate" enableMouse="true">
        <Anchors>
          <Anchor point="TOPLEFT">
            <Offset>
              <AbsDimension x="71" y="-40"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Layers>
          <Layer level="BACKGROUND">
            <FontString name="$parentText" inherits="GameFontNormal" text="Filter:" justifyH="LEFT">
              <Anchors>
                <Anchor point="TOPRIGHT" relativePoint="TOPLEFT">
                  <Offset>
                    <AbsDimension x="10" y="-6"/>
                  </Offset>
                </Anchor>
              </Anchors>
            </FontString>
          </Layer>
        </Layers>
      </Frame>
      <CheckButton name="ErrorRedirectOptionsFrameHighlight" inherits="OptionsCheckButtonTemplate">
        <Anchors>
          <Anchor point="TOPLEFT" relativeTo="ErrorRedirectOptionsFrameCombo" relativePoint="BOTTOMLEFT">
            <Offset>
              <AbsDimension x="-30" y="-5"/>
            </Offset>
          </Anchor>
        </Anchors>
      </CheckButton>^
      <CheckButton name="ErrorRedirectOptionsFrameSuppress" inherits="OptionsCheckButtonTemplate">
        <Anchors>
          <Anchor point="TOPLEFT" relativeTo="ErrorRedirectOptionsFrameHighlight" relativePoint="BOTTOMLEFT">
            <Offset>
              <AbsDimension x="0" y="0"/>
            </Offset>
          </Anchor>
        </Anchors>
      </CheckButton>
      <Button name="ErrorRedirectOptionsFrameOkay" inherits="OptionsButtonTemplate" text="Okay">
        <Anchors>
          <Anchor point="BOTTOMRIGHT">
            <Offset>
              <AbsDimension x="-20" y="16"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            if ErrorRedirectOptionsFrameHighlight:GetChecked() then
              ErrorRedirect_HighlightMessages = true;
            else
              ErrorRedirect_HighlightMessages = false;
            end

            if ErrorRedirectOptionsFrameSuppress:GetChecked() then
              ErrorRedirect_SuppressModErrors = true;
            else
              ErrorRedirect_SuppressModErrors = false;
            end

            if UIDropDownMenu_GetSelectedValue(ErrorRedirectOptionsFrameCombo) == 1 then
              ErrorRedirect_IsEnabled = false;
              ErrorRedirect_Frame = "";
            elseif UIDropDownMenu_GetSelectedValue(ErrorRedirectOptionsFrameCombo) == 2 then
              ErrorRedirect_IsEnabled = true;
              ErrorRedirect_Frame = "";
            elseif UIDropDownMenu_GetSelectedValue(ErrorRedirectOptionsFrameCombo) == 3 then
              ErrorRedirect_IsEnabled = true;
              ErrorRedirect_Frame = "ChatFrame1";
            elseif UIDropDownMenu_GetSelectedValue(ErrorRedirectOptionsFrameCombo) == 4 then
              ErrorRedirect_IsEnabled = true;
              ErrorRedirect_Frame = "ChatFrame2";
            else
              ErrorRedirect_IsEnabled = true;
              ErrorRedirect_Frame = "ChatFrame2";
            end

            PlaySound("gsTitleOptionOK");
            ErrorRedirectOptionsFrame:Hide();
          </OnClick>
        </Scripts>
      </Button>
    </Frames>
    <Scripts>
      <OnLoad>
        table.insert(UISpecialFrames, "ErrorRedirectOptionsFrame");

        ErrorRedirectOptionsFrameHighlightText:SetTextHeight(12);
        ErrorRedirectOptionsFrameSuppressText:SetTextHeight(12);

        ErrorRedirectOptionsFrameTitle:SetText(ERRORREDIRECT_NAME);
        ErrorRedirectOptionsFrameHighlightText:SetText(ERRORREDIRECT_CUSTOMCOLOR);
        ErrorRedirectOptionsFrameSuppressText:SetText(ERRORREDIRECT_SUPPRESSNIL);

        UIDropDownMenu_Initialize(ErrorRedirectOptionsFrameCombo, function()
          local info1 = { text = ERRORREDIRECT_COMBOTEXT[1],
                          value = 1,
                          func = function()
                            UIDropDownMenu_SetSelectedValue(ErrorRedirectOptionsFrameCombo, 1);
                          end }

          local info2 = { text = ERRORREDIRECT_COMBOTEXT[2],
                          value = 2,
                          func = function()
                            UIDropDownMenu_SetSelectedValue(ErrorRedirectOptionsFrameCombo, 2);
                          end }

          local info3 = { text = ERRORREDIRECT_COMBOTEXT[3],
                          value = 3,
                          func = function()
                            UIDropDownMenu_SetSelectedValue(ErrorRedirectOptionsFrameCombo, 3);
                          end }
          local info4 = { text = ERRORREDIRECT_COMBOTEXT[4],
                          value = 4,
                          func = function()
                            UIDropDownMenu_SetSelectedValue(ErrorRedirectOptionsFrameCombo, 4);
                          end }

          UIDropDownMenu_AddButton(info1);
          UIDropDownMenu_AddButton(info2);
          UIDropDownMenu_AddButton(info3);
          UIDropDownMenu_AddButton(info4);
        end);
        UIDropDownMenu_SetWidth(200, ErrorRedirectOptionsFrameCombo);
        ErrorRedirectOptionsFrameComboText:ClearAllPoints();
        ErrorRedirectOptionsFrameComboText:SetPoint("LEFT", "ErrorRedirectOptionsFrameCombo", "LEFT", 25, 3);
        ErrorRedirectOptionsFrameComboText:SetJustifyH("LEFT");
      </OnLoad>
      <OnShow>
        local currentConfig = 0;
        if ErrorRedirect_IsEnabled and ErrorRedirect_Frame == "ChatFrame1" then
          currentConfig = 3;
        elseif ErrorRedirect_IsEnabled and ErrorRedirect_Frame == "ChatFrame2" then
          currentConfig = 4;
        elseif ErrorRedirect_IsEnabled then
          currentConfig = 2;
        else
          currentConfig = 1;
        end
        UIDropDownMenu_SetSelectedValue(ErrorRedirectOptionsFrameCombo, currentConfig);
        UIDropDownMenu_SetText(ERRORREDIRECT_COMBOTEXT[currentConfig], ErrorRedirectOptionsFrameCombo);

        if ErrorRedirect_HighlightMessages then
          ErrorRedirectOptionsFrameHighlight:SetChecked(1);
        else
          ErrorRedirectOptionsFrameHighlight:SetChecked(0);
        end

        if ErrorRedirect_SuppressModErrors then
          ErrorRedirectOptionsFrameSuppress:SetChecked(1);
        else
          ErrorRedirectOptionsFrameSuppress:SetChecked(0);
        end
      </OnShow>
    </Scripts>
  </Frame>
</Ui>