require "scripts/dialog_common.lua"

-- Determine size of dialog.

local text_size = get_requester_text_height(
    gDialogTable.body,
    355,
    432,
    kHAlignCenter + kVAlignTop,
    RequesterTextFont[ 1 ],
    RequesterTextFont[ 2 ]
)
local full_height = dialog_height( text_size )
play_from_database( "requester_open", false, 1.0, 0, 0 )

MakeDialog
{
    name="profile_yesno_dialog",

    Bitmap {
        image = "images/background.png",
        x = 0,
        y = 0,
        w = 800,
        h = 600,
        alpha = true,

    Window {
        fit = true,
        x = kCenter,
        y = kCenter,
        w = 497,
        h = full_height,

        --requester_background( text_size, "orange", "" ),
        requester_background( text_size, "blue", "better" ),

        Text
        {
            font = RequesterTitleFont,
            name = "window_title",
            x = kCenter, y = 59 + 0, w = 160, h = 34,
            flags = kHAlignCenter + kVAlignCenter,
            label = "profile_dialog_delete_title"
        },

        Text {
             name = "text_window",
             x = kCenter,
             y = 59 + 41,
             w = 355,
             h = full_height,
             align = kHAlignCenter + kVAlignTop,
             flags = kHAlignCenter + kVAlignTop,
             font = RequesterTextFont,
             label = gDialogTable.body,
        },
        Button {
            name = "button_yes",
            x = 63 + 120,
            y = kMax - 30,
            align = kHAlignCenter + kVAlignBottom,
            type = kPush,
            graphics = NewButtonGraphics,
            scale = 1,
            default = true,
            command=function()
                play_from_database( "button_click", false, 1.0, 0, 0 )
                ProfilesDialogDeleteRememberYesNo( 1 )
                PopModal( "profile_yesno_dialog" )
            end,
            Text {
                label = "profile_dialog_yes",
                x = 0, y = 2, w = kMax, h = 27,
                flags = kHAlignCenter + kVAlignCenter,
                font = RequesterButtonFont,
            },
        },
        Button {
            name = "button_no",
            x = 63 + 250,
            y = kMax - 30,
            align = kHAlignCenter + kVAlignBottom,
            type = kPush,
            graphics = NewButtonGraphics,
            scale = 1,
            default = true,
            command=function()
                play_from_database( "button_click", false, 1.0, 0, 0 )
                ProfilesDialogDeleteRememberYesNo( 0 )
                PopModal( "profile_yesno_dialog" )
            end,
            Text {
                label = "profile_dialog_no",
                x = 0, y = 2, w = kMax, h = 27,
                flags = kHAlignCenter + kVAlignCenter,
                font = RequesterButtonFont,
            },
        },
    },
    },
    FitToChildren(),
}

-- Ensure hierarchy

move_to_front( "window_title" )
move_to_front( "text_window" )
move_to_front( "button_yes" )
move_to_front( "button_no" )
