Add Speed Selector

This commit is contained in:
Jonathan Payne
2010-11-28 20:13:59 -08:00
parent c1579ef1da
commit 8786171623
5 changed files with 244 additions and 2 deletions
@@ -0,0 +1,147 @@
-- GamePreferences: Clone of AJ's User Preferences "Module"
-- Written by AJ Kelly of KKI Labs / Version 2.11-ssc
-- (modified slightly for Cerulean Skies 2's disregard of the name of the
-- themeinfo variable lol :p)
--[[
the first released version was broken.
this version aims to be simpler, and therefore work.
[changelog]
v2.11-ssc
Remove EnvUtils references; we have it in sm-ssc.
v2.1-ssc
sm-ssc version of UserPrefs. We can now assume players have certain
functionality, like RageFile:GetError().
v2.1
Added type specific GetUserPref functions.
[usage]
First, edit PrefPath to match your theme.
If you use ThemeInfo, then you shouldn't have to edit this.
If you're not using ThemeInfo, then you can replace
".. themeInfo.Name .." with the theme's folder name.
ThemeInfo is documented at http://kki.ajworld.net/wiki/ThemeInfo.lua
After that's set up, read the docs.
]]
local PrefPath = "Data/GamePrefs/"
--[[ begin internal stuff; no need to edit below this line. ]]
-- Local internal function to write envs. ___Not for themer use.___
local function WriteEnv(envName,envValue)
return setenv(envName,envValue)
end
function ReadGamePrefFromFile(name)
local f = RageFileUtil.CreateRageFile()
local fullFilename = PrefPath..name..".cfg"
local option
if f:Open(fullFilename,1) then
option = tostring( f:Read() )
WriteEnv(name,option)
f:destroy()
return option
else
local fError = f:GetError()
Trace( "[FileUtils] Error reading ".. fullFilename ..": ".. fError )
f:ClearError()
f:destroy()
return nil
end
end
function WriteGamePrefToFile(name,value)
local f = RageFileUtil.CreateRageFile()
local fullFilename = PrefPath..name..".cfg"
if f:Open(fullFilename, 2) then
f:Write( tostring(value) )
WriteEnv(name,value)
else
local fError = f:GetError()
Trace( "[FileUtils] Error writing to ".. fullFilename ..": ".. fError )
f:ClearError()
f:destroy()
return false
end
f:destroy()
return true
end
--[[ end internal functions; still don't edit below this line ]]
function GetGamePref(name)
return ReadGamePrefFromFile(name)
end
function SetGamePref(name,value)
return WriteGamePrefToFile(name,value)
end
--[[ type specific, for when you want to be lazy ]]
-- XXX: make set funcs, since I hate dealing with colors and I know
-- other themers would too.
-- GetUserPrefB: boolean
function GetGamePrefB(name)
-- this one is a bit trickier.
local pref = ReadGamePrefFromFile(name)
if type(pref) == "string" then
pref = string.lower(pref)
if pref == "true" or cmp == "t" then
return true
elseif pref == "false" or cmp == "f" then
return false
else
Trace("Error in GetUserPrefB(".. name ..") converting from string" )
return false
end
elseif type(pref) == "number" then
-- both 0 and -1 are false; if you want to change this,
-- feel free to remove "or pref == -1".
if pref == 0 or pref == -1 then
else
return true
end
end
end
-- GetUserPrefC: color
function GetGamePrefC(name)
-- XXX: make sure it's grabbing a string that can be turned into a color
-- and also possibly handle HSV values too.
return color( ReadGamePrefFromFile(name) )
end
-- GetUserPrefN: numbers (integers, floats)
function GetGamePrefN(name)
return tonumber( ReadGamePrefFromFile(name) )
end
--[[
Copyright © 2008-2009 AJ Kelly/KKI Labs
All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
@@ -0,0 +1,42 @@
-- theme library: juicy library that returns lua objects on demand.
Library = {
GrooveRadar = function(self)
local function radarSet(self,player)
local selection = nil;
if GAMESTATE:IsCourseMode() then
if GAMESTATE:GetCurrentCourse() then
selection = GAMESTATE:GetCurrentTrail(player);
end;
else
if GAMESTATE:GetCurrentSong() then
selection = GAMESTATE:GetCurrentSteps(player);
end;
end;
if selection then
self:SetFromRadarValues(player, selection:GetRadarValues(player));
else
self:SetEmpty(player);
end;
end
--
local t = Def.ActorFrame {
Name="Radar";
Def.GrooveRadar {
OnCommand=cmd(zoom,0;sleep,0.583;decelerate,0.150;zoom,1);
OffCommand=cmd(sleep,0.183;decelerate,0.167;zoom,0);
CurrentSongChangedMessageCommand=function(self)
for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
radarSet(self, pn);
end;
end;
CurrentStepsP1ChangedMessageCommand=function(self) radarSet(self, PLAYER_1); end;
CurrentStepsP2ChangedMessageCommand=function(self) radarSet(self, PLAYER_2); end;
CurrentTrailP1ChangedMessageCommand=function(self) radarSet(self, PLAYER_1); end;
CurrentTrailP2ChangedMessageCommand=function(self) radarSet(self, PLAYER_2); end;
};
};
return t;
end;
}
+2
View File
@@ -68,6 +68,7 @@ UserPrefLongFail=Fail Length
UserPrefComboOnRolls=Rolls Increment Combo
UserPrefFlashyCombo=Flashy Combo
UserPrefComboUnderField=Combo Under Field
UserPrefAdjustSpeed=Adjust Speed
[OptionExplanations]
UserPrefNotePosition=Determines where the arrow receptors are placed in gameplay.
UserPrefGameplayShowScore=Show or Hide the score display in gameplay.
@@ -78,6 +79,7 @@ UserPrefLongFail=Choose between the original sm-ssc fail (Long) or the new sm-ss
UserPrefComboOnRolls=Choose if rolls should increment the combo or not.
UserPrefFlashyCombo=Determine if combo flashes should be shown or not.
UserPrefComboUnderField=Determine if the combo should display under the notes or not.
UserPrefAdjustSpeed=Adjust the default scale for speed modifiers. Slow corresponds to the original StepMania 3.9 speed, Fast is twice that rate.
[StepsListDisplayRow StepsType]
Dance_Single=4
Dance_Double=8
+48
View File
@@ -34,6 +34,9 @@ function InitUserPrefs()
if GetUserPrefB("UserPrefComboUnderField") == nil then
SetUserPref("UserPrefComboUnderField", true);
end;
if GetUserPrefB("UserPrefAdjustSpeed") == nil then
SetUserPref("UserPrefAdjustSpeed", false);
end;
--[[ if GetUserPref("ProTimingP1") == nil then
SetUserPref("ProTimingP1", false);
end;
@@ -452,4 +455,49 @@ function UserPrefComboUnderField()
setmetatable( t, t );
return t;
end
function GetDefaultArrowSpacing()
local rates = {
64, -- Default
80, -- Pro
128, -- New
};
return GetUserPrefB("UserPrefAdjustSpeed") and rates[3] or rates[1];
end;
function UserPrefAdjustSpeed()
local t = {
Name = "UserPrefAdjustSpeed";
LayoutType = "ShowAllInRow";
SelectType = "SelectOne";
OneChoiceForAllPlayers = true;
ExportOnChange = false;
Choices = { 'Slow','Fast' };
LoadSelections = function(self, list, pn)
if ReadPrefFromFile("UserPrefAdjustSpeed") ~= nil then
if GetUserPrefB("UserPrefAdjustSpeed") then
list[2] = true;
else
list[1] = true;
end;
else
WritePrefToFile("UserPrefAdjustSpeed",true);
list[2] = true;
end;
end;
SaveSelections = function(self, list, pn)
local val;
if list[2] then
val = true;
else
val = false;
end;
WritePrefToFile("UserPrefAdjustSpeed",val);
MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } );
THEME:ReloadMetrics();
end;
};
setmetatable( t, t );
return t;
end
--[[ end option rows ]]
+5 -2
View File
@@ -321,6 +321,9 @@ ReceptorArrowsYStandard=GetTapPosition('Standard')
ReceptorArrowsYReverse=GetTapPosition('Reverse')
RollBodyIncrementsCombo=GetUserPrefB("UserPrefComboOnRolls")
[ArrowEffects]
ArrowSpacing=GetDefaultArrowSpacing()
[ScoreDisplayNormal]
FrameX=
FrameY=
@@ -818,7 +821,7 @@ ItemsLongRowSharedX=SCREEN_CENTER_X
[ScreenOptionsTheme]
Fallback="ScreenOptionsServiceChild"
LineNames="gNotePos,gAuto,gScore,gSDisp,gOpts,gLongFail,gComboUnderField,FlashyCombo"
LineNames="gNotePos,gAuto,gScore,gSDisp,gOpts,gLongFail,gComboUnderField,FlashyCombo,AdjustSpeed"
#,gAuto
LinegNotePos="lua,UserPrefNotePosition()"
LinegScore="lua,UserPrefGameplayShowScore()"
@@ -828,7 +831,7 @@ LinegAuto="lua,UserPrefAutoSetStyle()"
LinegLongFail="lua,UserPrefLongFail()"
LinegComboUnderField="lua,UserPrefComboUnderField()"
LineFlashyCombo="lua,UserPrefFlashyCombo()"
LineAdjustSpeed="lua,UserPrefAdjustSpeed()"
[ScreenOptionsSystemDirection]
LineNames="1,2,3,4,5,6,7,8,9,FlashyCombo,RollCombo,10,11,12,13,14,15,16,LF,17,18,19,20,21,22"
LineLF="lua,UserPrefLongFail()"