require( "scripts/style.lua" );
--DebugOut("ChoosePlayer");

txtStatH = 26;
txtStatUnderline = 26;
txtStatY = 105;
txtStatX1 = 195;
txtStatW1 = 240;
txtStatX2 = 410;
txtStatW2 = 70;

StatFont = {
  standardFont,
  24,
  BlackColor
};

HeaderFont = {
  bigButtonFont,
  50,
  DarkRedColor
};

ButtonX = kCenter;
ButtonY = 90;
ButtonYSpace = 30;

kMaxUsers = 10

NameButtonGraphics = {
	"buttons/choosenameover.png",
	"buttons/choosenamedown.png",
	"buttons/choosenameover.png",
	"buttons/choosenamedown.png"
};	

NameStyle= {
	type = kRadio,
	flags = kHAlignCenter + kVAlignCenter,
	font = StandardButtonFont,
	graphics = NameButtonGraphics,
	sound = kDefaultButtonSound
};


MakeDialog
{
	-- Name the modal dialog
	name="statistic_wnd",
    Bitmap
    {
        name="grayimage",
        image="backgrounds/shadow.png",
        alpha=true,
        x=0,
        y=0
    };
    
	Bitmap
	{ 
		image="backgrounds/select_player",
		x=kCenter,
		y=kCenter,
        w=675,
        h=574,
		
		Bitmap
		{
			x = 0, y = 0, w=kMax, h=kMax,
			
			Text
			{
				font = HeaderFont,
				name = "caption_wnd",
				x=0,y=5,w=kMax,h=kMax,
				flags = kHAlignCenter + kVAlignTop,
				label = "stat_txt_collected"
			};
--статистика
--линия 1
			Text
			{
				font = StatFont,
				name = "stat_txt_expert",
				x=txtStatX1,y=txtStatY,w=txtStatW1,h=txtStatH,
				label = "stat_txt_expert"
			};
			Text
			{
				font = StatFont,
				name = "expert",
				x=txtStatX2,y=txtStatY,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 2
			Text
			{
				font = StatFont,
				name = "stat_txt_egg",
				x=txtStatX1,y=txtStatY + txtStatUnderline,w=txtStatW1,h=txtStatH,
				label = "stat_txt_egg"
			};
			Text
			{
				font = StatFont,
				name = "egg",
				x=txtStatX2,y=txtStatY + txtStatUnderline,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 3
			Text
			{
				font = StatFont,
				name = "stat_txt_milk",
				x=txtStatX1,y=txtStatY + txtStatUnderline*2,w=txtStatW1,h=txtStatH,
				label = "stat_txt_milk"
			};
			Text
			{
				font = StatFont,
				name = "milk",
				x=txtStatX2,y=txtStatY + txtStatUnderline*2,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 4
			Text
			{
				font = StatFont,
				name = "stat_txt_milkgoat",
				x=txtStatX1,y=txtStatY + txtStatUnderline*3,w=txtStatW1,h=txtStatH,
				label = "stat_txt_milkgoat"
			};
			Text
			{
				font = StatFont,
				name = "milkgoat",
				x=txtStatX2,y=txtStatY + txtStatUnderline*3,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 5
			Text
			{
				font = StatFont,
				name = "stat_txt_tomatos",
				x=txtStatX1,y=txtStatY + txtStatUnderline*4,w=txtStatW1,h=txtStatH,
				label = "stat_txt_tomatos"
			};
			Text
			{
				font = StatFont,
				name = "tomatos",
				x=txtStatX2,y=txtStatY + txtStatUnderline*4,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 6
			Text
			{
				font = StatFont,
				name = "stat_txt_corns",
				x=txtStatX1,y=txtStatY + txtStatUnderline*5,w=txtStatW1,h=txtStatH,
				label = "stat_txt_corns"
			};
			Text
			{
				font = StatFont,
				name = "corns",
				x=txtStatX2,y=txtStatY + txtStatUnderline*5,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 7
			Text
			{
				font = StatFont,
				name = "stat_txt_pumpkin",
				x=txtStatX1,y=txtStatY + txtStatUnderline*6,w=txtStatW1,h=txtStatH,
				label = "stat_txt_pumpkin"
			};
			Text
			{
				font = StatFont,
				name = "pumpkin",
				x=txtStatX2,y=txtStatY + txtStatUnderline*6,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 8
			Text
			{
				font = StatFont,
				name = "stat_txt_shear",
				x=txtStatX1,y=txtStatY + txtStatUnderline*7,w=txtStatW1,h=txtStatH,
				label = "stat_txt_shear"
			};
			Text
			{
				font = StatFont,
				name = "shear",
				x=txtStatX2,y=txtStatY + txtStatUnderline*7,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 9
			Text
			{
				font = StatFont,
				name = "stat_txt_cheese",
				x=txtStatX1,y=txtStatY + txtStatUnderline*8,w=txtStatW1,h=txtStatH,
				label = "stat_txt_cheese"
			};
			Text
			{
				font = StatFont,
				name = "cheese",
				x=txtStatX2,y=txtStatY + txtStatUnderline*8,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 10
			Text
			{
				font = StatFont,
				name = "stat_txt_grape",
				x=txtStatX1,y=txtStatY + txtStatUnderline*9,w=txtStatW1,h=txtStatH,
				label = "stat_txt_grape"
			};
			Text
			{
				font = StatFont,
				name = "grapes",
				x=txtStatX2,y=txtStatY + txtStatUnderline*9,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 11
			Text
			{
				font = StatFont,
				name = "stat_txt_apple",
				x=txtStatX1,y=txtStatY + txtStatUnderline*10,w=txtStatW1,h=txtStatH,
				label = "stat_txt_apple"
			};
			Text
			{
				font = StatFont,
				name = "apple",
				x=txtStatX2,y=txtStatY + txtStatUnderline*10,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 12
			Text
			{
				font = StatFont,
				name = "stat_txt_orange",
				x=txtStatX1,y=txtStatY + txtStatUnderline*11,w=txtStatW1,h=txtStatH,
				label = "stat_txt_orange"
			};
			Text
			{
				font = StatFont,
				name = "orange",
				x=txtStatX2,y=txtStatY + txtStatUnderline*11,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
--линия 13
			Text
			{
				font = StatFont,
				name = "stat_txt_watermelon",
				x=txtStatX1,y=txtStatY + txtStatUnderline*12,w=txtStatW1,h=txtStatH,
				label = "stat_txt_watermelon"
			};
			Text
			{
				font = StatFont,
				name = "watermelon",
				x=txtStatX2,y=txtStatY + txtStatUnderline*12,w=txtStatW2,h=txtStatH,
                flags = kHAlignRight,
				label = "null_text"
			};
            
--конец статистики
			SetStyle(ButtonStyle);
				
			Button
			{
                x=264, y=440,
                graphics = StButtonGraphicsMid,
                font = MenuButtonFont;
                scale=0.9,
				name="chooseok",
				label="ok",
				type = kPush,
				default = true,
                sound=kDefaultButtonSound,
				command = 
					function()
						PopModal("statistic_wnd");
					end
				
			};
				
		}
	}
}

function IteratorUserProducts(aKey,aValue)
    if (aValue > 0) then
        SetLabel(aKey,""..aValue);
    else
        SetLabel(aKey,"0");
    end
end

function SetValueStatistic()
    SetLabel("expert",""..gGlobalPlayerInfo.gExpert);
    table.foreach( gGlobalPlayerInfo.gProducts, IteratorUserProducts );
end

EnableWindow("stat_txt_watermelon",false);
EnableWindow("watermelon",false);

SetImageAlpha("grayimage",0.4);
SetValueStatistic();
