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


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=60,y=24,w=182,h=44,
                label="comics_farm3_1_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=427,y=25,w=198,h=44,
                label="comics_farm3_1_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=208,y=228,w=186,h=32,
                label="comics_farm3_1_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont1,
                x=557,y=211,w=166,h=50,
                label="comics_farm3_1_text4",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name="text1_5",
                font = ComicsFont2,
                x=474,y=284,w=190,h=48,
                label="comics_farm3_1_text5",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont2,
                x=500,y=403,w=144,h=48,
                label="comics_farm3_1_text6",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont2,
                x=58,y=434,w=106,h=100,
                label="comics_farm3_1_text7",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name="text1_8",
                font = ComicsFont2,
                x=198,y=482,w=132,h=48,
                label="comics_farm3_1_text8",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                font = ComicsFont2,
                x=400,y=469,w=308,h=54,
                label="comics_farm3_1_text9",
                flags = kHAlignCenter + kVAlignCenter,
            },
        },
        Window 
        {
            name = "text_page2",
            x=0,y=0,w=800,h=600,
            Text {
                name = "text2_1",
                font = ComicsFont2,
                x=61,y=23,w=254,h=52,
                label="comics_farm3_2_text1",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_2",
                font = ComicsFont2,
                x=151,y=183,w=229,h=51,
                label="comics_farm3_2_text2",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_3",
                font = ComicsFont2,
                x=494,y=303,w=162,h=42,
                label="comics_farm3_2_text3",
                flags = kHAlignCenter + kVAlignCenter,
            },
            Text {
                name = "text2_4",
                font = ComicsFont2,
                x=470,y=470,w=227,h=45,
                label="comics_farm3_2_text4",
                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_5",-3);
SetUnderlineDistance("text1_8",-3);
SetUnderlineDistance("text2_4",-3);
--[[
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);
