-- Timing Set: sets Timing Windows
function TimingSet()	
	local function AllChoices()
		Trace('all choices');
		local ret = { }
		ret[1] = 'StepMania Defaults';
		ret[2] = 'DDR Extreme';
        ret[3] = 'In The Groove 1';
        ret[4] = 'In The Groove 2';
        ret[5] = 'Pump It Up: Pro';
		return ret
	end

	local t = 
	{
		-- Name is used to retrieve the header and explanation text.
		Name = "SetTimings";
		LayoutType = "ShowAllInRow";
		SelectType = "SelectOne";
		OneChoiceForAllPlayers = true;
		ExportOnChange = false;
		Choices = AllChoices();
		LoadSelections = function(self, list, pn)
			list[1] = true
		end;
		SaveSelections = function(self, list, pn)
            -- list: SM, DDR, ITG
            local Default = {
                Attack = 0.135000,
                Hold = 0.250000,
                Mine = 0.090000,
                Roll = 0.350000,
                W1 = 0.022500,
                W2 = 0.045000,
                W3 = 0.090000,
                W4 = 0.135000,
                W5 = 0.180000,
            };
            local Extreme = {
                Attack = 0.135000,
                Hold = 0.250000,
                Mine = 0.108333,
                Roll = 0.350000,
                W1 = 0.016666,
                W2 = 0.033333,
                W3 = 0.083000,
                W4 = 0.120000,
                W5 = 0.158333,
            };
            local ITG2 = {
                Attack = 0.130000,
                Hold = 0.320000,
                Mine = 0.070000,
                Roll = 0.350000,
                W1 = 0.021500,
                W2 = 0.043000,
                W3 = 0.102000,
                W4 = 0.135000,
                W5 = 0.180000,
            };
            local Pro = {
                Attack = 0.135000,
                Hold = 0.060,
                Mine = 0.070,
                Roll = 0.350,
                W1 = 0.026,
                W2 = 0.055,
                W3 = 0.100,
                W4 = 0.145,
                W5 = 0.180,
            };
            local ITG1 = {
                Roll = 0.350,
                Mine = 0.070000,
                W5 = 0.180000,
                W4 = 0.135000,
                W3 = 0.102000,
                W2 = 0.043000,
                W1 = 0.021500,
                Hold = 0.320000,
                Attack = 0.130000,
            };
--~             };
            local val = {};
            if list[1] then 
                val = Default;
            end;
            if list[2] then
                val = Extreme;
            end;
            if list[3] then
                val = ITG1;
            end;
            if list[4] then
                val = ITG2;
            end;
            if list[5] then
                val = Pro;
            end;
            
			PREFSMAN:SetPreference("TimingWindowSecondsW1",val['W1']);
			PREFSMAN:SetPreference("TimingWindowSecondsW2",val['W2']);
			PREFSMAN:SetPreference("TimingWindowSecondsW3",val['W3']);
			PREFSMAN:SetPreference("TimingWindowSecondsW4",val['W4']);
			PREFSMAN:SetPreference("TimingWindowSecondsW5",val['W5']);
			PREFSMAN:SetPreference("TimingWindowSecondsAttack",val['Attack']);
			PREFSMAN:SetPreference("TimingWindowSecondsHold",val['Hold']);
			PREFSMAN:SetPreference("TimingWindowSecondsMine",val['Mine']);
			PREFSMAN:SetPreference("TimingWindowSecondsRoll",val['Roll']);
            
            SCREENMAN:SystemMessage("Exit StepMania to commit your changes!");
		end;
	};
	setmetatable( t, t );
	return t;
end

function SetThemeColor()	
	local function AllChoices()
		Trace('all choices');
		local ret = { }
		ret[1] = 'Blue';
		ret[2] = 'Red';
		return ret
	end

	local t = 
	{
		-- Name is used to retrieve the header and explanation text.
		Name = "ThemeBaseColor";
		LayoutType = "ShowAllInRow";
		SelectType = "SelectOne";
		OneChoiceForAllPlayers = true;
		ExportOnChange = false;
		Choices = AllChoices();
		LoadSelections = function(self, list, pn)
			list[1] = true
		end;
		SaveSelections = function(self, list, pn)
            local val = {};
            if list[1] then 
                val = "Blue";
            end;
            if list[2] then
                val = "Red";
            end;
            
            WritePref("Themes/Cerulean Skies/Preferences/","ThemeColor",val);
            SCREENMAN:SystemMessage("Hold F3, then F6, then Press '7' to commit your changes")
		end;
	};
	setmetatable( t, t );
	return t;
end

function SetThemeMusic()
	local function AllChoices()
		Trace('all choices');
		local ret = { }
		ret[1] = 'CS Theme';
		ret[2] = 'Industry';
        ret[3] = 'Flamenco';
        ret[4] = 'Cosby Rap';
		return ret
	end

	local t = 
	{
		-- Name is used to retrieve the header and explanation text.
		Name = "ThemeMainMusic";
		LayoutType = "ShowAllInRow";
		SelectType = "SelectOne";
		OneChoiceForAllPlayers = true;
		ExportOnChange = false;
		Choices = AllChoices();
		LoadSelections = function(self, list, pn)
			list[1] = true
		end;
		SaveSelections = function(self, list, pn)
            local val = {};
            if list[1] then 
                val = "Menu/CS Theme";
            end;
            if list[2] then
                val = "Menu/Industry";
            end;
            if list[3] then
                val = "Menu/Flamenco";
            end;
            if list[4] then
                val = "Menu/Cosby";
            end;
            
            WriteRedir("Themes/Cerulean Skies/Sounds/","_common menu music",val);
            SCREENMAN:SystemMessage("Hold F3, then F6, then Press '7' to commit your changes")
            
		end;
	};
	setmetatable( t, t );
	return t;
end