mirror of
https://gitea.tendokyu.moe/beerpsi/sinmai-mods.git
synced 2024-11-23 23:31:02 +01:00
initial commit
This commit is contained in:
commit
cdec49dd87
493
.gitignore
vendored
Normal file
493
.gitignore
vendored
Normal file
@ -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
|
13
.idea/.idea.sinmai-mods/.idea/.gitignore
vendored
Normal file
13
.idea/.idea.sinmai-mods/.idea/.gitignore
vendored
Normal file
@ -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
|
4
.idea/.idea.sinmai-mods/.idea/encodings.xml
Normal file
4
.idea/.idea.sinmai-mods/.idea/encodings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
8
.idea/.idea.sinmai-mods/.idea/indexLayout.xml
Normal file
8
.idea/.idea.sinmai-mods/.idea/indexLayout.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
65
CachedDataManager/CachedDataManager.csproj
Normal file
65
CachedDataManager/CachedDataManager.csproj
Normal file
@ -0,0 +1,65 @@
|
||||
<?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>
|
@ -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;
|
||||
}
|
||||
}
|
205
CachedDataManager/Manager/patch_DataManager.cs
Normal file
205
CachedDataManager/Manager/patch_DataManager.cs
Normal file
@ -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<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;
|
||||
}
|
||||
|
||||
|
35
CachedDataManager/Properties/AssemblyInfo.cs
Normal file
35
CachedDataManager/Properties/AssemblyInfo.cs
Normal file
@ -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")]
|
67
CachedDataManager/SerializationCache.cs
Normal file
67
CachedDataManager/SerializationCache.cs
Normal file
@ -0,0 +1,67 @@
|
||||
// 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;
|
||||
}
|
73
FixLocaleIssues/FixLocaleIssues.csproj
Normal file
73
FixLocaleIssues/FixLocaleIssues.csproj
Normal file
@ -0,0 +1,73 @@
|
||||
<?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>{48B5F480-D749-48E9-9D26-E0E5260D95DE}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>FixLocaleIssues</RootNamespace>
|
||||
<AssemblyName>Assembly-CSharp.FixLocaleIssues.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>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\External\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\External\UnityEngine.CoreModule.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MAI2System\patch_IniSection.cs" />
|
||||
<Compile Include="Manager\patch_MA2Record.cs" />
|
||||
<Compile Include="Manager\patch_SlideManager.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>
|
21
FixLocaleIssues/MAI2System/patch_IniSection.cs
Normal file
21
FixLocaleIssues/MAI2System/patch_IniSection.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
36
FixLocaleIssues/Manager/patch_MA2Record.cs
Normal file
36
FixLocaleIssues/Manager/patch_MA2Record.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
224
FixLocaleIssues/Manager/patch_SlideManager.cs
Normal file
224
FixLocaleIssues/Manager/patch_SlideManager.cs
Normal file
@ -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<ControlPoint> 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<Vector2>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
35
FixLocaleIssues/Properties/AssemblyInfo.cs
Normal file
35
FixLocaleIssues/Properties/AssemblyInfo.cs
Normal file
@ -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")]
|
13
README.md
Normal file
13
README.md
Normal file
@ -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.
|
22
sinmai-mods.sln
Normal file
22
sinmai-mods.sln
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user