-- This fucker needs a rewrite

if GAMESTATE:IsCourseMode() then return Def.ActorFrame{}; end;

local grades = {
	Grade_Tier01 = color("#FFEEEEFF"), -- AAAA
	Grade_Tier02 = color("#AAAAAAFF"), -- AAA
	Grade_Tier03 = color("#999999FF"), -- AA
	Grade_Tier04 = color("#888888FF"), -- A
	Grade_Tier05 = color("#777777FF"), -- B
	Grade_Tier06 = color("#666666FF"), -- C
	Grade_Tier07 = color("#555555FF"), -- D
	Grade_Failed = color("#444444FF"), -- fals
	Grade_None   = color("#00000000"), -- no data
};

function CapAlpha(c,alpha)
	return { c[1], c[2], c[3], alpha }
end;

local t = Def.ActorFrame{
	LoadActor( "_base" ) .. {
		SetGradeCommand=function(self, params)
			local color = grades[params.Grade] or grades.Grade_None;
			self:diffuse( color );
		end;
	};
	
	LoadFont("_pf tempesta seven 8px")..{
		InitCommand=cmd(settext,"";PixelFont);
		SetGradeCommand=function(self,params)
			if params.Grade then
				local cropped = string.sub(params.Grade, 7);
				if cropped == "None" then cropped = "NoData"; end;
				
				self:settext( THEME:GetString( "Grade", cropped ) );
				
				-- rotate based on player
				if params.Player == PLAYER_1 then
					self:rotationz(90);
				else
					self:rotationz(-90);
				end;
			end;
		end;
	};
	
	--[[
	LoadActor( "_glow" ) .. {
		InitCommand=cmd(stopeffect;blend,'BlendMode_Add');
		SetGradeCommand=function(self, params)
			local c = grades[params.Grade] or grades.Grade_None;
			local g = params.Grade;
			if g < Grade_Tier03 then
				self:visible(true);
				self:diffuseshift();
				self:effectcolor1( c );
				self:effectcolor2( CapAlpha(c,0.5) );
			elseif g > Grade_Tier03 and g < Grade_None then
				self:visible(true);
				self:stopeffect();
			else
				self:stopeffect();
				self:visible(false)
			end;
		end;
	};
	]]
};

return t;

-- based on glenn code though cooler!