gFileName = "backgrounds/page1_";
gCurrentFile = 1;
gFilesCount = 4;


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

function SetScreen(screen)
    if(screen<1 or screen>gFilesCount)then
        if(--[[gStartLevelAfterClose==0 and--]] screen<1 )then
            PopModal("tutorial");
            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("start"));
        else
            SetLabel("second_button",GetString("next"));
        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 {
                font = ComicsFont1,
                x=436,y=10,w=266,h=80,
                label="comics_farm1_1_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont3,
                x=88,y=51,w=182,h=60,
                label="comics_farm1_1_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=123,y=207,w=175,h=38,
                label="comics_farm1_1_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=514,y=465,w=220,h=62,
                label="comics_farm1_1_text4",
                flags = kHAlignCenter + kVAlignCenter,
            },
        },
        Window 
        {
            name = "text_page2",
            x=0,y=0,w=800,h=600,
            Text {
                name = "text2_1",
                font = ComicsFont1,
                x=568,y=28,w=112,h=39,
                label="comics_farm1_2_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_2",
                font = ComicsFont1,
                x=498,y=82,w=100,h=35,
                label="comics_farm1_2_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_3",
                font = ComicsFont1,
                x=560,y=132,w=129,h=40,
                label="comics_farm1_2_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_4",
                font = ComicsFont1,
                x=500,y=184,w=100,h=40,
                label="comics_farm1_2_text4",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_5",
                font = ComicsFont2,
                x=65,y=276,w=160,h=50,
                label="comics_farm1_2_text5",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_6",
                font = ComicsFont2,
                x=280,y=280,w=100,h=33,
                label="comics_farm1_2_text6",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_7",
                font = ComicsFont2,
                x=399,y=237,w=94,h=60,
                label="comics_farm1_2_text7",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=547,y=252,w=134,h=42,
                label="comics_farm1_2_text8",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_9",
                font = ComicsFont2,
                x=115,y=340,w=100,h=65,
                label="comics_farm1_2_text9",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=88,y=495,w=260,h=25,
                label="comics_farm1_2_text10",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=400,y=486,w=198,h=46,
                label="comics_farm1_2_text11",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_12",
                font = ComicsFont1,
                x=605,y=486,w=145,h=38,
                label="comics_farm1_2_text12",
                flags = kHAlignCenter + kVAlignCenter,
            },
        },
        Window 
        {
            name = "text_page3",
            x=0,y=0,w=800,h=600,
            Text {
                font = ComicsFont1,
                x=68,y=30,w=168,h=50,
                label="comics_farm1_3_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text3_2",
                font = ComicsFont2,
                x=62,y=308,w=88,h=94,
                label="comics_farm1_3_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text3_3",
                font = ComicsFont2,
                x=158,y=300,w=220,h=44,
                label="comics_farm1_3_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text3_4",
                font = ComicsFont2,
                x=466,y=300,w=274,h=46,
                label="comics_farm1_3_text4",
                flags = kHAlignCenter + kVAlignCenter,
            },
        },
        Window 
        {
            name = "text_page4",
            x=0,y=0,w=800,h=600,
            Text {
                name = "text4_1",
                font = ComicsFont2,
	            x = 277,
	            y = 26,
	            w = 150,
	            h = 38,
                label="comics_farm1_4_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text4_2",
                font = ComicsFont2,
                x=556,y=27,w=170,h=28,
                label="comics_farm1_4_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text4_3",
                font = ComicsFont2,
	            x = 58,
	            y = 160,
	            w = 180,
	            h = 79,
                label="comics_farm1_4_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text4_4",
                font = ComicsFont2,
	            x = 250,
	            y = 159,
	            w = 202,
	            h = 59,
                label="comics_farm1_4_text4",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text4_5",
                font = ComicsFont2,
	            x = 67,
	            y = 231,
	            w = 272,
	            h = 90,
                label="comics_farm1_4_text5",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text4_6",
                font = ComicsFont2,
	            x = 164,
	            y = 318,
	            w = 160,
	            h = 75,
                label="comics_farm1_4_text6",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text4_7",
                font = ComicsFont2,
	            x = 395,
	            y = 261,
	            w = 145,
	            h = 47,

                label="comics_farm1_4_text7",
                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("text2_5",-3);
SetUnderlineDistance("text2_6",-3);
SetUnderlineDistance("text2_7",-2);
SetUnderlineDistance("text2_9",-3);
SetUnderlineDistance("text2_12",-2);

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);
