Make "show part" console commands print out information about each item the part contains

0.7.4-extended
Justin Clark-Casey (justincc) 2012-10-19 00:37:25 +01:00
parent c0254d914f
commit 1cbe4363a3
1 changed files with 93 additions and 20 deletions

View File

@ -141,7 +141,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"show object uuid", "show object uuid",
"show object uuid [--full] <UUID>", "show object uuid [--full] <UUID>",
"Show details of a scene object with the given UUID", "Show details of a scene object with the given UUID",
"The --full option will print out information on all the parts of the object.", "The --full option will print out information on all the parts of the object.\n"
+ "For yet more detailed part information, use the \"show part\" commands.",
HandleShowObjectByUuid); HandleShowObjectByUuid);
m_console.Commands.AddCommand( m_console.Commands.AddCommand(
@ -151,6 +152,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"show object name [--full] [--regex] <name>", "show object name [--full] [--regex] <name>",
"Show details of scene objects with the given name.", "Show details of scene objects with the given name.",
"The --full option will print out information on all the parts of the object.\n" "The --full option will print out information on all the parts of the object.\n"
+ "For yet more detailed part information, use the \"show part\" commands.\n"
+ "If --regex is specified then the name is treatead as a regular expression.", + "If --regex is specified then the name is treatead as a regular expression.",
HandleShowObjectByName); HandleShowObjectByName);
@ -161,6 +163,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"show object pos [--full] <start-coord> to <end-coord>", "show object pos [--full] <start-coord> to <end-coord>",
"Show details of scene objects within the given area.", "Show details of scene objects within the given area.",
"The --full option will print out information on all the parts of the object.\n" "The --full option will print out information on all the parts of the object.\n"
+ "For yet more detailed part information, use the \"show part\" commands.\n"
+ "Each component of the coord is comma separated. There must be no spaces between the commas.\n" + "Each component of the coord is comma separated. There must be no spaces between the commas.\n"
+ "If you don't care about the z component you can simply omit it.\n" + "If you don't care about the z component you can simply omit it.\n"
+ "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n" + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n"
@ -242,7 +245,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.OutputFormat(sb.ToString()); m_console.OutputFormat(sb.ToString());
} }
private void OutputSopsToConsole(Predicate<SceneObjectPart> searchPredicate) private void OutputSopsToConsole(Predicate<SceneObjectPart> searchPredicate, bool showFull)
{ {
List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups(); List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups();
List<SceneObjectPart> parts = new List<SceneObjectPart>(); List<SceneObjectPart> parts = new List<SceneObjectPart>();
@ -253,7 +256,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
foreach (SceneObjectPart part in parts) foreach (SceneObjectPart part in parts)
{ {
AddScenePartReport(sb, part); AddScenePartReport(sb, part, showFull);
sb.Append("\n"); sb.Append("\n");
} }
@ -362,21 +365,27 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
OutputSogsToConsole(searchPredicate, showFull); OutputSogsToConsole(searchPredicate, showFull);
} }
private void HandleShowPartByUuid(string module, string[] cmd) private void HandleShowPartByUuid(string module, string[] cmdparams)
{ {
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return; return;
if (cmd.Length < 4) // bool showFull = false;
OptionSet options = new OptionSet();
// options.Add("full", v => showFull = v != null );
List<string> mainParams = options.Parse(cmdparams);
if (mainParams.Count < 4)
{ {
m_console.OutputFormat("Usage: show part uuid <uuid>"); m_console.OutputFormat("Usage: show part uuid [--full] <uuid>");
return; return;
} }
UUID objectUuid; UUID objectUuid;
if (!UUID.TryParse(cmd[3], out objectUuid)) if (!UUID.TryParse(mainParams[3], out objectUuid))
{ {
m_console.OutputFormat("{0} is not a valid uuid", cmd[3]); m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]);
return; return;
} }
@ -389,7 +398,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
AddScenePartReport(sb, sop); AddScenePartReport(sb, sop, true);
m_console.OutputFormat(sb.ToString()); m_console.OutputFormat(sb.ToString());
} }
@ -399,13 +408,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return; return;
if (cmdparams.Length < 5) // bool showFull = false;
OptionSet options = new OptionSet();
// options.Add("full", v => showFull = v != null );
List<string> mainParams = options.Parse(cmdparams);
if (mainParams.Count < 5)
{ {
m_console.OutputFormat("Usage: show part pos <start-coord> to <end-coord>"); m_console.OutputFormat("Usage: show part pos [--full] <start-coord> to <end-coord>");
return; return;
} }
string rawConsoleStartVector = cmdparams[3]; string rawConsoleStartVector = mainParams[3];
Vector3 startVector; Vector3 startVector;
if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector)) if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector))
@ -414,7 +429,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return; return;
} }
string rawConsoleEndVector = cmdparams[5]; string rawConsoleEndVector = mainParams[5];
Vector3 endVector; Vector3 endVector;
if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector)) if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector))
@ -423,7 +438,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return; return;
} }
OutputSopsToConsole(sop => Util.IsInsideBox(sop.AbsolutePosition, startVector, endVector)); OutputSopsToConsole(sop => Util.IsInsideBox(sop.AbsolutePosition, startVector, endVector), true);
} }
private void HandleShowPartByName(string module, string[] cmdparams) private void HandleShowPartByName(string module, string[] cmdparams)
@ -431,14 +446,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return; return;
// bool showFull = false;
bool useRegex = false; bool useRegex = false;
OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); OptionSet options = new OptionSet();
// options.Add("full", v => showFull = v != null );
options.Add("regex", v => useRegex = v != null );
List<string> mainParams = options.Parse(cmdparams); List<string> mainParams = options.Parse(cmdparams);
if (mainParams.Count < 4) if (mainParams.Count < 4)
{ {
m_console.OutputFormat("Usage: show part name [--regex] <name>"); m_console.OutputFormat("Usage: show part name [--full] [--regex] <name>");
return; return;
} }
@ -456,16 +474,26 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
searchPredicate = sop => sop.Name == name; searchPredicate = sop => sop.Name == name;
} }
OutputSopsToConsole(searchPredicate); OutputSopsToConsole(searchPredicate, true);
} }
/// <summary>
/// Append a scene object report to an input StringBuilder
/// </summary>
/// <returns></returns>
/// <param name='sb'></param>
/// <param name='so'</param>
/// <param name='showFull'>
/// If true then information on all parts of an object is appended.
/// If false then only summary information about an object is appended.
/// </param>
private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so, bool showFull) private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so, bool showFull)
{ {
if (showFull) if (showFull)
{ {
foreach (SceneObjectPart sop in so.Parts) foreach (SceneObjectPart sop in so.Parts)
{ {
AddScenePartReport(sb, sop); AddScenePartReport(sb, sop, false);
sb.Append("\n"); sb.Append("\n");
} }
} }
@ -491,7 +519,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return sb.Append(cdl.ToString()); return sb.Append(cdl.ToString());
} }
private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop) /// <summary>
/// Append a scene object part report to an input StringBuilder
/// </summary>
/// <returns></returns>
/// <param name='sb'></param>
/// <param name='sop'</param>
/// <param name='showFull'>
/// If true then information on each inventory item will be shown.
/// If false then only summary inventory information is shown.
/// </param>
private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop, bool showFull)
{ {
ConsoleDisplayList cdl = new ConsoleDisplayList(); ConsoleDisplayList cdl = new ConsoleDisplayList();
cdl.AddRow("Name", sop.Name); cdl.AddRow("Name", sop.Name);
@ -504,11 +542,46 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
sop.IsRoot ? "Is Root" : string.Format("{0} {1}", sop.ParentGroup.Name, sop.ParentGroup.UUID)); sop.IsRoot ? "Is Root" : string.Format("{0} {1}", sop.ParentGroup.Name, sop.ParentGroup.UUID));
cdl.AddRow("Link number", sop.LinkNum); cdl.AddRow("Link number", sop.LinkNum);
cdl.AddRow("Flags", sop.Flags); cdl.AddRow("Flags", sop.Flags);
cdl.AddRow("Items", sop.Inventory.Count);
object itemsOutput;
if (showFull)
{
StringBuilder itemsSb = new StringBuilder("\n");
itemsOutput = AddScenePartItemsReport(itemsSb, sop.Inventory).ToString();
}
else
{
itemsOutput = sop.Inventory.Count;
}
cdl.AddRow("Items", itemsOutput);
return sb.Append(cdl.ToString()); return sb.Append(cdl.ToString());
} }
private StringBuilder AddScenePartItemsReport(StringBuilder sb, IEntityInventory inv)
{
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.Indent = 2;
cdt.AddColumn("Name", 50);
cdt.AddColumn("Type", 12);
cdt.AddColumn("Running", 7);
cdt.AddColumn("Item UUID", 36);
cdt.AddColumn("Asset UUID", 36);
foreach (TaskInventoryItem item in inv.GetInventoryItems())
cdt.AddRow(
item.Name,
((InventoryType)item.InvType).ToString(),
(InventoryType)item.InvType == InventoryType.LSL ? item.ScriptRunning.ToString() : "n/a",
item.ItemID.ToString(),
item.AssetID.ToString());
return sb.Append(cdt.ToString());
}
private void HandleDeleteObject(string module, string[] cmd) private void HandleDeleteObject(string module, string[] cmd)
{ {
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))