mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2026-02-04 22:22:22 +08:00
WIP
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AssemblyName>AutoPilot</AssemblyName>
|
||||
<BepInExPluginGuid>tanu.AutoPilot</BepInExPluginGuid>
|
||||
<BepInExPluginGuid>org.soardev.AutoPilot</BepInExPluginGuid>
|
||||
<Description>DSP MOD - AutoPilot</Description>
|
||||
<Version>0.0.4</Version>
|
||||
<Version>0.1.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
|
||||
@@ -6,27 +6,29 @@ namespace AutoPilot;
|
||||
|
||||
internal class AutoPilotConfigManager : ConfigManager
|
||||
{
|
||||
internal AutoPilotConfigManager(ConfigFile Config)
|
||||
: base(Config)
|
||||
public static void Init(ConfigFile config)
|
||||
{
|
||||
ConfigManager.Init<AutoPilotConfigManager>(config);
|
||||
}
|
||||
|
||||
protected override void CheckConfigImplements(Step step)
|
||||
{
|
||||
var ok = false;
|
||||
if (step == Step.Awake)
|
||||
switch (step)
|
||||
{
|
||||
case Step.Awake:
|
||||
{
|
||||
var configEntry = Bind("Base", "ModVersion", "0.0.4", "Don't change.");
|
||||
configEntry.Value = "0.0.4";
|
||||
ok = true;
|
||||
goto case Step.GameMainBegin;
|
||||
}
|
||||
|
||||
if (step is Step.Awake or Step.GameMainBegin)
|
||||
case Step.GameMainBegin:
|
||||
{
|
||||
AutoPilotDebugUI.Show = Bind("Debug", "DebugWindowShow", false).Value;
|
||||
AutoPilotPlugin.Conf.MinEnergyPer = Bind("Setting", "MinEnergyPer", 20).Value;
|
||||
AutoPilotPlugin.Conf.MaxSpeed = Bind("Setting", "MaxSpeed", 2000).Value;
|
||||
AutoPilotPlugin.Conf.WarpMinRangeAU = Bind("Setting", "WarpMinRangeAU", 2).Value;
|
||||
AutoPilotPlugin.Conf.WarpMinRangeAu = Bind("Setting", "WarpMinRangeAU", 2).Value;
|
||||
AutoPilotPlugin.Conf.SpeedToWarp = Bind("Setting", "WarpSpeed", 1200).Value;
|
||||
AutoPilotPlugin.Conf.LocalWarpFlag = Bind("Setting", "LocalWarp", false).Value;
|
||||
AutoPilotPlugin.Conf.AutoStartFlag = Bind("Setting", "AutoStart", true).Value;
|
||||
@@ -40,13 +42,14 @@ internal class AutoPilotConfigManager : ConfigManager
|
||||
}
|
||||
AutoPilotDebugUI.Rect.x = Bind("State", "DebugWindowLeft", 100).Value;
|
||||
AutoPilotDebugUI.Rect.y = Bind("State", "DebugWindowTop", 100).Value;
|
||||
break;
|
||||
}
|
||||
else if (step == Step.State)
|
||||
case Step.State:
|
||||
{
|
||||
LogManager.LogInfo("check state.");
|
||||
ok |= UpdateEntry("Setting", "MinEnergyPer", AutoPilotPlugin.Conf.MinEnergyPer);
|
||||
ok |= UpdateEntry("Setting", "MaxSpeed", AutoPilotPlugin.Conf.MaxSpeed);
|
||||
ok |= UpdateEntry("Setting", "WarpMinRangeAU", AutoPilotPlugin.Conf.WarpMinRangeAU);
|
||||
ok |= UpdateEntry("Setting", "WarpMinRangeAU", AutoPilotPlugin.Conf.WarpMinRangeAu);
|
||||
ok |= UpdateEntry("Setting", "WarpSpeed", AutoPilotPlugin.Conf.SpeedToWarp);
|
||||
ok |= UpdateEntry("Setting", "LocalWarp", AutoPilotPlugin.Conf.LocalWarpFlag);
|
||||
ok |= UpdateEntry("Setting", "AutoStart", AutoPilotPlugin.Conf.AutoStartFlag);
|
||||
@@ -61,6 +64,12 @@ internal class AutoPilotConfigManager : ConfigManager
|
||||
ok |= UpdateEntry("State", "DebugWindowLeft", (int)AutoPilotDebugUI.Rect.x);
|
||||
ok |= UpdateEntry("State", "DebugWindowTop", (int)AutoPilotDebugUI.Rect.y);
|
||||
AutoPilotMainUI.NextCheckGameTick = long.MaxValue;
|
||||
break;
|
||||
}
|
||||
case Step.UniverseGenCreateGalaxy:
|
||||
case Step.ChangeSeed:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
|
||||
@@ -19,7 +19,7 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
|
||||
public void SetTargetAstroId(int astroId)
|
||||
{
|
||||
AutoPilotPlugin.State = (AutoPilotPlugin.Conf.AutoStartFlag ? AutoPilotState.Active : AutoPilotState.Inactive);
|
||||
AutoPilotPlugin.State = AutoPilotPlugin.Conf.AutoStartFlag ? AutoPilotState.Active : AutoPilotState.Inactive;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
}
|
||||
|
||||
@@ -33,17 +33,16 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = true;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
var ignoreGravityFlag = AutoPilotPlugin.Conf.IgnoreGravityFlag;
|
||||
if (ignoreGravityFlag)
|
||||
if (AutoPilotPlugin.Conf.IgnoreGravityFlag)
|
||||
{
|
||||
player.controller.universalGravity = VectorLF3.zero;
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
__instance.controller.input0.z = 1f;
|
||||
return true;
|
||||
}
|
||||
@@ -58,17 +57,16 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = true;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
var ignoreGravityFlag = AutoPilotPlugin.Conf.IgnoreGravityFlag;
|
||||
if (ignoreGravityFlag)
|
||||
if (AutoPilotPlugin.Conf.IgnoreGravityFlag)
|
||||
{
|
||||
player.controller.universalGravity = VectorLF3.zero;
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
__instance.controller.input0.z = 1f;
|
||||
return true;
|
||||
}
|
||||
@@ -83,21 +81,19 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = true;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
var ignoreGravityFlag = AutoPilotPlugin.Conf.IgnoreGravityFlag;
|
||||
if (ignoreGravityFlag)
|
||||
if (AutoPilotPlugin.Conf.IgnoreGravityFlag)
|
||||
{
|
||||
player.controller.universalGravity = VectorLF3.zero;
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
var controller = __instance.controller;
|
||||
controller.input0.y = controller.input0.y + 1f;
|
||||
var controller2 = __instance.controller;
|
||||
controller2.input1.y = controller2.input1.y + 1f;
|
||||
controller.input0.y += 1f;
|
||||
controller.input1.y += 1f;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -111,7 +107,6 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = false;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
@@ -132,7 +127,8 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
if (AutoPilotPlugin.Speed < AutoPilotPlugin.Conf.MaxSpeed)
|
||||
var speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
if (speed < AutoPilotPlugin.Conf.MaxSpeed)
|
||||
{
|
||||
AutoPilotPlugin.InputSailSpeedUp = true;
|
||||
AutoPilotPlugin.SpeedUp = true;
|
||||
@@ -141,7 +137,7 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
if (GameMain.localPlanet == null)
|
||||
{
|
||||
if (!AutoPilotPlugin.Conf.LocalWarpFlag && GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id == GameMain.localStar.id) return false;
|
||||
if (!(AutoPilotPlugin.Conf.WarpMinRangeAU * 40000.0 <= CruiseAssistPlugin.TargetRange) || !(AutoPilotPlugin.Conf.SpeedToWarp <= AutoPilotPlugin.Speed) ||
|
||||
if (!(AutoPilotPlugin.Conf.WarpMinRangeAu * 40000.0 <= CruiseAssistPlugin.TargetRange) || !(AutoPilotPlugin.Conf.SpeedToWarp <= speed) ||
|
||||
1 > AutoPilotPlugin.WarperCount) return false;
|
||||
if (!(mecha.coreEnergy > mecha.warpStartPowerPerSpeed * mecha.maxWarpSpeed)) return false;
|
||||
if (!mecha.UseWarper()) return false;
|
||||
@@ -150,11 +146,13 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
return false;
|
||||
}
|
||||
|
||||
speed = player.uVelocity.magnitude;
|
||||
var vec = player.uPosition - GameMain.localPlanet.uPosition;
|
||||
if (120.0 < AutoPilotPlugin.Speed && Math.Max(GameMain.localPlanet.realRadius, 800f) < vec.magnitude - GameMain.localPlanet.realRadius)
|
||||
if (340.0 < speed && Math.Max(GameMain.localPlanet.realRadius, 900f) < vec.magnitude - GameMain.localPlanet.realRadius)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
VectorLF3 result;
|
||||
if (Vector3.Angle(player.uPosition - GameMain.localPlanet.uPosition, CruiseAssistPlugin.TargetUPos - GameMain.localPlanet.uPosition) > 90f)
|
||||
{
|
||||
@@ -165,10 +163,17 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
{
|
||||
result = CruiseAssistPlugin.TargetUPos - player.uPosition;
|
||||
}
|
||||
var num = Vector3.Angle(result, player.uVelocity);
|
||||
var num2 = 1.6f / Mathf.Max(10f, num);
|
||||
var num3 = Math.Min(AutoPilotPlugin.Speed, 120.0);
|
||||
player.uVelocity = Vector3.Slerp(player.uVelocity, result.normalized * num3, num2);
|
||||
|
||||
var angle = Vector3.Angle(result, player.uVelocity);
|
||||
if (angle > 1.6f)
|
||||
{
|
||||
player.uVelocity = Vector3.Slerp(player.uVelocity, result.normalized * Math.Min(speed, 320.0), 1.6f / Mathf.Max(10f, angle));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.uVelocity = result.normalized * Math.Min(speed, 320.0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,51 +191,53 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
var uiGame = UIRoot.instance.uiGame;
|
||||
var num = CruiseAssistMainUI.Scale / 100f;
|
||||
if (!_initialized)
|
||||
{
|
||||
_initialized = true;
|
||||
AutoPilotMainUI.OnInit();
|
||||
AutoPilotConfigUI.OnInit();
|
||||
AutoPilotDebugUI.OnInit();
|
||||
}
|
||||
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
|
||||
AutoPilotMainUI.OnGUI();
|
||||
var flag = AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx];
|
||||
if (flag)
|
||||
if (AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx])
|
||||
{
|
||||
AutoPilotConfigUI.OnGUI();
|
||||
}
|
||||
var show = AutoPilotDebugUI.Show;
|
||||
if (show)
|
||||
|
||||
if (AutoPilotDebugUI.Show)
|
||||
{
|
||||
AutoPilotDebugUI.OnGUI();
|
||||
}
|
||||
var flag2 = ResetInput(AutoPilotMainUI.Rect[CruiseAssistMainUI.WIdx], num);
|
||||
var flag3 = !flag2 && AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx];
|
||||
if (flag3)
|
||||
|
||||
var resetInput = ResetInput(AutoPilotMainUI.Rect[CruiseAssistMainUI.WIdx], scale);
|
||||
if (!resetInput && AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx])
|
||||
{
|
||||
flag2 = ResetInput(AutoPilotConfigUI.Rect[CruiseAssistMainUI.WIdx], num);
|
||||
resetInput = ResetInput(AutoPilotConfigUI.Rect[CruiseAssistMainUI.WIdx], scale);
|
||||
}
|
||||
var flag4 = !flag2 && AutoPilotDebugUI.Show;
|
||||
if (flag4)
|
||||
|
||||
if (!resetInput && AutoPilotDebugUI.Show)
|
||||
{
|
||||
flag2 = ResetInput(AutoPilotDebugUI.Rect, num);
|
||||
ResetInput(AutoPilotDebugUI.Rect, scale);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ResetInput(Rect rect, float scale)
|
||||
private static bool ResetInput(Rect rect, float scale)
|
||||
{
|
||||
var num = rect.xMin * scale;
|
||||
var num2 = rect.xMax * scale;
|
||||
var num3 = rect.yMin * scale;
|
||||
var num4 = rect.yMax * scale;
|
||||
var xMin = rect.xMin * scale;
|
||||
var xMax = rect.xMax * scale;
|
||||
var yMin = rect.yMin * scale;
|
||||
var yMax = rect.yMax * scale;
|
||||
var x = Input.mousePosition.x;
|
||||
var num5 = Screen.height - Input.mousePosition.y;
|
||||
var flag = num <= x && x <= num2 && num3 <= num5 && num5 <= num4;
|
||||
if (flag)
|
||||
{
|
||||
int[] array = { 0, 1, 2 };
|
||||
var flag2 = array.Any(Input.GetMouseButton) || Input.mouseScrollDelta.y != 0f;
|
||||
if (flag2)
|
||||
{
|
||||
if (!(xMin <= x) || !(x <= xMax) || !(yMin <= num5) || !(num5 <= yMax)) return false;
|
||||
if (!MouseButtonArray.Any(Input.GetMouseButton) && Input.mouseScrollDelta.y == 0f) return false;
|
||||
Input.ResetInputAxes();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool _initialized;
|
||||
private static readonly int[] MouseButtonArray = [0, 1, 2];
|
||||
}
|
||||
@@ -2,22 +2,24 @@
|
||||
using AutoPilot.Enums;
|
||||
using AutoPilot.Patches;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using CruiseAssist;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace AutoPilot;
|
||||
|
||||
[BepInDependency("tanu.CruiseAssist")]
|
||||
[BepInDependency("org.soardev.CruiseAssist")]
|
||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||
public class AutoPilotPlugin : BaseUnityPlugin
|
||||
{
|
||||
public void Awake()
|
||||
{
|
||||
LogManager.Logger = Logger;
|
||||
new AutoPilotConfigManager(Config);
|
||||
AutoPilotConfigManager.Init(new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, "tanu.AutoPilot.cfg"), false, Info.Metadata));
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.Awake);
|
||||
_harmony = new Harmony("tanu.AutoPilot.Patch");
|
||||
_harmony = new Harmony("org.soardev.AutoPilot.Patch");
|
||||
_harmony.PatchAll(typeof(Patch_VFInput));
|
||||
_harmony.PatchAll(typeof(UI.Strings));
|
||||
CruiseAssistPlugin.RegistExtension(new AutoPilotExtension());
|
||||
}
|
||||
|
||||
@@ -29,8 +31,6 @@ public class AutoPilotPlugin : BaseUnityPlugin
|
||||
|
||||
public static double EnergyPer = 0.0;
|
||||
|
||||
public static double Speed = 0.0;
|
||||
|
||||
public static int WarperCount = 0;
|
||||
|
||||
public static bool LeavePlanet = false;
|
||||
@@ -49,7 +49,7 @@ public class AutoPilotPlugin : BaseUnityPlugin
|
||||
|
||||
public static int MaxSpeed = 2000;
|
||||
|
||||
public static int WarpMinRangeAU = 2;
|
||||
public static int WarpMinRangeAu = 2;
|
||||
|
||||
public static int SpeedToWarp = 1200;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ namespace AutoPilot.Commons;
|
||||
|
||||
internal abstract class ConfigManager
|
||||
{
|
||||
public static ConfigFile Config { get; private set; }
|
||||
private static ConfigFile Config { get; set; }
|
||||
|
||||
protected ConfigManager(ConfigFile config)
|
||||
protected static void Init<T>(ConfigFile config) where T: ConfigManager, new()
|
||||
{
|
||||
_instance = this;
|
||||
_instance = new T();
|
||||
Config = config;
|
||||
Config.SaveOnConfigSet = false;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,6 @@
|
||||
"description": "Auto pilot to a planet or star system.",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17",
|
||||
"tanu-CruiseAssist-0.0.37"
|
||||
"soarqin-CruiseAssist-0.1.0"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public class PatchSave
|
||||
try
|
||||
{
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryWriter), new [] { typeof(FileStream) }))
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryWriter), [typeof(FileStream)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "CreateBinaryWriter")
|
||||
).MatchForward(false,
|
||||
@@ -191,7 +191,7 @@ public class PatchSave
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "FileLengthWrite0")
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryWriter), "Write", new [] { typeof(long) }))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryWriter), "Write", [typeof(long)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "FileLengthWrite1")
|
||||
).MatchForward(false,
|
||||
@@ -299,7 +299,7 @@ public class PatchSave
|
||||
try
|
||||
{
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryReader), new [] { typeof(FileStream) }))
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryReader), [typeof(FileStream)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "CreateBinaryReader")
|
||||
).MatchForward(false,
|
||||
|
||||
@@ -67,7 +67,7 @@ static class PatchUISaveGame
|
||||
PatchSave.UseCompressSave = true;
|
||||
}
|
||||
|
||||
private static UIContext _context = new UIContext();
|
||||
private static UIContext _context = new();
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "_OnOpen"), HarmonyPostfix]
|
||||
private static void _OnOpen(UISaveGameWindow __instance)
|
||||
|
||||
@@ -84,7 +84,7 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
public override void Write(byte value)
|
||||
{
|
||||
CheckCapacityAndSwap(1);
|
||||
*(_curPos++) = value;
|
||||
*_curPos++ = value;
|
||||
}
|
||||
|
||||
public override void Write(bool value) => Write((byte)(value ? 1 : 0));
|
||||
@@ -168,15 +168,15 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
public override void Write(double value)
|
||||
{
|
||||
CheckCapacityAndSwap(8);
|
||||
ulong num = (ulong)(*(long*)(&value));
|
||||
*(_curPos++) = (byte)num;
|
||||
*(_curPos++) = (byte)(num >> 8);
|
||||
*(_curPos++) = (byte)(num >> 16);
|
||||
*(_curPos++) = (byte)(num >> 24);
|
||||
*(_curPos++) = (byte)(num >> 32);
|
||||
*(_curPos++) = (byte)(num >> 40);
|
||||
*(_curPos++) = (byte)(num >> 48);
|
||||
*(_curPos++) = (byte)(num >> 56);
|
||||
ulong num = (ulong)*(long*)&value;
|
||||
*_curPos++ = (byte)num;
|
||||
*_curPos++ = (byte)(num >> 8);
|
||||
*_curPos++ = (byte)(num >> 16);
|
||||
*_curPos++ = (byte)(num >> 24);
|
||||
*_curPos++ = (byte)(num >> 32);
|
||||
*_curPos++ = (byte)(num >> 40);
|
||||
*_curPos++ = (byte)(num >> 48);
|
||||
*_curPos++ = (byte)(num >> 56);
|
||||
}
|
||||
|
||||
//slow
|
||||
@@ -195,15 +195,15 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
public override void Write(short value)
|
||||
{
|
||||
CheckCapacityAndSwap(2);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
}
|
||||
|
||||
public override void Write(ushort value)
|
||||
{
|
||||
CheckCapacityAndSwap(2);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
}
|
||||
|
||||
|
||||
@@ -213,56 +213,56 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
{
|
||||
SwapBuffer();
|
||||
}
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
}
|
||||
|
||||
public override void Write(uint value)
|
||||
{
|
||||
CheckCapacityAndSwap(4);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
}
|
||||
|
||||
|
||||
public override void Write(long value)
|
||||
{
|
||||
CheckCapacityAndSwap(8);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*(_curPos++) = (byte)(value >> 32);
|
||||
*(_curPos++) = (byte)(value >> 40);
|
||||
*(_curPos++) = (byte)(value >> 48);
|
||||
*(_curPos++) = (byte)(value >> 56);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)(value >> 32);
|
||||
*_curPos++ = (byte)(value >> 40);
|
||||
*_curPos++ = (byte)(value >> 48);
|
||||
*_curPos++ = (byte)(value >> 56);
|
||||
}
|
||||
|
||||
public override void Write(ulong value)
|
||||
{
|
||||
CheckCapacityAndSwap(8);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*(_curPos++) = (byte)(value >> 32);
|
||||
*(_curPos++) = (byte)(value >> 40);
|
||||
*(_curPos++) = (byte)(value >> 48);
|
||||
*(_curPos++) = (byte)(value >> 56);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)(value >> 32);
|
||||
*_curPos++ = (byte)(value >> 40);
|
||||
*_curPos++ = (byte)(value >> 48);
|
||||
*_curPos++ = (byte)(value >> 56);
|
||||
}
|
||||
|
||||
public override void Write(float value)
|
||||
{
|
||||
CheckCapacityAndSwap(4);
|
||||
uint num = *(uint*)(&value);
|
||||
*(_curPos++) = (byte)num;
|
||||
*(_curPos++) = (byte)(num >> 8);
|
||||
*(_curPos++) = (byte)(num >> 16);
|
||||
*(_curPos++) = (byte)(num >> 24);
|
||||
uint num = *(uint*)&value;
|
||||
*_curPos++ = (byte)num;
|
||||
*_curPos++ = (byte)(num >> 8);
|
||||
*_curPos++ = (byte)(num >> 16);
|
||||
*_curPos++ = (byte)(num >> 24);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ public class DoubleBuffer(byte[] readingBuffer, byte[] writingBuffer, Action onR
|
||||
private ByteSpan _readBuffer;
|
||||
private ByteSpan _midBuffer = new(readingBuffer);
|
||||
|
||||
private readonly Semaphore _readEnd = new Semaphore(1, 1);
|
||||
private readonly Semaphore _writeEnd = new Semaphore(0, 1);
|
||||
private readonly Semaphore _readEnd = new(1, 1);
|
||||
private readonly Semaphore _writeEnd = new(0, 1);
|
||||
|
||||
public ByteSpan ReadBegin()
|
||||
{
|
||||
|
||||
@@ -7,11 +7,11 @@ namespace CruiseAssist.Commons;
|
||||
|
||||
internal abstract class ConfigManager
|
||||
{
|
||||
public static ConfigFile Config { get; private set; }
|
||||
private static ConfigFile Config { get; set; }
|
||||
|
||||
protected ConfigManager(ConfigFile config)
|
||||
protected static void Init<T>(ConfigFile config) where T: ConfigManager, new()
|
||||
{
|
||||
_instance = this;
|
||||
_instance = new T();
|
||||
Config = config;
|
||||
Config.SaveOnConfigSet = false;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AssemblyName>CruiseAssist</AssemblyName>
|
||||
<BepInExPluginGuid>tanu.CruiseAssist</BepInExPluginGuid>
|
||||
<BepInExPluginGuid>org.soardev.CruiseAssist</BepInExPluginGuid>
|
||||
<Description>DSP MOD - CruiseAssist</Description>
|
||||
<Version>0.0.37</Version>
|
||||
<Version>0.1.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Configuration;
|
||||
using CruiseAssist.Commons;
|
||||
using CruiseAssist.Enums;
|
||||
using CruiseAssist.UI;
|
||||
|
||||
namespace CruiseAssist;
|
||||
|
||||
internal class CruiseAssistConfigManager(ConfigFile config) : ConfigManager(config)
|
||||
internal class CruiseAssistConfigManager : ConfigManager
|
||||
{
|
||||
public static void Init(ConfigFile config)
|
||||
{
|
||||
ConfigManager.Init<CruiseAssistConfigManager>(config);
|
||||
}
|
||||
|
||||
protected override void CheckConfigImplements(Step step)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using CruiseAssist.Commons;
|
||||
using CruiseAssist.Enums;
|
||||
using CruiseAssist.Patches;
|
||||
@@ -19,9 +18,9 @@ public class CruiseAssistPlugin : BaseUnityPlugin
|
||||
public void Awake()
|
||||
{
|
||||
LogManager.Logger = Logger;
|
||||
new CruiseAssistConfigManager(Config);
|
||||
CruiseAssistConfigManager.Init(new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, "tanu.CruiseAssist.cfg"), false, Info.Metadata));
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.Awake);
|
||||
_harmony = new Harmony("tanu.CruiseAssist.Patch");
|
||||
_harmony = new Harmony("org.soardev.CruiseAssist.Patch");
|
||||
_harmony.PatchAll(typeof(Patch_GameMain));
|
||||
_harmony.PatchAll(typeof(Patch_UISailPanel));
|
||||
_harmony.PatchAll(typeof(Patch_UIStarmap));
|
||||
@@ -30,6 +29,7 @@ public class CruiseAssistPlugin : BaseUnityPlugin
|
||||
_harmony.PatchAll(typeof(Patch_PlayerMoveDrift));
|
||||
_harmony.PatchAll(typeof(Patch_PlayerMoveFly));
|
||||
_harmony.PatchAll(typeof(Patch_PlayerMoveSail));
|
||||
_harmony.PatchAll(typeof(Strings));
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
@@ -102,10 +102,7 @@ public class CruiseAssistPlugin : BaseUnityPlugin
|
||||
{
|
||||
ResetInput(CruiseAssistDebugUI.Rect, scale);
|
||||
}
|
||||
Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.OnGUI();
|
||||
});
|
||||
Extensions.ForEach(extension => extension.OnGUI());
|
||||
}
|
||||
|
||||
private static bool ResetInput(Rect rect, float scale)
|
||||
|
||||
@@ -13,10 +13,7 @@ internal class Patch_GameMain
|
||||
{
|
||||
CruiseAssistStarListUI.OnReset();
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.GameMainBegin);
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CheckConfig(ConfigManager.Step.GameMainBegin.ToString());
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CheckConfig(ConfigManager.Step.GameMainBegin.ToString()));
|
||||
}
|
||||
|
||||
[HarmonyPatch("Pause")]
|
||||
@@ -24,9 +21,6 @@ internal class Patch_GameMain
|
||||
public static void Pause_Prefix()
|
||||
{
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.State);
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CheckConfig(ConfigManager.Step.State.ToString());
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CheckConfig(ConfigManager.Step.State.ToString()));
|
||||
}
|
||||
}
|
||||
@@ -15,17 +15,11 @@ internal class Patch_PlayerMoveDrift
|
||||
if (VFInput._moveForward.pressing || VFInput._pullUp.pressing)
|
||||
{
|
||||
CruiseAssistPlugin.Interrupt = true;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CancelOperate();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CancelOperate());
|
||||
}
|
||||
else
|
||||
{
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.OperateDrift(__instance);
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.OperateDrift(__instance));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,17 +15,11 @@ internal class Patch_PlayerMoveFly
|
||||
if (VFInput._moveForward.pressing || VFInput._pullUp.pressing)
|
||||
{
|
||||
CruiseAssistPlugin.Interrupt = true;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CancelOperate();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CancelOperate());
|
||||
}
|
||||
else
|
||||
{
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.OperateFly(__instance);
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.OperateFly(__instance));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,7 @@ internal class Patch_PlayerMoveSail
|
||||
if (controller.input0 != Vector4.zero || controller.input1 != Vector4.zero)
|
||||
{
|
||||
CruiseAssistPlugin.Interrupt = true;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CancelOperate();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CancelOperate());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -38,14 +35,19 @@ internal class Patch_PlayerMoveSail
|
||||
CruiseAssistPlugin.TargetUPos = CruiseAssistPlugin.TargetStar.uPosition;
|
||||
}
|
||||
var operate = false;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
operate |= extension.OperateSail(__instance);
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => operate |= extension.OperateSail(__instance));
|
||||
if (operate) return;
|
||||
var vec = CruiseAssistPlugin.TargetUPos - player.uPosition;
|
||||
var magnitude = controller.actionSail.visual_uvel.magnitude;
|
||||
player.uVelocity = Vector3.Slerp(player.uVelocity, vec.normalized * magnitude, 1.6f / Mathf.Max(10f, Vector3.Angle(vec, player.uVelocity)));
|
||||
var angle = Vector3.Angle(vec, player.uVelocity);
|
||||
if (angle > 1.6f)
|
||||
{
|
||||
player.uVelocity = Vector3.Slerp(player.uVelocity, vec.normalized * magnitude, 1.6f / Mathf.Max(10f, angle));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.uVelocity = vec.normalized * magnitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using CruiseAssist.Commons;
|
||||
using CruiseAssist.Commons;
|
||||
using CruiseAssist.Enums;
|
||||
using CruiseAssist.UI;
|
||||
using HarmonyLib;
|
||||
@@ -45,10 +44,7 @@ internal class Patch_PlayerMoveWalk
|
||||
CruiseAssistPlugin.SelectTargetPlanet = null;
|
||||
CruiseAssistPlugin.SelectTargetStar = GameMain.galaxy.StarById(indicatorAstroId / 100);
|
||||
}
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.SetTargetAstroId(indicatorAstroId);
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.SetTargetAstroId(indicatorAstroId));
|
||||
}
|
||||
|
||||
if (CruiseAssistPlugin.SelectTargetStar != null)
|
||||
@@ -63,10 +59,7 @@ internal class Patch_PlayerMoveWalk
|
||||
CruiseAssistPlugin.SelectTargetPlanet = null;
|
||||
CruiseAssistPlugin.SelectTargetAstroId = 0;
|
||||
GameMain.mainPlayer.navigation.indicatorAstroId = 0;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.SetInactive();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.SetInactive());
|
||||
return;
|
||||
}
|
||||
CruiseAssistPlugin.TargetPlanet = CruiseAssistPlugin.SelectTargetPlanet;
|
||||
@@ -78,10 +71,7 @@ internal class Patch_PlayerMoveWalk
|
||||
CruiseAssistPlugin.SelectTargetStar = null;
|
||||
CruiseAssistPlugin.SelectTargetAstroId = 0;
|
||||
GameMain.mainPlayer.navigation.indicatorAstroId = 0;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.SetInactive();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.SetInactive());
|
||||
return;
|
||||
}
|
||||
if (CruiseAssistPlugin.ReticuleTargetPlanet != null)
|
||||
@@ -118,32 +108,22 @@ internal class Patch_PlayerMoveWalk
|
||||
{
|
||||
if (CruiseAssistPlugin.TargetStar == null)
|
||||
{
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.SetInactive();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.SetInactive());
|
||||
return;
|
||||
}
|
||||
CruiseAssistPlugin.State = CruiseAssistState.ToStar;
|
||||
CruiseAssistPlugin.TargetRange = (CruiseAssistPlugin.TargetStar.uPosition - GameMain.mainPlayer.uPosition).magnitude - (CruiseAssistPlugin.TargetStar.viewRadius - 120f);
|
||||
CruiseAssistPlugin.TargetSelected = true;
|
||||
}
|
||||
var flag18 = __instance.controller.movementStateInFrame > EMovementState.Walk;
|
||||
if (flag18) return;
|
||||
if (__instance.controller.movementStateInFrame > EMovementState.Walk) return;
|
||||
if (VFInput._jump.pressing)
|
||||
{
|
||||
CruiseAssistPlugin.Interrupt = true;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CancelOperate();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CancelOperate());
|
||||
}
|
||||
else
|
||||
{
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.OperateWalk(__instance);
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.OperateWalk(__instance));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using CruiseAssist.Commons;
|
||||
using HarmonyLib;
|
||||
@@ -17,7 +16,7 @@ internal class Patch_UISailPanel
|
||||
codeMatcher.MatchForward(true,
|
||||
new CodeMatch(OpCodes.Ldarg_0)
|
||||
).InsertAndAdvance(
|
||||
Transpilers.EmitDelegate<Action>(delegate
|
||||
Transpilers.EmitDelegate(delegate()
|
||||
{
|
||||
CruiseAssistPlugin.ReticuleTargetPlanet = null;
|
||||
CruiseAssistPlugin.ReticuleTargetStar = null;
|
||||
|
||||
@@ -11,9 +11,6 @@ internal class Patch_UIStarmap
|
||||
public static void OnClose_Prefix()
|
||||
{
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.State);
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CheckConfig(ConfigManager.Step.State.ToString());
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CheckConfig(ConfigManager.Step.State.ToString()));
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,6 @@ internal class Patch_UITechTree
|
||||
public static void OnOpen_Prefix()
|
||||
{
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.State);
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.CheckConfig(ConfigManager.Step.State.ToString());
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.CheckConfig(ConfigManager.Step.State.ToString()));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using CruiseAssist.Enums;
|
||||
using System;
|
||||
using CruiseAssist.Commons;
|
||||
using CruiseAssist.Enums;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
@@ -7,6 +9,8 @@ public static class CruiseAssistConfigUI
|
||||
{
|
||||
public static void OnInit()
|
||||
{
|
||||
Strings.OnLanguageChanged += LangChanged;
|
||||
LangChanged();
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 120f,
|
||||
@@ -69,12 +73,18 @@ public static class CruiseAssistConfigUI
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
return;
|
||||
|
||||
void LangChanged()
|
||||
{
|
||||
_viewModeTexts = [Strings.Get(30), Strings.Get(31)];
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
Rect[_wIdx] = GUILayout.Window(99030293, Rect[_wIdx], WindowFunction, "CruiseAssist - Config", CruiseAssistMainUI.WindowStyle);
|
||||
Rect[_wIdx] = GUILayout.Window(99030293, Rect[_wIdx], WindowFunction, "CruiseAssist - " + Strings.Get(5), CruiseAssistMainUI.WindowStyle);
|
||||
var num = CruiseAssistMainUI.Scale / 100f;
|
||||
if (Screen.width / num < Rect[_wIdx].xMax)
|
||||
{
|
||||
@@ -112,10 +122,10 @@ public static class CruiseAssistConfigUI
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Main Window Style :", _labelStyle);
|
||||
GUILayout.Label(Strings.Get(21), _labelStyle);
|
||||
var viewMode = CruiseAssistMainUI.ViewMode == CruiseAssistMainUIViewMode.Full ? 0 : 1;
|
||||
GUI.changed = false;
|
||||
var value = GUILayout.Toolbar(viewMode, ViewModeTexts, _toolbarButtonStyle);
|
||||
var value = GUILayout.Toolbar(viewMode, _viewModeTexts, _toolbarButtonStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -137,11 +147,11 @@ public static class CruiseAssistConfigUI
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("UI Scale :", _uiScaleStyle);
|
||||
GUILayout.Label(Strings.Get(22), _uiScaleStyle);
|
||||
TempScale = GUILayout.HorizontalSlider(TempScale, 80f, 240f, _horizontalSliderStyle, _horizontalSliderThunbStyle);
|
||||
TempScale = (int)TempScale / 5 * 5;
|
||||
GUILayout.Label(TempScale.ToString("0") + "%", _percentStyle);
|
||||
if (GUILayout.Button("SET", _setButtonStyle))
|
||||
if (GUILayout.Button(Strings.Get(14), _setButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.Scale = TempScale;
|
||||
@@ -149,49 +159,49 @@ public static class CruiseAssistConfigUI
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.MarkVisitedFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.MarkVisitedFlag, "Mark the visited system and planet.".Translate(), _toggleStyle);
|
||||
CruiseAssistPlugin.Conf.MarkVisitedFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.MarkVisitedFlag, Strings.Get(23), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.SelectFocusFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.SelectFocusFlag, "Focus when select target.".Translate(), _toggleStyle);
|
||||
CruiseAssistPlugin.Conf.SelectFocusFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.SelectFocusFlag, Strings.Get(24), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag, "Hide duplicate history.".Translate(), _toggleStyle);
|
||||
CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag, Strings.Get(25), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.AutoDisableLockCursorFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.AutoDisableLockCursorFlag, "Disable lock cursor when starting sail mode.".Translate(), _toggleStyle);
|
||||
CruiseAssistPlugin.Conf.AutoDisableLockCursorFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.AutoDisableLockCursorFlag, Strings.Get(26), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.ShowMainWindowWhenTargetSelectedEvenNotSailModeFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.ShowMainWindowWhenTargetSelectedEvenNotSailModeFlag, "Show main window when target selected, even not sail mode.".Translate(), _toggleStyle);
|
||||
CruiseAssistPlugin.Conf.ShowMainWindowWhenTargetSelectedEvenNotSailModeFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.ShowMainWindowWhenTargetSelectedEvenNotSailModeFlag, Strings.Get(27), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag, "Close StarList when set target planet.".Translate(), _toggleStyle);
|
||||
CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag, Strings.Get(28), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag, "Hide bottom close button.".Translate(), _toggleStyle);
|
||||
CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag, Strings.Get(29), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -200,7 +210,7 @@ public static class CruiseAssistConfigUI
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
if (!CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag && GUILayout.Button("Close", _closeButtonStyle))
|
||||
if (!CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag && GUILayout.Button(Strings.Get(20), _closeButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
Show[_wIdx] = false;
|
||||
@@ -236,5 +246,5 @@ public static class CruiseAssistConfigUI
|
||||
private static GUIStyle _toggleStyle;
|
||||
private static GUIStyle _setButtonStyle;
|
||||
private static GUIStyle _closeButtonStyle;
|
||||
private static readonly string[] ViewModeTexts = ["FULL", "MINI"];
|
||||
private static string[] _viewModeTexts = [Strings.Get(30), Strings.Get(31)];
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using CruiseAssist.Commons;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
|
||||
@@ -20,7 +17,7 @@ public static class CruiseAssistDebugUI
|
||||
}
|
||||
public static void OnGUI()
|
||||
{
|
||||
Rect = GUILayout.Window(99030294, Rect, WindowFunction, "CruiseAssist - Debug", _windowStyle, Array.Empty<GUILayoutOption>());
|
||||
Rect = GUILayout.Window(99030294, Rect, WindowFunction, "CruiseAssist - Debug", _windowStyle);
|
||||
if (Screen.width < Rect.xMax)
|
||||
{
|
||||
Rect.x = Screen.width - Rect.width;
|
||||
@@ -56,31 +53,31 @@ public static class CruiseAssistDebugUI
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
_scrollPos = GUILayout.BeginScrollView(_scrollPos, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
_scrollPos = GUILayout.BeginScrollView(_scrollPos);
|
||||
var reticuleTargetStar = CruiseAssistPlugin.ReticuleTargetStar;
|
||||
GUILayout.Label($"CruiseAssistPlugin.ReticuleTargetStar.id={(reticuleTargetStar != null ? new int?(reticuleTargetStar.id) : null)}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"CruiseAssistPlugin.ReticuleTargetStar.id={(reticuleTargetStar != null ? new int?(reticuleTargetStar.id) : null)}", _debugStyle);
|
||||
var reticuleTargetPlanet = CruiseAssistPlugin.ReticuleTargetPlanet;
|
||||
GUILayout.Label($"CruiseAssistPlugin.ReticuleTargetPlanet.id={(reticuleTargetPlanet != null ? new int?(reticuleTargetPlanet.id) : null)}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"CruiseAssistPlugin.ReticuleTargetPlanet.id={(reticuleTargetPlanet != null ? new int?(reticuleTargetPlanet.id) : null)}", _debugStyle);
|
||||
var selectTargetStar = CruiseAssistPlugin.SelectTargetStar;
|
||||
GUILayout.Label($"CruiseAssistPlugin.SelectTargetStar.id={(selectTargetStar != null ? new int?(selectTargetStar.id) : null)}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"CruiseAssistPlugin.SelectTargetStar.id={(selectTargetStar != null ? new int?(selectTargetStar.id) : null)}", _debugStyle);
|
||||
var selectTargetPlanet = CruiseAssistPlugin.SelectTargetPlanet;
|
||||
GUILayout.Label($"CruiseAssistPlugin.SelectTargetPlanet.id={(selectTargetPlanet != null ? new int?(selectTargetPlanet.id) : null)}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.navigation.indicatorAstroId={GameMain.mainPlayer.navigation.indicatorAstroId}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.w={GameMain.mainPlayer.controller.input0.w}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.x={GameMain.mainPlayer.controller.input0.x}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.y={GameMain.mainPlayer.controller.input0.y}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.z={GameMain.mainPlayer.controller.input0.z}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.w={GameMain.mainPlayer.controller.input1.w}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.x={GameMain.mainPlayer.controller.input1.x}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.y={GameMain.mainPlayer.controller.input1.y}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.z={GameMain.mainPlayer.controller.input1.z}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"VFInput._sailSpeedUp={VFInput._sailSpeedUp}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"CruiseAssistPlugin.Enable={CruiseAssistPlugin.Enable}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.margin.top={GUI.skin.window.margin.top}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.border.top={GUI.skin.window.border.top}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.padding.top={GUI.skin.window.padding.top}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.overflow.top={GUI.skin.window.overflow.top}", _debugStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"CruiseAssistPlugin.SelectTargetPlanet.id={(selectTargetPlanet != null ? new int?(selectTargetPlanet.id) : null)}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.navigation.indicatorAstroId={GameMain.mainPlayer.navigation.indicatorAstroId}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.w={GameMain.mainPlayer.controller.input0.w}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.x={GameMain.mainPlayer.controller.input0.x}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.y={GameMain.mainPlayer.controller.input0.y}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.z={GameMain.mainPlayer.controller.input0.z}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.w={GameMain.mainPlayer.controller.input1.w}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.x={GameMain.mainPlayer.controller.input1.x}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.y={GameMain.mainPlayer.controller.input1.y}", _debugStyle);
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.z={GameMain.mainPlayer.controller.input1.z}", _debugStyle);
|
||||
GUILayout.Label($"VFInput._sailSpeedUp={VFInput._sailSpeedUp}", _debugStyle);
|
||||
GUILayout.Label($"CruiseAssistPlugin.Enable={CruiseAssistPlugin.Enable}", _debugStyle);
|
||||
GUILayout.Label($"GUI.skin.window.margin.top={GUI.skin.window.margin.top}", _debugStyle);
|
||||
GUILayout.Label($"GUI.skin.window.border.top={GUI.skin.window.border.top}", _debugStyle);
|
||||
GUILayout.Label($"GUI.skin.window.padding.top={GUI.skin.window.padding.top}", _debugStyle);
|
||||
GUILayout.Label($"GUI.skin.window.overflow.top={GUI.skin.window.overflow.top}", _debugStyle);
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.EndVertical();
|
||||
GUI.DragWindow();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CruiseAssist.Commons;
|
||||
using CruiseAssist.Enums;
|
||||
@@ -524,7 +523,7 @@ public static class CruiseAssistMainUI
|
||||
};
|
||||
if (_verticalScrollBarSkins == null)
|
||||
{
|
||||
_verticalScrollBarSkins = new List<GUIStyle>();
|
||||
_verticalScrollBarSkins = [];
|
||||
var guistyle = new GUIStyle(GUI.skin.verticalScrollbarThumb)
|
||||
{
|
||||
name = "cruiseassist.verticalscrollbarthumb",
|
||||
@@ -671,7 +670,7 @@ public static class CruiseAssistMainUI
|
||||
};
|
||||
_configButtonStyle = new GUIStyle(BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 50f,
|
||||
fixedWidth = 55f,
|
||||
fixedHeight = 18f,
|
||||
fontSize = 11,
|
||||
alignment = TextAnchor.MiddleCenter
|
||||
@@ -683,15 +682,15 @@ public static class CruiseAssistMainUI
|
||||
switch (ViewMode)
|
||||
{
|
||||
case CruiseAssistMainUIViewMode.Full:
|
||||
Rect[WIdx].width = 398f;
|
||||
Rect[WIdx].width = 408f;
|
||||
Rect[WIdx].height = 150f;
|
||||
break;
|
||||
case CruiseAssistMainUIViewMode.Mini:
|
||||
Rect[WIdx].width = 288f;
|
||||
Rect[WIdx].width = 298f;
|
||||
Rect[WIdx].height = 70f;
|
||||
break;
|
||||
}
|
||||
Rect[WIdx] = GUILayout.Window(99030291, Rect[WIdx], WindowFunction, "CruiseAssist", WindowStyle, Array.Empty<GUILayoutOption>());
|
||||
Rect[WIdx] = GUILayout.Window(99030291, Rect[WIdx], WindowFunction, "CruiseAssist", WindowStyle);
|
||||
var scale = Scale / 100f;
|
||||
if (Screen.width / scale < Rect[WIdx].xMax)
|
||||
{
|
||||
@@ -736,41 +735,41 @@ public static class CruiseAssistMainUI
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
if (ViewMode == CruiseAssistMainUIViewMode.Full)
|
||||
{
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
var starColor = CruiseAssistPlugin.State == CruiseAssistState.ToStar ? Color.cyan : Color.white;
|
||||
var planetColor = CruiseAssistPlugin.State == CruiseAssistState.ToPlanet ? Color.cyan : Color.white;
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
_starLabelStyle.normal.textColor = starColor;
|
||||
GUILayout.Label("Target\n System:", _starLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(Strings.Get(0), _starLabelStyle);
|
||||
_planetLabelStyle.normal.textColor = planetColor;
|
||||
GUILayout.Label("Target\n Planet:", _planetLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(Strings.Get(1), _planetLabelStyle);
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
if (CruiseAssistPlugin.TargetStar != null && ((GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id != GameMain.localStar.id) || CruiseAssistPlugin.TargetPlanet == null))
|
||||
{
|
||||
_starLabelStyle2.normal.textColor = starColor;
|
||||
GUILayout.Label(CruiseAssistPlugin.GetStarName(CruiseAssistPlugin.TargetStar), _starLabelStyle2, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(CruiseAssistPlugin.GetStarName(CruiseAssistPlugin.TargetStar), _starLabelStyle2);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" ", _starLabelStyle2, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(" ", _starLabelStyle2);
|
||||
}
|
||||
|
||||
if (CruiseAssistPlugin.TargetPlanet != null)
|
||||
{
|
||||
_planetLabelStyle2.normal.textColor = planetColor;
|
||||
GUILayout.Label(CruiseAssistPlugin.GetPlanetName(CruiseAssistPlugin.TargetPlanet), _planetLabelStyle2, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(CruiseAssistPlugin.GetPlanetName(CruiseAssistPlugin.TargetPlanet), _planetLabelStyle2);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" ", _planetLabelStyle2, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(" ", _planetLabelStyle2);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
var actionSail = GameMain.mainPlayer.controller.actionSail;
|
||||
var visualUvel = actionSail.visual_uvel;
|
||||
var warping = GameMain.mainPlayer.warping;
|
||||
@@ -779,47 +778,47 @@ public static class CruiseAssistMainUI
|
||||
{
|
||||
_starLabelStyle3.normal.textColor = starColor;
|
||||
var text = GameMain.mainPlayer.sailing ? TimeToString(CruiseAssistPlugin.TargetRange / magnitude) : "-- -- --";
|
||||
GUILayout.Label(RangeToString(CruiseAssistPlugin.TargetRange) + "\n" + text, _starLabelStyle3, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(RangeToString(CruiseAssistPlugin.TargetRange) + "\n" + text, _starLabelStyle3);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" \n ", _starLabelStyle3, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(" \n ", _starLabelStyle3);
|
||||
}
|
||||
|
||||
if (CruiseAssistPlugin.TargetPlanet != null)
|
||||
{
|
||||
_planetLabelStyle3.normal.textColor = planetColor;
|
||||
var text2 = GameMain.mainPlayer.sailing ? TimeToString(CruiseAssistPlugin.TargetRange / magnitude) : "-- -- --";
|
||||
GUILayout.Label(RangeToString(CruiseAssistPlugin.TargetRange) + "\n" + text2, _planetLabelStyle3, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(RangeToString(CruiseAssistPlugin.TargetRange) + "\n" + text2, _planetLabelStyle3);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" \n ", _planetLabelStyle3, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(" \n ", _planetLabelStyle3);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
if (!CruiseAssistPlugin.Enable)
|
||||
{
|
||||
GUILayout.Label("Cruise Assist Disabled.", _stateLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(Strings.Get(2), _stateLabelStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CruiseAssistPlugin.State == CruiseAssistState.Inactive || CruiseAssistPlugin.Interrupt)
|
||||
{
|
||||
GUILayout.Label("Cruise Assist Inactive.", _stateLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(Strings.Get(3), _stateLabelStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stateLabelStyle.normal.textColor = Color.cyan;
|
||||
GUILayout.Label("Cruise Assist Active.", _stateLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(Strings.Get(4), _stateLabelStyle);
|
||||
}
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("Config", _configButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
GUILayout.BeginVertical();
|
||||
if (GUILayout.Button(Strings.Get(5), _configButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistConfigUI.Show[WIdx] = !CruiseAssistConfigUI.Show[WIdx];
|
||||
@@ -829,28 +828,25 @@ public static class CruiseAssistMainUI
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button(CruiseAssistPlugin.Enable ? "Enable" : "Disable", _configButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
if (GUILayout.Button(CruiseAssistPlugin.Enable ? Strings.Get(6) : Strings.Get(7), _configButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistPlugin.Enable = !CruiseAssistPlugin.Enable;
|
||||
if (!CruiseAssistPlugin.Enable)
|
||||
{
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.SetInactive();
|
||||
});
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.SetInactive());
|
||||
}
|
||||
NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("StarList", _configButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
GUILayout.BeginVertical();
|
||||
if (GUILayout.Button(Strings.Get(8), _configButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistStarListUI.Show[WIdx] = !CruiseAssistStarListUI.Show[WIdx];
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Cancel", _configButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
if (GUILayout.Button(Strings.Get(9), _configButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistStarListUI.SelectStar(null, null);
|
||||
@@ -865,7 +861,7 @@ public static class CruiseAssistMainUI
|
||||
{
|
||||
return range switch
|
||||
{
|
||||
< 10000.0 => $"{(int)(range + 0.5)}m ",
|
||||
< 10000.0 => $"{(int)(range + 0.5)}m",
|
||||
< 600000.0 => $"{range / 40000.0:0.00}AU",
|
||||
_ => $"{range / 2400000.0:0.00}Ly"
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
@@ -12,24 +13,27 @@ public static class CruiseAssistStarListUI
|
||||
private static GUIStyle _nameLabelHighlightStyle;
|
||||
private static GUIStyle _nRangeLabelStyle;
|
||||
private static GUIStyle _nRangeLabelHighlightStyle;
|
||||
private static GUIStyle _hRangeLabelStyle;
|
||||
private static GUIStyle _nActionButtonStyle;
|
||||
private static GUIStyle _hActionButtonStyle;
|
||||
private static GUIStyle _nSortButtonStyle;
|
||||
private static GUIStyle _hSortButtonStyle;
|
||||
private static GUIStyle _verticalScrollbarStyle;
|
||||
private static GUIStyle _commonButtonStyle;
|
||||
private static readonly string[] Tabs = ["Normal", "History", "Bookmark"];
|
||||
private static string[] _tabs = [
|
||||
Strings.Get(10),
|
||||
Strings.Get(11),
|
||||
Strings.Get(12)
|
||||
];
|
||||
|
||||
private static readonly string[][] ButtonTexts =
|
||||
private static string[][] _buttonTexts =
|
||||
[
|
||||
["Target", "Bookmark"],
|
||||
["Target", "Bookmark", "Delete"],
|
||||
["Target", "Sort", "Delete"]
|
||||
[Strings.Get(13), Strings.Get(14)],
|
||||
[Strings.Get(13), Strings.Get(14), Strings.Get(15)],
|
||||
[Strings.Get(13), Strings.Get(16), Strings.Get(15)]
|
||||
];
|
||||
|
||||
public static void OnInit()
|
||||
{
|
||||
Strings.OnLanguageChanged += LangChanged;
|
||||
LangChanged();
|
||||
_toolbarStyle = new GUIStyle(CruiseAssistMainUI.BaseToolbarButtonStyle)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
@@ -65,10 +69,6 @@ public static class CruiseAssistStarListUI
|
||||
textColor = Color.cyan
|
||||
}
|
||||
};
|
||||
_hRangeLabelStyle = new GUIStyle(_nRangeLabelStyle)
|
||||
{
|
||||
fixedHeight = 40f
|
||||
};
|
||||
_nActionButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 40f,
|
||||
@@ -79,13 +79,6 @@ public static class CruiseAssistStarListUI
|
||||
},
|
||||
fontSize = 12
|
||||
};
|
||||
_hActionButtonStyle = new GUIStyle(_nActionButtonStyle)
|
||||
{
|
||||
margin =
|
||||
{
|
||||
top = 16
|
||||
}
|
||||
};
|
||||
_nSortButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 20f,
|
||||
@@ -96,13 +89,6 @@ public static class CruiseAssistStarListUI
|
||||
},
|
||||
fontSize = 12
|
||||
};
|
||||
_hSortButtonStyle = new GUIStyle(_nSortButtonStyle)
|
||||
{
|
||||
margin =
|
||||
{
|
||||
top = 16
|
||||
}
|
||||
};
|
||||
_verticalScrollbarStyle = new GUIStyle(CruiseAssistMainUI.BaseVerticalScrollBarStyle);
|
||||
_commonButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
@@ -110,12 +96,19 @@ public static class CruiseAssistStarListUI
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
return;
|
||||
|
||||
void LangChanged()
|
||||
{
|
||||
_tabs = [Strings.Get(10), Strings.Get(11), Strings.Get(12)];
|
||||
_buttonTexts = [[Strings.Get(13), Strings.Get(14)], [Strings.Get(13), Strings.Get(14), Strings.Get(15)], [Strings.Get(13), Strings.Get(16), Strings.Get(15)]];
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
Rect[_wIdx] = GUILayout.Window(99030292, Rect[_wIdx], WindowFunction, "CruiseAssist - StarList", CruiseAssistMainUI.WindowStyle);
|
||||
Rect[_wIdx] = GUILayout.Window(99030292, Rect[_wIdx], WindowFunction, "CruiseAssist - " + Strings.Get(8), CruiseAssistMainUI.WindowStyle);
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
if (Screen.width / scale < Rect[_wIdx].xMax)
|
||||
{
|
||||
@@ -158,7 +151,7 @@ public static class CruiseAssistStarListUI
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUI.changed = false;
|
||||
var selectedIndex = GUILayout.Toolbar(ListSelected, Tabs, _toolbarStyle);
|
||||
var selectedIndex = GUILayout.Toolbar(ListSelected, _tabs, _toolbarStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -184,8 +177,8 @@ public static class CruiseAssistStarListUI
|
||||
GUILayout.Label(celestialBody.Name, selected ? _nameLabelHighlightStyle : _nameLabelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(CruiseAssistMainUI.RangeToString(celestialBody.Range), selected ? _nRangeLabelHighlightStyle : _nRangeLabelStyle);
|
||||
if (GUILayout.Button(ActionSelected[ListSelected] == 0 ? "SET" :
|
||||
celestialBody.IsPlanet ? celestialBody.InBookmark ? "DEL" : "ADD" : "-",
|
||||
if (GUILayout.Button(ActionSelected[ListSelected] == 0 ? Strings.Get(17) :
|
||||
celestialBody.IsPlanet ? celestialBody.InBookmark ? Strings.Get(19) : Strings.Get(18) : "-",
|
||||
_nActionButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -198,51 +191,44 @@ public static class CruiseAssistStarListUI
|
||||
Show[_wIdx] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (planetData != null)
|
||||
else if (planetData != null)
|
||||
{
|
||||
if (RemoveBookmark(planetData))
|
||||
{
|
||||
celestialBody.InBookmark = false;
|
||||
var bb = History.Find(b => b.PlanetData == planetData);
|
||||
if (bb != null) bb.InBookmark = false;
|
||||
}
|
||||
else
|
||||
else if (Bookmark.Count <= 128 && AddBookmark(planetData))
|
||||
{
|
||||
if (Bookmark.Count <= 128)
|
||||
{
|
||||
AddBookmark(planetData);
|
||||
celestialBody.InBookmark = true;
|
||||
var bb = History.Find(b => b.PlanetData == planetData);
|
||||
if (bb != null) bb.InBookmark = true;
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
break;
|
||||
case 1 or 2:
|
||||
{
|
||||
UpdateHistoryOrBookmarkList();
|
||||
var highlighted = false;
|
||||
var enumBookmark = ListSelected != 1 ? Bookmark : Enumerable.Reverse(History);
|
||||
if (ListSelected == 1 && ActionSelected[ListSelected] != 2 && CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
||||
{
|
||||
enumBookmark = HistoryDistinct;
|
||||
enumBookmark = _historyDistinct;
|
||||
}
|
||||
|
||||
var listIndex = -1;
|
||||
enumBookmark.Do(body =>
|
||||
var listIndex = 0;
|
||||
foreach (var body in enumBookmark)
|
||||
{
|
||||
var planetData = body.PlanetData;
|
||||
var id = planetData.id;
|
||||
listIndex += 1;
|
||||
var selected = !highlighted && selectTargetPlanet != null && planetData.id == selectTargetPlanet.id;
|
||||
if (selected)
|
||||
{
|
||||
_nameLabelStyle.normal.textColor = Color.cyan;
|
||||
_nRangeLabelStyle.normal.textColor = Color.cyan;
|
||||
highlighted = true;
|
||||
}
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
var name = CruiseAssistPlugin.GetStarName(planetData.star) + " - " + CruiseAssistPlugin.GetPlanetName(planetData);
|
||||
@@ -266,6 +252,7 @@ public static class CruiseAssistStarListUI
|
||||
var index = Bookmark.IndexOf(body);
|
||||
Bookmark.RemoveAt(index);
|
||||
Bookmark.Insert(index + 1, body);
|
||||
goto outside;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,21 +264,21 @@ public static class CruiseAssistStarListUI
|
||||
var index = Bookmark.IndexOf(body);
|
||||
Bookmark.RemoveAt(index);
|
||||
Bookmark.Insert(index - 1, body);
|
||||
goto outside;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button(
|
||||
ActionSelected[ListSelected] == 0 ? "SET" :
|
||||
ActionSelected[ListSelected] == 2 ? ListSelected == 1 && listIndex == 0 ? "-" : "DEL" :
|
||||
HasBookmark(id) ? "DEL" : "ADD", _nActionButtonStyle))
|
||||
ActionSelected[ListSelected] == 0 ? Strings.Get(17) :
|
||||
ActionSelected[ListSelected] == 2 ? ListSelected == 1 && listIndex == 0 ? "-" : Strings.Get(19) :
|
||||
body.InBookmark ? Strings.Get(19) : Strings.Get(18), _nActionButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
switch (ActionSelected[ListSelected])
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
SelectStar(planetData.star, planetData);
|
||||
if (CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag)
|
||||
{
|
||||
@@ -299,32 +286,30 @@ public static class CruiseAssistStarListUI
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (ListSelected == 1)
|
||||
{
|
||||
if (ListSelected != 1) break;
|
||||
if (HasBookmark(id))
|
||||
{
|
||||
RemoveBookmark(planetData);
|
||||
}
|
||||
else if (Bookmark.Count <= 128)
|
||||
{
|
||||
AddBookmark(planetData);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
var b = _celestialBodies.Find(b => b.IsPlanet && b.PlanetData == planetData);
|
||||
if (b != null) b.InBookmark = false;
|
||||
var bb = History.Find(bb => bb.PlanetData == planetData);
|
||||
if (bb != null) bb.InBookmark = false;
|
||||
}
|
||||
|
||||
break;
|
||||
if (Bookmark.Count > 128 || !AddBookmark(planetData)) goto outside;
|
||||
var b2 = _celestialBodies.Find(b => b.IsPlanet && b.PlanetData == planetData);
|
||||
if (b2 != null) b2.InBookmark = true;
|
||||
var bb2 = History.Find(b => b.PlanetData == planetData);
|
||||
if (bb2 != null) bb2.InBookmark = true;
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
goto outside;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (ActionSelected[ListSelected] == 2)
|
||||
{
|
||||
case 2:
|
||||
switch (ListSelected)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (listIndex != 0)
|
||||
{
|
||||
if (CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
||||
@@ -332,25 +317,25 @@ public static class CruiseAssistStarListUI
|
||||
else
|
||||
RemoveHistoryAt(History.Count - 1 - listIndex);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
goto outside;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
RemoveBookmark(planetData);
|
||||
var b = _celestialBodies.Find(b => b.IsPlanet && b.PlanetData == planetData);
|
||||
if (b != null) b.InBookmark = true;
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
});
|
||||
listIndex++;
|
||||
}
|
||||
outside:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -358,15 +343,15 @@ public static class CruiseAssistStarListUI
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button(ButtonTexts[ListSelected][ActionSelected[ListSelected]], _commonButtonStyle))
|
||||
if (GUILayout.Button(_buttonTexts[ListSelected][ActionSelected[ListSelected]], _commonButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
ActionSelected[ListSelected]++;
|
||||
ActionSelected[ListSelected] %= ButtonTexts[ListSelected].Length;
|
||||
ActionSelected[ListSelected] %= _buttonTexts[ListSelected].Length;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
if (!CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag && GUILayout.Button("Close", _commonButtonStyle))
|
||||
if (!CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag && GUILayout.Button(Strings.Get(20), _commonButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
Show[_wIdx] = false;
|
||||
@@ -393,7 +378,7 @@ public static class CruiseAssistStarListUI
|
||||
{
|
||||
if (star != null)
|
||||
{
|
||||
var uistarmapStar = uiGame.starmap.starUIs.Where(s => s.star.id == star.id).FirstOrDefault();
|
||||
var uistarmapStar = uiGame.starmap.starUIs.FirstOrDefault(s => s.star.id == star.id);
|
||||
if (uistarmapStar != null)
|
||||
{
|
||||
UIStarmap_OnStarClick(uiGame.starmap, uistarmapStar);
|
||||
@@ -403,7 +388,7 @@ public static class CruiseAssistStarListUI
|
||||
|
||||
if (planet != null)
|
||||
{
|
||||
var uistarmapPlanet = uiGame.starmap.planetUIs.Where(p => p.planet.id == planet.id).FirstOrDefault();
|
||||
var uistarmapPlanet = uiGame.starmap.planetUIs.FirstOrDefault(p => p.planet.id == planet.id);
|
||||
if (uistarmapPlanet != null)
|
||||
{
|
||||
UIStarmap_OnPlanetClick(uiGame.starmap, uistarmapPlanet);
|
||||
@@ -429,7 +414,7 @@ public static class CruiseAssistStarListUI
|
||||
}
|
||||
|
||||
CruiseAssistPlugin.SelectTargetAstroId = GameMain.mainPlayer.navigation.indicatorAstroId;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension) { extension.SetTargetAstroId(CruiseAssistPlugin.SelectTargetAstroId); });
|
||||
CruiseAssistPlugin.Extensions.ForEach(extension => extension.SetTargetAstroId(CruiseAssistPlugin.SelectTargetAstroId));
|
||||
}
|
||||
|
||||
private static void UIStarmap_OnStarClick(UIStarmap starmap, UIStarmapStar star)
|
||||
@@ -503,6 +488,19 @@ public static class CruiseAssistStarListUI
|
||||
if (LoadSelectedStarPlanets() || reorder) SortCelestialBodies();
|
||||
}
|
||||
|
||||
private static void UpdateHistoryOrBookmarkList()
|
||||
{
|
||||
if (_nextCheckTick2 > GameMain.instance.timei)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_nextCheckTick2 = GameMain.instance.timei + (GameMain.data.localPlanet == null ? 30 : 300);
|
||||
foreach (var body in ListSelected == 1 ? History : Bookmark)
|
||||
{
|
||||
body.Range = (body.PlanetData.uPosition - GameMain.mainPlayer.uPosition).magnitude - body.PlanetData.realRadius;
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadAllStars()
|
||||
{
|
||||
_stars = [];
|
||||
@@ -516,7 +514,6 @@ public static class CruiseAssistStarListUI
|
||||
StarData = star,
|
||||
Name = (visted ? VisitedMark : NonVisitMark) + CruiseAssistPlugin.GetStarName(star),
|
||||
Pos = star.uPosition,
|
||||
Visited = visted,
|
||||
IsPlanet = false
|
||||
});
|
||||
}
|
||||
@@ -566,7 +563,6 @@ public static class CruiseAssistStarListUI
|
||||
Name = (visted ? VisitedMark : NonVisitMark) + CruiseAssistPlugin.GetPlanetName(planet),
|
||||
Pos = planet.uPosition,
|
||||
IsPlanet = true,
|
||||
Visited = visted,
|
||||
InBookmark = HasBookmark(planet.id)
|
||||
});
|
||||
}
|
||||
@@ -611,7 +607,6 @@ public static class CruiseAssistStarListUI
|
||||
Name = (visted ? VisitedMark : NonVisitMark) + CruiseAssistPlugin.GetPlanetName(planet),
|
||||
Pos = planet.uPosition,
|
||||
IsPlanet = true,
|
||||
Visited = visted,
|
||||
InBookmark = HasBookmark(planet.id)
|
||||
});
|
||||
}
|
||||
@@ -654,30 +649,30 @@ public static class CruiseAssistStarListUI
|
||||
History.Add(new BookmarkCelestialBody
|
||||
{
|
||||
PlanetData = planet,
|
||||
Name = CruiseAssistPlugin.GetStarName(planet.star) + " - " + CruiseAssistPlugin.GetPlanetName(planet),
|
||||
Range = (planet.uPosition - GameMain.mainPlayer.uPosition).magnitude - planet.realRadius
|
||||
Range = (planet.uPosition - GameMain.mainPlayer.uPosition).magnitude - planet.realRadius,
|
||||
InBookmark = HasBookmark(planet.id)
|
||||
});
|
||||
HistoryDistinct = Enumerable.Reverse(History).Distinct().ToList();
|
||||
_historyDistinct = Enumerable.Reverse(History).Distinct().ToList();
|
||||
}
|
||||
|
||||
private static void RemoveHistoryAt(int index)
|
||||
{
|
||||
History.RemoveAt(index);
|
||||
HistoryDistinct = Enumerable.Reverse(History).Distinct().ToList();
|
||||
_historyDistinct = Enumerable.Reverse(History).Distinct().ToList();
|
||||
}
|
||||
|
||||
private static void RemoveHistoryDistinctAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= HistoryDistinct.Count) return;
|
||||
var body = HistoryDistinct[index];
|
||||
if (index < 0 || index >= _historyDistinct.Count) return;
|
||||
var body = _historyDistinct[index];
|
||||
History.Remove(body);
|
||||
HistoryDistinct.RemoveAt(index);
|
||||
_historyDistinct.RemoveAt(index);
|
||||
}
|
||||
|
||||
public static void ClearHistory()
|
||||
{
|
||||
History.Clear();
|
||||
HistoryDistinct.Clear();
|
||||
_historyDistinct.Clear();
|
||||
}
|
||||
|
||||
public static int LastHistoryId() => History.Count > 0 ? History.Last().PlanetData.id : 0;
|
||||
@@ -692,7 +687,7 @@ public static class CruiseAssistStarListUI
|
||||
if (!int.TryParse(s, out var id)) continue;
|
||||
var planet = GameMain.galaxy.PlanetById(id);
|
||||
if (planet == null) continue;
|
||||
AddBookmark(planet);
|
||||
AddHistory(planet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,8 +699,8 @@ public static class CruiseAssistStarListUI
|
||||
Bookmark.Add(new BookmarkCelestialBody
|
||||
{
|
||||
PlanetData = planet,
|
||||
Name = CruiseAssistPlugin.GetStarName(planet.star) + " - " + CruiseAssistPlugin.GetPlanetName(planet),
|
||||
Range = (planet.uPosition - GameMain.mainPlayer.uPosition).magnitude - planet.realRadius
|
||||
Range = (planet.uPosition - GameMain.mainPlayer.uPosition).magnitude - planet.realRadius,
|
||||
InBookmark = true
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@@ -754,15 +749,14 @@ public static class CruiseAssistStarListUI
|
||||
public double Range;
|
||||
public bool IsPlanet;
|
||||
public bool Selected;
|
||||
public bool Visited;
|
||||
public bool InBookmark;
|
||||
}
|
||||
|
||||
private class BookmarkCelestialBody
|
||||
{
|
||||
public PlanetData PlanetData;
|
||||
public string Name;
|
||||
public double Range;
|
||||
public bool InBookmark;
|
||||
}
|
||||
|
||||
private static List<CelestialBody> _celestialBodies;
|
||||
@@ -771,11 +765,12 @@ public static class CruiseAssistStarListUI
|
||||
private static List<CelestialBody> _selectedStarPlanets;
|
||||
|
||||
private static readonly List<BookmarkCelestialBody> History = [];
|
||||
private static List<BookmarkCelestialBody> HistoryDistinct = [];
|
||||
private static List<BookmarkCelestialBody> _historyDistinct = [];
|
||||
private static readonly List<BookmarkCelestialBody> Bookmark = [];
|
||||
private static readonly HashSet<int> BookmarkSet = [];
|
||||
|
||||
private static long _nextCheckTick;
|
||||
private static long _nextCheckTick2;
|
||||
private static StarData _lastLocalStar;
|
||||
private static PlanetData _lastLocalPlanet;
|
||||
private static StarData _lastSelectedStar;
|
||||
|
||||
115
CruiseAssist/UI/StringsUI.cs
Normal file
115
CruiseAssist/UI/StringsUI.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using CruiseAssist.Commons;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
|
||||
public static class Strings
|
||||
{
|
||||
private static readonly string[] EngUs = [
|
||||
// 0
|
||||
"Target\n System:",
|
||||
"Target\n Planet:",
|
||||
"Cruise Assist Disabled.",
|
||||
"Cruise Assist Inactive.",
|
||||
"Cruise Assist Active.",
|
||||
// 5
|
||||
"Config",
|
||||
"Disable",
|
||||
"Enable",
|
||||
"StarList",
|
||||
"Cancel",
|
||||
// 10
|
||||
"Normal",
|
||||
"History",
|
||||
"Bookmark",
|
||||
"Target",
|
||||
"SET",
|
||||
// 15
|
||||
"Delete",
|
||||
"Sort",
|
||||
"SET",
|
||||
"ADD",
|
||||
"DEL",
|
||||
// 20
|
||||
"Close",
|
||||
"Main Window Style :",
|
||||
"UI Scale :",
|
||||
"Mark the visited system and planet.",
|
||||
"Focus when select target.",
|
||||
// 25
|
||||
"Hide duplicate history.",
|
||||
"Disable lock cursor when starting sail mode.",
|
||||
"Show main window when target selected, even not sail mode.",
|
||||
"Close StarList when set target planet.",
|
||||
"Hide bottom close button.",
|
||||
// 30
|
||||
"FULL",
|
||||
"MINI"
|
||||
];
|
||||
|
||||
private static readonly string[] ZhoCn =
|
||||
[
|
||||
// 0
|
||||
"目标\n 星系:",
|
||||
"目标\n 行星:",
|
||||
"Cruise Assist 已禁用",
|
||||
"Cruise Assist 未在工作",
|
||||
"Cruise Assist 正在工作",
|
||||
// 5
|
||||
"设置",
|
||||
"禁用",
|
||||
"启用",
|
||||
"天体列表",
|
||||
"取消",
|
||||
// 10
|
||||
"常规",
|
||||
"历史记录",
|
||||
"书签",
|
||||
"目标",
|
||||
"设置",
|
||||
// 15
|
||||
"删除",
|
||||
"排序",
|
||||
"设为目标",
|
||||
"添加",
|
||||
"删除",
|
||||
// 20
|
||||
"关闭",
|
||||
"主窗口样式 :",
|
||||
"界面缩放 :",
|
||||
"标记已访问的星系和行星",
|
||||
"设置目标时聚焦该天体",
|
||||
// 25
|
||||
"隐藏重复历史记录",
|
||||
"进入航行模式时不锁定鼠标光标",
|
||||
"选定目标天体时即使不在航行模式也显示主窗口",
|
||||
"设置目标后关闭天体列表窗口",
|
||||
"隐藏底部关闭按钮",
|
||||
// 30
|
||||
"完整",
|
||||
"迷你"
|
||||
];
|
||||
|
||||
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