require "scripts/style"

kFirstMatchY = 300;
kMatchPicHalfWidth = 77; -- 155 is the width
kCreditPicHalfWidth = 20; -- 40 is the width

function setStaticBasicItemPics( )
	
    t = { SetStyle(QuickTaskStyle), BeginGroup() };

    local offsetY = 165;
-- fill the name of the file
    local itemName = "pics/";
    if(gItemType == 1) then itemName = itemName.."food_lvl";  end
    if(gItemType == 2) then itemName = itemName.."money_lvl"; end
    if(gItemType == 3) then itemName = itemName.."stone_lvl"; end
    if(gItemType == 4) then itemName = itemName.."wood_lvl";  end

-- item before    
    table.insert(t,
        Bitmap
        {
            name = "itemBeforePic",
            image = itemName..(gLevel-1),
            x = kCenter-63,
            y = offsetY,
            scale = 1.1
        }
    );

-- arrow  
    table.insert(t,
        Bitmap
        {
            name = "arrowPic",
            image = "pics/onetime_dialog_gfx/arrow",
            x = kCenter,
            y = offsetY-8,
            --scale = 1.1
        }
    );
    
-- item now    
    table.insert(t,
        Bitmap
        {
            name = "itemNowPic",
            image = itemName..gLevel,
            x = kCenter+63,
            y = offsetY,
            scale = 1.1
        }
    );    
    -- add the level number
    itemName = itemName..gLevel;
    for i=3,5 do
        offsetY = kFirstMatchY + (i-3)*47;
-- match pic
        table.insert(t,
            Bitmap
            {
                name = "match"..i.."Pic",
                image = "pics/matchimages/match"..i,
                x = kCenter-110,
                y = offsetY,
                scale = 0.8
            }
        );
-- item pic
        table.insert(t,
            Bitmap
            {
                name = "leveledUpItem",
                image = itemName,
                x = kCenter+40,
                y = offsetY+5,
                --scale = 0.9            
            }
        );
-- credits pic
        table.insert(t,
            Bitmap
            {
                name = "creditsForItem",
                image = "pics/items/points",
                x = kCenter+kMatchPicHalfWidth-kCreditPicHalfWidth+100,
                y = offsetY+5,
            }
        );
    end
    return Group(t);
end

function setItemPointPics( )
	
    t = { SetStyle(QuickTaskStyle), BeginGroup() };

    local offsetX;
    local offsetY;
    
    for i=3,5 do
        offsetX = kCenter-17;
        offsetY = kFirstMatchY + (i-3)*47;    
-- points for resources
        table.insert(t,
            Bitmap
            {
                name = "match"..i.."Pic",
                image = "pics/onetime_dialog_gfx/"..(i*i*gLevel),
                x = offsetX,
                y = offsetY,
                scale = 0.8
            }
        
        );
        offsetX = kCenter+99;
        
-- credits for resources
        table.insert(t,
            Bitmap
            {
                name = "creditsForMatch"..i,
                image = "pics/onetime_dialog_gfx/"..(i*i),
                x = offsetX,
                y = offsetY,
                scale = 0.8
            }
        );
    end
    return Group(t);
end


MakeDialog
{
	-- Name the modal dialog
	name="itemLeveledUp",
	Bitmap
	{
		--image="backgrounds/dialog_itemsandmatches",
        image="backgrounds/largedialog",
		x = kCenter,
		y = kCenter,

-- Title
			Text
			{
				align=kHAlignLeft,
				font = StandardButtonFontFour,
				name = "itemLeveledUpTitle",
				x=kCenter,
                y=50,
                w=kMax-100, h=30,
				flags = kHAlignCenter + kVAlignCenter,
				label = "itemsInStyleTitle"
			};

-- Description 1
			Text
			{
				align=kHAlignLeft,
				font = StandardButtonFontBig,
				name = "itemLeveledUpDescription1",
				x=kCenter,
                y=85,
                w=kMax-100, h=80,
				flags = kHAlignCenter + kVAlignCenter,
				label = "itemsInStyle02Description1"
			};
-- Description 2
			Text
			{
				align=kHAlignLeft,
				font = StandardButtonFontBig,
				name = "itemLeveledUpDescription2",
				x=kCenter,
                y=235,
                w=kMax-100, h=60,
				flags = kHAlignCenter + kVAlignCenter,
				label = "itemsInStyle02Description2"
			};

            SetStyle(SmallEmptyRoundButtonStyle),
			Button
			{
				x = kCenter,
				y = kMax-86, --84,
				name="itemLeveledUpOK",
				label="ok",
				close=true,
				default=true,
				type = kPush,
                command=
                    function()
                    end	                    
			},            
-- set pics for basic items
            setStaticBasicItemPics();
            setItemPointPics();
--		},
	},
}


