local Player = ...
assert( Player );

local flip = (Player == PLAYER_1) and 96 or 544;
local stats = STATSMAN:GetCurStageStats():GetPlayerStageStats(Player);
local percent = stats:GetPercentDancePoints();

local t = Def.ActorFrame{
	Name="Grade"..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;
	
	LoadFont("_popstar","combo")..{
		Text=FormatPercentScore(percent);
		InitCommand=cmd(shadowlength,0;zoom,0.75;diffusealpha,0);
		BeginCommand=function(self)
			-- "100.00%" is fucking needless, afaik you can't get over 100%?
			local text = self:GetText();
			if text == "100.00%" then self:SetText("100%");
			end;
			
			local diff = GAMESTATE:GetCurrentSteps(Player):GetDifficulty();
			self:diffuse( DifficultyColor(diff) );
		end;
		OnCommand=cmd(linear,0.2;diffusealpha,1);
		OffCommand=cmd(linear,0.2;diffusealpha,0);
	};
};

return t;