1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-04 15:12:17 +08:00
This commit is contained in:
2023-09-08 13:15:00 +08:00
parent cfcffb85ee
commit 09dc6dbdcd
7 changed files with 103 additions and 101 deletions

View File

@@ -12,6 +12,7 @@ public class EpicDifficulty
{
I18N.Add("究极少", "Micro", "究极少");
I18N.Add("史诗难度", "Epic Difficulty !!", "史诗难度 !!");
I18N.Apply();
Harmony.CreateAndPatchAll(typeof(EpicDifficulty));
}

View File

@@ -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;

View File

@@ -32,6 +32,7 @@ public class MoreSettings
I18N.Add("步进最小距离", "Step Distance Min", "步进最小距离");
I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离");
I18N.Add("扁平度", "Flatness", "扁平度");
I18N.Apply();
Harmony.CreateAndPatchAll(typeof(MoreSettings));
}