Skip to content

Commit

Permalink
[KKS] Fixed clothes import hook running all the time in studio, preve…
Browse files Browse the repository at this point in the history
…nting clothes replacing; Log cleanup
  • Loading branch information
ManlyMarco committed Sep 28, 2021
1 parent 988ce9c commit d2ef419
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/KKS_ExtensibleSaveFormat/KKS.ExtendedSave.Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ private static void KKChaFileLoadFileHook(ChaFile file, BlockHeader header, Bina
var dictionary = MessagePackDeserialize<Dictionary<string, PluginData>>(data);
if (dictionary != null)
{
if (!file.charaFileName.IsNullOrEmpty())//plugin currently feeds empty, but not null charafilenames
Logger.Log(LogLevel.Debug, $"Importing \"{file.parameter.fullname}\" \"{file.charaFileName}\" ");
if (!file.charaFileName.IsNullOrEmpty()) // plugins can leave charaFileName empty instead of null
Logger.Log(LogLevel.Debug, $"Importing \"{file.parameter?.fullname}\" from \"{file.charaFileName}\" ");

CardImportEvent(dictionary, CoordinateMapping);
internalCharaDictionary.Set(file, dictionary);
}
Expand Down Expand Up @@ -165,8 +166,9 @@ private static void KKChaFileLoadFilePostHook(ChaFile __instance, bool __result,

if (dictionary != null)
{
if (!__instance.charaFileName.IsNullOrEmpty())
Logger.Log(LogLevel.Debug, $"Importing \"{__instance.parameter.fullname}\" \"{__instance.charaFileName}\" ");
if (!__instance.charaFileName.IsNullOrEmpty()) // plugins can leave charaFileName empty instead of null
Logger.Log(LogLevel.Debug, $"Importing \"{__instance.parameter?.fullname}\" from \"{__instance.charaFileName}\" ");

CardImportEvent(dictionary, CoordinateMapping);
internalCharaDictionary.Set(__instance, dictionary);
}
Expand Down Expand Up @@ -225,7 +227,10 @@ private static bool SetCoordinateBytes(ChaFile __instance, byte[] data, Version
return false;
}

private static bool DoingImport = true;
private static bool DoingImport;

[HarmonyPostfix, HarmonyPatch(typeof(ConvertChaFileScene), nameof(ConvertChaFileScene.Start))]
private static void ConvertChaFileSceneStart() => DoingImport = true;

[HarmonyPostfix, HarmonyPatch(typeof(ConvertChaFileScene), nameof(ConvertChaFileScene.OnDestroy))]
private static void ConvertChaFileSceneEnd()
Expand Down

0 comments on commit d2ef419

Please sign in to comment.