Esempio n. 1
0
		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 static void ContentChange(NetState state, PacketReader pvSrc)
        {
            // need to deal with actual books
            string entryText = String.Empty;
            Mobile from      = state.Mobile;

            int serial = pvSrc.ReadInt32();

            BaseEntryBook book = World.FindItem(serial) as BaseEntryBook;

            if (book == null)
            {
                // try it as a basebook
                BaseBook basebook = World.FindItem(serial) as BaseBook;
                if (basebook == null)
                {
                    // didnt find that either
                    return;
                }
                else
                {
                    // do the base book content change
                    BaseContentChange(basebook, state, pvSrc);
                    return;
                }
            }
            // get the number of available pages in the book
            int pageCount = pvSrc.ReadUInt16();

            if (pageCount > book.PagesCount)
            {
                return;
            }

            for (int i = 0; i < pageCount; ++i)
            {
                // get the current page number being read
                int index = pvSrc.ReadUInt16();

                if (index >= 1 && index <= book.PagesCount)
                {
                    --index;

                    int lineCount = pvSrc.ReadUInt16();

                    if (lineCount <= 8)
                    {
                        string[] lines = new string[lineCount];

                        for (int j = 0; j < lineCount; ++j)
                        {
                            if ((lines[j] = pvSrc.ReadUTF8StringSafe()).Length >= 80)
                            {
                                return;
                            }
                        }

                        book.Pages[index].Lines = lines;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            // add the book lines to the entry string
            for (int i = 0; i < book.PagesCount; ++i)
            {
                for (int j = 0; j < book.Pages[i].Lines.Length; j++)
                {
                    sb.Append(book.Pages[i].Lines[j]);
                }
            }
            // send the book text off to be processed by invoking the callback if it is a textentry book
            XmlTextEntryBook tebook = book as XmlTextEntryBook;

            if (tebook != null && tebook.m_bookcallback != null)
            {
                tebook.m_bookcallback(state.Mobile, tebook.m_args, sb.ToString());
            }
        }
Esempio n. 3
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (m_Spawner == null || m_Spawner.Deleted || state == null || info == null)
            {
                if (m_Spawner != null) m_Spawner.SpawnerGump = null;
                return;
            }

            // restrict access to the original creator or someone of higher access level
            //if (m_Spawner.FirstModifiedBy != null && m_Spawner.FirstModifiedBy != state.Mobile && state.Mobile.AccessLevel <= m_Spawner.FirstModifiedBy.AccessLevel)
            //return;


            // Get the current name
            TextRelay tr = info.GetTextEntry(999);
            if (tr != null)
            {
                m_Spawner.Name = tr.Text;
            }

            // update typenames of the spawn objects based upon the current text entry strings
            UpdateTypeNames(state.Mobile, info);

            // Update the creature list
            m_Spawner.SpawnObjects = CreateArray(info, state.Mobile);

            if (m_Spawner.SpawnObjects == null)
            {
                m_Spawner.SpawnerGump = null;
                return;
            }

            AllowGumpUpdate = true;

            for (int i = 0; i < m_Spawner.SpawnObjects.Length; i++)
            {
                if (page != (int)(i / MaxEntriesPerPage)) continue;

                // check the max count entry
                TextRelay temcnt = info.GetTextEntry(500 + i);
                if (temcnt != null)
                {
                    int maxval = 0;
                    try { maxval = Convert.ToInt32(temcnt.Text, 10); }
                    catch { }
                    if (maxval < 0) maxval = 0;

                    m_Spawner.SpawnObjects[i].MaxCount = maxval;
                }

                if (m_ShowGump > 0)
                {
                    // check the subgroup entry
                    TextRelay tegrp = info.GetTextEntry(600 + i);
                    if (tegrp != null)
                    {
                        int grpval = 0;
                        try { grpval = Convert.ToInt32(tegrp.Text, 10); }
                        catch { }
                        if (grpval < 0) grpval = 0;

                        m_Spawner.SpawnObjects[i].SubGroup = grpval;
                    }
                }

                if (m_ShowGump > 1)
                {
                    // note, while these values can be entered in any spawn entry, they will only be assigned to the subgroup leader
                    int subgroupindex = m_Spawner.GetCurrentSequentialSpawnIndex(m_Spawner.SpawnObjects[i].SubGroup);
                    TextRelay tegrp;

                    if (subgroupindex >= 0 && subgroupindex < m_Spawner.SpawnObjects.Length)
                    {
                        // check the reset time entry
                        tegrp = info.GetTextEntry(1000 + i);
                        if (tegrp != null && tegrp.Text != null && tegrp.Text.Length > 0)
                        {
                            double grpval = 0;
                            try { grpval = Convert.ToDouble(tegrp.Text); }
                            catch { }
                            if (grpval < 0) grpval = 0;

                            m_Spawner.SpawnObjects[i].SequentialResetTime = 0;

                            m_Spawner.SpawnObjects[subgroupindex].SequentialResetTime = grpval;
                        }
                        // check the reset to entry
                        tegrp = info.GetTextEntry(1100 + i);
                        if (tegrp != null && tegrp.Text != null && tegrp.Text.Length > 0)
                        {
                            int grpval = 0;
                            try { grpval = Convert.ToInt32(tegrp.Text, 10); }
                            catch { }
                            if (grpval < 0) grpval = 0;

                            m_Spawner.SpawnObjects[subgroupindex].SequentialResetTo = grpval;
                        }
                        // check the kills entry
                        tegrp = info.GetTextEntry(1200 + i);
                        if (tegrp != null && tegrp.Text != null && tegrp.Text.Length > 0)
                        {
                            int grpval = 0;
                            try { grpval = Convert.ToInt32(tegrp.Text, 10); }
                            catch { }
                            if (grpval < 0) grpval = 0;

                            m_Spawner.SpawnObjects[subgroupindex].KillsNeeded = grpval;
                        }

                    }

                    // check the mindelay
                    tegrp = info.GetTextEntry(1300 + i);
                    if (tegrp != null)
                    {
                        if (tegrp.Text != null && tegrp.Text.Length > 0)
                        {
                            double grpval = -1;
                            try { grpval = Convert.ToDouble(tegrp.Text); }
                            catch { }
                            if (grpval < 0) grpval = -1;

                            // if this value has changed, then update the next spawn time
                            if (grpval != m_Spawner.SpawnObjects[i].MinDelay)
                            {
                                m_Spawner.SpawnObjects[i].MinDelay = grpval;
                                m_Spawner.RefreshNextSpawnTime(m_Spawner.SpawnObjects[i]);
                            }
                        }
                        else
                        {
                            m_Spawner.SpawnObjects[i].MinDelay = -1;
                            m_Spawner.SpawnObjects[i].MaxDelay = -1;
                            m_Spawner.RefreshNextSpawnTime(m_Spawner.SpawnObjects[i]);
                        }
                    }

                    // check the maxdelay
                    tegrp = info.GetTextEntry(1400 + i);
                    if (tegrp != null)
                    {
                        if (tegrp.Text != null && tegrp.Text.Length > 0)
                        {
                            double grpval = -1;
                            try { grpval = Convert.ToDouble(tegrp.Text); }
                            catch { }
                            if (grpval < 0) grpval = -1;

                            // if this value has changed, then update the next spawn time
                            if (grpval != m_Spawner.SpawnObjects[i].MaxDelay)
                            {
                                m_Spawner.SpawnObjects[i].MaxDelay = grpval;
                                m_Spawner.RefreshNextSpawnTime(m_Spawner.SpawnObjects[i]);
                            }
                        }
                        else
                        {
                            m_Spawner.SpawnObjects[i].MinDelay = -1;
                            m_Spawner.SpawnObjects[i].MaxDelay = -1;
                            m_Spawner.RefreshNextSpawnTime(m_Spawner.SpawnObjects[i]);
                        }
                    }

                    // check the spawns per tick
                    tegrp = info.GetTextEntry(1500 + i);
                    if (tegrp != null)
                    {
                        if (tegrp.Text != null && tegrp.Text.Length > 0)
                        {
                            int grpval = 1;
                            try { grpval = int.Parse(tegrp.Text); }
                            catch { }
                            if (grpval < 0) grpval = 1;

                            // if this value has changed, then update the next spawn time
                            if (grpval != m_Spawner.SpawnObjects[i].SpawnsPerTick)
                            {
                                m_Spawner.SpawnObjects[i].SpawnsPerTick = grpval;
                            }
                        }
                        else
                        {
                            m_Spawner.SpawnObjects[i].SpawnsPerTick = 1;
                        }
                    }

                    // check the packrange
                    tegrp = info.GetTextEntry(1600 + i);
                    if (tegrp != null)
                    {
                        if (tegrp.Text != null && tegrp.Text.Length > 0)
                        {
                            int grpval = 1;
                            try { grpval = int.Parse(tegrp.Text); }
                            catch { }
                            if (grpval < 0) grpval = 1;

                            // if this value has changed, then update 
                            if (grpval != m_Spawner.SpawnObjects[i].PackRange)
                            {
                                m_Spawner.SpawnObjects[i].PackRange = grpval;
                            }
                        }
                        else
                        {
                            m_Spawner.SpawnObjects[i].PackRange = -1;
                        }
                    }
                }
            }

            // Update the maxcount
            TextRelay temax = info.GetTextEntry(300);
            if (temax != null)
            {
                int maxval = 0;
                try { maxval = Convert.ToInt32(temax.Text, 10); }
                catch { }
                if (maxval < 0) maxval = 0;
                // if the maxcount of the spawner has been altered external to the interface (e.g. via props, or by the running spawner itself
                // then that change will override the text entry
                if (m_Spawner.MaxCount == this.initial_maxcount)
                {
                    m_Spawner.MaxCount = maxval;
                }
            }

            switch (info.ButtonID)
            {
                case 0: // Close
                    {
                        // clear any text entry books
                        m_Spawner.DeleteTextEntryBook();
                        // and reset the gump status
                        m_Spawner.GumpReset = true;

                        return;
                    }
                case 1: // Help
                    {
                        //state.Mobile.SendGump( new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump));
                        state.Mobile.SendGump(new HelpGump(m_Spawner, this, this.X + 290, this.Y));
                        break;
                    }
                case 2: // Bring everything home
                    {
                        m_Spawner.BringToHome();
                        break;
                    }
                case 3: // Complete respawn
                    {
                        m_Spawner.Respawn();
                        //m_Spawner.AdvanceSequential();
                        m_Spawner.m_killcount = 0;
                        break;
                    }
                case 4: // Goto
                    {
                        state.Mobile.Location = m_Spawner.Location;
                        state.Mobile.Map = m_Spawner.Map;
                        break;
                    }
                case 200: // gump extension
                    {
                        if (this.m_ShowGump > 1)
                            state.Mobile.SendGump(new XmlSpawnerGump(m_Spawner, this.X, this.Y, -1, this.xoffset, this.page));
                        else
                            state.Mobile.SendGump(new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump + 2, this.xoffset, this.page));
                        return;
                    }
                case 201: // gump text extension
                    {
                        if (this.xoffset > 0)
                            state.Mobile.SendGump(new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, 0, this.page));
                        else
                            state.Mobile.SendGump(new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, 250, this.page));
                        return;
                    }
                case 700: // Start/stop spawner
                    {
                        if (m_Spawner.Running)
                            m_Spawner.Running = false;
                        else
                            m_Spawner.Running = true;
                        break;
                    }
                case 701: // Complete reset
                    {
                        m_Spawner.Reset();
                        break;
                    }
                case 702: // Sort spawns
                    {
                        m_Spawner.SortSpawns();
                        break;
                    }
                case 900: // empty the status string
                    {
                        m_Spawner.status_str = "";
                        break;
                    }
                case 9998:  // refresh the gump
                    {
                        state.Mobile.SendGump(new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, this.xoffset, this.page));
                        return;
                    }
                case 9999:
                    {
                        // Show the props window for the spawner, as well as a new gump
                        state.Mobile.SendGump(new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, this.xoffset, this.page));
#if(NEWPROPSGUMP)
                        state.Mobile.SendGump(new XmlPropertiesGump(state.Mobile, m_Spawner));
#else
                    state.Mobile.SendGump( new PropertiesGump( state.Mobile, m_Spawner ) );
#endif
                        return;
                    }
                default:
                    {
                        // check the restrict kills flag
                        if (info.ButtonID >= 300 && info.ButtonID < 300 + MaxSpawnEntries)
                        {
                            int index = info.ButtonID - 300;
                            if (index < m_Spawner.SpawnObjects.Length)
                                m_Spawner.SpawnObjects[index].RestrictKillsToSubgroup = !m_Spawner.SpawnObjects[index].RestrictKillsToSubgroup;

                        }
                        else
                            // check the clear on advance flag
                            if (info.ButtonID >= 400 && info.ButtonID < 400 + MaxSpawnEntries)
                            {
                                int index = info.ButtonID - 400;
                                if (index < m_Spawner.SpawnObjects.Length)
                                    m_Spawner.SpawnObjects[index].ClearOnAdvance = !m_Spawner.SpawnObjects[index].ClearOnAdvance;
                            }
                            else
                                // text entry gump scroll buttons
                                if (info.ButtonID >= 800 && info.ButtonID < 800 + MaxSpawnEntries)
                                {
                                    // open the text entry gump
                                    int index = info.ButtonID - 800;
                                    // open a text entry gump
#if(BOOKTEXTENTRY)
                                    // display a new gump
                                    XmlSpawnerGump newgump = new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, this.xoffset, this.page);
                                    state.Mobile.SendGump(newgump);

                                    // is there an existing book associated with the gump?
                                    if (m_Spawner.m_TextEntryBook == null)
                                    {
                                        m_Spawner.m_TextEntryBook = new ArrayList();
                                    }

                                    object[] args = new object[6];

                                    args[0] = m_Spawner;
                                    args[1] = index;
                                    args[2] = X;
                                    args[3] = Y;
                                    args[4] = m_ShowGump;
                                    args[5] = page;

                                    XmlTextEntryBook book = new XmlTextEntryBook(0, String.Empty, m_Spawner.Name, 20, true, new XmlTextEntryBookCallback(ProcessSpawnerBookEntry), args);

                                    m_Spawner.m_TextEntryBook.Add(book);

                                    book.Title = String.Format("Entry {0}", index);
                                    book.Author = m_Spawner.Name;

                                    // fill the contents of the book with the current text entry data
                                    string text = String.Empty;
                                    if (m_Spawner.SpawnObjects != null && index < m_Spawner.SpawnObjects.Length)
                                    {
                                        text = m_Spawner.SpawnObjects[index].TypeName;
                                    }
                                    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);

                                    // and open it
                                    book.OnDoubleClick(state.Mobile);


#else
                            state.Mobile.SendGump( new TextEntryGump(m_Spawner,this, index, this.X, this.Y));
#endif
                                    return;
                                }
                                else
                                    // goto spawn buttons
                                    if (info.ButtonID >= 1300 && info.ButtonID < 1300 + MaxSpawnEntries)
                                    {
                                        nclicks++;
                                        // find the location of the spawn at the specified index
                                        int index = info.ButtonID - 1300;
                                        if (index < m_Spawner.SpawnObjects.Length)
                                        {
                                            int scount = m_Spawner.SpawnObjects[index].SpawnedObjects.Count;
                                            if (scount > 0)
                                            {
                                                object so = m_Spawner.SpawnObjects[index].SpawnedObjects[nclicks % scount];
                                                if (ValidGotoObject(state.Mobile, so))
                                                {
                                                    IPoint3D o = so as IPoint3D;
                                                    if (o != null)
                                                    {
                                                        Map m = m_Spawner.Map;
                                                        if (o is Item)
                                                            m = ((Item)o).Map;
                                                        if (o is Mobile)
                                                            m = ((Mobile)o).Map;

                                                        state.Mobile.Location = new Point3D(o);
                                                        state.Mobile.Map = m;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                        // page buttons
                                        if (info.ButtonID >= 4000 && info.ButtonID < 4001 + (int)(MaxSpawnEntries / MaxEntriesPerPage))
                                        {
                                            // which page
                                            this.page = info.ButtonID - 4000;

                                        }
                                        else
                                            // toggle the disabled state of the entry
                                            if (info.ButtonID >= 6000 && info.ButtonID < 6000 + MaxSpawnEntries)
                                            {
                                                int index = info.ButtonID - 6000;

                                                if (index < m_Spawner.SpawnObjects.Length)
                                                {
                                                    m_Spawner.SpawnObjects[index].Disabled = !m_Spawner.SpawnObjects[index].Disabled;

                                                    // clear any current spawns on the disabled entry
                                                    if (m_Spawner.SpawnObjects[index].Disabled)
                                                        m_Spawner.RemoveSpawnObjects(m_Spawner.SpawnObjects[index]);
                                                }
                                            }
                                            else
                                                if (info.ButtonID >= 5000 && info.ButtonID < 5000 + MaxSpawnEntries)
                                                {
                                                    int i = info.ButtonID - 5000;




                                                    string categorystring = null;
                                                    string entrystring = null;

                                                    TextRelay te = info.GetTextEntry(i);

                                                    if (te != null && te.Text != null)
                                                    {
                                                        // get the string

                                                        string[] cargs = te.Text.Split(',');

                                                        // parse out any comma separated args
                                                        categorystring = cargs[0];

                                                        entrystring = te.Text;
                                                    }


                                                    if (categorystring == null || categorystring.Length == 0)
                                                    {

                                                        XmlSpawnerGump newg = new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, this.xoffset, this.page);
                                                        state.Mobile.SendGump(newg);

                                                        // if no string has been entered then just use the full categorized add gump
                                                        state.Mobile.CloseGump(typeof(Server.Gumps.XmlCategorizedAddGump));
                                                        state.Mobile.SendGump(new Server.Gumps.XmlCategorizedAddGump(state.Mobile, i, newg));
                                                    }
                                                    else
                                                    {
                                                        // use the XmlPartialCategorizedAddGump
                                                        state.Mobile.CloseGump(typeof(Server.Gumps.XmlPartialCategorizedAddGump));

                                                        //Type [] types = (Type[])XmlPartialCategorizedAddGump.Match( categorystring ).ToArray( typeof( Type ) );
                                                        ArrayList types = XmlPartialCategorizedAddGump.Match(categorystring);


                                                        XmlSpawnerGump.ReplacementEntry re = new XmlSpawnerGump.ReplacementEntry();
                                                        re.Typename = entrystring;
                                                        re.Index = i;
                                                        re.Color = 0x1436;

                                                        XmlSpawnerGump newg = new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, this.xoffset, this.page, re);

                                                        state.Mobile.SendGump(new XmlPartialCategorizedAddGump(state.Mobile, categorystring, 0, types, true, i, newg));

                                                        state.Mobile.SendGump(newg);
                                                    }

                                                    return;


                                                }
                                                else
                                                {
                                                    // up and down arrows
                                                    int buttonID = info.ButtonID - 6;
                                                    int index = buttonID / 2;
                                                    int type = buttonID % 2;

                                                    TextRelay entry = info.GetTextEntry(index);

                                                    if (entry != null && entry.Text.Length > 0)
                                                    {
                                                        string entrystr = entry.Text;

#if(BOOKTEXTENTRY)
                                                        if (index < m_Spawner.SpawnObjects.Length)
                                                        {
                                                            string str = m_Spawner.SpawnObjects[index].TypeName;

                                                            if (str != null && str.Length >= 230)
                                                                entrystr = str;
                                                        }
#endif

                                                        if (type == 0) // Add creature
                                                        {
                                                            m_Spawner.AddSpawnObject(entrystr);
                                                        }
                                                        else // Remove creatures
                                                        {
                                                            m_Spawner.DeleteSpawnObject(state.Mobile, entrystr);


                                                        }
                                                    }
                                                }
                        break;
                    }
            }
            // Create a new gump
            //m_Spawner.OnDoubleClick( state.Mobile);
            state.Mobile.SendGump(new XmlSpawnerGump(m_Spawner, this.X, this.Y, this.m_ShowGump, this.xoffset, this.page, this.Rentry));
        }
Esempio n. 4
0
        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);
        }