* Added a download command to TestClient to download non-texture assets

* ls -l in TestClient now also prints AssetIDs
* Removed ExportOutfit and ImportOutfit, they didn't work
* Added default eyes and more clothing textures to Simian. Appearance is working for me now. Appearance won't persist until we have a persistent asset store

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@2282 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2008-10-09 01:55:46 +00:00
parent e180f7a612
commit 003eb8a220
15 changed files with 154 additions and 157 deletions

View File

@@ -0,0 +1,90 @@
using System;
using System.IO;
using System.Threading;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class DownloadCommand : Command
{
UUID AssetID;
AssetType assetType;
AutoResetEvent DownloadHandle = new AutoResetEvent(false);
bool Success;
public DownloadCommand(TestClient testClient)
{
Name = "download";
Description = "Downloads the specified asset. Usage: download [uuid] [assetType]";
Category = CommandCategory.Inventory;
testClient.Assets.OnAssetReceived += new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length != 2)
return "Usage: download [uuid] [assetType]";
Success = false;
AssetID = UUID.Zero;
assetType = AssetType.Unknown;
DownloadHandle.Reset();
if (UUID.TryParse(args[0], out AssetID))
{
int typeInt;
if (Int32.TryParse(args[1], out typeInt) && typeInt >= 0 && typeInt <= 22)
{
assetType = (AssetType)typeInt;
// Start the asset download
Client.Assets.RequestAsset(AssetID, assetType, true);
if (DownloadHandle.WaitOne(120 * 1000, false))
{
if (Success)
return String.Format("Saved {0}.{1}", AssetID, assetType.ToString().ToLower());
else
return String.Format("Failed to download asset {0}, perhaps {1} is the incorrect asset type?",
AssetID, assetType);
}
else
{
return "Timed out waiting for texture download";
}
}
else
{
return "Usage: download [uuid] [assetType]";
}
}
else
{
return "Usage: download [uuid] [assetType]";
}
}
private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
{
if (transfer.AssetID == AssetID)
{
if (transfer.Success)
{
try
{
File.WriteAllBytes(String.Format("{0}.{1}", AssetID,
assetType.ToString().ToLower()), asset.AssetData);
Success = true;
}
catch (Exception ex)
{
Logger.Log(ex.Message, Helpers.LogLevel.Error, ex);
}
}
DownloadHandle.Set();
}
}
}
}

View File

@@ -1,59 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.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";
Category = CommandCategory.Inventory;
}
public override string Execute(string[] args, UUID fromAgentID)
{
UUID id;
string path;
if (args.Length == 1)
{
id = Client.Self.AgentID;
path = args[0];
}
else if (args.Length == 2)
{
if (!UUID.TryParse(args[0], out id))
return "Usage: exportoutfit [avataruuid] outputfile.xml";
path = args[1];
}
else
return "Usage: exportoutfit [avataruuid] outputfile.xml";
lock (Client.Appearances)
{
if (Client.Appearances.ContainsKey(id))
{
try
{
File.WriteAllText(path, Packet.ToXmlString(Client.Appearances[id]));
}
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();
}
}
}
}
}

View File

@@ -1,68 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.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";
Category = CommandCategory.Inventory;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length != 1)
return "Usage: importoutfit inputfile.xml";
return "LLSD packet import is under construction";
//try
//{
// Packet packet = Packet.FromXmlString((File.ReadAllText(args[0])));
// if (packet.Type != PacketType.AvatarAppearance)
// return "Deserialized a " + packet.Type + " packet instead of an AvatarAppearance packet";
// AvatarAppearancePacket appearance = (AvatarAppearancePacket)packet;
// AgentSetAppearancePacket set = new AgentSetAppearancePacket();
// set.AgentData.AgentID = Client.Self.AgentID;
// set.AgentData.SessionID = Client.Self.SessionID;
// set.AgentData.SerialNum = SerialNum++;
// // HACK: Weak hack to calculate size
// 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 Vector3(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";
}
}
}

View File

@@ -56,6 +56,8 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell
displayString += PermMaskString(item.Permissions.EveryoneMask);
displayString += " " + item.UUID;
displayString += " " + item.Name;
displayString += nl;
displayString += " AssetID: " + item.AssetUUID;
}
}
else

View File

@@ -16,7 +16,7 @@ namespace OpenMetaverse.TestClient
{
Name = "downloadtexture";
Description = "Downloads the specified texture. " +
"Usage: downloadtexture [texture-uuid]";
"Usage: downloadtexture [texture-uuid] [discardlevel]";
Category = CommandCategory.Inventory;
testClient.Assets.OnImageReceiveProgress += new AssetManager.ImageReceiveProgressCallback(Assets_OnImageReceiveProgress);