----------- Рамка миниигр и доп.локаций--------------
loadresource("data\\ramka.png","mini_Ramka");
loadresource("data\\ramka_shadow.png","mini_Ramka_shadow");
--loadresource("data\\menu\\1\\mini_skip.png","mini_skip");
loadresource("data\\plashechka.png","plashechka");

loadresource("data\\tutorial_win.png","tutorial_win");
loadresource("data\\tutorial_arrow.png","tutorial_arrow");
loadresource("data\\tutorial_arrow1.png","tutorial_arrow1");
-----------------------------------------------------
loadresource("data\\skip1.png","skip1")
loadresource("data\\skip2.png","skip2")
loadresource("data\\skip3.png","skip3")
-----------------------------------------------------
loadresource("data\\buttons.png","buttons",1000017);
loadresource("data\\exit.png","exit",15);

loadresource("data\\message.png","message",1000024);
loadresource("data\\okno.png","okno",5000);

loadresource("data\\menu_texture1.png","menu_texture1");
loadresource("data\\ring_cur.png","ring_cur");
loadresource("data\\arrow.png","cursor");

dofile("script\\settings_dialog.lua")
dofile("script\\exit_dialog.lua")

addglobalobjecttogame(10000001,"ring_cur",2000,0,"")
addglobalobjecttogame(10000002,"cursor",2000,0,"")




AddOptions();
AddIngameMemu();

--------------------------------------------------Меню игры-------------------------------------------------------------------------------
exit_pressed = -200
exit_active = -201
options_pressed = -202
options_active = -203
back_pressed = -204
back_active = -205
ingame_menu_bg = -206
ingame_menu=false;


------------------------------------------------------------
--  function: MessageFromMenu
------------------------------------------------------------

function MessageFromMenu(nCount,Param1)
  Write("MessageFromMenu: nCount="..nCount.."; Param1"..Param1.."\n")
  if flags.is_hidden_loc and flags.collapsed==15 then return end
  if nCount == 1 then
    removeFromMouse()
    gameinput(8,-1,-1)  -- костыль чтоб работала мини-игра 6/10
    if Param1 == 7000007 then
      if not ingame_menu then
        showIngameMenu()
        ingame_menu = true
      else
        del_object_from_game(ingame_menu_bg)
        del_object_from_game(back_active)
        del_object_from_game(options_active)
        del_object_from_game(exit_active)
        del_object_from_game(back_pressed)
        del_object_from_game(options_pressed)
        del_object_from_game(exit_pressed)
        ingame_menu = false
        SetShtrafFunc("Shtrafing",10,30)
        setInputFunction()
        Write("resume\n")
      end
      return
    end
    if Param1 == 7000013 then
      if not ingame_menu then
        Journal:click()
        return
      end
    end
  end
end


------------------------------------------------------------
--  function: MessageProc
------------------------------------------------------------
function MessageProc(event,id)
  Write("MessageProc: sender = "..event.."; obj_id="..id.."\n")
  removeFromMouse()
  gameinput(8,-1,-1)  -- костыль чтоб работала мини-игра 6/10
  if event==2 then
    if not ingame_menu then
      showIngameMenu()
      ingame_menu = true
    else
      CloseIngameMenu()
        
--      pressed = back_pressed
    --  ingameMenuGameInput(6,0)
    end      
  end;
  if event==3 then
    --if flags.is_hidden_loc and flags.collapsed==15 then return end
    --if not Journal.visible and not ingame_menu and hintReady and not(flags.is_hidden_loc and flags.collapsed==15) then
    if hintReady and not (Journal.visible or ingame_menu or (flags.is_hidden_loc and flags.collapsed==15)) then
      Write("hint\n")
      -- if tutorial_window then
        -- CloseTutorial()
      -- end;      
      -- playeffect("hint")
      SelectRandom()
    end
  end;  
end

function CloseIngameMenu()
      del_object_from_game(ingame_menu_bg)
      del_object_from_game(back_active)
      del_object_from_game(options_active)
      del_object_from_game(exit_active)
      del_object_from_game(back_pressed)
      del_object_from_game(options_pressed)
      del_object_from_game(exit_pressed)
      ingame_menu = false  
      setInputFunction()      
      SetShtrafFunc("Shtrafing",10,30)
end;

------------------------------------------------------------
--  function: showIngameMenu
------------------------------------------------------------
function showIngameMenu()

  SetShtrafFunc("dummy",10,30)

  addstaticobjecttogame(ingame_menu_bg,"menu_texture1"  ,280,110,"",0  ,471,496,365)
  addstaticobjecttogame(exit_active,"menu_texture1"    ,367,344,"",497,56 ,317,45 )
  addstaticobjecttogame(exit_pressed,"menu_texture1"    ,338,341,"",605,0  ,383,48 ) 
  addstaticobjecttogame(options_active,"menu_texture1"  ,367,269,"",497,99,317,45 )
  addstaticobjecttogame(options_pressed,"menu_texture1"  ,338,265,"",0  ,423,383,48 )
  addstaticobjecttogame(back_active,"menu_texture1"    ,367,197,"",497,143,317,45 )
  addstaticobjecttogame(back_pressed,"menu_texture1"    ,338,197,"",383,423,383,44 )
      
  speciale_action(4,ingame_menu_bg)
  speciale_action(4,exit_active)
  speciale_action(4,exit_pressed)
  speciale_action(4,options_active)
  speciale_action(4,options_pressed)
  speciale_action(4,back_active)
  speciale_action(4,back_pressed)
  
  set_visible_object(exit_pressed,false)
  set_visible_object(options_pressed,false)
  set_visible_object(back_pressed,false)
  
  SetAlfaValue(back_active,0.01)
  SetAlfaValue(options_active,0.01)
  SetAlfaValue(exit_active,0.01)
  
  OnMouseOver(back_active)
  OnMouseOver(options_active)
  OnMouseOver(exit_active)  

  setInputFunction("ingameMenuGameInput")
  function ingameMenuGameInput(sender,obj_id)
    Write("menuGameInput: sender = "..sender.."; obj_id="..tostring(obj_id).."\n")
    
    -- if sender == 2 then
      -- if not ingame_menu then
        -- showIngameMenu()
        -- ingame_menu = true
      -- else
        -- ingameMenuGameInput(6,0)
      -- end
    -- end
    if sender==2 then
      MessageProc(sender,obj_id);
    return;end;    
    if threeStateButton(sender,obj_id,attachedID,back_active,back_pressed) then
      CloseIngameMenu()
      Write("resume\n")
    end
    
    if threeStateButton(sender,obj_id,attachedID,exit_active,exit_pressed) then
      CloseIngameMenu()
      Exit()
      Write("exit\n")    
    end

    if threeStateButton(sender,obj_id,attachedID,options_active,options_pressed) then
      CloseIngameMenu()
      fromIngameMenu=true
      showOptions()
      Write("options\n")
    end
  end
end

function setpouse(value)
  Write("Alt+F4\n")
  return
end
-- function gameexit(value)
  -- SaveGame();
  -- exitgame();
-- end
-- function backgame(value)
  -- CloseSatelite()
  -- SaveGame();
  -- setstatemenu();
-- end





















------Окошко Настройки----------------------------------------------------------------------------------
OptionsWnd={}
OptionsWnd["img"]="menu_texture1";
OptionsWnd["posX"]   =0.0;
OptionsWnd["posY"]   =0.0;
OptionsWnd["posXimg"]=0.0;
OptionsWnd["posYimg"]=0.0;
OptionsWnd["width"]  =1.0;
OptionsWnd["height"] =1.0;
-------Слайдер---------------------------------------------------------------------------------
EffectSlider={}
EffectSlider["posX"]       =1.0;
EffectSlider["posY"]       =1.0;
EffectSlider["maxshift"]     =1.0;
EffectSlider["posXimg"]    =1.0;
EffectSlider["posYimg"]    =1.0;
EffectSlider["width"]      =1.0;
EffectSlider["height"]     =1.0;
EffectSlider["offsetx"]    =0.0;
EffectSlider["offsety"]   =0.0;
EffectSlider["func"]     ="musuk";
-------Слайдер---------------------------------------------------------------------------------
MusicSlider={}
MusicSlider["posX"]       =1.0;
MusicSlider["posY"]       =1.0;
MusicSlider["maxshift"]     =1.0;
MusicSlider["posXimg"]    =1.0;  
MusicSlider["posYimg"]    =1.0;
MusicSlider["width"]      =1.0; 
MusicSlider["height"]     =1.0; 
MusicSlider["offsetx"]    =0.0;  
MusicSlider["offsety"]     =0.0;  
MusicSlider["func"]     ="effect";
--------Кнопка перехода в полноэкранный режим--------------------------------------------------------------------------------       
FullScrean={}
FullScrean["posX"]       =1.0;
FullScrean["posY"]       =1.0;
FullScrean["posXimg"]    =1.0;
FullScrean["posYimg"]    =1.0;
FullScrean["width"]      =1.0;
FullScrean["height"]     =1.0;
FullScrean["offsetx"]      =-1.0;
FullScrean["offsety"]     =-1.0;
FullScrean["func"]       ="tofullscrean";
--------Кнопка Ок--------------------------------------------------------------------------------   
OptionsOK={}
OptionsOK["posX"]       =1.0;
OptionsOK["posY"]       =1.0;
OptionsOK["posXimg"]    =1.0;
OptionsOK["posYimg"]    =1.0;
OptionsOK["width"]      =1.0;
OptionsOK["height"]     =1.0;
OptionsOK["offsetx"]      =0.0;
OptionsOK["offsety"]     =0.0;
OptionsOK["func"]       ="tofullscrean";
-------Выделение кнопки ок---------------------------------------------------------------------------------   
OptionsOKSelect={}
OptionsOKSelect["img"]      ="menu_texture1";
OptionsOKSelect["posX"]       =1.0;
OptionsOKSelect["posY"]       =1.0;
OptionsOKSelect["posXimg"]    =1.0;
OptionsOKSelect["posYimg"]    =1.0;
OptionsOKSelect["width"]      =1.0;
OptionsOKSelect["height"]     =1.0;
OptionsOKSelect["func"]     ="close_options";
---------Внутри игровое меню-------------------------------------------------------------------------------   
IngameBG={}
IngameBG["img"]      ="menu_texture1";
IngameBG["posX"]       =0.0;
IngameBG["posY"]       =0.0;
IngameBG["posXimg"]    =0.0;
IngameBG["posYimg"]    =0.0;
IngameBG["width"]      =1.0;
IngameBG["height"]     =1.0;
---------Вернутся в игру-------------------------------------------------------------------------------   
BackToGame={}
BackToGame["posX"]       =1.0;
BackToGame["posY"]       =1.0;
BackToGame["posXimg"]    =1.0;
BackToGame["posYimg"]    =1.0;
BackToGame["width"]      =1.0;
BackToGame["height"]     =1.0;
BackToGame["offsetx"]      =0.0;
BackToGame["offsety"]     =0.0;
----------Вернутся в игру выделение------------------------------------------------------------------------------ 
BackToGameSelect={}
BackToGameSelect["img"]      ="menu_texture1";
BackToGameSelect["posX"]       =1.0;
BackToGameSelect["posY"]       =1.0;
BackToGameSelect["posXimg"]    =1.0;
BackToGameSelect["posYimg"]    =1.0;
BackToGameSelect["width"]      =1.0;
BackToGameSelect["height"]     =1.0;
BackToGameSelect["func"]     ="back";
----------Переход в опции------------------------------------------------------------------------------ 
ToOptions={}
ToOptions["posX"]       =1.0;
ToOptions["posY"]       =1.0;
ToOptions["posXimg"]    =1.0;
ToOptions["posYimg"]    =1.0;
ToOptions["width"]      =1.0;
ToOptions["height"]     =1.0;
ToOptions["offsetx"]      =0.0;
ToOptions["offsety"]     =0.0;
----------Переход в опции выделение------------------------------------------------------------------------------ 
ToOptionsSelect={}
ToOptionsSelect["img"]      ="menu_texture1";
ToOptionsSelect["posX"]       =1.0;
ToOptionsSelect["posY"]       =1.0;
ToOptionsSelect["posXimg"]    =1.0;
ToOptionsSelect["posYimg"]    =1.0;
ToOptionsSelect["width"]      =1.0;
ToOptionsSelect["height"]     =1.0;
ToOptionsSelect["func"]     ="options";
----------Сохранить и выйти------------------------------------------------------------------------------ 
SaveAndExit={}
SaveAndExit["posX"]       =1.0;
SaveAndExit["posY"]       =1.0;
SaveAndExit["posXimg"]    =1.0;
SaveAndExit["posYimg"]    =1.0;
SaveAndExit["width"]      =1.0;
SaveAndExit["height"]     =1.0;
SaveAndExit["offsetx"]    =0.0;
SaveAndExit["offsety"]     =0.0;
-----------Сохранить и выйти выделение----------------------------------------------------------------------------- 
SaveAndExitSelect={}
SaveAndExitSelect["img"]      ="menu_texture1";
SaveAndExitSelect["posX"]       =1.0;
SaveAndExitSelect["posY"]       =1.0;
SaveAndExitSelect["posXimg"]    =1.0;
SaveAndExitSelect["posYimg"]    =1.0;
SaveAndExitSelect["width"]      =1.0;
SaveAndExitSelect["height"]     =1.0;
SaveAndExitSelect["func"]       ="save_exit";
------------------Кнопка разработчики----------------------------------------------------------------------
ToDevWnd={}
ToDevWnd["posX"]       =-1.0;
ToDevWnd["posY"]       =-1.0;
ToDevWnd["posXimg"]    =1.0;
ToDevWnd["posYimg"]    =1.0;
ToDevWnd["width"]      =1.0;
ToDevWnd["height"]     =1.0;
ToDevWnd["offsetx"]    =0.0;
ToDevWnd["offsety"]   =0.0;
------------------Выделение кнопки разработчики----------------------------------------------------------------------
ToDevWndSelect={}
ToDevWndSelect["img"]      ="menu_texture1";
ToDevWndSelect["posX"]       =-1.0;
ToDevWndSelect["posY"]       =-1.0;
ToDevWndSelect["posXimg"]    =1.0;
ToDevWndSelect["posYimg"]    =1.0;
ToDevWndSelect["width"]      =1.0;
ToDevWndSelect["height"]     =1.0;
ToDevWndSelect["func"]       ="todevelopers";
---------------Окошко Разработчики---------------------------------------------
 
DevelopersWND={}
DevelopersWND["img"]      ="menu_texture1";
DevelopersWND["posX"]       =0.0;
DevelopersWND["posY"]       =0.0;
DevelopersWND["posXimg"]    =0.0;
DevelopersWND["posYimg"]    =0.0;
DevelopersWND["width"]      =1.0;
DevelopersWND["height"]     =1.0;
-------------Кнопка Ок---------------------------------------------------------------------------
DevelopersWNDOk={}
DevelopersWNDOk["img"]      ="menu_texture1";
DevelopersWNDOk["posX"]       =1.0;
DevelopersWNDOk["posY"]       =1.0;
DevelopersWNDOk["posXimg"]    =1.0;
DevelopersWNDOk["posYimg"]    =1.0;
DevelopersWNDOk["width"]      =1.0;
DevelopersWNDOk["height"]     =1.0;
-------------Выделение для кнопки Ок---------------------------------------------------------------------------
DevelopersWNDOkSelect={}
DevelopersWNDOkSelect["img"]      ="menu_texture1";
DevelopersWNDOkSelect["posX"]       =1.0;
DevelopersWNDOkSelect["posY"]       =1.0;
DevelopersWNDOkSelect["posXimg"]    =1.0;
DevelopersWNDOkSelect["posYimg"]    =1.0;
DevelopersWNDOkSelect["width"]      =1.0;
DevelopersWNDOkSelect["height"]     =1.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"]      =1.0;
-- ExitMenuBG["height"]     =1.0;

-- ExitMenuOk={} 
-- ExitMenuOk["posX"]       =1.0;
-- ExitMenuOk["posY"]       =1.0;
-- ExitMenuOk["posXimg"]    =1.0;
-- ExitMenuOk["posYimg"]    =1.0;
-- ExitMenuOk["width"]      =1.0;
-- ExitMenuOk["height"]     =1.0;
-- ExitMenuOk["offsetx"]    =0.0;
-- ExitMenuOk["offsety"]   =0.0;

-- ExitMenuOkSelect={} 
-- ExitMenuOkSelect["img"]      ="buttons";
-- ExitMenuOkSelect["posX"]       =1.0;
-- ExitMenuOkSelect["posY"]       =1.0;
-- ExitMenuOkSelect["posXimg"]    =1.0;
-- ExitMenuOkSelect["posYimg"]    =1.0;
-- ExitMenuOkSelect["width"]      =1.0;
-- ExitMenuOkSelect["height"]     =1.0;
-- ExitMenuOkSelect["func"]       ="gameexit";

-- ExitMenuToMenu={} 
-- ExitMenuToMenu["posX"]       =1.0;
-- ExitMenuToMenu["posY"]       =1.0;
-- ExitMenuToMenu["posXimg"]    =1.0;
-- ExitMenuToMenu["posYimg"]    =1.0;
-- ExitMenuToMenu["width"]      =1.0;
-- ExitMenuToMenu["height"]     =1.0;
-- ExitMenuToMenu["offsetx"]    =0.0;
-- ExitMenuToMenu["offsety"]   =0.0;


-- ExitMenuToMenuSelect={}
-- ExitMenuToMenuSelect["img"]      ="buttons";
-- ExitMenuToMenuSelect["posX"]       =1.0;
-- ExitMenuToMenuSelect["posY"]       =1.0;
-- ExitMenuToMenuSelect["posXimg"]    =1.0;
-- ExitMenuToMenuSelect["posYimg"]    =1.0;
-- ExitMenuToMenuSelect["width"]      =1.0;
-- ExitMenuToMenuSelect["height"]     =1.0;
-- ExitMenuToMenuSelect["func"]       ="backgame";

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