Skip to content

Commit

Permalink
Fixed KKAPI controllers not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Kokaiinum authored Jul 5, 2019
1 parent b6da75c commit 3da2b64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions JannieReplacer/JannieReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Logger = BepInEx.Logger;
using BepInEx.Logging;
using System;
using System.Linq;

namespace JannieReplacer {
[BepInProcess("Koikatu")]
Expand All @@ -18,10 +19,10 @@ public class JannieReplacer : BaseUnityPlugin {

public const string GUID = "kokaiinum.janniereplacer";
public const string Name = "Janitor Replacer";
public const string Version = "1.3";
public const string Version = "1.4";


public const string FileExtension = ".png";
public const string FileExtension = ".png";
public const string Filter = "Koikatu cards (*.png)|*.png|All files|*.*";


Expand Down Expand Up @@ -95,14 +96,18 @@ private static bool IsKoiCard(string path) {
private void Awake() {
Enabled = new ConfigWrapper<bool>("Enabled", GUID, true);
FilePath = new ConfigWrapper<string>(nameof(FilePath), GUID, null);
var harmony = HarmonyInstance.Create(GUID);
harmony.PatchAll(typeof(JannieReplacer));
// There's no reason to install this plugin on a game without Darkness, but just in case someone does so anyway,
// this check prevents a MissingMethodExcetpion being thrown.
if (typeof(ChaControl).GetProperties(AccessTools.all).Any(p => p.Name == "exType")) {
var harmony = HarmonyInstance.Create(GUID);
harmony.PatchAll(typeof(JannieReplacer));
}
}

[HarmonyPrefix]
[HarmonyPatch(typeof(ChaControl), "LoadPreset")]
public static bool LoadPresetPrefix(int _exType, ChaControl __instance) {
if (Enabled.Value) {
if (Enabled.Value) {
if (!FilePath.Value.IsNullOrEmpty()) {
if (_exType == 1) {
if (!File.Exists(FilePath.Value)) {
Expand All @@ -115,13 +120,13 @@ public static bool LoadPresetPrefix(int _exType, ChaControl __instance) {
FilePath.Value = null;
return true;
}
__instance.chaFile.LoadFileLimited(FilePath.Value);
__instance.chaFile.LoadCharaFile(FilePath.Value);
return false;
}
}
}
return true;
}
}

[HarmonyPrefix]
[HarmonyPatch(typeof(FreeHScene), "SetMainCanvasObject")]
Expand Down
4 changes: 2 additions & 2 deletions JannieReplacer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyVersion("1.0.4.0")]
[assembly: AssemblyFileVersion("1.0.4.0")]

0 comments on commit 3da2b64

Please sign in to comment.