[+] Network error reason

pull/55/head
Clansty 2024-10-01 01:00:32 +08:00
parent e39f013808
commit e65d67f12e
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
10 changed files with 140 additions and 9 deletions

View File

@ -327,6 +327,7 @@ DEBUG</DefineConstants>
<Compile Include="Utils\PractiseMode.cs" />
<Compile Include="Utils\PractiseModeUI.cs" />
<Compile Include="Utils\SelectionDetail.cs" />
<Compile Include="Utils\ShowNetErrorDetail.cs" />
<Compile Include="Utils\WindowState.cs" />
<Compile Include="UX\CustomPlaceName.cs" />
<Compile Include="UX\CustomVersionString.cs" />

View File

@ -96,6 +96,8 @@ IWontTapOrSlideVigorously=true
SkipGameOverScreen=true
# Skip TrackStart screen
SkipTrackStart=true
# Show reason when net icon is gray
ShowNetErrorDetail=true
[TouchSensitivity]
# Enable custom sensitivity

View File

@ -94,6 +94,8 @@ Width=0
Height=0
# 选歌界面显示选择的歌曲的详情
SelectionDetail=true
# 出现灰网时显示原因
ShowNetErrorDetail=true
# ===================================
# 节省一些不知道有用没用的时间

View File

@ -62,6 +62,7 @@ namespace AquaMai
public int Height { get; set; }
public bool PractiseMode { get; set; }
public bool SelectionDetail { get; set; }
public bool ShowNetErrorDetail { get; set; }
}
public class TimeSavingConfig

View File

@ -174,8 +174,7 @@ namespace AquaMai
if (_hasErrors)
{
MelonLogger.Warning("========================================================================!!!");
MelonLogger.Warning(Locale.LoadError);
MelonLogger.Warning("========================================================================!!!\n" + Locale.LoadError);
MelonLogger.Warning("===========================================================================");
}

View File

@ -98,6 +98,42 @@ namespace AquaMai.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Aime reader error.
/// </summary>
internal static string NetErrIsAliveAimeReader {
get {
return ResourceManager.GetString("NetErrIsAliveAimeReader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Aime server error.
/// </summary>
internal static string NetErrIsAliveAimeServer {
get {
return ResourceManager.GetString("NetErrIsAliveAimeServer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Server communication error.
/// </summary>
internal static string NetErrIsAliveServer {
get {
return ResourceManager.GetString("NetErrIsAliveServer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Data download not success.
/// </summary>
internal static string NetErrWasDownloadSuccessOnce {
get {
return ResourceManager.GetString("NetErrWasDownloadSuccessOnce", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Pause.
/// </summary>

View File

@ -69,4 +69,16 @@
<data name="Loaded" xml:space="preserve">
<value>Loaded!</value>
</data>
<data name="NetErrIsAliveServer" xml:space="preserve">
<value>Server communication error</value>
</data>
<data name="NetErrIsAliveAimeReader" xml:space="preserve">
<value>Aime reader error</value>
</data>
<data name="NetErrIsAliveAimeServer" xml:space="preserve">
<value>Aime server error</value>
</data>
<data name="NetErrWasDownloadSuccessOnce" xml:space="preserve">
<value>Data download not success</value>
</data>
</root>

View File

@ -62,4 +62,16 @@
<data name="Loaded" xml:space="preserve">
<value>加载完成!</value>
</data>
<data name="NetErrIsAliveServer" xml:space="preserve">
<value>主服务器通信错误</value>
</data>
<data name="NetErrIsAliveAimeReader" xml:space="preserve">
<value>Aime 读卡器错误</value>
</data>
<data name="NetErrIsAliveAimeServer" xml:space="preserve">
<value>AimeDB 通信错误</value>
</data>
<data name="NetErrWasDownloadSuccessOnce" xml:space="preserve">
<value>数据下载不成功</value>
</data>
</root>

View File

@ -42,13 +42,10 @@ public class ImmediateSave
void CheckSaveDone()
{
doneCount++;
if (doneCount == 4)
{
if (ui != null)
{
UnityEngine.Object.Destroy(ui);
}
}
if (doneCount != 4) return;
if (ui == null) return;
UnityEngine.Object.Destroy(ui);
ui = null;
}
for (int i = 0; i < 2; i++)

View File

@ -0,0 +1,69 @@
using System.Collections.Generic;
using AquaMai.Helpers;
using AquaMai.Resources;
using HarmonyLib;
using MAI2.Util;
using Manager;
using MelonLoader;
using Monitor;
using Process;
using UnityEngine;
namespace AquaMai.Utils;
public class ShowNetErrorDetail
{
[HarmonyPatch(typeof(CommonProcess), "OnStart")]
[HarmonyPostfix]
public static void SetIconStatus(CommonMonitor[] ____monitors)
{
____monitors[0].gameObject.AddComponent<DetailUi>();
}
private class DetailUi : MonoBehaviour
{
public void OnGUI()
{
var errors = new List<string>();
if (!Singleton<OperationManager>.Instance.IsAliveServer)
{
errors.Add(Locale.NetErrIsAliveServer);
}
if (!Singleton<OperationManager>.Instance.IsAliveAimeReader)
{
errors.Add(Locale.NetErrIsAliveAimeReader);
}
if (!Singleton<OperationManager>.Instance.IsAliveAimeServer)
{
errors.Add(Locale.NetErrIsAliveAimeServer);
}
if (!Singleton<OperationManager>.Instance.WasDownloadSuccessOnce)
{
errors.Add(Locale.NetErrWasDownloadSuccessOnce);
}
if (errors.Count == 0)
{
return;
}
var labelStyle = GUI.skin.GetStyle("label");
labelStyle.fontSize = GuiSizes.FontSize;
labelStyle.alignment = TextAnchor.MiddleCenter;
var x = GuiSizes.PlayerCenter + GuiSizes.PlayerWidth * .2f;
var y = Screen.height * .01f;
var width = GuiSizes.FontSize * 15f;
var height = GuiSizes.LabelHeight * errors.Count + GuiSizes.Margin * 2;
GUI.Box(new Rect(x, y, width, height), "");
for (var i = 0; i < errors.Count; i++)
{
GUI.Label(new Rect(x, y + GuiSizes.Margin + GuiSizes.LabelHeight * i, width, GuiSizes.LabelHeight), errors[i]);
}
}
}
}