From cdec49dd878ecab05f0aa23f2eed2f31ef9200df Mon Sep 17 00:00:00 2001 From: beerpsi Date: Wed, 22 May 2024 22:31:19 +0700 Subject: [PATCH] initial commit --- .gitignore | 493 ++++++++++++++++++ .idea/.idea.sinmai-mods/.idea/.gitignore | 13 + .idea/.idea.sinmai-mods/.idea/encodings.xml | 4 + .idea/.idea.sinmai-mods/.idea/indexLayout.xml | 8 + CachedDataManager/CachedDataManager.csproj | 65 +++ .../MaiStudio/Serialize/patch_FilePath.cs | 20 + .../Manager/patch_DataManager.cs | 205 ++++++++ CachedDataManager/Properties/AssemblyInfo.cs | 35 ++ CachedDataManager/SerializationCache.cs | 67 +++ FixLocaleIssues/FixLocaleIssues.csproj | 73 +++ .../MAI2System/patch_IniSection.cs | 21 + FixLocaleIssues/Manager/patch_MA2Record.cs | 36 ++ FixLocaleIssues/Manager/patch_SlideManager.cs | 224 ++++++++ FixLocaleIssues/Properties/AssemblyInfo.cs | 35 ++ README.md | 13 + sinmai-mods.sln | 22 + 16 files changed, 1334 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.idea.sinmai-mods/.idea/.gitignore create mode 100644 .idea/.idea.sinmai-mods/.idea/encodings.xml create mode 100644 .idea/.idea.sinmai-mods/.idea/indexLayout.xml create mode 100644 CachedDataManager/CachedDataManager.csproj create mode 100644 CachedDataManager/Manager/MaiStudio/Serialize/patch_FilePath.cs create mode 100644 CachedDataManager/Manager/patch_DataManager.cs create mode 100644 CachedDataManager/Properties/AssemblyInfo.cs create mode 100644 CachedDataManager/SerializationCache.cs create mode 100644 FixLocaleIssues/FixLocaleIssues.csproj create mode 100644 FixLocaleIssues/MAI2System/patch_IniSection.cs create mode 100644 FixLocaleIssues/Manager/patch_MA2Record.cs create mode 100644 FixLocaleIssues/Manager/patch_SlideManager.cs create mode 100644 FixLocaleIssues/Properties/AssemblyInfo.cs create mode 100644 README.md create mode 100644 sinmai-mods.sln diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fdfb943 --- /dev/null +++ b/.gitignore @@ -0,0 +1,493 @@ +# Created by https://www.toptal.com/developers/gitignore/api/csharp,rider,dotnetcore +# Edit at https://www.toptal.com/developers/gitignore?templates=csharp,rider,dotnetcore + +### Csharp ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### DotnetCore ### +# .NET Core build folders +bin/ +obj/ + +# Common node modules locations +/node_modules +/wwwroot/node_modules + +### Rider ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# End of https://www.toptal.com/developers/gitignore/api/csharp,rider,dotnetcore + +External +!External/.gitkeep \ No newline at end of file diff --git a/.idea/.idea.sinmai-mods/.idea/.gitignore b/.idea/.idea.sinmai-mods/.idea/.gitignore new file mode 100644 index 0000000..9b0ac3e --- /dev/null +++ b/.idea/.idea.sinmai-mods/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/.idea.sinmai-mods.iml +/modules.xml +/contentModel.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.sinmai-mods/.idea/encodings.xml b/.idea/.idea.sinmai-mods/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.sinmai-mods/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.sinmai-mods/.idea/indexLayout.xml b/.idea/.idea.sinmai-mods/.idea/indexLayout.xml new file mode 100644 index 0000000..f5a863a --- /dev/null +++ b/.idea/.idea.sinmai-mods/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CachedDataManager/CachedDataManager.csproj b/CachedDataManager/CachedDataManager.csproj new file mode 100644 index 0000000..811a7c0 --- /dev/null +++ b/CachedDataManager/CachedDataManager.csproj @@ -0,0 +1,65 @@ + + + + + Debug + AnyCPU + {F1C1B6BF-626C-4F10-8672-2F9596706CA6} + Library + Properties + CachedDataManager + Assembly-CSharp.CachedDataManager.mm + v4.6.2 + 512 + latest + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + ..\External\MonoMod.exe + False + + + ..\External\Assembly-CSharp.dll + False + + + + + + + + + + + + diff --git a/CachedDataManager/Manager/MaiStudio/Serialize/patch_FilePath.cs b/CachedDataManager/Manager/MaiStudio/Serialize/patch_FilePath.cs new file mode 100644 index 0000000..19262e0 --- /dev/null +++ b/CachedDataManager/Manager/MaiStudio/Serialize/patch_FilePath.cs @@ -0,0 +1,20 @@ +// 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; + } +} diff --git a/CachedDataManager/Manager/patch_DataManager.cs b/CachedDataManager/Manager/patch_DataManager.cs new file mode 100644 index 0000000..ce89b60 --- /dev/null +++ b/CachedDataManager/Manager/patch_DataManager.cs @@ -0,0 +1,205 @@ +// 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 + { + public TK Key; + public TV Value; + } + + private static Dictionary LoadCacheFile(string fileName) + { + if (!File.Exists(fileName)) + { + return new Dictionary(); + } + + using var fs = File.OpenRead(fileName); + var serializer = new XmlSerializer(typeof(List>)); + var entries = (List>)serializer.Deserialize(fs); + + return entries.ToDictionary(e => e.Key, e => e.Value); + } + + private static void SaveCacheFile(string destination, Dictionary collection) + { + if (collection == null) + { + return; + } + + using var fs = File.Open(destination, FileMode.Create); + var serializer = new XmlSerializer(typeof(List>)); + + serializer.Serialize( + fs, + collection + .Select(kvp => new SerializableKeyValuePair { 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(string filePath, out T dsr) where T : new(); + private static bool Deserialize(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)collectionField.GetValue(Cache); + + if (collection == null) + { + collection = LoadCacheFile(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; +} + + diff --git a/CachedDataManager/Properties/AssemblyInfo.cs b/CachedDataManager/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5b8bfcc --- /dev/null +++ b/CachedDataManager/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +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")] \ No newline at end of file diff --git a/CachedDataManager/SerializationCache.cs b/CachedDataManager/SerializationCache.cs new file mode 100644 index 0000000..b55c463 --- /dev/null +++ b/CachedDataManager/SerializationCache.cs @@ -0,0 +1,67 @@ +// ReSharper disable UnassignedField.Global +using System.Collections.Generic; +using Manager.MaiStudio.Serialize; + +namespace CachedDataManager; + +public class SerializationCache +{ + public Dictionary RomConfigs; + public Dictionary DataConfigs; + public Dictionary Charas; + public Dictionary CharaAwakes; + public Dictionary CharaGenres; + public Dictionary Events; + public Dictionary Musics; + public Dictionary MusicGenres; + public Dictionary MusicGroups; + public Dictionary MusicVersions; + public Dictionary MusicNameSorts; + public Dictionary MusicClearRanks; + public Dictionary MusicDifficultys; + public Dictionary MusicLevels; + public Dictionary TournamentMusics; + public Dictionary Courses; + public Dictionary CourseModes; + public Dictionary LoginBonuses; + public Dictionary Maps; + public Dictionary MapColors; + public Dictionary MapTreasures; + public Dictionary MapBonusMusics; + public Dictionary MapOtomodachis; + public Dictionary MapSilhouettes; + public Dictionary MapTitles; + public Dictionary ItemMusics; + public Dictionary Icons; + public Dictionary Plates; + public Dictionary Titles; + public Dictionary Partners; + public Dictionary Frames; + public Dictionary Tickets; + public Dictionary CollectionTypes; + public Dictionary CollectionGenres; + public Dictionary PhotoFrames; + public Dictionary Informations; + public Dictionary Udemaes; + public Dictionary Classes; + public Dictionary UdemaeBosses; + public Dictionary UdemaeSeasonEvents; + public Dictionary UdemaeSeasonRewards; + public Dictionary Cards; + public Dictionary CardCharas; + public Dictionary CardTypes; + public Dictionary WeekdayBonuses; + public Dictionary Challenges; + public Dictionary MusicRankings; + public Dictionary MusicSorts; + public Dictionary LoginBonusSorts; + public Dictionary IconSorts; + public Dictionary PlateSorts; + public Dictionary TitleSorts; + public Dictionary PartnerSorts; + public Dictionary FrameSorts; + public Dictionary TicketSorts; + public Dictionary CollectionGenreSorts; + public Dictionary CharaSorts; + public Dictionary CharaGenreSorts; +} diff --git a/FixLocaleIssues/FixLocaleIssues.csproj b/FixLocaleIssues/FixLocaleIssues.csproj new file mode 100644 index 0000000..bfc949a --- /dev/null +++ b/FixLocaleIssues/FixLocaleIssues.csproj @@ -0,0 +1,73 @@ + + + + + Debug + AnyCPU + {48B5F480-D749-48E9-9D26-E0E5260D95DE} + Library + Properties + FixLocaleIssues + Assembly-CSharp.FixLocaleIssues.mm + v4.6.2 + 512 + latest + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + ..\External\MonoMod.exe + False + + + ..\External\Assembly-CSharp.dll + False + + + ..\External\UnityEngine.dll + False + + + ..\External\UnityEngine.CoreModule.dll + False + + + + + + + + + + + + diff --git a/FixLocaleIssues/MAI2System/patch_IniSection.cs b/FixLocaleIssues/MAI2System/patch_IniSection.cs new file mode 100644 index 0000000..b387af0 --- /dev/null +++ b/FixLocaleIssues/MAI2System/patch_IniSection.cs @@ -0,0 +1,21 @@ +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming + +using System.Globalization; +using MonoMod; + +namespace MAI2System; + +class patch_IniSection : IniSection +{ + [MonoModIgnore] + public patch_IniSection(ref IniSection head, ref IniSection tail, string name, string value) : base(ref head, ref tail, name, value) + { + } + + [MonoModReplace] + public new bool getFloatValue(out float value) + { + return float.TryParse(_variableValue, NumberStyles.Float, CultureInfo.InvariantCulture, out value); + } +} diff --git a/FixLocaleIssues/Manager/patch_MA2Record.cs b/FixLocaleIssues/Manager/patch_MA2Record.cs new file mode 100644 index 0000000..f36f87c --- /dev/null +++ b/FixLocaleIssues/Manager/patch_MA2Record.cs @@ -0,0 +1,36 @@ +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming + +using System.Globalization; +using MonoMod; + +namespace Manager; + +class patch_MA2Record : MA2Record +{ + [MonoModIgnore] + private static extern Ma2fileParamID.Def getParamIDFromRec(Ma2fileRecordID.Def rec, int index); + + [MonoModReplace] + public new float getF32(uint index) + { + if (index >= _str.Count) + { + return 0; + } + + var paramIDFromRec = getParamIDFromRec(_recID, (int)index); + + if (!paramIDFromRec.isValid() || !paramIDFromRec.isAvailableFloat() || _str[(int)index].Length == 0) + { + return 0; + } + + if (!float.TryParse(_str[(int)index], NumberStyles.Float, CultureInfo.InvariantCulture, out var num)) + { + return 0; + } + + return num; + } +} \ No newline at end of file diff --git a/FixLocaleIssues/Manager/patch_SlideManager.cs b/FixLocaleIssues/Manager/patch_SlideManager.cs new file mode 100644 index 0000000..784efca --- /dev/null +++ b/FixLocaleIssues/Manager/patch_SlideManager.cs @@ -0,0 +1,224 @@ +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming + +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text.RegularExpressions; +using System.Xml; +using MonoMod; +using UnityEngine; + +namespace Manager; + +public class patch_SlideManager : SlideManager +{ + [MonoModIgnore] + private struct SlidePath + { + public List Points; + } + + [MonoModIgnore] + private static readonly char[] RemoveChars = ['\r', '\n', '\t']; + + [MonoModReplace] + private bool loadXML(SlidePath path, string dataPath) + { + if (!File.Exists(dataPath)) + { + return false; + } + + var xmlDocument = new XmlDocument { XmlResolver = null }; + + try + { + xmlDocument.Load(dataPath); + + var regex = new Regex(@"([MCLSclsvVhH(points)])((-?\d+(\.\d+)?[,-]?\d+(\.\d+)?),?)+", RegexOptions.Multiline); + var regex2 = new Regex(@"(-?\d+(\.\d+)?),?(-?\d+(\.\d+)?)", RegexOptions.Multiline); + var regex3 = new Regex(@"(-?\d+(\.\d+)?),?(-?\d+(\.\d+)?)", RegexOptions.Multiline); + var controlPoint = new ControlPoint(); + + foreach (var obj in xmlDocument.GetElementsByTagName("line")) + { + var xmlElement = (XmlElement)obj; + var x1 = float.Parse(xmlElement.GetAttribute("x1"), NumberStyles.Float, CultureInfo.InvariantCulture); + var y1 = float.Parse(xmlElement.GetAttribute("y1"), NumberStyles.Float, CultureInfo.InvariantCulture); + var vector = new Vector2(x1, y1); + var controlPoint2 = new ControlPoint + { + Handle1 = new Vector3(vector.x, vector.y, 0), + Handle2 = new Vector3(vector.x, vector.y, 0), + Anchore = new Vector3(vector.x, vector.y, 0) + }; + + path.Points.Add(controlPoint2); + + var x2 = float.Parse(xmlElement.GetAttribute("x2"), NumberStyles.Float, CultureInfo.InvariantCulture); + var y2 = float.Parse(xmlElement.GetAttribute("y2"), NumberStyles.Float, CultureInfo.InvariantCulture); + var vector2 = new Vector2(x2, y2); + var controlPoint3 = new ControlPoint + { + Handle1 = new Vector3(vector2.x, vector2.y, 0), + Handle2 = new Vector3(vector2.x, vector2.y, 0), + Anchore = new Vector3(vector2.x, vector2.y, 0) + }; + + path.Points.Add(controlPoint3); + } + + foreach (var obj in xmlDocument.GetElementsByTagName("polyline")) + { + var attribute = ((XmlElement)obj).GetAttribute("points"); + + foreach (var matchObj in regex3.Matches(attribute)) + { + var match = (Match)matchObj; + var vector = new Vector2( + float.Parse(match.Groups[1].Value, NumberStyles.Float, CultureInfo.InvariantCulture), + float.Parse(match.Groups[3].Value, NumberStyles.Float, CultureInfo.InvariantCulture)); + var controlPoint4 = new ControlPoint + { + Handle1 = new Vector3(vector.x, vector.y, 0), + Handle2 = new Vector3(vector.x, vector.y, 0), + Anchore = new Vector3(vector.x, vector.y, 0) + }; + path.Points.Add(controlPoint4); + } + } + + foreach (var obj in xmlDocument.GetElementsByTagName("path")) + { + var d = ((XmlElement)obj).GetAttribute("d"); + var vectors = new List(); + + foreach (var c in RemoveChars) + { + d = d.Replace(c.ToString(), ""); + } + + foreach (var matchObj in regex.Matches(d)) + { + var match2 = (Match)matchObj; + var controlPoint5 = new ControlPoint(); + + vectors.Clear(); + + foreach (var matchObj2 in regex2.Matches(match2.Value)) + { + var match3 = (Match)matchObj2; + + switch (match2.Groups[1].Value) + { + case "h" or "H": + { + var x = float.Parse(match3.Value, NumberStyles.Float, CultureInfo.InvariantCulture); + vectors.Add(new Vector2(x, 0)); + break; + } + case "V" or "V": + { + var y = float.Parse(match3.Value, NumberStyles.Float, CultureInfo.InvariantCulture); + vectors.Add(new Vector2(0, y)); + break; + } + default: + { + var x = float.Parse(match3.Groups[1].Value, NumberStyles.Float, + CultureInfo.InvariantCulture); + var y = float.Parse(match3.Groups[3].Value, NumberStyles.Float, + CultureInfo.InvariantCulture); + vectors.Add(new Vector2(x, y)); + break; + } + } + } + switch (match2.Groups[1].Value) + { + case "C": + controlPoint5.Handle1 = new Vector3(vectors[0].x, vectors[0].y, 0f); + controlPoint5.Handle2 = new Vector3(vectors[1].x, vectors[1].y, 0f); + controlPoint5.Anchore = new Vector3(vectors[2].x, vectors[2].y, 0f); + break; + case "c": + controlPoint5.Handle1 = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y + vectors[0].y, 0f); + controlPoint5.Handle2 = new Vector3(controlPoint.Anchore.x + vectors[1].x, controlPoint.Anchore.y + vectors[1].y, 0f); + controlPoint5.Anchore = new Vector3(controlPoint.Anchore.x + vectors[2].x, controlPoint.Anchore.y + vectors[2].y, 0f); + break; + case "s" when path.Points.Count > 0: + { + var vector3 = controlPoint.Anchore - (controlPoint.Handle2 - controlPoint.Anchore); + controlPoint5.Handle1 = new Vector3(vector3.x, vector3.y, 0f); + controlPoint5.Handle2 = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y + vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(controlPoint.Anchore.x + vectors[1].x, controlPoint.Anchore.y + vectors[1].y, 0f); + break; + } + case "s": + controlPoint5.Handle1 = new Vector3(controlPoint.Anchore.x + vectors[1].x, controlPoint.Anchore.y + vectors[1].y, 0f); + controlPoint5.Handle2 = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y + vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(controlPoint.Anchore.x + vectors[1].x, controlPoint.Anchore.y + vectors[1].y, 0f); + break; + case "S" when path.Points.Count > 0: + { + var vector4 = controlPoint.Anchore - (controlPoint.Handle2 - controlPoint.Anchore); + controlPoint5.Handle1 = new Vector3(vector4.x, vector4.y, 0f); + controlPoint5.Handle2 = new Vector3(vectors[0].x, vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(vectors[1].x, vectors[1].y, 0f); + break; + } + case "S": + controlPoint5.Handle1 = new Vector3(vectors[1].x, vectors[1].y, 0f); + controlPoint5.Handle2 = new Vector3(vectors[0].x, vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(vectors[1].x, vectors[1].y, 0f); + break; + case "l": + controlPoint5.Handle1 = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y + vectors[0].y, 0f); + controlPoint5.Handle2 = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y + vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y + vectors[0].y, 0f); + break; + case "L": + controlPoint5.Handle1 = new Vector3(vectors[0].x, vectors[0].y, 0f); + controlPoint5.Handle2 = new Vector3(vectors[0].x, vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(vectors[0].x, vectors[0].y, 0f); + break; + case "v": + controlPoint5.Handle1 = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y, 0f); + controlPoint5.Handle2 = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y, 0f); + controlPoint5.Anchore = new Vector3(controlPoint.Anchore.x + vectors[0].x, controlPoint.Anchore.y, 0f); + break; + case "V": + controlPoint5.Handle1 = new Vector3(controlPoint.Anchore.x, vectors[0].y, 0f); + controlPoint5.Handle2 = new Vector3(controlPoint.Anchore.x, vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(controlPoint.Anchore.x, vectors[0].y, 0f); + break; + case "h": + controlPoint5.Handle1 = new Vector3(controlPoint.Anchore.x, controlPoint.Anchore.y + vectors[0].y, 0f); + controlPoint5.Handle2 = new Vector3(controlPoint.Anchore.x, controlPoint.Anchore.y + vectors[0].y, 0f); + controlPoint5.Anchore = new Vector3(controlPoint.Anchore.x, controlPoint.Anchore.y + vectors[0].y, 0f); + break; + case "H": + controlPoint5.Handle1 = new Vector3(vectors[0].x, controlPoint.Anchore.y, 0f); + controlPoint5.Handle2 = new Vector3(vectors[0].x, controlPoint.Anchore.y, 0f); + controlPoint5.Anchore = new Vector3(vectors[0].x, controlPoint.Anchore.y, 0f); + break; + default: + controlPoint5.Anchore = new Vector3(vectors[0].x, vectors[0].y, 0f); + controlPoint5.Handle1 = new Vector3(vectors[0].x, vectors[0].y, 0f); + controlPoint5.Handle2 = new Vector3(vectors[0].x, vectors[0].y, 0f); + break; + } + path.Points.Add(controlPoint5); + controlPoint = controlPoint5; + } + } + } + catch + { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/FixLocaleIssues/Properties/AssemblyInfo.cs b/FixLocaleIssues/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8f4730c --- /dev/null +++ b/FixLocaleIssues/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +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("FixLocaleIssues")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FixLocaleIssues")] +[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("48B5F480-D749-48E9-9D26-E0E5260D95DE")] + +// 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")] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d7b31ac --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +## sinmai-mods + +Miscellaneous mods for maimai DX + +### CachedDataManager +Speeds up game reboots by caching loaded data. Cache is stored in the `dataCache` folder +and should be deleted if any issues arise. + +### FixLocaleIssues +Attempts to fix charts not loading on some system locales. + +Adds `CultureInfo.InvariantCulture` to all instances of `float.Parse` and `float.TryParse` +so charts will still load on locales where the comma is the decimal separator. diff --git a/sinmai-mods.sln b/sinmai-mods.sln new file mode 100644 index 0000000..055194f --- /dev/null +++ b/sinmai-mods.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CachedDataManager", "CachedDataManager\CachedDataManager.csproj", "{F1C1B6BF-626C-4F10-8672-2F9596706CA6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FixLocaleIssues", "FixLocaleIssues\FixLocaleIssues.csproj", "{48B5F480-D749-48E9-9D26-E0E5260D95DE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F1C1B6BF-626C-4F10-8672-2F9596706CA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1C1B6BF-626C-4F10-8672-2F9596706CA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1C1B6BF-626C-4F10-8672-2F9596706CA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1C1B6BF-626C-4F10-8672-2F9596706CA6}.Release|Any CPU.Build.0 = Release|Any CPU + {48B5F480-D749-48E9-9D26-E0E5260D95DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48B5F480-D749-48E9-9D26-E0E5260D95DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48B5F480-D749-48E9-9D26-E0E5260D95DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48B5F480-D749-48E9-9D26-E0E5260D95DE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal