require( "scripts/style.lua" );
require( "scripts/ui/style_text.lua" );
require( "scripts/ui/style_buttons.lua" );

local lbl_yes = "yes";
local lbl_no = "no";
local dlg_name = "dlg_yesno";
local cmd_yes = gDialogTable.cmd_yes;
local cmd_no = gDialogTable.cmd_no;
local picture_scale = 1;
local dlg_timer = {
    name = "panels",
    category = "UI",
};
local fade_scale = 1.0;

if (gDialogTable.scale) then
    fade_scale = gDialogTable.scale;
end
if (gDialogTable.lbl_yes) then
    lbl_yes = gDialogTable.lbl_yes;
end
if (gDialogTable.lbl_no) then
    lbl_no = gDialogTable.lbl_no;
end
if (gDialogTable.dlg_name) then
    dlg_name = gDialogTable.dlg_name;
end
if (gDialogTable.timer) then
    dlg_timer = gDialogTable.timer;
end
if (gDialogTable.pic_scale) then
    picture_scale = gDialogTable.pic_scale;
end



local kOffBtnX = 85;
local kOffBtnY = 95;
local kRetVal = "no",

MakeDialog
{
    BitmapVisual
    {
        name="bmp_fade_menu",
        image    = "cutscenes/black",
        alpha_val = 0.5,
        --scale_val = fade_scale,
        x = 512, y = 384,
        w = 1024, h = 768,
        
        WindowExt
        {
            x = 512,
            y = 384,
            fit=true,
            name = dlg_name,
            
            timer_settings = dlg_timer,
            
            state_handlers = {
                justcreated = function()
                    ShowControl(dlg_name);
                    PauseTimer("game", "game");
                end;
                hidden = function()
                    StartTimer("game", "game");
                    CloseWindow(kRetVal);
                end;
            },

            Bitmap
            {
                image = "backgrounds/dialog",
                x = kCenter,
                y = kCenter,
                
                Bitmap
                {
                    image = gDialogTable.image,
                    x = kCenter,
                    y = kCenter - 40,
                    scale = picture_scale,
                },

                SetStyle(TextStyle),
                CreateMinionSbItText(24, CaptionBrown, kCenter+1, 34, "#"..GetString("caption_outline", GetString(gDialogTable.title)), 250, 24),
                CreateMinionSbItText(24, CaptionYellow, kCenter, 33, "#"..GetString("caption_outline", GetString(gDialogTable.title)), 250, 24),
                
                CreateMinionSbItText(18, ShadowColor, kCenter+1, kCenter + 38, "#"..GetString("caption_outline", GetString(gDialogTable.body)), 310, 80),
                CreateMinionSbItText(18, WhiteColor, kCenter, kCenter + 37, "#"..GetString("caption_outline", GetString(gDialogTable.body)), 310, 80),
                
                SetStyle(BtnDefault),
                Button
                {
                    close = true,
                    label = lbl_yes,
                    x = kCenter - kOffBtnX,
                    y = kMax - kOffBtnY,
                    font = CreateNamedFont(MinionSbItSymbolSet, 24, ButtonBrown),
                    command = function()
                        kRetVal = "yes";
                        if (cmd_yes) then 
                            cmd_yes();
                        end;
                        HideControl(dlg_name);
                    end;
                },
                Button
                {
                    close = true,
                    label = lbl_no,
                    x = kCenter + kOffBtnX,
                    y = kMax - kOffBtnY,
                    font = CreateNamedFont(MinionSbItSymbolSet, 24, ButtonBrown),
                    command = function()
                        kRetVal = "no";
                        if (cmd_no) then
                            cmd_no();
                        end;
                        HideControl(dlg_name);
                    end;
                },

                -- LAMP FX

                WndFxSprite
                {
                    name = "left_lamp_firebugs_fx",
                    x = 0,
                    y = 0,
                    w = 580,
                    h = 310,
                    effect_position = "67,96",
                    file_name = "fx/lamp_firebugs.lua",
                    start_activate = true,
                    advance = 50,
                    anim_pool = "yesno",
                    timer_settings = {
                        name = "control",
                        category = "control",
                    },
                },

                WndFxSprite
                {
                    name = "right_lamp_firebugs_fx",
                    x = 0,
                    y = 0,
                    w = 580,
                    h = 310,
                    effect_position = "518,96",
                    file_name = "fx/lamp_firebugs.lua",
                    start_activate = true,
                    advance = 50,
                    anim_pool = "yesno",
                    timer_settings = {
                        name = "control",
                        category = "control",
                    },
                },

                WndFxSprite
                {
                    name = "left_lamp_light_fx",
                    x = 0,
                    y = 0,
                    w = 580,
                    h = 310,
                    effect_position = "67,96",
                    file_name = "fx/lamp_light.lua",
                    start_activate = true,
                    advance = 50,
                    anim_pool = "yesno",
                    timer_settings = {
                        name = "control",
                        category = "control",
                    },
                },

                WndFxSprite
                {
                    name = "right_lamp_light_fx",
                    x = 0,
                    y = 0,
                    w = 580,
                    h = 310,
                    effect_position = "518,96",
                    file_name = "fx/lamp_light.lua",
                    start_activate = true,
                    advance = 50,
                    anim_pool = "yesno",
                    timer_settings = {
                        name = "control",
                        category = "control",
                    },
                },
            },
        },
    },
} -- MakeDialog