timer_quest_mirror = {
    name = "panels",
    category = "UI",
};

function fn_Spawn_Person()
    if GetCount("curr_garden") ~= 4 then
        return Group
        {
            BitmapVisual
            {
                x = 105,
                y = 105,
                image = "interface/game/pnl_quest_mirror/btn_person_2/p_02",
                scale_val = 0.6,
                rotation_val=-12,
            },
        };
    else
        return Group
        {
            BitmapVisual
            {
                x = 105,
                y = 105,
                image = "interface/game/pnl_quest_mirror/btn_person_2/p_03",
                scale_val = 0.6,
                rotation_val=-12,
            },
        };
    end
end;

function Spawn_BlightMirror()
    return Group
    {
        WindowExt
        {
            x = 0, y = -1000,
            w = 1024, h = 768,
            
            timer_settings = timer_quest_mirror,
            name = "blight_mirror_dlg",
            
            state_handlers = {
                showing = function()
                    SetItemCount("pnl_blight", 1);
                    GM_StartPersistentAction("NullAction");
                    DeactivateControl("start_day");
                    PlaySound("audio/sfx/shop/dialogappear.ogg");
                    kDialogActive = true;
                    bmp_fade_StartCurveCallBack("curves/fade.xml","in","");
                    pic_new_quest_StartCurveCallBack("curves/game_ui_panels.xml", "mirror_out", "");
                    EnableWindow("new_quest", false);
                end;
                showed = function()
                    DeactivateControl("start_day");
                    GM_StartPersistentAction("NullAction");
                    EnableWindow("new_quest", false);
                end;
                hiding = function()
                    PlaySound("audio/sfx/shop/dialogdisappear.ogg");
                    pic_new_quest_StartCurveCallBack("curves/game_ui_panels.xml", "mirror_in", "");
                    bmp_fade_StartCurveCallBack("curves/fade.xml","out","");
                    EnableWindow("new_quest", false);
                end;
                hidden = function()
                    SetItemCount("pnl_blight", 0);
                    EnableWindow("new_quest", true);
                    ActivateControl("start_day");
                    GM_StartPersistentAction("ShopClick");
                    kDialogActive = false;
                    if (GetCount("hint_group_welcome") == 0) and (GetCount("tutorial_skipped") == 0) and (GetCount("curr_garden") == 1) then
                        SetItemCount("hint_group_welcome", 1);
                    else
                        if (GetCount("curr_garden") == 2) and (GetCount("hint_mech_plants") == 0) then
                            SetItemCount("hint_mech_plants", 1);
                        else
                            if (GetCount("curr_garden") == 3) and (GetCount("hint_spells") == 0) then
                                SetItemCount("hint_spells", 1);
                            else
                                ShowControl("quest_mirror_dlg");
                            end;
                        end;
                    end;
                end;
            },
            
            state_curves = {
                container = "curves/blight_mirror_drop_down.xml",
                showing = {
                    set = "",
                    inverse = false,
                    offset = false
                },
                hiding = {
                    set = "",
                    inverse = true,
                    offset = false
                },
            },
             
            Bitmap
            {
                image="backgrounds/pnl_trophy",
                x=kCenter+30,
                y=kCenter+90,
                
                SetStyle(TextStyle),
                TextVisual
                {
                    x = 60,--50
                    y = 45,
                    w = 180,--200
                    h = 215,
                    label = "#"..GetString("mirror_blight_"..tostring(GetCount("curr_garden"))),
                    font = CreateNamedFont(LucidaSymbolSet, 22, BlackColor),
                },
                
                SetStyle(BtnQuestMirror),
                -- CLOSE
                Button
                {
                    x = kCenter,
                    y = kMax - 95,
                    close = true,
                    label = "close",
                    name = "close_blight_mirror",
                    font = CreateNamedFont(MinionSbItSymbolSet, 24, ButtonBrown),
                    command = function()
                        HideControl("blight_mirror_dlg");
                    end;
                },
            },
            BitmapVisual
            {
                image="interface/game/pnl_quest_mirror/mirror",
                x=352,
                y=424,
                rotation_val=-12,
                
                WndFxSprite
                {
                    x = kCenter-20,
                    y = kCenter-70,
                    w = 200,
                    h = 200,
                    effect_position = "100,100",
                    file_name = "fx/quest_mirror_portal.lua",
                    start_activate = true,
                    advance = 100,
                    timer_settings = timer_quest_mirror,
                    
                    fn_Spawn_Person(),
                },
            },
        },
    };
end;