Skip to content

Commit

Permalink
ModTextDump: dump more studio mods, KSS_TextResourseRedirector: fix s…
Browse files Browse the repository at this point in the history
…alon subs
  • Loading branch information
GeBo1 committed Sep 29, 2021
1 parent 6bcf162 commit 0922d17
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 101 deletions.
292 changes: 208 additions & 84 deletions src/Core_ModTextDump/Core.ModTextDump.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Core_ModTextDump/Core_ModTextDump.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<Compile Include="$(MSBuildThisFileDirectory)AssemblyInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Core.ModTextDump.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Enums.cs" />
<Compile Include="$(MSBuildThisFileDirectory)WaitUntilStable.cs" />
</ItemGroup>
</Project>
37 changes: 37 additions & 0 deletions src/Core_ModTextDump/WaitUntilStable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections;
using System.Linq;
using UnityEngine;

namespace IllusionMods
{
internal class WaitUntilStable : CustomYieldInstruction

{
private readonly int _framesUntilStable;
private readonly ICollection _target;
private int _lastCount = -1;
private int _stableCount;

internal WaitUntilStable(ICollection target, int framesUntilStable = 3)
{
_framesUntilStable = framesUntilStable;
_target = target;
}

public override bool keepWaiting => !IsDone();

private bool IsDone()
{
var lastCount = _lastCount;
_lastCount = _target.Count;
if (_lastCount != lastCount)
{
_stableCount = 0;
return false;
}

_stableCount++;
return _stableCount > _framesUntilStable;
}
}
}
4 changes: 3 additions & 1 deletion src/Core_TextDump/Core.AssetLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ADV.Commands.Base;
using BepInEx.Logging;
using UnityEngine;
using static IllusionMods.AssetLoader;
using Logger = UnityEngine.Logger;
using Object = UnityEngine.Object;

Expand Down Expand Up @@ -184,7 +185,8 @@ internal static T AssetBundleManagerLoader(string assetBundleName, string assetN
}
catch (Exception err)
{
Logger.LogFatal(err);
Logger.LogWarning($"{nameof(AssetBundleManagerLoader)}: {err.Message}");
UnityEngine.Debug.LogException(err);
}
}
return bundle.LoadAsset<T>(assetName);
Expand Down
22 changes: 16 additions & 6 deletions src/Core_TextResourceHelper/Core.IPathListBoundHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface IPathListBoundHandler
public static partial class PathListBoundHandlerExtensions
{
private static ManualLogSource Logger => TextResourceHelper.Logger;

public static bool IsPathWhitelisted(this IPathListBoundHandler handler, string path,
bool isPathNormalized = false)
{
Expand All @@ -29,14 +30,23 @@ public static bool IsPathBlacklisted(this IPathListBoundHandler handler, string
public static bool IsPathAllowed(this IPathListBoundHandler handler, string path, bool isPathNormalized = false)
{
var search = isPathNormalized ? path : PathList.Normalize(path);
Logger.DebugLogDebug($"IsPathAllowed: {search}");
// run shorter test first
if (handler.WhiteListPaths.Count < handler.BlackListPaths.Count)
var result = true;
try
{
return IsPathWhitelisted(handler, search, true) && !IsPathBlacklisted(handler, search, true);
}
// run shorter test first
if (handler.WhiteListPaths.Count < handler.BlackListPaths.Count)
{
return result = IsPathWhitelisted(handler, search, true) &&
!IsPathBlacklisted(handler, search, true);
}

return !IsPathBlacklisted(handler, search, true) && IsPathWhitelisted(handler, search, true);
return result = !IsPathBlacklisted(handler, search, true) &&
IsPathWhitelisted(handler, search, true);
}
finally
{
Logger.DebugLogDebug("{0}.{1}: {2} => {3}", handler.GetType(), nameof(IsPathAllowed), search, result);
}
}

public static bool IsPathBlocked(this IPathListBoundHandler handler, string path, bool isPathNormalized = false)
Expand Down
4 changes: 2 additions & 2 deletions src/Core_TextResourceHelper/Core.ResourceMappingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public IEnumerable<ResourceMappingPath> GetMappingForPath(ResourceMappingPath pa

if (IsPathUnmapped(path, mode))
{
Logger.LogFatal($"{nameof(GetMappingForPath)}: {path}: unmapped");
Logger.DebugLogDebug($"{nameof(GetMappingForPath)}: {path}: unmapped");
yield break;
}

if (TryGetCachedMappingPaths(path, mode, out var cachedMappedPaths))
{
foreach (var mappedPath in cachedMappedPaths) yield return mappedPath;
Logger.LogFatal($"{nameof(GetMappingForPath)}: {path}: used cached");
Logger.DebugLogDebug($"{nameof(GetMappingForPath)}: {path}: used cached");
yield break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Core_TextResourceHelper/Core.ResourceMappingPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private ResourceMappingPath(string resourcePath = null, string calculatedModific
if (_calculatedModificationPath != null && _calculatedModificationPath[1] == ':' &&
_calculatedModificationPath[2] != '\\')
{
TextResourceHelper.Logger.LogFatal($"_calculatedModificationPath is corrupted {_calculatedModificationPath}");
TextResourceHelper.Logger.LogWarning($"{this}.{nameof(_calculatedModificationPath)} is corrupted {_calculatedModificationPath}");
}
}

Expand Down Expand Up @@ -87,7 +87,7 @@ private string BaseModificationPath
if (_baseModificationPath != null && _baseModificationPath[1] == ':' &&
_baseModificationPath[2] != '\\')
{
TextResourceHelper.Logger.LogFatal($"_baseModificationPath is corrupted {_baseModificationPath}");
TextResourceHelper.Logger.LogFatal($"{this}.{nameof(_baseModificationPath)} is corrupted {_baseModificationPath}");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public partial class TextResourceRedirector : BaseUnityPlugin

public const string PluginName = "Text Resource Redirector";
public const string GUID = "com.deathweasel.bepinex.textresourceredirector";
public const string Version = "1.4.5.2";
public const string Version = "1.4.5.5";
internal new static ManualLogSource Logger;
#if !HS
internal ChaListDataHandler ChaListDataHandler;
Expand Down
2 changes: 1 addition & 1 deletion src/KKS_TextDump/KKS_AssetDumpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ IDictionary<string, string> Dumper()


// CUSTOM_LIST2 = 3
Logger.LogFatal($"{nameof(GetCustomListDumpers)}: {assetBundleName} {asset.name}: ");
//Logger.LogFatal($"{nameof(GetCustomListDumpers)}: {assetBundleName} {asset.name}: ");
var processors = colsToDump.Select(col => GetTranslateManagerRowProcessor(3, mapIdx, col)).ToList();
var items = GetExcelEntries(asset, assetName).ToList();
for (var i = firstRow; i < items.Count; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void ConfigureHandlersForKKS(TextResourceRedirector sender, EventArgs ev

if (sender.EstheticVoiceInfoHandler is IPathListBoundHandler estheticVoiceInfoHandler)
{
estheticVoiceInfoHandler.WhiteListPaths.Add("esthetic/list/voice");
estheticVoiceInfoHandler.WhiteListPaths.Add("abdata/esthetic/list/voice");
}

Harmony.CreateAndPatchAll(typeof(Hooks));
Expand Down
20 changes: 18 additions & 2 deletions src/Shared.TextDumpBase/BaseTextDumpPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,24 @@ protected IEnumerator WriteTranslations()

if (moveSuccess)
{
LogWithMessage(BepInExLogLevel.Info,
$"Dump can be found in {DumpDestination}");
LogWithMessage(BepInExLogLevel.Info, $"Dump can be found in {DumpDestination}");
if (_dumpRoot != null)
{
var oldDumpRoot = _dumpRoot;
_dumpRoot = null;
if (Directory.Exists(oldDumpRoot))

{
try
{
Directory.Delete(DumpRoot);
}
catch
{
// leave it
}
}
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Shared.Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static class Constants
internal const RegexOptions DefaultRegexOptions = RegexOptions.Compiled;
#elif KKS
internal const string GameName = "Koikatsu Sunshine";
internal const string StudioProcessName = "CharaStudioV2";
internal const string StudioProcessName = "CharaStudio";
internal const string MainGameProcessName = "Koikatsu Sunshine";
internal const RegexOptions DefaultRegexOptions = RegexOptions.Compiled;
#else
Expand Down

0 comments on commit 0922d17

Please sign in to comment.