mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-14 18:43:29 +08:00
WIP
This commit is contained in:
@@ -7,11 +7,11 @@ namespace CruiseAssist.Commons;
|
||||
|
||||
internal abstract class ConfigManager
|
||||
{
|
||||
public static ConfigFile Config { get; private set; }
|
||||
|
||||
protected ConfigManager(ConfigFile config)
|
||||
private static ConfigFile Config { get; set; }
|
||||
|
||||
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,23 +191,20 @@ public static class CruiseAssistStarListUI
|
||||
Show[_wIdx] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (planetData != null)
|
||||
{
|
||||
if (planetData != null)
|
||||
if (RemoveBookmark(planetData))
|
||||
{
|
||||
if (RemoveBookmark(planetData))
|
||||
{
|
||||
celestialBody.InBookmark = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bookmark.Count <= 128)
|
||||
{
|
||||
AddBookmark(planetData);
|
||||
celestialBody.InBookmark = true;
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
celestialBody.InBookmark = false;
|
||||
var bb = History.Find(b => b.PlanetData == planetData);
|
||||
if (bb != null) bb.InBookmark = false;
|
||||
}
|
||||
else 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,26 +213,22 @@ public static class CruiseAssistStarListUI
|
||||
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,58 +286,56 @@ public static class CruiseAssistStarListUI
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (ListSelected == 1)
|
||||
if (ListSelected != 1) break;
|
||||
if (HasBookmark(id))
|
||||
{
|
||||
if (HasBookmark(id))
|
||||
{
|
||||
RemoveBookmark(planetData);
|
||||
}
|
||||
else if (Bookmark.Count <= 128)
|
||||
{
|
||||
AddBookmark(planetData);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
RemoveBookmark(planetData);
|
||||
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)
|
||||
{
|
||||
switch (ListSelected)
|
||||
{
|
||||
case 1:
|
||||
case 1:
|
||||
if (listIndex != 0)
|
||||
{
|
||||
if (listIndex != 0)
|
||||
{
|
||||
if (CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
||||
RemoveHistoryDistinctAt(listIndex);
|
||||
else
|
||||
RemoveHistoryAt(History.Count - 1 - listIndex);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
RemoveBookmark(planetData);
|
||||
if (CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
||||
RemoveHistoryDistinctAt(listIndex);
|
||||
else
|
||||
RemoveHistoryAt(History.Count - 1 - listIndex);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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