local Player = ...
assert(Player);

local alignment = Player == PLAYER_1 and 0 or 1;

local diff = Def.ActorFrame{
	LoadFont("_bm delico")..{
		InitCommand=cmd(shadowlength,1;PixelFont;halign,alignment);
		BeginCommand=cmd(player,Player);
		OnCommand=cmd(playcommand,"Set");
		
		SetCommand=function(self,params)
			local SongOrCourse;
			local StepsOrTrail;
			if GAMESTATE:IsCourseMode() then
				SongOrCourse = GAMESTATE:GetCurrentCourse();
				StepsOrTrail = GAMESTATE:GetCurrentTrail(Player);
			else
				SongOrCourse = GAMESTATE:GetCurrentSong();
				StepsOrTrail = GAMESTATE:GetCurrentSteps(Player);
			end;
			
			-- no song or steps? blank it and move on.
			if not SongOrCourse or not StepsOrTrail then
				self:settext(""); return;
			end;
			
			-- steps or trail? abuse it.
			if StepsOrTrail then
				local Difficulty = StepsOrTrail:GetDifficulty();
				local StepsType = StepsOrTrail:GetStepsType();
				
				local FullText;
				local DiffText;
				local STText = string.sub(StepsType,11);
				if Difficulty == 'Difficulty_Edit' then
					DiffText = StepsOrTrail:GetDescription();
					FullText = DiffText .." ".. STText;
				else
					DiffText = string.sub(Difficulty,12);
					--= THEME:GetString("Difficulties",);
					FullText = THEME:GetString("DifficultyAndStepsType",DiffText.."-"..STText);
				end;
				
				local Meter = StepsOrTrail:GetMeter();
				
				if StepsOrTrail:IsAutogen() then
					FullText = "Autogenned ".. FullText;
				end;
				
				self:settext(FullText .." ".. "[".. Meter .."]");
				self:diffuse( StepsOrTrailToColor(StepsOrTrail) );
			end;
		end;
		
		CurrentSongChangedMessageCommand=cmd(playcommand,"Set");
		CurrentCourseChangeDMessageCommand=cmd(playcommand,"Set");
		
		CurrentStepsP1ChangedMessageCommand=function(self)
			if Player == PLAYER_1 then self:playcommand("Set"); end;
		end;
		CurrentTrailP1ChangedMessageCommand=function(self)
			if Player == PLAYER_1 then self:playcommand("Set"); end;
		end;
		CurrentStepsP2ChangedMessageCommand=function(self)
			if Player == PLAYER_2 then self:playcommand("Set"); end;
		end;
		CurrentTrailP2ChangedMessageCommand=function(self)
			if Player == PLAYER_2 then self:playcommand("Set"); end;
		end;
	};
};

return diff;