-- ActorFrame name, used for controlling the children from control actor (in FG).
local name = 'overlay'

local base_param = ...
local sw,sh,scx,scy,songdir,rr,am,bt,hs,pe,hr,ease,wratio,hratio,paraph = base_param.sw,base_param.sh,base_param.scx,base_param.scy,base_param.songdir,base_param.rr,base_param.am,base_param.bt,base_param.hs,base_param.pe,base_param.hr,base_param.ease,base_param.wratio,base_param.hratio,base_param.paraph

-- Camera manipulation table
local Cameras = {
	Name=name,
	Tween={
	}
}

-- Children manipulation table
local Actors = {
	Name=name,
	Tween={
		{'digil', 3072, 'diffusealpha', 1},
		{'digir', 3072, 'diffusealpha', 1},
		{'digil', 3120, 'setstate', 1},
		{'digir', 3120, 'setstate', 1},
		{'digil', 3168, 'setstate', 2},
		{'digir', 3168, 'setstate', 2},
		{'digil', 3216, 'diffusealpha', 0},
		{'digir', 3216, 'diffusealpha', 0},
		{'digil', 3216, 'setstate', 0},
		{'digir', 3216, 'setstate', 0},
		{'flash', 4800, {4896, 'x2', 'diffusealpha', 1, 0}},
		{'flash', 4992, {5088, 'x2', 'diffusealpha', 1, 0}},
		{'flash', 5184, {5280, 'x2', 'diffusealpha', 1, 0}},
		{'flash', 5376, {5472, 'x2', 'diffusealpha', 1, 0}},
		{'flash', 5568, {5664, 'x2', 'diffusealpha', 1, 0}},
		{'flash', 5760, {5856, 'x2', 'diffusealpha', 1, 0}},
		{'black', 6240, {6288, 'x2', 'diffusealpha', 1, 0}},
		{'redol', 6672, 'diffusealpha', 1},
		{'redol', 6684, 'diffusealpha', 0},
		{'bluad', 7056, 'diffusealpha', 1},
		{'bluad', 7068, 'diffusealpha', 0},
		{'redol', 7440, 'diffusealpha', 1},
		{'redol', 7452, 'diffusealpha', 0},
		{'bluad', 7824, 'diffusealpha', 1},
		{'bluad', 7836, 'diffusealpha', 0},
		{'redol', 8208, 'diffusealpha', 1},
		{'redol', 8220, 'diffusealpha', 0},
		{'bluad', 8592, 'diffusealpha', 1},
		{'bluad', 8604, 'diffusealpha', 0},
		{'redol', 8976, 'diffusealpha', 1},
		{'redol', 8988, 'diffusealpha', 0},
		{'bluad', 9360, 'diffusealpha', 1},
		{'bluad', 9372, 'diffusealpha', 0},
		{'redol', 9744, 'diffusealpha', 1},
		{'redol', 9756, 'diffusealpha', 0},
		{'bluad', 10128, 'diffusealpha', 1},
		{'bluad', 10140, 'diffusealpha', 0},
		{'digil', 10368, 'diffusealpha', 1},
		{'digir', 10368, 'diffusealpha', 1},
		{'digil', 10416, 'setstate', 1},
		{'digir', 10416, 'setstate', 1},
		{'digil', 10464, 'setstate', 2},
		{'digir', 10464, 'setstate', 2},
		{'digil', 10512, 'diffusealpha', 0},
		{'digir', 10512, 'diffusealpha', 0},
		{'digil', 10512, 'setstate', 0},
		{'digir', 10512, 'setstate', 0},
		{'redol', 12240, 'diffusealpha', 1},
		{'redad', 12240, 'diffusealpha', 1},
		{'redol', 12288, 'diffusealpha', 0},
		{'redad', 12288, 'diffusealpha', 0},
		{'butun1', 12432, {12444, 'decelerate', 'y', -sh*3/4, -sh*1/4}},
		{'butun2', 12432, {12444, 'decelerate', 'y', sh*3/4, sh*1/4}},
		{'butun1', 12444, {12504, 'accelerate', 'diffusealpha', 1, 0}},
		{'butun2', 12444, {12504, 'accelerate', 'diffusealpha', 1, 0}},
		{'redol', 12624, 'diffusealpha', 1},
		{'redad', 12624, 'diffusealpha', 1},
		{'redol', 12672, 'diffusealpha', 0},
		{'redad', 12672, 'diffusealpha', 0},
	}
}

local Players = {
	Tween={
	}
}

-- Shortcut to the 'FG' ActorFrame.
local FG

-- We can use "InitializeCommand" instead of usual "OnCommand", which is executed on the beginning of section.
-- This reduces that ridiculously large frame drop on beat 0.
return Def.ActorFrame{
Name=name,
InitCommand=function(self) FG = self:GetParent():GetParent() self:visible(false) end,
InitializeCommand=function(self)
	local c = FG:GetChild('Cameras')
	local a = FG:GetChild('Actors')
--	local plt = a[1].Tween
--	for i = 1, #Players do
--		plt[#plt+1] = Players[i]
--	end
	c[#c+1] = Cameras
	a[#a+1] = Actors
	self:fov(90)
end,
Def.Quad{
	Name='black',
	InitializeCommand=function(self)
		self:zoomto(sw,sh):diffuse(0,0,0,0)
	end,
},
Def.Sprite{
	Name='digil',
	Texture=songdir..'fg/texture/321',
	InitializeCommand=function(self) self:x(-scx/2):blend('BlendMode_InvertDest'):diffusealpha(0):animate(0):setstate(0) end,
},
Def.Sprite{
	Name='digir',
	Texture=songdir..'fg/texture/321',
	InitializeCommand=function(self) self:x(scx/2):blend('BlendMode_InvertDest'):diffusealpha(0):animate(0):setstate(0) end,
},
Def.Quad{
	Name='flash',
	InitializeCommand=function(self)
		self:zoomto(sw,sh):diffuse(1,1,1,0)
	end,
},
Def.Quad{
	Name='butun1',
	InitializeCommand=function(self)
		self:zoomto(sw,sh/2):diffuse(0,0,0,1):y(-sh*3/4)
	end,
},
Def.Quad{
	Name='butun2',
	InitializeCommand=function(self)
		self:zoomto(sw,sh/2):diffuse(0,0,0,1):y(sh*3/4)
	end,
},
Def.Quad{
	Name='bluad',
	InitializeCommand=function(self)
		self:zoomto(sw,sh):diffuse(0,0,0.15,0):blend('BlendMode_Add')
	end,
},
Def.Quad{
	Name='redol',
	InitializeCommand=function(self)
		self:zoomto(sw,sh):diffuse(1,0.85,0.85,0):blend('BlendMode_Modulate')
	end,
},
Def.Quad{
	Name='redad',
	InitializeCommand=function(self)
		self:zoomto(sw,sh):diffuse(0.15,0,0,0):blend('BlendMode_Add')
	end,
},
}