setfocusfunc("StartPause")

--loadresource("data\\mb.png","button",1000001);
loadresource("data\\menu.png","menu",1000002);
loadresource("data\\pt.png","pt",1000003);
loadresource("data\\ingamebg.png","ingamebg",1000004);
loadresource("data\\options.png","options",1000005);
--loadresource("data\\map.png","map",1000006);
--loadresource("data\\help.png","help",1000007);
--loadresource("data\\options.png","options",1000008);
--loadresource("data\\tomain.png","tomain",1000009);
loadresource("data\\pause.png","pause",1000010);
--loadresource("data\\clear.jpg","clear",1000011);
--loadresource("data\\endlavel.png","endlavel",1000012);
--loadresource("data\\helper.png","helper",1000013);
loadresource("data\\strike.png","strike",1000015);
loadresource("data\\exit.png","exit",1000016);
loadresource("data\\buttons.png","buttons",1000017);
loadresource("data\\star.png","star",1000018);
--loadresource("data\\particle.png","particle",1000019);
--loadresource("data\\m_num.png","help_numbers",1000020);
--loadresource("data\\c_el.png","c_el",1000021);
--loadresource("data\\selc.png","selc",1000024);
--loadresource("data\\c_el_l.png","c_el_l",1000022);
--loadresource("data\\helpwindow.jpg","helpwindow",1000023);
--loadresource("data\\gmap.jpg","gmap",99);
loadresource("data\\exit.png","exitgame",100001);
loadresource("data\\rc.png","randomclick",100002);
loadresource("data\\message.png","message",1000024);
loadresource("data\\sharp_star.png","sharp_star",1000025);
loadresource("data\\pb.png","pb",1000026);
loadresource("data\\messageinfo.png","messageinfo",1000027);
loadresource("data\\skip.png","skip",2000027);
loadresource("data\\developers.jpg","developers",14);
loadresource("data\\spause.png","spause",73);

addglobalobjecttogame( 11111,"spause",0,0,"",0,0,1024,768);--надпись пауза
addglobalobjecttogame( -303033,"star",-100,-100,"",0,0,8,8);--particl star
addglobalobjecttogame( -313031,"randomclick",200,200,"",0,0,615,335);
addglobalobjecttogame( -303030,"buttons",0,0,"",0,1008,16,16);--Окно закрывающее весь экран при многократном клике
addglobalobjecttogame( -303031,"pt",143,217,"",0,0,512,128);--надпись пауза
AddGlobalFade(-303032,0.9);
set_visible_object(11111,false);
set_visible_object(-303030,false);
set_visible_object(-303031,false);
set_visible_object(-313031,false);
set_visible_object(-303032,false);
--------------------------------------------------Меню игры-------------------------------------------------------------------------------
--------------------------------------------------Меню игры-------------------------------------------------------------------------------
------Окошко Настройки----------------------------------------------------------------------------------
OptionsWnd={}
OptionsWnd["img"]="options";
OptionsWnd["posX"]   =229.0;
OptionsWnd["posY"]   =143.0;
OptionsWnd["posXimg"]=0.0;
OptionsWnd["posYimg"]=0.0;
OptionsWnd["width"]  =512.0;
OptionsWnd["height"] =538.0;
-------Слайдер---------------------------------------------------------------------------------
EffectSlider={}
EffectSlider["posX"]   		=366.0;
EffectSlider["posY"]   		=420.0;
EffectSlider["maxshift"]   	=247.0;
EffectSlider["posXimg"]		=0.0;
EffectSlider["posYimg"]		=129.0;
EffectSlider["width"]  		=40.0;
EffectSlider["height"] 		=40.0;
EffectSlider["offsetx"]  	=0.0;
EffectSlider["offsety"] 	=0.0;
EffectSlider["func"] 		="effect";
-------Слайдер---------------------------------------------------------------------------------
MusicSlider={}
MusicSlider["posX"]   		=366.0;
MusicSlider["posY"]   		=300.0;
MusicSlider["maxshift"]   	=247.0;
MusicSlider["posXimg"]		=0.0;  
MusicSlider["posYimg"]		=129.0;
MusicSlider["width"]  		=40.0; 
MusicSlider["height"] 		=40.0; 
MusicSlider["offsetx"]  	=0.0;  
MusicSlider["offsety"] 		=0.0;  
MusicSlider["func"] 		="musuk";
--------Кнопка перехода в полноэкранный режим--------------------------------------------------------------------------------       
FullScrean={}
FullScrean["posX"]   		=515.0;
FullScrean["posY"]   		=534.0;
FullScrean["posXimg"]		=0.0;
FullScrean["posYimg"]		=177.0;
FullScrean["width"]  		=40.0;
FullScrean["height"] 		=35.0;
FullScrean["offsetx"]  		=0.0;
FullScrean["offsety"] 		=35.0;
FullScrean["func"] 			="tofullscrean";
--------Кнопка Ок--------------------------------------------------------------------------------   
OptionsOK={}
OptionsOK["posX"]   		=616.0;
OptionsOK["posY"]   		=522.0;
OptionsOK["posXimg"]		=50.0;
OptionsOK["posYimg"]		=143.0;
OptionsOK["width"]  		=46.0;
OptionsOK["height"] 		=32.0;
OptionsOK["offsetx"]  		=0.0;
OptionsOK["offsety"] 		=0.0;
--OptionsOK["func"] 			="tofullscrean";
-------Выделение кнопки ок---------------------------------------------------------------------------------   
OptionsOKSelect={}
OptionsOKSelect["img"]			="buttons";
OptionsOKSelect["posX"]   		=608.0;
OptionsOKSelect["posY"]   		=508.0;
OptionsOKSelect["posXimg"]		=42.0;
OptionsOKSelect["posYimg"]		=130.0;
OptionsOKSelect["width"]  		=61.0;
OptionsOKSelect["height"] 		=61.0;
OptionsOKSelect["func"] 		="close_options";
---------Внутри игровое меню-------------------------------------------------------------------------------   
IngameBG={}
IngameBG["img"]			="ingamebg";
IngameBG["posX"]   		=318.0;
IngameBG["posY"]   		=184.0;
IngameBG["posXimg"]		=0.0;
IngameBG["posYimg"]		=0.0;
IngameBG["width"]  		=373.0;
IngameBG["height"] 		=325.0;
---------Вернутся в игру-------------------------------------------------------------------------------   
BackToGame={}
BackToGame["posX"]   		=393.0;
BackToGame["posY"]   		=215.0;
BackToGame["posXimg"]		=23.0;
BackToGame["posYimg"]		=317.0;
BackToGame["width"]  		=242.0;
BackToGame["height"] 		=46.0;
BackToGame["offsetx"]  		=0.0;
BackToGame["offsety"] 		=0.0;
----------Вернутся в игру выделение------------------------------------------------------------------------------ 
BackToGameSelect={}
BackToGameSelect["img"]			="buttons";
BackToGameSelect["posX"]   		=370.0;
BackToGameSelect["posY"]   		=211.0;
BackToGameSelect["posXimg"]		=466.0;
BackToGameSelect["posYimg"]		=468.0;
BackToGameSelect["width"]  		=285.0;
BackToGameSelect["height"] 		=57.0;
BackToGameSelect["func"] 		="back";
----------Переход в опции------------------------------------------------------------------------------ 
ToOptions={}
ToOptions["posX"]   		=426.0;
ToOptions["posY"]   		=320.0;
ToOptions["posXimg"]		=12.0;
ToOptions["posYimg"]		=443.0;
ToOptions["width"]  		=156.0;
ToOptions["height"] 		=46.0;
ToOptions["offsetx"]  		=0.0;
ToOptions["offsety"] 		=0.0;
----------Переход в опции выделение------------------------------------------------------------------------------ 
ToOptionsSelect={}
ToOptionsSelect["img"]			="buttons";
ToOptionsSelect["posX"]   		=370.0;
ToOptionsSelect["posY"]   		=315.0;
ToOptionsSelect["posXimg"]		=466.0;
ToOptionsSelect["posYimg"]		=468.0;
ToOptionsSelect["width"]  		=285.0;
ToOptionsSelect["height"] 		=57.0;
ToOptionsSelect["func"] 		="options";
----------Сохранить и выйти------------------------------------------------------------------------------ 
SaveAndExit={}
SaveAndExit["posX"]   		=382.0;
SaveAndExit["posY"]   		=419.0;
SaveAndExit["posXimg"]		=192.0;
SaveAndExit["posYimg"]		=446.0;
SaveAndExit["width"]  		=268.0;
SaveAndExit["height"] 		=44.0;
SaveAndExit["offsetx"]  	=0.0;
SaveAndExit["offsety"] 		=0.0;
-----------Сохранить и выйти выделение----------------------------------------------------------------------------- 
SaveAndExitSelect={}
SaveAndExitSelect["img"]			="buttons";
SaveAndExitSelect["posX"]   		=370.0;
SaveAndExitSelect["posY"]   		=412.0;
SaveAndExitSelect["posXimg"]		=466.0;
SaveAndExitSelect["posYimg"]		=468.0;
SaveAndExitSelect["width"]  		=285.0;
SaveAndExitSelect["height"] 		=57.0;
SaveAndExitSelect["func"] 			="save_exit";
---------------------------------------------------------------------------------------- 
------------------Кнопка разработчики----------------------------------------------------------------------
ToDevWnd={}
ToDevWnd["posX"]   		=388.0;
ToDevWnd["posY"]   		=600.0;
ToDevWnd["posXimg"]		=55.0;
ToDevWnd["posYimg"]		=262.0;
ToDevWnd["width"]  		=189.0;
ToDevWnd["height"] 		=47.0;
ToDevWnd["offsetx"]  	=0.0;
ToDevWnd["offsety"] 	=0.0;
------------------Выделение кнопки разработчики----------------------------------------------------------------------
ToDevWndSelect={}
ToDevWndSelect["img"]			="buttons";
ToDevWndSelect["posX"]   		=380.0;
ToDevWndSelect["posY"]   		=592.0;
ToDevWndSelect["posXimg"]		=46.0;
ToDevWndSelect["posYimg"]		=197.0;
ToDevWndSelect["width"]  		=204.0;
ToDevWndSelect["height"] 		=59.0;
ToDevWndSelect["func"] 			="todevelopers";
---------------Окошко Разработчики---------------------------------------------
 
DevelopersWND={}
DevelopersWND["img"]			="developers";
DevelopersWND["posX"]   		=0.0;
DevelopersWND["posY"]   		=0.0;
DevelopersWND["posXimg"]		=0.0;
DevelopersWND["posYimg"]		=0.0;
DevelopersWND["width"]  		=1024.0;
DevelopersWND["height"] 		=768.0;
-------------Кнопка Ок---------------------------------------------------------------------------
DevelopersWNDOk={}
DevelopersWNDOk["img"]			="buttons";
DevelopersWNDOk["posX"]   		=715.0;
DevelopersWNDOk["posY"]   		=687.0;
DevelopersWNDOk["posXimg"]		=482.0;
DevelopersWNDOk["posYimg"]		=191.0;
DevelopersWNDOk["width"]  		=95.0;
DevelopersWNDOk["height"] 		=70.0;
-------------Выделение для кнопки Ок---------------------------------------------------------------------------
DevelopersWNDOkSelect={}
DevelopersWNDOkSelect["img"]			="buttons";
DevelopersWNDOkSelect["posX"]   		=715.0;
DevelopersWNDOkSelect["posY"]   		=687.0;
DevelopersWNDOkSelect["posXimg"]		=482.0;
DevelopersWNDOkSelect["posYimg"]		=260.0;
DevelopersWNDOkSelect["width"]  		=95.0;
DevelopersWNDOkSelect["height"] 		=70.0;
DevelopersWNDOkSelect["func"] 			="backtooptions";
----------------------------------------------------------------------------------------
 ExitMenuBG={}
ExitMenuBG["img"]			="exitgame";
ExitMenuBG["posX"]   		=173.0;
ExitMenuBG["posY"]   		=146.0
ExitMenuBG["posXimg"]		=0.0;
ExitMenuBG["posYimg"]		=0.0;
ExitMenuBG["width"]  		=512.0;
ExitMenuBG["height"] 		=323.0;

ExitMenuOk={} 
ExitMenuOk["posX"]   		=459.0;
ExitMenuOk["posY"]   		=408.0;
ExitMenuOk["posXimg"]		=885.0;
ExitMenuOk["posYimg"]		=480.0;
ExitMenuOk["width"]  		=116.0;
ExitMenuOk["height"] 		=34.0;
ExitMenuOk["offsetx"]  	=0.0;
ExitMenuOk["offsety"] 	=0.0;

ExitMenuOkSelect={} 
ExitMenuOkSelect["img"]			="buttons";
ExitMenuOkSelect["posX"]   		=451.0;
ExitMenuOkSelect["posY"]   		=401.0;
ExitMenuOkSelect["posXimg"]		=885.0;
ExitMenuOkSelect["posYimg"]		=426.0;
ExitMenuOkSelect["width"]  		=133.0;
ExitMenuOkSelect["height"] 		=48.0;
ExitMenuOkSelect["func"] 			="gameexit";

ExitMenuToMenu={} 
ExitMenuToMenu["posX"]   		=272.0;
ExitMenuToMenu["posY"]   		=408.0;
ExitMenuToMenu["posXimg"]		=760.0;
ExitMenuToMenu["posYimg"]		=480.0;
ExitMenuToMenu["width"]  		=116.0;
ExitMenuToMenu["height"] 		=34.0;
ExitMenuToMenu["offsetx"]  	=0.0;
ExitMenuToMenu["offsety"] 	=0.0;


ExitMenuToMenuSelect={}
ExitMenuToMenuSelect["img"]			="buttons";
ExitMenuToMenuSelect["posX"]   		=264.0;
ExitMenuToMenuSelect["posY"]   		=401.0;
ExitMenuToMenuSelect["posXimg"]		=885.0;
ExitMenuToMenuSelect["posYimg"]		=426.0;
ExitMenuToMenuSelect["width"]  		=133.0;
ExitMenuToMenuSelect["height"] 		=48.0;
ExitMenuToMenuSelect["func"] 			="backgame";

HintTime={}
HintTime["time"] = 60;
AddOptions();
AddIngameMemu();

-- add_shape(80,400,300);
-- speciale_action(1,80);

local showhelp=false;
local click=0;
local helpload=false;

backpage=-1;
ingame_options=false;
complete=false;
gamepause = false;
-- function MessageFromMenu(nCount,Param1)
-- if Param1==2000029 then
	-- help();
-- return;end;
-- showoptons(0);
-- return;end;

function StartPause()
	if not flags.comics then
		set_visible_object(11111,true);
		speciale_action(4,11111);
		pause_state=true;
	end;
end;

function MessageProc(event,id,selectedid)
if event==1 then

return end;
--/////////////////////////////////Обробатываем нажатие на ескейп/////////////////////////////////////////////
if event==2 then

	if not ingame_options then

	  showoptons();	
	return;end;

return; end;
	--////////////////////////////////////////////////////////////////////////////////////////////////////////////	
if event==3 then
		--	messagebox("sfdf");
		-- selectrandomobject(1.5);	
		playeffect("help");
		if selectedid~=0 then	  
		  SelectRandomRadar(selectedid);
		end;  
		if selectedid==0 then
		   
		   SelectRandom();
		end;
return;end;
--////////////////////////////////////////////////////////////////////////////////////////////////////////////		
end
function showoptons(param)
	playeffect("click");	
	--speciale_action(2,-2);
	ingame_options = not ingame_options;
	show_ingame_menu(ingame_options);
end;
--////////////////////////////////////////////////////////////////////////////////////////////////////////////
function close_options()
	options_menu(false);
end
function back()
	showoptons(false);
			pause_state=false;
			set_visible_object(11111,false);
end
function help()
	--messagebox("Pres Help");
	show_help(true);

	--if not showhelp then 
		--showhelp=true;
		--show_help(showhelp);
		-- speciale_action(2,-22);--скрываем обьект, помощь
		--show_ingame_menu(false);	
	--return;end;
	
	--if  showhelp then
		--showhelp=false;
		--show_help(showhelp);
		-- speciale_action(2,-22);--скрываем обьект, помощь
		--show_ingame_menu(true);		
	--return;end;	
	
end
function options()
	options_menu(true);
end
function save_exit()
 if not flags.comics then
	savegame(SaveLevel());
end;	
	setstatemenu();
	--showoptons();
	--pause(false);
end
------------------------------------------------------------------------------------------------------- 
function setpouse(value)

end
---------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------- 
function gameexit(value)
 if not flags.comics then
	savegame(SaveLevel());
	end;
	exitgame();
end
---------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------- 
function backgame(value)
 if not flags.comics then
	savegame(SaveLevel());
	end;
	setstatemenu();	
end
---------------------------------------------------------------------------------------------------------
function todevelopers()
	switch_ingame_menu(4)
end
------------------------------------------------------------------------------------------------------- 
function backtooptions()
	switch_ingame_menu(2)
end
