mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2026-02-04 14:12:18 +08:00
WIP
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using CruiseAssist.Commons;
|
using CruiseAssist.Commons;
|
||||||
using CruiseAssist.Enums;
|
using CruiseAssist.Enums;
|
||||||
@@ -82,8 +84,10 @@ internal class CruiseAssistConfigManager(ConfigFile config) : ConfigManager(conf
|
|||||||
var reset = CruiseAssistPlugin.Seed != -1;
|
var reset = CruiseAssistPlugin.Seed != -1;
|
||||||
if (!reset) return;
|
if (!reset) return;
|
||||||
CruiseAssistPlugin.Seed = -1;
|
CruiseAssistPlugin.Seed = -1;
|
||||||
CruiseAssistPlugin.History = new List<int>();
|
CruiseAssistPlugin.History = [];
|
||||||
CruiseAssistPlugin.Bookmark = new List<int>();
|
CruiseAssistPlugin.HistoryDistinct = [];
|
||||||
|
CruiseAssistPlugin.Bookmark = [];
|
||||||
|
CruiseAssistPlugin.BookmarkSet = [];
|
||||||
LogManager.LogInfo("clear seed.");
|
LogManager.LogInfo("clear seed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -91,7 +95,9 @@ internal class CruiseAssistConfigManager(ConfigFile config) : ConfigManager(conf
|
|||||||
if (CruiseAssistPlugin.Seed == GameMain.galaxy.seed) return;
|
if (CruiseAssistPlugin.Seed == GameMain.galaxy.seed) return;
|
||||||
CruiseAssistPlugin.Seed = GameMain.galaxy.seed;
|
CruiseAssistPlugin.Seed = GameMain.galaxy.seed;
|
||||||
CruiseAssistPlugin.History = ListUtils.ParseToIntList(Bind("Save", $"History_{CruiseAssistPlugin.Seed}", "").Value);
|
CruiseAssistPlugin.History = ListUtils.ParseToIntList(Bind("Save", $"History_{CruiseAssistPlugin.Seed}", "").Value);
|
||||||
|
CruiseAssistPlugin.HistoryDistinct = Enumerable.Reverse(CruiseAssistPlugin.History).Distinct().ToList();
|
||||||
CruiseAssistPlugin.Bookmark = ListUtils.ParseToIntList(Bind("Save", $"Bookmark_{CruiseAssistPlugin.Seed}", "").Value);
|
CruiseAssistPlugin.Bookmark = ListUtils.ParseToIntList(Bind("Save", $"Bookmark_{CruiseAssistPlugin.Seed}", "").Value);
|
||||||
|
CruiseAssistPlugin.BookmarkSet = [..CruiseAssistPlugin.Bookmark];
|
||||||
LogManager.LogInfo($"change seed {CruiseAssistPlugin.Seed}.");
|
LogManager.LogInfo($"change seed {CruiseAssistPlugin.Seed}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,28 @@ public class CruiseAssistPlugin : BaseUnityPlugin
|
|||||||
internal static readonly List<ICruiseAssistExtensionAPI> Extensions = [];
|
internal static readonly List<ICruiseAssistExtensionAPI> Extensions = [];
|
||||||
private Harmony _harmony;
|
private Harmony _harmony;
|
||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
|
|
||||||
|
public static void AddHistory(int id)
|
||||||
|
{
|
||||||
|
if (History.Count >= 128)
|
||||||
|
{
|
||||||
|
History.RemoveAt(0);
|
||||||
|
}
|
||||||
|
History.Add(id);
|
||||||
|
HistoryDistinct = Enumerable.Reverse(History).Distinct().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveHistoryAt(int index)
|
||||||
|
{
|
||||||
|
History.RemoveAt(index);
|
||||||
|
HistoryDistinct = Enumerable.Reverse(History).Distinct().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ClearHistory()
|
||||||
|
{
|
||||||
|
History.Clear();
|
||||||
|
HistoryDistinct.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public static bool HasBookmark(int id) => BookmarkSet.Contains(id);
|
public static bool HasBookmark(int id) => BookmarkSet.Contains(id);
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ internal class Patch_GameMain
|
|||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void Begin_Postfix()
|
public static void Begin_Postfix()
|
||||||
{
|
{
|
||||||
|
CruiseAssistStarListUI.OnReset();
|
||||||
ConfigManager.CheckConfig(ConfigManager.Step.GameMainBegin);
|
ConfigManager.CheckConfig(ConfigManager.Step.GameMainBegin);
|
||||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||||
{
|
{
|
||||||
CruiseAssistStarListUI.OnReset();
|
|
||||||
extension.CheckConfig(ConfigManager.Step.GameMainBegin.ToString());
|
extension.CheckConfig(ConfigManager.Step.GameMainBegin.ToString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,7 @@ internal class Patch_PlayerMoveWalk
|
|||||||
{
|
{
|
||||||
if (CruiseAssistPlugin.History.Count == 0 || CruiseAssistPlugin.History.Last() != GameMain.localPlanet.id)
|
if (CruiseAssistPlugin.History.Count == 0 || CruiseAssistPlugin.History.Last() != GameMain.localPlanet.id)
|
||||||
{
|
{
|
||||||
if (CruiseAssistPlugin.History.Count >= 128)
|
CruiseAssistPlugin.AddHistory(GameMain.localPlanet.id);
|
||||||
{
|
|
||||||
CruiseAssistPlugin.History.RemoveAt(0);
|
|
||||||
}
|
|
||||||
CruiseAssistPlugin.History.Add(GameMain.localPlanet.id);
|
|
||||||
ConfigManager.CheckConfig(ConfigManager.Step.State);
|
ConfigManager.CheckConfig(ConfigManager.Step.State);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,10 +70,6 @@ public static class CruiseAssistStarListUI
|
|||||||
{
|
{
|
||||||
fixedHeight = 40f
|
fixedHeight = 40f
|
||||||
};
|
};
|
||||||
_hRangeLabelHighlightStyle = new GUIStyle(_hRangeLabelStyle)
|
|
||||||
{
|
|
||||||
fixedHeight = 40f
|
|
||||||
};
|
|
||||||
_nActionButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
_nActionButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||||
{
|
{
|
||||||
fixedWidth = 40f,
|
fixedWidth = 40f,
|
||||||
@@ -232,7 +228,7 @@ public static class CruiseAssistStarListUI
|
|||||||
var enumBookmark = ListSelected != 1 ? CruiseAssistPlugin.Bookmark : Enumerable.Reverse(CruiseAssistPlugin.History);
|
var enumBookmark = ListSelected != 1 ? CruiseAssistPlugin.Bookmark : Enumerable.Reverse(CruiseAssistPlugin.History);
|
||||||
if (ListSelected == 1 && ActionSelected[ListSelected] != 2 && CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
if (ListSelected == 1 && ActionSelected[ListSelected] != 2 && CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
||||||
{
|
{
|
||||||
enumBookmark = Enumerable.Reverse(CruiseAssistPlugin.HistoryDistinct);
|
enumBookmark = CruiseAssistPlugin.HistoryDistinct;
|
||||||
}
|
}
|
||||||
|
|
||||||
var listIndex = -1;
|
var listIndex = -1;
|
||||||
@@ -334,7 +330,7 @@ public static class CruiseAssistStarListUI
|
|||||||
{
|
{
|
||||||
if (listIndex != 0)
|
if (listIndex != 0)
|
||||||
{
|
{
|
||||||
CruiseAssistPlugin.History.RemoveAt(CruiseAssistPlugin.History.Count - 1 - listIndex);
|
CruiseAssistPlugin.RemoveHistoryAt(CruiseAssistPlugin.History.Count - 1 - listIndex);
|
||||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user