上传文件至 GUI
This commit is contained in:
39
GUI/AutoPlayPanel.cs
Normal file
39
GUI/AutoPlayPanel.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using SinmaiAssist.Cheat;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class AutoPlayPanel
|
||||
{
|
||||
public static void OnGUI()
|
||||
{
|
||||
GUILayout.Label($"Mode: {AutoPlay.autoPlayMode}", MainGUI.Style.Text);
|
||||
AutoPlay.DisableUpdate = GUILayout.Toggle(AutoPlay.DisableUpdate, "Disable Mode Update");
|
||||
if (GUILayout.Button("Critical (AP+)", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.Critical.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.Critical;
|
||||
|
||||
if (GUILayout.Button("Perfect", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.Perfect.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.Perfect;
|
||||
|
||||
if (GUILayout.Button("Great", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.Great.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.Great;
|
||||
|
||||
if (GUILayout.Button("Good", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.Good.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.Good;
|
||||
|
||||
if (GUILayout.Button("Random", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.Random.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.Random;
|
||||
|
||||
if (GUILayout.Button("RandomAllPerfect", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.RandomAllPerfect.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.RandomAllPerfect;
|
||||
|
||||
if (GUILayout.Button("RandomFullComboPlus", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.RandomFullComboPlus.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.RandomFullComboPlus;
|
||||
|
||||
if (GUILayout.Button("RandomFullCombo", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.RandomFullCombo.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.RandomFullCombo;
|
||||
|
||||
if (GUILayout.Button("None", MainGUI.Style.Button) || DebugInput.GetKeyDown(SinmaiAssist.KeyBindConfig.AutoPlay.None.KeyCode))
|
||||
AutoPlay.autoPlayMode = AutoPlay.AutoPlayMode.None;
|
||||
}
|
||||
}
|
||||
32
GUI/ChartControllerPanel.cs
Normal file
32
GUI/ChartControllerPanel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using SinmaiAssist.Cheat;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class ChartControllerPanel
|
||||
{
|
||||
public static void OnGUI()
|
||||
{
|
||||
GUIStyle buttonStyle = new GUIStyle(MainGUI.Style.Button) { fontSize = 24 };
|
||||
ChartController.ButtonStatus = ChartController.Button.None;
|
||||
Manager.NotesManager notesManager = new Manager.NotesManager();
|
||||
GUILayout.Label($"Timer Status: {(notesManager.IsPlaying() ? (ChartController.IsPlaying ? "Playing" : "Paused") : "Not Play")}", MainGUI.Style.Text);
|
||||
GUILayout.Label($"Timer:", new GUIStyle(MainGUI.Style.Text) { fontSize = 20 });
|
||||
GUILayout.Label($"{ChartController.Timer.ToString("0000000.0000")}", new GUIStyle(MainGUI.Style.Title) { fontSize = 20 });
|
||||
if (GUILayout.Button($"{(ChartController.IsPlaying ? "Pause" : "Play")}", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.Pause;
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("<<<", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.TimeSkipSub3;
|
||||
if (GUILayout.Button("<<", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.TimeSkipSub2;
|
||||
if (GUILayout.Button("<", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.TimeSkipSub;
|
||||
if (GUILayout.Button(">", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.TimeSkipAdd;
|
||||
if (GUILayout.Button(">>", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.TimeSkipAdd2;
|
||||
if (GUILayout.Button(">>>", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.TimeSkipAdd3;
|
||||
GUILayout.EndHorizontal();
|
||||
if (GUILayout.Button("Reset", buttonStyle, GUILayout.Height(45f))) ChartController.ButtonStatus = ChartController.Button.Reset;
|
||||
GUILayout.Label($"RecordTime: {ChartController.RecordTime.ToString("0000000")}({-((int)ChartController.Timer - ChartController.RecordTime)})", MainGUI.Style.Text);
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Set", MainGUI.Style.Button)) ChartController.ButtonStatus = ChartController.Button.Set;
|
||||
if (GUILayout.Button("Back", MainGUI.Style.Button)) ChartController.ButtonStatus = ChartController.Button.Back;
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
31
GUI/DebugPanel.cs
Normal file
31
GUI/DebugPanel.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using MAI2.Util;
|
||||
using Manager;
|
||||
using SinmaiAssist.Cheat;
|
||||
using SinmaiAssist.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class DebugPanel
|
||||
{
|
||||
public static bool UnityLogger = false;
|
||||
public static void OnGUI()
|
||||
{
|
||||
GUILayout.Label($"Test Tools", MainGUI.Style.Title);
|
||||
if (GUILayout.Button("TouchArea Display", MainGUI.Style.Button)) Common.InputManager.TouchAreaDisplayButton = true;
|
||||
if (GUILayout.Button("Send Test Message", MainGUI.Style.Button))
|
||||
{
|
||||
GameMessageManager.SendMessage(0,"Hello World!\nMonitorId: 0");
|
||||
GameMessageManager.SendMessage(1,"Hello World!\nMonitorId: 1");
|
||||
}
|
||||
if (GUILayout.Button("Save P1 Option To DefaultOption", MainGUI.Style.Button)) Common.ChangeDefaultOption.SaveOptionFile(0L);
|
||||
if (GUILayout.Button("Save P2 Option To DefaultOption", MainGUI.Style.Button)) Common.ChangeDefaultOption.SaveOptionFile(1L);
|
||||
if (GUILayout.Button("↑ ↓ ↑ ↓", MainGUI.Style.Button)) SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_ENTRY_AIME_ERROR, 1);
|
||||
if (GUILayout.Button("Switch Utage Mode", MainGUI.Style.Button)) UnlockUtage.SwitchUtageMode();
|
||||
GUILayout.Label($"GUI Toggle", MainGUI.Style.Title);
|
||||
if (GUILayout.Button("Toggle Show Info", MainGUI.Style.Button)) SinmaiAssist.MainConfig.ModSetting.ShowInfo = !SinmaiAssist.MainConfig.ModSetting.ShowInfo;
|
||||
if (GUILayout.Button("Toggle Show FPS", MainGUI.Style.Button)) SinmaiAssist.MainConfig.Common.ShowFPS = !SinmaiAssist.MainConfig.Common.ShowFPS;
|
||||
UnityLogger = GUILayout.Toggle(UnityLogger, "Log Unity Debug?");
|
||||
}
|
||||
}
|
||||
56
GUI/DummyLoginPanel.cs
Normal file
56
GUI/DummyLoginPanel.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Manager;
|
||||
using Net.Packet;
|
||||
using Net.Packet.Helper;
|
||||
using SinmaiAssist.Common;
|
||||
using SinmaiAssist.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class DummyLoginPanel
|
||||
{
|
||||
public static string DummyLoginCode = "";
|
||||
public static string DummyUserId = "";
|
||||
public static bool CodeLoginFlag = false;
|
||||
public static bool UserIdLoginFlag = false;
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Code:", MainGUI.Style.Text);
|
||||
DummyLoginCode = GUILayout.TextArea(DummyLoginCode, GUILayout.Height(100f));
|
||||
if (GUILayout.Button("Code Login", MainGUI.Style.Button))
|
||||
{
|
||||
CodeLoginFlag = true;
|
||||
if(SinmaiAssist.GameID != "SDGB")DummyAimeLogin.ReadCard();
|
||||
}
|
||||
GUILayout.Label("UserID:", MainGUI.Style.Text);
|
||||
DummyUserId = GUILayout.TextField(DummyUserId, GUILayout.Height(20f));
|
||||
if (GUILayout.Button("UserId Login", MainGUI.Style.Button))
|
||||
{
|
||||
UserIdLoginFlag = true;
|
||||
if(SinmaiAssist.GameID != "SDGB")DummyAimeLogin.ReadCard("12312312312312312312", DummyLoginCode);
|
||||
}
|
||||
GUILayout.Label($"AMDaemon BootTime: {AMDaemon.Allnet.Auth.AuthTime}", MainGUI.Style.Text);
|
||||
if (SinmaiAssist.GameID == "SDGB")
|
||||
{
|
||||
if (GUILayout.Button("UserId Logout", MainGUI.Style.Button))
|
||||
{
|
||||
PacketHelper.StartPacket(new UserLogout(ulong.Parse(DummyUserId), AMDaemon.Allnet.Auth.AuthTime, "", LogoutComplete,LogoutFailed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void LogoutComplete()
|
||||
{
|
||||
SoundManager.PlayVoice(Mai2.Voice_000001.Cue.VO_000012, 1);
|
||||
GameMessageManager.SendMessage(0,$"Id: {DummyUserId} Logout Complete.");
|
||||
GameMessageManager.SendMessage(1,$"Id: {DummyUserId} Logout Complete.");
|
||||
}
|
||||
|
||||
private static void LogoutFailed(PacketStatus status)
|
||||
{
|
||||
SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_ENTRY_AIME_ERROR, 1);
|
||||
GameMessageManager.SendMessage(0,$"Id: {DummyUserId} Logout Failed.");
|
||||
GameMessageManager.SendMessage(1,$"Id: {DummyUserId} Logout Failed.");
|
||||
}
|
||||
}
|
||||
44
GUI/FastSkipPanel.cs
Normal file
44
GUI/FastSkipPanel.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using SinmaiAssist.Cheat;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class FastSkipPanel
|
||||
{
|
||||
private static string _scoreInput = "0";
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
FastSkip.SkipButton = false;
|
||||
GUILayout.Label($"Skip Mode: {(FastSkip.CustomSkip ? "Custom" : "Default")}", MainGUI.Style.Text);
|
||||
if (GUILayout.Button("Skip", new GUIStyle(MainGUI.Style.Button){ fontSize=20 }, GUILayout.Height(45f))) FastSkip.SkipButton = true;
|
||||
GUILayout.Label($"Mode Setting", MainGUI.Style.Title);
|
||||
if (GUILayout.Button("Default", MainGUI.Style.Button)) FastSkip.CustomSkip = false;
|
||||
if (GUILayout.Button("Custom", MainGUI.Style.Button)) FastSkip.CustomSkip = true;
|
||||
if (FastSkip.CustomSkip)
|
||||
{
|
||||
GUILayout.Label($"Custom Setting", MainGUI.Style.Title);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label($"Custom Score(0 - 101): ", MainGUI.Style.Text);
|
||||
_scoreInput = GUILayout.TextField(_scoreInput);
|
||||
GUILayout.EndHorizontal();
|
||||
if (int.TryParse(_scoreInput, out int scoreValue))
|
||||
{
|
||||
if (scoreValue >= 0f && scoreValue <= 101f)
|
||||
{
|
||||
FastSkip.CustomAchivement = scoreValue;
|
||||
GUILayout.Label($"Custom Score: {scoreValue} %", MainGUI.Style.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("Error: Please enter a value between 0 and 101.", MainGUI.Style.ErrorMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("Error: Please enter a valid int value.", MainGUI.Style.ErrorMessage);
|
||||
}
|
||||
FastSkip.Force1Miss = GUILayout.Toggle(FastSkip.Force1Miss, "Force Add 1 miss");
|
||||
}
|
||||
}
|
||||
}
|
||||
40
GUI/GraphicPanel.cs
Normal file
40
GUI/GraphicPanel.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using SinmaiAssist.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class GraphicPanel
|
||||
{
|
||||
private static string screenWidth = $"{Graphic.GetResolutionWidth()}";
|
||||
private static string screenHeight = $"{Graphic.GetResolutionHeight()}";
|
||||
private static string frameRate = $"{Graphic.GetMaxFrameRate()}";
|
||||
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
if (GUILayout.Button("Toggle full screen", MainGUI.Style.Button, GUILayout.Height(50))) Graphic.ToggleFullscreen();
|
||||
GUILayout.Label($"Custom Graphic Settings", MainGUI.Style.Title);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label($"Width:", MainGUI.Style.Text);
|
||||
screenWidth = GUILayout.TextField(screenWidth);
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label($"Height:", MainGUI.Style.Text);
|
||||
screenHeight = GUILayout.TextField(screenHeight);
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label($"Max FPS (Unlimited is -1):", MainGUI.Style.Text);
|
||||
frameRate = GUILayout.TextField(frameRate);
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
if (GUILayout.Button("Apply", MainGUI.Style.Button, GUILayout.Height(20)) && int.TryParse(screenWidth, out int widthValue) && int.TryParse(screenHeight, out int heightValue) && int.TryParse(frameRate, out int fpsValue))
|
||||
{
|
||||
if (widthValue >= 360f && heightValue >= 360f)
|
||||
{
|
||||
Graphic.SetResolution(widthValue, heightValue);
|
||||
Graphic.SetMaxFrameRate(fpsValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
114
GUI/MainGUI.cs
Normal file
114
GUI/MainGUI.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class MainGUI
|
||||
{
|
||||
private enum Toolbar
|
||||
{
|
||||
AutoPlay,
|
||||
FastSkip,
|
||||
ChartController,
|
||||
DummyLogin,
|
||||
UserData,
|
||||
Graphic,
|
||||
Debug
|
||||
}
|
||||
|
||||
private const float PanelWidth = 320f;
|
||||
private const int ButtonsPerRow = 3;
|
||||
|
||||
private Rect _panelWindow;
|
||||
private Toolbar _toolbar = Toolbar.AutoPlay;
|
||||
private bool _backspaceKeyDown = false;
|
||||
private string _titleStr = BuildInfo.Name;
|
||||
|
||||
public static readonly Style Style = new Style();
|
||||
|
||||
public MainGUI()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
if (DebugInput.GetKey(SinmaiAssist.KeyBindConfig.SinmaiAssist.ShowUserPanel.KeyCode))
|
||||
{
|
||||
if(!_backspaceKeyDown) SinmaiAssist.MainConfig.ModSetting.ShowPanel = !SinmaiAssist.MainConfig.ModSetting.ShowPanel;
|
||||
_backspaceKeyDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_backspaceKeyDown = false;
|
||||
}
|
||||
|
||||
if (SinmaiAssist.MainConfig.ModSetting.ShowPanel)
|
||||
{
|
||||
if (SinmaiAssist.MainConfig.ModSetting.SafeMode) _titleStr += "(SafeMode)";
|
||||
_panelWindow = GUILayout.Window(10086, _panelWindow, MainPanel, _titleStr);
|
||||
SinmaiAssist.MainConfig.ModSetting.ShowPanel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_panelWindow = new Rect();
|
||||
}
|
||||
}
|
||||
|
||||
private void MainPanel(int id)
|
||||
{
|
||||
GUILayout.BeginVertical($"{BuildInfo.Name} {BuildInfo.Version} ({BuildInfo.CommitHash??"NOT SET"})", GUILayout.Height(20f));
|
||||
ToolBarPanel();
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(GUILayout.Width(PanelWidth), GUILayout.Height(380f));
|
||||
if (_toolbar == Toolbar.AutoPlay && SinmaiAssist.MainConfig.Cheat.AutoPlay) AutoPlayPanel.OnGUI();
|
||||
else if (_toolbar == Toolbar.FastSkip && SinmaiAssist.MainConfig.Cheat.FastSkip) FastSkipPanel.OnGUI();
|
||||
else if (_toolbar == Toolbar.ChartController && SinmaiAssist.MainConfig.Cheat.ChartController) ChartControllerPanel.OnGUI();
|
||||
else if (_toolbar == Toolbar.DummyLogin && SinmaiAssist.MainConfig.Common.DummyLogin.Enable) DummyLoginPanel.OnGUI();
|
||||
else if (_toolbar == Toolbar.UserData) UserDataPanel.OnGUI();
|
||||
else if (_toolbar == Toolbar.Graphic) GraphicPanel.OnGUI();
|
||||
else if (_toolbar == Toolbar.Debug) DebugPanel.OnGUI();
|
||||
else DisablePanel();
|
||||
GUILayout.EndVertical();
|
||||
UnityEngine.GUI.DragWindow();
|
||||
}
|
||||
|
||||
private void ToolBarPanel()
|
||||
{
|
||||
string[] toolbarNames = Enum.GetNames(typeof(Toolbar));
|
||||
int toolbarCount = toolbarNames.Length;
|
||||
int rowCount = Mathf.CeilToInt((float)toolbarCount / ButtonsPerRow);
|
||||
int selectedToolbar = (int)_toolbar;
|
||||
|
||||
for (int row = 0; row < rowCount; row++)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
int startIndex = row * ButtonsPerRow;
|
||||
int endIndex = Mathf.Min(startIndex + ButtonsPerRow, toolbarCount);
|
||||
|
||||
string[] rowToolbarNames = new string[endIndex - startIndex];
|
||||
Array.Copy(toolbarNames, startIndex, rowToolbarNames, 0, endIndex - startIndex);
|
||||
|
||||
int rowSelection = GUILayout.Toolbar(
|
||||
selectedToolbar - startIndex,
|
||||
rowToolbarNames,
|
||||
Style.Button,
|
||||
GUILayout.Width(PanelWidth),
|
||||
GUILayout.Height(20f)
|
||||
);
|
||||
|
||||
selectedToolbar = startIndex + rowSelection;
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
_toolbar = (Toolbar)selectedToolbar;
|
||||
}
|
||||
|
||||
private void DisablePanel()
|
||||
{
|
||||
GUILayout.Label(_toolbar.ToString(), Style.DisablePanel, GUILayout.Width(PanelWidth), GUILayout.Height(120f));
|
||||
GUILayout.Label("is Disable", Style.DisablePanel, GUILayout.Width(PanelWidth), GUILayout.Height(160f));
|
||||
}
|
||||
}
|
||||
43
GUI/ShowVersionInfo.cs
Normal file
43
GUI/ShowVersionInfo.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Text;
|
||||
using MAI2.Util;
|
||||
using MAI2System;
|
||||
using SinmaiAssist.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class ShowVersionInfo
|
||||
{
|
||||
private static readonly StringBuilder VersionText = new StringBuilder();
|
||||
|
||||
private static readonly GUIStyle TextShadow = new GUIStyle()
|
||||
{
|
||||
fontSize = 24,
|
||||
alignment = TextAnchor.UpperLeft,
|
||||
normal = new GUIStyleState(){textColor = Color.black}
|
||||
};
|
||||
|
||||
private static readonly GUIStyle TextStyle = new GUIStyle()
|
||||
{
|
||||
fontSize = 24,
|
||||
alignment = TextAnchor.UpperLeft,
|
||||
normal = new GUIStyleState(){textColor = Color.white}
|
||||
};
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
VersionText.Clear();
|
||||
VersionText.AppendLine($"{BuildInfo.Name} {BuildInfo.Version} ({BuildInfo.CommitHash})");
|
||||
VersionText.AppendLine("Powered by MelonLoader");
|
||||
VersionText.AppendLine($"Client Version: {SinmaiAssist.GameID} {SinmaiAssist.GameVersion}");
|
||||
VersionText.AppendLine(
|
||||
$"Data Version: {Singleton<SystemConfig>.Instance.config.dataVersionInfo.versionNo.versionString} {Singleton<SystemConfig>.Instance.config.dataVersionInfo.versionNo.releaseNoAlphabet}");
|
||||
VersionText.AppendLine($"Current Title Server: {Server.GetTitleServerUri()}");
|
||||
VersionText.AppendLine($"Keychip: {AMDaemon.System.KeychipId}");
|
||||
VersionText.AppendLine($"UserId: {User.GetUserIdString(0L)} | {User.GetUserIdString(1L)}");
|
||||
if (SinmaiAssist.MainConfig.ModSetting.SafeMode)
|
||||
VersionText.AppendLine("Safe Mode");
|
||||
UnityEngine.GUI.Label(new Rect(10+2, 40+2, 500, 30), VersionText.ToString(), TextShadow);
|
||||
UnityEngine.GUI.Label(new Rect(10, 40, 500, 30), VersionText.ToString(), TextStyle);
|
||||
}
|
||||
}
|
||||
96
GUI/Style.cs
Normal file
96
GUI/Style.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System.Windows.Forms;
|
||||
using Monitor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class Style
|
||||
{
|
||||
public readonly GUIStyle Title = new GUIStyle()
|
||||
{
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
normal = new GUIStyleState() { textColor = Color.white }
|
||||
};
|
||||
|
||||
public readonly GUIStyle DisablePanel = new GUIStyle()
|
||||
{
|
||||
fontSize = 40,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
normal = new GUIStyleState(){textColor = Color.white}
|
||||
};
|
||||
|
||||
public readonly GUIStyle ErrorMessage = new GUIStyle()
|
||||
{
|
||||
normal = new GUIStyleState() { textColor = Color.red }
|
||||
};
|
||||
|
||||
public readonly GUIStyle Button = new GUIStyle()
|
||||
{
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
border = new RectOffset(2, 2, 2, 2), //边框
|
||||
margin = new RectOffset(5,5,5,5), //边距
|
||||
padding = new RectOffset(4,4,4,4), //内边距
|
||||
normal = new GUIStyleState()
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = CreateBorderTexture(new Color(0.2f, 0.2f, 0.2f,0.5f))
|
||||
},
|
||||
hover = new GUIStyleState()
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = CreateBorderTexture(new Color(0.4f, 0.4f, 0.4f,0.5f))
|
||||
},
|
||||
active = new GUIStyleState()
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = CreateBorderTexture(new Color(0.25f, 0.25f, 0.25f,0.5f))
|
||||
},
|
||||
onNormal = new GUIStyleState() {
|
||||
textColor = Color.yellow,
|
||||
background = CreateBorderTexture(new Color(0.25f, 0.25f, 0.25f,0.5f))
|
||||
},
|
||||
onHover = new GUIStyleState() {
|
||||
textColor = Color.yellow,
|
||||
background = CreateBorderTexture(new Color(0.4f, 0.4f, 0.4f,0.5f))
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public GUIStyle Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return new GUIStyle(UnityEngine.GUI.skin.label)
|
||||
{
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//创建背景纹理
|
||||
|
||||
private static Texture2D CreateBorderTexture(Color color)
|
||||
{
|
||||
Texture2D texture = new Texture2D(3, 3)
|
||||
{
|
||||
wrapMode = TextureWrapMode.Repeat
|
||||
};
|
||||
for (int x = 0; x < 3; x++){
|
||||
for (int y = 0; y < 3; y++){
|
||||
texture.SetPixel(x, y, color);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 3; i++){
|
||||
texture.SetPixel(i, 0, Color.white);
|
||||
texture.SetPixel(i, 2, Color.white);
|
||||
texture.SetPixel(0, i, Color.white);
|
||||
texture.SetPixel(2, i, Color.white);
|
||||
}
|
||||
texture.SetPixel(0, 0, color);
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
205
GUI/UserDataPanel.cs
Normal file
205
GUI/UserDataPanel.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MAI2.Util;
|
||||
using Manager;
|
||||
using MelonLoader;
|
||||
using SinmaiAssist.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.GUI;
|
||||
|
||||
public class UserDataPanel
|
||||
{
|
||||
private static UserData _player1 = null;
|
||||
private static UserData _player2 = null;
|
||||
private static bool _isNewItem = false;
|
||||
|
||||
private enum CollectionType
|
||||
{
|
||||
Icon = UserData.Collection.Icon,
|
||||
Plate = UserData.Collection.Plate,
|
||||
Title = UserData.Collection.Title,
|
||||
Partner = UserData.Collection.Partner,
|
||||
Frame = UserData.Collection.Frame
|
||||
}
|
||||
|
||||
private static string[] _userInputId = ["", "", "", "", "", "", ""];
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
GUILayout.Label($"User Info", MainGUI.Style.Title);
|
||||
try
|
||||
{
|
||||
_player1 = Singleton<UserDataManager>.Instance.GetUserData(0);
|
||||
_player2 = Singleton<UserDataManager>.Instance.GetUserData(1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
GUILayout.Label($"1P: {_player1.Detail.UserName} ({_player1.Detail.UserID})", MainGUI.Style.Text);
|
||||
GUILayout.Label($"2P: {_player2.Detail.UserName} ({_player2.Detail.UserID})", MainGUI.Style.Text);
|
||||
|
||||
GUILayout.Label("Add Collections", MainGUI.Style.Title);
|
||||
foreach (CollectionType type in Enum.GetValues(typeof(CollectionType)))
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
int typeId = (int)type;
|
||||
GUILayout.Label(type.ToString(), new GUIStyle(MainGUI.Style.Text){fixedWidth = 50});
|
||||
_userInputId[typeId] = GUILayout.TextField(_userInputId[typeId]);
|
||||
if (GUILayout.Button("Add", new GUIStyle(MainGUI.Style.Button){ fixedWidth = 50}))
|
||||
{
|
||||
AddCollections(0, type, _userInputId[typeId]);
|
||||
AddCollections(1, type, _userInputId[typeId]);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
_isNewItem = GUILayout.Toggle(_isNewItem, "Is New Item");
|
||||
|
||||
GUILayout.Label("Unlock Music", MainGUI.Style.Title);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Music", new GUIStyle(MainGUI.Style.Text){fixedWidth = 50});
|
||||
_userInputId[0] = GUILayout.TextField(_userInputId[0]);
|
||||
if (GUILayout.Button("Add", new GUIStyle(MainGUI.Style.Button){ fixedWidth = 50}))
|
||||
{
|
||||
UnlockMusic(0, _userInputId[0]);
|
||||
UnlockMusic(1, _userInputId[0]);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Label("MaiMile", MainGUI.Style.Title);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("MaiMile", new GUIStyle(MainGUI.Style.Text){fixedWidth = 50});
|
||||
_userInputId[6] = GUILayout.TextField(_userInputId[6]);
|
||||
if (GUILayout.Button("Add", new GUIStyle(MainGUI.Style.Button){ fixedWidth = 50}))
|
||||
{
|
||||
AddMaiMile(0, _userInputId[6]);
|
||||
AddMaiMile(1, _userInputId[6]);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Label("User Data Backup", MainGUI.Style.Title);
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("1P", MainGUI.Style.Button)) User.ExportBackupData(0);
|
||||
if (GUILayout.Button("2P", MainGUI.Style.Button)) User.ExportBackupData(1);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
}
|
||||
|
||||
private static void AddCollections(long index, CollectionType type, string input)
|
||||
{
|
||||
UserData userData = Singleton<UserDataManager>.Instance.GetUserData(index);
|
||||
if (userData.IsGuest())
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,"Guest Account\nUnable to add collections");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (int.TryParse(input, out int id))
|
||||
{
|
||||
if (userData.AddCollections((UserData.Collection)type, id, _isNewItem))
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Add Collections \n{type} {id}" + (_isNewItem ? " (New Item)" : "") );
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Failed to add Collections or already added\n{type} {id}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Invalid ID\n {input}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Unknown error");
|
||||
MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void UnlockMusic(long index, string input)
|
||||
{
|
||||
UserData userData = Singleton<UserDataManager>.Instance.GetUserData(index);
|
||||
if (userData.IsGuest())
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,"Guest Account\nUnable to unlock music");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (int.TryParse(input, out int id))
|
||||
{
|
||||
if (!userData.IsUnlockMusic(UserData.MusicUnlock.Base, id))
|
||||
{
|
||||
if (userData.AddUnlockMusic(UserData.MusicUnlock.Base, id))
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Unlock Music \n{id}");
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Failed to unlock music or already unlocked \n{id}");
|
||||
}
|
||||
}
|
||||
else if(!userData.IsUnlockMusic(UserData.MusicUnlock.Master, id))
|
||||
{
|
||||
userData.AddUnlockMusic(UserData.MusicUnlock.Master, id);
|
||||
userData.AddUnlockMusic(UserData.MusicUnlock.ReMaster, id);
|
||||
GameMessageManager.SendMessage((int)index,$"Unlock Master \n{id}");
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Failed to unlock Master or already unlocked\n{id}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Invalid ID\n {input}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Unknown error");
|
||||
MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddMaiMile(long index, string input)
|
||||
{
|
||||
UserData userData = Singleton<UserDataManager>.Instance.GetUserData(index);
|
||||
if (SinmaiAssist.GameVersion < 25000)
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,"MaiMile is not supported in this version");
|
||||
return;
|
||||
}
|
||||
if (userData.IsGuest())
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,"Guest Account\nUnable to add MaiMile");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (int.TryParse(input , out int addMile))
|
||||
{
|
||||
var haveMile = userData.Detail.Point;
|
||||
if (haveMile + addMile >= 99999)
|
||||
addMile = 99999 - haveMile;
|
||||
var addMileBefore = haveMile + addMile;
|
||||
|
||||
userData.AddPresentMile(addMile);
|
||||
GameMessageManager.SendMessage((int)index,$"Add {addMile} MaiMile\n ({haveMile} -> {addMileBefore})");
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Invalid MaiMile\n {input}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GameMessageManager.SendMessage((int)index,$"Unknown error");
|
||||
MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user