upgrade CustomSpeedMods to 2.2, disable KeymapGuard because it doesn't work
This commit is contained in:
@@ -1,9 +1,13 @@
|
|||||||
--[[
|
--[[
|
||||||
Custom Speed Mods v2.1 (for StepMania 5)
|
Custom Speed Mods v2.2 (for StepMania 5)
|
||||||
by AJ Kelly of KKI Labs ( http://kki.ajworld.net/ )
|
by AJ Kelly of KKI Labs ( http://kki.ajworld.net/ )
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
|
|
||||||
|
v2.2 (StepMania 5 alpha 2) [by FSX]
|
||||||
|
* Rewrite table management code.
|
||||||
|
* Add code to make sure that there are speed mods and that they are correct.
|
||||||
|
|
||||||
v2.1 (StepMania 5 Preview 2)
|
v2.1 (StepMania 5 Preview 2)
|
||||||
* Added support for m-Mods.
|
* Added support for m-Mods.
|
||||||
|
|
||||||
@@ -48,20 +52,7 @@ end
|
|||||||
-- Tries to parse the file at path. If successful, returns a table of mods.
|
-- Tries to parse the file at path. If successful, returns a table of mods.
|
||||||
-- If it can't open the file, it will write a fallback set of mods.
|
-- If it can't open the file, it will write a fallback set of mods.
|
||||||
local function ParseSpeedModFile(path)
|
local function ParseSpeedModFile(path)
|
||||||
local file = RageFileUtil.CreateRageFile()
|
local function Failure()
|
||||||
if file:Open(path, 1) then
|
|
||||||
-- success
|
|
||||||
local contents = file:Read()
|
|
||||||
mods = split(',',contents)
|
|
||||||
|
|
||||||
-- strip any whitespace
|
|
||||||
for i=1,#mods do
|
|
||||||
string.gsub(mods[i], "%s", "")
|
|
||||||
end
|
|
||||||
|
|
||||||
file:destroy()
|
|
||||||
return mods
|
|
||||||
else
|
|
||||||
-- error; write a fallback mod file and return it
|
-- error; write a fallback mod file and return it
|
||||||
local fallbackString = "0.5x,1x,1.5x,2x,3x,4x,5x,6x,7x,8x,C250,C450,m550"
|
local fallbackString = "0.5x,1x,1.5x,2x,3x,4x,5x,6x,7x,8x,C250,C450,m550"
|
||||||
Trace("[CustomSpeedMods]: Could not read SpeedMods; writing fallback to "..path)
|
Trace("[CustomSpeedMods]: Could not read SpeedMods; writing fallback to "..path)
|
||||||
@@ -70,49 +61,46 @@ local function ParseSpeedModFile(path)
|
|||||||
file:destroy()
|
file:destroy()
|
||||||
return split(',',fallbackString)
|
return split(',',fallbackString)
|
||||||
end
|
end
|
||||||
|
local file = RageFileUtil.CreateRageFile()
|
||||||
|
if file:Open(path, 1) then
|
||||||
|
-- success
|
||||||
|
local contents = file:Read()
|
||||||
|
mods = split(',',contents)
|
||||||
|
|
||||||
|
-- strip any whitespace and check
|
||||||
|
for i=1,#mods do
|
||||||
|
string.gsub(mods[i], "%s", "")
|
||||||
|
if not(mods[i]:find("%d+\.?%d*x") or mods[i]:find("[cmCM]%d+")) then
|
||||||
|
mods[i] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MarkDupes(src,parent)
|
if #mods==0 then return Failure() end
|
||||||
-- Marks duplicates in src from any matches in parent.
|
|
||||||
-- the overall mods are usually used as the parent.
|
file:destroy()
|
||||||
local function MarkDupes(src,parent)
|
return mods
|
||||||
for iPar=1,#parent do
|
else
|
||||||
for iSrc=1,#src do
|
return Failure()
|
||||||
if parent[iPar] == src[iSrc] then
|
|
||||||
src[iSrc] = "XXX"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return src
|
|
||||||
end
|
|
||||||
|
|
||||||
-- RemoveMarked(src)
|
-- InvertTable(tbl)
|
||||||
-- Removes any values marked for deletion.
|
-- Returns a table where a key-value pair is swapped.
|
||||||
local function RemoveMarked(src)
|
local function InvertTable(tbl)
|
||||||
for iSrc=1,#src do
|
local rTable = {}
|
||||||
if src[iSrc] == "XXX" then
|
for k,v in pairs(tbl) do
|
||||||
table.remove(src,iSrc)
|
rTable[v] = k
|
||||||
end
|
end
|
||||||
end
|
return rTable
|
||||||
return src
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MergeTables(parent,child)
|
-- MergeTables(parent,child)
|
||||||
-- Adds the child's contents to the parent.
|
-- Puts two tables together, overwriting values
|
||||||
-- the overall mods are usually used as the parent.
|
-- with the same key.
|
||||||
local function MergeTables(parent, child)
|
local function MergeTables(parent, child)
|
||||||
child = RemoveMarked(child)
|
for k,v in pairs(parent) do
|
||||||
if #child == 0 then
|
child[k] = v
|
||||||
return parent
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local addMe = true
|
|
||||||
for iC=1,#child do
|
|
||||||
if addMe then
|
|
||||||
table.insert(parent,child[iC])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return parent
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- code in this function is based off of code in
|
-- code in this function is based off of code in
|
||||||
@@ -187,8 +175,8 @@ local function GetSpeedMods()
|
|||||||
-- figure out how many players we have to deal with.
|
-- figure out how many players we have to deal with.
|
||||||
local numPlayers = GAMESTATE:GetNumPlayersEnabled()
|
local numPlayers = GAMESTATE:GetNumPlayersEnabled()
|
||||||
|
|
||||||
-- load machine
|
-- load machine to finalMods
|
||||||
local machineMods = ParseSpeedModFile(profileDirs.Machine..baseFilename)
|
finalMods = InvertTable(ParseSpeedModFile(profileDirs.Machine..baseFilename))
|
||||||
|
|
||||||
local playerMods = {}
|
local playerMods = {}
|
||||||
for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
|
for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
|
||||||
@@ -201,34 +189,22 @@ local function GetSpeedMods()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- mine for duplicates, first pass
|
-- join players, overwriting duplicates
|
||||||
machineMods = MarkDupes(machineMods,finalMods)
|
|
||||||
for ply=1,#playerMods do
|
for ply=1,#playerMods do
|
||||||
playerMods[ply] = MarkDupes(playerMods[ply],finalMods)
|
MergeTables(finalMods,InvertTable(playerMods[ply]))
|
||||||
end
|
|
||||||
-- remove XXX, first pass
|
|
||||||
machineMods = RemoveMarked(machineMods);
|
|
||||||
for ply=1,#playerMods do
|
|
||||||
playerMods[ply] = RemoveMarked(playerMods[ply])
|
|
||||||
end
|
|
||||||
-- mine for duplicates, second pass (machine <-> player)
|
|
||||||
for ply=1,#playerMods do
|
|
||||||
playerMods[ply] = MarkDupes(playerMods[ply],machineMods)
|
|
||||||
end
|
|
||||||
-- remove XXX, second pass
|
|
||||||
machineMods = RemoveMarked(machineMods)
|
|
||||||
for ply=1,#playerMods do
|
|
||||||
playerMods[ply] = RemoveMarked(playerMods[ply])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- merge zone
|
-- convert into an unsorted integer-indexed table
|
||||||
finalMods = MergeTables(finalMods,machineMods)
|
do
|
||||||
for ply=1,#playerMods do
|
local curIndex = 1
|
||||||
finalMods = MergeTables(finalMods,playerMods[ply])
|
local newFinalMods = {}
|
||||||
|
for k,v in pairs(finalMods) do
|
||||||
|
newFinalMods[curIndex] = k
|
||||||
|
curIndex = curIndex + 1
|
||||||
|
end
|
||||||
|
finalMods = newFinalMods
|
||||||
end
|
end
|
||||||
|
|
||||||
-- final removal of XXX before sorting
|
|
||||||
finalMods = RemoveMarked(finalMods)
|
|
||||||
-- sort the mods before returning them
|
-- sort the mods before returning them
|
||||||
return SpeedModSort(finalMods)
|
return SpeedModSort(finalMods)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,25 +1 @@
|
|||||||
--[[ People sometimes have problems where they rebind the enter key and thus
|
--does not work
|
||||||
cannot press start. To work around this problem, this script deletes every key
|
|
||||||
binding to Enter. --]]
|
|
||||||
|
|
||||||
function ClearEnterMappedKeys()
|
|
||||||
-- load Keymaps.ini
|
|
||||||
local keymaps = IniFile.ReadFile("/Save/Keymaps.ini")
|
|
||||||
|
|
||||||
-- iterate through the games
|
|
||||||
for k,v in pairs(keymaps) do
|
|
||||||
-- iterate through the potential key mappings
|
|
||||||
for l,w in pairs(v) do
|
|
||||||
-- check for enter
|
|
||||||
w:gsub("Key_enter","")
|
|
||||||
-- write back
|
|
||||||
keymaps[k][l] = w
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- write Keymaps.ini back out. yay.
|
|
||||||
IniFile.WriteFile("/Save/Keymaps.ini",keymaps)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- actually run it.
|
|
||||||
ClearEnterMappedKeys()
|
|
||||||
Reference in New Issue
Block a user