mirror of
https://gitea.tendokyu.moe/beerpsi/sinmai-mods.git
synced 2024-11-28 01:20:48 +01:00
85 lines
3.3 KiB
C#
85 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 OptionBreakseIDEnum
|
|
{
|
|
public static extern bool LoadFromFile(string filename);
|
|
public static extern void DumpToFile(string filename);
|
|
protected static OptionBreakseTableRecord[] records;
|
|
}
|
|
|
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
|
[Serializable]
|
|
public class SerializableOptionBreakseTableRecord {
|
|
public System.Int32 EnumValue;
|
|
public System.String EnumName;
|
|
public System.String Name;
|
|
public System.String NameEx;
|
|
public System.String Detail;
|
|
public System.String DetailEx;
|
|
public System.String SeGoodEnum;
|
|
public System.String SeBadEnum;
|
|
public System.Boolean isDefault;
|
|
public System.String FilePath;
|
|
|
|
}
|
|
|
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
|
public class patch_OptionBreakseIDEnum : OptionBreakseIDEnum {
|
|
public new static bool LoadFromFile(string filename) {
|
|
if (!File.Exists(filename)) {
|
|
return false;
|
|
}
|
|
|
|
var table = JsonUtility.FromJson<Table<SerializableOptionBreakseTableRecord>>(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 OptionBreakseTableRecord { EnumValue = (System.Int32)src[i].EnumValue, EnumName = (System.String)src[i].EnumName, Name = (System.String)src[i].Name, NameEx = (System.String)src[i].NameEx, Detail = (System.String)src[i].Detail, DetailEx = (System.String)src[i].DetailEx, SeGoodEnum = (System.String)src[i].SeGoodEnum, SeBadEnum = (System.String)src[i].SeBadEnum, isDefault = (System.Boolean)src[i].isDefault, FilePath = (System.String)src[i].FilePath, };
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
Debug.LogError($"File read error: {filename}");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public new static void DumpToFile(string filename) {
|
|
var table = new Table<SerializableOptionBreakseTableRecord>() {
|
|
records = new SerializableOptionBreakseTableRecord[records.Length]
|
|
};
|
|
|
|
var src = records;
|
|
var dst = table.records;
|
|
|
|
for (var i = 0; i < records.Length; i++) {
|
|
dst[i] = new SerializableOptionBreakseTableRecord { EnumValue = (System.Int32)src[i].EnumValue, EnumName = (System.String)src[i].EnumName, Name = (System.String)src[i].Name, NameEx = (System.String)src[i].NameEx, Detail = (System.String)src[i].Detail, DetailEx = (System.String)src[i].DetailEx, SeGoodEnum = (System.String)src[i].SeGoodEnum, SeBadEnum = (System.String)src[i].SeBadEnum, isDefault = (System.Boolean)src[i].isDefault, FilePath = (System.String)src[i].FilePath, };
|
|
}
|
|
|
|
File.WriteAllText(filename, JsonUtility.ToJson(table, true), Encoding.UTF8);
|
|
}
|
|
}
|