--[[ ATTN THIS IS OUT OF DATE
I SOMEHOW GOT IT WORKING AND NOW IT'S IN THE THEME ]]

-- this was my attempt to get a custom OptionIconRow working.
-- I was very close, but for some reason usually only one icon would
-- show the fuck up and they wouldn't fucking move.
-- Also the updating was gonna be a problem and I never thought of a way
-- around it.

-- OptionIcons(pn)
-- Generates OptionIcons for a specified player.
-- Using the setup I have now, I can only put 12 icons on screen at once
-- (6 icons/row x 2 rows).
-- A lot of code here is stolen from the implementation of the Mexi Mexi
-- difficulty-based speed modifier, written by myself.
-- Note to themers: code reuse is helpful.
local function OptionIcons(pn)
	-- make the ActorFrame to store the icons.
	local u = Def.ActorFrame{ Name="OptionIconRow"..pn; };
	
	-- get the options.
	local PlayerState = GAMESTATE:GetPlayerState(pn);
	-- grab the song options from this PlayerState.
	local options = PlayerState:GetPlayerOptions('ModsLevel_Preferred');
	-- now using split, let's put them into a table for comparison
	local listOfOptions = split(", ", options);
	-- find out how many options are in play.
	local numOptions = #listOfOptions;
	-- set xPos here first
	local xPos = 0;
	
	-- perform some checks here.
	if numOptions == 0 then
		-- no options, we don't need to be here wasting my cycles which
		-- can be used up by other advanced functions.
		return;
	elseif numOptions > 7 then
		-- we need two rows.
		-- set xPos here first
		local xPos = 0;
		
		for i=1,numOptions do
			-- set text
			local text = listOfOptions[i];
			
			-- find out which row we're in and set y accordingly.
			local yPos = 0;
			-- shift up row #1.
			if i < 7 then
				yPos = -16;
			end;
			
			-- now do the same for x.
			if i == 7 or i == 1 then xPos = 0;
			else xPos = i * 16;
			end;
			
			-- make an icon for each option.
			u[#u+1] = Def.ActorFrame{
				InitCommand=cmd(x,xPos;y,yPos);
				
				LoadActor("_optionicon")..{
					InitCommand=cmd(diffuse,PlayerColor(pn));
				};
				LoadFont("_frutiger lt std 55 roman 24px")..{
					Text=text;
					InitCommand=cmd(zoom,0.5;diffuse,color("#FFFFFF");shadowlength,1);
				};
			};
		end;
	else
		-- the fallback, one row.
		for i=1,numOptions do
			-- set text
			local text = listOfOptions[i];
			
			-- make an icon for each option.
			u[#u+1] = Def.ActorFrame{
				InitCommand=cmd(x,xPos;y,0);
				BeginCommand=function(self)
					Trace("AJ DEBUG [OptionIcon "..i.."] x = ".. self:GetX());
				end;
				
				LoadActor("_optionicon")..{
					InitCommand=cmd(diffuse,PlayerColor(pn));
				};
				LoadFont("_frutiger lt std 55 roman 24px")..{
					Text=text;
					InitCommand=cmd(zoom,0.5;diffuse,color("#FFFFFF");shadowlength,1);
				};
			};
			-- move x.
			xPos = i * 16;
		end;
	end;
	return u;
end;