Skip to content

Commit

Permalink
Fix 753 part2 (#768)
Browse files Browse the repository at this point in the history
* Hide the guild invite button in the ui if they are already in a guild

* Added the message on the client side as well
  • Loading branch information
jcsnider committed Jun 7, 2021
1 parent 1917201 commit 2949dd0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
34 changes: 22 additions & 12 deletions Intersect.Client/Interface/Game/EntityPanel/EntityBox.cs
Expand Up @@ -277,7 +277,7 @@ public void ShowAllElements()
HpLbl.Show();
HpTitle.Show();

ShowGuildButton();
TryShowGuildButton();
}

public void SetupEntityElements()
Expand Down Expand Up @@ -447,7 +447,7 @@ public void Update()
TradeLabel.Show();
PartyLabel.Show();
FriendLabel.Show();
ShowGuildButton();
TryShowGuildButton();
}
}

Expand Down Expand Up @@ -1012,31 +1012,41 @@ void friendRequest_Clicked(Base sender, ClickedEventArgs arguments)

void guildRequest_Clicked(Base sender, ClickedEventArgs arguments)
{
if (MyEntity is Player plyr && MyEntity != Globals.Me && string.IsNullOrWhiteSpace(plyr.Guild))
if (MyEntity is Player plyr && MyEntity != Globals.Me)
{
if (Globals.Me?.GuildRank?.Permissions?.Invite ?? false)
if (string.IsNullOrWhiteSpace(plyr.Guild))
{
if (Globals.Me.CombatTimer < Globals.System.GetTimeMs())
if (Globals.Me?.GuildRank?.Permissions?.Invite ?? false)
{
PacketSender.SendInviteGuild(MyEntity.Name);
}
else
{
PacketSender.SendChatMsg(Strings.Friends.infight.ToString(), 4);
if (Globals.Me.CombatTimer < Globals.System.GetTimeMs())
{
PacketSender.SendInviteGuild(MyEntity.Name);
}
else
{
PacketSender.SendChatMsg(Strings.Friends.infight.ToString(), 4);
}
}
}
else
{
Chat.ChatboxMsg.AddMessage(new Chat.ChatboxMsg(Strings.Guilds.InviteAlreadyInGuild, Color.Red, ChatMessageType.Guild));
}
}
}

void ShowGuildButton()
void TryShowGuildButton()
{
var show = false;
if (MyEntity is Player plyr && MyEntity != Globals.Me && string.IsNullOrWhiteSpace(plyr.Guild))
{
if (Globals.Me?.GuildRank?.Permissions?.Invite ?? false)
{
GuildLabel.Show();
show = true;
}
}

GuildLabel.IsHidden = !show;
}


Expand Down
2 changes: 2 additions & 0 deletions Intersect.Client/Localization/Strings.cs
Expand Up @@ -865,6 +865,8 @@ public struct Guilds
public static LocalizedString NotAllowedDeposit = @"You do not have permission to deposit items into {00}'s guild bank!";

public static LocalizedString NotAllowedSwap = @"You do not have permission to swap items around within {00}'s guild bank!";

public static LocalizedString InviteAlreadyInGuild = @"The player you're trying to invite is already in a guild or has a pending invite.";
}

public struct InputBox
Expand Down

0 comments on commit 2949dd0

Please sign in to comment.