diff --git a/Patches/ItemPanelPatches.cs b/Patches/ItemPanelPatches.cs index 97fdce9..ec64274 100644 --- a/Patches/ItemPanelPatches.cs +++ b/Patches/ItemPanelPatches.cs @@ -168,7 +168,7 @@ namespace UIFixes private static FieldInfo InteractionsButtonsContainerContainerField; private static FieldInfo InteractionsButtonContainerUIField; - private static MethodInfo InteractionsButtonContainerUIDisposeMethod; + private static MethodInfo InteractionsButtonContainerUIAddDisposableMethod; private static FieldInfo SimpleContextMenuButtonTextField; @@ -178,7 +178,7 @@ namespace UIFixes InteractionsButtonsContainerContainerField = AccessTools.Field(typeof(InteractionButtonsContainer), "_buttonsContainer"); InteractionsButtonContainerUIField = AccessTools.Field(typeof(InteractionButtonsContainer), "UI"); - InteractionsButtonContainerUIDisposeMethod = AccessTools.Method(InteractionsButtonContainerUIField.FieldType, "AddDisposable", [typeof(Action)]); + InteractionsButtonContainerUIAddDisposableMethod = AccessTools.Method(InteractionsButtonContainerUIField.FieldType, "AddDisposable", [typeof(Action)]); SimpleContextMenuButtonTextField = AccessTools.Field(typeof(ContextMenuButton), "_text"); @@ -203,21 +203,15 @@ namespace UIFixes SimpleContextMenuButton toggleButton = null; - Action onClick = () => - { - Settings.ShowModStats.Value = !Settings.ShowModStats.Value; + Action onClick = () => Settings.ShowModStats.Value = !Settings.ShowModStats.Value; - var text = SimpleContextMenuButtonTextField.GetValue(toggleButton) as TextMeshProUGUI; - text.text = GetLabel(); - - __instance.method_5(); // rebuild stat panels - }; - - // Listen to the setting to handle multiple windows open at once + // Listen to the setting and the work there to handle multiple windows open at once EventHandler onSettingChanged = (sender, args) => { var text = SimpleContextMenuButtonTextField.GetValue(toggleButton) as TextMeshProUGUI; text.text = GetLabel(); + + __instance.method_5(); // rebuild stat panels }; Settings.ShowModStats.SettingChanged += onSettingChanged; @@ -233,7 +227,7 @@ namespace UIFixes contextInteractions.OnRedrawRequired += createButton; // And unsubscribe when the window goes away - InteractionsButtonContainerUIDisposeMethod.Invoke(InteractionsButtonContainerUIField.GetValue(____interactionButtonsContainer), [() => + InteractionsButtonContainerUIAddDisposableMethod.Invoke(InteractionsButtonContainerUIField.GetValue(____interactionButtonsContainer), [() => { contextInteractions.OnRedrawRequired -= createButton; Settings.ShowModStats.SettingChanged -= onSettingChanged; @@ -376,10 +370,8 @@ namespace UIFixes { changed = false; List itemAttributes = item.Attributes.Where(a => a.DisplayType() == EItemAttributeDisplayType.Compact).ToList(); - var subComponents = item.GetItemComponentsInChildren(true); - foreach (var subComponent in subComponents) + foreach (var subItem in item.GetAllItems()) { - var subItem = ItemComponentItemField.GetValue(subComponent) as Item; if (subItem == item) { continue; diff --git a/Patches/SwapPatch.cs b/Patches/SwapPatch.cs index af2da0d..1c0b83d 100644 --- a/Patches/SwapPatch.cs +++ b/Patches/SwapPatch.cs @@ -82,7 +82,7 @@ namespace UIFixes return false; } - if (itemContext.Item == targetItemContext.Item) + if (itemContext.Item == targetItemContext.Item || targetItemContext.Item.GetAllParentItems().Contains(itemContext.Item)) { return false; } diff --git a/UIFixes.Test/UIFixes.Test.csproj b/UIFixes.Test/UIFixes.Test.csproj index 1c12f6d..29dec08 100644 --- a/UIFixes.Test/UIFixes.Test.csproj +++ b/UIFixes.Test/UIFixes.Test.csproj @@ -7,6 +7,7 @@ false true + Debug;Release;Dist diff --git a/UIFixes.csproj b/UIFixes.csproj index dceb57e..266b8fd 100644 --- a/UIFixes.csproj +++ b/UIFixes.csproj @@ -7,6 +7,7 @@ 1.3.3 true latest + Debug;Release;Dist @@ -16,6 +17,7 @@ ..\..\..\..\SPT\3.8.0-debug ..\..\..\..\SPT\3.8.0 + ..\..\..\..\SPT\3.8.0 @@ -59,6 +61,6 @@ - + diff --git a/UIFixes.sln b/UIFixes.sln index 214d2ea..962c7d6 100644 --- a/UIFixes.sln +++ b/UIFixes.sln @@ -5,20 +5,25 @@ VisualStudioVersion = 17.9.34723.18 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIFixes", "UIFixes.csproj", "{240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIFixes.Test", "UIFixes.Test\UIFixes.Test.csproj", "{FE27D858-0061-4BAD-BE4D-FABBDB53213F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIFixes.Test", "UIFixes.Test\UIFixes.Test.csproj", "{FE27D858-0061-4BAD-BE4D-FABBDB53213F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Dist|Any CPU = Dist|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Dist|Any CPU.ActiveCfg = Dist|Any CPU + {240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Dist|Any CPU.Build.0 = Dist|Any CPU {240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Release|Any CPU.ActiveCfg = Release|Any CPU {240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Release|Any CPU.Build.0 = Release|Any CPU {FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Dist|Any CPU.ActiveCfg = Dist|Any CPU + {FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Dist|Any CPU.Build.0 = Dist|Any CPU {FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Release|Any CPU.ActiveCfg = Release|Any CPU {FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection