mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-11 11:53:31 +08:00
WIP
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
|
||||
@@ -8,6 +9,8 @@ public class I18N
|
||||
{
|
||||
private static bool _initialized;
|
||||
|
||||
public static Action OnInitialized;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
Harmony.CreateAndPatchAll(typeof(I18N));
|
||||
@@ -25,29 +28,12 @@ public class I18N
|
||||
ZHCN = string.IsNullOrEmpty(zhcn) ? enus : zhcn,
|
||||
FRFR = string.IsNullOrEmpty(frfr) ? enus : frfr
|
||||
};
|
||||
if (_initialized)
|
||||
{
|
||||
var index = strings.dataArray.Length;
|
||||
strProto.ID = GetNextID();
|
||||
strings.dataArray = strings.dataArray.Append(strProto).ToArray();
|
||||
strings.dataIndices[strProto.ID] = index;
|
||||
strings.nameIndices[strProto.Name] = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringsToAdd.Add(strProto);
|
||||
}
|
||||
StringsToAdd.Add(strProto);
|
||||
}
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
|
||||
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||
public static void Apply()
|
||||
{
|
||||
if (_initialized) return;
|
||||
_initialized = true;
|
||||
if (StringsToAdd.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_initialized) return;
|
||||
var strings = LDB._strings;
|
||||
var index = strings.dataArray.Length;
|
||||
strings.dataArray = strings.dataArray.Concat(StringsToAdd).ToArray();
|
||||
@@ -62,6 +48,21 @@ public class I18N
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
|
||||
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||
{
|
||||
if (_initialized) return;
|
||||
_initialized = true;
|
||||
if (StringsToAdd.Count == 0)
|
||||
{
|
||||
OnInitialized?.Invoke();
|
||||
return;
|
||||
}
|
||||
|
||||
Apply();
|
||||
OnInitialized?.Invoke();
|
||||
}
|
||||
|
||||
private static int GetNextID()
|
||||
{
|
||||
var strings = LDB._strings;
|
||||
|
||||
Reference in New Issue
Block a user