Fix buttpads, fix suppressed exception on swapping container into itself

This commit is contained in:
Tyfon
2024-05-03 11:10:19 -07:00
parent fe1c44f4f0
commit 588d9ad79b
5 changed files with 19 additions and 19 deletions

View File

@@ -168,7 +168,7 @@ namespace UIFixes
private static FieldInfo InteractionsButtonsContainerContainerField; private static FieldInfo InteractionsButtonsContainerContainerField;
private static FieldInfo InteractionsButtonContainerUIField; private static FieldInfo InteractionsButtonContainerUIField;
private static MethodInfo InteractionsButtonContainerUIDisposeMethod; private static MethodInfo InteractionsButtonContainerUIAddDisposableMethod;
private static FieldInfo SimpleContextMenuButtonTextField; private static FieldInfo SimpleContextMenuButtonTextField;
@@ -178,7 +178,7 @@ namespace UIFixes
InteractionsButtonsContainerContainerField = AccessTools.Field(typeof(InteractionButtonsContainer), "_buttonsContainer"); InteractionsButtonsContainerContainerField = AccessTools.Field(typeof(InteractionButtonsContainer), "_buttonsContainer");
InteractionsButtonContainerUIField = AccessTools.Field(typeof(InteractionButtonsContainer), "UI"); 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"); SimpleContextMenuButtonTextField = AccessTools.Field(typeof(ContextMenuButton), "_text");
@@ -203,21 +203,15 @@ namespace UIFixes
SimpleContextMenuButton toggleButton = null; SimpleContextMenuButton toggleButton = null;
Action onClick = () => Action onClick = () => Settings.ShowModStats.Value = !Settings.ShowModStats.Value;
{
Settings.ShowModStats.Value = !Settings.ShowModStats.Value;
var text = SimpleContextMenuButtonTextField.GetValue(toggleButton) as TextMeshProUGUI; // Listen to the setting and the work there to handle multiple windows open at once
text.text = GetLabel();
__instance.method_5(); // rebuild stat panels
};
// Listen to the setting to handle multiple windows open at once
EventHandler onSettingChanged = (sender, args) => EventHandler onSettingChanged = (sender, args) =>
{ {
var text = SimpleContextMenuButtonTextField.GetValue(toggleButton) as TextMeshProUGUI; var text = SimpleContextMenuButtonTextField.GetValue(toggleButton) as TextMeshProUGUI;
text.text = GetLabel(); text.text = GetLabel();
__instance.method_5(); // rebuild stat panels
}; };
Settings.ShowModStats.SettingChanged += onSettingChanged; Settings.ShowModStats.SettingChanged += onSettingChanged;
@@ -233,7 +227,7 @@ namespace UIFixes
contextInteractions.OnRedrawRequired += createButton; contextInteractions.OnRedrawRequired += createButton;
// And unsubscribe when the window goes away // And unsubscribe when the window goes away
InteractionsButtonContainerUIDisposeMethod.Invoke(InteractionsButtonContainerUIField.GetValue(____interactionButtonsContainer), [() => InteractionsButtonContainerUIAddDisposableMethod.Invoke(InteractionsButtonContainerUIField.GetValue(____interactionButtonsContainer), [() =>
{ {
contextInteractions.OnRedrawRequired -= createButton; contextInteractions.OnRedrawRequired -= createButton;
Settings.ShowModStats.SettingChanged -= onSettingChanged; Settings.ShowModStats.SettingChanged -= onSettingChanged;
@@ -376,10 +370,8 @@ namespace UIFixes
{ {
changed = false; changed = false;
List<ItemAttributeClass> itemAttributes = item.Attributes.Where(a => a.DisplayType() == EItemAttributeDisplayType.Compact).ToList(); List<ItemAttributeClass> itemAttributes = item.Attributes.Where(a => a.DisplayType() == EItemAttributeDisplayType.Compact).ToList();
var subComponents = item.GetItemComponentsInChildren<IItemComponent>(true); foreach (var subItem in item.GetAllItems())
foreach (var subComponent in subComponents)
{ {
var subItem = ItemComponentItemField.GetValue(subComponent) as Item;
if (subItem == item) if (subItem == item)
{ {
continue; continue;

View File

@@ -82,7 +82,7 @@ namespace UIFixes
return false; return false;
} }
if (itemContext.Item == targetItemContext.Item) if (itemContext.Item == targetItemContext.Item || targetItemContext.Item.GetAllParentItems().Contains(itemContext.Item))
{ {
return false; return false;
} }

View File

@@ -7,6 +7,7 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject> <IsTestProject>true</IsTestProject>
<Configurations>Debug;Release;Dist</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -7,6 +7,7 @@
<Version>1.3.3</Version> <Version>1.3.3</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Configurations>Debug;Release;Dist</Configurations>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@@ -16,6 +17,7 @@
<PropertyGroup> <PropertyGroup>
<PathToSPT Condition="'$(Configuration)'=='Debug'">..\..\..\..\SPT\3.8.0-debug</PathToSPT> <PathToSPT Condition="'$(Configuration)'=='Debug'">..\..\..\..\SPT\3.8.0-debug</PathToSPT>
<PathToSPT Condition="'$(Configuration)'=='Release'">..\..\..\..\SPT\3.8.0</PathToSPT> <PathToSPT Condition="'$(Configuration)'=='Release'">..\..\..\..\SPT\3.8.0</PathToSPT>
<PathToSPT Condition="'$(Configuration)'=='Dist'">..\..\..\..\SPT\3.8.0</PathToSPT>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -59,6 +61,6 @@
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if $(ConfigurationName) == Debug (&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\$(TargetName).dll&quot;&#xD;&#xA; copy &quot;$(ProjectDir)$(OutDir)$(TargetName).pdb&quot; &quot;$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\$(TargetName).pdb&quot;&#xD;&#xA;) else (&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\$(TargetName).dll&quot;&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\dist\BepInEx\plugins\$(TargetName).dll&quot;&#xD;&#xA; 7z a -t7z Tyfon-UIFixes-$(Version).7z $(ProjectDir)\dist\BepInEx&#xD;&#xA; move /Y Tyfon-UIFixes-$(Version).7z dist\&#xD;&#xA;)" /> <Exec Command="if $(ConfigurationName) == Debug (&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\$(TargetName).dll&quot;&#xD;&#xA; copy &quot;$(ProjectDir)$(OutDir)$(TargetName).pdb&quot; &quot;$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\$(TargetName).pdb&quot;&#xD;&#xA;) &#xD;&#xA;if $(ConfigurationName) == Release (&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\$(TargetName).dll&quot;&#xD;&#xA;)&#xD;&#xA;if $(Configurationname) == Dist (&#xD;&#xA; mkdir &quot;$(ProjectDir)\dist\BepInDex\plugins&quot;&#xD;&#xA; copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\dist\BepInEx\plugins\$(TargetName).dll&quot;&#xD;&#xA; 7z a -t7z Tyfon-UIFixes-$(Version).7z $(ProjectDir)\dist\BepInEx&#xD;&#xA; move /Y Tyfon-UIFixes-$(Version).7z dist\&#xD;&#xA;)" />
</Target> </Target>
</Project> </Project>

View File

@@ -5,20 +5,25 @@ VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIFixes", "UIFixes.csproj", "{240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIFixes", "UIFixes.csproj", "{240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Dist|Any CPU = Dist|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {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}.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.ActiveCfg = Release|Any CPU
{240CCF3A-4A9E-4C7D-96BB-AD7C375892BF}.Release|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU
{FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Release|Any CPU.Build.0 = Release|Any CPU {FE27D858-0061-4BAD-BE4D-FABBDB53213F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection