Represents the state of an active context menu. This includes who opened the menu, the menu's focus object, and a list of entries that the menu is composed of. ContextMenuEntry
コード例 #1
0
		public static void ContextMenuRequest( NetState state, PacketReader pvSrc )
		{
			Mobile from = state.Mobile;
			IEntity target = World.FindEntity( pvSrc.ReadInt32() );

			if ( from != null && target != null && from.Map == target.Map && from.CanSee( target ) )
			{
				if ( target is Mobile && !Utility.InUpdateRange( from.Location, target.Location ) )
					return;
				else if ( target is Item && !Utility.InUpdateRange( from.Location, ((Item)target).GetWorldLocation() ) )
					return;

				if ( !from.CheckContextMenuDisplay( target ) )
					return;

				ContextMenu c = new ContextMenu( from, target );

				if ( c.Entries.Length > 0 )
				{
					if ( target is Item )
					{
						object root = ((Item)target).RootParent;

						if ( root is Mobile && root != from && ((Mobile)root).AccessLevel >= from.AccessLevel )
						{
							for ( int i = 0; i < c.Entries.Length; ++i )
							{
								if ( !c.Entries[i].NonLocalUse )
									c.Entries[i].Enabled = false;
							}
						}
					}

					from.ContextMenu = c;
				}
			}
		}
コード例 #2
0
ファイル: Packets.cs プロジェクト: BackupTheBerlios/sunuo-svn
        public DisplayContextMenu( ContextMenu menu )
            : base(0xBF)
        {
            ContextMenuEntry[] entries = menu.Entries;

            int length = (byte) entries.Length;

            this.EnsureCapacity( 12 + (length * 8) );

            m_Stream.Write( (short) 0x14 );
            m_Stream.Write( (short) 0x01 );

            IEntity target = menu.Target as IEntity;

            m_Stream.Write( (int) ( target == null ? Serial.MinusOne : target.Serial ) );

            m_Stream.Write( (byte) length );

            Point3D p;

            if ( target is Mobile )
                p = target.Location;
            else if ( target is Item )
                p = ((Item)target).GetWorldLocation();
            else
                p = Point3D.Zero;

            for ( int i = 0; i < length; ++i )
            {
                ContextMenuEntry e = entries[i];

                m_Stream.Write( (short) i );
                m_Stream.Write( (ushort) e.Number );

                int range = e.Range;

                if ( range == -1 )
                    range = 18;

                CMEFlags flags = (e.Enabled && menu.From.InRange( p, range )) ? CMEFlags.None : CMEFlags.Disabled;

                int color = e.Color & 0xFFFF;

                if ( color != 0xFFFF )
                    flags |= CMEFlags.Colored;

                flags |= e.Flags;

                m_Stream.Write( (short) flags );

                if ( (flags & CMEFlags.Colored) != 0 )
                    m_Stream.Write( (short) color );
            }
        }
コード例 #3
0
ファイル: Packets.cs プロジェクト: Ziden/ServUO-EC-Test-Fork
        public DisplayContextMenuOld(ContextMenu menu)
            : base(0xBF)
        {
            ContextMenuEntry[] entries = menu.Entries;

            int length = (byte)entries.Length;

            EnsureCapacity(12 + (length * 8));

            m_Stream.Write((short)0x14);
            #region Enhance Client
            m_Stream.Write((short)0x02);
            #endregion

            var target = menu.Target as IEntity;

            m_Stream.Write((target == null ? Serial.MinusOne : target.Serial));

            m_Stream.Write((byte)length);

            Point3D p;

            if (target is Mobile)
            {
                p = target.Location;
            }
            else if (target is Item)
            {
                p = ((Item)target).GetWorldLocation();
            }
            else
            {
                p = Point3D.Zero;
            }

            for (int i = 0; i < length; ++i)
            {
                ContextMenuEntry e = entries[i];

                #region Enhance Client
                if (e.Number <= 65535)
                    m_Stream.Write((uint)(e.Number + 3000000));
                else
                    m_Stream.Write((uint)e.Number);

                m_Stream.Write((short)i);
                #endregion

                int range = e.Range;

                if (range == -1)
                {
                    range = Core.GlobalUpdateRange; //18
                }

                CMEFlags flags = (e.Enabled && menu.From.InRange(p, range)) ? CMEFlags.None : CMEFlags.Disabled;

                int color = e.Color & 0xFFFF;

                if (color != 0xFFFF)
                {
                    flags |= CMEFlags.Colored;
                }

                flags |= e.Flags;

                m_Stream.Write((short)flags);

                if ((flags & CMEFlags.Colored) != 0)
                {
                    m_Stream.Write((short)color);
                }
            }
        }
コード例 #4
0
ファイル: Packets.cs プロジェクト: Ravenwolfe/ServUO
		public DisplayContextMenu(ContextMenu menu)
			: base(0xBF)
		{
			var entries = menu.Entries;

			int length = (byte)entries.Length;

			EnsureCapacity(12 + (length * 8));

			m_Stream.Write((short)0x14);
			m_Stream.Write((short)0x02);

			IEntity target = menu.Target as IEntity;

			m_Stream.Write((target == null ? Serial.MinusOne : target.Serial));

			m_Stream.Write((byte)length);

			Point3D p;

			if (target is Mobile)
			{
				p = target.Location;
			}
			else if (target is Item)
			{
				p = ((Item)target).GetWorldLocation();
			}
			else
			{
				p = Point3D.Zero;
			}

			for (int i = 0; i < length; ++i)
			{
				ContextMenuEntry e = entries[i];

				m_Stream.Write(e.Number);
				m_Stream.Write((short)i);

				int range = e.Range;

				if (range == -1)
				{
					range = 18;
				}

				CMEFlags flags = (e.Enabled && menu.From.InRange(p, range)) ? CMEFlags.None : CMEFlags.Disabled;

				flags |= e.Flags;

				m_Stream.Write((short)flags);
			}
		}
コード例 #5
0
ファイル: Packets.cs プロジェクト: 3HMonkey/runuo-ec
        public DisplayContextMenu( ContextMenu menu )
            : base(0xBF)
        {
            // Genova: suporte ao UO:KR.
            // Is KR Client?
            bool isKRClient = menu.From.NetState.IsKRClient;
            bool isSAClient = menu.From.NetState.IsSAClient;

            ContextMenuEntry[] entries = menu.Entries;

            int length = (byte) entries.Length;

            // Genova: suporte ao UO:KR.
            if (isKRClient)
                this.EnsureCapacity(12 + (length * 10));
            else
                this.EnsureCapacity( 12 + (length * 8) );

            m_Stream.Write( (short) 0x14 );
            // Genova: suporte ao UO:KR.
            if (isKRClient)
                m_Stream.Write((short)0x02);
            else
                m_Stream.Write((short)0x01);

            IEntity target = menu.Target as IEntity;

            m_Stream.Write( (int) ( target == null ? Serial.MinusOne : target.Serial ) );

            m_Stream.Write( (byte) length );

            Point3D p;

            if ( target is Mobile )
                p = target.Location;
            else if ( target is Item )
                p = ((Item)target).GetWorldLocation();
            else
                p = Point3D.Zero;

            for ( int i = 0; i < length; ++i )
            {
                ContextMenuEntry e = entries[i];

                // RunSA SA Support.
                if (isKRClient || isSAClient)
                {
                    if (e.Number > 3000000)
                        m_Stream.Write((int)e.Number);
                    else
                        m_Stream.Write((int)(3000000 + e.Number));

                    m_Stream.Write((short)i);
                }
                else
                {
                    m_Stream.Write((int)e.Number);
                    m_Stream.Write((short)i);
                }

                int range = e.Range;

                if ( range == -1 )
                    range = 18;

                CMEFlags flags = (e.Enabled && menu.From.InRange( p, range )) ? CMEFlags.None : CMEFlags.Disabled;

                flags |= e.Flags;

                m_Stream.Write( (short) flags );
            }
        }