gFileName = "backgrounds/page5_";
gCurrentFile = 1;
gFilesCount = 2;


ComicsFont1 = {
  standardFont,
  18,
  BlackColor
};
ComicsFont2 = {
  standardFont,
  16,
  BlackColor
};
ComicsFont3 = {
  standardFont,
  22,
  BlackColor
};
ComicsFont4 = {
  standardFont,
  15,
  BlackColor
};

function SetScreen(screen)
    if(screen<1 or screen>gFilesCount)then
        if(screen>gFilesCount )then
	        SendGameMessage( "quit" );
            return;
        end;
        PopModal("tutorial");
    else
        gCurrentFile = screen;
        if(gCurrentFile==1)then
            SetLabel("first_button",GetString("close"));
            EnableWindow("first_button",false);
        else
            SetLabel("first_button",GetString("prev"));
            EnableWindow("first_button",true);          
        end;
        
        if(gCurrentFile==gFilesCount)then
            SetLabel("second_button", GetString("menu"));
			EnableWindow("skip_button", false);
			
        else
            SetLabel("second_button", GetString("next"));
			EnableWindow("skip_button", true);			
        end;
        
        SetBitmap("tutorial_image",gFileName..gCurrentFile);
        
        for wt_ind = 1,gFilesCount,1 do
            if (wt_ind == gCurrentFile) then 
                EnableWindow("text_page"..wt_ind,true);
            else
                EnableWindow("text_page"..wt_ind,false);
            end
        end
        
    end
end

MakeDialog
{
    name="tutorial",
    ParamTimer
    {
        param = "ComicScreenTime";
    };
    
    Bitmap
    {
        name="tutorial_image",
        image=gFileName..gCurrentFile,
        x=0,
        y=0,
        w = 800,
        h = 600,
        Window 
        {
            name = "text_page1",
            x=0,y=0,w=800,h=600,
            Text {
                name="text1_1",
                font = ComicsFont2,
                x = 59, y = 192,w = 137, h = 50,
                label="comics_farm5_1_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name="text1_2",
                font = ComicsFont2,
                x = 311, y = 172,w = 133, h = 119,
                label="comics_farm5_1_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name="text1_3",
                font = ComicsFont4,
                x = 471, y = 165,w = 121, h = 107,
                label="comics_farm5_1_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name="text1_4",
                font = ComicsFont2,
                x = 85, y = 266,w = 236, h = 50,
                label="comics_farm5_1_text4",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name="text1_5",
                font = ComicsFont2,
                x = 424, y = 264,w = 290, h = 83,
                label="comics_farm5_1_text5",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name="text1_6",
                font = ComicsFont2,
                x = 77, y = 475,w = 144, h = 48,
                label="comics_farm5_1_text6",
                flags = kHAlignCenter + kVAlignCenter,
            },
        },
        Window 
        {
            name = "text_page2",
            x=0,y=0,w=800,h=600,
            Text {
                name = "text2_1",
                font = ComicsFont2,
                x = 71, y = 6,w = 79, h = 52,
                label="comics_farm5_2_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_2",
                font = ComicsFont2,
                x = 63, y = 195,w = 264, h = 71,
                label="comics_farm5_2_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_3",
                font = ComicsFont2,
                x = 474, y = 208,w = 132, h = 72,
                label="comics_farm5_2_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_4",
                font = ComicsFont2,
                x = 94, y = 474,w = 142, h = 75,
                label="comics_farm5_2_text4",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_5",
                font = ComicsFont2,
                x = 440, y = 482,w = 167, h = 50,
                label="comics_farm5_2_text5",
                flags = kHAlignCenter + kVAlignCenter,
            },
        },
        Button
        {
            x=5,
            y=550,
            w=100,
            h = 44,
            font = StandardButtonFont,
            graphics = TutorialButton,
            name="first_button",
            label="prev",
            type = kPush,
            sound = kDefaultButtonSound,
            command=
                function()
                    SetScreen(gCurrentFile-1);
                end
        },
        
        
        Button
        {
            x=350,
            y=550,
            w=100,
            h = 44,
            font = StandardButtonFont,
            graphics = TutorialButton,
            name="skip_button",
            label="skip",
            sound = kDefaultButtonSound,            
            type = kPush,
            command=
                function()
                    SetScreen(999999);
                end
        },
        
        
        
        Button
        {
            x=680,
            y=550,
            w=100,
            h = 44,         
            font = StandardButtonFont,
            graphics = TutorialButton,
            name="second_button",
            label="next",
            type = kPush,
            sound = kDefaultButtonSound,            
            command=
                function()
                    SetScreen(gCurrentFile+1);
                end
        };
        
    };

}
SetUnderlineDistance("text1_1",-3);
SetUnderlineDistance("text1_2",-4);
SetUnderlineDistance("text1_3",-4);
SetUnderlineDistance("text2_2",-3);
SetUnderlineDistance("text2_4",-3);
--[[

SetUnderlineDistance("text3_2",-2);
SetUnderlineDistance("text3_3",-3);
SetUnderlineDistance("text3_4",-3);

SetUnderlineDistance("text4_1",-2);
SetUnderlineDistance("text4_3",-4);
SetUnderlineDistance("text4_4",-2);
SetUnderlineDistance("text4_5",-2);
SetUnderlineDistance("text4_6",-2);
SetUnderlineDistance("text4_7",-2);
SetUnderlineDistance("text4_8",-2);
--]]

SetScreen(1);
