require "scripts/dialog_common.lua"

play_from_database( "requester_open", false, 1.0, 0, 0 )

local opt_text_x = 463
local opt_text_y = 135
local opt_text_y_offset = 45
local opt_text_font = "fonts/garamont.mvec"
local opt_text_font_size = 18
local opt_button_font_size = 28
local optt_text_w = 150
local optt_text_h = 35
local opt_text_font_color = { 0.0, 0.0, 0.0, 1.0 }

local sliderYOffset = 20
local sliderGroupYOffset = 79
local sliderWidth = 150

OptionsTextFont = {
    opt_text_font,
    opt_text_font_size,
    Color(0,0,0,255)
};

ButtonFont = {
    opt_text_font,
    opt_button_font_size,
    Color(0,0,0,255)
};

ButtonFontRed = {
    opt_text_font,
    opt_button_font_size,
    Color(126,1,1,255)
};


ButtonGraphics = {
    "images/dummy.png",
    "images/dummy.png",
    "images/dummy.png",
};

SliderStyle =
{
	parent=DefaultStyle,
	railtop = "slider/osliderrailtop",
	railmid = "slider/osliderrailmid",
	railbot = "slider/osliderrailbot",
	sliderimage = "slider/osliderknob",
	sliderrollimage = "slider/osliderknobover",
	yoffset = 0, -- scoot the slider down by one pixel to center it.
} ;

CheckboxButtonGraphics = {
	"buttons/ochbx",
	"buttons/ochbxchecked",
	"buttons/ochbxover",
	"buttons/ochbxcheckedover"
} ;

CheckboxButtonStyle = {
	parent = DefaultStyle,
	font = OptionsTextFont,
	type = kToggle,
	sound = kDefaultButtonSound,
	graphics = CheckboxButtonGraphics,
} ;

MakeDialog
{
    name="options_dialog",

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

    OptionsWindow {
        fit = true,
        x = kCenter,
        y = kCenter,
        w = 800,
        h = 600,

        --requester_background( 280, "blue", "better" ),

        Text
        {
            font = ButtonFontRed,
            name = "window_title",
            x = opt_text_x, y = opt_text_y - 15, w = 150, h = 40,
            flags = kHAlignCenter + kVAlignCenter,
            label = "options_title"
        },
    
        Text
        {
            font = OptionsTextFont,
            name = "label_sfx",
            x = opt_text_x, y = sliderGroupYOffset + 140, w = 100, h = 50,
            flags = kHAlignCenter + kVAlignCenter,
            label = "options_sfx"
        },
    
        Text
        {
            font = OptionsTextFont,
            name = "label_music",
            x = opt_text_x, y = sliderGroupYOffset + 190, w = 100, h = 50,
            flags = kHAlignCenter + kVAlignCenter,
            label = "options_music"
        },

        Text
        {
            font = OptionsTextFont,
            name = "label_voice",
            x = opt_text_x, y = sliderGroupYOffset + 240, w = 100, h = 50,
            flags = kHAlignCenter + kVAlignCenter,
            label = "options_voice"
        },

        SetStyle(CheckboxButtonStyle),
        Button
        {
            name = "check_fullscreen",
            x = opt_text_x +  7, y = opt_text_y + 35,w = 150, h = 22,
            Text
            {
                font = OptionsTextFont,
                name = "label_fullscreen",
                x = 25, y = 0, w = kMax, h = kMax,
                flags = kHAlignLeft + kVAlignTop,
                label="options_full",
            };
        },

        Button
        {
            name = "check_mute",
            x = opt_text_x + 7, y = opt_text_y + 60, w = 155, h = 22,
            Text
            {
                font = OptionsTextFont,
                name = "label_mute",
                x = 25, y = 0, w = kMax, h = kMax,
                flags = kHAlignLeft + kVAlignTop,
                label="options_mute",
            },
        },

        SetStyle( SliderStyle ),
        Slider
        {
            name = "slider_sfx",
            x = opt_text_x, y = sliderGroupYOffset + 150 + sliderYOffset, w = sliderWidth, h = 50,
        },
        
        Slider
        {
            name = "slider_music",
            x = opt_text_x, y = sliderGroupYOffset + 200 + sliderYOffset, w = sliderWidth, h = 50,
        },

        Slider
        {
            name = "slider_voice",
            x = opt_text_x, y = sliderGroupYOffset + 250 + sliderYOffset, w = sliderWidth, h = 50,
        },

        Button {
            name = "button",
            x = 658,
            y = 85,
            w = 100,
            h = 40,
            align = kHAlignCenter + kVAlignBottom,
            type = kPush,
            --graphics = ButtonGraphics,
            scale = 1,
            command=function()
                play_from_database( "button_click_alt", false, 1.0, 0, 0 )
                PopModal( "options_dialog" )
            end,
            Text {
                label = "back",
                x = 0, y = 0, w = kMax, h = 30,
                flags = kHAlignCenter + kVAlignCenter,
                font = ButtonFont,
            },
        },
    },
    },
    FitToChildren(),
}
