mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-12 01:23:31 +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 CruiseAssist.Commons;
|
||||
using CruiseAssist.Enums;
|
||||
@@ -82,8 +84,10 @@ internal class CruiseAssistConfigManager(ConfigFile config) : ConfigManager(conf
|
||||
var reset = CruiseAssistPlugin.Seed != -1;
|
||||
if (!reset) return;
|
||||
CruiseAssistPlugin.Seed = -1;
|
||||
CruiseAssistPlugin.History = new List<int>();
|
||||
CruiseAssistPlugin.Bookmark = new List<int>();
|
||||
CruiseAssistPlugin.History = [];
|
||||
CruiseAssistPlugin.HistoryDistinct = [];
|
||||
CruiseAssistPlugin.Bookmark = [];
|
||||
CruiseAssistPlugin.BookmarkSet = [];
|
||||
LogManager.LogInfo("clear seed.");
|
||||
}
|
||||
else
|
||||
@@ -91,7 +95,9 @@ internal class CruiseAssistConfigManager(ConfigFile config) : ConfigManager(conf
|
||||
if (CruiseAssistPlugin.Seed == GameMain.galaxy.seed) return;
|
||||
CruiseAssistPlugin.Seed = GameMain.galaxy.seed;
|
||||
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.BookmarkSet = [..CruiseAssistPlugin.Bookmark];
|
||||
LogManager.LogInfo($"change seed {CruiseAssistPlugin.Seed}.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,28 @@ public class CruiseAssistPlugin : BaseUnityPlugin
|
||||
internal static readonly List<ICruiseAssistExtensionAPI> Extensions = [];
|
||||
private Harmony _harmony;
|
||||
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);
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ internal class Patch_GameMain
|
||||
[HarmonyPostfix]
|
||||
public static void Begin_Postfix()
|
||||
{
|
||||
CruiseAssistStarListUI.OnReset();
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.GameMainBegin);
|
||||
CruiseAssistPlugin.Extensions.ForEach(delegate(ICruiseAssistExtensionAPI extension)
|
||||
{
|
||||
CruiseAssistStarListUI.OnReset();
|
||||
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 >= 128)
|
||||
{
|
||||
CruiseAssistPlugin.History.RemoveAt(0);
|
||||
}
|
||||
CruiseAssistPlugin.History.Add(GameMain.localPlanet.id);
|
||||
CruiseAssistPlugin.AddHistory(GameMain.localPlanet.id);
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.State);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +70,6 @@ public static class CruiseAssistStarListUI
|
||||
{
|
||||
fixedHeight = 40f
|
||||
};
|
||||
_hRangeLabelHighlightStyle = new GUIStyle(_hRangeLabelStyle)
|
||||
{
|
||||
fixedHeight = 40f
|
||||
};
|
||||
_nActionButtonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 40f,
|
||||
@@ -232,7 +228,7 @@ public static class CruiseAssistStarListUI
|
||||
var enumBookmark = ListSelected != 1 ? CruiseAssistPlugin.Bookmark : Enumerable.Reverse(CruiseAssistPlugin.History);
|
||||
if (ListSelected == 1 && ActionSelected[ListSelected] != 2 && CruiseAssistPlugin.Conf.HideDuplicateHistoryFlag)
|
||||
{
|
||||
enumBookmark = Enumerable.Reverse(CruiseAssistPlugin.HistoryDistinct);
|
||||
enumBookmark = CruiseAssistPlugin.HistoryDistinct;
|
||||
}
|
||||
|
||||
var listIndex = -1;
|
||||
@@ -334,7 +330,7 @@ public static class CruiseAssistStarListUI
|
||||
{
|
||||
if (listIndex != 0)
|
||||
{
|
||||
CruiseAssistPlugin.History.RemoveAt(CruiseAssistPlugin.History.Count - 1 - listIndex);
|
||||
CruiseAssistPlugin.RemoveHistoryAt(CruiseAssistPlugin.History.Count - 1 - listIndex);
|
||||
CruiseAssistMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user