local curStage = GAMESTATE:GetCurrentStage();
local playMode = GAMESTATE:GetPlayMode();

-- label: "_label ".. {value}
-- model = starmodel
local stages = {
	   Stage_1st = { Label = "1", ModelColor = "yellow", ElementColor = color("0.8,1,0.8,1"), TwoChars=false },
	   Stage_2nd = { Label = "2", ModelColor = "yellow", ElementColor = color("0.8,0.8,1.0,1"), TwoChars=false },
	   Stage_3rd = { Label = "3", ModelColor = "yellow", ElementColor = color("1.0,1.0,0.8,1"), TwoChars=false },
	   Stage_4th = { Label = "4", ModelColor = "yellow", ElementColor = color("0.9,0.9,1.0,1"), TwoChars=false },
	   Stage_5th = { Label = "5", ModelColor = "yellow", ElementColor = color("1.0,0.8,0.9,1"), TwoChars=false },
	   Stage_6th = { Label = "6", ModelColor = "yellow", ElementColor = color("0.5,1.0,0.8,1"), TwoChars=false },
	 Stage_Final = { Label = "final",  ModelColor = "yellow", ElementColor = color(""), TwoChars=true },
	Stage_Extra1 = { Label = "extra1", ModelColor = "red", ElementColor = color(""), TwoChars=false },
	Stage_Extra2 = { Label = "extra2", ModelColor = "rainbow", ElementColor = color(""), TwoChars=true },
	 Stage_Event = { Label = "event",  ModelColor = "yellow", ElementColor = color("1,1,1,1"), TwoChars=true },
	-- course stages
	PlayMode_Nonstop = { Label = "nonstop", ModelColor = "red", ElementColor = color("1.0,1.0,0.8,1"), TwoChars = false },
	PlayMode_Oni = { Label = "oni", ModelColor = "red", ElementColor = color("0.0,0.0,1.0,1"), TwoChars = false },
	PlayMode_Endless = { Label = "endless", ModelColor = "red", ElementColor = color("0.0,0.0,1.0,1"), TwoChars = false },
};

if curStage == 'Stage_Event' and GAMESTATE:IsCourseMode() then
	curStage = playMode;
end;

local StageIndex = GAMESTATE:GetCurrentStageIndex();
local screen = SCREENMAN:GetTopScreen();
if screen and screen.GetStageStats then
	local ss = screen:GetStageStats();
	curStage = ss:GetStage();
	StageIndex = ss:GetStageIndex();
	-- todo: final
	if(tonumber(stages[curStage].Label) == PREFSMAN:GetPreference("SongsPerPlay")) then
		curStage = 'Stage_Final';
	end;
end

local t = Def.ActorFrame{
	LoadActor( THEME:GetPathB("_shared","models/_starmodel"), stages[curStage].ModelColor )..{
		InitCommand=cmd(Center;zoom,8.0;);
		OnCommand=cmd(decelerate,2.4;rotationy,720;linear,0.3;zoom,0;);
	};
	LoadActor("_label "..stages[curStage].Label)..{
		InitCommand=cmd(Center;shadowlength,5;diffuse,color("1.0,0.8,0.5,1");diffusealpha,0;);
		OnCommand=cmd(linear,0.3;diffusealpha,1;sleep,2.4;linear,0.3;zoomy,0;);
	};
};

-- character background
t[#t+1] = LoadActor(THEME:GetPathB("","stagetemp/stageframe2"))..{
	InitCommand=cmd(x,SCREEN_CENTER_X-244;CenterY;diffuse,stages[curStage].ElementColor;diffusealpha,0);
	OnCommand=cmd(linear,0.3;diffusealpha,1;sleep,2.4;linear,0.3;zoomx,0;);
};
t[#t+1] = LoadActor(THEME:GetPathB("","stagetemp/stageframe2"))..{
	InitCommand=cmd(x,SCREEN_CENTER_X+244;CenterY;diffuse,stages[curStage].ElementColor;diffusealpha,0);
	OnCommand=cmd(linear,0.3;diffusealpha,1;sleep,2.4;linear,0.3;zoomx,0;);
};
-- characters
if stages[curStage].TwoChars then
	-- num1, num2
	t[#t+1] = LoadActor("./kanji/_"..stages[curStage].Label.." num1")..{
		InitCommand=cmd(x,SCREEN_CENTER_X-244;CenterY;zoom,0;spin;diffuse,stages[curStage].ElementColor;diffusealpha,0);
		OnCommand=cmd(linear,0.3;zoom,0.8;diffusealpha,1;linear,2.4;rotationz,-360;linear,0.3;zoomx,0;);
	};
	t[#t+1] = LoadActor("./kanji/_"..stages[curStage].Label.." num2")..{
		InitCommand=cmd(x,SCREEN_CENTER_X+244;CenterY;zoom,0;spin;diffuse,stages[curStage].ElementColor;diffusealpha,0);
		OnCommand=cmd(linear,0.3;zoom,0.8;diffusealpha,1;linear,2.4;rotationz,-360;linear,0.3;zoomx,0;);
	};
else
	-- num, num
	t[#t+1] = LoadActor("./kanji/_"..stages[curStage].Label.." num")..{
		InitCommand=cmd(x,SCREEN_CENTER_X-244;CenterY;zoom,0;spin;diffuse,stages[curStage].ElementColor;diffusealpha,0);
		OnCommand=cmd(linear,0.3;zoom,0.8;diffusealpha,1;linear,2.4;rotationz,-360;linear,0.3;zoomx,0;);
	};
	t[#t+1] = LoadActor("./kanji/_"..stages[curStage].Label.." num")..{
		InitCommand=cmd(x,SCREEN_CENTER_X+244;CenterY;zoom,0;spin;diffuse,stages[curStage].ElementColor;diffusealpha,0);
		OnCommand=cmd(linear,0.3;zoom,0.8;diffusealpha,1;linear,2.4;rotationz,-360;linear,0.3;zoomx,0;);
	};
end;

local selInfo = Def.ActorFrame{
	InitCommand=cmd(Center);
};

-- song info
if not GAMESTATE:IsCourseMode() then
	local song = GAMESTATE:GetCurrentSong();
	if song:GetDisplaySubTitle() ~= "" then
		-- title on one line, subtitle on another
		selInfo[#selInfo+1] = LoadFont("_shared2")..{
			Name="SongMainTitle";
			Text=GAMESTATE:GetCurrentSong():GetDisplayMainTitle();
			InitCommand=cmd(diffusealpha,0;maxwidth,SCREEN_WIDTH-16);
			OnCommand=cmd(linear,0.3;addy,-42;diffusealpha,1;sleep,2.4;diffusealpha,1;linear,0.3;diffusealpha,0;);
		};
		selInfo[#selInfo+1] = LoadFont("_shared2")..{
			Name="SongSubTitle";
			Text=GAMESTATE:GetCurrentSong():GetDisplaySubTitle();
			InitCommand=cmd(diffusealpha,0;zoom,0.625;maxwidth,(SCREEN_WIDTH-16)*1.375);
			OnCommand=cmd(linear,0.3;addy,-24;diffusealpha,1;sleep,2.4;diffusealpha,1;linear,0.3;diffusealpha,0;);
		};
	else
		-- full title!
		selInfo[#selInfo+1] = LoadFont("_shared2")..{
			Name="SongTitle";
			Text=GAMESTATE:GetCurrentSong():GetDisplayFullTitle();
			InitCommand=cmd(diffusealpha,0;maxwidth,SCREEN_WIDTH-16);
			OnCommand=cmd(linear,0.3;addy,-32;diffusealpha,1;sleep,2.4;diffusealpha,1;linear,0.3;diffusealpha,0;);
		};
	end;
	selInfo[#selInfo+1] = LoadFont("_shared2")..{
		Name="Artist";
		Text=GAMESTATE:GetCurrentSong():GetDisplayArtist();
		InitCommand=cmd(diffusealpha,0;maxwidth,SCREEN_WIDTH-16);
		OnCommand=cmd(linear,0.3;addy,32;diffusealpha,1;sleep,2.4;diffusealpha,1;linear,0.3;diffusealpha,0;);
	};
	-- like the 3.9 version, only it has the subtitle included too
	--[[
	selInfo[#selInfo+1] = LoadFont("_shared2")..{
		Name="SongTitle";
		Text=GAMESTATE:GetCurrentSong():GetDisplayFullTitle();
		InitCommand=cmd(diffusealpha,0;);
		OnCommand=cmd(linear,0.3;addy,-32;diffusealpha,1;sleep,2.4;diffusealpha,1;linear,0.3;diffusealpha,0;);
	};
	--]]
-- course info
else
	local course = GAMESTATE:GetCurrentCourse();
end;

t[#t+1] = selInfo;

return t;