Example #1
0
 public XmlPropertiesGump(Mobile mobile, object o, Stack <PropertiesGump.StackEntry> stack, PropertiesGump.StackEntry parent) : base(GumpOffsetX, GumpOffsetY)
Example #2
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (!BaseCommand.IsAccessible(from, m_Object))
            {
                from.SendMessage("You may no longer access their properties.");
                return;
            }

            switch (info.ButtonID)
            {
            case 0:     // Closed
            {
                if (m_Stack != null && m_Stack.Count > 0)
                {
#if (NEWTIMERS)
                    PropertiesGump.StackEntry entry = m_Stack.Pop();

                    from.SendGump(new XmlPropertiesGump(from, entry.m_Object, m_Stack, null));
#else
                    object obj = m_Stack.Pop();

                    from.SendGump(new XmlPropertiesGump(from, obj, m_Stack, null));
#endif
                }

                break;
            }

            case 1:     // Previous
            {
                if (m_Page > 0)
                {
                    from.SendGump(new XmlPropertiesGump(from, m_Object, m_Stack, m_List, m_Page - 1));
                }

                break;
            }

            case 2:     // Next
            {
                if ((m_Page + 1) * EntryCount < m_List.Count)
                {
                    from.SendGump(new XmlPropertiesGump(from, m_Object, m_Stack, m_List, m_Page + 1));
                }

                break;
            }

            default:
            {
                int index = (m_Page * EntryCount) + (info.ButtonID - 3);

                if (index >= 0 && index < m_List.Count)
                {
                    PropertyInfo prop = m_List[index] as PropertyInfo;

                    if (prop == null)
                    {
                        return;
                    }

                    CPA attr = GetCPA(prop);

                    if (!prop.CanWrite || attr == null || from.AccessLevel < attr.WriteLevel)
                    {
                        return;
                    }

                    Type type = prop.PropertyType;

                    if (IsType(type, typeofMobile) || IsType(type, typeofItem))
                    {
                        from.SendGump(new XmlSetObjectGump(prop, from, m_Object, m_Stack, type, m_Page, m_List));
                    }
                    else if (IsType(type, typeofType))
                    {
                        from.Target = new XmlSetObjectTarget(prop, from, m_Object, m_Stack, type, m_Page, m_List);
                    }
                    else if (IsType(type, typeofPoint3D))
                    {
                        from.SendGump(new XmlSetPoint3DGump(prop, from, m_Object, m_Stack, m_Page, m_List));
                    }
                    else if (IsType(type, typeofPoint2D))
                    {
                        from.SendGump(new XmlSetPoint2DGump(prop, from, m_Object, m_Stack, m_Page, m_List));
                    }
                    else if (IsType(type, typeofTimeSpan))
                    {
                        from.SendGump(new XmlSetTimeSpanGump(prop, from, m_Object, m_Stack, m_Page, m_List));
                    }
                    else if (IsCustomEnum(type))
                    {
                        from.SendGump(new XmlSetCustomEnumGump(prop, from, m_Object, m_Stack, m_Page, m_List, GetCustomEnumNames(type)));
                    }
                    else if (IsType(type, typeofEnum))
                    {
                        from.SendGump(new XmlSetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, Enum.GetNames(type), GetObjects(Enum.GetValues(type))));
                    }
                    else if (IsType(type, typeofBool))
                    {
                        from.SendGump(new XmlSetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, m_BoolNames, m_BoolValues));
                    }
                    else if (IsType(type, typeofString) || IsType(type, typeofReal) || IsType(type, typeofNumeric))
                    {
                        from.SendGump(new XmlSetGump(prop, from, m_Object, m_Stack, m_Page, m_List));
                    }
                    else if (IsType(type, typeofPoison))
                    {
                        from.SendGump(new XmlSetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, m_PoisonValues));
                    }
                    else if (IsType(type, typeofMap))
                    {
                        from.SendGump(new XmlSetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, Map.GetMapNames(), Map.GetMapValues()));
                    }
                    else if (IsType(type, typeofSkills) && m_Object is Mobile mobile)
                    {
                        from.SendGump(new XmlPropertiesGump(from, mobile, m_Stack, m_List, m_Page));
                        from.SendGump(new SkillsGump(from, mobile));
                    }
                    else if (HasAttribute(type, typeofPropertyObject, true))
                    {
#if (NEWTIMERS)
                        object obj = prop.GetValue(m_Object, null);

                        from.SendGump(obj != null
                                    ? new XmlPropertiesGump(from, obj, m_Stack,
                                                            new PropertiesGump.StackEntry(m_Object, prop))
                                    : new XmlPropertiesGump(from, m_Object, m_Stack, m_List, m_Page));
#else
                        from.SendGump(new XmlPropertiesGump(from, prop.GetValue(m_Object, null), m_Stack, m_Object));
#endif
                    }
                }

                break;
            }
            }
        }