Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Commands
|
||||
{
|
||||
public class WhatIsIt
|
||||
{
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("WhatIsIt", AccessLevel.Player, new CommandEventHandler(GenericCommand_OnCommand));
|
||||
}
|
||||
|
||||
public class WhatIsItTarget : Target
|
||||
{
|
||||
|
||||
public WhatIsItTarget()
|
||||
: base(30, true, TargetFlags.None)
|
||||
{
|
||||
CheckLOS = false;
|
||||
}
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
if(from == null || targeted == null) return;
|
||||
|
||||
string name = String.Empty;
|
||||
string typename = targeted.GetType().Name;
|
||||
string article = "a";
|
||||
|
||||
if (typename != null && typename.Length > 0)
|
||||
{
|
||||
if ("aeiouy".IndexOf(typename.ToLower()[0]) >= 0)
|
||||
{
|
||||
article = "an";
|
||||
}
|
||||
}
|
||||
|
||||
if(targeted is Item)
|
||||
{
|
||||
name = ((Item)targeted).Name;
|
||||
} else
|
||||
if(targeted is Mobile)
|
||||
{
|
||||
name = ((Mobile)targeted).Name;
|
||||
}
|
||||
if (name != String.Empty && name != null)
|
||||
{
|
||||
from.SendMessage("That is {0} {1} named '{2}'", article, typename, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("That is {0} {1} with no name", article, typename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Usage( "WhatIsIt" )]
|
||||
public static void GenericCommand_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
if(e == null || e.Mobile == null) return;
|
||||
|
||||
e.Mobile.Target = new WhatIsItTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
using System;
|
||||
using Server;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using Server.Multis;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using System.Runtime.Serialization;
|
||||
using Server.Targeting;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
|
||||
namespace Server.Engines.XmlSpawner2
|
||||
{
|
||||
public class WriteMulti
|
||||
{
|
||||
private class TileEntry
|
||||
{
|
||||
public int ID;
|
||||
public int X;
|
||||
public int Y;
|
||||
public int Z;
|
||||
|
||||
public TileEntry(int id, int x, int y, int z)
|
||||
{
|
||||
ID = id;
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
||||
CommandSystem.Register("WriteMulti", XmlSpawner.DiskAccessLevel, new CommandEventHandler(WriteMulti_OnCommand));
|
||||
}
|
||||
|
||||
[Usage("WriteMulti <MultiFile> [zmin zmax][-noitems][-nostatics][-nomultis][-noaddons][-invisible]")]
|
||||
[Description("Creates a multi text file from the objects within the targeted area. The min/max z range can also be specified.")]
|
||||
public static void WriteMulti_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (e == null || e.Mobile == null) return;
|
||||
|
||||
if (e.Mobile.AccessLevel < XmlSpawner.DiskAccessLevel)
|
||||
{
|
||||
e.Mobile.SendMessage("You do not have rights to perform this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Arguments != null && e.Arguments.Length < 1)
|
||||
{
|
||||
e.Mobile.SendMessage("Usage: {0} <MultiFile> [zmin zmax][-noitems][-nostatics][-nomultis][-noaddons][-invisible]", e.Command);
|
||||
return;
|
||||
}
|
||||
|
||||
string filename = e.Arguments[0].ToString();
|
||||
|
||||
int zmin = int.MinValue;
|
||||
int zmax = int.MinValue;
|
||||
bool includeitems = true;
|
||||
bool includestatics = true;
|
||||
bool includemultis = true;
|
||||
bool includeaddons = true;
|
||||
bool includeinvisible = false;
|
||||
|
||||
if (e.Arguments.Length > 1)
|
||||
{
|
||||
int index = 1;
|
||||
while (index < e.Arguments.Length)
|
||||
{
|
||||
if (e.Arguments[index] == "-noitems")
|
||||
{
|
||||
includeitems = false;
|
||||
index++;
|
||||
}
|
||||
else if (e.Arguments[index] == "-nostatics")
|
||||
{
|
||||
includestatics = false;
|
||||
index++;
|
||||
}
|
||||
else if (e.Arguments[index] == "-nomultis")
|
||||
{
|
||||
includemultis = false;
|
||||
index++;
|
||||
}
|
||||
else if (e.Arguments[index] == "-noaddons")
|
||||
{
|
||||
includeaddons = false;
|
||||
index++;
|
||||
}
|
||||
else if (e.Arguments[index] == "-invisible")
|
||||
{
|
||||
includeinvisible = true;
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
zmin = int.Parse(e.Arguments[index++]);
|
||||
zmax = int.Parse(e.Arguments[index++]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
e.Mobile.SendMessage("{0} : Invalid zmin zmax arguments", e.Command);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string dirname;
|
||||
if (System.IO.Directory.Exists(XmlSpawner.XmlSpawnDir) && filename != null && !filename.StartsWith("/") && !filename.StartsWith("\\"))
|
||||
{
|
||||
// put it in the defaults directory if it exists
|
||||
dirname = String.Format("{0}/{1}", XmlSpawner.XmlSpawnDir, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise just put it in the main installation dir
|
||||
dirname = filename;
|
||||
}
|
||||
|
||||
// check to see if the file already exists and can be written to by the owner
|
||||
if (System.IO.File.Exists(dirname))
|
||||
{
|
||||
|
||||
// check the file
|
||||
try
|
||||
{
|
||||
StreamReader op = new StreamReader(dirname, false);
|
||||
|
||||
if (op == null)
|
||||
{
|
||||
e.Mobile.SendMessage("Cannot access file {0}", dirname);
|
||||
return;
|
||||
}
|
||||
|
||||
string line = op.ReadLine();
|
||||
|
||||
op.Close();
|
||||
|
||||
// check the first line
|
||||
if (line != null && line.Length > 0)
|
||||
{
|
||||
|
||||
string[] args = line.Split(" ".ToCharArray(), 3);
|
||||
if (args == null || args.Length < 3)
|
||||
{
|
||||
e.Mobile.SendMessage("Cannot overwrite file {0} : not owner", dirname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[2] != e.Mobile.Name)
|
||||
{
|
||||
e.Mobile.SendMessage("Cannot overwrite file {0} : not owner", dirname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage("Cannot overwrite file {0} : not owner", dirname);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
e.Mobile.SendMessage("Cannot overwrite file {0}", dirname);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DefineMultiArea(e.Mobile, dirname, zmin, zmax, includeitems, includestatics, includemultis, includeinvisible, includeaddons);
|
||||
}
|
||||
|
||||
public static void DefineMultiArea(Mobile m, string dirname, int zmin, int zmax, bool includeitems, bool includestatics,
|
||||
bool includemultis, bool includeinvisible, bool includeaddons)
|
||||
{
|
||||
object[] multiargs = new object[8];
|
||||
multiargs[0] = dirname;
|
||||
multiargs[1] = zmin;
|
||||
multiargs[2] = zmax;
|
||||
multiargs[3] = includeitems;
|
||||
multiargs[4] = includestatics;
|
||||
multiargs[5] = includemultis;
|
||||
multiargs[6] = includeinvisible;
|
||||
multiargs[7] = includeaddons;
|
||||
|
||||
BoundingBoxPicker.Begin(m, new BoundingBoxCallback(DefineMultiArea_Callback), multiargs);
|
||||
}
|
||||
|
||||
private static void DefineMultiArea_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
|
||||
{
|
||||
object[] multiargs = (object[])state;
|
||||
|
||||
if (from != null && multiargs != null && map != null)
|
||||
{
|
||||
string dirname = (string)multiargs[0];
|
||||
int zmin = (int)multiargs[1];
|
||||
int zmax = (int)multiargs[2];
|
||||
bool includeitems = (bool)multiargs[3];
|
||||
bool includestatics = (bool)multiargs[4];
|
||||
bool includemultis = (bool)multiargs[5];
|
||||
bool includeinvisible = (bool)multiargs[6];
|
||||
bool includeaddons = (bool)multiargs[7];
|
||||
|
||||
ArrayList itemlist = new ArrayList();
|
||||
ArrayList staticlist = new ArrayList();
|
||||
ArrayList tilelist = new ArrayList();
|
||||
|
||||
int sx = (start.X > end.X) ? end.X : start.X;
|
||||
int sy = (start.Y > end.Y) ? end.Y : start.Y;
|
||||
int ex = (start.X < end.X) ? end.X : start.X;
|
||||
int ey = (start.Y < end.Y) ? end.Y : start.Y;
|
||||
|
||||
// find all of the world-placed items within the specified area
|
||||
if (includeitems)
|
||||
{
|
||||
// make the first pass for items only
|
||||
IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(sx, sy, ex - sx + 1, ey - sy + 1));
|
||||
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
// is it within the bounding area
|
||||
if (item.Parent == null && (zmin == int.MinValue || (item.Location.Z >= zmin && item.Location.Z <= zmax)))
|
||||
{
|
||||
// add the item
|
||||
if ((includeinvisible || item.Visible) && (item.ItemID <= 16383))
|
||||
{
|
||||
itemlist.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
int searchrange = 100;
|
||||
|
||||
// make the second expanded pass to pick up addon components and multi components
|
||||
eable = map.GetItemsInBounds(new Rectangle2D(sx - searchrange, sy - searchrange, ex - sy + searchrange * 2 + 1,
|
||||
ey - sy + searchrange * 2 + 1));
|
||||
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
// is it within the bounding area
|
||||
if (item.Parent == null)
|
||||
{
|
||||
|
||||
if (item is BaseAddon && includeaddons)
|
||||
{
|
||||
// go through all of the addon components
|
||||
foreach (AddonComponent c in ((BaseAddon)item).Components)
|
||||
{
|
||||
int x = c.X;
|
||||
int y = c.Y;
|
||||
int z = c.Z;
|
||||
|
||||
if ((includeinvisible || item.Visible) && (item.ItemID <= 16383 || includemultis) &&
|
||||
(x >= sx && x <= ex && y >= sy && y <= ey && (zmin == int.MinValue || (z >= zmin && z <= zmax))))
|
||||
{
|
||||
itemlist.Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item is BaseMulti && includemultis)
|
||||
{
|
||||
// go through all of the multi components
|
||||
MultiComponentList mcl = ((BaseMulti)item).Components;
|
||||
if (mcl != null && mcl.List != null)
|
||||
{
|
||||
for (int i = 0; i < mcl.List.Length; i++)
|
||||
{
|
||||
MultiTileEntry t = mcl.List[i];
|
||||
|
||||
int x = t.m_OffsetX + item.X;
|
||||
int y = t.m_OffsetY + item.Y;
|
||||
int z = t.m_OffsetZ + item.Z;
|
||||
int itemID = t.m_ItemID & 0x3FFF;
|
||||
|
||||
if (x >= sx && x <= ex && y >= sy && y <= ey && (zmin == int.MinValue || (z >= zmin && z <= zmax)))
|
||||
{
|
||||
tilelist.Add(new TileEntry(itemID, x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
// find all of the static tiles within the specified area
|
||||
if (includestatics)
|
||||
{
|
||||
// count the statics
|
||||
for (int x = sx; x < ex; x++)
|
||||
{
|
||||
for (int y = sy; y < ey; y++)
|
||||
{
|
||||
StaticTile[] statics = map.Tiles.GetStaticTiles(x, y, false);
|
||||
|
||||
for (int j = 0; j < statics.Length; j++)
|
||||
{
|
||||
if ((zmin == int.MinValue || (statics[j].Z >= zmin && statics[j].Z <= zmax)))
|
||||
{
|
||||
staticlist.Add(new TileEntry(statics[j].ID & 0x3FFF, x, y, statics[j].Z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nstatics = staticlist.Count;
|
||||
int nitems = itemlist.Count;
|
||||
int ntiles = tilelist.Count;
|
||||
|
||||
int ntotal = nitems + nstatics + ntiles;
|
||||
|
||||
int ninvisible = 0;
|
||||
int nmultis = ntiles;
|
||||
int naddons = 0;
|
||||
|
||||
foreach (Item item in itemlist)
|
||||
{
|
||||
int x = item.X - from.X;
|
||||
int y = item.Y - from.Y;
|
||||
int z = item.Z - from.Z;
|
||||
|
||||
if (item.ItemID > 16383)
|
||||
{
|
||||
nmultis++;
|
||||
}
|
||||
if (!item.Visible)
|
||||
{
|
||||
ninvisible++;
|
||||
}
|
||||
if (item is BaseAddon || item is AddonComponent)
|
||||
{
|
||||
naddons++;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// open the file, overwrite any previous contents
|
||||
StreamWriter op = new StreamWriter(dirname, false);
|
||||
|
||||
if (op != null)
|
||||
{
|
||||
// write the header
|
||||
op.WriteLine("1 version {0}", from.Name);
|
||||
op.WriteLine("{0} num components", ntotal);
|
||||
|
||||
// write out the items
|
||||
foreach (Item item in itemlist)
|
||||
{
|
||||
|
||||
int x = item.X - from.X;
|
||||
int y = item.Y - from.Y;
|
||||
int z = item.Z - from.Z;
|
||||
|
||||
if (item.Hue > 0)
|
||||
{
|
||||
// format is x y z visible hue
|
||||
op.WriteLine("{0} {1} {2} {3} {4} {5}", item.ItemID, x, y, z, item.Visible ? 1 : 0, item.Hue);
|
||||
}
|
||||
else
|
||||
{
|
||||
// format is x y z visible
|
||||
op.WriteLine("{0} {1} {2} {3} {4}", item.ItemID, x, y, z, item.Visible ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (includestatics)
|
||||
{
|
||||
foreach (TileEntry s in staticlist)
|
||||
{
|
||||
int x = s.X - from.X;
|
||||
int y = s.Y - from.Y;
|
||||
int z = s.Z - from.Z;
|
||||
int ID = s.ID;
|
||||
op.WriteLine("{0} {1} {2} {3} {4}", ID, x, y, z, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (includemultis)
|
||||
{
|
||||
foreach (TileEntry s in tilelist)
|
||||
{
|
||||
int x = s.X - from.X;
|
||||
int y = s.Y - from.Y;
|
||||
int z = s.Z - from.Z;
|
||||
int ID = s.ID;
|
||||
op.WriteLine("{0} {1} {2} {3} {4}", ID, x, y, z, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
op.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
from.SendMessage("Error writing multi file {0}", dirname);
|
||||
return;
|
||||
}
|
||||
|
||||
from.SendMessage(66, "WriteMulti results:");
|
||||
|
||||
if (includeitems)
|
||||
{
|
||||
from.SendMessage(66, "Included {0} items", nitems);
|
||||
|
||||
if (includemultis)
|
||||
{
|
||||
from.SendMessage("{0} multis", nmultis);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage(33, "Ignored multis");
|
||||
}
|
||||
|
||||
if (includeinvisible)
|
||||
{
|
||||
from.SendMessage("{0} invisible", ninvisible);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage(33, "Ignored invisible");
|
||||
}
|
||||
|
||||
if (includeaddons)
|
||||
{
|
||||
from.SendMessage("{0} addons", naddons);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage(33, "Ignored addons");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage(33, "Ignored items");
|
||||
}
|
||||
|
||||
if (includestatics)
|
||||
{
|
||||
from.SendMessage(66, "Included {0} statics", nstatics);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage(33, "Ignored statics");
|
||||
}
|
||||
|
||||
from.SendMessage(66, "Saved {0} components to {1}", ntotal, dirname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1719
Scripts/Services/XmlSpawner/XmlSpawner Core/XmlUtils/XmlAdd.cs
Normal file
1719
Scripts/Services/XmlSpawner/XmlSpawner Core/XmlUtils/XmlAdd.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,476 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Collections;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
|
||||
/*
|
||||
** Modified from RunUO 1.0.0 CategorizedAddGump.cs
|
||||
** by ArteGordon
|
||||
** 2/5/05
|
||||
*/
|
||||
namespace Server.Gumps
|
||||
{
|
||||
|
||||
public abstract class XmlAddCAGNode
|
||||
{
|
||||
public abstract string Caption{ get; }
|
||||
public abstract void OnClick( Mobile from, int page, int index, Gump gump );
|
||||
}
|
||||
|
||||
public class XmlAddCAGObject : XmlAddCAGNode
|
||||
{
|
||||
private Type m_Type;
|
||||
private int m_ItemID;
|
||||
private int m_Hue;
|
||||
private XmlAddCAGCategory m_Parent;
|
||||
|
||||
public Type Type{ get{ return m_Type; } }
|
||||
public int ItemID{ get{ return m_ItemID; } }
|
||||
public int Hue{ get{ return m_Hue; } }
|
||||
public XmlAddCAGCategory Parent{ get{ return m_Parent; } }
|
||||
|
||||
public override string Caption{ get{ return ( m_Type == null ? "bad type" : m_Type.Name ); } }
|
||||
|
||||
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();
|
||||
xg.Rentry.Typename = m_Type.Name;
|
||||
xg.Rentry.Index = index;
|
||||
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) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public XmlAddCAGObject( XmlAddCAGCategory parent, XmlTextReader xml )
|
||||
{
|
||||
m_Parent = parent;
|
||||
|
||||
if ( xml.MoveToAttribute( "type" ) )
|
||||
m_Type = ScriptCompiler.FindTypeByFullName( xml.Value, false );
|
||||
|
||||
if ( xml.MoveToAttribute( "gfx" ) )
|
||||
m_ItemID = XmlConvert.ToInt32( xml.Value );
|
||||
|
||||
if ( xml.MoveToAttribute( "hue" ) )
|
||||
m_Hue = XmlConvert.ToInt32( xml.Value );
|
||||
}
|
||||
}
|
||||
|
||||
public class XmlAddCAGCategory : XmlAddCAGNode
|
||||
{
|
||||
private string m_Title;
|
||||
private XmlAddCAGNode[] m_Nodes;
|
||||
private XmlAddCAGCategory m_Parent;
|
||||
|
||||
public string Title{ get{ return m_Title; } }
|
||||
public XmlAddCAGNode[] Nodes{ get{ return m_Nodes; } }
|
||||
public XmlAddCAGCategory Parent{ get{ return m_Parent; } }
|
||||
|
||||
public override string Caption{ get{ return m_Title; } }
|
||||
|
||||
public override void OnClick( Mobile from, int page, int index, Gump gump )
|
||||
{
|
||||
from.SendGump( new XmlCategorizedAddGump( from, this, 0, index, gump ) );
|
||||
}
|
||||
|
||||
private XmlAddCAGCategory()
|
||||
{
|
||||
m_Title = "no data";
|
||||
m_Nodes = new XmlAddCAGNode[0];
|
||||
}
|
||||
|
||||
public XmlAddCAGCategory( XmlAddCAGCategory parent, XmlTextReader xml )
|
||||
{
|
||||
m_Parent = parent;
|
||||
|
||||
if ( xml.MoveToAttribute( "title" ) )
|
||||
{
|
||||
if(xml.Value == "Add Menu")
|
||||
m_Title = "XmlAdd Menu";
|
||||
else
|
||||
m_Title = xml.Value;
|
||||
|
||||
}
|
||||
else
|
||||
m_Title = "empty";
|
||||
|
||||
if ( m_Title == "Docked" )
|
||||
m_Title = "Docked 2";
|
||||
|
||||
if ( xml.IsEmptyElement )
|
||||
{
|
||||
m_Nodes = new XmlAddCAGNode[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList nodes = new ArrayList();
|
||||
|
||||
try{
|
||||
while ( xml.Read() && xml.NodeType != XmlNodeType.EndElement )
|
||||
{
|
||||
|
||||
if ( xml.NodeType == XmlNodeType.Element && xml.Name == "object" )
|
||||
nodes.Add( new XmlAddCAGObject( this, xml ) );
|
||||
else if (xml.NodeType == XmlNodeType.Element && xml.Name == "category")
|
||||
{
|
||||
if (!xml.IsEmptyElement)
|
||||
{
|
||||
|
||||
nodes.Add(new XmlAddCAGCategory(this, xml));
|
||||
}
|
||||
}
|
||||
else
|
||||
xml.Skip();
|
||||
|
||||
}
|
||||
} catch (Exception ex){
|
||||
Console.WriteLine("XmlCategorizedAddGump: Corrupted Data/objects.xml file detected. Not all XmlCAG objects loaded. {0}", ex);
|
||||
}
|
||||
|
||||
|
||||
m_Nodes = (XmlAddCAGNode[])nodes.ToArray( typeof( XmlAddCAGNode ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static XmlAddCAGCategory m_Root;
|
||||
|
||||
public static XmlAddCAGCategory Root
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Root == null )
|
||||
m_Root = Load( "Data/objects.xml" );
|
||||
|
||||
return m_Root;
|
||||
}
|
||||
}
|
||||
|
||||
public static XmlAddCAGCategory Load( string path )
|
||||
{
|
||||
if ( File.Exists( path ) )
|
||||
{
|
||||
XmlTextReader xml = new XmlTextReader( path );
|
||||
|
||||
xml.WhitespaceHandling = WhitespaceHandling.None;
|
||||
|
||||
while ( xml.Read() )
|
||||
{
|
||||
if ( xml.Name == "category" && xml.NodeType == XmlNodeType.Element )
|
||||
{
|
||||
XmlAddCAGCategory cat = new XmlAddCAGCategory( null, xml );
|
||||
|
||||
xml.Close();
|
||||
|
||||
return cat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new XmlAddCAGCategory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class XmlCategorizedAddGump : Gump
|
||||
{
|
||||
public static bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY /*+ (((EntryHeight - 20) / 2) / 2)*/;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY /*+ (((EntryHeight - 20) / 2) / 2)*/;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY /*+ (((EntryHeight - 20) / 2) / 2)*/;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = 24;//PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static bool PrevLabel = false, NextLabel = false;
|
||||
|
||||
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
|
||||
private static readonly int PrevLabelOffsetY = 0;
|
||||
|
||||
private static readonly int NextLabelOffsetX = -29;
|
||||
private static readonly int NextLabelOffsetY = 0;
|
||||
|
||||
private static readonly int EntryWidth = 180;
|
||||
private static readonly int EntryCount = 15;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private Mobile m_Owner;
|
||||
private XmlAddCAGCategory m_Category;
|
||||
private int m_Page;
|
||||
|
||||
private int m_Index = -1;
|
||||
private Gump m_Gump;
|
||||
private XmlSpawner m_Spawner;
|
||||
|
||||
public XmlCategorizedAddGump( Mobile owner, int index, Gump gump ) : this( owner, XmlAddCAGCategory.Root, 0, index, gump )
|
||||
{
|
||||
}
|
||||
|
||||
public XmlCategorizedAddGump( Mobile owner, XmlAddCAGCategory category, int page, int index, Gump gump ) : base( GumpOffsetX, GumpOffsetY )
|
||||
{
|
||||
if (category == null)
|
||||
{
|
||||
category = XmlAddCAGCategory.Root;
|
||||
page = 0;
|
||||
}
|
||||
|
||||
owner.CloseGump( typeof( WhoGump ) );
|
||||
|
||||
m_Owner = owner;
|
||||
m_Category = category;
|
||||
|
||||
m_Index = index;
|
||||
m_Gump = gump;
|
||||
if(gump is XmlAddGump)
|
||||
{
|
||||
XmlAddGump xmladdgump = (XmlAddGump)gump;
|
||||
|
||||
if(xmladdgump != null && xmladdgump.defs != null)
|
||||
{
|
||||
xmladdgump.defs.CurrentCategory = category;
|
||||
xmladdgump.defs.CurrentCategoryPage = page;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(gump is XmlSpawnerGump)
|
||||
{
|
||||
m_Spawner = ((XmlSpawnerGump)gump).m_Spawner;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Initialize( page );
|
||||
}
|
||||
|
||||
public void Initialize( int page )
|
||||
{
|
||||
m_Page = page;
|
||||
|
||||
XmlAddCAGNode[] nodes = m_Category.Nodes;
|
||||
|
||||
int count = nodes.Length - (page * EntryCount);
|
||||
|
||||
if ( count < 0 )
|
||||
count = 0;
|
||||
else if ( count > EntryCount )
|
||||
count = EntryCount;
|
||||
|
||||
int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
|
||||
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
|
||||
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize;
|
||||
|
||||
if ( OldStyle )
|
||||
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
|
||||
else
|
||||
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
|
||||
|
||||
if ( m_Category.Parent != null )
|
||||
{
|
||||
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( PrevLabel )
|
||||
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
|
||||
}
|
||||
|
||||
x += PrevWidth + OffsetSize;
|
||||
|
||||
int emptyWidth = TotalWidth - (PrevWidth * 2) - NextWidth - (OffsetSize * 5) - (OldStyle ? SetWidth + OffsetSize : 0);
|
||||
|
||||
if ( !OldStyle )
|
||||
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID );
|
||||
|
||||
AddHtml( x + TextOffsetX, y + ((EntryHeight - 20) / 2), emptyWidth - TextOffsetX, EntryHeight, String.Format( "<center>{0}</center>", m_Category.Caption ), false, false );
|
||||
|
||||
x += emptyWidth + OffsetSize;
|
||||
|
||||
if ( OldStyle )
|
||||
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
|
||||
else
|
||||
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
|
||||
|
||||
if ( page > 0 )
|
||||
{
|
||||
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2, GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( PrevLabel )
|
||||
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
|
||||
}
|
||||
|
||||
x += PrevWidth + OffsetSize;
|
||||
|
||||
if ( !OldStyle )
|
||||
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
|
||||
|
||||
if ( (page + 1) * EntryCount < nodes.Length )
|
||||
{
|
||||
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1 );
|
||||
|
||||
if ( NextLabel )
|
||||
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
|
||||
}
|
||||
|
||||
for ( int i = 0, index = page * EntryCount; i < EntryCount && index < nodes.Length; ++i, ++index )
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
XmlAddCAGNode node = nodes[index];
|
||||
|
||||
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
|
||||
AddLabelCropped( x + TextOffsetX, y + ((EntryHeight - 20) / 2), EntryWidth - TextOffsetX, EntryHeight, TextHue, node.Caption );
|
||||
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if ( SetGumpID != 0 )
|
||||
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
|
||||
|
||||
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4, GumpButtonType.Reply, 0 );
|
||||
|
||||
if ( node is XmlAddCAGObject )
|
||||
{
|
||||
XmlAddCAGObject obj = (XmlAddCAGObject)node;
|
||||
int itemID = obj.ItemID;
|
||||
|
||||
Rectangle2D bounds = ItemBounds.Table[itemID];
|
||||
|
||||
if ( itemID != 1 && bounds.Height < (EntryHeight * 2) )
|
||||
{
|
||||
if ( bounds.Height < EntryHeight )
|
||||
AddItem( x - OffsetSize - 22 - ((i % 2) * 44) - (bounds.Width / 2) - bounds.X, y + (EntryHeight / 2) - (bounds.Height / 2) - bounds.Y, itemID );
|
||||
else
|
||||
AddItem( x - OffsetSize - 22 - ((i % 2) * 44) - (bounds.Width / 2) - bounds.X, y + EntryHeight - 1 - bounds.Height - bounds.Y, itemID );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState state, RelayInfo info )
|
||||
{
|
||||
Mobile from = m_Owner;
|
||||
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 0: // Closed
|
||||
{
|
||||
return;
|
||||
}
|
||||
case 1: // Up
|
||||
{
|
||||
if ( m_Category.Parent != null )
|
||||
{
|
||||
int index = Array.IndexOf( m_Category.Parent.Nodes, m_Category ) / EntryCount;
|
||||
|
||||
if ( index < 0 )
|
||||
index = 0;
|
||||
|
||||
from.SendGump( new XmlCategorizedAddGump( from, m_Category.Parent, index, m_Index, m_Gump ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Previous
|
||||
{
|
||||
if ( m_Page > 0 )
|
||||
from.SendGump( new XmlCategorizedAddGump( from, m_Category, m_Page - 1, m_Index, m_Gump ) );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Next
|
||||
{
|
||||
if ( (m_Page + 1) * EntryCount < m_Category.Nodes.Length )
|
||||
from.SendGump( new XmlCategorizedAddGump( from, m_Category, m_Page + 1, m_Index, m_Gump ) );
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int index = (m_Page * EntryCount) + (info.ButtonID - 4);
|
||||
|
||||
if ( index >= 0 && index < m_Category.Nodes.Length )
|
||||
{
|
||||
m_Category.Nodes[index].OnClick( from, m_Page, m_Index, m_Gump );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1299
Scripts/Services/XmlSpawner/XmlSpawner Core/XmlUtils/XmlEdit.cs
Normal file
1299
Scripts/Services/XmlSpawner/XmlSpawner Core/XmlUtils/XmlEdit.cs
Normal file
File diff suppressed because it is too large
Load Diff
2659
Scripts/Services/XmlSpawner/XmlSpawner Core/XmlUtils/XmlFind.cs
Normal file
2659
Scripts/Services/XmlSpawner/XmlSpawner Core/XmlUtils/XmlFind.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,267 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using Server;
|
||||
using Server.Targeting;
|
||||
using Server.Engines.XmlSpawner2;
|
||||
using Server.Mobiles;
|
||||
|
||||
/*
|
||||
** Modified from RunUO 1.0.0 AddGump.cs
|
||||
** by ArteGordon
|
||||
** 3/13/05
|
||||
*/
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class XmlPartialCategorizedAddGump : Gump
|
||||
{
|
||||
private string m_SearchString;
|
||||
private ArrayList m_SearchResults;
|
||||
private int m_Page;
|
||||
private Gump m_Gump;
|
||||
private int m_EntryIndex = -1;
|
||||
private XmlSpawner m_Spawner;
|
||||
|
||||
public XmlPartialCategorizedAddGump( Mobile from, string searchString, int page, ArrayList searchResults, bool explicitSearch, int entryindex, Gump gump ) : base( 50, 50 )
|
||||
{
|
||||
|
||||
if(gump is XmlSpawnerGump)
|
||||
{
|
||||
// keep track of the spawner for xmlspawnergumps
|
||||
m_Spawner = ((XmlSpawnerGump)gump).m_Spawner;
|
||||
}
|
||||
|
||||
// keep track of the gump
|
||||
m_Gump = gump;
|
||||
|
||||
|
||||
m_SearchString = searchString;
|
||||
m_SearchResults = searchResults;
|
||||
m_Page = page;
|
||||
|
||||
m_EntryIndex = entryindex;
|
||||
|
||||
from.CloseGump( typeof( XmlPartialCategorizedAddGump ) );
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 420, 280, 5054 );
|
||||
|
||||
AddImageTiled( 10, 10, 400, 20, 2624 );
|
||||
AddAlphaRegion( 10, 10, 400, 20 );
|
||||
AddImageTiled( 41, 11, 184, 18, 0xBBC );
|
||||
AddImageTiled( 42, 12, 182, 16, 2624 );
|
||||
AddAlphaRegion( 42, 12, 182, 16 );
|
||||
|
||||
AddButton( 10, 9, 4011, 4013, 1, GumpButtonType.Reply, 0 );
|
||||
AddTextEntry( 44, 10, 180, 20, 0x480, 0, searchString );
|
||||
|
||||
AddHtmlLocalized( 230, 10, 100, 20, 3010005, 0x7FFF, false, false );
|
||||
|
||||
AddImageTiled( 10, 40, 400, 200, 2624 );
|
||||
AddAlphaRegion( 10, 40, 400, 200 );
|
||||
|
||||
if ( searchResults.Count > 0 )
|
||||
{
|
||||
for ( int i = (page * 10); i < ((page + 1) * 10) && i < searchResults.Count; ++i )
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
SearchEntry se = (SearchEntry)searchResults[i];
|
||||
|
||||
string labelstr = se.EntryType.Name;
|
||||
|
||||
if(se.Parameters.Length > 0)
|
||||
{
|
||||
for(int j = 0; j < se.Parameters.Length;j++)
|
||||
{
|
||||
labelstr += ", " + se.Parameters[j].Name;
|
||||
}
|
||||
}
|
||||
|
||||
AddLabel( 44, 39 + (index * 20), 0x480, labelstr );
|
||||
AddButton( 10, 39 + (index * 20), 4023, 4025, 4 + i, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLabel( 15, 44, 0x480, explicitSearch ? "Nothing matched your search terms." : "No results to display." );
|
||||
}
|
||||
|
||||
AddImageTiled( 10, 250, 400, 20, 2624 );
|
||||
AddAlphaRegion( 10, 250, 400, 20 );
|
||||
|
||||
if ( m_Page > 0 )
|
||||
AddButton( 10, 249, 4014, 4016, 2, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 10, 249, 4014 );
|
||||
|
||||
AddHtmlLocalized( 44, 250, 170, 20, 1061028, m_Page > 0 ? 0x7FFF : 0x5EF7, false, false ); // Previous page
|
||||
|
||||
if ( ((m_Page + 1) * 10) < searchResults.Count )
|
||||
AddButton( 210, 249, 4005, 4007, 3, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 210, 249, 4005 );
|
||||
|
||||
AddHtmlLocalized( 244, 250, 170, 20, 1061027, ((m_Page + 1) * 10) < searchResults.Count ? 0x7FFF : 0x5EF7, false, false ); // Next page
|
||||
}
|
||||
|
||||
private static Type typeofItem = typeof( Item ), typeofMobile = typeof( Mobile );
|
||||
|
||||
private class SearchEntry
|
||||
{
|
||||
public Type EntryType;
|
||||
public ParameterInfo [] Parameters;
|
||||
|
||||
public SearchEntry()
|
||||
{
|
||||
}
|
||||
}
|
||||
private static void Match( string match, Type[] types, ArrayList results )
|
||||
{
|
||||
if ( match.Length == 0 )
|
||||
return;
|
||||
|
||||
match = match.ToLower();
|
||||
|
||||
for ( int i = 0; i < types.Length; ++i )
|
||||
{
|
||||
Type t = types[i];
|
||||
|
||||
if ( (typeofMobile.IsAssignableFrom( t ) || typeofItem.IsAssignableFrom( t )) && t.Name.ToLower().IndexOf( match ) >= 0 && !results.Contains( t ) )
|
||||
{
|
||||
ConstructorInfo[] ctors = t.GetConstructors();
|
||||
|
||||
for ( int j = 0; j < ctors.Length; ++j )
|
||||
{
|
||||
if ( /*ctors[j].GetParameters().Length == 0 && */ ctors[j].IsDefined( typeof( ConstructableAttribute ), false ) )
|
||||
{
|
||||
SearchEntry s = new SearchEntry();
|
||||
s.EntryType = t;
|
||||
s.Parameters = ctors[j].GetParameters();
|
||||
//results.Add( t );
|
||||
results.Add( s );
|
||||
//break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList Match( string match )
|
||||
{
|
||||
ArrayList results = new ArrayList();
|
||||
Type[] types;
|
||||
|
||||
Assembly[] asms = ScriptCompiler.Assemblies;
|
||||
|
||||
for ( int i = 0; i < asms.Length; ++i )
|
||||
{
|
||||
types = ScriptCompiler.GetTypeCache( asms[i] ).Types;
|
||||
Match( match, types, results );
|
||||
}
|
||||
|
||||
types = ScriptCompiler.GetTypeCache( Core.Assembly ).Types;
|
||||
Match( match, types, results );
|
||||
|
||||
results.Sort( new TypeNameComparer() );
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private class TypeNameComparer : IComparer
|
||||
{
|
||||
public int Compare( object x, object y )
|
||||
{
|
||||
SearchEntry a = x as SearchEntry;
|
||||
SearchEntry b = y as SearchEntry;
|
||||
|
||||
return a.EntryType.Name.CompareTo( b.EntryType.Name );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user