remove old mods

This commit is contained in:
beer-psi 2024-08-08 13:35:35 +07:00
parent 54ff4d628f
commit 7a07ac502c
7 changed files with 0 additions and 560 deletions

View File

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F1C1B6BF-626C-4F10-8672-2F9596706CA6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CachedDataManager</RootNamespace>
<AssemblyName>Assembly-CSharp.CachedDataManager.mm</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<Reference Include="MonoMod">
<HintPath>..\External\MonoMod.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\External\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Manager\MaiStudio\Serialize\patch_FilePath.cs" />
<Compile Include="Manager\patch_DataManager.cs" />
<Compile Include="SerializationCache.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,20 +0,0 @@
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using MonoMod;
namespace Manager.MaiStudio.Serialize;
public class patch_FilePath : FilePath
{
[MonoModReplace]
public override void AddPath(string parentPath)
{
if (string.IsNullOrEmpty(path) || path.StartsWith(parentPath))
{
return;
}
path = parentPath + path;
}
}

View File

@ -1,205 +0,0 @@
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml.Serialization;
namespace Manager;
public class patch_DataManager : DataManager
{
private const string _cacheDirectory = "dataCache";
[Serializable]
[XmlType(TypeName="KeyValuePair")]
public class SerializableKeyValuePair<TK, TV>
{
public TK Key;
public TV Value;
}
private static Dictionary<string, T> LoadCacheFile<T>(string fileName)
{
if (!File.Exists(fileName))
{
return new Dictionary<string, T>();
}
using var fs = File.OpenRead(fileName);
var serializer = new XmlSerializer(typeof(List<SerializableKeyValuePair<string, T>>));
var entries = (List<SerializableKeyValuePair<string, T>>)serializer.Deserialize(fs);
return entries.ToDictionary(e => e.Key, e => e.Value);
}
private static void SaveCacheFile<T>(string destination, Dictionary<string, T> collection)
{
if (collection == null)
{
return;
}
using var fs = File.Open(destination, FileMode.Create);
var serializer = new XmlSerializer(typeof(List<SerializableKeyValuePair<string, T>>));
serializer.Serialize(
fs,
collection
.Select(kvp => new SerializableKeyValuePair<string, T> { Key = kvp.Key, Value = kvp.Value })
.ToList());
}
private static void SaveCache()
{
if (!Directory.Exists(_cacheDirectory))
{
Directory.CreateDirectory(_cacheDirectory);
}
SaveCacheFile(Path.Combine(_cacheDirectory, "RomConfigs.xml"), Cache.RomConfigs);
SaveCacheFile(Path.Combine(_cacheDirectory, "DataConfigs.xml"), Cache.DataConfigs);
SaveCacheFile(Path.Combine(_cacheDirectory, "Charas.xml"), Cache.Charas);
SaveCacheFile(Path.Combine(_cacheDirectory, "CharaAwakes.xml"), Cache.CharaAwakes);
SaveCacheFile(Path.Combine(_cacheDirectory, "CharaGenres.xml"), Cache.CharaGenres);
SaveCacheFile(Path.Combine(_cacheDirectory, "Events.xml"), Cache.Events);
SaveCacheFile(Path.Combine(_cacheDirectory, "Musics.xml"), Cache.Musics);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicGenres.xml"), Cache.MusicGenres);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicGroups.xml"), Cache.MusicGroups);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicVersions.xml"), Cache.MusicVersions);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicNameSorts.xml"), Cache.MusicNameSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicClearRanks.xml"), Cache.MusicClearRanks);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicDifficultys.xml"), Cache.MusicDifficultys);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicLevels.xml"), Cache.MusicLevels);
SaveCacheFile(Path.Combine(_cacheDirectory, "TournamentMusics.xml"), Cache.TournamentMusics);
SaveCacheFile(Path.Combine(_cacheDirectory, "Courses.xml"), Cache.Courses);
SaveCacheFile(Path.Combine(_cacheDirectory, "CourseModes.xml"), Cache.CourseModes);
SaveCacheFile(Path.Combine(_cacheDirectory, "LoginBonuses.xml"), Cache.LoginBonuses);
SaveCacheFile(Path.Combine(_cacheDirectory, "Maps.xml"), Cache.Maps);
SaveCacheFile(Path.Combine(_cacheDirectory, "MapColors.xml"), Cache.MapColors);
SaveCacheFile(Path.Combine(_cacheDirectory, "MapTreasures.xml"), Cache.MapTreasures);
SaveCacheFile(Path.Combine(_cacheDirectory, "MapBonusMusics.xml"), Cache.MapBonusMusics);
SaveCacheFile(Path.Combine(_cacheDirectory, "MapOtomodachis.xml"), Cache.MapOtomodachis);
SaveCacheFile(Path.Combine(_cacheDirectory, "MapSilhouettes.xml"), Cache.MapSilhouettes);
SaveCacheFile(Path.Combine(_cacheDirectory, "MapTitles.xml"), Cache.MapTitles);
SaveCacheFile(Path.Combine(_cacheDirectory, "ItemMusics.xml"), Cache.ItemMusics);
SaveCacheFile(Path.Combine(_cacheDirectory, "Icons.xml"), Cache.Icons);
SaveCacheFile(Path.Combine(_cacheDirectory, "Plates.xml"), Cache.Plates);
SaveCacheFile(Path.Combine(_cacheDirectory, "Titles.xml"), Cache.Titles);
SaveCacheFile(Path.Combine(_cacheDirectory, "Partners.xml"), Cache.Partners);
SaveCacheFile(Path.Combine(_cacheDirectory, "Frames.xml"), Cache.Frames);
SaveCacheFile(Path.Combine(_cacheDirectory, "Tickets.xml"), Cache.Tickets);
SaveCacheFile(Path.Combine(_cacheDirectory, "CollectionTypes.xml"), Cache.CollectionTypes);
SaveCacheFile(Path.Combine(_cacheDirectory, "CollectionGenres.xml"), Cache.CollectionGenres);
SaveCacheFile(Path.Combine(_cacheDirectory, "PhotoFrames.xml"), Cache.PhotoFrames);
SaveCacheFile(Path.Combine(_cacheDirectory, "Informations.xml"), Cache.Informations);
SaveCacheFile(Path.Combine(_cacheDirectory, "Udemaes.xml"), Cache.Udemaes);
SaveCacheFile(Path.Combine(_cacheDirectory, "Classes.xml"), Cache.Classes);
SaveCacheFile(Path.Combine(_cacheDirectory, "UdemaeBosses.xml"), Cache.UdemaeBosses);
SaveCacheFile(Path.Combine(_cacheDirectory, "UdemaeSeasonEvents.xml"), Cache.UdemaeSeasonEvents);
SaveCacheFile(Path.Combine(_cacheDirectory, "UdemaeSeasonRewards.xml"), Cache.UdemaeSeasonRewards);
SaveCacheFile(Path.Combine(_cacheDirectory, "Cards.xml"), Cache.Cards);
SaveCacheFile(Path.Combine(_cacheDirectory, "CardCharas.xml"), Cache.CardCharas);
SaveCacheFile(Path.Combine(_cacheDirectory, "CardTypes.xml"), Cache.CardTypes);
SaveCacheFile(Path.Combine(_cacheDirectory, "WeekdayBonuses.xml"), Cache.WeekdayBonuses);
SaveCacheFile(Path.Combine(_cacheDirectory, "Challenges.xml"), Cache.Challenges);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicRankings.xml"), Cache.MusicRankings);
SaveCacheFile(Path.Combine(_cacheDirectory, "MusicSorts.xml"), Cache.MusicSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "LoginBonusSorts.xml"), Cache.LoginBonusSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "IconSorts.xml"), Cache.IconSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "PlateSorts.xml"), Cache.PlateSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "TitleSorts.xml"), Cache.TitleSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "PartnerSorts.xml"), Cache.PartnerSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "FrameSorts.xml"), Cache.FrameSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "TicketSorts.xml"), Cache.TicketSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "CollectionGenreSorts.xml"), Cache.CollectionGenreSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "CharaSorts.xml"), Cache.CharaSorts);
SaveCacheFile(Path.Combine(_cacheDirectory, "CharaGenreSorts.xml"), Cache.CharaGenreSorts);
}
private static extern bool orig_Deserialize<T>(string filePath, out T dsr) where T : new();
private static bool Deserialize<T>(string filePath, out T dsr) where T : new()
{
var fileName = Path.GetFileName(filePath);
var collectionName = fileName switch
{
"UdemaeBoss.xml" => "UdemaeBosses",
"Class.xml" => "Classes",
"LoginBonus.xml" => "LoginBonuses",
"ScoreRanking.xml" => "TournamentMusics",
"Holiday.xml" => "WeekdayBonuses",
_ => fileName.Replace(".xml", "s"),
};
var collectionField =
typeof(CachedDataManager.SerializationCache).GetField(collectionName, BindingFlags.Public | BindingFlags.Instance);
if (collectionField == null)
{
System.Console.WriteLine("[CachedDataManager] [WARN] Could not find suitable collection for {0} (tried name {1})", fileName, collectionName);
return orig_Deserialize(filePath, out dsr);
}
try
{
var collection = (Dictionary<string, T>)collectionField.GetValue(Cache);
if (collection == null)
{
collection = LoadCacheFile<T>(Path.Combine(_cacheDirectory, $"{collectionName}.xml"));
collectionField.SetValue(Cache, collection);
}
if (collection.TryGetValue(filePath, out dsr))
{
return true;
}
if (!orig_Deserialize(filePath, out dsr))
{
return false;
}
collection.Add(filePath, dsr);
_cacheBusted = true;
return true;
}
catch (Exception e)
{
System.Console.WriteLine("[CachedDataManager] [ERROR] Could not load from cache: {0}", e);
return orig_Deserialize(filePath, out dsr);
}
}
private extern bool orig_IsLoaded();
public new bool IsLoaded()
{
var loaded = orig_IsLoaded();
if (!loaded || !_cacheBusted)
{
return loaded;
}
try
{
SaveCache();
}
catch (Exception e)
{
System.Console.WriteLine("[CachedDataManager] [ERROR] Could not save to cache: {0}", e);
}
_cacheBusted = false;
return true;
}
private static readonly CachedDataManager.SerializationCache Cache = new();
private static bool _cacheBusted;
}

View File

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CachedDataManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CachedDataManager")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("F1C1B6BF-626C-4F10-8672-2F9596706CA6")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,67 +0,0 @@
// ReSharper disable UnassignedField.Global
using System.Collections.Generic;
using Manager.MaiStudio.Serialize;
namespace CachedDataManager;
public class SerializationCache
{
public Dictionary<string, RomConfig> RomConfigs;
public Dictionary<string, DataConfig> DataConfigs;
public Dictionary<string, CharaData> Charas;
public Dictionary<string, CharaAwakeData> CharaAwakes;
public Dictionary<string, CharaGenreData> CharaGenres;
public Dictionary<string, EventData> Events;
public Dictionary<string, MusicData> Musics;
public Dictionary<string, MusicGenreData> MusicGenres;
public Dictionary<string, MusicGroupData> MusicGroups;
public Dictionary<string, MusicVersionData> MusicVersions;
public Dictionary<string, MusicNameSortData> MusicNameSorts;
public Dictionary<string, MusicClearRankData> MusicClearRanks;
public Dictionary<string, MusicDifficultyData> MusicDifficultys;
public Dictionary<string, MusicLevelData> MusicLevels;
public Dictionary<string, ScoreRankingData> TournamentMusics;
public Dictionary<string, CourseData> Courses;
public Dictionary<string, CourseModeData> CourseModes;
public Dictionary<string, LoginBonusData> LoginBonuses;
public Dictionary<string, MapData> Maps;
public Dictionary<string, MapColorData> MapColors;
public Dictionary<string, MapTreasureData> MapTreasures;
public Dictionary<string, MapBonusMusicData> MapBonusMusics;
public Dictionary<string, MapOtomodachiData> MapOtomodachis;
public Dictionary<string, MapSilhouetteData> MapSilhouettes;
public Dictionary<string, MapTitleData> MapTitles;
public Dictionary<string, ItemMusicData> ItemMusics;
public Dictionary<string, IconData> Icons;
public Dictionary<string, PlateData> Plates;
public Dictionary<string, TitleData> Titles;
public Dictionary<string, PartnerData> Partners;
public Dictionary<string, FrameData> Frames;
public Dictionary<string, TicketData> Tickets;
public Dictionary<string, CollectionTypeData> CollectionTypes;
public Dictionary<string, CollectionGenreData> CollectionGenres;
public Dictionary<string, PhotoFrameData> PhotoFrames;
public Dictionary<string, InformationData> Informations;
public Dictionary<string, UdemaeData> Udemaes;
public Dictionary<string, ClassData> Classes;
public Dictionary<string, UdemaeBossData> UdemaeBosses;
public Dictionary<string, UdemaeSeasonEventData> UdemaeSeasonEvents;
public Dictionary<string, UdemaeSeasonRewardData> UdemaeSeasonRewards;
public Dictionary<string, CardData> Cards;
public Dictionary<string, CardCharaData> CardCharas;
public Dictionary<string, CardTypeData> CardTypes;
public Dictionary<string, HolidayData> WeekdayBonuses;
public Dictionary<string, ChallengeData> Challenges;
public Dictionary<string, SerializeSortData> MusicRankings;
public Dictionary<string, SerializeSortData> MusicSorts;
public Dictionary<string, SerializeSortData> LoginBonusSorts;
public Dictionary<string, SerializeSortData> IconSorts;
public Dictionary<string, SerializeSortData> PlateSorts;
public Dictionary<string, SerializeSortData> TitleSorts;
public Dictionary<string, SerializeSortData> PartnerSorts;
public Dictionary<string, SerializeSortData> FrameSorts;
public Dictionary<string, SerializeSortData> TicketSorts;
public Dictionary<string, SerializeSortData> CollectionGenreSorts;
public Dictionary<string, SerializeSortData> CharaSorts;
public Dictionary<string, SerializeSortData> CharaGenreSorts;
}

View File

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.Ports" Version="9.0.0-preview.4.24266.19" />
</ItemGroup>
</Project>

View File

@ -1,154 +0,0 @@
// See https://aka.ms/new-console-template for more information
using System.Collections.Immutable;
using System.Reflection;
using System.Text;
var assemblyPath = args[0];
var targetPath = args[1];
var assembly = Assembly.LoadFrom(assemblyPath);
var types = assembly.GetTypes().Where(t => t.FullName.StartsWith("DB.") && t.FullName.EndsWith("IDEnum")).ToImmutableList();
foreach (var type in types)
{
var tableRecordType = assembly.GetType(type.FullName.Replace("IDEnum", "TableRecord"))!;
var patchClassName = $"patch_{type.Name}";
var readCommands = new StringBuilder();
var writeCommands = new StringBuilder();
var tableRecordFields = new StringBuilder();
foreach (var field in tableRecordType.GetFields(BindingFlags.Public | BindingFlags.Instance))
{
tableRecordFields.Append("public ");
if (field.FieldType.IsEnum)
{
tableRecordFields.Append("System.Int32 ");
}
else
{
tableRecordFields.Append(field.FieldType.FullName);
tableRecordFields.Append(" ");
}
tableRecordFields.Append(field.Name);
tableRecordFields.AppendLine(";");
readCommands.Append(field.Name)
.Append(" = (")
.Append(field.FieldType.FullName)
.Append(")src[i].")
.Append(field.Name)
.Append(", ");
writeCommands.Append(field.Name)
.Append(" = (")
.Append(field.FieldType.IsEnum ? "int" : field.FieldType.FullName)
.Append(")src[i].")
.Append(field.Name)
.Append(", ");
}
using var sw = File.CreateText(Path.Combine(targetPath, patchClassName + ".cs"));
sw.WriteLine($$"""
// 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 {{type.Name}}
{
public static extern bool LoadFromFile(string filename);
public static extern void DumpToFile(string filename);
protected static {{tableRecordType.Name}}[] records;
}
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
[Serializable]
public class Serializable{{tableRecordType.Name}} {
{{tableRecordFields}}
}
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
public class {{patchClassName}} : {{type.Name}} {
public new static bool LoadFromFile(string filename) {
if (!File.Exists(filename)) {
return false;
}
var table = JsonUtility.FromJson<Table<Serializable{{tableRecordType.Name}}>>(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 {{tableRecordType.Name}} { {{readCommands}} };
}
}
catch
{
Debug.LogError($"File read error: {filename}");
return false;
}
return true;
}
public new static void DumpToFile(string filename) {
var table = new Table<Serializable{{tableRecordType.Name}}>() {
records = new Serializable{{tableRecordType.Name}}[records.Length]
};
var src = records;
var dst = table.records;
for (var i = 0; i < records.Length; i++) {
dst[i] = new Serializable{{tableRecordType.Name}} { {{writeCommands}} };
}
File.WriteAllText(filename, JsonUtility.ToJson(table, true), Encoding.UTF8);
}
}
""");
}
using var dbLoaderSw = File.CreateText(Path.Combine(targetPath, "DBLoader.cs"));
dbLoaderSw.WriteLine($$"""
// ReSharper disable CheckNamespace
using System;
using System.CodeDom.Compiler;
using System.IO;
using System.Text;
namespace DB;
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
public class DBLoader
{
public static void LoadAll(string dirPath)
{
{{string.Join("\n", types.Select(t => $"{t.Name}.LoadFromFile(Path.Combine(dirPath, \"{t.Name.Replace("IDEnum", "TableRecord")}.json\"));"))}}
}
public static void DumpAll(string dirPath)
{
{{string.Join("\n", types.Select(t => $"{t.Name}.DumpToFile(Path.Combine(dirPath, \"{t.Name.Replace("IDEnum", "TableRecord")}.json\"));"))}}
}
}
""");