From: Cameron Ball Date: Tue, 26 Nov 2013 03:57:21 +0000 (+0800) Subject: New multi line speed mods system. At the moment the rows look bad on the player optio... X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=e02a17d098066296b4c91c3bcfead3a4c9394302;p=GrooveNights.git New multi line speed mods system. At the moment the rows look bad on the player options screen because they are too long, but that should be easy to sort out. --- diff --git a/Themes/GrooveNights/.gitignore b/Themes/GrooveNights/.gitignore index 142b7fe..d67f2c4 100644 --- a/Themes/GrooveNights/.gitignore +++ b/Themes/GrooveNights/.gitignore @@ -2,4 +2,7 @@ !.gitignore #include everything in this directory -!* \ No newline at end of file +!* + +#ignore netbeans crap +nbproject diff --git a/Themes/GrooveNights/BGAnimations/ScreenSelectStyle2 overlay/default.xml b/Themes/GrooveNights/BGAnimations/ScreenSelectStyle2 overlay/default.xml index 875ce54..6e9bad4 100644 --- a/Themes/GrooveNights/BGAnimations/ScreenSelectStyle2 overlay/default.xml +++ b/Themes/GrooveNights/BGAnimations/ScreenSelectStyle2 overlay/default.xml @@ -1,8 +1,11 @@ - + + + diff --git a/Themes/GrooveNights/Languages/english.ini b/Themes/GrooveNights/Languages/english.ini index 1974daa..426576c 100644 --- a/Themes/GrooveNights/Languages/english.ini +++ b/Themes/GrooveNights/Languages/english.ini @@ -330,6 +330,9 @@ Autosave=Autosave Speed=Speed +Base Speed=Base Speed +Extra Speed=Extra Speed +Speed Type=Speed Type Accel=Acceleration Effect=Effect Appearance=Fade @@ -359,6 +362,8 @@ LifeDifficulty=Life Diff. JudgeDifficulty=Judge Diff. DefaultFailType=Fail Type Theme=Swap Theme +SpeedModType=Speed Mods + Windowed=Display DisplayResolution=Resolution diff --git a/Themes/GrooveNights/Scripts/Other.lua b/Themes/GrooveNights/Scripts/Other.lua index e1a6d9c..b7b6d9b 100644 --- a/Themes/GrooveNights/Scripts/Other.lua +++ b/Themes/GrooveNights/Scripts/Other.lua @@ -447,3 +447,164 @@ function GetRateMod() elseif GetRateModHelper('0.9xmusic') then curRate = 0.9; return '0.9' else curRate = 1; return '(Unknown rate mod)' end end + +function oitgACoptions() + -- Right now we return the same line names for both OITG and whatever else happens to be running. But in the future they might be different. + if OPENITG then return "1,2,3,4,5,6,7,8,9,10,11" end + + return "1,2,3,4,5,6,7,8,9,10,11" +end + +function SongModifiers() + -- this is very basic right now, but it can be modified to take in to account OITG specific stuff + return SpeedLines() .. "4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24" +end + +function SpeedLines() + local type = GetSpeedModType() + + if type == "pro" then + return "1,2,3," + else + return "1," + end +end + +function SpeedMods(name) + local modList = baseSpeed + local s = "Speed" + + if name == "Extra" then + modList = extraSpeed + s = "Extra " .. s + end + + if name == "Type" then + modList = typeSpeed + s = s .. " Type" + end + + local Params = { Name = s, OneChoiceForAllPlayers = false } + + local function Load(self, list, pn) + -- default to the first item in the list + list[1] = true + + -- now loop through everything else in the list and see if it is set to true + for i=2, table.getn(modList) do + if name == "Base" then + if modList[i] == modBase[pn+1] then + list[i] = true + list[1] = false + else + list[i] = false + end + end + + if name == "Extra" then + if modList[i] == modExtra[pn+1] then + list[i] = true + list[1] = false + else + list[i] = false + end + end + + if name == "type" then + s = modList[n] + s = string.gsub(s, '-Mod','') + + if s == modType[pn+1] then + list[i] = true + list[1] = false + else + list[i] = false + end + end + end + end + + local function Save(self, list, pn) + for i = 1, table.getn(modList) do + if list[i] then + s = modList[i] + end + end + + local p = pn + 1 + + if name == "Type" then modType[p] = s end + if name == "Base" then + modBase[p] = s + + if GetSpeedModType() ~= "pro" then + if string.find(modBase[p],"x") then modBase[p] = string.gsub(modBase[p], "x", ""); modType[p] = 'x-mod' end + if string.find(modBase[p],"c") then modBase[p] = string.gsub(modBase[p], "c", ""); modType[p] = 'c-mod' end + if string.find(modBase[p],"m") then modBase[p] = string.gsub(modBase[p], "m", ""); modType[p] = 'm-mod' end + end + end + + if name == "Extra" then modExtra[p] = s end + + if modType[p] == 'x-mod' then modSpeed[p] = modBase[p] + modExtra[p] .. 'x' end + if modType[p] == 'c-mod' then modSpeed[p] = 'c' .. modBase[p]*100 + modExtra[p]*100 end + if modType[p] == 'c-mod' and GetSpeedModType() ~= "pro" then modSpeed[p] = 'c' .. modBase[p] end + if modType[p] == 'm-mod' then modSpeed[p] = 'm' .. modBase[p]*100 + modExtra[p]*100 end + if modType[p] == 'm-mod' and GetSpeedModType() ~= "pro" then modSpeed[p] = 'm' .. modBase[p] end + GAMESTATE:ApplyGameCommand('mod,1x',p) + ApplySpeedMods() + MESSAGEMAN:Broadcast('SpeedModChanged') + end + + return CreateOptionRow( Params, modList, Load, Save ) +end + +function ApplySpeedMods() + for pn=1, 2 do + if GAMESTATE:IsPlayerEnabled( pn - 1 ) then + speed = string.gsub(modSpeed[pn],modType[pn],"") + if modType[pn] == "x" then speed = math.ceil(100*speed/modRate)/100 .. "x" end + if modType[pn] == "c" then speed = "c" .. math.ceil(speed/modRate) end + if modType[pn] == "m" then speed = "m" .. math.ceil(speed/modRate) end + GAMESTATE:ApplyGameCommand('mod,' .. speed,pn) + end + end +end + +function InitSpeedMods() + Trace("Got in to initspeedmods") + + modBase = { "1", "1" } + modExtra = { "+.5", "+.5" } + modType = { "x-mod", "x-mod" } + modSpeed = { "1.5x", "1.5x" } + + if GetSpeedModType() == "pro" then + baseSpeed = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" } + extraSpeed = { "0", "+.25", "+.5", "+.75", "+.1", "+.2", "+.3", "+.4", "+.6", "+.7", "+.8", "+.9" } + end + + if GetSpeedModType() == "advanced" then + if OPENITG then baseSpeed = { "0.25x", "0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x", "2.25x", "2.5x", "2.75x", "3x", "3.25x", "3.5x", "3.75x", "4x", "4.25x", "4.5x", "4.75x", "5x", "5.25x", "5.5x", "5.75x", "6x", "6.25x", "6.5x", "6.75x", "7x", "c400", "c425", "c450", "c475", "c500", "c525", "c550", "c575", "c600", "c625", "c650", "c675", "c700", "c725", "c750", "c775", "c800", "c825", "c850", "c875", "c900", "c925", "c950", "c975", "c1000", "m400", "m425", "m450", "m475", "m500", "m525", "m550", "m575", "m600", "m625", "m650", "m675", "m700", "m725", "m750", "m775", "m800", "m825", "m850", "m875", "m900", "m925", "m950", "m975", "m1000" } + else baseSpeed = { "0.25x", "0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x", "2.25x", "2.5x", "2.75x", "3x", "3.25x", "3.5x", "3.75x", "4x", "4.25x", "4.5x", "4.75x", "5x", "5.25x", "5.5x", "5.75x", "6x", "6.25x", "6.5x", "6.75x", "7x", "c400", "c425", "c450", "c475", "c500", "c525", "c550", "c575", "c600", "c625", "c650", "c675", "c700", "c725", "c750", "c775", "c800", "c825", "c850", "c875", "c900", "c925", "c950", "c975", "c1000" } + end + + extraSpeed = { "0" } + modExtra = { "0", "0" } + end + + if GetSpeedModType() == "basic" then + if OPENITG then baseSpeed = { "1x", "1.5x", "2x", "2.5x", "3x", "3.5x", "4x", "4.5x", "5x", "6x", "c450", "m450" } + else baseSpeed = { "1x", "1.5x", "2x", "2.5x", "3x", "3.5x", "4x", "4.5x", "5x", "5.5x", "6x", "c450" } + end + + extraSpeed = { "0" } + modExtra = { "0", "0" } + end + + if OPENITG then + typeSpeed = { "x-mod", "c-mod", "m-mod" } + else + typeSpeed = { "x-mod", "c-mod" } + end +end \ No newline at end of file diff --git a/Themes/GrooveNights/Scripts/PrefsRows.lua b/Themes/GrooveNights/Scripts/PrefsRows.lua new file mode 100644 index 0000000..5254b8a --- /dev/null +++ b/Themes/GrooveNights/Scripts/PrefsRows.lua @@ -0,0 +1,176 @@ +--[[ +Simple PrefsRows API for 3.95/OpenITG, version 1.2 +Licensed under Creative Commons Attribution-Share Alike 3.0 Unported +(http://creativecommons.org/licenses/by-sa/3.0/) + +Base definitions and templates for StepMania LUA options lists. +Written by Mark Cannon ("Vyhd") for OpenITG (http://www.boxorroxors.net/) +All I ask is that you keep this notice intact and don't redistribute in bytecode. +--]] + + + +--[[ +Callable functions: + +CreateOptionRow( Params, Names, LoadFctn, SaveFctn ) +[creates a generic OptionRow with the given data] + - Params: table with OptionRow data. "Name" is required, others are optional. + - Names: table with the names of the objects to be used + - LoadFctn(self, list, pn): called on list load, sets an initial toggle + - SaveFctn(self, list, pn): called on list exit, uses a toggle to set a value + +CreatePrefsRow( Params, Names, Values, prefname ) +[creates a Preference-modifying OptionRow with this data] + - Values: table with the values to be used (1:1 map to Names) + - prefname: string with the name of the Preference to modify + +CreatePrefsRowRange( Params, Names, prefname, start, delta ) +[generates an OptionsRow with a value range, set to the length of Names] + - start: starting value, from which the value generation starts + - delta: difference between each value in the list + +CreatePrefsRowEnum( Params, Names, prefname ) +[generates an OptionsRow that uses enumeration values] + +CreatePrefsRowBool( Params, prefname ) +[generates an OptionsRow that toggles a boolean Preference] + +CreateSimplePrefsRowBool( prefname ) +[same as above, except sets the OptionRow name to prefname, too] + +If you're still confused, check out my usage of these elsewhere. +--]] + +function CreateOptionRow( Params, Names, LoadFctn, SaveFctn ) + if not Params.Name then return nil end + + -- this needs to be used because Lua evaluates 'false' as 'nil', so + -- we can't use an OR operator to assign the value properly. + local function setbool( value, default ) + if value ~= nil then return value else return default end + end + + -- fill in with passed params or default values. only Name is required. + local t = + { + Name = Params.Name, + + LayoutType = Params.LayoutType or "ShowAllInRow", + SelectType = Params.SelectType or "SelectOne", + + OneChoiceForAllPlayers = setbool(Params.OneChoiceForAllPlayers, true), + EnabledForPlayers = Params.EnabledForPlayers or {PLAYER_1, PLAYER_2}, + + ExportOnChange = setbool(Params.ExportOnChange, false), + ReloadRowMessages= Params.ReloadRowMessages or {}, + + Choices = Names, + LoadSelections = LoadFctn, + SaveSelections = SaveFctn, + } + + setmetatable( t, t ) + return t +end + +-- creates a row list given a list of names and values +function CreatePrefsRow( Params, Names, Values, prefname ) + local amt = table.getn(Names) + local val = PREFSMAN:GetPreference(prefname) + + local function Load(self, list, pn) + for i = 1, amt do + if Values[i] == val then + list[i] = true + return + end + end + list[1] = true -- fall back to first value + end + + local function Save(self, list, pn) + for i = 1, amt do + if list[i] then + PREFSMAN:SetPreference(prefname, Values[i]) + return + end + end + end + + return CreateOptionRow( Params, Names, Load, Save ) +end + +-- creates a ranged list, given an offset and delta between values +function CreatePrefsRowRange( Params, Names, prefname, start, delta ) + local amt = table.getn(Names) + local val = PREFSMAN:GetPreference(prefname) + + local function IndexToValue(i) + return start+(delta*(i-1)) + end + + local function Load(self, list, pn) + for i = 1, amt do + if IndexToValue(i) == val then + list[i] = true + return + end + end + list[1] = true -- fall back to first value + end + + local function Save(self, list, pn) + for i = 1,amt do + if list[i] then + PREFSMAN:SetPreference(prefname, IndexToValue(i)) + end + end + end + + return CreateOptionRow( Params, Names, Load, Save ) +end + +-- creates an enumerated toggle for a preference +function CreatePrefsRowEnum( Params, Names, prefname ) + local amt = table.getn(Names) + local val = PREFSMAN:GetPreference(prefname) + + return CreateOptionRowRange( Params, Names, prefname, 0, 1 ) +end + +-- creates a boolean toggle for a preference +function CreatePrefsRowBool( Params, prefname ) + local OptionValues = { false, true } + local OptionNames = { "OFF", "ON" } + + local val = PREFSMAN:GetPreference(prefname) + + local function Load(self, list, pn) + if PREFSMAN:GetPreference(prefname) == true then + list[2] = true + else + list[1] = true + end + end + + -- set 0 if "OFF" (index 1), 1 if "ON" (index 2) + local function Save(self, list, pn) + for i = 1,2 do + if list[i] then + PREFSMAN:SetPreference(prefname, OptionValues[i] ) + return + end + end + end + + return CreateOptionRow( Params, OptionNames, Load, Save ) +end + +-- very simple boolean toggle for a preference +function CreateSimplePrefsRowBool( prefname ) + local Params = {} + Params.Name = prefname + + return CreatePrefsRowBool( Params, prefname ) +end \ No newline at end of file diff --git a/Themes/GrooveNights/Scripts/gnCustomOptions.lua b/Themes/GrooveNights/Scripts/gnCustomOptions.lua new file mode 100644 index 0000000..6c72bfa --- /dev/null +++ b/Themes/GrooveNights/Scripts/gnCustomOptions.lua @@ -0,0 +1,46 @@ +-- This is purely for convenience +local ProfileTable = PROFILEMAN:GetMachineProfile():GetSaved() + +-- Valid speed mod row type names. +local Names = { "Basic", "Advanced", "Pro" } + +function SpeedModTypeRow() + local type = ProfileTable.SpeedModType + + local function Load(self, list, pn) + -- if type is not set then default to basic + if not type then list[1] = true return end + + -- what we're doing here is checking what we got from profileman against the valid names. + for i=1,3 do + if type == string.lower(Names[i]) then list[i] = true return end + end + + -- if nothing matched then just default to basic + list[1] = true + end + + local function Save(self, list, pn) + -- go through each item in the list and save the first one that is set to true + for i=1,3 do + if list[i] then + ProfileTable.SpeedModType = string.lower(Names[i]) + PROFILEMAN:SaveMachineProfile() + return + end + end + end + + local Params = { Name = "SpeedModType" } + + return CreateOptionRow( Params, Names, Load, Save ) +end + +function GetSpeedModType() + local type = ProfileTable.SpeedModType + + -- as soon as we find a valid name, return it. + for i=1,3 do + if type == string.lower(Names[i]) then return type end + end +end \ No newline at end of file diff --git a/Themes/GrooveNights/metrics.ini b/Themes/GrooveNights/metrics.ini index 8eb34c8..f99725c 100644 --- a/Themes/GrooveNights/metrics.ini +++ b/Themes/GrooveNights/metrics.ini @@ -3943,7 +3943,7 @@ CapitalizeAllOptionNames=0 [ScreenArcadeOptions] Fallback=ScreenOptionsSubmenu -LineNames=1,2,3,4,5,6,7,8,9,10 +LineNames=@oitgACoptions() OptionMenuFlags=together;forceallplayers;explanations Line1=conf,CoinModeNoHome Line2=conf,SongsPerPlay @@ -3955,6 +3955,7 @@ Line7=conf,LifeDifficulty Line8=conf,JudgeDifficulty Line9=conf,DefaultFailType Line10=conf,Theme +Line11=lua,SpeedModTypeRow() [ScreenGraphicOptions] Fallback=ScreenOptionsSubmenu @@ -4025,33 +4026,34 @@ ShowStage=1 NextScreen=ScreenBranchStage PrevScreen=@SongSelectionScreen() PlayMusic=0 -LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 +LineNames=@SongModifiers() OptionMenuFlags=explanations;firstchoicegoesdown -Line1=lua,SpeedMod() -Line2=lua,AddSpeedMod() -Line3=list,Persp -Line4=lua,RateMod() -Line5=list,NoteSkins2 -Line6=list,Accel -Line7=list,Mini -Line8=list,Beat -Line9=list,Dizzy -Line10=list,Flip -Line11=list,Drift -Line12=List,Float -Line13=list,Invisible -Line14=list,Appearance -Line15=list,Handicap -Line16=list,Turn -Line17=list,InsertOther -Line18=list,Foreground -Line19=list,InsertTaps -Line20=list,Hide -Line21=list,HideBG -Line22=lua,GoBack() -Line23=list,Steps +Line1=lua,SpeedMods('Base') +Line2=lua,SpeedMods('Extra') +Line3=lua,SpeedMods('Type') +Line4=list,Persp +Line5=lua,RateMod() +Line6=list,NoteSkins2 +Line7=list,Accel +Line8=list,Mini +Line9=list,Beat +Line10=list,Dizzy +Line11=list,Flip +Line12=list,Drift +Line13=List,Float +Line14=list,Invisible +Line15=list,Appearance +Line16=list,Handicap +Line17=list,Turn +Line18=list,InsertOther +Line19=list,Foreground +Line20=list,InsertTaps +Line21=list,Hide +Line22=list,HideBG +Line23=lua,GoBack() +Line24=list,Steps #Removed from GrooveNights -Line24=lua,StaminaMod() +Line25=lua,StaminaMod() CancelAllP1X=SCREEN_CENTER_X-160 CancelAllP1Y=SCREEN_CENTER_Y