1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-04 17:02:17 +08:00

Support for DSP 0.10

This commit is contained in:
2023-12-15 20:59:48 +08:00
parent aae771d730
commit d4b1ea93c8
37 changed files with 377 additions and 126 deletions

View File

@@ -17,17 +17,21 @@ public static class I18N
}
public static bool Initialized() => _initialized;
private static int _nextID = 1;
private static readonly List<StringProto> StringsToAdd = [];
public static void Add(string key, string enus, string zhcn = null, string frfr = null)
private struct Translation
{
var strProto = new StringProto
public string Key;
public string English;
public string Chinese;
}
private static readonly List<Translation> StringsToAdd = [];
public static void Add(string key, string enus, string zhcn = null)
{
if (zhcn == null && key == enus) return;
var strProto = new Translation
{
Name = key,
SID = "",
ENUS = enus,
ZHCN = string.IsNullOrEmpty(zhcn) ? enus : zhcn,
FRFR = string.IsNullOrEmpty(frfr) ? enus : frfr
Key = key,
English = enus,
Chinese = string.IsNullOrEmpty(zhcn) ? enus : zhcn
};
StringsToAdd.Add(strProto);
}
@@ -35,18 +39,52 @@ public static class I18N
public static void Apply()
{
if (!_initialized) return;
var strings = LDB._strings;
var index = strings.dataArray.Length;
strings.dataArray = strings.dataArray.Concat(StringsToAdd).ToArray();
StringsToAdd.Clear();
var newIndex = strings.dataArray.Length;
for (; index < newIndex; index++)
var indexer = Localization.namesIndexer;
var enIdx = -1;
var zhIdx = -1;
var llen = 0;
for (var i = 0; i < Localization.strings.Length; i++)
{
var strProto = strings.dataArray[index];
strProto.ID = GetNextID();
strings.dataIndices[strProto.ID] = index;
strings.nameIndices[strings.dataArray[index].Name] = index;
switch (Localization.Languages[i].lcId)
{
case Localization.LCID_ENUS:
if (!Localization.LanguageLoaded(i) && Localization.Loaded)
{
Localization.LoadLanguage(i);
}
enIdx = i;
break;
case Localization.LCID_ZHCN:
if (!Localization.LanguageLoaded(i) && Localization.Loaded)
{
Localization.LoadLanguage(i);
}
zhIdx = i;
llen = Localization.strings[i].Length;
break;
}
}
var enus = new string[StringsToAdd.Count];
var zhcn = new string[StringsToAdd.Count];
for (var i = 0; i < StringsToAdd.Count; i++)
{
var str = StringsToAdd[i];
enus[i] = str.English;
zhcn[i] = str.Chinese;
indexer[str.Key] = llen + i;
}
Localization.strings[enIdx] = Localization.strings[enIdx].Concat(enus).ToArray();
if (enIdx == Localization.currentLanguageIndex)
{
Localization.currentStrings = Localization.strings[enIdx];
}
Localization.strings[zhIdx] = Localization.strings[zhIdx].Concat(zhcn).ToArray();
if (zhIdx == Localization.currentLanguageIndex)
{
Localization.currentStrings = Localization.strings[zhIdx];
}
StringsToAdd.Clear();
}
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
@@ -63,22 +101,4 @@ public static class I18N
Apply();
OnInitialized?.Invoke();
}
private static int GetNextID()
{
var strings = LDB._strings;
while (_nextID <= 12000)
{
if (!strings.dataIndices.ContainsKey(_nextID))
{
break;
}
_nextID++;
}
var result = _nextID;
_nextID++;
return result;
}
}

View File

@@ -243,14 +243,14 @@ public static class FactoryPatch
var label1 = generator.DefineLabel();
var label2 = generator.DefineLabel();
matcher.MatchForward(false,
new CodeMatch(OpCodes.Pop)
new CodeMatch(OpCodes.Stloc_1)
).Advance(1).InsertAndAdvance(
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(NightLight), nameof(NightLight.Enabled))),
new CodeInstruction(OpCodes.Brfalse_S, label1),
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.mainPlayer))),
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.transform))),
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Transform), nameof(Transform.up))),
new CodeInstruction(OpCodes.Stloc_1),
new CodeInstruction(OpCodes.Stloc_2),
new CodeInstruction(OpCodes.Br_S, label2)
);
matcher.Labels.Add(label1);

View File

@@ -39,7 +39,7 @@ public static class PlanetFunctions
}
else
{
factory.RemoveEntityWithComponents(etd.id);
factory.RemoveEntityWithComponents(etd.id, false);
}
}
}

View File

@@ -4,6 +4,9 @@
#### 一些提升用户体验的功能和补丁
## Changlog
* 1.0.5
+ Support game version 0.10.28.20759
+ Sort blueprint structures before saving, to reduce generated blueprint data size a little.
* 1.0.4
+ Add new function: `Off-grid building and stepped rotation`
+ Fix an issue that window position not restored and can not be resized when function is enabled but game is started with different mod profiles.
@@ -66,6 +69,9 @@
* [OffGridConstruction](https://github.com/Velociraptor115-DSPModding/OffGridConstruction): Off-grid building & stepped rotation implementations
## 更新日志
* 1.0.5
+ 支持游戏版本0.10.28.20759
+ 保存蓝图前对建筑进行排序,以减少生成的蓝图数据大小
* 1.0.4
+ 添加了新功能:`脱离网格建造和小角度旋转`
+ 修复了当功能启用但游戏使用不同的mod配置文件启动时窗口位置无法正确恢复和不可拖动改变大小的问题

View File

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId>
@@ -15,14 +15,35 @@
<ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
<!--<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />-->
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\GameAssembly\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro">
<HintPath>..\GameAssembly\Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Networking">
<HintPath>..\GameAssembly\UnityEngine.Networking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.SpatialTracking">
<HintPath>..\GameAssembly\UnityEngine.SpatialTracking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Timeline">
<HintPath>..\GameAssembly\UnityEngine.Timeline.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\GameAssembly\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
</Target>

View File

@@ -1,6 +1,6 @@
{
"name": "UXAssist",
"version_number": "1.0.4",
"version_number": "1.0.5",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
"dependencies": [