Пример #1
0
        private void Initialize(int page)
        {
            m_Page = page;

            int count = m_List.Count - (page * EntryCount);

            if (count < 0)
            {
                count = 0;
            }
            else if (count > EntryCount)
            {
                count = EntryCount;
            }

            int lastIndex = (page * EntryCount) + count - 1;

            if (lastIndex >= 0 && lastIndex < m_List.Count && m_List[lastIndex] == null)
            {
                --count;
            }

            int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (ColumnEntryCount + 1));

            AddPage(0);

            AddBackground(0, 0, TotalWidth * 3 + BorderSize * 2, BorderSize + totalHeight + BorderSize, BackGumpID);
            AddImageTiled(BorderSize, BorderSize + EntryHeight, (TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0)) * 3, totalHeight - EntryHeight, OffsetGumpID);

            int x = BorderSize + OffsetSize;
            int y = BorderSize /*+ OffsetSize*/;

            int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);

            if (m_Object is Item)
            {
                AddLabelCropped(x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, ((Item)m_Object).Name);
            }
            int propcount = 0;

            for (int i = 0, index = page * EntryCount; i < count && index < m_List.Count; ++i, ++index)
            {
                // do the multi column display
                int column = propcount / ColumnEntryCount;
                if (propcount % ColumnEntryCount == 0)
                {
                    y = BorderSize;
                }
                x  = BorderSize + OffsetSize + column * (ValueWidth + NameWidth + OffsetSize * 2 + SetOffsetX + SetWidth);
                y += EntryHeight + OffsetSize;



                object o = m_List[index];

                if (o == null)
                {
                    AddImageTiled(x - OffsetSize, y, TotalWidth, EntryHeight, BackGumpID + 4);
                    propcount++;
                }
                else

                /*if ( o is Type )
                 *              {
                 *                      Type type = (Type)o;
                 *
                 *                      AddImageTiled( x, y, TypeWidth, EntryHeight, EntryGumpID );
                 *                      AddLabelCropped( x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, type.Name );
                 *                      x += TypeWidth + OffsetSize;
                 *
                 *                      if ( SetGumpID != 0 )
                 *                              AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
                 *              }
                 *              else
                 */
                if (o is PropertyInfo)
                {
                    propcount++;

                    PropertyInfo prop = (PropertyInfo)o;

                    // look for the default value of the equivalent property in the XmlSpawnerDefaults.DefaultEntry class

                    int       huemodifier = TextHue;
                    FieldInfo finfo       = null;
                    Server.Mobiles.XmlSpawnerDefaults.DefaultEntry de = new Server.Mobiles.XmlSpawnerDefaults.DefaultEntry();
                    Type ftype = de.GetType();
                    if (ftype != null)
                    {
                        finfo = ftype.GetField(prop.Name);
                    }
                    // is there an equivalent default field?
                    if (finfo != null)
                    {
                        // see if the value is different from the default
                        if (ValueToString(finfo.GetValue(de)) != ValueToString(prop))
                        {
                            huemodifier = 68;
                        }
                    }

                    AddImageTiled(x, y, NameWidth, EntryHeight, EntryGumpID);
                    AddLabelCropped(x + TextOffsetX, y, NameWidth - TextOffsetX, EntryHeight, huemodifier, prop.Name);
                    x += NameWidth + OffsetSize;
                    AddImageTiled(x, y, ValueWidth, EntryHeight, EntryGumpID);
                    AddLabelCropped(x + TextOffsetX, y, ValueWidth - TextOffsetX, EntryHeight, huemodifier, ValueToString(prop));
                    x += ValueWidth + OffsetSize;

                    if (SetGumpID != 0)
                    {
                        AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                    }

                    CPA cpa = GetCPA(prop);

                    if (prop.CanWrite && cpa != null && m_Mobile.AccessLevel >= cpa.WriteLevel)
                    {
                        AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, 0);
                    }
                }
            }
        }
Пример #2
0
		private void Initialize( int page )
		{
			m_Page = page;

			int count = m_List.Count - (page * EntryCount);

			if ( count < 0 )
				count = 0;
			else if ( count > EntryCount )
				count = EntryCount;

			int lastIndex = (page * EntryCount) + count - 1;

			if ( lastIndex >= 0 && lastIndex < m_List.Count && m_List[lastIndex] == null )
				--count;

			int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (ColumnEntryCount + 1));

			AddPage( 0 );

			AddBackground( 0, 0, TotalWidth*3 + BorderSize*2, BorderSize + totalHeight + BorderSize, BackGumpID );
			AddImageTiled( BorderSize, BorderSize + EntryHeight, (TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0))*3, totalHeight-EntryHeight, OffsetGumpID );

			int x = BorderSize + OffsetSize;
			int y = BorderSize /*+ OffsetSize*/;

			int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);

			if(m_Object is Item)
                AddLabelCropped( x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, ((Item)m_Object).Name );
            int propcount = 0;
			for ( int i = 0, index = page * EntryCount; i < count && index < m_List.Count; ++i, ++index )
			{
			// do the multi column display
				int column = propcount/ColumnEntryCount;
                if(propcount%ColumnEntryCount == 0)
                    y = BorderSize;
				x = BorderSize + OffsetSize + column*(ValueWidth + NameWidth +OffsetSize*2 + SetOffsetX + SetWidth);
				y += EntryHeight + OffsetSize;



				object o = m_List[index];

				if ( o == null )
				{
					AddImageTiled( x - OffsetSize, y, TotalWidth, EntryHeight, BackGumpID + 4 );
					propcount++;
				}
				else
                /*if ( o is Type )
				{
					Type type = (Type)o;

					AddImageTiled( x, y, TypeWidth, EntryHeight, EntryGumpID );
					AddLabelCropped( x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, type.Name );
					x += TypeWidth + OffsetSize;

					if ( SetGumpID != 0 )
						AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
				}
				else
                */
                if ( o is PropertyInfo )
				{
				    propcount++;

					PropertyInfo prop = (PropertyInfo)o;

					// look for the default value of the equivalent property in the XmlSpawnerDefaults.DefaultEntry class

					int huemodifier = TextHue;
					FieldInfo finfo = null;
					Server.Mobiles.XmlSpawnerDefaults.DefaultEntry de = new Server.Mobiles.XmlSpawnerDefaults.DefaultEntry();
					Type ftype = de.GetType();
					if(ftype != null)
					   finfo = ftype.GetField(prop.Name);
					// is there an equivalent default field?
					if(finfo != null){
					    // see if the value is different from the default
                        if(ValueToString(finfo.GetValue(de)) != ValueToString(prop))
    					{
    					   huemodifier = 68;
    					}
					}

					AddImageTiled( x, y, NameWidth, EntryHeight, EntryGumpID );
					AddLabelCropped( x + TextOffsetX, y, NameWidth - TextOffsetX, EntryHeight, huemodifier, prop.Name );
					x += NameWidth + OffsetSize;
					AddImageTiled( x, y, ValueWidth, EntryHeight, EntryGumpID );
					AddLabelCropped( x + TextOffsetX, y, ValueWidth - TextOffsetX, EntryHeight, huemodifier, ValueToString( prop ) );
					x += ValueWidth + OffsetSize;

					if ( SetGumpID != 0 )
						AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );

					CPA cpa = GetCPA( prop );

					if ( prop.CanWrite && cpa != null && m_Mobile.AccessLevel >= cpa.WriteLevel )
						AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, 0 );
				}
			}
		}