Refactor and support BepInEx's native plugin format

This commit is contained in:
beerpsi 2024-05-23 16:13:19 +07:00
parent 6056dbcb31
commit fefc398f07
38 changed files with 497 additions and 126 deletions

View File

@ -0,0 +1,38 @@
using System.Reflection;
using Game;
using HarmonyLib;
using Manager;
using Rizu.Core;
namespace Rizu.BepInEx;
[HarmonyPatch(typeof(GameScoreList))]
public class PatchGameScoreList
{
// New field introduced in SDEZ 1.40 (maimai DX BUDDiES)
private static readonly FieldInfo UtageKanjiTextField = typeof(SessionInfo)
.GetField("utageKanjiText", BindingFlags.Instance | BindingFlags.Public);
// ReSharper disable once InconsistentNaming
[HarmonyPatch(nameof(GameScoreList.SetPlayAfterRate))]
[HarmonyPostfix]
private static void SetPlayAfterRatePostfix(GameScoreList __instance, int musicRate, int danRate, UdemaeID dan, int classValue)
{
if (!__instance.IsEnable)
{
return;
}
if (__instance.SessionInfo.isAdvDemo || __instance.SessionInfo.isTutorial)
{
return;
}
if (UtageKanjiTextField != null && !string.IsNullOrEmpty((string)UtageKanjiTextField.GetValue(__instance.SessionInfo)))
{
return;
}
RizuPlugin.Instance.StartCoroutine(Exporter.Instance.ExportScore(__instance));
}
}

View File

@ -0,0 +1,27 @@
using HarmonyLib;
using Manager.UserDatas;
using Rizu.Core;
namespace Rizu.BepInEx;
[HarmonyPatch(typeof(UserDetail))]
public class PatchUserDetail
{
// ReSharper disable once InconsistentNaming
[HarmonyPatch(nameof(UserDetail.CourseRank), MethodType.Setter)]
[HarmonyPrefix]
private static bool CourseRankPrefix(UserDetail __instance, ref uint value)
{
var previousValue = __instance.CourseRank;
// Don't send an import if it's the same rank
if (value == previousValue || value == 0)
{
return true;
}
RizuPlugin.Instance.StartCoroutine(Exporter.Instance.ExportDan(__instance));
return true;
}
}

View File

@ -4,12 +4,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Rizu")] [assembly: AssemblyTitle("Rizu.BepInEx")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("Tachi score hook for maimai DX")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rizu")] [assembly: AssemblyProduct("Rizu")]
[assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyCopyright("Copyright © beerpsi 2024")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("0.1.1.0")]

View File

@ -0,0 +1,86 @@
<?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>{4DDF918E-7A74-4266-B56A-028D66ED336F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rizu.BepInEx</RootNamespace>
<AssemblyName>Rizu</AssemblyName>
<Product>Rizu</Product>
<Version>0.1.1</Version>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json;
https://nuget.bepinex.dev/v3/index.json
</RestoreAdditionalProjectSources>
</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"/>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.BaseLib" Version="5.*" GeneratePathProperty="true" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
<PackageReference Include="HarmonyX" Version="2.12.0" GeneratePathProperty="true" />
<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="PatchGameScoreList.cs" />
<Compile Include="PatchUserDetail.cs" />
<Compile Include="RizuPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rizu.Core\Rizu.Core.csproj">
<Project>{4241a369-1619-4450-8182-cb66f447985f}</Project>
<Name>Rizu.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,34 @@
using BepInEx;
using HarmonyLib;
using Rizu.Core;
namespace Rizu.BepInEx;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInProcess("Sinmai.exe")]
public class RizuPlugin : BaseUnityPlugin
{
public static RizuPlugin Instance { get; private set; }
private Harmony _harmony;
private void Awake()
{
Instance = this;
Exporter.Instance.LoadConfig();
if (!Exporter.Instance.IsEnabled)
{
return;
}
_harmony = new Harmony(MyPluginInfo.PLUGIN_GUID);
_harmony.PatchAll();
}
private void OnDestroy()
{
_harmony?.UnpatchSelf();
}
}

13
Rizu.Core/Config.cs Normal file
View File

@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace Rizu.Core;
public class Config
{
public bool Enabled;
public int NetworkTimeout;
public string FailedImportsFolder;
public string TachiBaseUrl;
public string TachiImportEndpoint;
public Dictionary<string, string> AccessTokens = new();
}

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -8,19 +7,20 @@ using MAI2.Util;
using MAI2System; using MAI2System;
using Manager; using Manager;
using Manager.UserDatas; using Manager.UserDatas;
using Rizu.Models; using Rizu.Core.Models;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
using Path = System.IO.Path; using Path = System.IO.Path;
namespace Rizu; namespace Rizu.Core;
public class Exporter : SingletonMonoBehaviour<Exporter> public class Exporter
{ {
protected Exporter() public static readonly Exporter Instance = new();
{
_dontDestroyOnLoad = true; private readonly Config _config = new();
}
public bool IsEnabled => _config.Enabled;
// ReSharper disable Unity.PerformanceAnalysis // ReSharper disable Unity.PerformanceAnalysis
public IEnumerator ExportScore(GameScoreList score) public IEnumerator ExportScore(GameScoreList score)
@ -199,7 +199,7 @@ public class Exporter : SingletonMonoBehaviour<Exporter>
} }
} }
private void SaveFailedImport(string path, string import) private static void SaveFailedImport(string path, string import)
{ {
var parent = Path.GetDirectoryName(path); var parent = Path.GetDirectoryName(path);
@ -210,7 +210,7 @@ public class Exporter : SingletonMonoBehaviour<Exporter>
File.WriteAllText(path, import); File.WriteAllText(path, import);
} }
public void LoadConfig() public void LoadConfig()
{ {
using var ini = new IniFile(".\\Rizu.cfg"); using var ini = new IniFile(".\\Rizu.cfg");
@ -239,16 +239,4 @@ public class Exporter : SingletonMonoBehaviour<Exporter>
Logger.Info("> Tachi import URL: {0}{1}", _config.TachiBaseUrl, _config.TachiImportEndpoint); Logger.Info("> Tachi import URL: {0}{1}", _config.TachiBaseUrl, _config.TachiImportEndpoint);
Logger.Info("> {0} API key{1} loaded", _config.AccessTokens.Count, _config.AccessTokens.Count != 1 ? "s" : ""); Logger.Info("> {0} API key{1} loaded", _config.AccessTokens.Count, _config.AccessTokens.Count != 1 ? "s" : "");
} }
private readonly Config _config = new();
private class Config
{
public bool Enabled;
public int NetworkTimeout;
public string FailedImportsFolder;
public string TachiBaseUrl;
public string TachiImportEndpoint;
public Dictionary<string, string> AccessTokens = new();
}
} }

View File

@ -1,6 +1,6 @@
using UnityEngine.Networking; using UnityEngine.Networking;
namespace Rizu; namespace Rizu.Core;
public class ForceAcceptAllCertificateHandler : CertificateHandler public class ForceAcceptAllCertificateHandler : CertificateHandler
{ {

View File

@ -1,7 +1,7 @@
using System.Diagnostics; using System.Diagnostics;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Rizu; namespace Rizu.Core;
// UnityEngine.Debug logs don't show up in BepInEx logs for some reason // UnityEngine.Debug logs don't show up in BepInEx logs for some reason
public static class Logger public static class Logger
@ -54,5 +54,4 @@ public static class Logger
{ {
System.Console.WriteLine($"{LogPrefix} [{level}] {format}", args); System.Console.WriteLine($"{LogPrefix} [{level}] {format}", args);
} }
}
}

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManual public class BatchManual

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualDan public class BatchManualDan

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualMatchingClass public class BatchManualMatchingClass

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualMeta public class BatchManualMeta

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualOptional public class BatchManualOptional

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualRankUp public class BatchManualRankUp

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualResponseBody public class BatchManualResponseBody

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualScore public class BatchManualScore

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class BatchManualScoreJudgements public class BatchManualScoreJudgements

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class ImportDocument public class ImportDocument

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class ImportErrContent public class ImportErrContent

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class ImportProgress public class ImportProgress

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class ImportStatusResponseBody public class ImportStatusResponseBody

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class SessionInfoReturn public class SessionInfoReturn

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Rizu.Models; namespace Rizu.Core.Models;
[Serializable] [Serializable]
public class TachiResponse<T> public class TachiResponse<T>

View 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("Rizu.Core")]
[assembly: AssemblyDescription("Tachi score hook for maimai DX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rizu.Core")]
[assembly: AssemblyCopyright("Copyright © beerpsi 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("4241A369-1619-4450-8182-CB66F447985F")]
// 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("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]

View File

@ -5,20 +5,15 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{888E076C-8A77-453F-87DC-BC0186FDBB55}</ProjectGuid> <ProjectGuid>{4241A369-1619-4450-8182-CB66F447985F}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rizu</RootNamespace> <RootNamespace>Rizu.Core</RootNamespace>
<AssemblyName>Assembly-CSharp.Rizu.mm</AssemblyName> <AssemblyName>Rizu.Core</AssemblyName>
<TargetFramework>net46</TargetFramework> <Version>0.1.1</Version>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json;
https://nuget.bepinex.dev/v3/index.json;
https://nuget.samboy.dev/v3/index.json
</RestoreAdditionalProjectSources>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -40,38 +35,30 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System"/> <Reference Include="System"/>
<Reference Include="System.Core"/> <Reference Include="System.Core"/>
<Reference Include="System.Data"/> <Reference Include="System.Data"/>
<Reference Include="System.Xml"/> <Reference Include="System.Xml"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>External\Assembly-CSharp.dll</HintPath> <HintPath>..\External\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod">
<HintPath>External\MonoMod.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>External\UnityEngine.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.CoreModule"> <Reference Include="UnityEngine.CoreModule">
<HintPath>External\UnityEngine.CoreModule.dll</HintPath> <HintPath>..\External\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.JSONSerializeModule"> <Reference Include="UnityEngine.JSONSerializeModule">
<HintPath>External\UnityEngine.JSONSerializeModule.dll</HintPath> <HintPath>..\External\UnityEngine.JSONSerializeModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.UnityWebRequestModule"> <Reference Include="UnityEngine.UnityWebRequestModule">
<HintPath>External\UnityEngine.UnityWebRequestModule.dll</HintPath> <HintPath>..\External\UnityEngine.UnityWebRequestModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Exporter.cs" />
<Compile Include="ForceAcceptAllCertificateHandler.cs" /> <Compile Include="ForceAcceptAllCertificateHandler.cs" />
<Compile Include="Logger.cs" /> <Compile Include="Logger.cs" />
<Compile Include="Models\BatchManual.cs" /> <Compile Include="Models\BatchManual.cs" />
@ -89,16 +76,9 @@
<Compile Include="Models\ImportStatusResponseBody.cs" /> <Compile Include="Models\ImportStatusResponseBody.cs" />
<Compile Include="Models\SessionInfoReturn.cs" /> <Compile Include="Models\SessionInfoReturn.cs" />
<Compile Include="Models\TachiResponse.cs" /> <Compile Include="Models\TachiResponse.cs" />
<Compile Include="patch_GameScoreList.cs" />
<Compile Include="patch_AmManager.cs" />
<Compile Include="patch_UserDetail.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/> <Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="Exporter.cs" />
<Compile Include="ScoreConversion.cs" /> <Compile Include="ScoreConversion.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Resources\Rizu.cfg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -2,10 +2,10 @@
using DB; using DB;
using MAI2.Util; using MAI2.Util;
using Manager; using Manager;
using Rizu.Models; using Rizu.Core.Models;
using UnityEngine; using UnityEngine;
namespace Rizu; namespace Rizu.Core;
public static class ScoreConversion public static class ScoreConversion
{ {

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- ILRepack -->
<Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\Rizu.MonoMod.dll" />
<InputAssemblies Include="$(OutputPath)\Rizu.Core.dll" />
</ItemGroup>
<ItemGroup>
<LibraryPaths Include="..\External" />
</ItemGroup>
<ILRepack
LogFile="ILRepack.log"
Parallel="true"
InputAssemblies="@(InputAssemblies)"
LibraryPath="@(LibraryPaths)"
TargetKind="Dll"
OutputFile="$(OutputPath)\Assembly-CSharp.Rizu.mm.dll" />
</Target>
<!-- /ILRepack -->
</Project>

View 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("Rizu.MonoMod")]
[assembly: AssemblyDescription("Tachi score hook for maimai DX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rizu")]
[assembly: AssemblyCopyright("Copyright © beerpsi 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("888E076C-8A77-453F-87DC-BC0186FDBB55")]
// 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("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]

View File

@ -0,0 +1,89 @@
<?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>{888E076C-8A77-453F-87DC-BC0186FDBB55}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rizu.MonoMod</RootNamespace>
<AssemblyName>Rizu.MonoMod</AssemblyName>
<Version>0.1.1</Version>
<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"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.32" PrivateAssets="all" />
<Reference Include="Assembly-CSharp">
<HintPath>..\External\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod">
<HintPath>..\External\MonoMod.exe</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="patch_GameScoreList.cs" />
<Compile Include="patch_AmManager.cs" />
<Compile Include="patch_UserDetail.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="RizuMonoBehaviour.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ILRepack.targets" />
<Content Include="Resources\Rizu.cfg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rizu.Core\Rizu.Core.csproj">
<Project>{4241a369-1619-4450-8182-cb66f447985f}</Project>
<Name>Rizu.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,5 @@
using MAI2.Util;
namespace Rizu.MonoMod;
public class RizuMonoBehaviour : SingletonMonoBehaviour<RizuMonoBehaviour>;

View File

@ -1,7 +1,7 @@
// ReSharper disable CheckNamespace // ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
using MAI2.Util; using Rizu.Core;
using UnityEngine; using UnityEngine;
namespace Manager; namespace Manager;
@ -13,8 +13,9 @@ public class patch_AmManager : AmManager
private void Execute_WaitAmDaemonReady() private void Execute_WaitAmDaemonReady()
{ {
var go = new GameObject { name = "Rizu" }; var go = new GameObject { name = "Rizu" };
go.AddComponent<Rizu.Exporter>(); go.AddComponent<Rizu.MonoMod.RizuMonoBehaviour>();
SingletonMonoBehaviour<Rizu.Exporter>.instance.LoadConfig();
Exporter.Instance.LoadConfig();
orig_Execute_WaitAmDaemonReady(); orig_Execute_WaitAmDaemonReady();
} }

View File

@ -0,0 +1,41 @@
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using System.Reflection;
using Game;
using MAI2.Util;
using Rizu.Core;
using Rizu.MonoMod;
namespace Manager;
public class patch_GameScoreList(int index) : GameScoreList(index)
{
// New field introduced in SDEZ 1.40 (maimai DX BUDDiES)
private static readonly FieldInfo utageKanjiTextField = typeof(SessionInfo)
.GetField("utageKanjiText", BindingFlags.Instance | BindingFlags.Public);
private extern void orig_SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue);
public new void SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue)
{
orig_SetPlayAfterRate(musicRate, danRate, dan, classValue);
if (!IsEnable)
{
return;
}
if (SessionInfo.isAdvDemo || SessionInfo.isTutorial)
{
return;
}
if (utageKanjiTextField != null && !string.IsNullOrEmpty((string)utageKanjiTextField.GetValue(SessionInfo)))
{
return;
}
SingletonMonoBehaviour<RizuMonoBehaviour>.instance.StartCoroutine(Exporter.Instance.ExportScore(this));
}
}

View File

@ -2,6 +2,8 @@
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
using MAI2.Util; using MAI2.Util;
using Rizu.Core;
using Rizu.MonoMod;
namespace Manager.UserDatas; namespace Manager.UserDatas;
@ -11,23 +13,16 @@ public class patch_UserDetail : UserDetail
public void set_CourseRank(uint value) public void set_CourseRank(uint value)
{ {
// Don't send an import if it's the same rank var prevValue = CourseRank;
if (value == CourseRank)
{
orig_set_CourseRank(value);
return;
}
orig_set_CourseRank(value); orig_set_CourseRank(value);
// Don't send an import if it's rank 0 (invalid) // Don't send an import if it's the same rank
if (value == 0) if (value == prevValue || value == 0)
{ {
return; return;
} }
var exporter = SingletonMonoBehaviour<Rizu.Exporter>.instance; SingletonMonoBehaviour<RizuMonoBehaviour>.instance.StartCoroutine(Exporter.Instance.ExportDan(this));
exporter.StartCoroutine(exporter.ExportDan(this));
} }
} }

View File

@ -1,6 +1,10 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu", "Rizu\Rizu.csproj", "{888E076C-8A77-453F-87DC-BC0186FDBB55}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu.Core", "Rizu.Core\Rizu.Core.csproj", "{4241A369-1619-4450-8182-CB66F447985F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu.MonoMod", "Rizu.MonoMod\Rizu.MonoMod.csproj", "{888E076C-8A77-453F-87DC-BC0186FDBB55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu.BepInEx", "Rizu.BepInEx\Rizu.BepInEx.csproj", "{4DDF918E-7A74-4266-B56A-028D66ED336F}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -8,9 +12,17 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4241A369-1619-4450-8182-CB66F447985F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4241A369-1619-4450-8182-CB66F447985F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4241A369-1619-4450-8182-CB66F447985F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4241A369-1619-4450-8182-CB66F447985F}.Release|Any CPU.Build.0 = Release|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {888E076C-8A77-453F-87DC-BC0186FDBB55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Debug|Any CPU.Build.0 = Debug|Any CPU {888E076C-8A77-453F-87DC-BC0186FDBB55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Release|Any CPU.ActiveCfg = Release|Any CPU {888E076C-8A77-453F-87DC-BC0186FDBB55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Release|Any CPU.Build.0 = Release|Any CPU {888E076C-8A77-453F-87DC-BC0186FDBB55}.Release|Any CPU.Build.0 = Release|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

View File

@ -1,30 +0,0 @@
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using MAI2.Util;
namespace Manager;
public class patch_GameScoreList(int index) : GameScoreList(index)
{
private extern void orig_SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue);
public new void SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue)
{
orig_SetPlayAfterRate(musicRate, danRate, dan, classValue);
if (!IsEnable)
{
return;
}
if (SessionInfo.isAdvDemo || SessionInfo.isTutorial || !string.IsNullOrEmpty(SessionInfo.utageKanjiText))
{
return;
}
var exporter = SingletonMonoBehaviour<Rizu.Exporter>.instance;
exporter.StartCoroutine(exporter.ExportScore(this));
}
}