[+] Show tip when saving is done

This commit is contained in:
Clansty
2024-10-01 00:15:55 +08:00
parent c34affc215
commit e39f013808
6 changed files with 278 additions and 166 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
}
}

View File

@@ -7,8 +7,6 @@
// </auto-generated>
//------------------------------------------------------------------------------
using MelonLoader;
namespace AquaMai.Resources {
using System;
@@ -61,6 +59,27 @@ namespace AquaMai.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Loaded!.
/// </summary>
internal static string Loaded {
get {
return ResourceManager.GetString("Loaded", resourceCulture);
}
}
/// <summary>
/// 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.
/// </summary>
internal static string LoadError {
get {
return ResourceManager.GetString("LoadError", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to End.
/// </summary>
@@ -124,6 +143,15 @@ namespace AquaMai.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Saving... Do not exit the game.
/// </summary>
internal static string SavingDontExit {
get {
return ResourceManager.GetString("SavingDontExit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Seek &lt;&lt;.
/// </summary>

View File

@@ -57,4 +57,16 @@
<data name="SpeedReset" xml:space="preserve">
<value>Speed Reset</value>
</data>
<data name="LoadError" xml:space="preserve">
<value>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</value>
</data>
<data name="SavingDontExit" xml:space="preserve">
<value>Saving... Do not exit the game</value>
</data>
<data name="Loaded" xml:space="preserve">
<value>Loaded!</value>
</data>
</root>

View File

@@ -50,4 +50,16 @@
<data name="SpeedUp" xml:space="preserve">
<value>速度 +</value>
</data>
<data name="LoadError" xml:space="preserve">
<value>加载过程中检测到错误!
- 请检查你是否安装了错误的 AquaMai 版本,比如在 SDGA 上使用了 SDEZ 的版本
- 你是否正在使用魔改的 Assembly-CSharp.dll这会导致函数不一致而无法找到需要修改的函数
- 请检查是否有冲突的 Mod或者开启了不兼容的选项</value>
</data>
<data name="SavingDontExit" xml:space="preserve">
<value>正在保存… 请不要关闭游戏</value>
</data>
<data name="Loaded" xml:space="preserve">
<value>加载完成!</value>
</data>
</root>

View File

@@ -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,11 +17,12 @@ 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)
@@ -28,15 +31,39 @@ namespace AquaMai.UX
return false;
}
private static SavingUi ui;
[HarmonyPostfix]
[HarmonyPatch(typeof(ResultProcess), "OnStart")]
public static void ResultProcessOnStart()
{
var doneCount = 0;
void CheckSaveDone()
{
doneCount++;
if (doneCount == 4)
{
if (ui != null)
{
UnityEngine.Object.Destroy(ui);
}
}
}
for (int i = 0; i < 2; i++)
{
var userData = Singleton<UserDataManager>.Instance.GetUserData(i);
if(!userData.IsEntry) continue;
if(userData.IsGuest()) continue;
if (!userData.IsEntry || userData.IsGuest())
{
doneCount += 2;
continue;
}
if (ui == null)
{
ui = SharedInstances.GameMainObject.gameObject.AddComponent<SavingUi>();
}
SaveDataFix(userData);
# if SDGA145
@@ -45,12 +72,18 @@ namespace AquaMai.UX
var accessToken = Singleton<OperationManager>.Instance.GetAccessToken(i);
PacketHelper.StartPacket(new PacketUploadUserPlaylog(i, userData, (int)GameManager.MusicTrackNumber - 1, accessToken,
# endif
delegate { MelonLogger.Msg("Playlog saved"); },
delegate
{
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)
@@ -61,18 +94,23 @@ namespace AquaMai.UX
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(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();
}));
}
}
@@ -187,9 +225,30 @@ namespace AquaMai.UX
userData.Detail.LastPlayMode = 2;
}
# if SDGA145
userData.Detail.LastGameId = "SDGA";
# else
userData.Detail.LastGameId = "SDEZ";
# endif
userData.Detail.LastRomVersion = Singleton<SystemConfig>.Instance.config.romVersionInfo.versionNo.versionString;
userData.Detail.LastDataVersion = Singleton<SystemConfig>.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);
}
}
}