
loadresource("data\\ingamebg.png","ingamebg",1000004);
loadresource("data\\options.png","options",1000005);

loadresource("data\\strike.png","strike",1000015);

loadresource("data\\buttons.png","buttons",1000017);
loadresource("data\\star.png","star",1000018);

loadresource("data\\m_num.png","help_numbers",1000020);
loadresource("data\\tutorial_win.png","tutorial_win",7000005);
loadresource("data\\tutorial_arrow.png","tutorial_arrow",7000005);
loadresource("data\\tutorial_arrow1.png","tutorial_arrow1",7000005);  
loadresource("data\\tutorial_arrow2.png","tutorial_arrow2",7000005);
loadresource("data\\tutorial_arrow3.png","tutorial_arrow3",7000005);
loadresource("data\\3\\0\\0017.png","clouds",1000020);
loadresource("data\\clouds1.png","clouds1",1000020);
loadresource("data\\clouds2.png","clouds2",1000020);
loadresource("data\\developers.jpg","developers",14);
loadresource("data\\buttons_wind.png","buttons_wind",18061987);
loadresource("data\\exit.png","exit",15);
loadresource("data\\exit.png","exitgame",100001);
loadresource("data\\message.png","message",1000024);
loadresource("data\\wind\\okno.png","okno",5000);
loadresource("data\\wind\\okno1.png","okno1",5000);
loadresource("data\\tuman.png","tuman",5001);
loadresource("data\\tr_shtaf.png","tresh1"           ,70000008);    
loadresource("data\\MWind.png","MWind",666999);
loadresource("data\\all_cursor.png","all_cursor",666999);
loadresource("data\\metka.png","magnifier",666999);
loadresource("data\\sharp_star.png","sharp_star",1000025);
loadresource("data\\ring_cur.png","ring_cur",1000025);
loadresource("data\\helpbtn.png","helpbtn",1000025);
--loadresource("data\\arrow1.png","arrow1",1000025);

addglobalobjecttogame(10000000,"magnifier",2000,0,"",0,0,64,64);--particl star
addglobalobjecttogame(10000001,"ring_cur",2000,0,"",0,0,115,104);--particl star

addglobalobjecttogame( -303033,"star",2000,0,"",0,0,8,8);--particl star
addglobalobjecttogame( -303030,"buttons",0,0,"",0,1008,16,16);--Окно закрывающее весь экран при многократном клике
AddGlobalFade(-303032,0.9);
set_visible_object(400000,true);
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"]   =0.0;
OptionsWnd["posY"]   =0.0;
OptionsWnd["posXimg"]=0.0;
OptionsWnd["posYimg"]=0.0;
OptionsWnd["width"]  =1024.0;
OptionsWnd["height"] =768.0;
-------Слайдер---------------------------------------------------------------------------------
EffectSlider={}
EffectSlider["posX"]           =487.0;
EffectSlider["posY"]           =222.0;
EffectSlider["maxshift"]       =246.0;
EffectSlider["posXimg"]        =729.0;
EffectSlider["posYimg"]        =864.0;
EffectSlider["width"]          =63.0;
EffectSlider["height"]         =63.0;
EffectSlider["offsetx"]      =0.0;
EffectSlider["offsety"]     =0.0;
EffectSlider["func"]         ="musuk";
-------Слайдер---------------------------------------------------------------------------------
MusicSlider={}
MusicSlider["posX"]           =460.0;
MusicSlider["posY"]           =375.0;
MusicSlider["maxshift"]       =244.0;
MusicSlider["posXimg"]        =729.0;  
MusicSlider["posYimg"]        =864.0;
MusicSlider["width"]          =63.0; 
MusicSlider["height"]         =63.0; 
MusicSlider["offsetx"]      =0.0;  
MusicSlider["offsety"]         =0.0;  
MusicSlider["func"]         ="effect";
--------Кнопка перехода в полноэкранный режим--------------------------------------------------------------------------------       
FullScrean={}
FullScrean["posX"]           =249.0;
FullScrean["posY"]           =491.0;
FullScrean["posXimg"]        =559.0;
FullScrean["posYimg"]        =743.0;
FullScrean["width"]          =147.0;
FullScrean["height"]         =137.0;
FullScrean["offsetx"]          =-14.0;
FullScrean["offsety"]         =-149.0;
FullScrean["func"]             ="tofullscrean";
--------Кнопка Ок--------------------------------------------------------------------------------   
OptionsOK={}
OptionsOK["posX"]           =730.0;
OptionsOK["posY"]           =544.0;
OptionsOK["posXimg"]        =835.0;
OptionsOK["posYimg"]        =692.0;
OptionsOK["width"]          =90.0;
OptionsOK["height"]         =107.0;
OptionsOK["offsetx"]          =0.0;
OptionsOK["offsety"]         =0.0;
OptionsOK["func"]             ="tofullscrean";
-------Выделение кнопки ок---------------------------------------------------------------------------------   
OptionsOKSelect={}
OptionsOKSelect["img"]            ="buttons";
OptionsOKSelect["posX"]           =730.0;
OptionsOKSelect["posY"]           =544.0;
OptionsOKSelect["posXimg"]        =930.0;
OptionsOKSelect["posYimg"]        =688.0;
OptionsOKSelect["width"]          =90.0;
OptionsOKSelect["height"]         =107.0;
OptionsOKSelect["func"]         ="close_options";
---------Внутри игровое меню-------------------------------------------------------------------------------   
IngameBG={}
IngameBG["img"]            ="ingamebg";
IngameBG["posX"]           =0.0;
IngameBG["posY"]           =0.0;
IngameBG["posXimg"]        =0.0;
IngameBG["posYimg"]        =0.0;
IngameBG["width"]          =1024.0;
IngameBG["height"]         =768.0;
---------Вернутся в игру-------------------------------------------------------------------------------   
BackToGame={}
BackToGame["posX"]           =407.0;
BackToGame["posY"]           =254.0;
BackToGame["posXimg"]        =372.0;
BackToGame["posYimg"]        =895.0;
BackToGame["width"]          =242.0;
BackToGame["height"]         =27.0;
BackToGame["offsetx"]          =0.0;
BackToGame["offsety"]         =0.0;
----------Вернутся в игру выделение------------------------------------------------------------------------------ 
BackToGameSelect={}
BackToGameSelect["img"]            ="buttons";
BackToGameSelect["posX"]           =405.0;
BackToGameSelect["posY"]           =252.0;
BackToGameSelect["posXimg"]        =364.0;
BackToGameSelect["posYimg"]        =936.0;
BackToGameSelect["width"]          =245.0;
BackToGameSelect["height"]         =30.0;
BackToGameSelect["func"]         ="backtogame1";
----------Переход в опции------------------------------------------------------------------------------ 
ToOptions={}
ToOptions["posX"]           =465.0;
ToOptions["posY"]           =343.0;
ToOptions["posXimg"]        =232.0;
ToOptions["posYimg"]        =895.0;
ToOptions["width"]          =111.0;
ToOptions["height"]         =27.0;
ToOptions["offsetx"]          =0.0;
ToOptions["offsety"]         =0.0;
----------Переход в опции выделение------------------------------------------------------------------------------ 
ToOptionsSelect={}
ToOptionsSelect["img"]            ="buttons";
ToOptionsSelect["posX"]           =465.0;
ToOptionsSelect["posY"]           =343.0;
ToOptionsSelect["posXimg"]        =231.0;
ToOptionsSelect["posYimg"]        =937.0;
ToOptionsSelect["width"]          =113.0;
ToOptionsSelect["height"]         =28.0;
ToOptionsSelect["func"]         ="options";
----------Сохранить и выйти------------------------------------------------------------------------------  
SaveAndExit={}
SaveAndExit["posX"]           =428.0;
SaveAndExit["posY"]           =429.0;
SaveAndExit["posXimg"]        =15.0;
SaveAndExit["posYimg"]        =892.0;
SaveAndExit["width"]          =191.0;
SaveAndExit["height"]         =28.0;
SaveAndExit["offsetx"]      =0.0;
SaveAndExit["offsety"]         =0.0;
-----------Сохранить и выйти выделение----------------------------------------------------------------------------- 
SaveAndExitSelect={}
SaveAndExitSelect["img"]            ="buttons";
SaveAndExitSelect["posX"]           =425.0;
SaveAndExitSelect["posY"]           =427.0;
SaveAndExitSelect["posXimg"]        =134.0;
SaveAndExitSelect["posYimg"]        =985.0;
SaveAndExitSelect["width"]          =196.0;
SaveAndExitSelect["height"]         =32.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"]            ="exit";
ExitMenuBG["posX"]           =0.0;
ExitMenuBG["posY"]           =0.0
ExitMenuBG["posXimg"]        =0.0;
ExitMenuBG["posYimg"]        =0.0;
ExitMenuBG["width"]          =1024.0;
ExitMenuBG["height"]         =768.0;

ExitMenuOk={} 
ExitMenuOk["posX"]           =678.0;
ExitMenuOk["posY"]           =471.0;
ExitMenuOk["posXimg"]        =824.0;
ExitMenuOk["posYimg"]        =807.0;
ExitMenuOk["width"]          =79.0;
ExitMenuOk["height"]         =89.0;
ExitMenuOk["offsetx"]      =0.0;
ExitMenuOk["offsety"]     =0.0;

ExitMenuOkSelect={} 
ExitMenuOkSelect["img"]            ="buttons";
ExitMenuOkSelect["posX"]           =677.0;
ExitMenuOkSelect["posY"]           =471.0;
ExitMenuOkSelect["posXimg"]        =940.0;
ExitMenuOkSelect["posYimg"]        =801.0;
ExitMenuOkSelect["width"]          =87.0;
ExitMenuOkSelect["height"]         =89.0;
ExitMenuOkSelect["func"]             ="gameexit";

ExitMenuToMenu={} 
ExitMenuToMenu["posX"]           =254.0;
ExitMenuToMenu["posY"]           =432.0;
ExitMenuToMenu["posXimg"]        =861.0;
ExitMenuToMenu["posYimg"]        =576.0;
ExitMenuToMenu["width"]          =158.0;
ExitMenuToMenu["height"]         =109.0;
ExitMenuToMenu["offsetx"]      =0.0;
ExitMenuToMenu["offsety"]     =0.0;


ExitMenuToMenuSelect={}
ExitMenuToMenuSelect["img"]            ="buttons";
ExitMenuToMenuSelect["posX"]           =254.0;
ExitMenuToMenuSelect["posY"]           =432.0;
ExitMenuToMenuSelect["posXimg"]        =696.0;
ExitMenuToMenuSelect["posYimg"]        =583.0;
ExitMenuToMenuSelect["width"]          =158.0;
ExitMenuToMenuSelect["height"]         =109.0;
ExitMenuToMenuSelect["func"]             ="backgame";
HelpScreen={}
HelpScreen["posX"]           =451.0;
HelpScreen["posY"]           =510.0;
HelpScreen["posXimg"]        =500.0;
HelpScreen["posYimg"]        =984.0;
HelpScreen["width"]          =165.0;
HelpScreen["height"]         =38.0;
HelpScreen["offsetx"]          =0.0;
HelpScreen["offsety"]         =0.0;
----------Вернутся в игру выделение------------------------------------------------------------------------------ 
HelpScreenSelect={}
HelpScreenSelect["img"]            ="helpbtn";
HelpScreenSelect["posX"]           =452.0;
HelpScreenSelect["posY"]           =509.0;
HelpScreenSelect["posXimg"]        =0.0;
HelpScreenSelect["posYimg"]        =29.0;
HelpScreenSelect["width"]          =164.0;
HelpScreenSelect["height"]         =48.0;
HelpScreenSelect["func"]         ="help_sel";

HintTime={}
HintTime["time"] = 16;


AddOptions();
AddIngameMemu();



--------------------------------------------------Меню игры-------------------------------------------------------------------------------

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;
SetShtrafFunc("Shtrafing",10,30)
function MessageFromMenu(nCount,Param1)
  -- messagebox("Param1="..Param1)
 if Param1 == 7000025 or Param1 == 7000026 or Param1 == 7000027 then  --7000004
    -- if Param1 == 12346 then  --7000004
    ClearCursor()
    RemObjFromMouse()
    showoptons(0);
  return; end;
return;end;

function MessageProc(event,id)
-- if event==1 then
        -- if id == -10 then --кликаем на паузу
            -- if ingame_options == false then
                -- playeffect("click");    
                -- setpouse(true);
            -- end    
        -- return 0; end
        
            -- if id == -303032 or id == -303031 then--кликаем на черный экран

                -- if gamepause then
                    -- setpouse(false);                    
            -- end
         -- end    
-- return end;
--/////////////////////////////////Обробатываем нажатие на ескейп/////////////////////////////////////////////
if event==2 then
--messageboxi(id);
-- if id==2000028 then
    -- if not ingame_options then

      -- pause(true);
	if not flags.IngameMenu then
    flags.IngameMenu=true;
	else
	flags.IngameMenu=false;
	end;
    showoptons();
    RemObjFromMouse()   
    -- return;end;
-- return;end;    
-- if id==2000029 then
--    messagebox("help_mini")
--return;end;    
return; end;
    --////////////////////////////////////////////////////////////////////////////////////////////////////////////    
if event==3 then
    WriteToConsole("flags.GlobalHint = "..tostring(flags.GlobalHint).." flags.Is_Satellite = "..tostring(flags.Is_Satellite).." \n")
	if is_tutorial then
		tutorialGameInput(6)
	end;
	if not tutorialprocessing then
	--	messagebox("flags.GlobalHint = "..tostring(flags.GlobalHint))
        if (not flags.GlobalHint) and (not flags.Is_Satellite) then
            --  messagebox("flag");
			SelectRandom()
		 if (not_hint==false) 	then    
                playeffect("hint")
                speciale_action(2,8000027)
                speciale_action(2,8000028)
                speciale_action(2,8000029)
                speciale_action(2,8000030)       
				WriteToConsole("anim")
                StartAnimation(12345,0,6);
                -- AlternateTimer("StartHint",0.2*1000)
               StartTimer(333,0.2,"StartHint",true)
                --StartTimer(333,0.2);
                flags.GlobalHint = true;
			return; end;
			        if  not_hint then
not_hint=false

end;
           return; end;
		 end;  
		
        --selectrandomobjectus(1.5);    
return;end;
if event==5 then

    speciale_action(2,8000027)
    speciale_action(2,8000028)
    speciale_action(2,8000029)
    speciale_action(2,8000030)

return;end;
--////////////////////////////////////////////////////////////////////////////////////////////////////////////        
end
function showoptons(param)
    playeffect("click");    
    --speciale_action(2,-2);
    ingame_options = not ingame_options;
    show_ingame_menu(ingame_options);
    ClearCursor()
end;
--////////////////////////////////////////////////////////////////////////////////////////////////////////////
function close_options()
    options_menu(false);
    flags.IngameMenu=false;
end
function h_i(sender)
    if sender==1 then
        from_menu=false
        DelTreeFromMenu("manual")
        --delete_tree_leaf("manual")
        SetIngameMenuFunc("")
        BlockMenu(false)
    return;end;
end;
function help_sel()
    from_menu=true;
    if not repeat_help then
        add_tree_leaf("Root","manual",0,12);
        dofile("data/0/12/res.lua")
        repeat_help=true
        set_activ_leaf(cur_lev,cur_lev_numb,0);
        if not flags.is_hidden_loc then
            SwitchToSheet("gr");
            SetDrawSheet("gr",true);
        end;
        if flags.is_hidden_loc then
            SwitchToSheet("re");
            SetDrawSheet("gr",false);
        end;        
    end;
    AddTreeToMenu("manual")
    SetIngameMenuFunc("h_i")
    BlockMenu(true)
end;
function backtogame1()
    showoptons(false);
flags.IngameMenu=false;
    -- pause(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 FinishLevel()
    WriteToConsole("FinishLevel \n")

end;

function save_exit()
    if flags.obj_id_gl~=0 and flags.obj_id_gl~=nil then
        flags.ShowWindow=true
        -- if flags.is_hidden_loc then
            -- LevelComplete()
            -- StartTimer(762221,2,"FinishLevel",true)
        -- else
        -- StoreObj1(flags.obj_id_gl,flags.metka_gl)
        -- StartTimer(762221,1,"FinishLevel",true)
        -- end;
    end;
    SaveGame();
    StopAllEffects()
    clear_satelite_leaf(cur_lev)
    setstatemenu();
end
------------------------------------------------------------------------------------------------------- 
function setpouse(value)
    -- pause(value);
    
    -- set_visible_object(-303031,value);
    -- speciale_action(4,-303031);
    -- if value then

    -- set_visible_object(-303032,value);
    -- else
        -- set_visible_object(-303032,value);        
    -- end;
    -- gamepause=value;
end
---------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------- 
function gameexit(value)
    SaveGame();
    exitgame();
end
---------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------- 
function backgame(value)
    SaveGame();
    StopAllEffects()
    WriteToConsole("Current Level = "..cur_lev.."\n")
    clear_satelite_leaf(cur_lev)
    setstatemenu();    
end
---------------------------------------------------------------------------------------------------------

