public override void OnClick(Mobile from, int page, int index, Gump gump) { if (m_Type == null) { from.SendMessage("That is an invalid type name."); } else { if (gump is XmlAddGump) { XmlAddGump xmladdgump = (XmlAddGump)gump; //Commands.Handle( from, String.Format( "{0}Add {1}", Commands.CommandPrefix, m_Type.Name ) ); if (xmladdgump != null && xmladdgump.defs != null && xmladdgump.defs.NameList != null && index >= 0 && index < xmladdgump.defs.NameList.Length) { xmladdgump.defs.NameList[index] = m_Type.Name; XmlAddGump.Refresh(from, true); } from.SendGump(new XmlCategorizedAddGump(from, m_Parent, page, index, xmladdgump)); } else if (gump is XmlSpawnerGump) { XmlSpawner m_Spawner = ((XmlSpawnerGump)gump).m_Spawner; if (m_Spawner != null) { XmlSpawnerGump xg = m_Spawner.SpawnerGump; if (xg != null) { xg.Rentry = new XmlSpawnerGump.ReplacementEntry { Typename = m_Type.Name, Index = index, Color = 0x1436 }; Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(XmlSpawnerGump.Refresh_Callback), new object[] { from }); //from.CloseGump(typeof(XmlSpawnerGump)); //from.SendGump( new XmlSpawnerGump(xg.m_Spawner, xg.X, xg.Y, xg.m_ShowGump, xg.xoffset, xg.page, xg.Rentry) ); } } } } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { Mobile from = sender.Mobile; switch (info.ButtonID) { case 1: // Search { TextRelay te = info.GetTextEntry(0); string match = (te == null ? "" : te.Text.Trim()); if (match.Length < 3) { from.SendMessage("Invalid search string."); from.SendGump(new XmlPartialCategorizedAddGump(from, match, m_Page, m_SearchResults, false, m_EntryIndex, m_Gump)); } else { from.SendGump(new XmlPartialCategorizedAddGump(from, match, 0, Match(match), true, m_EntryIndex, m_Gump)); } break; } case 2: // Previous page { if (m_Page > 0) { from.SendGump(new XmlPartialCategorizedAddGump(from, m_SearchString, m_Page - 1, m_SearchResults, true, m_EntryIndex, m_Gump)); } break; } case 3: // Next page { if ((m_Page + 1) * 10 < m_SearchResults.Count) { from.SendGump(new XmlPartialCategorizedAddGump(from, m_SearchString, m_Page + 1, m_SearchResults, true, m_EntryIndex, m_Gump)); } break; } default: { int index = info.ButtonID - 4; if (index >= 0 && index < m_SearchResults.Count) { Type type = ((SearchEntry)m_SearchResults[index]).EntryType; if (m_Gump is XmlAddGump && type != null) { XmlAddGump m_XmlAddGump = (XmlAddGump)m_Gump; if (type != null && m_XmlAddGump.defs != null && m_XmlAddGump.defs.NameList != null && m_EntryIndex >= 0 && m_EntryIndex < m_XmlAddGump.defs.NameList.Length) { m_XmlAddGump.defs.NameList[m_EntryIndex] = type.Name; XmlAddGump.Refresh(from, true); } } else if (m_Spawner != null && type != null) { XmlSpawnerGump xg = m_Spawner.SpawnerGump; if (xg != null) { xg.Rentry = new XmlSpawnerGump.ReplacementEntry(); xg.Rentry.Typename = type.Name; xg.Rentry.Index = m_EntryIndex; xg.Rentry.Color = 0x1436; Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(XmlSpawnerGump.Refresh_Callback), new object[] { from }); //from.CloseGump(typeof(XmlSpawnerGump)); //from.SendGump( new XmlSpawnerGump(xg.m_Spawner, xg.X, xg.Y, xg.m_ShowGump, xg.xoffset, xg.page, xg.Rentry) ); } } } break; } } }