Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Commit

Permalink
Implemented INI and Shader edits
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 28, 2019
1 parent 8ac4802 commit bf2c60e
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions OMODFramework/Scripting/OBMMScriptHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,11 @@ internal static ScriptReturnData Execute(string inputScript, string dataPath, st
FunctionPatch(line, false);
break;
case "EditINI":
//TODO: FunctionEditINI(line);
FunctionEditINI(line);
break;
case "EditSDP":
case "EditShader":
//TODO: FunctionEditShader(line);
FunctionEditShader(line);
break;
case "SetGMST":
//TODO: FunctionSetEspVar(line, true);
Expand Down Expand Up @@ -2065,5 +2065,48 @@ private static void FunctionPatch(IReadOnlyCollection<string> line, bool plugin)
throw new OMODFrameworkException("Unknown PatchMethod for Framework.CurrentPatchMethod!");
}
}

private static void FunctionEditShader(IReadOnlyCollection<string> line)
{
if(line.Count < 4) {
Warn("Missing arguments for 'EditShader'");
return;
}

if (line.Count > 4) Warn("Unexpected arguments for 'EditShader'");
var shaderPath = Path.Combine(DataFiles, line.ElementAt(3));
if (!Utils.IsSafeFileName(line.ElementAt(3)))
{
Warn($"Invalid argument for 'EditShader'\n'{line.ElementAt(3)}' is not a valid file name");
return;
}

if (!File.Exists(shaderPath))
{
Warn($"Invalid argument for 'EditShader'\nFile '{line.ElementAt(3)}' does not exist");
return;
}

if (!byte.TryParse(line.ElementAt(1), out var package))
{
Warn($"Invalid argument for function 'EditShader'\n'{line.ElementAt(1)}' is not a valid shader package ID");
return;
}

srd.SDPEdits.Add(new SDPEditInfo(package, line.ElementAt(2), shaderPath));

}

private static void FunctionEditINI(IReadOnlyCollection<string> line)
{
if (line.Count < 4)
{
Warn("Missing arguments for 'EditINI'");
return;
}

if(line.Count > 4) Warn("Unexpected argument for EditINI");
srd.INIEdits.Add(new INIEditInfo(line.ElementAt(1), line.ElementAt(2), line.ElementAt(3)));
}
}
}

0 comments on commit bf2c60e

Please sign in to comment.