diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index 88ca73d..27abb28 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -3,6 +3,11 @@ ## Changlog +* 1.3.1 + + 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. + + `Dismantle blueprint selected buildings`: Fix an issue that items in Logistic Station slots are not dropped out. + + Tweak star name filter's planet type list. * 1.3.0 + New feature for starmap view: - Add a star name filter, you can filter displayed star names by ores or planet types now. @@ -284,6 +289,11 @@ ## 更新日志 +* 1.3.1 + + 修复了在星图上点击新增的下拉框时部分UI元素被隐藏的问题 + + 修复了未启用`显示星系名称快捷键`时星系名称过滤器不生效的问题 + + `拆除蓝图选中的建筑`:修复了物流站中的物品未被丢出的问题 + + 调整了星系名称过滤器中的行星类型列表 * 1.3.0 + 在星图上添加新功能: - 添加星系名过滤器,现在可以按矿物或行星类型过滤显示的星系名 diff --git a/UXAssist/Functions/FactoryFunctions.cs b/UXAssist/Functions/FactoryFunctions.cs index 8ea4b9b..7c731ff 100644 --- a/UXAssist/Functions/FactoryFunctions.cs +++ b/UXAssist/Functions/FactoryFunctions.cs @@ -83,8 +83,23 @@ public static class FactoryFunctions buildPreviewsToRemove.Insert(~index, connObjId); } } + var entityPool = factory.entityPool; + var stationPool = factory.transport.stationPool; foreach (var objId in buildPreviewsToRemove) { + int stationId = entityPool[objId].stationId; + if (stationId > 0) + { + StationComponent sc = stationPool[stationId]; + if (sc.id != stationId) continue; + for (int i = 0; i < sc.storage.Length; i++) + { + int package = player.TryAddItemToPackage(sc.storage[i].itemId, sc.storage[i].count, 0, true, objId); + UIItemup.Up(sc.storage[i].itemId, package); + } + sc.storage = new StationStore[sc.storage.Length]; + sc.needs = new int[sc.needs.Length]; + } build.DoDismantleObject(objId); } blueprintCopyTool.ClearSelection(); diff --git a/UXAssist/Functions/UIFunctions.cs b/UXAssist/Functions/UIFunctions.cs index c994db2..7df9003 100644 --- a/UXAssist/Functions/UIFunctions.cs +++ b/UXAssist/Functions/UIFunctions.cs @@ -82,7 +82,7 @@ public static class UIFunctions } } - private static readonly int[] FilterPlanetThemes = [16, 23, 10, 15, 18, 22, 25, 21, 14, 17, 19, 7, 24, 9, 13]; + private static readonly int[] FilterPlanetThemes = [16, 23, 15, 22, 25, 21, 14, 17, 19, 7, 10, 20, 24, 9, 13]; public static void InitMenuButtons() { if (_initialized) return; @@ -190,9 +190,9 @@ public static class UIFunctions Common.Util.LoadEmbeddedSprite("assets/planet_icon/15.png"), Common.Util.LoadEmbeddedSprite("assets/planet_icon/16.png"), Common.Util.LoadEmbeddedSprite("assets/planet_icon/17.png"), - Common.Util.LoadEmbeddedSprite("assets/planet_icon/18.png"), - Common.Util.LoadEmbeddedSprite("assets/planet_icon/19.png"), null, + Common.Util.LoadEmbeddedSprite("assets/planet_icon/19.png"), + Common.Util.LoadEmbeddedSprite("assets/planet_icon/20.png"), Common.Util.LoadEmbeddedSprite("assets/planet_icon/21.png"), Common.Util.LoadEmbeddedSprite("assets/planet_icon/22.png"), Common.Util.LoadEmbeddedSprite("assets/planet_icon/23.png"), @@ -209,12 +209,12 @@ public static class UIFunctions var panel = new GameObject("uxassist-starmap-panel"); var rtrans = panel.AddComponent(); panel.transform.SetParent(rect); - rtrans.sizeDelta = new Vector2(Screen.width, Screen.height); + rtrans.sizeDelta = new Vector2(0f, 0f); rtrans.localScale = new Vector3(1f, 1f, 1f); - rtrans.anchorMax = new Vector2(0f, 1f); - rtrans.anchorMin = new Vector2(0f, 1f); + rtrans.anchorMax = new Vector2(1f, 1f); + rtrans.anchorMin = new Vector2(0f, 0f); rtrans.pivot = new Vector2(0f, 1f); - rtrans.localPosition = new Vector3(0f, 0, 0f); + rtrans.anchoredPosition3D = new Vector3(0, 0, 0f); var cornerComboBox = UI.MyCornerComboBox.CreateComboBox(135, 0, rtrans, true).WithItems("Show original name".Translate(), "Show distance".Translate(), "Show planet count".Translate(), "Show all information".Translate()); cornerComboBox.SetIndex(Functions.UIFunctions.CornerComboBoxIndex); @@ -244,9 +244,9 @@ public static class UIFunctions UI.MyCheckButton.CreateCheckButton(24, 120, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), UI.MyCheckButton.CreateCheckButton(24, 144, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), UI.MyCheckButton.CreateCheckButton(24, 168, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), - UI.MyCheckButton.CreateCheckButton(24, 192, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), - UI.MyCheckButton.CreateCheckButton(24, 216, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), + UI.MyCheckButton.CreateCheckButton(24, 210, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), + UI.MyCheckButton.CreateCheckButton(24, 234, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), UI.MyCheckButton.CreateCheckButton(24, 258, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), UI.MyCheckButton.CreateCheckButton(24, 282, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), UI.MyCheckButton.CreateCheckButton(24, 306, rtrans, false).WithIcon().WithSize(150, 24).WithIconWidth(24), @@ -254,7 +254,7 @@ public static class UIFunctions 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), ]; - var allOresText = MyWindow.AddText(20, 238, rtrans, "All 6 Basic Ores".Translate(), 12); + var allOresText = MyWindow.AddText(20, 190, rtrans, "All 6 Basic Ores".Translate(), 12); allOresText.gameObject.SetActive(false); _starmapFilterToggler.OnChecked += UpdateButtons; foreach (var button in buttons) @@ -281,10 +281,10 @@ public static class UIFunctions veinProto = LDB.veins.Select(i + 9); buttons[i].SetIcon(veinProto.iconSprite); } - var itemProto = LDB.items.Select(1007); - buttons[6].SetIcon(itemProto.iconSprite); - veinProto = LDB.veins.Select(8); - buttons[7].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); @@ -423,10 +423,10 @@ public static class UIFunctions var themeProto = LDB.themes.Select(theme); switch (i) { - case 7: + case 5: buttons[12 + i].SetLabelText($"{themeProto.DisplayName.Translate()} ({"High yield".Translate()})"); break; - case 8: + case 6: buttons[12 + i].SetLabelText($"{themeProto.DisplayName.Translate()} ({"Perfect".Translate()})"); break; default: @@ -623,7 +623,7 @@ public static class UIFunctions set { _cornerComboBoxIndex = value; - Patches.PlayerPatch.ShortcutKeysForStarsName.SetForceShowAllStarsNameExternal(_cornerComboBoxIndex != 0 && !_starFilterEnabled); + Patches.PlayerPatch.ShortcutKeysForStarsName.ForceShowAllStarsNameExternal = _cornerComboBoxIndex != 0 && !_starFilterEnabled; UpdateStarmapStarNames(); } } @@ -632,8 +632,8 @@ public static class UIFunctions { if (_starFilterEnabled == enabled) return; _starFilterEnabled = enabled; - if (!enabled) Patches.PlayerPatch.ShortcutKeysForStarsName.SetShowAllStarsNameStatus(0); - Patches.PlayerPatch.ShortcutKeysForStarsName.SetForceShowAllStarsNameExternal(_cornerComboBoxIndex != 0 && !_starFilterEnabled); + if (!enabled) Patches.PlayerPatch.ShortcutKeysForStarsName.ShowAllStarsNameStatus = 0; + Patches.PlayerPatch.ShortcutKeysForStarsName.ForceShowAllStarsNameExternal = _cornerComboBoxIndex != 0 && !_starFilterEnabled; UpdateStarmapStarNames(); } diff --git a/UXAssist/Patches/PlayerPatch.cs b/UXAssist/Patches/PlayerPatch.cs index 4e73b65..3321de6 100644 --- a/UXAssist/Patches/PlayerPatch.cs +++ b/UXAssist/Patches/PlayerPatch.cs @@ -8,7 +8,7 @@ using UXAssist.Common; namespace UXAssist.Patches; -public static class PlayerPatch +public class PlayerPatch : PatchImpl { public static ConfigEntry EnhancedMechaForgeCountControlEnabled; public static ConfigEntry HideTipsForSandsChangesEnabled; @@ -66,6 +66,7 @@ public static class PlayerPatch HideTipsForSandsChanges.Enable(HideTipsForSandsChangesEnabled.Value); ShortcutKeysForStarsName.Enable(ShortcutKeysForStarsNameEnabled.Value); AutoNavigation.Enable(AutoNavigationEnabled.Value); + Enable(true); } public static void OnInputUpdate() @@ -79,12 +80,54 @@ public static class PlayerPatch public static void Uninit() { + Enable(false); EnhancedMechaForgeCountControl.Enable(false); HideTipsForSandsChanges.Enable(false); ShortcutKeysForStarsName.Enable(false); AutoNavigation.Enable(false); } + + [HarmonyTranspiler] + [HarmonyPatch(typeof(UIStarmapStar), nameof(UIStarmapStar._OnLateUpdate))] + private static IEnumerable UIStarmapStar__OnLateUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + Label? jumpPos = null; + matcher.MatchForward(false, + new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(UIStarmapStar), nameof(UIStarmapStar.projectedCoord))), + new CodeMatch(ci => ci.IsLdloc()), + new CodeMatch(ci => ci.Branches(out jumpPos)) + ); + matcher.Advance(3); + var labels = matcher.Labels; + matcher.Labels = []; + matcher.CreateLabel(out var jumpPos2); + matcher.InsertAndAdvance( + new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(ShortcutKeysForStarsName.ShowAllStarsNameStatus))).WithLabels(labels), + new CodeInstruction(OpCodes.Ldc_I4_1), + new CodeInstruction(OpCodes.Ceq), + new CodeInstruction(OpCodes.Brtrue, jumpPos.Value), + new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(PlayerPatch.ShortcutKeysForStarsName), nameof(ShortcutKeysForStarsName.ForceShowAllStarsName))), + new CodeInstruction(OpCodes.Brtrue, jumpPos.Value), + new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(Functions.UIFunctions), nameof(Functions.UIFunctions.ShowStarName))), + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UIStarmapStar), nameof(UIStarmapStar.star))), + new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))), + new CodeInstruction(OpCodes.Ldelem_I1), + new CodeInstruction(OpCodes.Brtrue, jumpPos.Value), + new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(ShortcutKeysForStarsName.ShowAllStarsNameStatus))), + new CodeInstruction(OpCodes.Ldc_I4_2), + new CodeInstruction(OpCodes.Ceq), + new CodeInstruction(OpCodes.Brfalse, jumpPos2), + new CodeInstruction(OpCodes.Ldc_I4_0), + new CodeInstruction(OpCodes.Stloc_1), + new CodeInstruction(OpCodes.Br, jumpPos.Value) + ); + return matcher.InstructionEnumeration(); + } + + private class EnhancedMechaForgeCountControl: PatchImpl { [HarmonyTranspiler] @@ -152,79 +195,36 @@ public static class PlayerPatch public class ShortcutKeysForStarsName: PatchImpl { - private static int _showAllStarsNameStatus; - private static bool _forceShowAllStarsName; - private static bool _forceShowAllStarsNameExternal; - - public static void SetShowAllStarsNameStatus(int status) - { - _showAllStarsNameStatus = status; - } + public static int ShowAllStarsNameStatus; + public static bool ForceShowAllStarsName; + public static bool ForceShowAllStarsNameExternal; public static void ToggleAllStarsName() { - _showAllStarsNameStatus = (_showAllStarsNameStatus + 1) % 3; - } - - public static void SetForceShowAllStarsNameExternal(bool value) - { - _forceShowAllStarsNameExternal = value; + ShowAllStarsNameStatus = (ShowAllStarsNameStatus + 1) % 3; } public static void OnInputUpdate() { if (!UIRoot.instance.uiGame.starmap.active) return; + var enabled = ShortcutKeysForStarsNameEnabled.Value; + if (!enabled) + { + ForceShowAllStarsName = ForceShowAllStarsNameExternal; + return; + } if (_toggleAllStarsNameKey.keyValue) { ToggleAllStarsName(); } - _forceShowAllStarsName = _forceShowAllStarsNameExternal || _showAllStarsNameKey.IsKeyPressing(); + ForceShowAllStarsName = ForceShowAllStarsNameExternal || _showAllStarsNameKey.IsKeyPressing(); } [HarmonyPrefix] [HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap._OnOpen))] private static void UIStarmap__OnOpen_Prefix() { - _showAllStarsNameStatus = 0; - } - - [HarmonyTranspiler] - [HarmonyPatch(typeof(UIStarmapStar), nameof(UIStarmapStar._OnLateUpdate))] - private static IEnumerable UIStarmapStar__OnLateUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - Label? jumpPos = null; - matcher.MatchForward(false, - new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(UIStarmapStar), nameof(UIStarmapStar.projectedCoord))), - new CodeMatch(ci => ci.IsLdloc()), - new CodeMatch(ci => ci.Branches(out jumpPos)) - ); - matcher.Advance(3); - var labels = matcher.Labels; - matcher.Labels = []; - matcher.CreateLabel(out var jumpPos2); - matcher.InsertAndAdvance( - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(_showAllStarsNameStatus))).WithLabels(labels), - new CodeInstruction(OpCodes.Ldc_I4_1), - new CodeInstruction(OpCodes.Ceq), - new CodeInstruction(OpCodes.Brtrue, jumpPos.Value), - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(PlayerPatch.ShortcutKeysForStarsName), nameof(_forceShowAllStarsName))), - new CodeInstruction(OpCodes.Brtrue, jumpPos.Value), - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(Functions.UIFunctions), nameof(Functions.UIFunctions.ShowStarName))), - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UIStarmapStar), nameof(UIStarmapStar.star))), - new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))), - new CodeInstruction(OpCodes.Ldelem_I1), - new CodeInstruction(OpCodes.Brtrue, jumpPos.Value), - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(_showAllStarsNameStatus))), - new CodeInstruction(OpCodes.Ldc_I4_2), - new CodeInstruction(OpCodes.Ceq), - new CodeInstruction(OpCodes.Brfalse, jumpPos2), - new CodeInstruction(OpCodes.Ldc_I4_0), - new CodeInstruction(OpCodes.Stloc_1), - new CodeInstruction(OpCodes.Br, jumpPos.Value) - ); - return matcher.InstructionEnumeration(); + ShowAllStarsNameStatus = 0; } /* [HarmonyTranspiler] diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index eb01295..494f779 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.3.0 + 1.3.1 true latest UXAssist @@ -50,8 +50,8 @@ - + diff --git a/UXAssist/assets/planet_icon/18.png b/UXAssist/assets/planet_icon/18.png deleted file mode 100644 index 9cb39ef..0000000 Binary files a/UXAssist/assets/planet_icon/18.png and /dev/null differ diff --git a/UXAssist/assets/planet_icon/20.png b/UXAssist/assets/planet_icon/20.png new file mode 100644 index 0000000..6a3962c Binary files /dev/null and b/UXAssist/assets/planet_icon/20.png differ diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index c2d2bdc..e778a15 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.3.0", + "version_number": "1.3.1", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [