
ECA_BOTTOM_LEFT = 0;
ECA_BOTTOM_RIGHT = 1;
ECA_ANY_FREE_POSITION = 2;

------------------------------------------------------------------------------
--
function RegisterGlobalCharacters()
	local anim = CreateAnimation('data/Texture/Comics/Characters/sara1.png',0,0, 375.0,673.0, 1,0);
	anim:SetHotSpot(100.0, 673.0);
--	anim:SetBlendMode(2);
--	anim:SetColor('0xFFFFFFFF');
	GetComicsManager():RegisterCharacter('Sarah1', anim, '0xFFFFFFFF');
	local anim = CreateAnimation('data/Texture/Comics/Characters/sara2.png',0,0, 375.0,673.0, 1,0);
	anim:SetHotSpot(100.0, 673.0);
	GetComicsManager():RegisterCharacter('Sarah2', anim, '0xFFFFFFFF');
	local anim = CreateAnimation('data/Texture/Comics/Characters/sara3.png',0,0, 375.0,673.0, 1,0);
	anim:SetHotSpot(100.0, 673.0);
	GetComicsManager():RegisterCharacter('Sarah3', anim, '0xFFFFFFFF');


	local anim = CreateAnimation('data/Texture/Comics/Characters/michael1.png',0,0, 375.0,673.0, 1,0);
	anim:SetHotSpot(130.0, 673.0);
	GetComicsManager():RegisterCharacter('Michael1', anim, '0xFFFFFFFF');
	local anim = CreateAnimation('data/Texture/Comics/Characters/michael2.png',0,0, 512.0,400.0, 1,0);
	anim:SetHotSpot(256.0, 400.0);
	GetComicsManager():RegisterCharacter('Michael2', anim, '0xFFFFFFFF');


	local anim = CreateAnimation('data/Texture/Comics/Characters/John1.png',0,0, 375.0,673.0, 1,0);
	anim:SetHotSpot(130.0, 673.0);
	GetComicsManager():RegisterCharacter('John1', anim, '0xFFFFFFFF');
	local anim = CreateAnimation('data/Texture/Comics/Characters/John2.png',0,0, 375.0,673.0, 1,0);
	anim:SetHotSpot(130.0, 673.0);
	GetComicsManager():RegisterCharacter('John2', anim, '0xFFFFFFFF');

--	local anim = CreateAnimation('data/Texture/dummy.bmp',0,0, 1.0,1.0, 1,0);
--	anim:SetHotSpot(0,0);
--	GetComicsManager():RegisterCharacter('Unknown', anim, '0xFFFFFFFF');
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function LoadGlobalComicsData()
	RegisterGlobalCharacters();

	local cm = GetComicsManager(); 

	cm:BeginComic('Level1Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:ShowCharacter(	'Michael1', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Sarah1');
	cm:AddCharacterCue(	'Michael1', GetTextString('LEVEL1_INTRO_TEXT2'));
	cm:FadeCharacter(	'Michael1');
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL1_INTRO_TEXT3'));
	cm:HideCharacter(	'Sarah1');
	cm:HideCharacter(	'Michael1');
	cm:EndComic();

	cm:BeginComic('Level2Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:ShowCharacter(	'Michael1', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Sarah1');
	cm:AddCharacterCue(	'Michael1', GetTextString('LEVEL2_INTRO_TEXT2'));
	cm:FadeCharacter(	'Michael1');
	cm:HideCharacter(	'Sarah1');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL2_INTRO_TEXT3'));
	cm:HideCharacter(	'Sarah3');
	cm:HideCharacter(	'Michael1');
	cm:EndComic();
	cm:BeginComic('Level2Outro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:ShowCharacter(	'Michael1', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Sarah1');
	cm:AddCharacterCue(	'Michael1', GetTextString('LEVEL2_OUTRO_TEXT1'));
	cm:FadeCharacter(	'Michael1');
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL2_OUTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:HideCharacter(	'Michael1');
	cm:EndComic();

	cm:BeginComic('Level3Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:ShowCharacter(	'Michael1', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Michael1');
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL3_INTRO_TEXT2'));
	cm:FadeCharacter(	'Sarah1');
	cm:AddCharacterCue(	'Michael1', GetTextString('LEVEL3_INTRO_TEXT3'));
	cm:FadeCharacter(	'Michael1');
	cm:HideCharacter(	'Sarah1');
	cm:HideCharacter(	'Michael1');
	cm:EndComic();
	cm:BeginComic('Level3Outro');
	cm:ShowCharacter(	'Sarah2', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah2', GetTextString('LEVEL3_OUTRO_TEXT1'));
	cm:HideCharacter(	'Sarah2');
	cm:EndComic();

	cm:BeginComic('Level4Intro');
	cm:ShowCharacter(	'Sarah2', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah2', GetTextString('LEVEL4_INTRO_TEXT21'));
	cm:HideCharacter(	'Sarah2');
	cm:EndComic();

	cm:BeginComic('Level5Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL5_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();
	cm:BeginComic('Level5Outro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL5_OUTRO_TEXT1'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level6Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL6_INTRO_TEXT2'));
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL6_INTRO_TEXT3'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level7Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL7_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL7_INTRO_TEXT3'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level8Intro');
	cm:EndComic();
	cm:BeginComic('Level8Outro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL8_OUTRO_TEXT1'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level9Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL9_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level10Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL10_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level11Intro');
	cm:ShowCharacter(	'Sarah2', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah2', GetTextString('LEVEL11_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah2');
	cm:EndComic();

	cm:BeginComic('Level12Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL12_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level13Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL13_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level14Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL14_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level15Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL15_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level16Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL16_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level17Intro');
	cm:ShowCharacter(	'Sarah2', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah2', GetTextString('LEVEL17_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah2');
	cm:EndComic();

	cm:BeginComic('Level18Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL18_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level19Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL19_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level20Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL20_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();

	cm:BeginComic('Level21Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL21_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL21_INTRO_TEXT3'));
	cm:HideCharacter(	'Sarah3');
	cm:ShowCharacter(	'Sarah2', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah2', GetTextString('LEVEL21_INTRO_TEXT4'));
	cm:HideCharacter(	'Sarah2');
	cm:EndComic();

	cm:BeginComic('Level22Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL22_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level23Intro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL23_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();

	cm:BeginComic('Level24Intro');
	cm:ShowCharacter(	'Sarah3', ECA_BOTTOM_LEFT);
	cm:AddCharacterCue(	'Sarah3', GetTextString('LEVEL24_INTRO_TEXT2'));
	cm:HideCharacter(	'Sarah3');
	cm:EndComic();
	cm:BeginComic('Level24Outro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:ShowCharacter(	'Michael1', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Sarah1');
	cm:AddCharacterCue(	'Michael1', GetTextString('LEVEL24_OUTRO_TEXT1'));
	cm:FadeCharacter(	'Michael1');
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL24_OUTRO_TEXT2'));
	cm:HideCharacter(	'Sarah1');
	cm:HideCharacter(	'Michael1');
	cm:EndComic();

	cm:BeginComic('Level25Intro');
	cm:ShowCharacter(	'Sarah2', ECA_BOTTOM_LEFT);
	cm:ShowCharacter(	'Michael1', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Michael1');
	cm:AddCharacterCue(	'Sarah2', GetTextString('LEVEL25_INTRO_TEXT2'));
	cm:FadeCharacter(	'Sarah2');
	cm:AddCharacterCue(	'Michael1', GetTextString('LEVEL25_INTRO_TEXT3'));
	cm:HideCharacter(	'Michael1');
	cm:ShowCharacter(	'John2', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Sarah2');
	cm:AddCharacterCue(	'John2', GetTextString('LEVEL25_INTRO_TEXT4'));
	cm:HideCharacter(	'Sarah2');
	cm:HideCharacter(	'John2');
	cm:EndComic();

	cm:BeginComic('Level25JohnSaved');
	cm:ShowCharacter(	'John1', ECA_BOTTOM_RIGHT);
	cm:AddCharacterCue(	'John1', GetTextString('LEVEL25_JOHN_SAVED_TEXT1'));
	cm:HideCharacter(	'John1');
	cm:EndComic();

	cm:BeginComic('Level25Outro');
	cm:ShowCharacter(	'Sarah1', ECA_BOTTOM_LEFT);
	cm:ShowCharacter(	'Michael1', ECA_BOTTOM_RIGHT);
	cm:FadeCharacter(	'Sarah1');
	cm:AddCharacterCue(	'Michael1', GetTextString('LEVEL25_OUTRO_TEXT1'));
	cm:FadeCharacter(	'Michael1');
	cm:AddCharacterCue(	'Sarah1', GetTextString('LEVEL25_OUTRO_TEXT2'));
	cm:HideCharacter(	'Michael1');
	cm:HideCharacter(	'Sarah1');
	cm:EndComic();
end

------------------------------------------------------------------------------
--
function ShowLevelIntro(levelIndex, delay)
	assert(playField ~= nil and GetLevelMap()[levelIndex] ~= nil);
	delay = (delay ~= nil and delay or 1.75);

	local levelIndexStr = tostring(levelIndex);
--	local storyTextName = 'LEVEL'..levelIndexStr..'_INTRO_TEXT1';
	local comicsName = 'Level'..levelIndexStr..'Intro';
	
	local comicsFirstCueName = 'LEVEL'..levelIndexStr..'_INTRO_TEXT2';
	local comicsFirstCueText = GetTextString(comicsFirstCueName);

	if (comicsFirstCueText ~= "" and comicsFirstCueText ~= "* NO APPROPRIATE TEXT *") then
--		TimerDoString('playField:GetLevelScreen():ShowInfoScreen(GetTextString(\''..storyTextName..'\'));', delay, playField:GetTimer());
		TimerDoString('playField:GetLevelScreen():ShowComicScreen(\''..comicsName..'\');', 1.15*delay, playField:GetTimer());
	end
end

