local Player = ...
assert( Player );

local flip = (Player == PLAYER_1) and 64 or 576;
local textAlign = (Player == PLAYER_1) and 0 or 1;
local meterHeight = 252;
local posCap = -meterHeight;

local t = Def.ActorFrame{
	Name="Score"..Player;
	InitCommand=cmd(x,flip;y,SCREEN_CENTER_Y+77);
	BeginCommand=function(self)
		if GAMESTATE:IsSideJoined(Player) then
			self:visible(true);
			return;
		end;
		self:visible(false);
	end;
	
	Def.ActorFrame{
		Name="Bar"..Player;
		LoadActor("_score bar")..{
			InitCommand=cmd(diffusealpha,0);
			OnCommand=cmd(linear,0.2;diffusealpha,1);
			OffCommand=cmd(linear,0.2;diffusealpha,0);
		};
		Def.Quad{
			InitCommand=cmd(diffuse,PlayerColor(Player);y,126;diffusebottomedge,1,1,1,0.8;zoomto,28,0;vertalign,bottom);
			OnCommand=function(self)
				local stats = STATSMAN:GetCurStageStats():GetPlayerStageStats(Player);
				local actualDP = stats:GetActualDancePoints();
				local possibleDP = stats:GetPossibleDancePoints();
				self:linear(1);
				self:zoomy( (actualDP/possibleDP) * 252 );
			end;
			OffCommand=cmd(accelerate,0.25;zoomy,0);
		};
	};
};

return t;