------------------------------------------------------------------------------
-- class 'ScreenshotManager'
------------------------------------------------------------------------------

class 'InformManager'

------------------------------------------------------------------------------
function InformManager:__init(game_scene)
	self.game_scene = game_scene
	self.inform_screen = self.game_scene:getPanel():getInform()
    if not isCollectorsEdition() then
		self.inform_screen:hide()
	end

	self.fade_time = .4
	self.show_time = 4

	self.contents = 
	{
		['room_link'] = 
		{
			['class_name'] = 'RoomLink',
			['script_file'] = 'Data/Scripts/Inform/RoomLink.lua',
		},		
		['achievment_mg'] =
		{
			['class_name'] = 'AchievmentInformMG',
			['script_file'] = 'Data/Scripts/Inform/AchievmentInformMG.lua',
		},
		['achievment_nMg'] =
		{
			['class_name'] = 'AchievmentInformNMG',
			['script_file'] = 'Data/Scripts/Inform/AchievmentInformNMG.lua',
		},		
		['achievment_ho'] =
		{
			['class_name'] = 'AchievmentInformHO',
			['script_file'] = 'Data/Scripts/Inform/AchievmentInformHO.lua',
		},
		['achievment_10photo'] =
		{
			['class_name'] = 'AchievmentInform10Photo',
			['script_file'] = 'Data/Scripts/Inform/AchievmentInform10Photo.lua',
		},		
	}

	self.contents_text = 
	{
		['achievment_ho'] = 'A_NO_HINT_HO',
		['achievment_mg'] = 'A_NO_SKIP_MG',
		['achievment_10photo'] = 'A_PHOTO_GET',

	}

	self.current_content_node = nil

	local current_content = HasGameState('CURRENT_INFORM_CONTENT', nil, EGameStateTag.GENERAL) and GetGameState('CURRENT_INFORM_CONTENT', EGameStateTag.GENERAL):get(0) or 'room_link'
	local num_unlocked = HasGameState('CURRENT_INFORM_NUM_UNLOCKED', nil, EGameStateTag.GENERAL) and GetGameState('CURRENT_INFORM_NUM_UNLOCKED', EGameStateTag.GENERAL):get(0) or 0
	local num_maximum = HasGameState('CURRENT_INFORM_NUM_MAXIMUM', nil, EGameStateTag.GENERAL) and GetGameState('CURRENT_INFORM_NUM_MAXIMUM', EGameStateTag.GENERAL):get(0) or 0
	self:set_content(current_content, tonumber(num_unlocked), tonumber(num_maximum))
end

------------------------------------------------------------------------------
function InformManager:show_message(content_id, num_unlocked, num_maximum)
	self:set_content(content_id, num_unlocked, num_maximum)
	playCommonSound('ShowInformScreen')
	if (not self.inform_screen:isOnScreen()) then
		self.inform_screen:present()
	end
end

------------------------------------------------------------------------------
function InformManager:on_window_click()
	self.inform_screen:getMainEntity():ChangeOpacity(1, 0, self.fade_time)
	self.inform_screen:getMainEntity():setRespondable(false)
end

------------------------------------------------------------------------------
function InformManager:set_content(content_id, num_unlocked, num_maximum)
	if self.contents[content_id] then
		SetGameState('CURRENT_INFORM_CONTENT', content_id, EGameStateTag.GENERAL)
		SetGameState('CURRENT_INFORM_NUM_UNLOCKED', tostring(num_unlocked), EGameStateTag.GENERAL)
		SetGameState('CURRENT_INFORM_NUM_MAXIMUM', tostring(num_maximum), EGameStateTag.GENERAL)
		if self.current_content_node then
			self.current_content_node:getMainEntity():destroy()
		end

		local content_info = self.contents[content_id]
		dofile(content_info['script_file'])
		local content_node = Helpers.CallFunctionByName(content_info.class_name, self.game_scene:getPanel())
		content_node:getMainEntity():setXY(-512, -384)
		content_node:getMainEntity():attachTo(self.inform_screen:getContentAnchor())
		self.current_content_node = content_node

			
		if (self.contents_text[content_id]) then
			self.inform_screen:getEntityNamed('inform_title'):show()
			local text_entity = self.inform_screen:getEntityNamed('achievment_text')

			local additional_text = ''
			if num_unlocked and num_maximum and num_unlocked < num_maximum then
				additional_text = num_unlocked .. '/' .. num_maximum
			end

			text_entity:setText(StringManager:getString(self.contents_text[content_id]) .. additional_text)
		else
			self.inform_screen:getEntityNamed('inform_title'):hide()
		end	
	end
end

------------------------------------------------------------------------------
function InformManager:getInformScreen()
	return self.inform_screen
end