mirror of
https://gitea.tendokyu.moe/beerpsi/sinmai-mods.git
synced 2024-11-30 18:24:39 +01:00
86 lines
3.3 KiB
C#
86 lines
3.3 KiB
C#
// ReSharper disable CheckNamespace
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
using System;
|
|
using System.CodeDom.Compiler;
|
|
using System.IO;
|
|
using System.Text;
|
|
using MonoMod;
|
|
using LooseDBTables;
|
|
using UnityEngine;
|
|
|
|
namespace DB;
|
|
|
|
[MonoModIgnore]
|
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
|
public class WindowMessageIDEnum
|
|
{
|
|
public static extern bool LoadFromFile(string filename);
|
|
public static extern void DumpToFile(string filename);
|
|
protected static WindowMessageTableRecord[] records;
|
|
}
|
|
|
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
|
[Serializable]
|
|
public class SerializableWindowMessageTableRecord {
|
|
public System.Int32 EnumValue;
|
|
public System.String EnumName;
|
|
public System.Int32 Kind;
|
|
public System.Int32 Position;
|
|
public System.Int32 Size;
|
|
public System.String Title;
|
|
public System.String TitleEx;
|
|
public System.String Name;
|
|
public System.String NameEx;
|
|
public System.Int32 Lifetime;
|
|
public System.String FileName;
|
|
|
|
}
|
|
|
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
|
public class patch_WindowMessageIDEnum : WindowMessageIDEnum {
|
|
public new static bool LoadFromFile(string filename) {
|
|
if (!File.Exists(filename)) {
|
|
return false;
|
|
}
|
|
|
|
var table = JsonUtility.FromJson<Table<SerializableWindowMessageTableRecord>>(File.ReadAllText(filename));
|
|
|
|
try
|
|
{
|
|
if (table.records.Length != records.Length) {
|
|
Debug.LogError($"Count read error: {filename}");
|
|
return false;
|
|
}
|
|
|
|
var src = table.records;
|
|
var dst = records;
|
|
|
|
for (var i = 0; i < table.records.Length; i++) {
|
|
dst[i] = new WindowMessageTableRecord { EnumValue = (System.Int32)src[i].EnumValue, EnumName = (System.String)src[i].EnumName, Kind = (DB.WindowKindID)src[i].Kind, Position = (DB.WindowPositionID)src[i].Position, Size = (DB.WindowSizeID)src[i].Size, Title = (System.String)src[i].Title, TitleEx = (System.String)src[i].TitleEx, Name = (System.String)src[i].Name, NameEx = (System.String)src[i].NameEx, Lifetime = (System.Int32)src[i].Lifetime, FileName = (System.String)src[i].FileName, };
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
Debug.LogError($"File read error: {filename}");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public new static void DumpToFile(string filename) {
|
|
var table = new Table<SerializableWindowMessageTableRecord>() {
|
|
records = new SerializableWindowMessageTableRecord[records.Length]
|
|
};
|
|
|
|
var src = records;
|
|
var dst = table.records;
|
|
|
|
for (var i = 0; i < records.Length; i++) {
|
|
dst[i] = new SerializableWindowMessageTableRecord { EnumValue = (System.Int32)src[i].EnumValue, EnumName = (System.String)src[i].EnumName, Kind = (int)src[i].Kind, Position = (int)src[i].Position, Size = (int)src[i].Size, Title = (System.String)src[i].Title, TitleEx = (System.String)src[i].TitleEx, Name = (System.String)src[i].Name, NameEx = (System.String)src[i].NameEx, Lifetime = (System.Int32)src[i].Lifetime, FileName = (System.String)src[i].FileName, };
|
|
}
|
|
|
|
File.WriteAllText(filename, JsonUtility.ToJson(table, true), Encoding.UTF8);
|
|
}
|
|
}
|