require "scripts/style"

imgWidthX = 248;
imgWidthY = 141;
offsetX   = 10;
posX      = kCenter - imgWidthX - offsetX;
posY      = {90,270};
-- time related
textWidth      = 85;
--timeOffsetY    = 25;
timeValueExtraOffsetX = 8;

function placeLevelImages( )
    
	t = { SetStyle(QuickTaskStyle), BeginGroup() };
    
    counter = gLvlNumber+1;
    tPosX = posX;
    tPosY = posY[1];
    for i = 1,6 do 
        if(i == 4) then
            tPosY = posY[2];
            tPosX = posX;
        end
    
        SetStyle(WorldMapMenuButtonStyle);
-- level button with picture of the level
        table.insert(t,
            Button
            {
                x = tPosX,
                y = tPosY,

                name="chooseLevelButton"..i,
                graphics = { "pics/levelthumbs/lvl_"..counter.."_normal",
                             "pics/levelthumbs/lvl_"..counter.."_normal",
                             "pics/levelthumbs/lvl_"..counter.."_over" },
                type = kPush,
                command=
                    function()
                        levelChoosen(i-1)
                        CloseWindow(true);
                    end	    
            }
        );
        table.insert(t,
            Text
            {
                font = StandardButtonFontBig,
                name = "bestTimeText"..i,
                x=tPosX - textWidth/2,
                y=tPosY + imgWidthY, 
                w=textWidth,
                h=30,
                flags = kHAlignLeft+kVAlignCenter,
                label = "chooseLevel_BestTime"
            }
        );  
        table.insert(t,
            Text
            {
                font = StandardButtonFontBig,
                name = "bestTimeValue"..i,
                x=tPosX + textWidth/2 + timeValueExtraOffsetX,
                y=tPosY + imgWidthY, 
                w=textWidth,
                h=30,
                flags = kHAlignLeft+kVAlignCenter,
                label = "infoBar_LevelTimeEmpty"
            }
        );    
--[[        
        table.insert(t,
            Text
            {
                font = StandardButtonFontBig,
                name = "levelTimeText"..i,
                x=tPosX - textWidth/2,
                y=tPosY + imgWidthY + timeOffsetY, 
                w=textWidth,
                h=30,
                flags = kHAlignLeft+kVAlignCenter,
                label = "chooseLevel_levelTimeText"
            }
        );    
        table.insert(t,
            Text
            {
                font = StandardButtonFontBig,
                name = "levelTimeValue"..i,
                x=tPosX + textWidth/2 + timeValueExtraOffsetX,
                y=tPosY + imgWidthY + timeOffsetY, 
                w=textWidth,
                h=30,
                flags = kHAlignLeft+kVAlignCenter,
                label = "infoBar_LevelTimeEmpty"
            }
        );--]]
        counter = counter + 1;
        tPosX = tPosX + imgWidthX + offsetX;
    end
   
    return Group(t);
end


MakeDialog
{
	-- Name the modal dialog
	name="choose_level",
	Bitmap
	{
		image="backgrounds/dialog_levelchooser",
		x = kCenter,
		y = kCenter,
        
        levelChooserMenu{
			x = 0, y = 0, w=kMax, h=kMax,        
-- Title            
            Text
            {
                font = StandardButtonFontFour,
                name = "stationName",
                x=kCenter,
                y=45,
                w=335,h=30,
                flags = kHAlignCenter + kVAlignCenter,
                label = "StationName1"
            };
-- back button
            SetStyle(SmallEmptyRoundButtonStyle),
            Button
            {
                x = kCenter,
                y = kMax-80,
                name="chooseLevelBack",
                label="back",
                close=true,
                cancel=true,
                default=true,
                type = kPush,
                command=
                    function()
                        CloseWindow(false);
                    end	    
            },
            placeLevelImages( );            
        }
    },
}


