From 4ac727313439d5de44204fad2ef370fec40c689f Mon Sep 17 00:00:00 2001 From: WeylonSantana Date: Sat, 3 Aug 2024 19:13:06 -0300 Subject: [PATCH] chore: refactor guild window --- .../Interface/Game/GuildWindow.cs | 577 +++++++++--------- Intersect.Client/Interface/Game/Menu.cs | 8 +- Intersect.Client/Localization/Strings.cs | 3 + 3 files changed, 305 insertions(+), 283 deletions(-) diff --git a/Intersect.Client/Interface/Game/GuildWindow.cs b/Intersect.Client/Interface/Game/GuildWindow.cs index aa175b25a8..11136f84fa 100644 --- a/Intersect.Client/Interface/Game/GuildWindow.cs +++ b/Intersect.Client/Interface/Game/GuildWindow.cs @@ -10,201 +10,192 @@ namespace Intersect.Client.Interface.Game; - -partial class GuildWindow +partial class GuildWindow : WindowControl { + private readonly ImagePanel _textboxContainer; + private readonly TextBox _textboxSearch; + private readonly ListBox _listGuildMembers; + private readonly Button _buttonAdd; + private readonly Button _buttonLeave; + private readonly Button _buttonAddPopup; + private readonly Framework.Gwen.Control.Menu _contextMenu; + private readonly MenuItem _privateMessageOption; + private readonly MenuItem[] _promoteOptions; + private readonly MenuItem[] _demoteOptions; + private readonly MenuItem _kickOption; + private readonly MenuItem _transferOption; + + private readonly bool _addButtonUsed; + private readonly bool _addPopupButtonUsed; + private GuildMember? _selectedMember; + + public GuildWindow(Canvas gameCanvas) : base(gameCanvas, Globals.Me?.Guild, false, nameof(GuildWindow)) + { + DisableResizing(); - private Button mAddButton; - - private Button mAddPopupButton; - - private Button mLeave; - - private ListBox mGuildMembers; - - //Controls - private WindowControl mGuildWindow; - - private TextBox mSearchTextbox; - - private ImagePanel mTextboxContainer; - - private bool mAddButtonUsed; - - private bool mAddPopupButtonUsed; - - //Context Menu - private Framework.Gwen.Control.Menu mContextMenu; - - private MenuItem mPmOption; - - private MenuItem[] mPromoteOptions; - - private MenuItem[] mDemoteOptions; - - private MenuItem mKickOption; - - private MenuItem mTransferOption; + // Textbox Search + _textboxContainer = new ImagePanel(this, "SearchContainer"); + _textboxSearch = new TextBox(_textboxContainer, "SearchTextbox"); + Interface.FocusElements.Add(_textboxSearch); - private GuildMember mSelectedMember; + // List of Guild Members + _listGuildMembers = new ListBox(this, "GuildMembers"); - //Init - public GuildWindow(Canvas gameCanvas) - { - mGuildWindow = new WindowControl(gameCanvas, Globals.Me.Guild, false, "GuildWindow"); - mGuildWindow.DisableResizing(); + #region Action Buttons - mTextboxContainer = new ImagePanel(mGuildWindow, "SearchContainer"); - mSearchTextbox = new TextBox(mTextboxContainer, "SearchTextbox"); - Interface.FocusElements.Add(mSearchTextbox); + // Add Button + _buttonAdd = new Button(this, "InviteButton") + { + Text = Strings.Guilds.Add + }; + _buttonAdd.Clicked += (s, e) => + { + if (_textboxSearch.Text.Trim().Length >= 3) + { + PacketSender.SendInviteGuild(_textboxSearch.Text); + } + }; - mGuildMembers = new ListBox(mGuildWindow, "GuildMembers"); + // Leave Button + _buttonLeave = new Button(this, "LeaveButton") + { + Text = Strings.Guilds.Leave + }; + _buttonLeave.Clicked += (s, e) => + { + _ = new InputBox( + title: Strings.Guilds.LeaveTitle, + prompt: Strings.Guilds.LeavePrompt.ToString(Globals.Me?.Guild), + inputType: InputBox.InputType.YesNo, + onSuccess: (s, e) => PacketSender.SendLeaveGuild() + ); + }; - mAddButton = new Button(mGuildWindow, "InviteButton"); - mAddButton.SetText("+"); - mAddButton.Clicked += addButton_Clicked; + // Add Popup Button + _buttonAddPopup = new Button(this, "InvitePopupButton") + { + Text = Strings.Guilds.Invite, + IsHidden = true + }; + _buttonAddPopup.Clicked += (s, e) => + { + _ = new InputBox( + title: Strings.Guilds.InviteMemberTitle, + prompt: Strings.Guilds.InviteMemberPrompt.ToString(Globals.Me?.Guild), + inputType: InputBox.InputType.TextInput, + onSuccess: (s, e) => + { + if (s is InputBox inputBox && inputBox.TextValue.Trim().Length >= 3) + { + PacketSender.SendInviteGuild(inputBox.TextValue); + } + } + ); + }; - mLeave = new Button(mGuildWindow, "LeaveButton"); - mLeave.SetText(Strings.Guilds.Leave); - mLeave.Clicked += leave_Clicked; + #endregion - mAddPopupButton = new Button(mGuildWindow, "InvitePopupButton"); - mAddPopupButton.IsHidden = true; - mAddPopupButton.SetText(Strings.Guilds.Invite); - mAddPopupButton.Clicked += addPopupButton_Clicked; + #region Context Menu Options - mContextMenu = new Framework.Gwen.Control.Menu(gameCanvas, "GuildContextMenu"); - mContextMenu.IsHidden = true; - mContextMenu.IconMarginDisabled = true; + // Context Menu + _contextMenu = new Framework.Gwen.Control.Menu(gameCanvas, "GuildContextMenu") + { + IsHidden = true, + IconMarginDisabled = true + }; //Add Context Menu Options //TODO: Is this a memory leak? - mContextMenu.Children.Clear(); + _contextMenu.Children.Clear(); - mPmOption = mContextMenu.AddItem(Strings.Guilds.PM.ToString()); - mPmOption.Clicked += pmOption_Clicked; + // Private Message + _privateMessageOption = _contextMenu.AddItem(Strings.Guilds.PM); + _privateMessageOption.Clicked += (s, e) => + { + if (_selectedMember?.Online == true && _selectedMember?.Id != Globals.Me?.Id) + { + Interface.GameUi.SetChatboxText("/pm " + _selectedMember!.Name + " "); + } + }; - mPromoteOptions = new MenuItem[Options.Instance.Guild.Ranks.Length - 2]; + // Promote Options + _promoteOptions = new MenuItem[Options.Instance.Guild.Ranks.Length - 2]; for (int i = 1; i < Options.Instance.Guild.Ranks.Length - 1; i++) { - mPromoteOptions[i - 1] = mContextMenu.AddItem(Strings.Guilds.Promote.ToString(Options.Instance.Guild.Ranks[i].Title)); - mPromoteOptions[i - 1].UserData = i; - mPromoteOptions[i - 1].Clicked += promoteOption_Clicked; + _promoteOptions[i - 1] = _contextMenu.AddItem(Strings.Guilds.Promote.ToString(Options.Instance.Guild.Ranks[i].Title)); + _promoteOptions[i - 1].UserData = i; + _promoteOptions[i - 1].Clicked += promoteOption_Clicked; } - mDemoteOptions = new MenuItem[Options.Instance.Guild.Ranks.Length - 2]; + // Demote Options + _demoteOptions = new MenuItem[Options.Instance.Guild.Ranks.Length - 2]; for (int i = 2; i < Options.Instance.Guild.Ranks.Length; i++) { - mDemoteOptions[i - 2] = mContextMenu.AddItem(Strings.Guilds.Demote.ToString(Options.Instance.Guild.Ranks[i].Title)); - mDemoteOptions[i - 2].UserData = i; - mDemoteOptions[i - 2].Clicked += demoteOption_Clicked; + _demoteOptions[i - 2] = _contextMenu.AddItem(Strings.Guilds.Demote.ToString(Options.Instance.Guild.Ranks[i].Title)); + _demoteOptions[i - 2].UserData = i; + _demoteOptions[i - 2].Clicked += demoteOption_Clicked; } - mKickOption = mContextMenu.AddItem(Strings.Guilds.Kick.ToString()); - mKickOption.Clicked += kickOption_Clicked; + // Kick Option + _kickOption = _contextMenu.AddItem(Strings.Guilds.Kick); + _kickOption.Clicked += kickOption_Clicked; + + // Transfer Option + _transferOption = _contextMenu.AddItem(Strings.Guilds.Transfer); + _transferOption.Clicked += transferOption_Clicked; - mTransferOption = mContextMenu.AddItem(Strings.Guilds.Transfer.ToString()); - mTransferOption.Clicked += transferOption_Clicked; + #endregion UpdateList(); - mContextMenu.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); - mGuildWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); + _contextMenu.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer?.GetResolutionString()); + LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer?.GetResolutionString()); - mAddButtonUsed = !mAddButton.IsHidden; - mAddPopupButtonUsed = !mAddPopupButton.IsHidden; + _addButtonUsed = !_buttonAdd.IsHidden; + _addPopupButtonUsed = !_buttonAddPopup.IsHidden; } //Methods public void Update() { - if (mGuildWindow.IsHidden) + if (IsHidden) { return; } // Force our window title to co-operate, might be empty after creating/joining a guild. - if (mGuildWindow.Title != Globals.Me.Guild) + if (!string.IsNullOrEmpty(Globals.Me?.Guild) && Title != Globals.Me.Guild) { - mGuildWindow.Title = Globals.Me.Guild; + Title = Globals.Me.Guild; } } - public void Show() + public override void Hide() { - mGuildWindow.IsHidden = false; + _contextMenu?.Close(); + base.Hide(); } - public bool IsVisible() - { - return !mGuildWindow.IsHidden; - } - - public void Hide() - { - mContextMenu?.Close(); - mGuildWindow.IsHidden = true; - } - - #region "Adding/Leaving" - void addButton_Clicked(Base sender, ClickedEventArgs arguments) - { - if (mSearchTextbox.Text.Trim().Length >= 3) //Don't bother sending a packet less than the char limit - { - PacketSender.SendInviteGuild(mSearchTextbox.Text); - } - } - - void addPopupButton_Clicked(Base sender, ClickedEventArgs arguments) - { - _ = new InputBox( - title: Strings.Guilds.InviteMemberTitle, - prompt: Strings.Guilds.InviteMemberPrompt.ToString(Globals.Me?.Guild), - inputType: InputBox.InputType.TextInput, - onSuccess: (s, e) => - { - if (s is InputBox inputBox && inputBox.TextValue.Trim().Length >= 3) - { - PacketSender.SendInviteGuild(inputBox.TextValue); - } - } - ); - } - - private void leave_Clicked(Base sender, ClickedEventArgs arguments) - { - _ = new InputBox( - title: Strings.Guilds.LeaveTitle, - prompt: Strings.Guilds.LeavePrompt.ToString(Globals.Me?.Guild), - inputType: InputBox.InputType.YesNo, - onSuccess: (s, e) => PacketSender.SendLeaveGuild() - ); - } - - #endregion - #region "Member List" + public void UpdateList() { //Clear previous instances if already existing - if (mGuildMembers != null) - { - mGuildMembers.Clear(); - } + _listGuildMembers.Clear(); - foreach (var f in Globals.Me.GuildMembers) + foreach (var member in Globals.Me?.GuildMembers ?? []) { - var str = f.Online ? Strings.Guilds.OnlineListEntry : Strings.Guilds.OfflineListEntry; - var row = mGuildMembers.AddRow(str.ToString(Options.Instance.Guild.Ranks[f.Rank].Title, f.Name, f.Map)); + var str = member.Online ? Strings.Guilds.OnlineListEntry : Strings.Guilds.OfflineListEntry; + var row = _listGuildMembers.AddRow(str.ToString(Options.Instance.Guild.Ranks[member.Rank].Title, member.Name, member.Map)); row.Name = "GuildMemberRow"; - row.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); - row.SetToolTipText(Strings.Guilds.Tooltip.ToString(f.Level, f.Class)); - row.UserData = f; + row.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer?.GetResolutionString()); + row.SetToolTipText(Strings.Guilds.Tooltip.ToString(member.Level, member.Class)); + row.UserData = member; row.Clicked += member_Clicked; row.RightClicked += member_RightClicked; //Row Render color (red = offline, green = online) - if (f.Online == true) + if (member.Online == true) { row.SetTextColor(Color.Green); } @@ -216,20 +207,22 @@ public void UpdateList() row.RenderColor = new Color(50, 255, 255, 255); } + var isInviteDenied = Globals.Me == null || Globals.Me.GuildRank == null || !Globals.Me.GuildRank.Permissions.Invite; + //Determine if we can invite - mAddButton.IsHidden = Globals.Me == null || Globals.Me.GuildRank == null || !Globals.Me.GuildRank.Permissions.Invite || !mAddButtonUsed; - mTextboxContainer.IsHidden = Globals.Me == null || Globals.Me.GuildRank == null || !Globals.Me.GuildRank.Permissions.Invite || !mAddButtonUsed; - mAddPopupButton.IsHidden = Globals.Me == null || Globals.Me.GuildRank == null || !Globals.Me.GuildRank.Permissions.Invite || !mAddPopupButtonUsed; - mLeave.IsHidden = Globals.Me != null && Globals.Me.Rank == 0; + _buttonAdd.IsHidden = isInviteDenied || !_addButtonUsed; + _textboxContainer.IsHidden = isInviteDenied || !_addButtonUsed; + _buttonAddPopup.IsHidden = isInviteDenied || !_addPopupButtonUsed; + _buttonLeave.IsHidden = Globals.Me != null && Globals.Me.Rank == 0; } void member_Clicked(Base sender, ClickedEventArgs arguments) { - var row = (ListBoxRow)sender; - var member = (GuildMember)row.UserData; - - //Only pm online players - if (member?.Online == true && member?.Id != Globals.Me?.Id) + if (sender is ListBoxRow row && + row.UserData is GuildMember member && + member.Online && + member.Id != Globals.Me?.Id + ) { Interface.GameUi.SetChatboxText("/pm " + member.Name + " "); } @@ -237,183 +230,209 @@ void member_Clicked(Base sender, ClickedEventArgs arguments) private void member_RightClicked(Base sender, ClickedEventArgs arguments) { - var row = (ListBoxRow)sender; - var member = (GuildMember)row.UserData; + if (sender is not ListBoxRow row || row.UserData is not GuildMember member) + { + return; + } - //Only pm online players - if (member != null && member.Id != Globals.Me?.Id) + if (Globals.Me == default || member.Id == Globals.Me.Id) { - mSelectedMember = member; + return; + } - var rank = Globals.Me?.GuildRank ?? null; + _selectedMember = member; - if (rank != null) - { - //Remove and re-add children - foreach (var child in mContextMenu.Children.ToArray()) - { - mContextMenu.RemoveChild(child, false); - } + var rank = Globals.Me.GuildRank ?? default; + if (rank == null) + { + return; + } - var rankIndex = Globals.Me.Rank; - var isOwner = rankIndex == 0; + //Remove and re-add children + foreach (var child in _contextMenu.Children.ToArray()) + { + _contextMenu.RemoveChild(child, false); + } - if (mSelectedMember?.Online ?? false) - { - mContextMenu.AddChild(mPmOption); - } + var rankIndex = Globals.Me.Rank; + var isOwner = rankIndex == 0; - //Promote Options - foreach (var opt in mPromoteOptions) - { - if ((isOwner || rank.Permissions.Promote) && (int)opt.UserData > rankIndex && (int)opt.UserData < member.Rank && member.Rank > rankIndex) - { - mContextMenu.AddChild(opt); - } - } + if (_selectedMember.Online) + { + _contextMenu.AddChild(_privateMessageOption); + } - //Demote Options - foreach (var opt in mDemoteOptions) - { - if ((isOwner || rank.Permissions.Demote) && (int)opt.UserData > rankIndex && (int)opt.UserData > member.Rank && member.Rank > rankIndex) - { - mContextMenu.AddChild(opt); - } - } + //Promote Options + foreach (var opt in _promoteOptions) + { + var isAllowed = (isOwner || rank.Permissions.Promote); + var hasLowerRank = (int)opt.UserData > rankIndex; + var canRankChange = (int)opt.UserData < member.Rank && member.Rank > rankIndex; - if ((rank.Permissions.Kick || isOwner) && member.Rank > rankIndex) - { - mContextMenu.AddChild(mKickOption); - } + if (isAllowed && hasLowerRank && canRankChange) + { + _contextMenu.AddChild(opt); + } + } - if (isOwner) - { - mContextMenu.AddChild(mTransferOption); - } + //Demote Options + foreach (var opt in _demoteOptions) + { + var isAllowed = (isOwner || rank.Permissions.Demote); + var hasLowerRank = (int)opt.UserData > rankIndex; + var canRankChange = (int)opt.UserData > member.Rank && member.Rank > rankIndex; - mContextMenu.SizeToChildren(); - mContextMenu.Open(Framework.Gwen.Pos.None); + if (isAllowed && hasLowerRank && canRankChange) + { + _contextMenu.AddChild(opt); } } - } - #endregion + if ((rank.Permissions.Kick || isOwner) && member.Rank > rankIndex) + { + _contextMenu.AddChild(_kickOption); + } - #region "Kicking" - private void kickOption_Clicked(Base sender, ClickedEventArgs arguments) - { - var rank = Globals.Me?.GuildRank ?? null; - var rankIndex = Globals.Me?.Rank; - var isOwner = rankIndex == 0; - if (mSelectedMember != null && (rank.Permissions.Kick || isOwner) && mSelectedMember.Rank > rankIndex) + if (isOwner) { - _ = new InputBox( - title: Strings.Guilds.KickTitle, - prompt: Strings.Guilds.KickPrompt.ToString(mSelectedMember?.Name), - inputType: InputBox.InputType.YesNo, - userData: mSelectedMember, - onSuccess: (s, e) => - { - if (s is InputBox inputBox && inputBox.UserData is GuildMember member) - { - PacketSender.SendKickGuildMember(member.Id); - } - } - ); + _contextMenu.AddChild(_transferOption); } + + _ = _contextMenu.SizeToChildren(); + _contextMenu.Open(Framework.Gwen.Pos.None); } #endregion - #region "Transferring" - private void transferOption_Clicked(Base sender, ClickedEventArgs arguments) + #region Guild Actions + + private void promoteOption_Clicked(Base sender, ClickedEventArgs arguments) { - var rank = Globals.Me?.GuildRank ?? null; - var rankIndex = Globals.Me?.Rank; + if (Globals.Me == default || Globals.Me.GuildRank == default || _selectedMember == default) + { + return; + } + + var rank = Globals.Me.GuildRank; + var rankIndex = Globals.Me.Rank; var isOwner = rankIndex == 0; - if (mSelectedMember != null && (rank.Permissions.Kick || isOwner) && mSelectedMember.Rank > rankIndex) + var newRank = (int)sender.UserData; + + if (!(rank.Permissions.Promote || isOwner) || _selectedMember.Rank <= rankIndex) { - _ = new InputBox( - title: Strings.Guilds.TransferTitle, - prompt: Strings.Guilds.TransferPrompt.ToString(mSelectedMember?.Name, rank.Title, Globals.Me?.Guild), - inputType: InputBox.InputType.TextInput, - userData: mSelectedMember, - onSuccess: (s, e) => + return; + } + + _ = new InputBox( + Strings.Guilds.PromoteTitle, + Strings.Guilds.PromotePrompt.ToString(_selectedMember.Name, Options.Instance.Guild.Ranks[newRank].Title), + InputBox.InputType.YesNo, + userData: new Tuple(_selectedMember, newRank), + onSuccess: (s, e) => + { + if (s is InputBox inputBox && inputBox.UserData is Tuple memberRankPair) { - if (s is InputBox inputBox && inputBox.TextValue == Globals.Me?.Guild && inputBox.UserData is GuildMember member) - { - PacketSender.SendTransferGuild(member.Id); - } + var (member, newRank) = memberRankPair; + PacketSender.SendPromoteGuildMember(member.Id, newRank); } - ); - } + } + ); } - #endregion + private void demoteOption_Clicked(Base sender, ClickedEventArgs arguments) + { + if (Globals.Me == default || Globals.Me.GuildRank == default || _selectedMember == default) + { + return; + } + var rank = Globals.Me.GuildRank; + var rankIndex = Globals.Me.Rank; + var isOwner = rankIndex == 0; + var newRank = (int)sender.UserData; - private void pmOption_Clicked(Base sender, ClickedEventArgs arguments) - { - //Only pm online players - if (mSelectedMember?.Online == true && mSelectedMember?.Id != Globals.Me?.Id) + if (!(rank.Permissions.Demote || isOwner) || _selectedMember.Rank <= rankIndex) { - Interface.GameUi.SetChatboxText("/pm " + mSelectedMember.Name + " "); + return; } + + _ = new InputBox( + Strings.Guilds.DemoteTitle, + Strings.Guilds.DemotePrompt.ToString(_selectedMember.Name, Options.Instance.Guild.Ranks[newRank].Title), + InputBox.InputType.YesNo, + userData: new Tuple(_selectedMember, newRank), + onSuccess: (s, e) => + { + if (s is InputBox inputBox && inputBox.UserData is Tuple memberRankPair) + { + var (member, newRank) = memberRankPair; + PacketSender.SendDemoteGuildMember(member.Id, newRank); + } + } + ); } - #region "Promoting" - private void promoteOption_Clicked(Base sender, ClickedEventArgs arguments) + private void kickOption_Clicked(Base sender, ClickedEventArgs arguments) { - var rank = Globals.Me?.GuildRank ?? null; - var rankIndex = Globals.Me?.Rank; + if (Globals.Me == default || Globals.Me.GuildRank == default || _selectedMember == default) + { + return; + } + + var rank = Globals.Me.GuildRank; + var rankIndex = Globals.Me.Rank; var isOwner = rankIndex == 0; - var newRank = (int)sender.UserData; - if (mSelectedMember != null && (rank.Permissions.Kick || isOwner) && mSelectedMember.Rank > rankIndex) + + if (!(rank.Permissions.Kick || isOwner) || _selectedMember.Rank <= rankIndex) { - _ = new InputBox( - title: Strings.Guilds.PromoteTitle, - prompt: Strings.Guilds.PromotePrompt.ToString(mSelectedMember?.Name, Options.Instance.Guild.Ranks[newRank].Title), - inputType: InputBox.InputType.YesNo, - userData: new Tuple(mSelectedMember, newRank), - onSuccess: (s, e) => + return; + } + + _ = new InputBox( + Strings.Guilds.KickTitle, + Strings.Guilds.KickPrompt.ToString(_selectedMember?.Name), + InputBox.InputType.YesNo, + userData: _selectedMember, + onSuccess: (s, e) => + { + if (s is InputBox inputBox && inputBox.UserData is GuildMember member) { - if (s is InputBox inputBox && inputBox.UserData is Tuple memberRankPair) - { - var (member, newRank) = memberRankPair; - PacketSender.SendPromoteGuildMember(member?.Id ?? Guid.Empty, newRank); - } + PacketSender.SendKickGuildMember(member.Id); } - ); - } + } + ); } - #endregion - - #region "Demoting" - private void demoteOption_Clicked(Base sender, ClickedEventArgs arguments) + private void transferOption_Clicked(Base sender, ClickedEventArgs arguments) { - var rank = Globals.Me?.GuildRank ?? null; - var rankIndex = Globals.Me?.Rank; + if (Globals.Me == default || Globals.Me.GuildRank == default || _selectedMember == default) + { + return; + } + + var rank = Globals.Me.GuildRank; + var rankIndex = Globals.Me.Rank; var isOwner = rankIndex == 0; - var newRank = (int)sender.UserData; - if (mSelectedMember != null && (rank.Permissions.Kick || isOwner) && mSelectedMember.Rank > rankIndex) + + if (!(rank.Permissions.Kick || isOwner) || _selectedMember.Rank <= rankIndex) { - _ = new InputBox( - title: Strings.Guilds.DemoteTitle, - prompt: Strings.Guilds.DemotePrompt.ToString(mSelectedMember?.Name, Options.Instance.Guild.Ranks[newRank].Title), - inputType: InputBox.InputType.YesNo, - userData: new Tuple(mSelectedMember, newRank), - onSuccess: (s, e) => + return; + } + + _ = new InputBox( + Strings.Guilds.TransferTitle, + Strings.Guilds.TransferPrompt.ToString(_selectedMember?.Name, rank.Title, Globals.Me?.Guild), + InputBox.InputType.TextInput, + userData: _selectedMember, + onSuccess: (s, e) => + { + if (s is InputBox inputBox && inputBox.TextValue == Globals.Me?.Guild && inputBox.UserData is GuildMember member) { - if (s is InputBox inputBox && inputBox.UserData is Tuple memberRankPair) - { - var (member, newRank) = memberRankPair; - PacketSender.SendDemoteGuildMember(member?.Id ?? Guid.Empty, newRank); - } + PacketSender.SendTransferGuild(member.Id); } - ); - } + } + ); } - #endregion + #endregion } diff --git a/Intersect.Client/Interface/Game/Menu.cs b/Intersect.Client/Interface/Game/Menu.cs index c172f0f346..6e1698e89a 100644 --- a/Intersect.Client/Interface/Game/Menu.cs +++ b/Intersect.Client/Interface/Game/Menu.cs @@ -1,4 +1,4 @@ -using Intersect.Client.Core; +using Intersect.Client.Core; using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Gwen.Control; using Intersect.Client.Framework.Gwen.Control.EventArguments; @@ -213,7 +213,7 @@ public bool ToggleFriendsWindow() public bool ToggleGuildWindow() { - if (mGuildWindow.IsVisible()) + if (!mGuildWindow.IsHidden) { mGuildWindow.Hide(); } @@ -225,7 +225,7 @@ public bool ToggleGuildWindow() mGuildWindow.Show(); } - return mGuildWindow.IsVisible(); + return !mGuildWindow.IsHidden; } public void HideGuildWindow() @@ -346,7 +346,7 @@ public bool HasWindowsOpen() windowsOpen = true; } - if (mGuildWindow.IsVisible()) + if (!mGuildWindow.IsHidden) { windowsOpen = true; } diff --git a/Intersect.Client/Localization/Strings.cs b/Intersect.Client/Localization/Strings.cs index 88db9726b3..3b44e1adaf 100644 --- a/Intersect.Client/Localization/Strings.cs +++ b/Intersect.Client/Localization/Strings.cs @@ -1101,6 +1101,9 @@ public partial struct General public partial struct Guilds { + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public static LocalizedString Add = @"+"; + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public static LocalizedString Bank = @"{00} Guild Bank";