Files
AquaDX/AquaMai/AquaMai.Mods/Utils/ShowNetErrorDetail.cs
Menci 37044dae01 [RF] AquaMai configuration refactor (#82)
更新了配置文件格式,原有的配置文件将被自动无缝迁移,详情请见新的配置文件中的注释(例外:`SlideJudgeTweak` 不再默认启用)
旧配置文件将被重命名备份,如果更新到此版本遇到 Bug 请联系我们

Updated configuration file schema. The old config file will be migrated automatically and seamlessly. See the comments in the new configuration file for details. (Except for `SlideJudgeTweak` is no longer enabled by default)
Your old configuration file will be renamed as a backup. If you encounter any bug with this version, please contact us.
2024-11-25 01:25:19 +08:00

73 lines
2.2 KiB
C#

using System.Collections.Generic;
using AquaMai.Config.Attributes;
using AquaMai.Core.Helpers;
using AquaMai.Core.Resources;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Monitor;
using Process;
using UnityEngine;
namespace AquaMai.Mods.Utils;
[ConfigSection(
en: "Show Network error detail in the game when gray network icon appears.",
zh: "出现灰网时显示原因")]
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]);
}
}
}
}