1
0
mirror of https://github.com/soarqin/DSP_Mods_TO.git synced 2026-02-04 22:22:22 +08:00
This commit is contained in:
2023-12-20 23:53:41 +08:00
parent b693006e0a
commit aae3d7df4c
5 changed files with 79 additions and 99 deletions

View File

@@ -6,7 +6,7 @@ using UnityEngine;
namespace AutoPilot.UI; namespace AutoPilot.UI;
internal class AutoPilotDebugUI internal static class AutoPilotDebugUI
{ {
public static void OnGUI() public static void OnGUI()
{ {
@@ -15,56 +15,52 @@ internal class AutoPilotDebugUI
fontSize = 11 fontSize = 11
}; };
Rect = GUILayout.Window(99031293, Rect, WindowFunction, "AutoPilot - Debug", guistyle, Array.Empty<GUILayoutOption>()); Rect = GUILayout.Window(99031293, Rect, WindowFunction, "AutoPilot - Debug", guistyle, Array.Empty<GUILayoutOption>());
var num = CruiseAssistMainUI.Scale / 100f;
var flag = Screen.width < Rect.xMax; if (Screen.width < Rect.xMax)
if (flag)
{ {
Rect.x = Screen.width - Rect.width; Rect.x = Screen.width - Rect.width;
} }
var flag2 = Rect.x < 0f;
if (flag2) if (Rect.x < 0f)
{ {
Rect.x = 0f; Rect.x = 0f;
} }
var flag3 = Screen.height < Rect.yMax;
if (flag3) if (Screen.height < Rect.yMax)
{ {
Rect.y = Screen.height - Rect.height; Rect.y = Screen.height - Rect.height;
} }
var flag4 = Rect.y < 0f;
if (flag4) if (Rect.y < 0f)
{ {
Rect.y = 0f; Rect.y = 0f;
} }
var flag5 = lastCheckWindowLeft != float.MinValue;
if (flag5) if (_lastCheckWindowLeft != float.MinValue)
{ {
var flag6 = Rect.x != lastCheckWindowLeft || Rect.y != lastCheckWindowTop; if (Rect.x != _lastCheckWindowLeft || Rect.y != _lastCheckWindowTop)
if (flag6)
{ {
AutoPilotMainUI.NextCheckGameTick = GameMain.gameTick + 300L; AutoPilotMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
} }
} }
lastCheckWindowLeft = Rect.x; _lastCheckWindowLeft = Rect.x;
lastCheckWindowTop = Rect.y; _lastCheckWindowTop = Rect.y;
var flag7 = AutoPilotMainUI.NextCheckGameTick <= GameMain.gameTick; if (AutoPilotMainUI.NextCheckGameTick <= GameMain.gameTick)
if (flag7)
{ {
ConfigManager.CheckConfig(ConfigManager.Step.State); ConfigManager.CheckConfig(ConfigManager.Step.State);
} }
} }
public static void WindowFunction(int windowId) private static void WindowFunction(int windowId)
{ {
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
var guistyle = new GUIStyle(GUI.skin.label) var guistyle = new GUIStyle(GUI.skin.label)
{ {
fontSize = 12 fontSize = 12
}; };
scrollPos = GUILayout.BeginScrollView(scrollPos, Array.Empty<GUILayoutOption>()); _scrollPos = GUILayout.BeginScrollView(_scrollPos, Array.Empty<GUILayoutOption>());
GUILayout.Label($"GameMain.mainPlayer.uPosition={GameMain.mainPlayer.uPosition}", guistyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"GameMain.mainPlayer.uPosition={GameMain.mainPlayer.uPosition}", guistyle, Array.Empty<GUILayoutOption>());
var flag = GameMain.localPlanet != null && CruiseAssistPlugin.TargetUPos != VectorLF3.zero; if (GameMain.localPlanet != null && CruiseAssistPlugin.TargetUPos != VectorLF3.zero)
if (flag)
{ {
var mainPlayer = GameMain.mainPlayer; var mainPlayer = GameMain.mainPlayer;
var targetUPos = CruiseAssistPlugin.TargetUPos; var targetUPos = CruiseAssistPlugin.TargetUPos;
@@ -80,10 +76,10 @@ internal class AutoPilotDebugUI
var mecha = GameMain.mainPlayer.mecha; var mecha = GameMain.mainPlayer.mecha;
GUILayout.Label($"mecha.coreEnergy={mecha.coreEnergy}", guistyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"mecha.coreEnergy={mecha.coreEnergy}", guistyle, Array.Empty<GUILayoutOption>());
GUILayout.Label($"mecha.coreEnergyCap={mecha.coreEnergyCap}", guistyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"mecha.coreEnergyCap={mecha.coreEnergyCap}", guistyle, Array.Empty<GUILayoutOption>());
var num = mecha.coreEnergy / mecha.coreEnergyCap * 100.0; var energyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
GUILayout.Label($"energyPer={num}", guistyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"energyPer={energyPer}", guistyle, Array.Empty<GUILayoutOption>());
var magnitude3 = GameMain.mainPlayer.controller.actionSail.visual_uvel.magnitude; var speed = GameMain.mainPlayer.controller.actionSail.visual_uvel.magnitude;
GUILayout.Label("spped=" + RangeToString(magnitude3), guistyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("spped=" + RangeToString(speed), guistyle, Array.Empty<GUILayoutOption>());
var movementStateInFrame = GameMain.mainPlayer.controller.movementStateInFrame; var movementStateInFrame = GameMain.mainPlayer.controller.movementStateInFrame;
GUILayout.Label($"movementStateInFrame={movementStateInFrame}", guistyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"movementStateInFrame={movementStateInFrame}", guistyle, Array.Empty<GUILayoutOption>());
var guistyle2 = new GUIStyle(GUI.skin.toggle) var guistyle2 = new GUIStyle(GUI.skin.toggle)
@@ -94,8 +90,7 @@ internal class AutoPilotDebugUI
}; };
GUI.changed = false; GUI.changed = false;
AutoPilotPlugin.Conf.IgnoreGravityFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.IgnoreGravityFlag, "Ignore gravity.", guistyle2, Array.Empty<GUILayoutOption>()); AutoPilotPlugin.Conf.IgnoreGravityFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.IgnoreGravityFlag, "Ignore gravity.", guistyle2, Array.Empty<GUILayoutOption>());
var changed = GUI.changed; if (GUI.changed)
if (changed)
{ {
VFAudio.Create("ui-click-0", null, Vector3.zero, true); VFAudio.Create("ui-click-0", null, Vector3.zero, true);
} }
@@ -104,36 +99,28 @@ internal class AutoPilotDebugUI
GUI.DragWindow(); GUI.DragWindow();
} }
public static string RangeToString(double range) private static string RangeToString(double range)
{ {
var flag = range < 10000.0; if (range < 10000.0)
string text;
if (flag)
{ {
text = ((int)(range + 0.5)) + "m "; return (int)(range + 0.5) + "m ";
} }
else
if (range < 600000.0)
{ {
var flag2 = range < 600000.0; return (range / 40000.0).ToString("0.00") + "AU";
if (flag2)
{
text = (range / 40000.0).ToString("0.00") + "AU";
}
else
{
text = (range / 2400000.0).ToString("0.00") + "Ly";
}
} }
return text;
return (range / 2400000.0).ToString("0.00") + "Ly";
} }
public static bool Show = false; public static bool Show = false;
public static Rect Rect = new Rect(0f, 0f, 400f, 400f); public static Rect Rect = new(0f, 0f, 400f, 400f);
private static float lastCheckWindowLeft = float.MinValue; private static float _lastCheckWindowLeft = float.MinValue;
private static float lastCheckWindowTop = float.MinValue; private static float _lastCheckWindowTop = float.MinValue;
private static Vector2 scrollPos = Vector2.zero; private static Vector2 _scrollPos = Vector2.zero;
} }

View File

@@ -8,81 +8,77 @@ using UnityEngine;
namespace AutoPilot.UI; namespace AutoPilot.UI;
internal class AutoPilotMainUI internal static class AutoPilotMainUI
{ {
public static void OnGUI() public static void OnGUI()
{ {
wIdx = CruiseAssistMainUI.WIdx; _wIdx = CruiseAssistMainUI.WIdx;
var viewMode = CruiseAssistMainUI.ViewMode; var viewMode = CruiseAssistMainUI.ViewMode;
var cruiseAssistMainUIViewMode = viewMode; if (viewMode != CruiseAssistMainUIViewMode.Full)
if (cruiseAssistMainUIViewMode != CruiseAssistMainUIViewMode.Full)
{ {
if (cruiseAssistMainUIViewMode == CruiseAssistMainUIViewMode.Mini) if (viewMode == CruiseAssistMainUIViewMode.Mini)
{ {
Rect[wIdx].width = CruiseAssistMainUI.Rect[wIdx].width; Rect[_wIdx].width = CruiseAssistMainUI.Rect[_wIdx].width;
Rect[wIdx].height = 70f; Rect[_wIdx].height = 70f;
} }
} }
else else
{ {
Rect[wIdx].width = CruiseAssistMainUI.Rect[wIdx].width; Rect[_wIdx].width = CruiseAssistMainUI.Rect[_wIdx].width;
Rect[wIdx].height = 150f; Rect[_wIdx].height = 150f;
} }
var guistyle = new GUIStyle(CruiseAssistMainUI.WindowStyle) var guistyle = new GUIStyle(CruiseAssistMainUI.WindowStyle)
{ {
fontSize = 11 fontSize = 11
}; };
Rect[wIdx] = GUILayout.Window(99031291, Rect[wIdx], WindowFunction, "AutoPilot", guistyle, Array.Empty<GUILayoutOption>()); Rect[_wIdx] = GUILayout.Window(99031291, Rect[_wIdx], WindowFunction, "AutoPilot", guistyle, Array.Empty<GUILayoutOption>());
var num = CruiseAssistMainUI.Scale / 100f; var scale = CruiseAssistMainUI.Scale / 100f;
var mainWindowJoinFlag = AutoPilotPlugin.Conf.MainWindowJoinFlag; if (AutoPilotPlugin.Conf.MainWindowJoinFlag)
if (mainWindowJoinFlag)
{ {
Rect[wIdx].x = CruiseAssistMainUI.Rect[CruiseAssistMainUI.WIdx].x; Rect[_wIdx].x = CruiseAssistMainUI.Rect[CruiseAssistMainUI.WIdx].x;
Rect[wIdx].y = CruiseAssistMainUI.Rect[CruiseAssistMainUI.WIdx].yMax; Rect[_wIdx].y = CruiseAssistMainUI.Rect[CruiseAssistMainUI.WIdx].yMax;
} }
var flag = Screen.width / num < Rect[wIdx].xMax;
if (flag) if (Screen.width / scale < Rect[_wIdx].xMax)
{ {
Rect[wIdx].x = Screen.width / num - Rect[wIdx].width; Rect[_wIdx].x = Screen.width / scale - Rect[_wIdx].width;
} }
var flag2 = Rect[wIdx].x < 0f;
if (flag2) if (Rect[_wIdx].x < 0f)
{ {
Rect[wIdx].x = 0f; Rect[_wIdx].x = 0f;
} }
var flag3 = Screen.height / num < Rect[wIdx].yMax;
if (flag3) if (Screen.height / scale < Rect[_wIdx].yMax)
{ {
Rect[wIdx].y = Screen.height / num - Rect[wIdx].height; Rect[_wIdx].y = Screen.height / scale - Rect[_wIdx].height;
} }
var flag4 = Rect[wIdx].y < 0f;
if (flag4) if (Rect[_wIdx].y < 0f)
{ {
Rect[wIdx].y = 0f; Rect[_wIdx].y = 0f;
} }
var flag5 = lastCheckWindowLeft[wIdx] != float.MinValue;
if (flag5) if (LastCheckWindowLeft[_wIdx] != float.MinValue)
{ {
var flag6 = Rect[wIdx].x != lastCheckWindowLeft[wIdx] || Rect[wIdx].y != lastCheckWindowTop[wIdx]; var flag6 = Rect[_wIdx].x != LastCheckWindowLeft[_wIdx] || Rect[_wIdx].y != LastCheckWindowTop[_wIdx];
if (flag6) if (flag6)
{ {
NextCheckGameTick = GameMain.gameTick + 300L; NextCheckGameTick = GameMain.gameTick + 300L;
} }
} }
lastCheckWindowLeft[wIdx] = Rect[wIdx].x; LastCheckWindowLeft[_wIdx] = Rect[_wIdx].x;
lastCheckWindowTop[wIdx] = Rect[wIdx].y; LastCheckWindowTop[_wIdx] = Rect[_wIdx].y;
var flag7 = NextCheckGameTick <= GameMain.gameTick; if (NextCheckGameTick <= GameMain.gameTick)
if (flag7)
{ {
ConfigManager.CheckConfig(ConfigManager.Step.State); ConfigManager.CheckConfig(ConfigManager.Step.State);
} }
} }
public static void WindowFunction(int windowId) private static void WindowFunction(int windowId)
{ {
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
var flag = CruiseAssistMainUI.ViewMode == CruiseAssistMainUIViewMode.Full; if (CruiseAssistMainUI.ViewMode == CruiseAssistMainUIViewMode.Full)
if (flag)
{ {
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
var guistyle = new GUIStyle(GUI.skin.label) var guistyle = new GUIStyle(GUI.skin.label)
@@ -116,8 +112,7 @@ internal class AutoPilotMainUI
fontSize = 14, fontSize = 14,
alignment = TextAnchor.MiddleLeft alignment = TextAnchor.MiddleLeft
}; };
var flag2 = AutoPilotPlugin.State == AutoPilotState.Inactive; if (AutoPilotPlugin.State == AutoPilotState.Inactive)
if (flag2)
{ {
GUILayout.Label("Auto Pilot Inactive.", guistyle2, Array.Empty<GUILayoutOption>()); GUILayout.Label("Auto Pilot Inactive.", guistyle2, Array.Empty<GUILayoutOption>());
} }
@@ -135,14 +130,13 @@ internal class AutoPilotMainUI
alignment = TextAnchor.MiddleCenter alignment = TextAnchor.MiddleCenter
}; };
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
var flag3 = GUILayout.Button("Config", guistyle3, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Config", guistyle3, Array.Empty<GUILayoutOption>()))
if (flag3)
{ {
VFAudio.Create("ui-click-0", null, Vector3.zero, true); VFAudio.Create("ui-click-0", null, Vector3.zero, true);
var show = AutoPilotConfigUI.Show; var show = AutoPilotConfigUI.Show;
var num = wIdx; var num = _wIdx;
show[num] = !show[num]; show[num] = !show[num];
var flag4 = AutoPilotConfigUI.Show[wIdx]; var flag4 = AutoPilotConfigUI.Show[_wIdx];
if (flag4) if (flag4)
{ {
AutoPilotConfigUI.TempMinEnergyPer = AutoPilotPlugin.Conf.MinEnergyPer.ToString(); AutoPilotConfigUI.TempMinEnergyPer = AutoPilotPlugin.Conf.MinEnergyPer.ToString();
@@ -151,8 +145,8 @@ internal class AutoPilotMainUI
AutoPilotConfigUI.TempSpeedToWarp = AutoPilotPlugin.Conf.SpeedToWarp.ToString(); AutoPilotConfigUI.TempSpeedToWarp = AutoPilotPlugin.Conf.SpeedToWarp.ToString();
} }
} }
var flag5 = GUILayout.Button("Start", guistyle3, Array.Empty<GUILayoutOption>());
if (flag5) if (GUILayout.Button("Start", guistyle3, Array.Empty<GUILayoutOption>()))
{ {
VFAudio.Create("ui-click-0", null, Vector3.zero, true); VFAudio.Create("ui-click-0", null, Vector3.zero, true);
AutoPilotPlugin.State = AutoPilotState.Active; AutoPilotPlugin.State = AutoPilotState.Active;
@@ -160,8 +154,7 @@ internal class AutoPilotMainUI
GUILayout.EndVertical(); GUILayout.EndVertical();
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Button("-", guistyle3, Array.Empty<GUILayoutOption>()); GUILayout.Button("-", guistyle3, Array.Empty<GUILayoutOption>());
var flag6 = GUILayout.Button("Stop", guistyle3, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Stop", guistyle3, Array.Empty<GUILayoutOption>()))
if (flag6)
{ {
VFAudio.Create("ui-click-0", null, Vector3.zero, true); VFAudio.Create("ui-click-0", null, Vector3.zero, true);
AutoPilotPlugin.State = AutoPilotState.Inactive; AutoPilotPlugin.State = AutoPilotState.Inactive;
@@ -172,7 +165,7 @@ internal class AutoPilotMainUI
GUI.DragWindow(); GUI.DragWindow();
} }
private static int wIdx; private static int _wIdx;
public const float WindowWidthFull = 398f; public const float WindowWidthFull = 398f;
@@ -182,14 +175,14 @@ internal class AutoPilotMainUI
public const float WindowHeightMini = 70f; public const float WindowHeightMini = 70f;
public static Rect[] Rect = { public static readonly Rect[] Rect = {
new Rect(0f, 0f, 398f, 150f), new Rect(0f, 0f, 398f, 150f),
new Rect(0f, 0f, 398f, 150f) new Rect(0f, 0f, 398f, 150f)
}; };
private static float[] lastCheckWindowLeft = { float.MinValue, float.MinValue }; private static readonly float[] LastCheckWindowLeft = { float.MinValue, float.MinValue };
private static float[] lastCheckWindowTop = { float.MinValue, float.MinValue }; private static readonly float[] LastCheckWindowTop = { float.MinValue, float.MinValue };
public static long NextCheckGameTick = long.MaxValue; public static long NextCheckGameTick = long.MaxValue;
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.