mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-15 02:53:29 +08:00
Added CruiseAssist and AutoPilot
This commit is contained in:
230
CruiseAssist/UI/CruiseAssistConfigUI.cs
Normal file
230
CruiseAssist/UI/CruiseAssistConfigUI.cs
Normal file
@@ -0,0 +1,230 @@
|
||||
using System;
|
||||
using CruiseAssist.Enums;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
|
||||
public static class CruiseAssistConfigUI
|
||||
{
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
Rect[_wIdx] = GUILayout.Window(99030293, Rect[_wIdx], WindowFunction, "CruiseAssist - Config", CruiseAssistMainUI.WindowStyle, Array.Empty<GUILayoutOption>());
|
||||
var num = CruiseAssistMainUI.Scale / 100f;
|
||||
if (Screen.width / num < Rect[_wIdx].xMax)
|
||||
{
|
||||
Rect[_wIdx].x = Screen.width / num - Rect[_wIdx].width;
|
||||
}
|
||||
if (Rect[_wIdx].x < 0f)
|
||||
{
|
||||
Rect[_wIdx].x = 0f;
|
||||
}
|
||||
if (Screen.height / num < Rect[_wIdx].yMax)
|
||||
{
|
||||
Rect[_wIdx].y = Screen.height / num - Rect[_wIdx].height;
|
||||
}
|
||||
if (Rect[_wIdx].y < 0f)
|
||||
{
|
||||
Rect[_wIdx].y = 0f;
|
||||
}
|
||||
if (LastCheckWindowLeft[_wIdx] != float.MinValue)
|
||||
{
|
||||
if (Rect[_wIdx].x != LastCheckWindowLeft[_wIdx] || Rect[_wIdx].y != LastCheckWindowTop[_wIdx])
|
||||
{
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
LastCheckWindowLeft[_wIdx] = Rect[_wIdx].x;
|
||||
LastCheckWindowTop[_wIdx] = Rect[_wIdx].y;
|
||||
}
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("Main Window Style :", new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 120f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
}, Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(CruiseAssistMainUI.BaseToolbarButtonStyle)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
var array = new[] { "FULL", "MINI" };
|
||||
var num = CruiseAssistMainUI.ViewMode == CruiseAssistMainUIViewMode.Full ? 0 : 1;
|
||||
GUI.changed = false;
|
||||
var num2 = GUILayout.Toolbar(num, array, guistyle, Array.Empty<GUILayoutOption>());
|
||||
var changed = GUI.changed;
|
||||
if (changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
}
|
||||
if (num2 != num)
|
||||
{
|
||||
if (num2 != 0)
|
||||
{
|
||||
if (num2 == 1)
|
||||
{
|
||||
CruiseAssistMainUI.ViewMode = CruiseAssistMainUIViewMode.Mini;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CruiseAssistMainUI.ViewMode = CruiseAssistMainUIViewMode.Full;
|
||||
}
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("UI Scale :", new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 60f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
}, Array.Empty<GUILayoutOption>());
|
||||
var guistyle2 = new GUIStyle(CruiseAssistMainUI.BaseHorizontalSliderStyle)
|
||||
{
|
||||
fixedWidth = 180f,
|
||||
margin =
|
||||
{
|
||||
top = 10
|
||||
},
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
var guistyle3 = new GUIStyle(CruiseAssistMainUI.BaseHorizontalSliderThumbStyle)
|
||||
{
|
||||
border = new RectOffset(1, 1, 8, 8)
|
||||
};
|
||||
TempScale = GUILayout.HorizontalSlider(TempScale, 80f, 240f, guistyle2, guistyle3, Array.Empty<GUILayoutOption>());
|
||||
TempScale = (int)TempScale / 5 * 5;
|
||||
var guistyle4 = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 40f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
GUILayout.Label(TempScale.ToString("0") + "%", guistyle4, Array.Empty<GUILayoutOption>());
|
||||
var ok = GUILayout.Button("SET", new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 60f,
|
||||
fixedHeight = 18f,
|
||||
margin =
|
||||
{
|
||||
top = 6
|
||||
},
|
||||
fontSize = 12
|
||||
}, Array.Empty<GUILayoutOption>());
|
||||
if (ok)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.Scale = TempScale;
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
var guistyle5 = new GUIStyle(CruiseAssistMainUI.BaseToggleStyle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
GUI.changed = false;
|
||||
CruiseAssistPlugin.Conf.MarkVisitedFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.MarkVisitedFlag, "Mark the visited system and planet.".Translate(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.FlexibleSpace();
|
||||
var guistyle6 = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
ok = !CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag && GUILayout.Button("Close", guistyle6, Array.Empty<GUILayoutOption>());
|
||||
if (ok)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
Show[_wIdx] = false;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
ok = GUI.Button(new Rect(Rect[_wIdx].width - 16f, 1f, 16f, 16f), "", CruiseAssistMainUI.CloseButtonStyle);
|
||||
if (ok)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
Show[_wIdx] = false;
|
||||
}
|
||||
GUI.DragWindow();
|
||||
}
|
||||
|
||||
private static int _wIdx;
|
||||
|
||||
public const float WindowWidth = 400f;
|
||||
|
||||
public const float WindowHeight = 400f;
|
||||
|
||||
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)
|
||||
};
|
||||
|
||||
private static readonly float[] LastCheckWindowLeft = { float.MinValue, float.MinValue };
|
||||
|
||||
private static readonly float[] LastCheckWindowTop = { float.MinValue, float.MinValue };
|
||||
|
||||
public static float TempScale;
|
||||
}
|
||||
92
CruiseAssist/UI/CruiseAssistDebugUI.cs
Normal file
92
CruiseAssist/UI/CruiseAssistDebugUI.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using CruiseAssist.Commons;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
|
||||
public static class CruiseAssistDebugUI
|
||||
{
|
||||
public static void OnGUI()
|
||||
{
|
||||
var guistyle = new GUIStyle(GUI.skin.window)
|
||||
{
|
||||
fontSize = 11
|
||||
};
|
||||
Rect = GUILayout.Window(99030294, Rect, WindowFunction, "CruiseAssist - Debug", guistyle, Array.Empty<GUILayoutOption>());
|
||||
if (Screen.width < Rect.xMax)
|
||||
{
|
||||
Rect.x = Screen.width - Rect.width;
|
||||
}
|
||||
if (Rect.x < 0f)
|
||||
{
|
||||
Rect.x = 0f;
|
||||
}
|
||||
if (Screen.height < Rect.yMax)
|
||||
{
|
||||
Rect.y = Screen.height - Rect.height;
|
||||
}
|
||||
if (Rect.y < 0f)
|
||||
{
|
||||
Rect.y = 0f;
|
||||
}
|
||||
if (_lastCheckWindowLeft != float.MinValue)
|
||||
{
|
||||
var flag6 = Rect.x != _lastCheckWindowLeft || Rect.y != _lastCheckWindowTop;
|
||||
if (flag6)
|
||||
{
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
_lastCheckWindowLeft = Rect.x;
|
||||
_lastCheckWindowTop = Rect.y;
|
||||
}
|
||||
|
||||
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>());
|
||||
var reticuleTargetStar = CruiseAssistPlugin.ReticuleTargetStar;
|
||||
GUILayout.Label($"CruiseAssistPlugin.ReticuleTargetStar.id={(reticuleTargetStar != null ? new int?(reticuleTargetStar.id) : null)}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
var reticuleTargetPlanet = CruiseAssistPlugin.ReticuleTargetPlanet;
|
||||
GUILayout.Label($"CruiseAssistPlugin.ReticuleTargetPlanet.id={(reticuleTargetPlanet != null ? new int?(reticuleTargetPlanet.id) : null)}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
var selectTargetStar = CruiseAssistPlugin.SelectTargetStar;
|
||||
GUILayout.Label($"CruiseAssistPlugin.SelectTargetStar.id={(selectTargetStar != null ? new int?(selectTargetStar.id) : null)}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
var selectTargetPlanet = CruiseAssistPlugin.SelectTargetPlanet;
|
||||
GUILayout.Label($"CruiseAssistPlugin.SelectTargetPlanet.id={(selectTargetPlanet != null ? new int?(selectTargetPlanet.id) : null)}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.navigation.indicatorAstroId={GameMain.mainPlayer.navigation.indicatorAstroId}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.w={GameMain.mainPlayer.controller.input0.w}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.x={GameMain.mainPlayer.controller.input0.x}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.y={GameMain.mainPlayer.controller.input0.y}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input0.z={GameMain.mainPlayer.controller.input0.z}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.w={GameMain.mainPlayer.controller.input1.w}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.x={GameMain.mainPlayer.controller.input1.x}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.y={GameMain.mainPlayer.controller.input1.y}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.controller.input1.z={GameMain.mainPlayer.controller.input1.z}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"VFInput._sailSpeedUp={VFInput._sailSpeedUp}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"CruiseAssistPlugin.Enable={CruiseAssistPlugin.Enable}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"CruiseAssistPlugin.History={CruiseAssistPlugin.History.Count()}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("CruiseAssistPlugin.History=" + ListUtils.ToString(CruiseAssistPlugin.History), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.margin.top={GUI.skin.window.margin.top}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.border.top={GUI.skin.window.border.top}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.padding.top={GUI.skin.window.padding.top}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GUI.skin.window.overflow.top={GUI.skin.window.overflow.top}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.EndVertical();
|
||||
GUI.DragWindow();
|
||||
}
|
||||
|
||||
public static bool Show = false;
|
||||
|
||||
public static Rect Rect = new Rect(0f, 0f, 400f, 400f);
|
||||
|
||||
private static float _lastCheckWindowLeft = float.MinValue;
|
||||
|
||||
private static float _lastCheckWindowTop = float.MinValue;
|
||||
|
||||
private static Vector2 _scrollPos = Vector2.zero;
|
||||
}
|
||||
920
CruiseAssist/UI/CruiseAssistMainUI.cs
Normal file
920
CruiseAssist/UI/CruiseAssistMainUI.cs
Normal file
@@ -0,0 +1,920 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CruiseAssist.Commons;
|
||||
using CruiseAssist.Enums;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
|
||||
public static class CruiseAssistMainUI
|
||||
{
|
||||
public static void OnGUI()
|
||||
{
|
||||
if (WhiteBorderBackgroundTexture == null)
|
||||
{
|
||||
WhiteBorderBackgroundTexture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
|
||||
var color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
var color2 = new Color32(0, 0, 0, 224);
|
||||
for (var i = 0; i < 64; i++)
|
||||
{
|
||||
for (var j = 0; j < 64; j++)
|
||||
{
|
||||
var color3 = i <= 0 || j <= 0 || i >= 63 || j >= 63 ? color : color2;
|
||||
WhiteBorderBackgroundTexture.SetPixel(j, i, color3);
|
||||
}
|
||||
}
|
||||
WhiteBorderBackgroundTexture.Apply();
|
||||
}
|
||||
|
||||
if (GrayBorderBackgroundTexture == null)
|
||||
{
|
||||
GrayBorderBackgroundTexture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
|
||||
var color4 = new Color32(64, 64, 64, byte.MaxValue);
|
||||
var color5 = new Color32(0, 0, 0, 224);
|
||||
for (var k = 0; k < 64; k++)
|
||||
{
|
||||
for (var l = 0; l < 64; l++)
|
||||
{
|
||||
var color6 = k <= 0 || l <= 0 || k >= 63 || l >= 63 ? color4 : color5;
|
||||
GrayBorderBackgroundTexture.SetPixel(l, k, color6);
|
||||
}
|
||||
}
|
||||
GrayBorderBackgroundTexture.Apply();
|
||||
}
|
||||
|
||||
if (WhiteBorderTexture == null)
|
||||
{
|
||||
WhiteBorderTexture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
|
||||
var color7 = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
var color8 = new Color32(0, 0, 0, byte.MaxValue);
|
||||
for (var m = 0; m < 64; m++)
|
||||
{
|
||||
for (var n = 0; n < 64; n++)
|
||||
{
|
||||
var color9 = m <= 0 || n <= 0 || m >= 63 || n >= 63 ? color7 : color8;
|
||||
WhiteBorderTexture.SetPixel(n, m, color9);
|
||||
}
|
||||
}
|
||||
WhiteBorderTexture.Apply();
|
||||
}
|
||||
|
||||
if (GrayBorderTexture == null)
|
||||
{
|
||||
GrayBorderTexture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
|
||||
var color10 = new Color32(64, 64, 64, byte.MaxValue);
|
||||
var color11 = new Color32(0, 0, 0, byte.MaxValue);
|
||||
for (var i = 0; i < 64; i++)
|
||||
{
|
||||
for (var j = 0; j < 64; j++)
|
||||
{
|
||||
var color12 = i <= 0 || j <= 0 || i >= 63 || j >= 63 ? color10 : color11;
|
||||
GrayBorderTexture.SetPixel(j, i, color12);
|
||||
}
|
||||
}
|
||||
GrayBorderTexture.Apply();
|
||||
}
|
||||
|
||||
if (BlackTexture == null)
|
||||
{
|
||||
BlackTexture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
|
||||
var color13 = new Color32(0, 0, 0, byte.MaxValue);
|
||||
for (var i = 0; i < 64; i++)
|
||||
{
|
||||
for (var j = 0; j < 64; j++)
|
||||
{
|
||||
BlackTexture.SetPixel(j, i, color13);
|
||||
}
|
||||
}
|
||||
BlackTexture.Apply();
|
||||
}
|
||||
|
||||
if (WhiteTexture == null)
|
||||
{
|
||||
WhiteTexture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
|
||||
var color14 = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
for (var i = 0; i < 64; i++)
|
||||
{
|
||||
for (var j = 0; j < 64; j++)
|
||||
{
|
||||
WhiteTexture.SetPixel(j, i, color14);
|
||||
}
|
||||
}
|
||||
WhiteTexture.Apply();
|
||||
}
|
||||
|
||||
if (ToggleOnTexture == null)
|
||||
{
|
||||
ToggleOnTexture = new Texture2D(16, 16, TextureFormat.RGBA32, false);
|
||||
var color15 = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
var color16 = new Color32(0, 0, 0, 0);
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
for (var j = 0; j < 16; j++)
|
||||
{
|
||||
var color17 = j is >= 1 and <= 12 && i is >= 2 and <= 13 ? color15 : color16;
|
||||
ToggleOnTexture.SetPixel(j, i, color17);
|
||||
}
|
||||
}
|
||||
ToggleOnTexture.Apply();
|
||||
}
|
||||
|
||||
if (ToggleOffTexture == null)
|
||||
{
|
||||
ToggleOffTexture = new Texture2D(16, 16, TextureFormat.RGBA32, false);
|
||||
var color18 = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
var color19 = new Color32(0, 0, 0, byte.MaxValue);
|
||||
var color20 = new Color32(0, 0, 0, 0);
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
for (var j = 0; j < 16; j++)
|
||||
{
|
||||
var color21 = j < 1 || j > 12 || i < 2 || i > 13 ? color20 : j is > 1 and < 12 && i is > 2 and < 13 ? color19 : color18;
|
||||
ToggleOffTexture.SetPixel(j, i, color21);
|
||||
}
|
||||
}
|
||||
ToggleOffTexture.Apply();
|
||||
}
|
||||
|
||||
if (CloseButtonGrayBorderTexture != null)
|
||||
{
|
||||
CloseButtonGrayBorderTexture = new Texture2D(16, 16, TextureFormat.RGBA32, false);
|
||||
var color22 = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
var color23 = new Color32(64, 64, 64, byte.MaxValue);
|
||||
var color24 = new Color32(0, 0, 0, byte.MaxValue);
|
||||
var color25 = new Color32(0, 0, 0, 0);
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
for (var j = 0; j < 16; j++)
|
||||
{
|
||||
var color26 = j < 1 || j > 12 || i < 2 || i > 13 ? color25 : j is > 1 and < 12 && i is > 2 and < 13 ? color24 : color23;
|
||||
CloseButtonGrayBorderTexture.SetPixel(j, i, color26);
|
||||
}
|
||||
}
|
||||
for (var i = 4; i <= 9; i++)
|
||||
{
|
||||
CloseButtonGrayBorderTexture.SetPixel(i, i + 1, color22);
|
||||
CloseButtonGrayBorderTexture.SetPixel(i, 14 - i, color22);
|
||||
}
|
||||
CloseButtonGrayBorderTexture.Apply();
|
||||
}
|
||||
|
||||
if (CloseButtonWhiteBorderTexture == null)
|
||||
{
|
||||
CloseButtonWhiteBorderTexture = new Texture2D(16, 16, TextureFormat.RGBA32, false);
|
||||
var color27 = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
var color28 = new Color32(0, 0, 0, byte.MaxValue);
|
||||
var color29 = new Color32(0, 0, 0, 0);
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
for (var j = 0; j < 16; j++)
|
||||
{
|
||||
var color30 = j < 1 || j > 12 || i < 2 || i > 13 ? color29 : j is > 1 and < 12 && i is > 2 and < 13 ? color28 : color27;
|
||||
CloseButtonWhiteBorderTexture.SetPixel(j, i, color30);
|
||||
}
|
||||
}
|
||||
for (var i = 4; i <= 9; i++)
|
||||
{
|
||||
CloseButtonWhiteBorderTexture.SetPixel(i, i + 1, color27);
|
||||
CloseButtonWhiteBorderTexture.SetPixel(i, 14 - i, color27);
|
||||
}
|
||||
CloseButtonWhiteBorderTexture.Apply();
|
||||
}
|
||||
|
||||
WindowStyle ??= new GUIStyle(GUI.skin.window)
|
||||
{
|
||||
fontSize = 11,
|
||||
normal =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = GrayBorderBackgroundTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = GrayBorderBackgroundTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = GrayBorderBackgroundTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = GrayBorderBackgroundTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderBackgroundTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderBackgroundTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderBackgroundTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderBackgroundTexture
|
||||
}
|
||||
};
|
||||
|
||||
BaseButtonStyle ??= new GUIStyle(GUI.skin.button)
|
||||
{
|
||||
normal =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
textColor = Color.white,
|
||||
background = WhiteBorderTexture
|
||||
}
|
||||
};
|
||||
|
||||
BaseToolbarButtonStyle ??= new GUIStyle(BaseButtonStyle)
|
||||
{
|
||||
normal =
|
||||
{
|
||||
textColor = Color.gray
|
||||
},
|
||||
hover =
|
||||
{
|
||||
textColor = Color.gray
|
||||
},
|
||||
active =
|
||||
{
|
||||
textColor = Color.gray
|
||||
},
|
||||
focused =
|
||||
{
|
||||
textColor = Color.gray
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = WhiteBorderBackgroundTexture
|
||||
}
|
||||
};
|
||||
|
||||
BaseVerticalScrollBarStyle ??= new GUIStyle(GUI.skin.verticalScrollbar)
|
||||
{
|
||||
name = "cruiseassist.verticalscrollbar",
|
||||
normal =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
}
|
||||
};
|
||||
|
||||
BaseHorizontalSliderStyle ??= new GUIStyle(GUI.skin.horizontalSlider)
|
||||
{
|
||||
normal =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = GrayBorderTexture
|
||||
}
|
||||
};
|
||||
|
||||
BaseHorizontalSliderThumbStyle ??= new GUIStyle(GUI.skin.horizontalSliderThumb)
|
||||
{
|
||||
normal =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
}
|
||||
};
|
||||
|
||||
BaseToggleStyle ??= new GUIStyle(GUI.skin.toggle)
|
||||
{
|
||||
normal =
|
||||
{
|
||||
background = ToggleOffTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = ToggleOffTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = ToggleOffTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = ToggleOffTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = ToggleOnTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = ToggleOnTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = ToggleOnTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = ToggleOnTexture
|
||||
}
|
||||
};
|
||||
|
||||
BaseTextFieldStyle ??= new GUIStyle(GUI.skin.textField)
|
||||
{
|
||||
normal =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
}
|
||||
};
|
||||
|
||||
CloseButtonStyle ??= new GUIStyle(GUI.skin.button)
|
||||
{
|
||||
normal =
|
||||
{
|
||||
background = CloseButtonGrayBorderTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = CloseButtonWhiteBorderTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = CloseButtonWhiteBorderTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = CloseButtonWhiteBorderTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = CloseButtonGrayBorderTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = CloseButtonWhiteBorderTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = CloseButtonWhiteBorderTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = CloseButtonWhiteBorderTexture
|
||||
}
|
||||
};
|
||||
|
||||
if (_verticalScrollBarSkins == null)
|
||||
{
|
||||
_verticalScrollBarSkins = new List<GUIStyle>();
|
||||
var guistyle = new GUIStyle(GUI.skin.verticalScrollbarThumb)
|
||||
{
|
||||
name = "cruiseassist.verticalscrollbarthumb",
|
||||
normal =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = WhiteBorderTexture
|
||||
}
|
||||
};
|
||||
_verticalScrollBarSkins.Add(guistyle);
|
||||
var guistyle2 = new GUIStyle(GUI.skin.verticalScrollbarUpButton)
|
||||
{
|
||||
name = "cruiseassist.verticalscrollbarupbutton",
|
||||
normal =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = BlackTexture
|
||||
}
|
||||
};
|
||||
_verticalScrollBarSkins.Add(guistyle2);
|
||||
var guistyle3 = new GUIStyle(GUI.skin.verticalScrollbarDownButton)
|
||||
{
|
||||
name = "cruiseassist.verticalscrollbardownbutton",
|
||||
normal =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
hover =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
active =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
focused =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onNormal =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onHover =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onActive =
|
||||
{
|
||||
background = BlackTexture
|
||||
},
|
||||
onFocused =
|
||||
{
|
||||
background = BlackTexture
|
||||
}
|
||||
};
|
||||
_verticalScrollBarSkins.Add(guistyle3);
|
||||
GUI.skin.customStyles = GUI.skin.customStyles.Concat(_verticalScrollBarSkins).ToArray();
|
||||
}
|
||||
switch (ViewMode)
|
||||
{
|
||||
case CruiseAssistMainUIViewMode.Full:
|
||||
Rect[WIdx].width = 398f;
|
||||
Rect[WIdx].height = 150f;
|
||||
break;
|
||||
case CruiseAssistMainUIViewMode.Mini:
|
||||
Rect[WIdx].width = 288f;
|
||||
Rect[WIdx].height = 70f;
|
||||
break;
|
||||
}
|
||||
Rect[WIdx] = GUILayout.Window(99030291, Rect[WIdx], WindowFunction, "CruiseAssist", WindowStyle, Array.Empty<GUILayoutOption>());
|
||||
var scale = Scale / 100f;
|
||||
if (Screen.width / scale < Rect[WIdx].xMax)
|
||||
{
|
||||
Rect[WIdx].x = Screen.width / scale - Rect[WIdx].width;
|
||||
}
|
||||
|
||||
if (Rect[WIdx].x < 0f)
|
||||
{
|
||||
Rect[WIdx].x = 0f;
|
||||
}
|
||||
|
||||
if (Screen.height / scale < Rect[WIdx].yMax)
|
||||
{
|
||||
Rect[WIdx].y = Screen.height / scale - Rect[WIdx].height;
|
||||
}
|
||||
|
||||
if (Rect[WIdx].y < 0f)
|
||||
{
|
||||
Rect[WIdx].y = 0f;
|
||||
}
|
||||
|
||||
if (LastCheckWindowLeft[WIdx] != float.MinValue)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.State);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
if (ViewMode == CruiseAssistMainUIViewMode.Full)
|
||||
{
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var color = CruiseAssistPlugin.State == CruiseAssistState.ToStar ? Color.cyan : Color.white;
|
||||
var color2 = CruiseAssistPlugin.State == CruiseAssistState.ToPlanet ? Color.cyan : Color.white;
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 50f,
|
||||
fixedHeight = 36f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.UpperLeft
|
||||
};
|
||||
var guistyle2 = new GUIStyle(guistyle);
|
||||
guistyle.normal.textColor = color;
|
||||
GUILayout.Label("Target\n System:", guistyle, Array.Empty<GUILayoutOption>());
|
||||
guistyle2.normal.textColor = color2;
|
||||
GUILayout.Label("Target\n Planet:", guistyle2, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var guistyle3 = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 240f,
|
||||
fixedHeight = 36f,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
var guistyle4 = new GUIStyle(guistyle3);
|
||||
if (CruiseAssistPlugin.TargetStar != null && ((GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id != GameMain.localStar.id) || CruiseAssistPlugin.TargetPlanet == null))
|
||||
{
|
||||
guistyle3.normal.textColor = color;
|
||||
GUILayout.Label(CruiseAssistPlugin.GetStarName(CruiseAssistPlugin.TargetStar), guistyle3, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" ", guistyle3, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
|
||||
if (CruiseAssistPlugin.TargetPlanet != null)
|
||||
{
|
||||
guistyle4.normal.textColor = color2;
|
||||
GUILayout.Label(CruiseAssistPlugin.GetPlanetName(CruiseAssistPlugin.TargetPlanet), guistyle4, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" ", guistyle4, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var actionSail = GameMain.mainPlayer.controller.actionSail;
|
||||
var visualUvel = actionSail.visual_uvel;
|
||||
var warping = GameMain.mainPlayer.warping;
|
||||
var magnitude = warping ? (visualUvel + actionSail.currentWarpVelocity).magnitude : visualUvel.magnitude;
|
||||
var guistyle5 = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
fixedHeight = 36f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleRight
|
||||
};
|
||||
var guistyle6 = new GUIStyle(guistyle5);
|
||||
if (CruiseAssistPlugin.TargetStar != null && ((GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id != GameMain.localStar.id) || CruiseAssistPlugin.TargetPlanet == null))
|
||||
{
|
||||
guistyle5.normal.textColor = color;
|
||||
var text = GameMain.mainPlayer.sailing ? TimeToString(CruiseAssistPlugin.TargetRange / magnitude) : "-- -- --";
|
||||
GUILayout.Label(RangeToString(CruiseAssistPlugin.TargetRange) + "\n" + text, guistyle5, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" \n ", guistyle5, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
|
||||
if (CruiseAssistPlugin.TargetPlanet != null)
|
||||
{
|
||||
guistyle6.normal.textColor = color2;
|
||||
var text2 = GameMain.mainPlayer.sailing ? TimeToString(CruiseAssistPlugin.TargetRange / magnitude) : "-- -- --";
|
||||
GUILayout.Label(RangeToString(CruiseAssistPlugin.TargetRange) + "\n" + text2, guistyle6, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(" \n ", guistyle6, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var guistyle7 = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 160f,
|
||||
fixedHeight = 32f,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
if (!CruiseAssistPlugin.Enable)
|
||||
{
|
||||
GUILayout.Label("Cruise Assist Disabled.", guistyle7, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CruiseAssistPlugin.State == CruiseAssistState.Inactive || CruiseAssistPlugin.Interrupt)
|
||||
{
|
||||
GUILayout.Label("Cruise Assist Inactive.", guistyle7, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
else
|
||||
{
|
||||
guistyle7.normal.textColor = Color.cyan;
|
||||
GUILayout.Label("Cruise Assist Active.", guistyle7, Array.Empty<GUILayoutOption>());
|
||||
}
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
var guistyle8 = new GUIStyle(BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 50f,
|
||||
fixedHeight = 18f,
|
||||
fontSize = 11,
|
||||
alignment = TextAnchor.MiddleCenter
|
||||
};
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("Config", guistyle8, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistConfigUI.Show[WIdx] = !CruiseAssistConfigUI.Show[WIdx];
|
||||
if (CruiseAssistConfigUI.Show[WIdx])
|
||||
{
|
||||
CruiseAssistConfigUI.TempScale = Scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button(CruiseAssistPlugin.Enable ? "Enable" : "Disable", guistyle8, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistPlugin.Enable = !CruiseAssistPlugin.Enable;
|
||||
NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("StarList", guistyle8, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistStarListUI.Show[WIdx] = !CruiseAssistStarListUI.Show[WIdx];
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Cancel", guistyle8, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
CruiseAssistStarListUI.SelectStar(null, null);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
GUI.DragWindow();
|
||||
}
|
||||
|
||||
public static string RangeToString(double range)
|
||||
{
|
||||
return range switch
|
||||
{
|
||||
< 10000.0 => (int)(range + 0.5) + "m ",
|
||||
< 600000.0 => (range / 40000.0).ToString("0.00") + "AU",
|
||||
_ => (range / 2400000.0).ToString("0.00") + "Ly"
|
||||
};
|
||||
}
|
||||
|
||||
private static string TimeToString(double time)
|
||||
{
|
||||
var sec = (int)(time + 0.5);
|
||||
var min = sec / 60;
|
||||
var hour = min / 60;
|
||||
sec %= 60;
|
||||
min %= 60;
|
||||
return $"{hour:00} {min:00} {sec:00}";
|
||||
}
|
||||
|
||||
public static float Scale = 150f;
|
||||
|
||||
public static int WIdx = 0;
|
||||
|
||||
public static CruiseAssistMainUIViewMode ViewMode = CruiseAssistMainUIViewMode.Full;
|
||||
|
||||
public const float WindowWidthFull = 398f;
|
||||
|
||||
public const float WindowHeightFull = 150f;
|
||||
|
||||
public const float WindowWidthMini = 288f;
|
||||
|
||||
public const float WindowHeightMini = 70f;
|
||||
|
||||
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 readonly float[] LastCheckWindowTop = { float.MinValue, float.MinValue };
|
||||
|
||||
public static long NextCheckGameTick = long.MaxValue;
|
||||
|
||||
public static Texture2D WhiteBorderBackgroundTexture;
|
||||
|
||||
public static Texture2D GrayBorderBackgroundTexture;
|
||||
|
||||
public static Texture2D WhiteBorderTexture;
|
||||
|
||||
public static Texture2D GrayBorderTexture;
|
||||
|
||||
public static Texture2D BlackTexture;
|
||||
|
||||
public static Texture2D WhiteTexture;
|
||||
|
||||
public static Texture2D ToggleOnTexture;
|
||||
|
||||
public static Texture2D ToggleOffTexture;
|
||||
|
||||
public static Texture2D CloseButtonGrayBorderTexture;
|
||||
|
||||
public static Texture2D CloseButtonWhiteBorderTexture;
|
||||
|
||||
public static GUIStyle WindowStyle;
|
||||
|
||||
public static GUIStyle BaseButtonStyle;
|
||||
|
||||
public static GUIStyle BaseToolbarButtonStyle;
|
||||
|
||||
public static GUIStyle BaseVerticalScrollBarStyle;
|
||||
|
||||
public static GUIStyle BaseHorizontalSliderStyle;
|
||||
|
||||
public static GUIStyle BaseHorizontalSliderThumbStyle;
|
||||
|
||||
public static GUIStyle BaseToggleStyle;
|
||||
|
||||
public static GUIStyle BaseTextFieldStyle;
|
||||
|
||||
public static GUIStyle CloseButtonStyle;
|
||||
|
||||
private static List<GUIStyle> _verticalScrollBarSkins;
|
||||
}
|
||||
526
CruiseAssist/UI/CruiseAssistStarListUI.cs
Normal file
526
CruiseAssist/UI/CruiseAssistStarListUI.cs
Normal file
@@ -0,0 +1,526 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
|
||||
public class CruiseAssistStarListUI
|
||||
{
|
||||
public static void OnGUI()
|
||||
{
|
||||
wIdx = CruiseAssistMainUI.WIdx;
|
||||
Rect[wIdx] = GUILayout.Window(99030292, Rect[wIdx], WindowFunction, "CruiseAssist - StarList", CruiseAssistMainUI.WindowStyle, Array.Empty<GUILayoutOption>());
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
if (Screen.width / scale < Rect[wIdx].xMax)
|
||||
{
|
||||
Rect[wIdx].x = Screen.width / scale - Rect[wIdx].width;
|
||||
}
|
||||
|
||||
if (Rect[wIdx].x < 0f)
|
||||
{
|
||||
Rect[wIdx].x = 0f;
|
||||
}
|
||||
|
||||
if (Screen.height / scale < Rect[wIdx].yMax)
|
||||
{
|
||||
Rect[wIdx].y = Screen.height / scale - Rect[wIdx].height;
|
||||
}
|
||||
|
||||
if (Rect[wIdx].y < 0f)
|
||||
{
|
||||
Rect[wIdx].y = 0f;
|
||||
}
|
||||
|
||||
if (lastCheckWindowLeft[wIdx] != float.MinValue)
|
||||
{
|
||||
if (Rect[wIdx].x != lastCheckWindowLeft[wIdx] || Rect[wIdx].y != lastCheckWindowTop[wIdx])
|
||||
{
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
lastCheckWindowLeft[wIdx] = Rect[wIdx].x;
|
||||
lastCheckWindowTop[wIdx] = Rect[wIdx].y;
|
||||
}
|
||||
|
||||
public static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(CruiseAssistMainUI.BaseToolbarButtonStyle)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
var array = new[] { "Normal", "History", "Bookmark" };
|
||||
GUI.changed = false;
|
||||
var selectedIndex = GUILayout.Toolbar(ListSelected, array, guistyle, Array.Empty<GUILayoutOption>());
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
}
|
||||
|
||||
if (selectedIndex != ListSelected)
|
||||
{
|
||||
ListSelected = selectedIndex;
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
scrollPos[ListSelected] = GUILayout.BeginScrollView(scrollPos[ListSelected], GUIStyle.none, new GUIStyle(CruiseAssistMainUI.BaseVerticalScrollBarStyle), Array.Empty<GUILayoutOption>());
|
||||
var nameLabelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 240f,
|
||||
stretchHeight = true,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
var nRangeLabelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 60f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleRight
|
||||
};
|
||||
var hRangeLabelStyle = new GUIStyle(nRangeLabelStyle)
|
||||
{
|
||||
fixedHeight = 40f
|
||||
};
|
||||
var nActionButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 40f,
|
||||
fixedHeight = 18f,
|
||||
margin =
|
||||
{
|
||||
top = 6
|
||||
},
|
||||
fontSize = 12
|
||||
};
|
||||
var hActionButtonStyle = new GUIStyle(nActionButtonStyle)
|
||||
{
|
||||
margin =
|
||||
{
|
||||
top = 16
|
||||
}
|
||||
};
|
||||
var nSortButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 20f,
|
||||
fixedHeight = 18f,
|
||||
margin =
|
||||
{
|
||||
top = 6
|
||||
},
|
||||
fontSize = 12
|
||||
};
|
||||
var hSortButtonStyle = new GUIStyle(nSortButtonStyle)
|
||||
{
|
||||
margin =
|
||||
{
|
||||
top = 16
|
||||
}
|
||||
};
|
||||
switch (ListSelected)
|
||||
{
|
||||
case 0:
|
||||
GameMain.galaxy.stars.Select(star => new Commons.Tuple<StarData, double>(star, (star.uPosition - GameMain.mainPlayer.uPosition).magnitude)).OrderBy(tuple => tuple.Item2).Do(delegate(Commons.Tuple<StarData, double> tuple)
|
||||
{
|
||||
var star = tuple.Item1;
|
||||
var range = tuple.Item2;
|
||||
var starName = CruiseAssistPlugin.GetStarName(star);
|
||||
var ok = false;
|
||||
if (GameMain.localStar != null && star.id == GameMain.localStar.id)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CruiseAssistPlugin.SelectTargetStar != null && star.id == CruiseAssistPlugin.SelectTargetStar.id && GameMain.history.universeObserveLevel >= (range >= 14400000.0 ? 4 : 3))
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
star.planets.Select(planet => new Commons.Tuple<PlanetData, double>(planet, (planet.uPosition - GameMain.mainPlayer.uPosition).magnitude)).AddItem(new Commons.Tuple<PlanetData, double>(null, (star.uPosition - GameMain.mainPlayer.uPosition).magnitude)).OrderBy(tuple2 => tuple2.Item2).Do(delegate(Commons.Tuple<PlanetData, double> tuple2)
|
||||
{
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var planetData = tuple2.Item1;
|
||||
var distance = tuple2.Item2;
|
||||
nameLabelStyle.normal.textColor = Color.white;
|
||||
nRangeLabelStyle.normal.textColor = Color.white;
|
||||
float height;
|
||||
if (planetData == null)
|
||||
{
|
||||
if (CruiseAssistPlugin.SelectTargetPlanet == null && CruiseAssistPlugin.SelectTargetStar != null && star.id == CruiseAssistPlugin.SelectTargetStar.id)
|
||||
{
|
||||
nameLabelStyle.normal.textColor = Color.cyan;
|
||||
nRangeLabelStyle.normal.textColor = Color.cyan;
|
||||
}
|
||||
var name = starName;
|
||||
if (CruiseAssistPlugin.Conf.MarkVisitedFlag)
|
||||
{
|
||||
name = (star.planets.Where(p => p.factory != null).Count() > 0 ? "● " : "") + name;
|
||||
}
|
||||
GUILayout.Label(name, nameLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
height = nameLabelStyle.CalcHeight(new GUIContent(name), nameLabelStyle.fixedWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CruiseAssistPlugin.SelectTargetPlanet != null && planetData.id == CruiseAssistPlugin.SelectTargetPlanet.id)
|
||||
{
|
||||
nameLabelStyle.normal.textColor = Color.cyan;
|
||||
nRangeLabelStyle.normal.textColor = Color.cyan;
|
||||
}
|
||||
var name = starName + " - " + CruiseAssistPlugin.GetPlanetName(planetData);
|
||||
if (CruiseAssistPlugin.Conf.MarkVisitedFlag)
|
||||
{
|
||||
name = (planetData.factory != null ? "● " : "") + name;
|
||||
}
|
||||
GUILayout.Label(name, nameLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
height = nameLabelStyle.CalcHeight(new GUIContent(name), nameLabelStyle.fixedWidth);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(CruiseAssistMainUI.RangeToString(planetData == null ? range : distance), height < 30f ? nRangeLabelStyle : hRangeLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button(actionSelected[ListSelected] == 0 ? "SET" : planetData == null ? "-" : CruiseAssistPlugin.Bookmark.Contains(planetData.id) ? "DEL" : "ADD", height < 30f ? nActionButtonStyle : hActionButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
if (actionSelected[ListSelected] == 0)
|
||||
{
|
||||
SelectStar(star, planetData);
|
||||
var closeStarListWhenSetTargetPlanetFlag = CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag;
|
||||
if (closeStarListWhenSetTargetPlanetFlag)
|
||||
{
|
||||
Show[wIdx] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (planetData != null)
|
||||
{
|
||||
if (CruiseAssistPlugin.Bookmark.Contains(planetData.id))
|
||||
{
|
||||
CruiseAssistPlugin.Bookmark.Remove(planetData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CruiseAssistPlugin.Bookmark.Count <= 128)
|
||||
{
|
||||
CruiseAssistPlugin.Bookmark.Add(planetData.id);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
nameLabelStyle.normal.textColor = Color.white;
|
||||
nRangeLabelStyle.normal.textColor = Color.white;
|
||||
if (CruiseAssistPlugin.SelectTargetStar != null && star.id == CruiseAssistPlugin.SelectTargetStar.id)
|
||||
{
|
||||
nameLabelStyle.normal.textColor = Color.cyan;
|
||||
nRangeLabelStyle.normal.textColor = Color.cyan;
|
||||
}
|
||||
var name = starName;
|
||||
if (CruiseAssistPlugin.Conf.MarkVisitedFlag)
|
||||
{
|
||||
name = (star.planets.Count(p => p.factory != null) > 0 ? "● " : "") + name;
|
||||
}
|
||||
GUILayout.Label(name, nameLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
var height = nameLabelStyle.CalcHeight(new GUIContent(name), nameLabelStyle.fixedWidth);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(CruiseAssistMainUI.RangeToString(range), height < 30f ? nRangeLabelStyle : hRangeLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button(actionSelected[ListSelected] == 0 ? "SET" : "-", height < 30f ? nActionButtonStyle : hActionButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
if (actionSelected[ListSelected] == 0)
|
||||
{
|
||||
SelectStar(star, null);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 1 or 2:
|
||||
{
|
||||
var highlighted = false;
|
||||
var enumBookmark = ListSelected != 1 ? CruiseAssistPlugin.Bookmark.ToList() : Enumerable.Reverse(CruiseAssistPlugin.History);
|
||||
if (ListSelected == 1 && actionSelected[ListSelected] != 2 && CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
||||
{
|
||||
enumBookmark = enumBookmark.Distinct();
|
||||
}
|
||||
var listIndex = -1;
|
||||
enumBookmark.Do(delegate(int id)
|
||||
{
|
||||
listIndex += 1;
|
||||
var planetData = GameMain.galaxy.PlanetById(id);
|
||||
if (planetData == null) return;
|
||||
var magnitude = (planetData.uPosition - GameMain.mainPlayer.uPosition).magnitude;
|
||||
nameLabelStyle.normal.textColor = Color.white;
|
||||
nRangeLabelStyle.normal.textColor = Color.white;
|
||||
if (!highlighted && CruiseAssistPlugin.SelectTargetPlanet != null && planetData.id == CruiseAssistPlugin.SelectTargetPlanet.id)
|
||||
{
|
||||
nameLabelStyle.normal.textColor = Color.cyan;
|
||||
nRangeLabelStyle.normal.textColor = Color.cyan;
|
||||
highlighted = true;
|
||||
}
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var name = CruiseAssistPlugin.GetStarName(planetData.star) + " - " + CruiseAssistPlugin.GetPlanetName(planetData);
|
||||
if (CruiseAssistPlugin.Conf.MarkVisitedFlag)
|
||||
{
|
||||
name = (planetData.factory != null ? "● " : "") + name;
|
||||
}
|
||||
GUILayout.Label(name, nameLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
var height = nameLabelStyle.CalcHeight(new GUIContent(name), nameLabelStyle.fixedWidth);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(CruiseAssistMainUI.RangeToString(magnitude), height < 30f ? nRangeLabelStyle : hRangeLabelStyle, Array.Empty<GUILayoutOption>());
|
||||
if (ListSelected == 2 && actionSelected[ListSelected] == 1)
|
||||
{
|
||||
var index = CruiseAssistPlugin.Bookmark.IndexOf(id);
|
||||
var first = index == 0;
|
||||
var last = index == CruiseAssistPlugin.Bookmark.Count - 1;
|
||||
if (GUILayout.Button(last ? "-" : "↓", height < 30f ? nSortButtonStyle : hSortButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
if (!last)
|
||||
{
|
||||
CruiseAssistPlugin.Bookmark.RemoveAt(index);
|
||||
CruiseAssistPlugin.Bookmark.Insert(index + 1, id);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button(first ? "-" : "↑", height < 30f ? nSortButtonStyle : hSortButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
if (!first)
|
||||
{
|
||||
CruiseAssistPlugin.Bookmark.RemoveAt(index);
|
||||
CruiseAssistPlugin.Bookmark.Insert(index - 1, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button(actionSelected[ListSelected] == 0 ? "SET" : actionSelected[ListSelected] == 2 ? ListSelected == 1 && listIndex == 0 ? "-" : "DEL" : CruiseAssistPlugin.Bookmark.Contains(id) ? "DEL" : "ADD", height < 30f ? nActionButtonStyle : hActionButtonStyle, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
switch (actionSelected[ListSelected])
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
SelectStar(planetData.star, planetData);
|
||||
if (CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag)
|
||||
{
|
||||
Show[wIdx] = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (ListSelected == 1)
|
||||
{
|
||||
if (CruiseAssistPlugin.Bookmark.Contains(id))
|
||||
{
|
||||
CruiseAssistPlugin.Bookmark.Remove(id);
|
||||
}
|
||||
else if (CruiseAssistPlugin.Bookmark.Count <= 128)
|
||||
{
|
||||
CruiseAssistPlugin.Bookmark.Add(id);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (actionSelected[ListSelected] == 2)
|
||||
{
|
||||
switch (ListSelected)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (listIndex != 0)
|
||||
{
|
||||
CruiseAssistPlugin.History.RemoveAt(CruiseAssistPlugin.History.Count - 1 - listIndex);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
CruiseAssistPlugin.Bookmark.Remove(planetData.id);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var buttonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
var buttons = new[]
|
||||
{
|
||||
new[] { "Target", "Bookmark" },
|
||||
new[] { "Target", "Bookmark", "Delete" },
|
||||
new[] { "Target", "Sort", "Delete" }
|
||||
};
|
||||
if (GUILayout.Button(buttons[ListSelected][actionSelected[ListSelected]], buttonStyle, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
actionSelected[ListSelected]++;
|
||||
actionSelected[ListSelected] %= buttons[ListSelected].Length;
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (!CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag && GUILayout.Button("Close", buttonStyle, Array.Empty<GUILayoutOption>()))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
Show[wIdx] = false;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
if (GUI.Button(new Rect(Rect[wIdx].width - 16f, 1f, 16f, 16f), "", CruiseAssistMainUI.CloseButtonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
Show[wIdx] = false;
|
||||
}
|
||||
GUI.DragWindow();
|
||||
}
|
||||
|
||||
public static void SelectStar(StarData star, PlanetData planet)
|
||||
{
|
||||
CruiseAssistPlugin.SelectTargetStar = star;
|
||||
CruiseAssistPlugin.SelectTargetPlanet = planet;
|
||||
var uiGame = UIRoot.instance.uiGame;
|
||||
if (CruiseAssistPlugin.Conf.SelectFocusFlag && uiGame.starmap.active)
|
||||
{
|
||||
if (star != null)
|
||||
{
|
||||
var uistarmapStar = uiGame.starmap.starUIs.Where(s => s.star.id == star.id).FirstOrDefault();
|
||||
if (uistarmapStar != null)
|
||||
{
|
||||
UIStarmap_OnStarClick(uiGame.starmap, uistarmapStar);
|
||||
uiGame.starmap.OnCursorFunction2Click(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (planet != null)
|
||||
{
|
||||
var uistarmapPlanet = uiGame.starmap.planetUIs.Where(p => p.planet.id == planet.id).FirstOrDefault();
|
||||
if (uistarmapPlanet != null)
|
||||
{
|
||||
UIStarmap_OnPlanetClick(uiGame.starmap, uistarmapPlanet);
|
||||
uiGame.starmap.OnCursorFunction2Click(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (planet != null)
|
||||
{
|
||||
GameMain.mainPlayer.navigation.indicatorAstroId = planet.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (star != null)
|
||||
{
|
||||
GameMain.mainPlayer.navigation.indicatorAstroId = star.id * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.mainPlayer.navigation.indicatorAstroId = 0;
|
||||
}
|
||||
}
|
||||
CruiseAssistPlugin.SelectTargetAstroId = GameMain.mainPlayer.navigation.indicatorAstroId;
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
extension.SetTargetAstroId(CruiseAssistPlugin.SelectTargetAstroId);
|
||||
});
|
||||
}
|
||||
|
||||
private static void UIStarmap_OnStarClick(UIStarmap starmap, UIStarmapStar star)
|
||||
{
|
||||
var traverse = Traverse.Create(starmap);
|
||||
if (starmap.focusStar != star)
|
||||
{
|
||||
if (starmap.viewPlanet != null || (starmap.viewStar != null && star.star != starmap.viewStar))
|
||||
{
|
||||
starmap.screenCameraController.DisablePositionLock();
|
||||
}
|
||||
starmap.focusPlanet = null;
|
||||
starmap.focusStar = star;
|
||||
traverse.Field("_lastClickTime").SetValue(0.0);
|
||||
}
|
||||
traverse.Field("forceUpdateCursorView").SetValue(true);
|
||||
}
|
||||
|
||||
private static void UIStarmap_OnPlanetClick(UIStarmap starmap, UIStarmapPlanet planet)
|
||||
{
|
||||
var traverse = Traverse.Create(starmap);
|
||||
if (starmap.focusPlanet != planet)
|
||||
{
|
||||
if ((starmap.viewPlanet != null && planet.planet != starmap.viewPlanet) || starmap.viewStar != null)
|
||||
{
|
||||
starmap.screenCameraController.DisablePositionLock();
|
||||
}
|
||||
starmap.focusPlanet = planet;
|
||||
starmap.focusStar = null;
|
||||
traverse.Field("_lastClickTime").SetValue(0.0);
|
||||
}
|
||||
traverse.Field("forceUpdateCursorView").SetValue(true);
|
||||
}
|
||||
|
||||
private static int wIdx;
|
||||
|
||||
public const float WindowWidth = 400f;
|
||||
|
||||
public const float WindowHeight = 480f;
|
||||
|
||||
public static readonly bool[] Show = new bool[2];
|
||||
|
||||
public static readonly Rect[] Rect = {
|
||||
new Rect(0f, 0f, 400f, 480f),
|
||||
new Rect(0f, 0f, 400f, 480f)
|
||||
};
|
||||
|
||||
public static int ListSelected;
|
||||
|
||||
public static readonly int[] actionSelected = new int[3];
|
||||
|
||||
private static readonly float[] lastCheckWindowLeft = { float.MinValue, float.MinValue };
|
||||
|
||||
private static readonly float[] lastCheckWindowTop = { float.MinValue, float.MinValue };
|
||||
|
||||
private static readonly Vector2[] scrollPos = {
|
||||
Vector2.zero,
|
||||
Vector2.zero,
|
||||
Vector2.zero
|
||||
};
|
||||
|
||||
private const string VisitedMark = "● ";
|
||||
|
||||
private const string NonVisitMark = "";
|
||||
}
|
||||
Reference in New Issue
Block a user