44using Intersect . Client . Framework . File_Management ;
55using Intersect . Client . Framework . Gwen ;
66using Intersect . Client . Framework . Gwen . Control ;
7- using Intersect . Client . Framework . Gwen . Control . EventArguments ;
87using Intersect . Client . General ;
98using Intersect . Client . Localization ;
10- using Intersect . Client . Networking ;
119using Intersect . Configuration ;
1210using Intersect . Enums ;
1311using Intersect . GameObjects ;
@@ -96,20 +94,8 @@ public partial class EntityBox
9694
9795 public bool ShouldUpdateStatuses ;
9896
99- public bool IsHidden ;
100-
10197 // Context menu
102- private Button _contextMenuButton ;
103-
104- private Framework . Gwen . Control . Menu _contextMenu ;
105-
106- private MenuItem _tradeMenuItem ;
107-
108- private MenuItem _partyMenuItem ;
109-
110- private MenuItem _friendMenuItem ;
111-
112- private MenuItem _guildMenuItem ;
98+ private readonly Button _contextMenuButton ;
11399
114100 //Init
115101 public EntityBox ( Canvas gameCanvas , EntityType entityType , Entity ? myEntity , bool isPlayerBox = false )
@@ -180,35 +166,10 @@ public EntityBox(Canvas gameCanvas, EntityType entityType, Entity? myEntity, boo
180166 // Target context menu with basic options.
181167 if ( ! _isPlayerBox )
182168 {
183- _contextMenu = new Framework . Gwen . Control . Menu ( gameCanvas , "TargetContextMenu" )
184- {
185- IsHidden = true ,
186- IconMarginDisabled = true
187- } ;
188-
189- _contextMenu . Children . Clear ( ) ;
190-
191- _tradeMenuItem = _contextMenu . AddItem ( Strings . EntityBox . Trade ) ;
192- _tradeMenuItem . Clicked += tradeRequest_Clicked ;
193-
194- _partyMenuItem = _contextMenu . AddItem ( Strings . EntityBox . Party ) ;
195- _partyMenuItem . Clicked += invite_Clicked ;
196-
197- _friendMenuItem = _contextMenu . AddItem ( Strings . EntityBox . Friend ) ;
198- _friendMenuItem . Clicked += friendRequest_Clicked ;
199-
200- _guildMenuItem = _contextMenu . AddItem ( Strings . Guilds . Guild ) ;
201- _guildMenuItem . Clicked += guildRequest_Clicked ;
202-
203- _contextMenu . LoadJsonUi ( GameContentManager . UI . InGame , Graphics . Renderer . GetResolutionString ( ) ) ;
204-
205169 _contextMenuButton = new Button ( EntityInfoPanel , "ContextMenuButton" ) ;
206- _contextMenuButton . Clicked += ( sender , e ) =>
170+ _contextMenuButton . Clicked += ( _ , _ ) =>
207171 {
208- _contextMenu . SizeToChildren ( ) ;
209- _contextMenu . Open ( Pos . None ) ;
210- _contextMenu . SetPosition ( _contextMenuButton . LocalPosToCanvas ( new Point ( 0 , 0 ) ) . X ,
211- _contextMenuButton . LocalPosToCanvas ( new Point ( 0 , 0 ) ) . Y + _contextMenuButton . Height ) ;
172+ Interface . GameUi . TargetContextMenu . ToggleHidden ( _contextMenuButton ) ;
212173 } ;
213174
214175 EntityStatusWindow = new ImagePanel ( EntityWindow , "EntityStatusWindow" ) ;
@@ -283,7 +244,6 @@ public void ShowAllElements()
283244
284245 if ( ! _isPlayerBox )
285246 {
286- TryShowGuildButton ( ) ;
287247 _contextMenuButton . Show ( ) ;
288248 EventDesc . Show ( ) ;
289249 }
@@ -417,15 +377,13 @@ public void Update()
417377 //Update the event/entity face.
418378 UpdateImage ( ) ;
419379
420- IsHidden = true ;
421380 if ( EntityType != EntityType . Event )
422381 {
423382 EntityName . SetText ( MyEntity . Name ) ;
424383 UpdateLevel ( ) ;
425384 UpdateMap ( ) ;
426385 UpdateHpBar ( elapsedTime ) ;
427386 UpdateMpBar ( elapsedTime ) ;
428- IsHidden = false ;
429387 }
430388 else
431389 {
@@ -449,7 +407,6 @@ public void Update()
449407 }
450408 else if ( _contextMenuButton . IsHidden && ! _isPlayerBox )
451409 {
452- TryShowGuildButton ( ) ;
453410 _contextMenuButton . Show ( ) ;
454411 }
455412 }
@@ -938,108 +895,6 @@ public void Dispose()
938895 EntityWindow . Dispose ( ) ;
939896 }
940897
941- //Input Handlers
942- void invite_Clicked ( Base sender , ClickedEventArgs arguments )
943- {
944- if ( Globals . Me . TargetIndex != Guid . Empty && Globals . Me . TargetIndex != Globals . Me . Id )
945- {
946- if ( Globals . Me . CombatTimer < Timing . Global . Milliseconds )
947- {
948- PacketSender . SendPartyInvite ( Globals . Me . TargetIndex ) ;
949- }
950- else
951- {
952- PacketSender . SendChatMsg ( Strings . Parties . InFight . ToString ( ) , 4 ) ;
953- }
954- }
955- }
956-
957- //Input Handlers
958- void tradeRequest_Clicked ( Base sender , ClickedEventArgs arguments )
959- {
960- if ( Globals . Me . TargetIndex != Guid . Empty && Globals . Me . TargetIndex != Globals . Me . Id )
961- {
962- if ( Globals . Me . CombatTimer < Timing . Global . Milliseconds )
963- {
964- PacketSender . SendTradeRequest ( Globals . Me . TargetIndex ) ;
965- }
966- else
967- {
968- PacketSender . SendChatMsg ( Strings . Trading . InFight . ToString ( ) , 4 ) ;
969- }
970- }
971- }
972-
973- //Input Handlers
974- void friendRequest_Clicked ( Base sender , ClickedEventArgs arguments )
975- {
976- if ( Globals . Me . TargetIndex != Guid . Empty && Globals . Me . TargetIndex != Globals . Me . Id )
977- {
978- if ( Globals . Me . CombatTimer < Timing . Global . Milliseconds )
979- {
980- PacketSender . SendAddFriend ( MyEntity . Name ) ;
981- }
982- else
983- {
984- PacketSender . SendChatMsg ( Strings . Friends . InFight . ToString ( ) , 4 ) ;
985- }
986- }
987- }
988-
989-
990- void guildRequest_Clicked ( Base sender , ClickedEventArgs arguments )
991- {
992- if ( MyEntity is Player plyr && MyEntity != Globals . Me )
993- {
994- if ( string . IsNullOrWhiteSpace ( plyr . Guild ) )
995- {
996- if ( Globals . Me ? . GuildRank ? . Permissions ? . Invite ?? false )
997- {
998- if ( Globals . Me . CombatTimer < Timing . Global . Milliseconds )
999- {
1000- PacketSender . SendInviteGuild ( MyEntity . Name ) ;
1001- }
1002- else
1003- {
1004- PacketSender . SendChatMsg ( Strings . Friends . InFight . ToString ( ) , 4 ) ;
1005- }
1006- }
1007- }
1008- else
1009- {
1010- Chat . ChatboxMsg . AddMessage ( new Chat . ChatboxMsg ( Strings . Guilds . InviteAlreadyInGuild , Color . Red , ChatMessageType . Guild ) ) ;
1011- }
1012- }
1013- }
1014-
1015- void TryShowGuildButton ( )
1016- {
1017- var shouldShow = false ;
1018- if ( MyEntity is Player plyr && MyEntity != Globals . Me && string . IsNullOrWhiteSpace ( plyr . Guild ) )
1019- {
1020- if ( Globals . Me ? . GuildRank ? . Permissions ? . Invite ?? false )
1021- {
1022- shouldShow = true ;
1023- }
1024- }
1025-
1026- if ( shouldShow )
1027- {
1028- if ( ! _contextMenu . Children . Contains ( _guildMenuItem ) )
1029- {
1030- _contextMenu . Children . Add ( _guildMenuItem ) ;
1031- }
1032- }
1033- else
1034- {
1035- if ( _contextMenu . Children . Contains ( _guildMenuItem ) )
1036- {
1037- _contextMenu . Children . Remove ( _guildMenuItem ) ;
1038- }
1039- }
1040- }
1041-
1042-
1043898 public void Hide ( )
1044899 {
1045900 EntityWindow . Hide ( ) ;
0 commit comments