class 'l_InGameMenu' (BaseScreen)
--------------------------------------------------------------------------------
IN_GAME_MENU_LAYER = 12
--------------------------------------------------------------------------------
local ingameMenuShown = false
--------------------------------------------------------------------------------

function l_InGameMenu:__init(name, screen)
	BaseScreen.__init(self, name, screen)
	
    self:CreateButtonByName('Continue', KEY_ESCAPE)
    self:CreateButtonByName('Options')
    self:CreateButtonByName('Help')
    self:CreateButtonByName('Credits')
    self:CreateButtonByName('Quit')
    
    ingameMenuShown = true
end
--------------------------------------------------------------------------------

function l_InGameMenu:OnButtonPress(action)
end
--------------------------------------------------------------------------------

function l_InGameMenu:OnContinueButtonClick()
	CloseInGameMenu()
end
--------------------------------------------------------------------------------

function l_InGameMenu:OnOptionsButtonClick()
    CreateOptionsScreen(true)
end
--------------------------------------------------------------------------------

function l_InGameMenu:OnHelpButtonClick()
	CreateHelpScreen()
end
--------------------------------------------------------------------------------

function l_InGameMenu:OnCreditsButtonClick()
	CreateCreditsScreen()
end
--------------------------------------------------------------------------------

function l_InGameMenu:OnQuitButtonClick()
    exitConfirmationScreen = CreateYesNoScreen("REALLY_QUIT_TO_MENU", "ExitToMainMenu", "ExitToMainMenuDiscard", true)
end
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
-- HELPERS
--------------------------------------------------------------------------------

function CreateInGameMenu()
    if ingameMenuShown then
		return
	end
    
    --VolumeRestoreAmbientMusic()
    HideBlackBar(true)
    
    local level = GetCurrentLevel()
    
    local inv = level:GetInventoryLuaObject()
    if inv:GetTool() then
        inv:DropTool(0)
    end
    
    ResetDragingObject()
     
	local screen = CreateScriptedScreen('data/Scripts/screens/InGameMenu.lua', 'l_InGameMenu')
    PopUpScreensMgr:Push(screen, true)
    screen:SetLayer(IN_GAME_MENU_LAYER)
    
    HideZoomZones()
    play_field:Stop()
end
--------------------------------------------------------------------------------

function CloseInGameMenu()
    PopUpScreensMgr:Pop()
	ShowHiddenZoomZones()
	GTimerContinue()
	
	ingameMenuShown = false
	
	if InteractiveHelp.tutorialScreen then
        InteractiveHelp.tutorialScreen.screen:SetOpacity(1)
    end
    
    play_field:Go()
end
--------------------------------------------------------------------------------

function IsInGameMenuShown()
    return ingameMenuShown
end
--------------------------------------------------------------------------------

function ExitToMainMenu()
    ingameMenuShown = false
    
    local inv = GetCurrentLevel():GetInventoryLuaObject()
    if inv:GetTool() then
        inv:DropTool(0)
    end

    if not exitConfirmationScreen then
        return
    end
    
    if InteractiveHelp.tutorialScreen then
        InteractiveHelp.tutorialScreen:Destroy()
        InteractiveHelp.tutorialScreen = nil
    end
    
    PopUpScreensMgr:Pop()
    CleanUpGameResources()
    CreateMainMenu()
end
--------------------------------------------------------------------------------

function ExitToMainMenuDiscard()
    exitConfirmationScreen = nil
end
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function l_InGameMenu:LoadData(screen)
	local anim
	anim = CreateAnimation('data/Texture/GUI/InGameMenu/InGameScreenBackground.png',0,0,419,482,1,0)
	anim:SetHotSpot(209,241)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('InGameScreenBackground',anim,512,364,101,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/InGameMenu/bttn_continue.png',0,0,302,100,3,0)
	anim:SetHotSpot(151,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_continue',anim,513,194,120,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/InGameMenu/bttn_options.png',0,0,302,100,3,0)
	anim:SetHotSpot(151,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_options',anim,512,279,120,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/InGameMenu/bttn_help.png',0,0,302,100,3,0)
	anim:SetHotSpot(151,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_help',anim,512,364,120,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/InGameMenu/bttn_credits.png',0,0,302,100,3,0)
	anim:SetHotSpot(151,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_credits',anim,516,449,120,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/InGameMenu/bttn_quit.png',0,0,302,100,3,0)
	anim:SetHotSpot(151,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_quit',anim,512,534,120,0,1,1)
	
end
-- CLEAR_ON_SAVE_END
