diff --git a/AquaMai/Helpers/SharedInstances.cs b/AquaMai/Helpers/SharedInstances.cs
index c37ea446..11017573 100644
--- a/AquaMai/Helpers/SharedInstances.cs
+++ b/AquaMai/Helpers/SharedInstances.cs
@@ -1,4 +1,5 @@
using HarmonyLib;
+using Main;
using Process;
namespace AquaMai.Helpers;
@@ -6,6 +7,7 @@ namespace AquaMai.Helpers;
public class SharedInstances
{
public static ProcessDataContainer ProcessDataContainer { get; private set; }
+ public static GameMainObject GameMainObject { get; private set; }
[HarmonyPrefix]
[HarmonyPatch(typeof(ProcessDataContainer), MethodType.Constructor)]
@@ -13,4 +15,11 @@ public class SharedInstances
{
ProcessDataContainer = __instance;
}
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(GameMainObject), "Awake")]
+ public static void OnCreateGameMainObject(GameMainObject __instance)
+ {
+ GameMainObject = __instance;
+ }
}
diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs
index af155b39..bb24ed04 100644
--- a/AquaMai/Main.cs
+++ b/AquaMai/Main.cs
@@ -175,19 +175,11 @@ namespace AquaMai
if (_hasErrors)
{
MelonLogger.Warning("========================================================================!!!");
- MelonLogger.Warning("加载过程中检测到错误!");
- MelonLogger.Warning("- 请检查你是否安装了错误的 AquaMai 版本,比如在 SDGA 上使用了 SDEZ 的版本");
- MelonLogger.Warning("- 你是否正在使用魔改的 Assembly-CSharp.dll,这会导致函数不一致而无法找到需要修改的函数");
- MelonLogger.Warning("- 请检查是否有冲突的 Mod,或者开启了不兼容的选项");
- MelonLogger.Warning("===========================================================================");
- MelonLogger.Warning("Errors detected while loading!");
- MelonLogger.Warning("- Check if you have installed the wrong version of AquaMai, such as using SDEZ version on SDGA");
- MelonLogger.Warning("- Are you using a modified Assembly-CSharp.dll, which will cause inconsistent functions and cannot find the functions that need to be modified");
- MelonLogger.Warning("- Check for conflicting mods, or enabled incompatible options");
+ MelonLogger.Warning(Locale.LoadError);
MelonLogger.Warning("===========================================================================");
}
- MelonLogger.Msg("Loaded!");
+ MelonLogger.Msg(Locale.Loaded);
}
}
}
diff --git a/AquaMai/Resources/Locale.Designer.cs b/AquaMai/Resources/Locale.Designer.cs
index 0934b60f..bf09b17c 100644
--- a/AquaMai/Resources/Locale.Designer.cs
+++ b/AquaMai/Resources/Locale.Designer.cs
@@ -7,12 +7,10 @@
//
//------------------------------------------------------------------------------
-using MelonLoader;
-
namespace AquaMai.Resources {
using System;
-
-
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -24,15 +22,15 @@ namespace AquaMai.Resources {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Locale {
-
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Locale() {
}
-
+
///
/// Returns the cached ResourceManager instance used by this class.
///
@@ -46,7 +44,7 @@ namespace AquaMai.Resources {
return resourceMan;
}
}
-
+
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
@@ -60,7 +58,28 @@ namespace AquaMai.Resources {
resourceCulture = value;
}
}
-
+
+ ///
+ /// Looks up a localized string similar to Loaded!.
+ ///
+ internal static string Loaded {
+ get {
+ return ResourceManager.GetString("Loaded", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Errors detected while loading!
+ ///- Check if you have installed the wrong version of AquaMai, such as using SDEZ version on SDGA
+ ///- Are you using a modified Assembly-CSharp.dll, which will cause inconsistent functions and cannot find the functions that need to be modified
+ ///- Check for conflicting mods, or enabled incompatible options.
+ ///
+ internal static string LoadError {
+ get {
+ return ResourceManager.GetString("LoadError", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to End.
///
@@ -69,7 +88,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("MarkRepeatEnd", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Start.
///
@@ -78,7 +97,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("MarkRepeatStart", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Pause.
///
@@ -87,7 +106,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("Pause", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Loop Not Set.
///
@@ -96,7 +115,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("RepeatNotSet", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Reset.
///
@@ -105,7 +124,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("RepeatReset", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Loop Set.
///
@@ -114,7 +133,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("RepeatStartEndSet", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Loop Start Set.
///
@@ -123,7 +142,16 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("RepeatStartSet", resourceCulture);
}
}
-
+
+ ///
+ /// Looks up a localized string similar to Saving... Do not exit the game.
+ ///
+ internal static string SavingDontExit {
+ get {
+ return ResourceManager.GetString("SavingDontExit", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Seek <<.
///
@@ -132,7 +160,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("SeekBackward", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Seek >>.
///
@@ -141,7 +169,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("SeekForward", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Speed.
///
@@ -150,7 +178,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("Speed", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Speed -.
///
@@ -159,7 +187,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("SpeedDown", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Speed Reset.
///
@@ -168,7 +196,7 @@ namespace AquaMai.Resources {
return ResourceManager.GetString("SpeedReset", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Speed +.
///
diff --git a/AquaMai/Resources/Locale.resx b/AquaMai/Resources/Locale.resx
index cfc74e0f..bbab57db 100644
--- a/AquaMai/Resources/Locale.resx
+++ b/AquaMai/Resources/Locale.resx
@@ -57,4 +57,16 @@
Speed Reset
+
+ Errors detected while loading!
+- Check if you have installed the wrong version of AquaMai, such as using SDEZ version on SDGA
+- Are you using a modified Assembly-CSharp.dll, which will cause inconsistent functions and cannot find the functions that need to be modified
+- Check for conflicting mods, or enabled incompatible options
+
+
+ Saving... Do not exit the game
+
+
+ Loaded!
+
diff --git a/AquaMai/Resources/Locale.zh.resx b/AquaMai/Resources/Locale.zh.resx
index 7b17c872..f637f92b 100644
--- a/AquaMai/Resources/Locale.zh.resx
+++ b/AquaMai/Resources/Locale.zh.resx
@@ -50,4 +50,16 @@
速度 +
+
+ 加载过程中检测到错误!
+- 请检查你是否安装了错误的 AquaMai 版本,比如在 SDGA 上使用了 SDEZ 的版本
+- 你是否正在使用魔改的 Assembly-CSharp.dll,这会导致函数不一致而无法找到需要修改的函数
+- 请检查是否有冲突的 Mod,或者开启了不兼容的选项
+
+
+ 正在保存… 请不要关闭游戏
+
+
+ 加载完成!
+
diff --git a/AquaMai/UX/ImmediateSave.cs b/AquaMai/UX/ImmediateSave.cs
index 40bf3f5c..7a73857d 100644
--- a/AquaMai/UX/ImmediateSave.cs
+++ b/AquaMai/UX/ImmediateSave.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using AquaMai.Helpers;
+using AquaMai.Resources;
using DB;
using HarmonyLib;
using MAI2.Util;
@@ -15,181 +17,238 @@ using Net.Packet.Helper;
using Net.Packet.Mai2;
using Process;
using Process.UserDataNet.State.UserDataULState;
+using UnityEngine;
-namespace AquaMai.UX
+namespace AquaMai.UX;
+
+public class ImmediateSave
{
- public class ImmediateSave
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(StateULUserAime), "RequestUploadUserPlayLogData")]
+ public static bool PreRequestUploadUserPlayLogData(StateULUserAime __instance)
{
- [HarmonyPrefix]
- [HarmonyPatch(typeof(StateULUserAime), "RequestUploadUserPlayLogData")]
- public static bool PreRequestUploadUserPlayLogData(StateULUserAime __instance)
+ Traverse.Create(__instance).Method("RequestUploadUserPortraitData").GetValue();
+ return false;
+ }
+
+ private static SavingUi ui;
+
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(ResultProcess), "OnStart")]
+ public static void ResultProcessOnStart()
+ {
+ var doneCount = 0;
+
+ void CheckSaveDone()
{
- Traverse.Create(__instance).Method("RequestUploadUserPortraitData").GetValue();
- return false;
+ doneCount++;
+ if (doneCount == 4)
+ {
+ if (ui != null)
+ {
+ UnityEngine.Object.Destroy(ui);
+ }
+ }
}
- [HarmonyPostfix]
- [HarmonyPatch(typeof(ResultProcess), "OnStart")]
- public static void ResultProcessOnStart()
+ for (int i = 0; i < 2; i++)
{
- for (int i = 0; i < 2; i++)
+ var userData = Singleton.Instance.GetUserData(i);
+ if (!userData.IsEntry || userData.IsGuest())
{
- var userData = Singleton.Instance.GetUserData(i);
- if(!userData.IsEntry) continue;
- if(userData.IsGuest()) continue;
+ doneCount += 2;
+ continue;
+ }
- SaveDataFix(userData);
+ if (ui == null)
+ {
+ ui = SharedInstances.GameMainObject.gameObject.AddComponent();
+ }
+
+ SaveDataFix(userData);
# if SDGA145
- PacketHelper.StartPacket(new PacketUploadUserPlaylog(i, userData, (int)GameManager.MusicTrackNumber - 1,
+ PacketHelper.StartPacket(new PacketUploadUserPlaylog(i, userData, (int)GameManager.MusicTrackNumber - 1,
# else
- var accessToken = Singleton.Instance.GetAccessToken(i);
- PacketHelper.StartPacket(new PacketUploadUserPlaylog(i, userData, (int)GameManager.MusicTrackNumber - 1, accessToken,
-# endif
- delegate { MelonLogger.Msg("Playlog saved"); },
- delegate(PacketStatus err)
- {
- SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_ENTRY_AIME_ERROR, i);
- MelonLogger.Error("Playlog save error");
- MelonLogger.Error(err);
- }));
-# if SDGA145
- PacketHelper.StartPacket(new PacketUpsertUserAll(i, userData, delegate(int code)
-# else
- PacketHelper.StartPacket(new PacketUpsertUserAll(i, userData, accessToken, delegate(int code)
+ var accessToken = Singleton.Instance.GetAccessToken(i);
+ PacketHelper.StartPacket(new PacketUploadUserPlaylog(i, userData, (int)GameManager.MusicTrackNumber - 1, accessToken,
# endif
+ delegate
{
- if (code == 1)
- {
- MelonLogger.Msg("UserAll saved");
- }
- else
- {
- SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_ENTRY_AIME_ERROR, i);
- MelonLogger.Error("UserAll upsert error");
- MelonLogger.Error(code);
- }
- }, delegate(PacketStatus err)
+ MelonLogger.Msg("Playlog saved");
+ CheckSaveDone();
+ },
+ delegate(PacketStatus err)
+ {
+ SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_ENTRY_AIME_ERROR, i);
+ MelonLogger.Error("Playlog save error");
+ MelonLogger.Error(err);
+ MessageHelper.ShowMessage("Playlog save error");
+ CheckSaveDone();
+ }));
+# if SDGA145
+ PacketHelper.StartPacket(new PacketUpsertUserAll(i, userData, delegate(int code)
+# else
+ PacketHelper.StartPacket(new PacketUpsertUserAll(i, userData, accessToken, delegate(int code)
+# endif
+ {
+ if (code == 1)
+ {
+ MelonLogger.Msg("UserAll saved");
+ CheckSaveDone();
+ }
+ else
{
SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_ENTRY_AIME_ERROR, i);
MelonLogger.Error("UserAll upsert error");
- MelonLogger.Error(err);
- }));
+ MelonLogger.Error(code);
+ MessageHelper.ShowMessage("UserAll upsert error");
+ CheckSaveDone();
+ }
+ }, delegate(PacketStatus err)
+ {
+ SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_ENTRY_AIME_ERROR, i);
+ MelonLogger.Error("UserAll upsert error");
+ MelonLogger.Error(err);
+ MessageHelper.ShowMessage("UserAll upsert error");
+ CheckSaveDone();
+ }));
+ }
+ }
+
+
+ private static void SaveDataFix(UserData userData)
+ {
+ UserDetail detail = userData.Detail;
+ _ = userData.ScoreList;
+ detail.EventWatchedDate = TimeManager.GetDateString(TimeManager.PlayBaseTime);
+ userData.CalcTotalValue();
+ float num = 0f;
+ try
+ {
+ if (userData.RatingList.RatingList.Any())
+ {
+ num = userData.RatingList.RatingList.Last().SingleRate;
}
}
-
-
- private static void SaveDataFix(UserData userData)
+ catch
{
- UserDetail detail = userData.Detail;
- _ = userData.ScoreList;
- detail.EventWatchedDate = TimeManager.GetDateString(TimeManager.PlayBaseTime);
- userData.CalcTotalValue();
- float num = 0f;
- try
+ }
+
+ num = (float)Math.Ceiling((double)((num + 1f) / GameManager.TheoryRateBorderNum) * 10.0);
+ float num2 = 0f;
+ try
+ {
+ if (userData.RatingList.NextRatingList.Any())
{
- if (userData.RatingList.RatingList.Any())
- {
- num = userData.RatingList.RatingList.Last().SingleRate;
- }
+ num2 = userData.RatingList.NewRatingList.Last().SingleRate;
}
- catch
+ }
+ catch
+ {
+ }
+
+ num2 = (float)Math.Ceiling((double)((num2 + 1f) / GameManager.TheoryRateBorderNum) * 10.0);
+ string logDateString = TimeManager.GetLogDateString(TimeManager.PlayBaseTime);
+ string timeJp = (string.IsNullOrEmpty(userData.Detail.DailyBonusDate) ? TimeManager.GetLogDateString(0L) : userData.Detail.DailyBonusDate);
+ if (userData.IsEntry && userData.Detail.IsNetMember >= 2 && !GameManager.IsEventMode && TimeManager.GetUnixTime(logDateString) > TimeManager.GetUnixTime(timeJp) && Singleton.Instance.IsSingleUser() && !GameManager.IsFreedomMode && !GameManager.IsCourseMode && !DoneEntry.IsWeekdayBonus(userData))
+ {
+ userData.Detail.DailyBonusDate = logDateString;
+ }
+
+ List list = new List();
+ List list2 = new List();
+ List[] scoreList = userData.ScoreList;
+ List ratingList = userData.RatingList.RatingList;
+ List newRatingList = userData.RatingList.NewRatingList;
+ int achive = RatingTableID.Rate_22.GetAchive();
+ for (int j = 0; j < scoreList.Length; j++)
+ {
+ if (scoreList[j] == null)
{
+ continue;
}
- num = (float)Math.Ceiling((double)((num + 1f) / GameManager.TheoryRateBorderNum) * 10.0);
- float num2 = 0f;
- try
+ foreach (UserScore item2 in scoreList[j])
{
- if (userData.RatingList.NextRatingList.Any())
- {
- num2 = userData.RatingList.NewRatingList.Last().SingleRate;
- }
- }
- catch
- {
- }
-
- num2 = (float)Math.Ceiling((double)((num2 + 1f) / GameManager.TheoryRateBorderNum) * 10.0);
- string logDateString = TimeManager.GetLogDateString(TimeManager.PlayBaseTime);
- string timeJp = (string.IsNullOrEmpty(userData.Detail.DailyBonusDate) ? TimeManager.GetLogDateString(0L) : userData.Detail.DailyBonusDate);
- if (userData.IsEntry && userData.Detail.IsNetMember >= 2 && !GameManager.IsEventMode && TimeManager.GetUnixTime(logDateString) > TimeManager.GetUnixTime(timeJp) && Singleton.Instance.IsSingleUser() && !GameManager.IsFreedomMode && !GameManager.IsCourseMode && !DoneEntry.IsWeekdayBonus(userData))
- {
- userData.Detail.DailyBonusDate = logDateString;
- }
-
- List list = new List();
- List list2 = new List();
- List[] scoreList = userData.ScoreList;
- List ratingList = userData.RatingList.RatingList;
- List newRatingList = userData.RatingList.NewRatingList;
- int achive = RatingTableID.Rate_22.GetAchive();
- for (int j = 0; j < scoreList.Length; j++)
- {
- if (scoreList[j] == null)
+ if (achive <= item2.achivement)
{
continue;
}
- foreach (UserScore item2 in scoreList[j])
+ MusicData music = Singleton.Instance.GetMusic(item2.id);
+ if (music == null)
{
- if (achive <= item2.achivement)
- {
- continue;
- }
+ continue;
+ }
- MusicData music = Singleton.Instance.GetMusic(item2.id);
- if (music == null)
+ UserRate item = new UserRate(item2.id, j, item2.achivement, (uint)music.version);
+ if (item.OldFlag)
+ {
+ if (num <= (float)item.Level && !ratingList.Contains(item))
{
- continue;
- }
-
- UserRate item = new UserRate(item2.id, j, item2.achivement, (uint)music.version);
- if (item.OldFlag)
- {
- if (num <= (float)item.Level && !ratingList.Contains(item))
- {
- list.Add(item);
- }
- }
- else if (num2 <= (float)item.Level && !newRatingList.Contains(item))
- {
- list2.Add(item);
+ list.Add(item);
}
}
+ else if (num2 <= (float)item.Level && !newRatingList.Contains(item))
+ {
+ list2.Add(item);
+ }
}
+ }
- list.Sort();
- list.Reverse();
- if (list.Count > 10)
- {
- list.RemoveRange(10, list.Count - 10);
- }
+ list.Sort();
+ list.Reverse();
+ if (list.Count > 10)
+ {
+ list.RemoveRange(10, list.Count - 10);
+ }
- userData.RatingList.NextRatingList = list;
- list2.Sort();
- list2.Reverse();
- if (list2.Count > 10)
- {
- list2.RemoveRange(10, list2.Count - 10);
- }
+ userData.RatingList.NextRatingList = list;
+ list2.Sort();
+ list2.Reverse();
+ if (list2.Count > 10)
+ {
+ list2.RemoveRange(10, list2.Count - 10);
+ }
- userData.RatingList.NextNewRatingList = list2;
+ userData.RatingList.NextNewRatingList = list2;
- userData.Detail.LastPlayCredit = 0;
- userData.Detail.LastPlayMode = 0;
- if (GameManager.IsFreedomMode)
- {
- userData.Detail.LastPlayMode = 1;
- }
+ userData.Detail.LastPlayCredit = 0;
+ userData.Detail.LastPlayMode = 0;
+ if (GameManager.IsFreedomMode)
+ {
+ userData.Detail.LastPlayMode = 1;
+ }
- if (GameManager.IsCourseMode)
- {
- userData.Detail.LastPlayMode = 2;
- }
+ if (GameManager.IsCourseMode)
+ {
+ userData.Detail.LastPlayMode = 2;
+ }
- userData.Detail.LastGameId = "SDEZ";
- userData.Detail.LastRomVersion = Singleton.Instance.config.romVersionInfo.versionNo.versionString;
- userData.Detail.LastDataVersion = Singleton.Instance.config.dataVersionInfo.versionNo.versionString;
+# if SDGA145
+ userData.Detail.LastGameId = "SDGA";
+# else
+ userData.Detail.LastGameId = "SDEZ";
+# endif
+ userData.Detail.LastRomVersion = Singleton.Instance.config.romVersionInfo.versionNo.versionString;
+ userData.Detail.LastDataVersion = Singleton.Instance.config.dataVersionInfo.versionNo.versionString;
+ }
+
+ private class SavingUi : MonoBehaviour
+ {
+ public void OnGUI()
+ {
+ var y = Screen.height * .075f;
+ var width = GuiSizes.FontSize * 20f;
+ var x = GuiSizes.PlayerCenter + GuiSizes.PlayerWidth / 2f - width;
+ var rect = new Rect(x, y, width, GuiSizes.LabelHeight * 2.5f);
+
+ var labelStyle = GUI.skin.GetStyle("label");
+ labelStyle.fontSize = (int)(GuiSizes.FontSize * 1.2);
+ labelStyle.alignment = TextAnchor.MiddleCenter;
+
+ GUI.Box(rect, "");
+ GUI.Label(rect, Locale.SavingDontExit);
}
}
}