2 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
8 partial class BannedPlayer
11 UInt32 uniqueIdentifier,
13 Either<Address, AccountId> addressOrAccountId,
15 Option<SerializableDateTime> expiration)
31 private void RecreateBanFrame()
57 RelativeSpacing = 0.05f,
62 isHorizontal:
true, childAnchor:
Anchor.CenterLeft)
65 RelativeSpacing = 0.02f
68 var addressOrAccountId = bannedPlayer.AddressOrAccountId;
70 string nameText = bannedPlayer.Name;
71 if (addressOrAccountId.TryCast(out Address address))
73 nameText += $
" ({address.StringRepresentation})";
75 else if (addressOrAccountId.TryCast(out AccountId accountId))
77 nameText += $
" ({accountId.StringRepresentation})";
86 TextManager.Get(
"BanListRemove"), style:
"GUIButtonSmall")
88 IgnoreLayoutGroups =
true,
89 UserData = bannedPlayer,
90 OnClicked = RemoveBan,
93 removeButton.OnAddedToGUIUpdateList += (component) =>
97 topArea.RectTransform.MinSize =
new Point(0, Math.Max(textBlock.
RectTransform.
MinSize.Y, removeButton.RectTransform.MinSize.Y));
98 topArea.RectTransform.IsFixedSize =
true;
101 bannedPlayer.ExpirationTime.TryUnwrap(out var expirationTime)
102 ? TextManager.GetWithVariable(
"BanExpires",
"[time]", expirationTime.ToLocalUserString())
103 : TextManager.Get(
"BanPermanent"),
104 font: GUIStyle.SmallFont);
108 TextManager.Get(
"BanReason") +
" " +
109 (
string.IsNullOrEmpty(bannedPlayer.Reason) ? TextManager.Get(
"None") : reason),
110 font: GUIStyle.SmallFont, wrap:
true)
115 paddedPlayerFrame.Recalculate();
123 private bool RemoveBan(
GUIButton button,
object obj)
147 bannedPlayers.Clear();
150 for (
int i = 0; i < (int)bannedPlayerCount; i++)
153 UInt32 uniqueIdentifier = incMsg.
ReadUInt32();
157 Option<SerializableDateTime> expiration = Option<SerializableDateTime>.None();
158 if (includesExpiration)
166 Either<Address, AccountId> addressOrAccountId;
172 if (isAddress && Address.Parse(str).TryUnwrap(out var address))
174 addressOrAccountId = address;
176 else if (AccountId.Parse(str).TryUnwrap(out var accountId))
178 addressOrAccountId = accountId;
187 addressOrAccountId =
new UnknownAddress();
189 bannedPlayers.Add(
new BannedPlayer(uniqueIdentifier, name, addressOrAccountId, reason, expiration));
205 outMsg.WriteUInt32(uniqueId);
virtual void RemoveChild(GUIComponent child)
RectTransform RectTransform
Vector2 MeasureString(LocalizedString str, bool removeExtraSpacing=false)
LocalizedString Fallback(LocalizedString fallback, bool useDefaultLanguageIfFound=true)
Use this text instead if the original text cannot be found.
void ClientAdminRead(IReadMessage incMsg)
List< UInt32 > localRemovedBans
void ClientAdminWrite(IWriteMessage outMsg)
GUIComponent CreateBanFrame(GUIComponent parent)
Option< SerializableDateTime > ExpirationTime
BannedPlayer(UInt32 uniqueIdentifier, string name, Either< Address, AccountId > addressOrAccountId, string reason, Option< SerializableDateTime > expiration)
readonly UInt32 UniqueIdentifier
readonly Either< Address, AccountId > AddressOrAccountId
bool HasPermission(ClientPermissions permission)
UInt32 ReadVariableUInt32()
void WriteVariableUInt32(UInt32 val)
DateTime wrapper that tries to offer a reliable string representation that's also human-friendly
static SerializableDateTime LocalNow