class 'SubtitlesBase'
-------------------------------------------------------------

function SubtitlesBase:__init(parent)
	self.stack			= {}
	self.fields			= {}
	self.fade_time		= 0.4
	
	self.parent			= parent
	
	self.font_name		= 'Data/Fonts/dialog.fnt'
	self.text_width		= 910
	self.text_height	= 30
	self.text_alignment	= TextEntity.ETextHorizontalAlignmentCenter
	self.text_hotspot	= TextEntity.ETextHotSpotTypeCenter
	self.text_x			= 512
	self.text_y			= 720
	self.text_order		= self.parent:getMaxOrder() + 1
end
-------------------------------------------------------------

function SubtitlesBase:pushReplic(text, time, dt)
	local info = {}
	info.text  = text
	info.time  = time
	info.dt    = dt
	
	table.insert(self.stack, info)
end
-------------------------------------------------------------

function SubtitlesBase:play()
	local max_time = 0;
	
	for i, info in ipairs(self.stack) do
		local text = self:_createTextField()
		text:setText( StringManager:getString(info.text) )

		local fade_time = (self.fade_time > info.dt) and info.dt or self.fade_time

		local af = CreateAnimationEffector()
		af:setDestroysOnEnd(true)
		af:attachTo(text)	
		af:setKey(_TRACK_O, 0,                		            0)
		af:setKey(_TRACK_O, info.time,                          0)
		af:setKey(_TRACK_O, info.time + fade_time,              1)
		af:setKey(_TRACK_O, info.time + info.dt,                1)
		af:setKey(_TRACK_O, info.time + fade_time + info.dt, 	0)
		af:play()
	end
end
-------------------------------------------------------------
function SubtitlesBase:destroy()
	for field in pairs(self.fields) do
		field:destroy()
		self.fields[field] = nil
	end
end
-------------------------------------------------------------

function SubtitlesBase:_createTextField()
	local field = CreateTextEntity()
	field:setName			( 'Subtitles' )
	field:setFont			( self.font_name )
	field:setTextAlignment	( self.text_alignment )
	field:setHotSpotType	( self.text_alignment )
	field:setBounds			( self.text_width, self.text_height )
	field:setHeight			( self.text_height )
	field:setXY				( self.text_x, self.text_y )
	field:setOrder			( self.text_order )
	field:attachTo			( self.parent:getMainEntity() )
		
	self.fields[field] = true
	
	return field
end
-------------------------------------------------------------