Skip to content

Commit

Permalink
- Updated libraries to latest version
Browse files Browse the repository at this point in the history
- Updated SessionManagerPatch to latest version
- Fixed custom helm patch injection by replacing SynthDataController with SynthController and post-hooking into the SynthsDataLoaded function
  • Loading branch information
v0idp committed Feb 10, 2024
1 parent 8d4a501 commit c0927e0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CSPL/CSPL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -79,7 +80,7 @@
<Compile Include="src\Patches\SessionsManagerPatch.cs" />
<Compile Include="src\CSPLPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\Patches\SynthDataControllerPatch.cs" />
<Compile Include="src\Patches\SynthControllerPatch.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
8 changes: 4 additions & 4 deletions CSPL/src/Patches/SessionsManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ public static class SessionsManagerPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(SessionsManager), nameof(SessionsManager.SaveSessionAs))]
public static void SaveSessionAs_Prefix(SessionsManager __instance, ref bool isInCloud, ref bool isCommunity)
public static void SaveSessionAs_Prefix(SessionsManager __instance, ref SessionSaveData sessionSaveData)
{
if (isCommunity == true)
if (sessionSaveData.IsShared || sessionSaveData.IsCloud)
{
isCommunity = false;
isInCloud = true;
sessionSaveData.IsShared = false;
sessionSaveData.IsCloud = false;
CSPLPlugin.Log.LogInfo("Preventing session from being shared to community...");
CSPLPlugin.Log.LogInfo("Session will be uploaded to cloud instead!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@
namespace CSPL.Patches
{
[HarmonyPatch]
public static class SynthDataControllerPatch
public static class SynthControllerPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(SynthDataController), nameof(SynthDataController.ApplyDefaults))]
public static void ApplyDefaults_Postfix(SynthDataController __instance)
[HarmonyPatch(typeof(SynthController), nameof(SynthController.SynthsDataLoaded))]
public static void SynthsDataLoaded_Postfix(SynthController __instance, ref InstrumentDataController dataController)
{
var directory = Directory.GetCurrentDirectory() + "\\import\\patches\\";
var dirInfo = new DirectoryInfo(directory);
var files = dirInfo.GetFiles("*.helm", SearchOption.AllDirectories);
if (files.Length > 0)
{
CSPLPlugin.Log.LogInfo($"Loading custom patches...");
for (var i = 0; i < files.Length; i++)
{
try
{
var patch = UnityEngine.JsonUtility.FromJson<HelmPatchFormat>(File.ReadAllText(files[i].FullName));
patch.patch_name = Path.GetFileNameWithoutExtension(files[i].Name);
patch.folder_name = "CustomPatches";
__instance.AddPatch(patch);
CSPLPlugin.Log.LogInfo($"Added custom patch {patch.patch_name}");
__instance.SynthDataController._defaultPatches.Add(new PatchSettings(patch));
__instance.SynthDataController.AddPatch(patch);
CSPLPlugin.Log.LogInfo($"Added custom patch \"{patch.patch_name}\"");
}
catch (Exception ex)
{
Expand Down
Binary file modified libs/Assembly-CSharp.dll
Binary file not shown.
Binary file modified libs/UnityEngine.AudioModule.dll
Binary file not shown.
Binary file modified libs/UnityEngine.CoreModule.dll
Binary file not shown.
Binary file modified libs/UnityEngine.JSONSerializeModule.dll
Binary file not shown.

0 comments on commit c0927e0

Please sign in to comment.