mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-11 12:07:32 +08:00
[+] Network error reason
This commit is contained in:
69
AquaMai/Utils/ShowNetErrorDetail.cs
Normal file
69
AquaMai/Utils/ShowNetErrorDetail.cs
Normal 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user