diff --git a/libsecondlife/examples/GUITestClient/GUITestClient.csproj b/libsecondlife/examples/GUITestClient/GUITestClient.csproj
index 5b0eed25..34a9e7e1 100644
--- a/libsecondlife/examples/GUITestClient/GUITestClient.csproj
+++ b/libsecondlife/examples/GUITestClient/GUITestClient.csproj
@@ -28,6 +28,7 @@
4
+
@@ -36,6 +37,8 @@
+
+
Form
@@ -70,12 +73,6 @@
True
-
-
- {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}
- libsecondlife
-
-
-
\ No newline at end of file
+
diff --git a/libsecondlife/examples/GUITestClient/Interfaces/MinimapInterface.cs b/libsecondlife/examples/GUITestClient/Interfaces/MinimapInterface.cs
new file mode 100644
index 00000000..3ca2dea2
--- /dev/null
+++ b/libsecondlife/examples/GUITestClient/Interfaces/MinimapInterface.cs
@@ -0,0 +1,145 @@
+using System;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using libsecondlife;
+using System.Net;
+using System.Diagnostics;
+
+namespace libsecondlife.GUITestClient
+{
+ public class MinimapInterface : Interface
+ {
+ //A magic number to calculate index sim y coord from actual coord
+ private const int GRID_Y_OFFSET = 1279;
+ //Base URL for web map api sim images
+ private const String MAP_IMG_URL = "http://secondlife.com/apps/mapapi/grid/map_image/";
+ private PictureBox world = new PictureBox();
+ private Button cmdRefresh = new Button();
+ private System.Drawing.Image mMapImage = null;
+ private string oldSim = String.Empty;
+
+ public MinimapInterface(frmTestClient testClient)
+ {
+ Name = "Minimap";
+ Description = "Displays a graphical minimap of the current simulator";
+ }
+
+ private void map_onclick(object sender, System.EventArgs e)
+ {
+ ;
+ }
+
+ private void cmdRefresh_onclick(object sender, System.EventArgs e)
+ {
+ printMap();
+ }
+
+ public void printMap()
+ {
+ Bitmap map = new Bitmap(256, 256, PixelFormat.Format32bppRgb);
+ Font font = new Font("Tahoma", 8, FontStyle.Bold);
+ Pen mAvPen = new Pen(Brushes.GreenYellow, 1);
+ Brush mAvBrush = new SolidBrush(Color.Green);
+ String strInfo = String.Empty;
+
+ // Get new background map if necessary
+ if (mMapImage == null || oldSim != Client.Network.CurrentSim.Name)
+ {
+ oldSim = Client.Network.CurrentSim.Name;
+ mMapImage = DownloadWebMapImage();
+ }
+
+ // Create in memory bitmap
+ using (Graphics g = Graphics.FromImage(map))
+ {
+ // Draw background map
+ g.DrawImage(mMapImage, new Rectangle(0, 0, 256, 256), 0, 0, 256, 256, GraphicsUnit.Pixel);
+
+ // Draw all avatars
+ Client.Network.CurrentSim.AvatarPositions.ForEach(
+ delegate(LLVector3 pos)
+ {
+ Rectangle rect = new Rectangle((int)Math.Round(pos.X, 0) - 2, 255 - ((int)Math.Round(pos.Y, 0) - 2), 4, 4);
+ g.FillEllipse(mAvBrush, rect);
+ g.DrawEllipse(mAvPen, rect);
+ }
+ );
+
+ // Draw self ;)
+ Rectangle myrect = new Rectangle((int)Math.Round(Client.Self.SimPosition.X, 0) - 3, 255 - ((int)Math.Round(Client.Self.SimPosition.Y, 0) - 3), 6, 6);
+ g.FillEllipse(new SolidBrush(Color.Yellow), myrect);
+ g.DrawEllipse(new Pen(Brushes.Goldenrod, 1), myrect);
+
+ // Draw region info
+ strInfo = string.Format("Sim {0}/{1}/{2}/{3}\nAvatars {4}", Client.Network.CurrentSim.Name,
+ Math.Round(Client.Self.SimPosition.X, 0),
+ Math.Round(Client.Self.SimPosition.Y, 0),
+ Math.Round(Client.Self.SimPosition.Z, 0),
+ Client.Network.CurrentSim.AvatarPositions.Count);
+ g.DrawString(strInfo, font, Brushes.DarkOrange, 4, 4);
+ }
+ // update picture box with new map bitmap
+ world.BackgroundImage = map;
+ }
+
+ public override void Initialize()
+ {
+ ((System.ComponentModel.ISupportInitialize)(world)).BeginInit();
+ world.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ world.Size = new System.Drawing.Size(256, 256);
+ world.Visible = true;
+ world.Click += new System.EventHandler(this.map_onclick);
+ ((System.ComponentModel.ISupportInitialize)(world)).EndInit();
+
+ //((System.ComponentModel.ISupportInitialize)(cmdRefresh)).BeginInit();
+ cmdRefresh.Text = "Refresh";
+ cmdRefresh.Size = new System.Drawing.Size(80, 24);
+ cmdRefresh.Left = world.Left + world.Width + 20;
+ cmdRefresh.Click += new System.EventHandler(this.cmdRefresh_onclick);
+ cmdRefresh.Visible = true;
+ //((System.ComponentModel.ISupportInitialize)(world)).EndInit();
+
+ TabPage.Controls.Add(world);
+ TabPage.Controls.Add(cmdRefresh);
+ }
+
+ // Ripped from "Terrain Scultor" by Cadroe with minors changes
+ // http://spinmass.blogspot.com/2007/08/terrain-sculptor-maps-sims-and-creates.html
+ private System.Drawing.Image DownloadWebMapImage()
+ {
+ HttpWebRequest request = null;
+ HttpWebResponse response = null;
+ String imgURL = "";
+ GridRegion currRegion;
+
+ Client.Grid.GetGridRegion(Client.Network.CurrentSim.Name, GridLayerType.Terrain, out currRegion);
+ try
+ {
+ //Form the URL using the sim coordinates
+ imgURL = MAP_IMG_URL + currRegion.X.ToString() + "-" +
+ (GRID_Y_OFFSET - currRegion.Y).ToString() + "-1-0";
+ //Make the http request
+ request = (HttpWebRequest)HttpWebRequest.Create(imgURL);
+ request.Timeout = 5000;
+ request.ReadWriteTimeout = 20000;
+ response = (HttpWebResponse)request.GetResponse();
+
+ return System.Drawing.Image.FromStream(response.GetResponseStream());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.ToString(), "Error Downloading Web Map Image");
+ return null;
+ }
+ }
+
+ public override void Paint(object sender, PaintEventArgs e)
+ {
+ ;
+ }
+ }
+}
diff --git a/libsecondlife/examples/GUITestClient/Interfaces/TeleportInterface.cs b/libsecondlife/examples/GUITestClient/Interfaces/TeleportInterface.cs
new file mode 100644
index 00000000..672d511d
--- /dev/null
+++ b/libsecondlife/examples/GUITestClient/Interfaces/TeleportInterface.cs
@@ -0,0 +1,79 @@
+using System;
+using System.ComponentModel;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using libsecondlife;
+
+namespace libsecondlife.GUITestClient
+{
+ class TeleportInterface : Interface
+ {
+ private System.Windows.Forms.Button cmdTeleport;
+ private System.Windows.Forms.TextBox txtLocation;
+ private System.Windows.Forms.Label lblLocation;
+
+ public TeleportInterface(frmTestClient testClient)
+ {
+ Name = "Teleport";
+ Description = "Teleport your's agent in SL Grid";
+ }
+
+ public override void Initialize()
+ {
+ txtLocation = new System.Windows.Forms.TextBox();
+ txtLocation.Size = new System.Drawing.Size(238, 24);
+ txtLocation.Top = 100;
+ txtLocation.Left = 12;
+
+ lblLocation = new System.Windows.Forms.Label();
+ lblLocation.Size = new System.Drawing.Size(238, 24);
+ lblLocation.Top = txtLocation.Top - 16;
+ lblLocation.Left = txtLocation.Left;
+ lblLocation.Text = "Location (eg: sim/x/y/z)";
+
+ cmdTeleport = new System.Windows.Forms.Button();
+ cmdTeleport.Size = new System.Drawing.Size(120, 24);
+ cmdTeleport.Top = 100; cmdTeleport.Left = 257;
+ cmdTeleport.Text = "Teleport !";
+ cmdTeleport.Click += new System.EventHandler(this.cmdTeleport_OnClick);
+
+ TabPage.Controls.Add(txtLocation);
+ TabPage.Controls.Add(lblLocation);
+ TabPage.Controls.Add(cmdTeleport);
+ }
+
+ private void cmdTeleport_OnClick(object sender, System.EventArgs e)
+ {
+ String destination = txtLocation.Text.Trim();
+
+ string[] tokens = destination.Split(new char[] { '/' });
+ if (tokens.Length != 4)
+ goto error_handler;
+
+ string sim = tokens[0];
+ float x, y, z;
+ if (!float.TryParse(tokens[1], out x) ||
+ !float.TryParse(tokens[2], out y) ||
+ !float.TryParse(tokens[3], out z))
+ {
+ goto error_handler;
+ }
+
+ if (Client.Self.Teleport(sim, new LLVector3(x, y, z)))
+ MessageBox.Show("Teleported to " + Client.Network.CurrentSim, "Teleport");
+ else
+ MessageBox.Show("Teleport failed: " + Client.Self.TeleportMessage, "Teleport");
+ return;
+
+ error_handler:
+ MessageBox.Show("Location must to be sim/x/y/z", "Teleport");
+ }
+
+ public override void Paint(object sender, PaintEventArgs e)
+ {
+ ;
+ }
+ }
+}
diff --git a/libsecondlife/examples/GUITestClient/frmTestClient.cs b/libsecondlife/examples/GUITestClient/frmTestClient.cs
index fbc05c70..d04c1991 100644
--- a/libsecondlife/examples/GUITestClient/frmTestClient.cs
+++ b/libsecondlife/examples/GUITestClient/frmTestClient.cs
@@ -102,7 +102,7 @@ namespace libsecondlife.GUITestClient
if (!Interfaces.ContainsKey(iface))
{
- lock(Interfaces) Interfaces.Add(iface, page);
+ lock (Interfaces) Interfaces.Add(iface, page);
}
iface.Initialize();
@@ -122,4 +122,4 @@ namespace libsecondlife.GUITestClient
}
}
}
-}
\ No newline at end of file
+}
diff --git a/libsecondlife/examples/TestClient/Commands/Inventory/InventoryCommand.cs b/libsecondlife/examples/TestClient/Commands/Inventory/InventoryCommand.cs
index a2ce7000..b0f020a0 100644
--- a/libsecondlife/examples/TestClient/Commands/Inventory/InventoryCommand.cs
+++ b/libsecondlife/examples/TestClient/Commands/Inventory/InventoryCommand.cs
@@ -27,35 +27,24 @@ namespace libsecondlife.TestClient
Inventory = Manager.Store;
StringBuilder result = new StringBuilder();
+
+ InventoryFolder rootFolder = Inventory.RootFolder;
+ PrintFolder(rootFolder, result, 0);
- //Client.Inventory.RequestFolderContents(Client.Inventory.Store.RootFolder.UUID, Client.Self.AgentID,
- // true, true, InventorySortOrder.ByName);
-
- //PrintFolder(Inventory.RootNode, result, 0);
-
- //return result.ToString();
-
- //FIXME:
- return "This function needs a blocking InventoryManager.FolderContents() to work";
+ return result.ToString();
}
- void PrintFolder(InventoryNode f, StringBuilder result, int indent)
+ void PrintFolder(InventoryFolder f, StringBuilder result, int indent)
{
- foreach ( InventoryNode i in f.Nodes.Values )
+ foreach (InventoryBase i in Manager.FolderContents(f.UUID, Client.Self.AgentID, true, true, InventorySortOrder.ByName, 3000))
{
- result.Append(i.Data.Name + "\n");
-
- if ( i.Nodes.Count > 0 )
- PrintFolder(i, result, indent + 1);
+ result.AppendFormat("{0}{1} ({2})\n", new String(' ', indent * 2), i.Name, i.UUID);
+ if (i is InventoryFolder)
+ {
+ InventoryFolder folder = (InventoryFolder)i;
+ PrintFolder(folder, result, indent + 1);
+ }
}
}
-
- //void Indent(StringBuilder output, int indenting)
- //{
- // for (int count = 0; count < indenting; count++)
- // {
- // output.Append(" ");
- // }
- //}
}
}
\ No newline at end of file
diff --git a/libsecondlife/examples/TestClient/Commands/Prims/PrimRegexCommand.cs b/libsecondlife/examples/TestClient/Commands/Prims/PrimRegexCommand.cs
new file mode 100644
index 00000000..44b1b39b
--- /dev/null
+++ b/libsecondlife/examples/TestClient/Commands/Prims/PrimRegexCommand.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Text.RegularExpressions;
+using libsecondlife;
+
+namespace libsecondlife.TestClient
+{
+ public class PrimRegexCommand : Command
+ {
+ public PrimRegexCommand(TestClient testClient)
+ {
+ Name = "primregex";
+ Description = "Find prim by text predicat. " +
+ "Usage: primregex [text predicat] (eg findprim .away.)";
+ }
+
+ public override string Execute(string[] args, LLUUID fromAgentID)
+ {
+ if (args.Length < 1)
+ return "Usage: primregex [text predicat]";
+
+ try
+ {
+ // Build the predicat from the args list
+ string predicatPrim = string.Empty;
+ for (int i = 0; i < args.Length; i++)
+ predicatPrim += args[i] + " ";
+ predicatPrim = predicatPrim.TrimEnd();
+
+ // Build Regex
+ Regex regexPrimName = new Regex(predicatPrim.ToLower());
+
+ // Print result
+ Client.Log(string.Format("Searching prim for [{0}] ({1} prims loaded in simulator)\n", predicatPrim, Client.Network.CurrentSim.Objects.PrimCount), Helpers.LogLevel.Info);
+ Client.Network.CurrentSim.Objects.ForEach(
+ delegate(Primitive prim)
+ {
+ if (prim.Text != null && regexPrimName.IsMatch(prim.Text.ToLower()))
+ Client.Log(string.Format("\nNAME={0}\nID = {1}\nFLAGS = {2}\nTEXT = '{3}'\n", prim.PropertiesFamily.Nameprim.ID, prim.Flags.ToString(), prim.Text), Helpers.LogLevel.Info);
+ }
+ );
+ }
+ catch (System.Exception e)
+ {
+ Client.Log(e.ToString(), Helpers.LogLevel.Error);
+ return "Error searching";
+ }
+
+ return "Done searching";
+ }
+ }
+}
diff --git a/libsecondlife/examples/TestClient/TestClient.csproj b/libsecondlife/examples/TestClient/TestClient.csproj
index f17ab521..c5f8a168 100644
--- a/libsecondlife/examples/TestClient/TestClient.csproj
+++ b/libsecondlife/examples/TestClient/TestClient.csproj
@@ -75,10 +75,12 @@
+
+