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 ]
)
text_size = text_size + 20 -- reserves some space around the text.
local full_height = dialog_height( text_size )

MakeDialog
{
    name="statistics_dialog",
    Window {
        fit = true,
        x = 0,
        y = 0,
        w = 497,
        h = full_height,

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

        Text
        {
            font = SpecialRequesterTitleFont,
            name = "window_title",
            x = kCenter, y = 32 + 0, w = 160, h = 34,
            flags = kHAlignCenter + kVAlignCenter,
            label = "statistics_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",
            x = kCenter,
            y = kMax - 5,
            align = kHAlignCenter + kVAlignBottom,
            type = kPush,
            graphics = RequesterButtonGraphics,
            scale = 1,
            default = true,
            command=function()
                play_from_database( "button_click", false, 1.0, 0, 0 )
                PopModal( "statistics_dialog" )
            end,
            Text {
                label = "continue",
                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" )
