require( "scripts/style.lua" );
require( "scripts/ui/style_text.lua" );
require( "scripts/ui/style_buttons.lua" );
require( "facebook/common/facebook_functions.lua" );
require( "facebook/game/facebook_globals.lua" );

local kOffBtnX = 55;
local kOffBtnY = 95;

if not IsFacebookEnabled() then
    kOffBtnX = 0;
end;

MakeDialog
{
    WindowExt
    {
        x = 512,
        y = -384,
        fit=true,
        name = "dlg_medal",
        
        state_curves = {
            container = "curves/dlg_drop_down.xml",
            showing = {
                set = "",
                inverse = false,
                offset = false
            },
            hiding = {
                set = "",
                inverse = true,
                offset = false
            },
        },
        
        state_handlers = {
            justcreated = function()
                ShowControl("dlg_medal");
                PauseTimer("ui", "UI");
                PauseTimer("panels", "UI");
                PauseTimerCategory("game");
                
                EnableWindow("pnl_water_barrel_rollover", false);
                EnableWindow("pnl_fountain_rollover", false);
                EnableWindow("pnl_gates_rollover", false);
                EnableWindow("pnl_magic_object_rollover", false);
                EnableWindow("pnl_storage_rollover", false);
                GM_StartPersistentAction("UIClick");
            end;
            hidden = function()
                StartTimer("ui", "UI");
                StartTimer("panels", "UI");
                StartTimerCategory("game");
                CloseWindow();
                if GetCount("lvl_gates") ~= 6 then
                    if GetCount("pnl_sell_screen_state") == 0 then
                        GM_StartPersistentAction("ShopClick");
                    else
                        GM_StartPersistentAction("PotionClick");
                    end;
                end;
                ShowingTrophyComplete();
            end;
        },

        Bitmap
        {
            image = "backgrounds/pnl_trophy",
            x = kCenter,
            y = kCenter,
            
            Bitmap
            {
                image = gDialogTable.image,
                x = kCenter,
                y = kCenter - 35,
            },

            SetStyle(TextStyle),
            CreateOndineText(26, BlueOutline, kCenter+1, 41, "#"..GetString("blue_outline", GetString("title_medal")), 250, 26),
            CreateOndineText(26, LightBlueText, kCenter, 40, "#"..GetString("blue_outline", GetString("title_medal")), 250, 26),
            
            CreateLucidaText(20, BlackColor, kCenter, kCenter + 65, gDialogTable.body, 250, 50),

            SetStyle(BtnQuestMirror),
            Button
            {
                label = "close",
                x = kCenter - kOffBtnX,
                y = kMax - kOffBtnY,
                font = CreateNamedFont(MinionSbItSymbolSet, 24, ButtonBrown),
                command = function()
                    HideControl("dlg_medal");
                end;
            },
            SetStyle({}),
            Facebook_CreateMedalButton(kCenter + kOffBtnX, 295),
        },
    },
} -- MakeDialog