-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixes edge cases with on off items (#1832)
### Summary - Generalizes the On/Off toggle items concept - Updates the OnOffGump so it is static - Standardizes OnOff items so they can be used by staff ### Notes Decided to not fix #1417 because it is not clear that the clilocs or errors are for that purpose. Can't test this on OSI anyways.
- Loading branch information
1 parent
f756cce
commit 19f65dc
Showing
10 changed files
with
141 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
using System.Threading; | ||
|
||
namespace Server; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
Projects/Server.Tests/Tests/Network/Packets/Outgoing/GumpPackets.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Server.Gumps; | ||
using Server.Network; | ||
|
||
namespace Server.Items; | ||
|
||
public interface IGumpToggleItem | ||
{ | ||
public bool IsLockedDown { get; } | ||
public bool TurnedOn { get; set; } | ||
} | ||
|
||
public sealed class TurnOnGump : TurnOnOffGump<TurnOnGump> | ||
{ | ||
public TurnOnGump(IGumpToggleItem item) : base(item) | ||
{ | ||
} | ||
|
||
protected override void BuildLayout(ref StaticGumpBuilder builder) | ||
{ | ||
base.BuildLayout(ref builder); | ||
|
||
builder.AddHtmlLocalized(45, 20, 300, 35, 1011034); // Activate this item | ||
} | ||
} | ||
|
||
public sealed class TurnOffGump : TurnOnOffGump<TurnOffGump> | ||
{ | ||
public TurnOffGump(IGumpToggleItem item) : base(item) | ||
{ | ||
} | ||
|
||
protected override void BuildLayout(ref StaticGumpBuilder builder) | ||
{ | ||
base.BuildLayout(ref builder); | ||
|
||
builder.AddHtmlLocalized(45, 20, 300, 35, 1011035); // Deactivate this item | ||
} | ||
} | ||
|
||
public abstract class TurnOnOffGump<T> : StaticGump<T> where T : TurnOnOffGump<T> | ||
{ | ||
protected readonly IGumpToggleItem _item; | ||
|
||
public TurnOnOffGump(IGumpToggleItem item) : base(150, 200) => _item = item; | ||
|
||
protected override void BuildLayout(ref StaticGumpBuilder builder) | ||
{ | ||
builder.AddBackground(0, 0, 300, 150, 0xA28); | ||
|
||
builder.AddButton(40, 53, 0xFA5, 0xFA7, 1); | ||
builder.AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY | ||
|
||
builder.AddButton(150, 53, 0xFA5, 0xFA7, 0); | ||
builder.AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL | ||
} | ||
|
||
public override void OnResponse(NetState sender, in RelayInfo info) | ||
{ | ||
var from = sender.Mobile; | ||
|
||
if (info.ButtonID != 1) | ||
{ | ||
from.SendLocalizedMessage(502694); // Cancelled action. | ||
return; | ||
} | ||
|
||
var newValue = !_item.TurnedOn; | ||
_item.TurnedOn = newValue; | ||
|
||
if (newValue && !_item.IsLockedDown) | ||
{ | ||
from.SendLocalizedMessage(502693); // Remember, this only works when locked down. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.