From e93869c7a785a4f375685ffa33c913033ed1c85a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 21 Jun 2007 17:08:21 +0000 Subject: * Importing Ming's mass test client --- .../Commands/Inventory/AppearanceCommand.cs | 29 +++++++ .../Commands/Inventory/BalanceCommand.cs | 21 +++++ .../Commands/Inventory/DeleteFolderCommand.cs | 43 ++++++++++ .../Commands/Inventory/DumpOutfitCommand.cs | 98 ++++++++++++++++++++++ .../Commands/Inventory/ExportOutfitCommand.cs | 66 +++++++++++++++ .../Commands/Inventory/GiveAllCommand.cs | 27 ++++++ .../Commands/Inventory/ImportOutfitCommand.cs | 66 +++++++++++++++ .../Commands/Inventory/InventoryCommand.cs | 62 ++++++++++++++ .../Commands/Inventory/WearCommand.cs | 43 ++++++++++ 9 files changed, 455 insertions(+) create mode 100644 tools/mass test client/Commands/Inventory/AppearanceCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/BalanceCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/DeleteFolderCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/DumpOutfitCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/ExportOutfitCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/GiveAllCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/InventoryCommand.cs create mode 100644 tools/mass test client/Commands/Inventory/WearCommand.cs (limited to 'tools/mass test client/Commands/Inventory') diff --git a/tools/mass test client/Commands/Inventory/AppearanceCommand.cs b/tools/mass test client/Commands/Inventory/AppearanceCommand.cs new file mode 100644 index 0000000..43aa784 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/AppearanceCommand.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class AppearanceCommand : Command + { + Utilities.Assets.AssetManager Assets; + Utilities.Appearance.AppearanceManager Appearance; + + public AppearanceCommand(TestClient testClient) + { + Name = "appearance"; + Description = "Set your current appearance to your last saved appearance"; + + Assets = new libsecondlife.Utilities.Assets.AssetManager(testClient); + Appearance = new libsecondlife.Utilities.Appearance.AppearanceManager(testClient, Assets); + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + Appearance.SetPreviousAppearance(); + return "Done."; + } + } +} diff --git a/tools/mass test client/Commands/Inventory/BalanceCommand.cs b/tools/mass test client/Commands/Inventory/BalanceCommand.cs new file mode 100644 index 0000000..46044f2 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/BalanceCommand.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class BalanceCommand: Command + { + public BalanceCommand(TestClient testClient) + { + Name = "balance"; + Description = "Shows the amount of L$."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + return Client.ToString() + " has L$: " + Client.Self.Balance; + } + } +} diff --git a/tools/mass test client/Commands/Inventory/DeleteFolderCommand.cs b/tools/mass test client/Commands/Inventory/DeleteFolderCommand.cs new file mode 100644 index 0000000..081ff86 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/DeleteFolderCommand.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading; +using System.Xml; +using System.Xml.Serialization; + +using libsecondlife; +using libsecondlife.Packets; +using libsecondlife.InventorySystem; + +namespace libsecondlife.TestClient +{ + public class DeleteFolderCommand : Command + { + public DeleteFolderCommand(TestClient testClient) + { + Name = "deleteFolder"; + Description = "Deletes a folder from inventory."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + return "Broken until someone fixes me"; + + //string target = String.Empty; + //for (int ct = 0; ct < args.Length; ct++) + // target = target + args[ct] + " "; + //target = target.TrimEnd(); + + //Client.Inventory.DownloadInventory(); + //InventoryFolder folder = Client.Inventory.getFolder(target); + //if (folder != null) + //{ + // folder.Delete(); + // return "Folder " + target + " deleted."; + //} + + //return "Unable to find: " + target; + } + } +} \ No newline at end of file diff --git a/tools/mass test client/Commands/Inventory/DumpOutfitCommand.cs b/tools/mass test client/Commands/Inventory/DumpOutfitCommand.cs new file mode 100644 index 0000000..8347acc --- /dev/null +++ b/tools/mass test client/Commands/Inventory/DumpOutfitCommand.cs @@ -0,0 +1,98 @@ +using System; +using System.Text; +using System.IO; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Utilities.Assets; +using libsecondlife.Utilities.Appearance; + +namespace libsecondlife.TestClient +{ + public class DumpOutfitCommand : Command + { + libsecondlife.Utilities.Assets.AssetManager Assets; + List OutfitAssets = new List(); + + public DumpOutfitCommand(TestClient testClient) + { + Name = "dumpoutfit"; + Description = "Dumps all of the textures from an avatars outfit to the hard drive. Usage: dumpoutfit [avatar-uuid]"; + + Assets = new AssetManager(testClient); + Assets.OnImageReceived += new AssetManager.ImageReceivedCallback(Assets_OnImageReceived); + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length != 1) + return "Usage: dumpoutfit [avatar-uuid]"; + + LLUUID target; + + if (!LLUUID.TryParse(args[0], out target)) + return "Usage: dumpoutfit [avatar-uuid]"; + + lock (Client.AvatarList) + { + foreach (Avatar avatar in Client.AvatarList.Values) + { + if (avatar.ID == target) + { + StringBuilder output = new StringBuilder("Downloading "); + + lock (OutfitAssets) OutfitAssets.Clear(); + + foreach (KeyValuePair face in avatar.Textures.FaceTextures) + { + ImageType type = ImageType.Normal; + + switch ((AppearanceManager.TextureIndex)face.Key) + { + case AppearanceManager.TextureIndex.HeadBaked: + case AppearanceManager.TextureIndex.EyesBaked: + case AppearanceManager.TextureIndex.UpperBaked: + case AppearanceManager.TextureIndex.LowerBaked: + case AppearanceManager.TextureIndex.SkirtBaked: + type = ImageType.Baked; + break; + } + + Assets.RequestImage(face.Value.TextureID, type, 100000.0f, 0); + + output.Append(((AppearanceManager.TextureIndex)face.Key).ToString()); + output.Append(" "); + } + + return output.ToString(); + } + } + } + + return "Couldn't find avatar " + target.ToStringHyphenated(); + } + + private void Assets_OnImageReceived(ImageDownload image) + { + if (image.Success) + { + try + { + File.WriteAllBytes(image.ID.ToStringHyphenated() + ".jp2", image.AssetData); + Console.WriteLine("Wrote JPEG2000 image " + image.ID.ToStringHyphenated() + ".jp2"); + + byte[] tgaFile = OpenJPEGNet.OpenJPEG.DecodeToTGA(image.AssetData); + File.WriteAllBytes(image.ID.ToStringHyphenated() + ".tga", tgaFile); + Console.WriteLine("Wrote TGA image " + image.ID.ToStringHyphenated() + ".tga"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + } + else + { + Console.WriteLine("Failed to download image " + image.ID.ToStringHyphenated()); + } + } + } +} diff --git a/tools/mass test client/Commands/Inventory/ExportOutfitCommand.cs b/tools/mass test client/Commands/Inventory/ExportOutfitCommand.cs new file mode 100644 index 0000000..9a91d00 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/ExportOutfitCommand.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class ExportOutfitCommand : Command + { + public ExportOutfitCommand(TestClient testClient) + { + Name = "exportoutfit"; + Description = "Exports an avatars outfit to an xml file. Usage: exportoutfit avataruuid outputfile.xml"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length != 2) + return "Usage: exportoutfit avataruuid outputfile.xml"; + + LLUUID id; + + try + { + id = new LLUUID(args[0]); + } + catch (Exception) + { + return "Usage: exportoutfit avataruuid outputfile.xml"; + } + + lock (Client.Appearances) + { + if (Client.Appearances.ContainsKey(id)) + { + try + { + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Indent = true; + XmlWriter writer = XmlWriter.Create(args[1], settings); + try + { + Client.Appearances[id].ToXml(writer); + } + finally + { + writer.Close(); + } + } + catch (Exception e) + { + return e.ToString(); + } + + return "Exported appearance for avatar " + id.ToString() + " to " + args[1]; + } + else + { + return "Couldn't find an appearance for avatar " + id.ToString(); + } + } + } + } +} \ No newline at end of file diff --git a/tools/mass test client/Commands/Inventory/GiveAllCommand.cs b/tools/mass test client/Commands/Inventory/GiveAllCommand.cs new file mode 100644 index 0000000..8890ea0 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/GiveAllCommand.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class GiveAllCommand: Command + { + public GiveAllCommand(TestClient testClient) + { + Name = "giveAll"; + Description = "Gives you all it's money."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (fromAgentID == null) + return "Unable to send money to console. This command only works when IMed."; + + int amount = Client.Self.Balance; + Client.Self.GiveMoney(fromAgentID, Client.Self.Balance, String.Empty); + return "Gave $" + amount + " to " + fromAgentID; + } + } +} diff --git a/tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs b/tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs new file mode 100644 index 0000000..595ce98 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; +using System.Xml.Serialization; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class ImportOutfitCommand : Command + { + private uint SerialNum = 1; + + public ImportOutfitCommand(TestClient testClient) + { + Name = "importoutfit"; + Description = "Imports an appearance from an xml file. Usage: importoutfit inputfile.xml"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length != 1) + return "Usage: importoutfit inputfile.xml"; + + try + { + XmlReader reader = XmlReader.Create(args[0]); + XmlSerializer serializer = new XmlSerializer(typeof(Packet)); + AvatarAppearancePacket appearance = (AvatarAppearancePacket)serializer.Deserialize(reader); + reader.Close(); + + AgentSetAppearancePacket set = new AgentSetAppearancePacket(); + + set.AgentData.AgentID = Client.Network.AgentID; + set.AgentData.SessionID = Client.Network.SessionID; + set.AgentData.SerialNum = SerialNum++; + + float AV_Height_Range = 2.025506f - 1.50856f; + float AV_Height = 1.50856f + (((float)appearance.VisualParam[25].ParamValue / 255.0f) * AV_Height_Range); + set.AgentData.Size = new LLVector3(0.45f, 0.6f, AV_Height); + + set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry; + set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length]; + + int i = 0; + foreach (AvatarAppearancePacket.VisualParamBlock block in appearance.VisualParam) + { + set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock(); + set.VisualParam[i].ParamValue = block.ParamValue; + i++; + } + + set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0]; + + Client.Network.SendPacket(set); + } + catch (Exception) + { + return "Failed to import the appearance XML file, maybe it doesn't exist or is in the wrong format?"; + } + + return "Imported " + args[0] + " and sent an AgentSetAppearance packet"; + } + } +} diff --git a/tools/mass test client/Commands/Inventory/InventoryCommand.cs b/tools/mass test client/Commands/Inventory/InventoryCommand.cs new file mode 100644 index 0000000..da5dc73 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/InventoryCommand.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading; +using System.Xml; +using System.Xml.Serialization; + +using libsecondlife; +using libsecondlife.Packets; +using libsecondlife.InventorySystem; + +namespace libsecondlife.TestClient +{ + public class InventoryCommand : Command + { + public InventoryCommand(TestClient testClient) + { + Name = "i"; + Description = "Prints out inventory."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + return "Broken until someone fixes me"; + + //Client.Inventory.DownloadInventory(); + //StringBuilder result = new StringBuilder(); + //PrintFolder(Client.Inventory.GetRootFolder(), result, 0); + //return result.ToString(); + } + + //void PrintFolder(InventoryFolder folder, StringBuilder output, int indenting) + //{ + // Indent(output, indenting); + // output.Append(folder.Name); + // output.Append("\n"); + // foreach (InventoryBase b in folder.GetContents()) + // { + // InventoryItem item = b as InventoryItem; + // if (item != null) + // { + // Indent(output, indenting + 1); + // output.Append(item.Name); + // output.Append("\n"); + // continue; + // } + // InventoryFolder subFolder = b as InventoryFolder; + // if (subFolder != null) + // PrintFolder(subFolder, output, indenting + 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/tools/mass test client/Commands/Inventory/WearCommand.cs b/tools/mass test client/Commands/Inventory/WearCommand.cs new file mode 100644 index 0000000..d7c1432 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/WearCommand.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading; +using System.Xml; +using System.Xml.Serialization; + +using libsecondlife; +using libsecondlife.Packets; +using libsecondlife.InventorySystem; + +namespace libsecondlife.TestClient +{ + public class WearCommand : Command + { + public WearCommand(TestClient testClient) + { + Name = "wear"; + Description = "Wear an outfit folder from inventory. Usage: wear [outfit name]"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + string target = String.Empty; + + for (int ct = 0; ct < args.Length; ct++) + target = target + args[ct] + " "; + + target = target.TrimEnd(); + + InventoryFolder folder = Client.Inventory.getFolder(target); + + if (folder != null) + { + Client.Appearance.WearOutfit(folder); + return "Outfit " + target + " worn."; + } + + return "Unable to find: " + target; + } + } +} -- cgit v1.1