Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Intersect.Client.Core/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Intersect.Client.Entities.Projectiles;
using Intersect.Client.Framework.Entities;
using Intersect.Client.Framework.GenericClasses;
using Intersect.Client.Framework.Input;
using Intersect.Client.Framework.Items;
using Intersect.Client.General;
using Intersect.Client.Interface.Game.Chat;
Expand Down Expand Up @@ -1720,6 +1721,14 @@ private void AutoTurnToTarget(Entity en)
PickLastDirection(Dir);
}

private static void ToggleTargetContextMenu(Entity en)
{
if (Globals.InputManager.MouseButtonDown(MouseButtons.Right))
{
Interface.Interface.GameUi.TargetContextMenu.ToggleHidden(en);
}
}

public bool TryBlock()
{
var shieldIndex = Options.ShieldIndex;
Expand Down Expand Up @@ -2622,6 +2631,7 @@ public void DrawTargets()

en.Value.DrawTarget((int)Enums.TargetType.Selected);
AutoTurnToTarget(en.Value);
ToggleTargetContextMenu(en.Value);
}

foreach (MapInstance eventMap in Maps.MapInstance.Lookup.Values.Cast<MapInstance>())
Expand Down Expand Up @@ -2660,6 +2670,7 @@ public void DrawTargets()

en.Value.DrawTarget((int)Enums.TargetType.Selected);
AutoTurnToTarget(en.Value);
ToggleTargetContextMenu(en.Value);
}
}

Expand Down Expand Up @@ -2693,6 +2704,7 @@ public void DrawTargets()
if (TargetType != 0 || TargetIndex != en.Value.Id)
{
en.Value.DrawTarget((int)Enums.TargetType.Hover);
ToggleTargetContextMenu(en.Value);
}
}
}
Expand All @@ -2717,6 +2729,7 @@ public void DrawTargets()
if (TargetType != 1 || TargetIndex != en.Value.Id)
{
en.Value.DrawTarget((int)Enums.TargetType.Hover);
ToggleTargetContextMenu(en.Value);
}
}
}
Expand Down
151 changes: 3 additions & 148 deletions Intersect.Client.Core/Interface/Game/EntityPanel/EntityBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
using Intersect.Client.Framework.File_Management;
using Intersect.Client.Framework.Gwen;
using Intersect.Client.Framework.Gwen.Control;
using Intersect.Client.Framework.Gwen.Control.EventArguments;
using Intersect.Client.General;
using Intersect.Client.Localization;
using Intersect.Client.Networking;
using Intersect.Configuration;
using Intersect.Enums;
using Intersect.GameObjects;
Expand Down Expand Up @@ -96,20 +94,8 @@ public partial class EntityBox

public bool ShouldUpdateStatuses;

public bool IsHidden;

// Context menu
private Button _contextMenuButton;

private Framework.Gwen.Control.Menu _contextMenu;

private MenuItem _tradeMenuItem;

private MenuItem _partyMenuItem;

private MenuItem _friendMenuItem;

private MenuItem _guildMenuItem;
private readonly Button _contextMenuButton;

//Init
public EntityBox(Canvas gameCanvas, EntityType entityType, Entity? myEntity, bool isPlayerBox = false)
Expand Down Expand Up @@ -180,35 +166,10 @@ public EntityBox(Canvas gameCanvas, EntityType entityType, Entity? myEntity, boo
// Target context menu with basic options.
if (!_isPlayerBox)
{
_contextMenu = new Framework.Gwen.Control.Menu(gameCanvas, "TargetContextMenu")
{
IsHidden = true,
IconMarginDisabled = true
};

_contextMenu.Children.Clear();

_tradeMenuItem = _contextMenu.AddItem(Strings.EntityBox.Trade);
_tradeMenuItem.Clicked += tradeRequest_Clicked;

_partyMenuItem = _contextMenu.AddItem(Strings.EntityBox.Party);
_partyMenuItem.Clicked += invite_Clicked;

_friendMenuItem = _contextMenu.AddItem(Strings.EntityBox.Friend);
_friendMenuItem.Clicked += friendRequest_Clicked;

_guildMenuItem = _contextMenu.AddItem(Strings.Guilds.Guild);
_guildMenuItem.Clicked += guildRequest_Clicked;

_contextMenu.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());

_contextMenuButton = new Button(EntityInfoPanel, "ContextMenuButton");
_contextMenuButton.Clicked += (sender, e) =>
_contextMenuButton.Clicked += (_, _) =>
{
_contextMenu.SizeToChildren();
_contextMenu.Open(Pos.None);
_contextMenu.SetPosition(_contextMenuButton.LocalPosToCanvas(new Point(0, 0)).X,
_contextMenuButton.LocalPosToCanvas(new Point(0, 0)).Y + _contextMenuButton.Height);
Interface.GameUi.TargetContextMenu.ToggleHidden(_contextMenuButton);
};

EntityStatusWindow = new ImagePanel(EntityWindow, "EntityStatusWindow");
Expand Down Expand Up @@ -283,7 +244,6 @@ public void ShowAllElements()

if (!_isPlayerBox)
{
TryShowGuildButton();
_contextMenuButton.Show();
EventDesc.Show();
}
Expand Down Expand Up @@ -417,15 +377,13 @@ public void Update()
//Update the event/entity face.
UpdateImage();

IsHidden = true;
if (EntityType != EntityType.Event)
{
EntityName.SetText(MyEntity.Name);
UpdateLevel();
UpdateMap();
UpdateHpBar(elapsedTime);
UpdateMpBar(elapsedTime);
IsHidden = false;
}
else
{
Expand All @@ -449,7 +407,6 @@ public void Update()
}
else if (_contextMenuButton.IsHidden && !_isPlayerBox)
{
TryShowGuildButton();
_contextMenuButton.Show();
}
}
Expand Down Expand Up @@ -938,108 +895,6 @@ public void Dispose()
EntityWindow.Dispose();
}

//Input Handlers
void invite_Clicked(Base sender, ClickedEventArgs arguments)
{
if (Globals.Me.TargetIndex != Guid.Empty && Globals.Me.TargetIndex != Globals.Me.Id)
{
if (Globals.Me.CombatTimer < Timing.Global.Milliseconds)
{
PacketSender.SendPartyInvite(Globals.Me.TargetIndex);
}
else
{
PacketSender.SendChatMsg(Strings.Parties.InFight.ToString(), 4);
}
}
}

//Input Handlers
void tradeRequest_Clicked(Base sender, ClickedEventArgs arguments)
{
if (Globals.Me.TargetIndex != Guid.Empty && Globals.Me.TargetIndex != Globals.Me.Id)
{
if (Globals.Me.CombatTimer < Timing.Global.Milliseconds)
{
PacketSender.SendTradeRequest(Globals.Me.TargetIndex);
}
else
{
PacketSender.SendChatMsg(Strings.Trading.InFight.ToString(), 4);
}
}
}

//Input Handlers
void friendRequest_Clicked(Base sender, ClickedEventArgs arguments)
{
if (Globals.Me.TargetIndex != Guid.Empty && Globals.Me.TargetIndex != Globals.Me.Id)
{
if (Globals.Me.CombatTimer < Timing.Global.Milliseconds)
{
PacketSender.SendAddFriend(MyEntity.Name);
}
else
{
PacketSender.SendChatMsg(Strings.Friends.InFight.ToString(), 4);
}
}
}


void guildRequest_Clicked(Base sender, ClickedEventArgs arguments)
{
if (MyEntity is Player plyr && MyEntity != Globals.Me)
{
if (string.IsNullOrWhiteSpace(plyr.Guild))
{
if (Globals.Me?.GuildRank?.Permissions?.Invite ?? false)
{
if (Globals.Me.CombatTimer < Timing.Global.Milliseconds)
{
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 TryShowGuildButton()
{
var shouldShow = false;
if (MyEntity is Player plyr && MyEntity != Globals.Me && string.IsNullOrWhiteSpace(plyr.Guild))
{
if (Globals.Me?.GuildRank?.Permissions?.Invite ?? false)
{
shouldShow = true;
}
}

if (shouldShow)
{
if (!_contextMenu.Children.Contains(_guildMenuItem))
{
_contextMenu.Children.Add(_guildMenuItem);
}
}
else
{
if (_contextMenu.Children.Contains(_guildMenuItem))
{
_contextMenu.Children.Remove(_guildMenuItem);
}
}
}


public void Hide()
{
EntityWindow.Hide();
Expand Down
5 changes: 4 additions & 1 deletion Intersect.Client.Core/Interface/Game/GameInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public GameInterface(Canvas canvas) : base(canvas)
GameCanvas = canvas;
EscapeMenu = new EscapeMenu(GameCanvas) {IsHidden = true};
SimplifiedEscapeMenu = new SimplifiedEscapeMenu(GameCanvas) {IsHidden = true};
TargetContextMenu = new TargetContextMenu(GameCanvas) {IsHidden = true};
AnnouncementWindow = new AnnouncementWindow(GameCanvas) { IsHidden = true };

InitGameGui();
Expand All @@ -102,9 +103,11 @@ public GameInterface(Canvas canvas) : base(canvas)
public Canvas GameCanvas { get; }

public EscapeMenu EscapeMenu { get; }

public SimplifiedEscapeMenu SimplifiedEscapeMenu { get; }

public TargetContextMenu TargetContextMenu { get; }

public AnnouncementWindow AnnouncementWindow { get; }

public Menu GameMenu { get; private set; }
Expand Down
Loading
Loading