BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
BrawlCrate.NodeWrappers.CollisionObjectWrapper Class Reference
Inheritance diagram for BrawlCrate.NodeWrappers.CollisionObjectWrapper:
BrawlCrate.NodeWrappers.GenericWrapper BrawlCrate.NodeWrappers.BaseWrapper BrawlCrate.NodeWrappers.MultiSelectableWrapper

Public Member Functions

override ResourceNode Duplicate ()
 
- Public Member Functions inherited from BrawlCrate.NodeWrappers.GenericWrapper
 GenericWrapper (IWin32Window owner)
 
 GenericWrapper ()
 
virtual void Sort ()
 
void MoveUp ()
 
virtual void MoveUp (bool select)
 
void MoveDown ()
 
virtual void MoveDown (bool select)
 
void DeleteSelected ()
 
void ExportSelected ()
 
virtual string Export ()
 
virtual void OnExport (string outPath)
 
virtual void Replace ()
 
virtual void OnReplace (string inStream)
 
void Restore ()
 
virtual void Delete ()
 
void Rename ()
 
virtual ResourceNode Duplicate ()
 
virtual ResourceNode Duplicate (bool changeName)
 
- Public Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
void Link (ResourceNode res)
 
void Unlink ()
 

Properties

override string ExportFilter [get]
 
override string ImportFilter [get]
 
- Properties inherited from BrawlCrate.NodeWrappers.GenericWrapper
virtual ContextMenuStrip MultiSelectMenuStrip [get]
 
virtual string DefaultName [get]
 
virtual string ExportFilter [get]
 
virtual string ImportFilter [get]
 
virtual string ReplaceFilter [get]
 
- Properties inherited from BrawlCrate.NodeWrappers.BaseWrapper
ResourceNode Resource [get]
 
virtual ? Color DefaultBackColor [get]
 
virtual ? Color DefaultForeColor [get]
 
- Properties inherited from BrawlCrate.NodeWrappers.MultiSelectableWrapper
ContextMenuStrip MultiSelectMenuStrip [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
static BaseWrapper[] GetAllNodes (BaseWrapper root)
 
static BaseWrapper Wrap (ResourceNode node)
 
static BaseWrapper Wrap (IWin32Window owner, ResourceNode node)
 
- Static Public Attributes inherited from BrawlCrate.NodeWrappers.BaseWrapper
static IWin32Window _owner
 
- Protected Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
 BaseWrapper ()
 
- Static Protected Member Functions inherited from BrawlCrate.NodeWrappers.GenericWrapper
static void MoveUpAction (object sender, EventArgs e)
 
static void MoveDownAction (object sender, EventArgs e)
 
static void ExportAction (object sender, EventArgs e)
 
static void ExportSelectedAction (object sender, EventArgs e)
 
static void DeleteSelectedAction (object sender, EventArgs e)
 
static void DuplicateAction (object sender, EventArgs e)
 
static void ReplaceAction (object sender, EventArgs e)
 
static void RestoreAction (object sender, EventArgs e)
 
static void DeleteAction (object sender, EventArgs e)
 
static void RenameAction (object sender, EventArgs e)
 
static void SortAction (object sender, EventArgs e)
 
- Static Protected Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
static T GetInstance< T > ()
 
static IEnumerable< T > GetInstances< T > ()
 
- Protected Attributes inherited from BrawlCrate.NodeWrappers.BaseWrapper
bool _discovered
 
ResourceNode _resource
 
- Static Protected Attributes inherited from BrawlCrate.NodeWrappers.BaseWrapper
static readonly ContextMenuStrip _emptyMenu = new ContextMenuStrip()
 

Member Function Documentation

◆ Duplicate()

override ResourceNode BrawlCrate.NodeWrappers.CollisionObjectWrapper.Duplicate ( )
inlinevirtual

Reimplemented from BrawlCrate.NodeWrappers.GenericWrapper.

19 {
20 if (_resource.Parent == null)
21 {
22 return null;
23 }
24
25 string tempPath = Path.GetTempFileName();
26 // Explicitly set the ".coll" extension to ensure that the node exports all necessary data
27 _resource.Export($"{tempPath}.coll");
28 if (!(NodeFactory.FromFile(null, $"{tempPath}.coll", typeof(CollisionNode)) is CollisionNode cNode))
29 {
30 MessageBox.Show("The node could not be duplicated correctly.");
31 return null;
32 }
33
34 int n = 0;
35 int index = _resource.Index;
36 // Copy the name directly since Collision Objects don't store their own name
37 cNode.Children[0].Name = _resource.Name;
38 // Set the name programatically (based on Windows' implementation)
39 while (_resource.Parent.FindChildrenByName(cNode.Children[0].Name).Length >= 1)
40 {
41 // Get the last index of the last duplicated node in order to place it after that one
42 index = Math.Max(index, _resource.Parent.FindChildrenByName(cNode.Children[0].Name).Last().Index);
43 // Set the name based on the number of duplicate nodes found
44 cNode.Children[0].Name = $"{_resource.Name} ({++n})";
45 }
46
47 // Place the node in the same containing parent, after the last duplicated node.
48 _resource.Parent.InsertChild(cNode.Children[0], true, index + 1);
49 cNode.Dispose();
50 return cNode.Children[0];
51 }
ResourceNode _resource
Definition: BaseWrapper.cs:76
Definition: CollisionNode.cs:15
Definition: NodeFactory.cs:18
static ResourceNode FromFile(ResourceNode parent, string path)
Definition: NodeFactory.cs:69
virtual void Export(string outPath)
Definition: ResourceNode.cs:909
ResourceNode[] FindChildrenByName(string name)
Definition: ResourceNode.cs:1558
virtual void InsertChild(ResourceNode child, int index)
Definition: ResourceNode.cs:774
ResourceNode Parent
Definition: ResourceNode.cs:245
int Index
Definition: ResourceNode.cs:301
virtual string Name
Definition: ResourceNode.cs:223

Property Documentation

◆ ExportFilter

override string BrawlCrate.NodeWrappers.CollisionObjectWrapper.ExportFilter
get

◆ ImportFilter

override string BrawlCrate.NodeWrappers.CollisionObjectWrapper.ImportFilter
get

The documentation for this class was generated from the following file: