From 58a8a4725af017532d49d1929822011ff505a99b Mon Sep 17 00:00:00 2001 From: Guflly <145608489+Guflly@users.noreply.github.com> Date: Sat, 8 Aug 2026 00:01:49 -0700 Subject: [PATCH] Use protected visual gump state --- .../Tests/Gumps/TestGumps/DynamicTestGump.cs | 2 ++ .../Tests/Gumps/TestGumps/EmptyTestGumps.cs | 6 ++++++ .../Tests/Gumps/TestGumps/LegacyTestGump.cs | 2 ++ .../Tests/Gumps/TestGumps/StaticTestGump.cs | 2 ++ .../Tests/Gumps/TestLayoutGumps.cs | 16 +++++++++------- Projects/UOContent/Gumps/Base/BaseGump.cs | 2 +- Projects/UOContent/Gumps/Base/StaticGump.cs | 6 +++--- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/DynamicTestGump.cs b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/DynamicTestGump.cs index 998e4c537..fd3dafc56 100644 --- a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/DynamicTestGump.cs +++ b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/DynamicTestGump.cs @@ -6,6 +6,8 @@ public class DynamicTestGump : DynamicGump { private readonly string _petName; + public bool HasVisualElementsForTest => HasVisualElements; + public DynamicTestGump(string petName) : base(50, 50) { _petName = petName; diff --git a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/EmptyTestGumps.cs b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/EmptyTestGumps.cs index 432dd7ebf..b99de1700 100644 --- a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/EmptyTestGumps.cs +++ b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/EmptyTestGumps.cs @@ -4,6 +4,8 @@ namespace Server.Tests.Gumps; public sealed class EmptyLegacyTestGump : Gump { + public bool HasVisualElementsForTest => HasVisualElements; + public EmptyLegacyTestGump() : base(0, 0) { } @@ -11,6 +13,8 @@ public sealed class EmptyLegacyTestGump : Gump public sealed class EmptyDynamicTestGump : DynamicGump { + public bool HasVisualElementsForTest => HasVisualElements; + public EmptyDynamicTestGump() : base(0, 0) { } @@ -23,6 +27,8 @@ public sealed class EmptyDynamicTestGump : DynamicGump public sealed class EmptyStaticTestGump : StaticGump { + public bool HasVisualElementsForTest => HasVisualElements; + public EmptyStaticTestGump() : base(0, 0) { } diff --git a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/LegacyTestGump.cs b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/LegacyTestGump.cs index 668d7e8ae..e45514c38 100644 --- a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/LegacyTestGump.cs +++ b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/LegacyTestGump.cs @@ -4,6 +4,8 @@ namespace Server.Tests.Gumps; public sealed class LegacyTestGump : Gump { + public bool HasVisualElementsForTest => HasVisualElements; + public LegacyTestGump(string petName) : base(50, 50) { Serial = (Serial)0x123; diff --git a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/StaticTestGump.cs b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/StaticTestGump.cs index ea67720f5..66d80c963 100644 --- a/Projects/UOContent.Tests/Tests/Gumps/TestGumps/StaticTestGump.cs +++ b/Projects/UOContent.Tests/Tests/Gumps/TestGumps/StaticTestGump.cs @@ -4,6 +4,8 @@ namespace Server.Tests.Gumps; public class StaticTestGump : StaticGump { + public bool HasVisualElementsForTest => HasVisualElements; + public StaticTestGump() : base(50, 50) { Serial = (Serial)0x123; diff --git a/Projects/UOContent.Tests/Tests/Gumps/TestLayoutGumps.cs b/Projects/UOContent.Tests/Tests/Gumps/TestLayoutGumps.cs index dfd474c98..804408fc7 100644 --- a/Projects/UOContent.Tests/Tests/Gumps/TestLayoutGumps.cs +++ b/Projects/UOContent.Tests/Tests/Gumps/TestLayoutGumps.cs @@ -76,20 +76,22 @@ public class TestLayoutGumps [Fact] public void TestEmptyGumpsHaveNoVisualElements() { - Assert.False(Compile(new EmptyLegacyTestGump()).HasVisualElements); - Assert.False(Compile(new EmptyDynamicTestGump()).HasVisualElements); - Assert.False(Compile(new EmptyStaticTestGump()).HasVisualElements); + Assert.False(Compile(new EmptyLegacyTestGump()).HasVisualElementsForTest); + Assert.False(Compile(new EmptyDynamicTestGump()).HasVisualElementsForTest); + Assert.False(Compile(new EmptyStaticTestGump()).HasVisualElementsForTest); + Assert.False(Compile(new EmptyStaticTestGump()).HasVisualElementsForTest); } [Fact] public void TestVisibleGumpsHaveVisualElements() { - Assert.True(Compile(new LegacyTestGump("Test")).HasVisualElements); - Assert.True(Compile(new DynamicTestGump("Test")).HasVisualElements); - Assert.True(Compile(new StaticTestGump()).HasVisualElements); + Assert.True(Compile(new LegacyTestGump("Test")).HasVisualElementsForTest); + Assert.True(Compile(new DynamicTestGump("Test")).HasVisualElementsForTest); + Assert.True(Compile(new StaticTestGump()).HasVisualElementsForTest); + Assert.True(Compile(new StaticTestGump()).HasVisualElementsForTest); } - private static BaseGump Compile(BaseGump gump) + private static T Compile(T gump) where T : BaseGump { var buffer = GC.AllocateUninitializedArray(512); var writer = new SpanWriter(buffer); diff --git a/Projects/UOContent/Gumps/Base/BaseGump.cs b/Projects/UOContent/Gumps/Base/BaseGump.cs index 6063d50fd..1780b0ab1 100644 --- a/Projects/UOContent/Gumps/Base/BaseGump.cs +++ b/Projects/UOContent/Gumps/Base/BaseGump.cs @@ -31,7 +31,7 @@ public abstract class BaseGump public int TypeID { get; protected set; } public Serial Serial { get; protected set; } - internal bool HasVisualElements { get; set; } + protected bool HasVisualElements { get; set; } public abstract int Switches { get; } public abstract int TextEntries { get; } diff --git a/Projects/UOContent/Gumps/Base/StaticGump.cs b/Projects/UOContent/Gumps/Base/StaticGump.cs index a4c9fe151..0ab2df5e0 100644 --- a/Projects/UOContent/Gumps/Base/StaticGump.cs +++ b/Projects/UOContent/Gumps/Base/StaticGump.cs @@ -30,7 +30,7 @@ public abstract class StaticGump : BaseGump where TSelf : StaticGump : BaseGump where TSelf : StaticGump : BaseGump where TSelf : StaticGump