public override void OnResponse(NetState sender, RelayInfo info) { int index = info.ButtonID - 1; if (index >= 0 && index < m_Values.Length) { try { object toSet = m_Values[index]; string result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, toSet, true); m_Mobile.SendMessage(result); if (result == "Property has been set.") { PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); }
protected override void OnTarget(Mobile from, object targeted) { try { if (m_Type == typeof(Type)) { targeted = targeted.GetType(); } else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) && targeted is AddonComponent) { targeted = ((AddonComponent)targeted).Addon; } if (m_Type.IsAssignableFrom(targeted.GetType())) { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString()); m_Property.SetValue(m_Object, targeted, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } else { m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name); } } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } }
public override void OnResponse(Mobile from, string text) { object toSet; bool shouldSet; try { int serial = Utility.ToInt32(text); toSet = World.FindEntity(serial); if (toSet == null) { shouldSet = false; m_Mobile.SendMessage("No object with that serial was found."); } else if (!m_Type.IsAssignableFrom(toSet.GetType())) { toSet = null; shouldSet = false; m_Mobile.SendMessage("The object with that serial could not be assigned to a property of type : {0}", m_Type.Name); } else { shouldSet = true; } } catch { toSet = null; shouldSet = false; m_Mobile.SendMessage("Bad format"); } if (shouldSet) { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString()); m_Property.SetValue(m_Object, toSet, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List)); }
public override void OnResponse(int hue) { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, hue.ToString()); m_Property.SetValue(m_Object, hue, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); }
protected override void OnTarget(Mobile from, object targeted) { IPoint3D p = targeted as IPoint3D; if (p != null) { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point3D(p).ToString()); m_Property.SetValue(m_Object, new Point3D(p), null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } }
public override void OnResponse(NetState sender, RelayInfo relayInfo) { int index = relayInfo.ButtonID - 1; if (index >= 0 && index < m_Names.Length) { try { MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new Type[] { typeof(string) }); string result = ""; if (info != null) { result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, info.Invoke(null, new object[] { m_Names[index] }), true); } else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum))) { result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, Enum.Parse(m_Property.PropertyType, m_Names[index], false), true); } m_Mobile.SendMessage(result); if (result == "Property has been set.") { PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); }
public SetObjectGump(PropertyInfo prop, Mobile mobile, object o, Stack <StackEntry> stack, Type type, int page, ArrayList list) : base(GumpOffsetX, GumpOffsetY) { m_Property = prop; m_Mobile = mobile; m_Object = o; m_Stack = stack; m_Type = type; m_Page = page; m_List = list; string initialText = PropertiesGump.ValueToString(o, prop); AddPage(0); AddBackground(0, 0, BackWidth, BackHeight, BackGumpID); AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID); int x = BorderSize + OffsetSize; int y = BorderSize + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name); x += EntryWidth + OffsetSize; if (SetGumpID != 0) { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); } x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, initialText); x += EntryWidth + OffsetSize; if (SetGumpID != 0) { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Change by Serial"); x += EntryWidth + OffsetSize; if (SetGumpID != 0) { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Nullify"); x += EntryWidth + OffsetSize; if (SetGumpID != 0) { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "View Properties"); x += EntryWidth + OffsetSize; if (SetGumpID != 0) { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0); }
public override void OnResponse(NetState sender, RelayInfo info) { object toSet; bool shouldSet, shouldSend = true; object viewProps = null; switch (info.ButtonID) { case 0: // closed { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); toSet = null; shouldSet = false; shouldSend = false; break; } case 1: // Change by Target { m_Mobile.Target = new SetObjectTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List); toSet = null; shouldSet = false; shouldSend = false; break; } case 2: // Change by Serial { toSet = null; shouldSet = false; shouldSend = false; m_Mobile.SendMessage("Enter the serial you wish to find:"); m_Mobile.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List); break; } case 3: // Nullify { toSet = null; shouldSet = true; break; } case 4: // View Properties { toSet = null; shouldSet = false; object obj = m_Property.GetValue(m_Object, null); if (obj == null) { m_Mobile.SendMessage("The property is null and so you cannot view its properties."); } else if (!BaseCommand.IsAccessible(m_Mobile, obj)) { m_Mobile.SendMessage("You may not view their properties."); } else { viewProps = obj; } break; } default: { toSet = null; shouldSet = false; break; } } if (shouldSet) { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString()); m_Property.SetValue(m_Object, toSet, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } if (shouldSend) { m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List)); } if (viewProps != null) { m_Mobile.SendGump(new PropertiesGump(m_Mobile, viewProps)); } }
public override void OnResponse(NetState sender, RelayInfo info) { Point3D toSet; bool shouldSet, shouldSend; switch (info.ButtonID) { case 1: // Current location { toSet = m_Mobile.Location; shouldSet = true; shouldSend = true; break; } case 2: // Pick location { m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List); toSet = Point3D.Zero; shouldSet = false; shouldSend = false; break; } case 3: // Use values { TextRelay x = info.GetTextEntry(0); TextRelay y = info.GetTextEntry(1); TextRelay z = info.GetTextEntry(2); toSet = new Point3D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text), z == null ? 0 : Utility.ToInt32(z.Text)); shouldSet = true; shouldSend = true; break; } default: { toSet = Point3D.Zero; shouldSet = false; shouldSend = true; break; } } if (shouldSet) { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString()); m_Property.SetValue(m_Object, toSet, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } if (shouldSend) { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } }
public override void OnResponse(NetState sender, RelayInfo info) { object toSet; bool shouldSet, shouldSend = true; switch (info.ButtonID) { case 1: { TextRelay text = info.GetTextEntry(0); if (text != null) { try { toSet = PropertiesGump.GetObjectFromString(m_Property.PropertyType, text.Text); shouldSet = true; } catch { toSet = null; shouldSet = false; m_Mobile.SendMessage("Bad format"); } } else { toSet = null; shouldSet = false; } break; } case 2: // Null { toSet = null; shouldSet = true; break; } case 3: // Hue Picker { toSet = null; shouldSet = false; shouldSend = false; m_Mobile.SendHuePicker(new InternalPicker(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List)); break; } case 4: // Body Picker { toSet = null; shouldSet = false; shouldSend = false; m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List)); break; } default: { toSet = null; shouldSet = false; break; } } if (shouldSet) { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString()); m_Property.SetValue(m_Object, toSet, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } if (shouldSend) { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } }
public override void OnResponse(NetState sender, RelayInfo info) { TimeSpan toSet; bool shouldSet, shouldSend; TextRelay h = info.GetTextEntry(0); TextRelay m = info.GetTextEntry(1); TextRelay s = info.GetTextEntry(2); switch (info.ButtonID) { case 1: // Zero { toSet = TimeSpan.Zero; shouldSet = true; shouldSend = true; break; } case 2: // From H:M:S { bool successfulParse = false; if (h != null && m != null && s != null) { successfulParse = TimeSpan.TryParse(h.Text + ":" + m.Text + ":" + s.Text, out toSet); } else { toSet = TimeSpan.Zero; } shouldSet = shouldSend = successfulParse; break; } case 3: // From H { if (h != null) { try { toSet = TimeSpan.FromHours(Utility.ToDouble(h.Text)); shouldSet = true; shouldSend = true; break; } catch { } } toSet = TimeSpan.Zero; shouldSet = false; shouldSend = false; break; } case 4: // From M { if (m != null) { try { toSet = TimeSpan.FromMinutes(Utility.ToDouble(m.Text)); shouldSet = true; shouldSend = true; break; } catch { } } toSet = TimeSpan.Zero; shouldSet = false; shouldSend = false; break; } case 5: // From S { if (s != null) { try { toSet = TimeSpan.FromSeconds(Utility.ToDouble(s.Text)); shouldSet = true; shouldSend = true; break; } catch { } } toSet = TimeSpan.Zero; shouldSet = false; shouldSend = false; break; } default: { toSet = TimeSpan.Zero; shouldSet = false; shouldSend = true; break; } } if (shouldSet) { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString()); m_Property.SetValue(m_Object, toSet, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } } if (shouldSend) { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } }
public override void OnResponse(NetState sender, RelayInfo info) { int index = info.ButtonID - 1; if (index == -1) { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } else if (index >= 0 && index < 4) { if (m_Monster == null) { LoadLists(); } ModelBodyType type; ArrayList list; switch (index) { default: case 0: type = ModelBodyType.Monsters; list = m_Monster; break; case 1: type = ModelBodyType.Animals; list = m_Animal; break; case 2: type = ModelBodyType.Sea; list = m_Sea; break; case 3: type = ModelBodyType.Human; list = m_Human; break; } m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, 0, list, type)); } else if (m_OurList != null) { index -= 4; if (index == 0 && m_OurPage > 0) { m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage - 1, m_OurList, m_OurType)); } else if (index == 1 && ((m_OurPage + 1) * 12) < m_OurList.Count) { m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage + 1, m_OurList, m_OurType)); } else { index -= 2; if (index >= 0 && index < m_OurList.Count) { try { InternalEntry entry = (InternalEntry)m_OurList[index]; CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, entry.Body.ToString()); m_Property.SetValue(m_Object, entry.Body, null); PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage, m_OurList, m_OurType)); } } } }