mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-16 03:23:32 +08:00
Progression of optimizations
This commit is contained in:
@@ -1,15 +1,80 @@
|
||||
using System;
|
||||
using CruiseAssist.Enums;
|
||||
using CruiseAssist.Enums;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CruiseAssist.UI;
|
||||
|
||||
public static class CruiseAssistConfigUI
|
||||
{
|
||||
public static void OnInit()
|
||||
{
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 120f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
_toolbarButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseToolbarButtonStyle)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
_uiScaleStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 60f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
_horizontalSliderStyle = new GUIStyle(CruiseAssistMainUI.BaseHorizontalSliderStyle)
|
||||
{
|
||||
fixedWidth = 180f,
|
||||
margin =
|
||||
{
|
||||
top = 10
|
||||
},
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
_horizontalSliderThunbStyle = new GUIStyle(CruiseAssistMainUI.BaseHorizontalSliderThumbStyle)
|
||||
{
|
||||
border = new RectOffset(1, 1, 8, 8)
|
||||
};
|
||||
_percentStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 40f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
_toggleStyle = new GUIStyle(CruiseAssistMainUI.BaseToggleStyle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
_setButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 60f,
|
||||
fixedHeight = 18f,
|
||||
margin =
|
||||
{
|
||||
top = 6
|
||||
},
|
||||
fontSize = 12
|
||||
};
|
||||
_closeButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 80f,
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
Rect[_wIdx] = GUILayout.Window(99030293, Rect[_wIdx], WindowFunction, "CruiseAssist - Config", CruiseAssistMainUI.WindowStyle, Array.Empty<GUILayoutOption>());
|
||||
Rect[_wIdx] = GUILayout.Window(99030293, Rect[_wIdx], WindowFunction, "CruiseAssist - Config", CruiseAssistMainUI.WindowStyle);
|
||||
var num = CruiseAssistMainUI.Scale / 100f;
|
||||
if (Screen.width / num < Rect[_wIdx].xMax)
|
||||
{
|
||||
@@ -40,35 +105,21 @@ public static class CruiseAssistConfigUI
|
||||
|
||||
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;
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Main Window Style :", _labelStyle);
|
||||
var viewMode = 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)
|
||||
var value = GUILayout.Toolbar(viewMode, ViewModeTexts, _toolbarButtonStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
}
|
||||
if (num2 != num)
|
||||
if (value != viewMode)
|
||||
{
|
||||
if (num2 != 0)
|
||||
if (value != 0)
|
||||
{
|
||||
if (num2 == 1)
|
||||
if (value == 1)
|
||||
{
|
||||
CruiseAssistMainUI.ViewMode = CruiseAssistMainUIViewMode.Mini;
|
||||
}
|
||||
@@ -80,128 +131,78 @@ public static class CruiseAssistConfigUI
|
||||
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>());
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("UI Scale :", _uiScaleStyle);
|
||||
TempScale = GUILayout.HorizontalSlider(TempScale, 80f, 240f, _horizontalSliderStyle, _horizontalSliderThunbStyle);
|
||||
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)
|
||||
GUILayout.Label(TempScale.ToString("0") + "%", _percentStyle);
|
||||
if (GUILayout.Button("SET", _setButtonStyle))
|
||||
{
|
||||
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>());
|
||||
CruiseAssistPlugin.Conf.MarkVisitedFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.MarkVisitedFlag, "Mark the visited system and planet.".Translate(), _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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
CruiseAssistPlugin.Conf.SelectFocusFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.SelectFocusFlag, "Focus when select target.".Translate(), _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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag, "Hide duplicate history.".Translate(), _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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
CruiseAssistPlugin.Conf.AutoDisableLockCursorFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.AutoDisableLockCursorFlag, "Disable lock cursor when starting sail mode.".Translate(), _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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
CruiseAssistPlugin.Conf.ShowMainWindowWhenTargetSelectedEvenNotSailModeFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.ShowMainWindowWhenTargetSelectedEvenNotSailModeFlag, "Show main window when target selected, even not sail mode.".Translate(), _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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.CloseStarListWhenSetTargetPlanetFlag, "Close StarList when set target planet.".Translate(), _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(), guistyle5, Array.Empty<GUILayoutOption>());
|
||||
CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag = GUILayout.Toggle(CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag, "Hide bottom close button.".Translate(), _toggleStyle);
|
||||
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.BeginHorizontal();
|
||||
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)
|
||||
if (!CruiseAssistPlugin.Conf.HideBottomCloseButtonFlag && GUILayout.Button("Close", _closeButtonStyle))
|
||||
{
|
||||
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)
|
||||
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;
|
||||
@@ -210,21 +211,25 @@ public static class CruiseAssistConfigUI
|
||||
}
|
||||
|
||||
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 = {
|
||||
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 };
|
||||
|
||||
];
|
||||
private static readonly float[] LastCheckWindowLeft = [float.MinValue, float.MinValue];
|
||||
private static readonly float[] LastCheckWindowTop = [float.MinValue, float.MinValue];
|
||||
public static float TempScale;
|
||||
private static GUIStyle _labelStyle;
|
||||
private static GUIStyle _toolbarButtonStyle;
|
||||
private static GUIStyle _uiScaleStyle;
|
||||
private static GUIStyle _horizontalSliderStyle;
|
||||
private static GUIStyle _horizontalSliderThunbStyle;
|
||||
private static GUIStyle _percentStyle;
|
||||
private static GUIStyle _toggleStyle;
|
||||
private static GUIStyle _setButtonStyle;
|
||||
private static GUIStyle _closeButtonStyle;
|
||||
private static readonly string[] ViewModeTexts = ["FULL", "MINI"];
|
||||
}
|
||||
Reference in New Issue
Block a user