diff --git a/src/Shared/CharacterReplacer.Hooks.cs b/src/Shared/CharacterReplacer.Hooks.cs index ebdf126..e7b58b9 100644 --- a/src/Shared/CharacterReplacer.Hooks.cs +++ b/src/Shared/CharacterReplacer.Hooks.cs @@ -29,15 +29,13 @@ internal static bool LoadFromAssetBundle(ChaFileControl __instance, string asset __instance.LoadCharaFile(CardPathDefaultM.Value); return false; } -#if !EC - else if (assetName == AssetOther) + else if (assetName == AssetOther && CardPathOther != null) { if (!VerifyCard(ReplacementCardType.Other)) return true; Logger.LogDebug($"Replacing {CardNameOther} with card: {CardPathOther.Value}"); __instance.LoadCharaFile(CardPathOther.Value); return false; } -#endif return true; } diff --git a/src/Shared/CharacterReplacer.cs b/src/Shared/CharacterReplacer.cs index 6a8be22..6de96b3 100644 --- a/src/Shared/CharacterReplacer.cs +++ b/src/Shared/CharacterReplacer.cs @@ -1,6 +1,7 @@ using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; +using HarmonyLib; using KKAPI.Utilities; using Shared; using System; @@ -16,7 +17,7 @@ public partial class CharacterReplacer { public const string GUID = "IllusionMods.CharacterReplacer"; public const string PluginName = "Character Replacer"; - public const string Version = "1.6.1"; + public const string Version = "1.6.2"; internal static new ManualLogSource Logger; public const string FileExtension = ".png"; @@ -29,9 +30,7 @@ public partial class CharacterReplacer public static ConfigEntry Enabled { get; private set; } public static ConfigEntry CardPathDefaultF { get; private set; } public static ConfigEntry CardPathDefaultM { get; private set; } -#if !EC public static ConfigEntry CardPathOther { get; private set; } -#endif internal void Awake() { @@ -42,7 +41,22 @@ internal void Awake() CardPathDefaultF = Config.Bind("Config", $"{CardNameDefaultF} Card Path", "", new ConfigDescription("Path of the replacement card on disk.", null, new ConfigurationManagerAttributes { Order = 8 })); Config.Bind("Config", $"{CardNameDefaultM} Card Replacement", "", new ConfigDescription("Browse for a card.", null, new ConfigurationManagerAttributes { Order = 7, HideDefaultButton = true, CustomDrawer = new Action(CardButtonDrawer) })); CardPathDefaultM = Config.Bind("Config", $"{CardNameDefaultM} Card Path", "", new ConfigDescription("Path of the replacement card on disk.", null, new ConfigurationManagerAttributes { Order = 6 })); -#if !EC + + AddOtherConfig(); + } + + /// + /// Only show the janitor/merchant stuff in games where it exists and in versions of KK where it exists + /// + private void AddOtherConfig() + { +#if EC + //EC has no Merchant or Janitor +#else +#if KK + //KK Party and KK without Darkness don't have Janitor + if (typeof(ChaControl).GetProperty("exType", AccessTools.all) == null) return; +#endif Config.Bind("Config", $"{CardNameOther} Card Replacement", "", new ConfigDescription("Browse for a card.", null, new ConfigurationManagerAttributes { Order = 5, HideDefaultButton = true, CustomDrawer = new Action(CardButtonDrawer) })); CardPathOther = Config.Bind("Config", $"{CardNameOther} Card Path", "", new ConfigDescription("Path of the replacement card on disk.", null, new ConfigurationManagerAttributes { Order = 4 })); #endif @@ -74,10 +88,8 @@ private void OnCardAccept(string key, string[] path) CardPathDefaultF.Value = path[0]; else if (key.StartsWith(CardNameDefaultM)) CardPathDefaultM.Value = path[0]; -#if !EC - else if (key.StartsWith(CardNameOther)) + else if (key.StartsWith(CardNameOther) && CardPathOther != null) CardPathOther.Value = path[0]; -#endif break; case CardType.None: Logger.LogMessage("Error! Not a card."); @@ -104,13 +116,11 @@ internal static bool VerifyCard(ReplacementCardType replacementCardType) configEntry = CardPathDefaultF; else if (replacementCardType == ReplacementCardType.DefaultMale) configEntry = CardPathDefaultM; -#if !EC - else if (replacementCardType == ReplacementCardType.Other) + else if (replacementCardType == ReplacementCardType.Other && CardPathOther != null) { configEntry = CardPathOther; text = $" {CardNameOther}"; } -#endif else return false; if (configEntry.Value.IsNullOrEmpty()) return false;