1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 06:13:36 +08:00

UXAssist v1.3.2

This commit is contained in:
2025-04-27 19:31:49 +08:00
parent 2124719de0
commit 5545d7a2bf
7 changed files with 107 additions and 100 deletions

View File

@@ -3,6 +3,10 @@
## Changlog ## Changlog
* 1.3.2
+ Add a checkbox to make union of results in starmap filter.
+ Fix some starmap vein/planet filter conditions.
+ Fix compatibility with `NebulaMultiplayerMod`.
* 1.3.1 * 1.3.1
+ Fix an issue that some UI elements are hidden while hitting the newly added combobox on Starmap. + Fix an issue that some UI elements are hidden while hitting the newly added combobox on Starmap.
+ Fix an issue that star name filter is not applied if `Shortcut keys for showing stars` is not enabled. + Fix an issue that star name filter is not applied if `Shortcut keys for showing stars` is not enabled.
@@ -289,6 +293,10 @@
## 更新日志 ## 更新日志
* 1.3.2
+ 添加了一个勾选框用于对星图过滤器的结果进行并集操作
+ 修复了一些星图过滤条件
+ 修复了与`NebulaMultiplayerMod`的兼容性问题
* 1.3.1 * 1.3.1
+ 修复了在星图上点击新增的下拉框时部分UI元素被隐藏的问题 + 修复了在星图上点击新增的下拉框时部分UI元素被隐藏的问题
+ 修复了未启用`显示星系名称快捷键`时星系名称过滤器不生效的问题 + 修复了未启用`显示星系名称快捷键`时星系名称过滤器不生效的问题

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using HarmonyLib; using HarmonyLib;
namespace UXAssist.Common; namespace UXAssist.Common;

View File

@@ -8,6 +8,7 @@ using UnityEngine.UI;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Collections.Generic;
public static class UIFunctions public static class UIFunctions
{ {
@@ -36,6 +37,7 @@ public static class UIFunctions
I18N.Add("KEYOpenUXAssistConfigWindow", "[UXA] Open UXAssist Config Window", "[UXA] 打开UX助手设置面板"); I18N.Add("KEYOpenUXAssistConfigWindow", "[UXA] Open UXAssist Config Window", "[UXA] 打开UX助手设置面板");
I18N.Add("High yield", "High yield", "高产"); I18N.Add("High yield", "High yield", "高产");
I18N.Add("Perfect", "Perfect", "完美"); I18N.Add("Perfect", "Perfect", "完美");
I18N.Add("Union results", "Union results", "结果取并集");
I18N.Add("All 6 Basic Ores", "All 6 Basic Ores", "六种基础矿物齐全"); I18N.Add("All 6 Basic Ores", "All 6 Basic Ores", "六种基础矿物齐全");
I18N.Add("Show original name", "Show original name", "显示原始名称"); I18N.Add("Show original name", "Show original name", "显示原始名称");
I18N.Add("Show distance", "Show distance", "显示距离"); I18N.Add("Show distance", "Show distance", "显示距离");
@@ -44,16 +46,6 @@ public static class UIFunctions
I18N.OnInitialized += RecreateConfigWindow; I18N.OnInitialized += RecreateConfigWindow;
} }
public static void OnUpdate()
{
if (!_starmapFilterInitialized || _starmapFilterToggler == null || _starmapFilterToggler.gameObject.activeSelf) return;
if (PlanetModelingManager.scnPlanetReqList.Count == 0)
{
StarmapUpdateFilterValues();
_starmapFilterToggler.gameObject.SetActive(true);
}
}
public static void OnInputUpdate() public static void OnInputUpdate()
{ {
if (_toggleKey.keyValue) if (_toggleKey.keyValue)
@@ -82,7 +74,6 @@ public static class UIFunctions
} }
} }
private static readonly int[] FilterPlanetThemes = [16, 23, 15, 22, 25, 21, 14, 17, 19, 7, 10, 20, 24, 9, 13];
public static void InitMenuButtons() public static void InitMenuButtons()
{ {
if (_initialized) return; if (_initialized) return;
@@ -200,6 +191,17 @@ public static class UIFunctions
Common.Util.LoadEmbeddedSprite("assets/planet_icon/25.png") Common.Util.LoadEmbeddedSprite("assets/planet_icon/25.png")
]; ];
private static readonly (int, int)[] FilterVeinIds = [(9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (7, 0), (0, 1116), (0, 1000), (8, 1011), (0, 1120), (0, 1121)];
private static readonly int[] FilterPlanetThemes = [16, 23, 15, 22, 25, 21, 14, 17, 19, 7, 10, 20, 24, 9, 13];
private static readonly Dictionary<int, int> ItemToVeinBitFlagMap = new()
{
{1011, 8},
{1120, 20},
{1121, 21},
{1116, 22},
{1000, 23},
};
public static void InitStarmapButtons() public static void InitStarmapButtons()
{ {
var uiRoot = UIRoot.instance; var uiRoot = UIRoot.instance;
@@ -254,6 +256,12 @@ public static class UIFunctions
UI.MyCheckButton.CreateCheckButton(24, 354, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), UI.MyCheckButton.CreateCheckButton(24, 354, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24),
UI.MyCheckButton.CreateCheckButton(24, 378, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), UI.MyCheckButton.CreateCheckButton(24, 378, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24),
]; ];
var unionCheckBox = UI.MyCheckBox.CreateCheckBox(312, 0, rtrans, false, "Union results".Translate(), 15).WithSmallerBox(24f);
unionCheckBox.gameObject.SetActive(false);
unionCheckBox.OnChecked += () =>
{
UpdateStarmapStarFilters();
};
var allOresText = MyWindow.AddText(20, 190, rtrans, "All 6 Basic Ores".Translate(), 12); var allOresText = MyWindow.AddText(20, 190, rtrans, "All 6 Basic Ores".Translate(), 12);
allOresText.gameObject.SetActive(false); allOresText.gameObject.SetActive(false);
_starmapFilterToggler.OnChecked += UpdateButtons; _starmapFilterToggler.OnChecked += UpdateButtons;
@@ -276,23 +284,21 @@ public static class UIFunctions
GameLogic.OnDataLoaded += () => GameLogic.OnDataLoaded += () =>
{ {
VeinProto veinProto; VeinProto veinProto;
for (int i = 0; i < 6; i++) ItemProto itemProto;
for (int i = 0; i < 12; i++)
{ {
veinProto = LDB.veins.Select(i + 9); var (veinProtoId, itemProtoId) = FilterVeinIds[i];
if (itemProtoId != 0)
{
itemProto = LDB.items.Select(itemProtoId);
buttons[i].SetIcon(itemProto.iconSprite);
}
else if (veinProtoId != 0)
{
veinProto = LDB.veins.Select(veinProtoId);
buttons[i].SetIcon(veinProto.iconSprite); buttons[i].SetIcon(veinProto.iconSprite);
} }
veinProto = LDB.veins.Select(7); }
buttons[6].SetIcon(veinProto.iconSprite);
var itemProto = LDB.items.Select(1011);
buttons[7].SetIcon(itemProto.iconSprite);
itemProto = LDB.items.Select(1116);
buttons[8].SetIcon(itemProto.iconSprite);
itemProto = LDB.items.Select(1000);
buttons[9].SetIcon(itemProto.iconSprite);
itemProto = LDB.items.Select(1120);
buttons[10].SetIcon(itemProto.iconSprite);
itemProto = LDB.items.Select(1121);
buttons[11].SetIcon(itemProto.iconSprite);
for (int i = 0; i < FilterPlanetThemes.Length; i++) for (int i = 0; i < FilterPlanetThemes.Length; i++)
{ {
@@ -377,6 +383,10 @@ public static class UIFunctions
if (star != null) PlanetModelingManager.RequestScanStar(star); if (star != null) PlanetModelingManager.RequestScanStar(star);
} }
_starmapFilterInitialized = true; _starmapFilterInitialized = true;
if (PlanetModelingManager.scnPlanetReqList.Count == 0)
{
OnPlanetScanEnded();
}
}; };
GameLogic.OnGameEnd += () => GameLogic.OnGameEnd += () =>
{ {
@@ -399,24 +409,21 @@ public static class UIFunctions
if (buttons != null) if (buttons != null)
{ {
VeinProto veinProto; VeinProto veinProto;
for (int i = 0; i < 6; i++) ItemProto itemProto;
for (int i = 0; i < 12; i++)
{ {
veinProto = LDB.veins.Select(i + 9); var (veinProtoId, itemProtoId) = FilterVeinIds[i];
if (itemProtoId != 0)
{
itemProto = LDB.items.Select(itemProtoId);
buttons[i].WithTip(itemProto.Name);
}
else if (veinProtoId != 0)
{
veinProto = LDB.veins.Select(veinProtoId);
buttons[i].WithTip(veinProto.Name); buttons[i].WithTip(veinProto.Name);
} }
var itemProto = LDB.items.Select(1007); }
buttons[6].WithTip(itemProto.Name);
veinProto = LDB.veins.Select(8);
buttons[7].WithTip(veinProto.Name);
itemProto = LDB.items.Select(1116);
buttons[8].WithTip(itemProto.Name);
itemProto = LDB.items.Select(1000);
buttons[9].WithTip(itemProto.Name);
itemProto = LDB.items.Select(1120);
buttons[10].WithTip(itemProto.Name);
itemProto = LDB.items.Select(1121);
buttons[11].WithTip(itemProto.Name);
for (int i = 0; i < FilterPlanetThemes.Length; i++) for (int i = 0; i < FilterPlanetThemes.Length; i++)
{ {
var theme = FilterPlanetThemes[i]; var theme = FilterPlanetThemes[i];
@@ -450,6 +457,7 @@ public static class UIFunctions
button.Checked = false; button.Checked = false;
} }
} }
unionCheckBox.gameObject.SetActive(chk);
allOresText.gameObject.SetActive(chk); allOresText.gameObject.SetActive(chk);
_starmapFilterToggler.SetLabelText(chk ? "X" : ">>"); _starmapFilterToggler.SetLabelText(chk ? "X" : ">>");
if (!chk) if (!chk)
@@ -460,38 +468,23 @@ public static class UIFunctions
void UpdateStarmapStarFilters() void UpdateStarmapStarFilters()
{ {
var filterValue = 0UL; var filterValue = 0UL;
var union = unionCheckBox.Checked;
if (_starmapFilterToggler.Checked) if (_starmapFilterToggler.Checked)
{ {
for (int i = 0; i < 6; i++) for (int i = 0; i < 12; i++)
{ {
if (buttons[i].Checked) if (buttons[i].Checked)
{ {
filterValue |= 1UL << (i + 9); var (veinProtoId, itemProtoId) = FilterVeinIds[i];
} if (veinProtoId != 0)
}
if (buttons[6].Checked)
{ {
filterValue |= 1UL << 7; filterValue |= 1UL << veinProtoId;
} }
if (buttons[7].Checked) else if (itemProtoId != 0)
{ {
filterValue |= 1UL << 8; filterValue |= 1UL << ItemToVeinBitFlagMap[itemProtoId];
} }
if (buttons[8].Checked)
{
filterValue |= 1UL << 22;
} }
if (buttons[9].Checked)
{
filterValue |= 1UL << 23;
}
if (buttons[10].Checked)
{
filterValue |= 1UL << 20;
}
if (buttons[11].Checked)
{
filterValue |= 1UL << 21;
} }
for (int i = 0; i < FilterPlanetThemes.Length; i++) for (int i = 0; i < FilterPlanetThemes.Length; i++)
{ {
@@ -512,12 +505,19 @@ public static class UIFunctions
} }
for (int i = _starmapStarFilterValues.Length - 1; i >= 0; i--) for (int i = _starmapStarFilterValues.Length - 1; i >= 0; i--)
{ {
ShowStarName[i] = (_starmapStarFilterValues[i] & filterValue) == filterValue; ShowStarName[i] = union ? (_starmapStarFilterValues[i] & filterValue) != 0 : (_starmapStarFilterValues[i] & filterValue) == filterValue;
} }
SetStarFilterEnabled(true); SetStarFilterEnabled(true);
} }
} }
public static void OnPlanetScanEnded()
{
if (!_starmapFilterInitialized || _starmapFilterToggler == null || _starmapFilterToggler.gameObject.activeSelf) return;
StarmapUpdateFilterValues();
_starmapFilterToggler.gameObject.SetActive(true);
}
private static void StarmapUpdateFilterValues() private static void StarmapUpdateFilterValues()
{ {
var galaxy = GameMain.data.galaxy; var galaxy = GameMain.data.galaxy;
@@ -530,46 +530,37 @@ public static class UIFunctions
foreach (var planet in star.planets) foreach (var planet in star.planets)
{ {
if (planet == null) continue; if (planet == null) continue;
while (planet.scanning) if (!planet.scanned)
{ {
Thread.Sleep(50); PlanetModelingManager.RequestScanPlanet(planet);
continue;
} }
var planetValue = 0UL; var planetValue = 0UL;
if (planet.type == EPlanetType.Gas) if (planet.type == EPlanetType.Gas)
{ {
foreach (var n in planet.gasItems) foreach (var n in planet.gasItems)
{ {
switch (n) if (ItemToVeinBitFlagMap.TryGetValue(n, out var bitFlag))
{ {
case 1011: planetValue |= 1UL << bitFlag;
planetValue |= 1UL << 8;
break;
case 1120:
planetValue |= 1UL << 20;
break;
case 1121:
planetValue |= 1UL << 21;
break;
} }
} }
} }
else else
{ {
foreach (var group in planet.veinGroups) if (planet.runtimeVeinGroups != null)
{
foreach (var group in planet.runtimeVeinGroups)
{ {
if (group.amount > 0) if (group.amount > 0)
{ {
planetValue |= 1UL << (int)group.type; planetValue |= 1UL << (int)group.type;
} }
} }
switch (planet.waterItemId) }
if (ItemToVeinBitFlagMap.TryGetValue(planet.waterItemId, out var bitFlag))
{ {
case 1116: planetValue |= 1UL << bitFlag;
planetValue |= 1UL << 22;
break;
case 1000:
planetValue |= 1UL << 23;
break;
} }
} }
if ((value & (1UL << (30 + planet.theme))) == 0) if ((value & (1UL << (30 + planet.theme))) == 0)
@@ -578,9 +569,11 @@ public static class UIFunctions
{ {
case 7: case 7:
case 9: case 9:
case 10:
case 13: case 13:
case 17: case 17:
case 19: case 19:
case 20:
case 24: case 24:
{ {
const ulong needed = 0x7EUL; const ulong needed = 0x7EUL;
@@ -599,10 +592,8 @@ public static class UIFunctions
} }
break; break;
} }
case 10:
case 15: case 15:
case 16: case 16:
case 18:
case 21: case 21:
case 22: case 22:
case 23: case 23:

View File

@@ -2,7 +2,6 @@ namespace UXAssist.Patches;
using Common; using Common;
using HarmonyLib; using HarmonyLib;
using UnityEngine;
[PatchGuid(PluginInfo.PLUGIN_GUID)] [PatchGuid(PluginInfo.PLUGIN_GUID)]
public class UIPatch: PatchImpl<UIPatch> public class UIPatch: PatchImpl<UIPatch>
@@ -14,12 +13,21 @@ public class UIPatch: PatchImpl<UIPatch>
} }
// Add config button to main menu // Add config button to main menu
[HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot._OnOpen))] [HarmonyPostfix]
[HarmonyPatch(typeof(UIRoot), nameof(UIRoot._OnOpen))]
public static void UIRoot__OnOpen_Postfix() public static void UIRoot__OnOpen_Postfix()
{ {
Functions.UIFunctions.InitMenuButtons(); Functions.UIFunctions.InitMenuButtons();
} }
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyScanEnded))]
private static void PlanetData_NotifyScanEnded_Postfix(PlanetData __instance)
{
if (PlanetModelingManager.scnPlanetReqList.Count > 0) return;
BepInEx.ThreadingHelper.Instance.StartSyncInvoke(Functions.UIFunctions.OnPlanetScanEnded);
}
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(UIPlanetGlobe), nameof(UIPlanetGlobe.DistributeButtons))] [HarmonyPatch(typeof(UIPlanetGlobe), nameof(UIPlanetGlobe.DistributeButtons))]
private static void UIPlanetGlobe_DistributeButtons_Postfix(UIPlanetGlobe __instance) private static void UIPlanetGlobe_DistributeButtons_Postfix(UIPlanetGlobe __instance)

View File

@@ -233,7 +233,7 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
GameLogic.Enable(false); GameLogic.Enable(false);
} }
private void Update() private void FixedUpdate()
{ {
if (DSPGame.IsMenuDemo) if (DSPGame.IsMenuDemo)
{ {
@@ -241,7 +241,6 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
UIFunctions.OnInputUpdate(); UIFunctions.OnInputUpdate();
return; return;
} }
UIFunctions.OnUpdate();
LogisticsPatch.OnUpdate(); LogisticsPatch.OnUpdate();
if (VFInput.inputing) return; if (VFInput.inputing) return;
LogisticsPatch.OnInputUpdate(); LogisticsPatch.OnInputUpdate();

View File

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid> <BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description> <Description>DSP MOD - UXAssist</Description>
<Version>1.3.1</Version> <Version>1.3.2</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId> <PackageId>UXAssist</PackageId>

View File

@@ -1,6 +1,6 @@
{ {
"name": "UXAssist", "name": "UXAssist",
"version_number": "1.3.1", "version_number": "1.3.2",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
"dependencies": [ "dependencies": [