public static void OnValueChanged(object obj, PropertyInfo prop, Stack <StackEntry> stack) { if (stack == null || stack.Count == 0) { return; } if (!prop.PropertyType.IsValueType) { return; } StackEntry peek = stack.Peek(); if (peek.m_Property.CanWrite) { peek.m_Property.SetValue(peek.m_Object, obj, null); } }
public PropertiesGump(Mobile mobile, object o, Stack <StackEntry> stack, StackEntry parent) : base(GumpOffsetX, GumpOffsetY) { m_Mobile = mobile; m_Object = o; m_Type = o.GetType(); m_Stack = stack; m_List = BuildList(); if (parent != null) { if (m_Stack == null) { m_Stack = new Stack <StackEntry>(); } m_Stack.Push(parent); } Initialize(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) { StackEntry entry = m_Stack.Pop(); from.SendGump(new PropertiesGump(from, entry.m_Object, m_Stack, null)); } break; } case 1: // Previous { if (m_Page > 0) { from.SendGump(new PropertiesGump(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 PropertiesGump(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 || attr.ReadOnly) { return; } Type type = prop.PropertyType; if (IsType(type, typeofMobile) || IsType(type, typeofItem)) { from.SendGump(new SetObjectGump(prop, from, m_Object, m_Stack, type, m_Page, m_List)); } else if (IsType(type, typeofType)) { from.Target = new SetObjectTarget(prop, from, m_Object, m_Stack, type, m_Page, m_List); } else if (IsType(type, typeofPoint3D)) { from.SendGump(new SetPoint3DGump(prop, from, m_Object, m_Stack, m_Page, m_List)); } else if (IsType(type, typeofPoint2D)) { from.SendGump(new SetPoint2DGump(prop, from, m_Object, m_Stack, m_Page, m_List)); } else if (IsType(type, typeofTimeSpan)) { from.SendGump(new SetTimeSpanGump(prop, from, m_Object, m_Stack, m_Page, m_List)); } else if (IsCustomEnum(type)) { from.SendGump(new SetCustomEnumGump(prop, from, m_Object, m_Stack, m_Page, m_List, GetCustomEnumNames(type))); } else if (IsType(type, typeofEnum)) { from.SendGump(new SetListOptionGump(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 SetListOptionGump(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) || IsType(type, typeofText)) { from.SendGump(new SetGump(prop, from, m_Object, m_Stack, m_Page, m_List)); } else if (IsType(type, typeofPoison)) { from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, m_PoisonValues)); } else if (IsType(type, typeofMap)) { from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, Map.GetMapNames(), Map.GetMapValues())); } else if (IsType(type, typeofSkills) && m_Object is Mobile) { from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page)); from.SendGump(new SkillsGump(from, (Mobile)m_Object)); } else if (HasAttribute(type, typeofPropertyObject, true)) { object obj = prop.GetValue(m_Object, null); if (obj != null) { from.SendGump(new PropertiesGump(from, obj, m_Stack, new StackEntry(m_Object, prop))); } else { from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page)); } } } break; } } }