mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-18 20:43:30 +08:00
WIP
This commit is contained in:
@@ -1,15 +1,35 @@
|
||||
using System;
|
||||
using CruiseAssist.UI;
|
||||
using CruiseAssist.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AutoPilot.UI;
|
||||
|
||||
internal static class AutoPilotConfigUI
|
||||
{
|
||||
public static void OnInit()
|
||||
{
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedHeight = 20f,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
_textFieldStyle = new GUIStyle(CruiseAssistMainUI.BaseTextFieldStyle)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedWidth = 60f
|
||||
};
|
||||
_toggleStyle = new GUIStyle(CruiseAssistMainUI.BaseToggleStyle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
Rect[_wIdx] = GUILayout.Window(99031292, Rect[_wIdx], WindowFunction, "AutoPilot - Config", CruiseAssistMainUI.WindowStyle, Array.Empty<GUILayoutOption>());
|
||||
Rect[_wIdx] = GUILayout.Window(99031292, Rect[_wIdx], WindowFunction, "AutoPilot - " + Strings.Get(0), CruiseAssistMainUI.WindowStyle);
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
if (Screen.width / scale < Rect[_wIdx].xMax)
|
||||
{
|
||||
@@ -42,76 +62,59 @@ internal static class AutoPilotConfigUI
|
||||
LastCheckWindowTop[_wIdx] = Rect[_wIdx].y;
|
||||
}
|
||||
|
||||
public static void WindowFunction(int windowId)
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedHeight = 20f,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
var guistyle2 = new GUIStyle(CruiseAssistMainUI.BaseTextFieldStyle)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedWidth = 60f
|
||||
};
|
||||
guistyle.fixedHeight = 20f;
|
||||
guistyle2.alignment = TextAnchor.MiddleRight;
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Min Energy Percent (0-100 default:20)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
_labelStyle.fixedHeight = 20f;
|
||||
_textFieldStyle.alignment = TextAnchor.MiddleRight;
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(15), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempMinEnergyPer, GUILayout.TextField(TempMinEnergyPer, guistyle2, Array.Empty<GUILayoutOption>()), 0, 100, ref AutoPilotPlugin.Conf.MinEnergyPer);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("%", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempMinEnergyPer, GUILayout.TextField(TempMinEnergyPer, _textFieldStyle), 0, 100, ref AutoPilotPlugin.Conf.MinEnergyPer);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("%", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Max Speed (0-2000 default:2000)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(16), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempMaxSpeed, GUILayout.TextField(TempMaxSpeed, guistyle2, Array.Empty<GUILayoutOption>()), 0, 2000, ref AutoPilotPlugin.Conf.MaxSpeed);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempMaxSpeed, GUILayout.TextField(TempMaxSpeed, _textFieldStyle), 0, 2000, ref AutoPilotPlugin.Conf.MaxSpeed);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Warp Min Range (1-60 default:2)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(17), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempWarpMinRangeAU, GUILayout.TextArea(TempWarpMinRangeAU, guistyle2, Array.Empty<GUILayoutOption>()), 1, 60, ref AutoPilotPlugin.Conf.WarpMinRangeAU);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("AU", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempWarpMinRangeAu, GUILayout.TextArea(TempWarpMinRangeAu, _textFieldStyle), 1, 60, ref AutoPilotPlugin.Conf.WarpMinRangeAu);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("AU", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Speed to warp (0-2000 default:1200)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(18), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempSpeedToWarp, GUILayout.TextArea(TempSpeedToWarp, guistyle2, Array.Empty<GUILayoutOption>()), 0, 2000, ref AutoPilotPlugin.Conf.SpeedToWarp);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempSpeedToWarp, GUILayout.TextArea(TempSpeedToWarp, _textFieldStyle), 0, 2000, ref AutoPilotPlugin.Conf.SpeedToWarp);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
var guistyle3 = new GUIStyle(CruiseAssistMainUI.BaseToggleStyle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
GUI.changed = false;
|
||||
AutoPilotPlugin.Conf.LocalWarpFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.LocalWarpFlag, "Warp to planet in local system.".Translate(), guistyle3, Array.Empty<GUILayoutOption>());
|
||||
AutoPilotPlugin.Conf.LocalWarpFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.LocalWarpFlag, Strings.Get(19), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
AutoPilotPlugin.Conf.AutoStartFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.AutoStartFlag, "Start AutoPilot when set target planet.".Translate(), guistyle3, Array.Empty<GUILayoutOption>());
|
||||
AutoPilotPlugin.Conf.AutoStartFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.AutoStartFlag, Strings.Get(20), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
AutoPilotPlugin.Conf.MainWindowJoinFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.MainWindowJoinFlag, "Join AutoPilot window to CruiseAssist window.".Translate(), guistyle3, Array.Empty<GUILayoutOption>());
|
||||
AutoPilotPlugin.Conf.MainWindowJoinFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.MainWindowJoinFlag, Strings.Get(21), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -149,6 +152,10 @@ internal static class AutoPilotConfigUI
|
||||
|
||||
}
|
||||
|
||||
private static GUIStyle _labelStyle;
|
||||
private static GUIStyle _textFieldStyle;
|
||||
private static GUIStyle _toggleStyle;
|
||||
|
||||
private static int _wIdx;
|
||||
|
||||
public const float WindowWidth = 400f;
|
||||
@@ -157,20 +164,21 @@ internal static class AutoPilotConfigUI
|
||||
|
||||
public static readonly bool[] Show = new bool[2];
|
||||
|
||||
public static readonly Rect[] Rect = {
|
||||
new Rect(0f, 0f, 400f, 400f),
|
||||
new Rect(0f, 0f, 400f, 400f)
|
||||
};
|
||||
public static readonly Rect[] Rect =
|
||||
[
|
||||
new(0f, 0f, 400f, 400f),
|
||||
new(0f, 0f, 400f, 400f)
|
||||
];
|
||||
|
||||
private static readonly float[] LastCheckWindowLeft = { float.MinValue, float.MinValue };
|
||||
private static readonly float[] LastCheckWindowLeft = [float.MinValue, float.MinValue];
|
||||
|
||||
private static readonly float[] LastCheckWindowTop = { float.MinValue, float.MinValue };
|
||||
private static readonly float[] LastCheckWindowTop = [float.MinValue, float.MinValue];
|
||||
|
||||
public static string TempMinEnergyPer;
|
||||
|
||||
public static string TempMaxSpeed;
|
||||
|
||||
public static string TempWarpMinRangeAU;
|
||||
public static string TempWarpMinRangeAu;
|
||||
|
||||
public static string TempSpeedToWarp;
|
||||
}
|
||||
@@ -1,20 +1,32 @@
|
||||
using System;
|
||||
using AutoPilot.Commons;
|
||||
using AutoPilot.Commons;
|
||||
using CruiseAssist;
|
||||
using CruiseAssist.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AutoPilot.UI;
|
||||
|
||||
internal static class AutoPilotDebugUI
|
||||
{
|
||||
public static void OnGUI()
|
||||
public static void OnInit()
|
||||
{
|
||||
var guistyle = new GUIStyle(GUI.skin.window)
|
||||
_windowStyle = new GUIStyle(GUI.skin.window)
|
||||
{
|
||||
fontSize = 11
|
||||
};
|
||||
Rect = GUILayout.Window(99031293, Rect, WindowFunction, "AutoPilot - Debug", guistyle, Array.Empty<GUILayoutOption>());
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
_toggleStyle = new GUIStyle(GUI.skin.toggle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
Rect = GUILayout.Window(99031293, Rect, WindowFunction, "AutoPilot - Debug", _windowStyle);
|
||||
|
||||
if (Screen.width < Rect.xMax)
|
||||
{
|
||||
@@ -53,13 +65,9 @@ internal static class AutoPilotDebugUI
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
_scrollPos = GUILayout.BeginScrollView(_scrollPos, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.uPosition={GameMain.mainPlayer.uPosition}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
_scrollPos = GUILayout.BeginScrollView(_scrollPos);
|
||||
GUILayout.Label($"GameMain.mainPlayer.uPosition={GameMain.mainPlayer.uPosition}", _labelStyle);
|
||||
if (GameMain.localPlanet != null && CruiseAssistPlugin.TargetUPos != VectorLF3.zero)
|
||||
{
|
||||
var mainPlayer = GameMain.mainPlayer;
|
||||
@@ -68,28 +76,22 @@ internal static class AutoPilotDebugUI
|
||||
var magnitude2 = (targetUPos - GameMain.localPlanet.uPosition).magnitude;
|
||||
var vectorLF = mainPlayer.uPosition - GameMain.localPlanet.uPosition;
|
||||
var vectorLF2 = CruiseAssistPlugin.TargetUPos - GameMain.localPlanet.uPosition;
|
||||
GUILayout.Label("range1=" + RangeToString(magnitude), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("range2=" + RangeToString(magnitude2), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"range1>range2={magnitude > magnitude2}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"angle={Vector3.Angle(vectorLF, vectorLF2)}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("range1=" + RangeToString(magnitude), _labelStyle);
|
||||
GUILayout.Label("range2=" + RangeToString(magnitude2), _labelStyle);
|
||||
GUILayout.Label($"range1>range2={magnitude > magnitude2}", _labelStyle);
|
||||
GUILayout.Label($"angle={Vector3.Angle(vectorLF, vectorLF2)}", _labelStyle);
|
||||
}
|
||||
var mecha = GameMain.mainPlayer.mecha;
|
||||
GUILayout.Label($"mecha.coreEnergy={mecha.coreEnergy}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"mecha.coreEnergyCap={mecha.coreEnergyCap}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"mecha.coreEnergy={mecha.coreEnergy}", _labelStyle);
|
||||
GUILayout.Label($"mecha.coreEnergyCap={mecha.coreEnergyCap}", _labelStyle);
|
||||
var energyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
GUILayout.Label($"energyPer={energyPer}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"energyPer={energyPer}", _labelStyle);
|
||||
var speed = GameMain.mainPlayer.controller.actionSail.visual_uvel.magnitude;
|
||||
GUILayout.Label("spped=" + RangeToString(speed), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("spped=" + RangeToString(speed), _labelStyle);
|
||||
var movementStateInFrame = GameMain.mainPlayer.controller.movementStateInFrame;
|
||||
GUILayout.Label($"movementStateInFrame={movementStateInFrame}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
var guistyle2 = new GUIStyle(GUI.skin.toggle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
GUILayout.Label($"movementStateInFrame={movementStateInFrame}", _labelStyle);
|
||||
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.", _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -114,6 +116,10 @@ internal static class AutoPilotDebugUI
|
||||
return (range / 2400000.0).ToString("0.00") + "Ly";
|
||||
}
|
||||
|
||||
private static GUIStyle _windowStyle;
|
||||
private static GUIStyle _labelStyle;
|
||||
private static GUIStyle _toggleStyle;
|
||||
|
||||
public static bool Show = false;
|
||||
|
||||
public static Rect Rect = new(0f, 0f, 400f, 400f);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using AutoPilot.Commons;
|
||||
using AutoPilot.Commons;
|
||||
using AutoPilot.Enums;
|
||||
using CruiseAssist;
|
||||
using CruiseAssist.Enums;
|
||||
@@ -10,6 +9,45 @@ namespace AutoPilot.UI;
|
||||
|
||||
internal static class AutoPilotMainUI
|
||||
{
|
||||
public static void OnInit()
|
||||
{
|
||||
_windowStyle = new GUIStyle(CruiseAssistMainUI.WindowStyle)
|
||||
{
|
||||
fontSize = 11
|
||||
};
|
||||
|
||||
_baseLabelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
|
||||
_highlightedLabelStyle = new GUIStyle(_baseLabelStyle)
|
||||
{
|
||||
normal = { textColor = Color.cyan }
|
||||
};
|
||||
|
||||
_ngLabelStyle = new GUIStyle(_baseLabelStyle)
|
||||
{
|
||||
normal = { textColor = Color.red }
|
||||
};
|
||||
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 160f,
|
||||
fixedHeight = 32f,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
|
||||
_buttonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 55f,
|
||||
fixedHeight = 18f,
|
||||
fontSize = 11,
|
||||
alignment = TextAnchor.MiddleCenter
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
@@ -27,11 +65,8 @@ internal static class AutoPilotMainUI
|
||||
Rect[_wIdx].width = CruiseAssistMainUI.Rect[_wIdx].width;
|
||||
Rect[_wIdx].height = 150f;
|
||||
}
|
||||
var guistyle = new GUIStyle(CruiseAssistMainUI.WindowStyle)
|
||||
{
|
||||
fontSize = 11
|
||||
};
|
||||
Rect[_wIdx] = GUILayout.Window(99031291, Rect[_wIdx], WindowFunction, "AutoPilot", guistyle, Array.Empty<GUILayoutOption>());
|
||||
|
||||
Rect[_wIdx] = GUILayout.Window(99031291, Rect[_wIdx], WindowFunction, "AutoPilot", _windowStyle);
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
if (AutoPilotPlugin.Conf.MainWindowJoinFlag)
|
||||
{
|
||||
@@ -61,12 +96,12 @@ internal static class AutoPilotMainUI
|
||||
|
||||
if (LastCheckWindowLeft[_wIdx] != float.MinValue)
|
||||
{
|
||||
var flag6 = Rect[_wIdx].x != LastCheckWindowLeft[_wIdx] || Rect[_wIdx].y != LastCheckWindowTop[_wIdx];
|
||||
if (flag6)
|
||||
if (Rect[_wIdx].x != LastCheckWindowLeft[_wIdx] || Rect[_wIdx].y != LastCheckWindowTop[_wIdx])
|
||||
{
|
||||
NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
|
||||
LastCheckWindowLeft[_wIdx] = Rect[_wIdx].x;
|
||||
LastCheckWindowTop[_wIdx] = Rect[_wIdx].y;
|
||||
if (NextCheckGameTick <= GameMain.gameTick)
|
||||
@@ -77,88 +112,137 @@ internal static class AutoPilotMainUI
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
if (CruiseAssistMainUI.ViewMode == CruiseAssistMainUIViewMode.Full)
|
||||
{
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(GUI.skin.label)
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.BeginVertical();
|
||||
int status;
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.EnergyPer <= AutoPilotPlugin.Conf.MinEnergyPer)
|
||||
status = 1;
|
||||
else
|
||||
status = 2;
|
||||
switch (status)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var text = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : ((AutoPilotPlugin.Conf.MinEnergyPer < AutoPilotPlugin.EnergyPer) ? "OK" : "NG"));
|
||||
guistyle.normal.textColor = ((text == "OK") ? Color.cyan : ((text == "NG") ? Color.red : Color.white));
|
||||
GUILayout.Label("Energy : " + text, guistyle, Array.Empty<GUILayoutOption>());
|
||||
var text2 = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : ((CruiseAssistPlugin.TargetStar == null) ? "---" : (GameMain.mainPlayer.warping ? "---" : ((!AutoPilotPlugin.Conf.LocalWarpFlag && GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id == GameMain.localStar.id) ? "---" : ((CruiseAssistPlugin.TargetRange < (double)(AutoPilotPlugin.Conf.WarpMinRangeAU * 40000)) ? "---" : ((AutoPilotPlugin.WarperCount < 1) ? "NG" : "OK"))))));
|
||||
guistyle.normal.textColor = ((text2 == "OK") ? Color.cyan : ((text2 == "NG") ? Color.red : Color.white));
|
||||
GUILayout.Label("Warper : " + text2, guistyle, Array.Empty<GUILayoutOption>());
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(3) + " : " + Strings.Get(7), _ngLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(3) + " : " + Strings.Get(8), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(3) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive || CruiseAssistPlugin.TargetStar == null || GameMain.mainPlayer.warping ||
|
||||
(!AutoPilotPlugin.Conf.LocalWarpFlag && GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id == GameMain.localStar.id) ||
|
||||
CruiseAssistPlugin.TargetRange < AutoPilotPlugin.Conf.WarpMinRangeAu * 40000)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.WarperCount < 1)
|
||||
status = 1;
|
||||
else
|
||||
status = 2;
|
||||
switch (status)
|
||||
{
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(4) + " : " + Strings.Get(7), _ngLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(4) + " : " + Strings.Get(8), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(4) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var text3 = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : (AutoPilotPlugin.LeavePlanet ? "ON" : "OFF"));
|
||||
guistyle.normal.textColor = ((text3 == "ON") ? Color.cyan : Color.white);
|
||||
GUILayout.Label("Leave Planet : " + text3, guistyle, Array.Empty<GUILayoutOption>());
|
||||
var text4 = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : (AutoPilotPlugin.SpeedUp ? "ON" : "OFF"));
|
||||
guistyle.normal.textColor = ((text4 == "ON") ? Color.cyan : Color.white);
|
||||
GUILayout.Label("Spee UP : " + text4, guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.LeavePlanet)
|
||||
status = 2;
|
||||
else
|
||||
status = 1;
|
||||
switch (status)
|
||||
{
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(5) + " : " + Strings.Get(10), _baseLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(5) + " : " + Strings.Get(9), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(5) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.SpeedUp)
|
||||
status = 2;
|
||||
else
|
||||
status = 1;
|
||||
switch (status)
|
||||
{
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(6) + " : " + Strings.Get(12), _baseLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(6) + " : " + Strings.Get(11), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(6) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var guistyle2 = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 160f,
|
||||
fixedHeight = 32f,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
{
|
||||
GUILayout.Label("Auto Pilot Inactive.", guistyle2, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(Strings.Get(13), _labelStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
guistyle2.normal.textColor = Color.cyan;
|
||||
GUILayout.Label("Auto Pilot Active.", guistyle2, Array.Empty<GUILayoutOption>());
|
||||
_labelStyle.normal.textColor = Color.cyan;
|
||||
GUILayout.Label(Strings.Get(14), _labelStyle);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
var guistyle3 = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 50f,
|
||||
fixedHeight = 18f,
|
||||
fontSize = 11,
|
||||
alignment = TextAnchor.MiddleCenter
|
||||
};
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("Config", guistyle3, Array.Empty<GUILayoutOption>()))
|
||||
GUILayout.BeginVertical();
|
||||
if (GUILayout.Button(Strings.Get(0), _buttonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
var show = AutoPilotConfigUI.Show;
|
||||
var num = _wIdx;
|
||||
show[num] = !show[num];
|
||||
var flag4 = AutoPilotConfigUI.Show[_wIdx];
|
||||
if (flag4)
|
||||
if (AutoPilotConfigUI.Show[_wIdx])
|
||||
{
|
||||
AutoPilotConfigUI.TempMinEnergyPer = AutoPilotPlugin.Conf.MinEnergyPer.ToString();
|
||||
AutoPilotConfigUI.TempMaxSpeed = AutoPilotPlugin.Conf.MaxSpeed.ToString();
|
||||
AutoPilotConfigUI.TempWarpMinRangeAU = AutoPilotPlugin.Conf.WarpMinRangeAU.ToString();
|
||||
AutoPilotConfigUI.TempWarpMinRangeAu = AutoPilotPlugin.Conf.WarpMinRangeAu.ToString();
|
||||
AutoPilotConfigUI.TempSpeedToWarp = AutoPilotPlugin.Conf.SpeedToWarp.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Start", guistyle3, Array.Empty<GUILayoutOption>()))
|
||||
if (GUILayout.Button(Strings.Get(1), _buttonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotPlugin.State = AutoPilotState.Active;
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Button("-", guistyle3, Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("Stop", guistyle3, Array.Empty<GUILayoutOption>()))
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Button("-", _buttonStyle);
|
||||
if (GUILayout.Button(Strings.Get(2), _buttonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotPlugin.State = AutoPilotState.Inactive;
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
@@ -167,22 +251,30 @@ internal static class AutoPilotMainUI
|
||||
|
||||
private static int _wIdx;
|
||||
|
||||
public const float WindowWidthFull = 398f;
|
||||
public const float WindowWidthFull = 408f;
|
||||
|
||||
public const float WindowHeightFull = 150f;
|
||||
|
||||
public const float WindowWidthMini = 288f;
|
||||
public const float WindowWidthMini = 298f;
|
||||
|
||||
public const float WindowHeightMini = 70f;
|
||||
|
||||
public static readonly Rect[] Rect = {
|
||||
public static readonly Rect[] Rect =
|
||||
[
|
||||
new Rect(0f, 0f, 398f, 150f),
|
||||
new Rect(0f, 0f, 398f, 150f)
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly float[] LastCheckWindowLeft = { float.MinValue, float.MinValue };
|
||||
private static GUIStyle _windowStyle;
|
||||
private static GUIStyle _baseLabelStyle;
|
||||
private static GUIStyle _highlightedLabelStyle;
|
||||
private static GUIStyle _ngLabelStyle;
|
||||
private static GUIStyle _labelStyle;
|
||||
private static GUIStyle _buttonStyle;
|
||||
|
||||
private static readonly float[] LastCheckWindowTop = { float.MinValue, float.MinValue };
|
||||
private static readonly float[] LastCheckWindowLeft = [float.MinValue, float.MinValue];
|
||||
|
||||
private static readonly float[] LastCheckWindowTop = [float.MinValue, float.MinValue];
|
||||
|
||||
public static long NextCheckGameTick = long.MaxValue;
|
||||
}
|
||||
91
AutoPilot/UI/StringsUI.cs
Normal file
91
AutoPilot/UI/StringsUI.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using CruiseAssist.Commons;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace AutoPilot.UI;
|
||||
|
||||
public static class Strings
|
||||
{
|
||||
private static readonly string[] EngUs = [
|
||||
// 0
|
||||
"Config",
|
||||
"Start",
|
||||
"Stop",
|
||||
"Energy",
|
||||
"Warper",
|
||||
// 5
|
||||
"Leaving Planet",
|
||||
"Speed UP",
|
||||
"NG",
|
||||
"OK",
|
||||
"YES",
|
||||
// 10
|
||||
"NO",
|
||||
"ON",
|
||||
"OFF",
|
||||
"Auto Pilot Inactive.",
|
||||
"Auto Pilot Active.",
|
||||
// 15
|
||||
"Min Energy Percent (0-100 default:20)",
|
||||
"Max Speed (0-2000 default:2000)",
|
||||
"Warp Min Range (1-60 default:2)",
|
||||
"Speed to warp (0-2000 default:1200)",
|
||||
"Warp to planet in local system.",
|
||||
// 20
|
||||
"Start AutoPilot when set target planet.",
|
||||
"Join AutoPilot window to CruiseAssist window.",
|
||||
];
|
||||
|
||||
private static readonly string[] ZhoCn =
|
||||
[
|
||||
// 0
|
||||
"设置",
|
||||
"开始",
|
||||
"停止",
|
||||
"能量",
|
||||
"翘曲",
|
||||
// 5
|
||||
"离开行星",
|
||||
"加速",
|
||||
"不足",
|
||||
"OK",
|
||||
"是",
|
||||
// 10
|
||||
"否",
|
||||
"开",
|
||||
"关",
|
||||
"Auto Pilot 未在工作",
|
||||
"Auto Pilot 正在工作",
|
||||
// 15
|
||||
"最小能量百分比 (0-100 默认:20)",
|
||||
"最大速度 (0-2000 默认:2000)",
|
||||
"启用曲速最小距离 (1-60 默认:2)",
|
||||
"航行速度达到此值时启动曲速 (0-2000 默认:1200)",
|
||||
"即使本星系的行星也允许曲速",
|
||||
// 20
|
||||
"设置目标行星后立即开始导航",
|
||||
"合并 AutoPilot 和 CruiseAssist 窗口",
|
||||
];
|
||||
|
||||
public static Action OnLanguageChanged;
|
||||
|
||||
private static string[] _langStr = EngUs;
|
||||
|
||||
public static string Get(int index) => _langStr[index];
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(Localization), nameof(Localization.LoadSettings))]
|
||||
[HarmonyPatch(typeof(Localization), nameof(Localization.LoadLanguage))]
|
||||
[HarmonyPatch(typeof(Localization), nameof(Localization.NotifyLanguageChange))]
|
||||
private static void Localization_LanguageChanged_Postfix()
|
||||
{
|
||||
var newstr = Localization.Languages[Localization.currentLanguageIndex].lcId switch
|
||||
{
|
||||
2052 => ZhoCn,
|
||||
_ => EngUs
|
||||
};
|
||||
if (newstr == _langStr) return;
|
||||
_langStr = newstr;
|
||||
OnLanguageChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user