Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
CLO: 修正在Studio中不運作 v1.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jim60105 committed Dec 4, 2022
1 parent d059428 commit dc7df58
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
22 changes: 22 additions & 0 deletions CoordinateLoadOption/CoordinateLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,28 @@ internal static void ChangeCoordinate(object OcicharOrChaCtrl)
if (Patches.readABMX) abmx.CopyABMXData(tmpChaCtrl);
}

// KKAPI OnCoordinateBeingSaved is not working outside maker.
// So I had to trigger them manually as a workaround.
if (CLO.insideStudio)
{
//Material Editor
if (me.isExist)
me.SetExtDataFromController();

//KCOX
if (kcox.isExist)
kcox.SetExtDataFromController();

//ABMX
if (abmx.isExist)
abmx.SetExtDataFromController();

Logger.LogDebug("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
Logger.LogDebug("It will be good if KKAPI OnCoordinateBeingSaved() can be handled in Studio.");
Logger.LogDebug("At least, it should not show up as red here.");
Logger.LogDebug("Since I' m intentionally calling ChaFileCoordinate.SaveFile() in Studio, and it works fine.");
}

// 處理要綁定飾品的插件資料
if (Patches.boundAcc && Patches.tgls[9].isOn)
{
Expand Down
7 changes: 5 additions & 2 deletions CoordinateLoadOption/CoordinateLoadOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class CoordinateLoadOption : BaseUnityPlugin
{
internal const string PLUGIN_NAME = "Coordinate Load Option";
internal const string GUID = "com.jim60105.kks.coordinateloadoption";
internal const string PLUGIN_VERSION = "22.12.04.2";
internal const string PLUGIN_RELEASE_VERSION = "1.4.6";
internal const string PLUGIN_VERSION = "22.12.04.3";
internal const string PLUGIN_RELEASE_VERSION = "1.4.7";

public static bool insideStudio = Application.productName == "CharaStudio";

Expand Down Expand Up @@ -131,6 +131,9 @@ public void Start()
if (_isHairAccessoryCustomizerExist)
HairAccessoryCustomizer.Patch(harmonyInstance);

if(_isMoreAccessoriesExist)
MoreAccessories.PatchMoreAcc(harmonyInstance);

FolderBrowser.PatchFolderBrowser(harmonyInstance);

StringResources.StringResourcesManager.SetUICulture();
Expand Down
15 changes: 14 additions & 1 deletion CoordinateLoadOption/OtherPlugin/MoreAccessories.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ExtensibleSaveFormat;
using Extension;
using HarmonyLib;
using MessagePack;
using System;
using System.Collections.Generic;
Expand All @@ -15,14 +16,16 @@ class MoreAccessories
{
public const string GUID = "com.joan6694.illusionplugins.moreaccessories";
private static object MoreAccObj;
private static Type MoreAcc;

public static bool LoadAssembly()
{
try
{
string path = KoikatuHelper.TryGetPluginInstance(GUID, new Version(2, 0, 10))?.Info.Location;
Assembly ass = Assembly.LoadFrom(path);
MoreAccObj = ass.GetType("MoreAccessoriesKOI.MoreAccessories")?.GetFieldStatic("_self");
MoreAcc = ass.GetType("MoreAccessoriesKOI.MoreAccessories");
MoreAccObj = MoreAcc?.GetFieldStatic("_self");
if (null == MoreAccObj)
{
throw new Exception("Load assembly FAILED: MoreAccessories");
Expand All @@ -37,6 +40,16 @@ public static bool LoadAssembly()
}
}

internal static void PatchMoreAcc(Harmony harmony)
{
// MoreAccessoriesKOI.MoreAccessories.OnActualCoordSave(ChaFileCoordinate file)
// is not working outside maker
harmony.Patch(MoreAcc.GetMethod("OnActualCoordSave", AccessTools.all),
prefix: new HarmonyMethod(typeof(MoreAccessories), nameof(NotInsideStudio)));
}

private static bool NotInsideStudio() => !CoordinateLoadOption.insideStudio;

/// <summary>
/// 讀取MoreAccessories
/// </summary>
Expand Down

0 comments on commit dc7df58

Please sign in to comment.