public void onBookEditTextButtonClick(GumpButton button, int param) { if (button != null) { var book = new XmlTextEntryBook( 0, String.Empty, String.Empty, 20, true, XmlTextEntryBookCallback, new object[] { param }); var properties = EditorState.SelectedElement.GetElementPropertiesSnapshot(); var bookText = properties[param].Text; // fill the contents of the book with the current text entry data book.FillTextEntryBook(bookText); // put the book at the location of the player so that it can be opened, but drop it below visible range book.Visible = false; book.Movable = false; book.MoveToWorld( new Point3D(EditorState.Caller.Location.X, EditorState.Caller.Location.Y, EditorState.Caller.Location.Z - 100), EditorState.Caller.Map); book.OnDoubleClick(EditorState.Caller); } EditorState.Refresh(); }
public override void OnResponse(NetState state, RelayInfo info) { if (info == null || state == null || state.Mobile == null || m_Dialog == null) { return; } int radiostate = -1; if (info.Switches.Length > 0) { radiostate = info.Switches[0]; } TextRelay tr = info.GetTextEntry(400); // displayfrom info try { DisplayFrom = int.Parse(tr.Text); } catch {} tr = info.GetTextEntry(300); // savefilename info if (tr != null) { SaveFilename = tr.Text; } if (m_Dialog != null) { tr = info.GetTextEntry(140); // proximity range if (tr != null) { try { m_Dialog.ProximityRange = int.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(141); // reset time if (tr != null) { try { m_Dialog.ResetTime = TimeSpan.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(142); // speech pace if (tr != null) { try { m_Dialog.SpeechPace = int.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(150); // trig on carried if (tr != null && (m_Dialog.TriggerOnCarried == null || m_Dialog.TriggerOnCarried.Length < 230)) { if (tr.Text != null && tr.Text.Trim().Length > 0) { m_Dialog.TriggerOnCarried = tr.Text; } else { m_Dialog.TriggerOnCarried = null; } } tr = info.GetTextEntry(151); // notrig on carried if (tr != null && (m_Dialog.NoTriggerOnCarried == null || m_Dialog.NoTriggerOnCarried.Length < 230)) { if (tr.Text != null && tr.Text.Trim().Length > 0) { m_Dialog.NoTriggerOnCarried = tr.Text; } else { m_Dialog.NoTriggerOnCarried = null; } } m_Dialog.AllowGhostTrig = info.IsSwitched(260); // allow ghost triggering } if (m_SearchList != null && Selected >= 0 && Selected + DisplayFrom >= 0 && Selected + DisplayFrom < m_SearchList.Count) { // entry information XmlDialog.SpeechEntry entry = (XmlDialog.SpeechEntry)m_SearchList[Selected + DisplayFrom]; tr = info.GetTextEntry(200); // entry number if (tr != null) { try { entry.EntryNumber = int.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(201); // entry id if (tr != null) { try { entry.ID = int.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(202); // depends on if (tr != null) { try { entry.DependsOn = tr.Text; } catch {} } tr = info.GetTextEntry(203); // prepause if (tr != null) { try { entry.PrePause = int.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(204); // pause if (tr != null) { try { entry.Pause = int.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(205); // hue if (tr != null) { try { entry.SpeechHue = int.Parse(tr.Text); } catch {} } tr = info.GetTextEntry(101); // keywords if (tr != null && (entry.Keywords == null || entry.Keywords.Length < 230)) { if (tr.Text != null && tr.Text.Trim().Length > 0) { entry.Keywords = tr.Text; } else { entry.Keywords = null; } } tr = info.GetTextEntry(100); // text if (tr != null && (entry.Text == null || entry.Text.Length < 230)) { if (tr.Text != null && tr.Text.Trim().Length > 0) { entry.Text = tr.Text; } else { entry.Text = null; } } tr = info.GetTextEntry(102); // condition if (tr != null && (entry.Condition == null || entry.Condition.Length < 230)) { if (tr.Text != null && tr.Text.Trim().Length > 0) { entry.Condition = tr.Text; } else { entry.Condition = null; } } tr = info.GetTextEntry(103); // action if (tr != null && (entry.Action == null || entry.Action.Length < 230)) { if (tr.Text != null && tr.Text.Trim().Length > 0) { entry.Action = tr.Text; } else { entry.Action = null; } } tr = info.GetTextEntry(104); // gump if (tr != null && (entry.Gump == null || entry.Gump.Length < 230)) { if (tr.Text != null && tr.Text.Trim().Length > 0) { entry.Gump = tr.Text; } else { entry.Gump = null; } } entry.LockConversation = info.IsSwitched(250); // lock conversation entry.AllowNPCTrigger = info.IsSwitched(251); // allow npc entry.IgnoreCarried = info.IsSwitched(252); // ignorecarried } switch (info.ButtonID) { case 0: // Close { m_Dialog.DeleteTextEntryBook(); return; } case 100: // toggle running status { m_Dialog.Running = !m_Dialog.Running; break; } case 155: // add new entry { if (m_SearchList != null) { // find the last entry int lastentry = 0; foreach (XmlDialog.SpeechEntry e in m_SearchList) { if (e.EntryNumber > lastentry) { lastentry = e.EntryNumber; } } lastentry += 10; XmlDialog.SpeechEntry se = new XmlDialog.SpeechEntry(); se.EntryNumber = lastentry; se.ID = lastentry; m_SearchList.Add(se); Selected = m_SearchList.Count - 1; } break; } case 156: // Delete selected entries { XmlEditDialogGump g = Refresh(state); int allcount = 0; if (m_SearchList != null) { allcount = m_SearchList.Count; } state.Mobile.SendGump(new XmlConfirmDeleteGump(state.Mobile, g, m_SearchList, m_SelectionList, DisplayFrom, SelectAll, allcount)); return; } case 159: // save to a .npc file { // Create a new gump Refresh(state); // try to save m_Dialog.DoSaveNPC(state.Mobile, SaveFilename, true); return; } case 201: // forward block { // clear the selections if (m_SelectionList != null && !SelectAll) { Array.Clear(m_SelectionList, 0, m_SelectionList.Length); } if (m_SearchList != null && DisplayFrom + MaxEntries < m_SearchList.Count) { DisplayFrom += MaxEntries; // clear any selection Selected = -1; } break; } case 202: // backward block { // clear the selections if (m_SelectionList != null && !SelectAll) { Array.Clear(m_SelectionList, 0, m_SelectionList.Length); } DisplayFrom -= MaxEntries; if (DisplayFrom < 0) { DisplayFrom = 0; } // clear any selection Selected = -1; break; } case 700: // Sort { // clear any selection Selected = -1; // clear the selections if (m_SelectionList != null && !SelectAll) { Array.Clear(m_SelectionList, 0, m_SelectionList.Length); } SortFindList(); break; } case 9998: // refresh the gump { // clear any selection Selected = -1; break; } default: { if (info.ButtonID >= 1000 && info.ButtonID < 1000 + MaxEntries) { // flag the entry selected Selected = info.ButtonID - 1000; } else if (info.ButtonID == 3998) { SelectAll = !SelectAll; // dont allow individual selection with the selectall button selected if (m_SelectionList != null) { for (int i = 0; i < MaxEntries; i++) { if (i < m_SelectionList.Length) { // only toggle the selection list entries for things that actually have entries m_SelectionList[i] = SelectAll; } else { break; } } } } else if (info.ButtonID == 3999) { // dont allow individual selection with the selectall button selected if (m_SelectionList != null && m_SearchList != null && !SelectAll) { for (int i = 0; i < MaxEntries; i++) { if (i < m_SelectionList.Length) { // only toggle the selection list entries for things that actually have entries if ((m_SearchList.Count - DisplayFrom > i)) { m_SelectionList[i] = !m_SelectionList[i]; } } else { break; } } } } else if (info.ButtonID >= 4000 && info.ButtonID < 4000 + MaxEntries) { int i = info.ButtonID - 4000; // dont allow individual selection with the selectall button selected if (m_SelectionList != null && i >= 0 && i < m_SelectionList.Length && !SelectAll) { // only toggle the selection list entries for things that actually have entries if (m_SearchList != null && (m_SearchList.Count - DisplayFrom > i)) { m_SelectionList[i] = !m_SelectionList[i]; } } } else if (info.ButtonID >= 5000 && info.ButtonID < 5100) { // text entry book buttons int textid = info.ButtonID - 5000; // entry information XmlDialog.SpeechEntry entry = null; if (m_SearchList != null && Selected >= 0 && Selected + DisplayFrom >= 0 && Selected + DisplayFrom < m_SearchList.Count) { entry = (XmlDialog.SpeechEntry)m_SearchList[Selected + DisplayFrom]; } string text = String.Empty; string title = String.Empty; switch (textid) { case 0: // text if (entry != null) { text = entry.Text; } title = "Text"; break; case 1: // keywords if (entry != null) { text = entry.Keywords; } title = "Keywords"; break; case 2: // condition if (entry != null) { text = entry.Condition; } title = "Condition"; break; case 3: // action if (entry != null) { text = entry.Action; } title = "Action"; break; case 4: // gump if (entry != null) { text = entry.Gump; } title = "Gump"; break; case 5: // trigoncarried text = m_Dialog.TriggerOnCarried; title = "TrigOnCarried"; break; case 6: // notrigoncarried text = m_Dialog.NoTriggerOnCarried; title = "NoTrigOnCarried"; break; } object [] args = new object[6]; args[0] = m_Dialog; args[1] = entry; args[2] = textid; args[3] = Selected; args[4] = DisplayFrom; args[5] = SaveFilename; XmlTextEntryBook book = new XmlTextEntryBook(0, String.Empty, m_Dialog.Name, 20, true, new XmlTextEntryBookCallback(ProcessXmlEditBookEntry), args); if (m_Dialog.m_TextEntryBook == null) { m_Dialog.m_TextEntryBook = new ArrayList(); } m_Dialog.m_TextEntryBook.Add(book); book.Title = title; book.Author = Name; // fill the contents of the book with the current text entry data book.FillTextEntryBook(text); // put the book at the location of the player so that it can be opened, but drop it below visible range book.Visible = false; book.Movable = false; book.MoveToWorld(new Point3D(state.Mobile.Location.X, state.Mobile.Location.Y, state.Mobile.Location.Z - 100), state.Mobile.Map); // Create a new gump Refresh(state); // and open it book.OnDoubleClick(state.Mobile); return; } break; } } // Create a new gump Refresh(state); }