------------------------------------------------------------------------------
-- class 'RSLAchievment'
-- Базовый клас для ачивок Reveries: Sisterly Love
------------------------------------------------------------------------------

class 'RSLAchievment' (Achievment)

------------------------------------------------------------------------------
function RSLAchievment:__init(game_scene)
	Achievment.__init(self, game_scene)
end

------------------------------------------------------------------------------
function RSLAchievment:createScreen(script_path, name, callback)
	dofile(script_path)
	local zone = Helpers.CallFunctionByName(name, name)
	zone:getWindowLayer():attachTo(self.game_scene:getMainEntity())
	zone:getWindowLayer():setOrder(10)

	local controls_panel = self.game_scene:getPanel():getControlsPanel()
	zone:getWindow():getHotkeySignal(ERSK_ESCAPE):add( bind(controls_panel.onMenuButtonClick, controls_panel) )
	
	local function on_close_button()
		zone:destroyScreen()
		self.game_scene:go()
	end
	
	zone:getEntityNamed('OKButton').onPress:add(on_close_button)
	zone:getEntityNamed('OKButton'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
	zone:getMainEntity().onClickBegin:add(on_close_button)
	if callback then
		zone:getEntityNamed('OKButton').onPress:add(callback)
		zone:getMainEntity().onClickBegin:add(callback)
	end
	
	self.game_scene:stop()
	
	return zone
end