BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
BrawlLib.SSBB.ResourceNodes.U8Node Class Reference
Inheritance diagram for BrawlLib.SSBB.ResourceNodes.U8Node:
BrawlLib.SSBB.ResourceNodes.U8EntryNode BrawlLib.SSBB.ResourceNodes.ResourceNode

Public Member Functions

override void OnPopulate ()
 
override bool OnInitialize ()
 
override int OnCalculateSize (bool force)
 
override void OnRebuild (VoidPtr address, int length, bool force)
 
override void Export (string outPath)
 
void ExportSZS (string outPath)
 
void ExportPair (string outPath)
 
void ExportNonYaz0 (string outPath)
 
void ExportCompressed (string outPath)
 
void ExtractToFolder (string outFolder)
 
void ExtractToFolder (string outFolder, string imageExtension)
 
void ExtractToFolder (string outFolder, string imageExtension, string modelExtension)
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.U8EntryNode
override bool OnInitialize ()
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void OnRenamed ()
 
List< ResourceNodeGetChildrenRecursive ()
 Used primarily to get bone lists. Kept for all resource nodes for utility. More...
 
virtual void SignalPropertyChange ()
 
virtual void Dispose ()
 
void SelectChildAtIndex (int index)
 
void UpdateProperties ()
 
void UpdateCurrentControl ()
 
virtual bool MoveUp ()
 
virtual bool MoveDown ()
 
virtual void OnMoved ()
 
virtual void DoMoveDown ()
 
virtual void DoMoveDown (bool select)
 
virtual void DoMoveUp ()
 
virtual void DoMoveUp (bool select)
 
virtual bool AddUp ()
 
virtual bool AddDown ()
 
virtual bool ToParent ()
 
void Populate (int levels=-1)
 
virtual void OnPopulate ()
 
void Initialize (ResourceNode parent, FileMap source)
 
void Initialize (ResourceNode parent, VoidPtr address, int length)
 
void Initialize (ResourceNode parent, DataSource origSource)
 
virtual void Initialize (ResourceNode parent, DataSource origSource, DataSource uncompSource)
 
virtual bool OnInitialize ()
 
virtual void Restore ()
 
virtual void Remove ()
 
virtual void RemoveChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child, bool change)
 
virtual void InsertChild (ResourceNode child, int index)
 
virtual void InsertChild (ResourceNode child, bool change, int index)
 
void SetSizeInternal (int size)
 
virtual void Replace (string fileName)
 
virtual void Replace (ResourceNode node)
 
virtual void Replace (string fileName, FileMapProtect prot, FileOptions options)
 
virtual void ReplaceRaw (VoidPtr address, int length)
 
virtual void ReplaceRaw (FileMap map)
 
virtual void Export (string outPath)
 
void Export (FileStream outStream)
 
virtual void ExportUncompressed (string outPath)
 
void ExportUncompressed (FileStream outStream)
 
virtual void Rebuild ()
 
virtual void Rebuild (bool force)
 
virtual void Rebuild (VoidPtr address, int length, bool force)
 
virtual void OnRebuild (VoidPtr address, int length, bool force)
 
virtual int CalculateSize (bool force)
 
virtual int OnCalculateSize (bool force)
 
void Merge ()
 
void Merge (bool forceBuild)
 
ResourceNode FindChildByType (string path, bool searchChildren, params ResourceType[] types)
 
ResourceNode FindChildByType (string path, bool searchChildren, StringComparison compare, params ResourceType[] types)
 
ResourceNode FindChild (string path)
 
ResourceNode FindChild (string path, bool searchChildren)
 
ResourceNode FindChild (string path, StringComparison compare)
 
ResourceNode FindChild (string path, bool searchChildren, StringComparison compare)
 
ResourceNode[] FindChildrenByClassType (string path, Type type)
 
ResourceNode[] FindChildrenByType (string path, ResourceType type)
 
ResourceNode[] FindChildrenByTypeInGroup (string path, ResourceType type, byte group)
 
ResourceNode[] FindChildrenByName (string name)
 
unsafe string FindName (string name)
 
ResourceNode FindEmbeddedIndex (int index)
 
virtual unsafe byte[] MD5 ()
 Find the MD5 checksum of this node's data. If this node doesn't have any data (BRESGroupNode, for example), this method will return null. More...
 
string MD5Str ()
 Get the result of the MD5() function as a string of hexadecimal digits. If MD5() returns null, this method will return an empty string. More...
 
ResourceNode PrevSibling ()
 
ResourceNode NextSibling ()
 
override string ToString ()
 
virtual void SortChildren ()
 

Properties

override ResourceType ResourceFileType [get]
 
override Type[] AllowedChildTypes [get]
 
override string Compression [get, set]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.U8EntryNode
int ParentIndex [get]
 
int ChildEndIndex [get]
 
int Type [get]
 
int ID [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
string FilePath [get]
 
string FileName [get]
 
string DirectoryName [get]
 
ResourceNode RootNode [get]
 
DataSource OriginalSource [get]
 
DataSource UncompressedSource [get]
 
DataSource WorkingSource [get]
 
DataSource WorkingUncompressed [get]
 
virtual bool HasChildren [get]
 
virtual ResourceType ResourceFileType [get]
 
string NodeType [get]
 
virtual string TreePathAbsolute [get]
 
virtual string TreePath [get]
 
virtual int Level [get]
 
virtual int MaxNameLength [get]
 
virtual bool AllowDuplicateNames [get]
 
virtual bool AllowNullNames [get]
 
virtual string Name [get, set]
 
ResourceNode Parent [get, set]
 
List< ResourceNodeChildren [get]
 
int Index [get]
 
int HexIndex [get]
 
bool IsCompressed [get]
 
bool HasChanged [get, set]
 
bool IsBranch [get]
 
bool HasMerged [get]
 
virtual bool AllowSaving [get, set]
 
virtual bool IsDirty [get, set]
 
virtual uint UncompressedSize [get]
 
virtual Type[] AllowedChildTypes [get]
 
virtual string Compression [get, set]
 
virtual bool RetainChildrenOnReplace [get]
 
virtual bool supportsCompression [get]
 
static MD5CryptoServiceProvider MD5Provider [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
static ResourceNode[] FindAllSubNodes (ResourceNode root)
 
static ResourceNode FindNode (ResourceNode root, string path, bool searchChildren, StringComparison compare)
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.U8EntryNode
int _u8Parent
 
int _u8FirstNotChild
 
int _u8Type
 
int _u8Index
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
Form _mainForm
 
string _name
 
string _origPath
 
ResourceNode _parent
 
List< ResourceNode_children = new List<ResourceNode>()
 
int _calcSize
 
EventHandler UpdateControl
 
MoveEventHandler MovedDown
 
ResourceEventHandler Renamed
 
ResourceEventHandler PropertyChanged
 
ResourceEventHandler Replaced
 
ResourceEventHandler Restored
 
ResourceChildEventHandler ChildRemoved
 
bool _isPopulating
 
bool _replaced
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void ForceReplacedEvent ()
 
virtual void MergeInternal ()
 
- Events inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
SelectEventHandler SelectChild
 
EventHandler UpdateProps
 
MoveEventHandler MovedUp
 
ResourceEventHandler Disposing
 
ResourceChildEventHandler ChildAdded
 
ResourceChildInsertEventHandler ChildInserted
 

Member Function Documentation

◆ Export()

override void BrawlLib.SSBB.ResourceNodes.U8Node.Export ( string  outPath)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

258 {
259 ExportNonYaz0(outPath);
260 }
void ExportNonYaz0(string outPath)
Definition: U8Node.cs:278

◆ ExportCompressed()

void BrawlLib.SSBB.ResourceNodes.U8Node.ExportCompressed ( string  outPath)
inline
284 {
285 if (_compression != CompressionType.None)
286 {
287 base.Export(outPath);
288 }
289 else
290 {
291 using (FileStream inStream = new FileStream(Path.GetTempFileName(), FileMode.OpenOrCreate,
292 FileAccess.ReadWrite, FileShare.None, 0x8, FileOptions.SequentialScan | FileOptions.DeleteOnClose))
293 {
294 using (FileStream outStream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
295 FileShare.None, 8, FileOptions.SequentialScan))
296 {
298 WorkingUncompressed.Length, inStream, this);
299 outStream.SetLength(inStream.Length);
300 using (FileMap map = FileMap.FromStream(inStream))
301 {
302 using (FileMap outMap = FileMap.FromStream(outStream))
303 {
304 Memory.Move(outMap.Address, map.Address, (uint) map.Length);
305 }
306 }
307 }
308 }
309 }
310 }
Definition: FileMap.cs:10
int Length
Definition: FileMap.cs:19
static FileMap FromStream(FileStream stream)
Definition: FileMap.cs:117
VoidPtr Address
Definition: FileMap.cs:16
Definition: Memory.cs:8
static void Move(VoidPtr dst, VoidPtr src, uint size)
Definition: Memory.cs:9
DataSource WorkingUncompressed
Definition: ResourceNode.cs:183
Definition: Compressor.cs:37
static void Compact(CompressionType type, VoidPtr srcAddr, int srcLen, Stream outStream, ResourceNode r)
Definition: Compressor.cs:233
CompressionType
Definition: CompressionHeader.cs:9
int Length
Definition: ResourceNode.cs:32
VoidPtr Address
Definition: ResourceNode.cs:31

◆ ExportNonYaz0()

void BrawlLib.SSBB.ResourceNodes.U8Node.ExportNonYaz0 ( string  outPath)
inline
279 {
280 base.Export(outPath);
281 }

◆ ExportPair()

void BrawlLib.SSBB.ResourceNodes.U8Node.ExportPair ( string  outPath)
inline
268 {
269 if (Path.HasExtension(outPath))
270 {
271 outPath = outPath.Substring(0, outPath.LastIndexOf('.'));
272 }
273
274 ExportNonYaz0(outPath + ".arc");
275 ExportCompressed(outPath + ".szs");
276 }
void ExportCompressed(string outPath)
Definition: U8Node.cs:283

◆ ExportSZS()

void BrawlLib.SSBB.ResourceNodes.U8Node.ExportSZS ( string  outPath)
inline
263 {
264 ExportCompressed(outPath);
265 }

◆ ExtractToFolder() [1/3]

void BrawlLib.SSBB.ResourceNodes.U8Node.ExtractToFolder ( string  outFolder)
inline
318 {
319 ExtractToFolder(outFolder, ".tex0", ".mdl0");
320 }
void ExtractToFolder(string outFolder)
Definition: U8Node.cs:317

◆ ExtractToFolder() [2/3]

void BrawlLib.SSBB.ResourceNodes.U8Node.ExtractToFolder ( string  outFolder,
string  imageExtension 
)
inline
323 {
324 ExtractToFolder(outFolder, imageExtension, ".mdl0");
325 }

◆ ExtractToFolder() [3/3]

void BrawlLib.SSBB.ResourceNodes.U8Node.ExtractToFolder ( string  outFolder,
string  imageExtension,
string  modelExtension 
)
inline
328 {
329 if (!Directory.Exists(outFolder))
330 {
331 Directory.CreateDirectory(outFolder);
332 }
333
334 List<string> directChildrenExportedPaths = new List<string>();
335 foreach (ResourceNode entry in Children)
336 {
337 if (entry is ARCNode)
338 {
339 ((ARCNode) entry).ExtractToFolder(
340 Path.Combine(outFolder,
341 entry.Name == null || entry.Name.Contains("<Null>", StringComparison.OrdinalIgnoreCase)
342 ? "Null"
343 : entry.Name), imageExtension, modelExtension);
344 }
345 else if (entry is BRRESNode)
346 {
347 ((BRRESNode) entry).ExportToFolder(
348 Path.Combine(outFolder,
349 entry.Name == null || entry.Name.Contains("<Null>", StringComparison.OrdinalIgnoreCase)
350 ? "Null"
351 : entry.Name), imageExtension, modelExtension);
352 }
353 else if (entry is U8Node)
354 {
355 ((U8Node) entry).ExtractToFolder(
356 Path.Combine(outFolder,
357 entry.Name == null || entry.Name.Contains("<Null>", StringComparison.OrdinalIgnoreCase)
358 ? "Null"
359 : entry.Name), imageExtension, modelExtension);
360 }
361 else if (entry is U8FolderNode)
362 {
363 ((U8FolderNode) entry).ExportToFolder(
364 Path.Combine(outFolder,
365 entry.Name == null || entry.Name.Contains("<Null>", StringComparison.OrdinalIgnoreCase)
366 ? "Null"
367 : entry.Name), imageExtension, modelExtension);
368 }
369 else
370 {
371 if (entry.WorkingSource.Length == 0)
372 {
373 continue;
374 }
375
376 string ext = FileFilters.GetDefaultExportAllExtension(entry.GetType());
377 string path = Path.Combine(outFolder, entry.Name + ext);
378
379 if (directChildrenExportedPaths.Contains(path))
380 {
381 throw new Exception(
382 $"There is more than one node underneath {Name} with the name {entry.Name}.");
383 }
384
385 directChildrenExportedPaths.Add(path);
386 entry.Export(path);
387 }
388 }
389 }
List< ResourceNode > Children
Definition: ResourceNode.cs:262

◆ OnCalculateSize()

override int BrawlLib.SSBB.ResourceNodes.U8Node.OnCalculateSize ( bool  force)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

142 {
143 _entrySize = 12;
144 int id = 1;
145
146 _stringTable = new OrderedStringTable();
147 _stringTable.Add("");
148
149 int childSize = 0;
150 foreach (ResourceNode e in Children)
151 {
152 if (e is U8EntryNode)
153 {
154 childSize += GetEntrySize(e as U8EntryNode, force, ref id);
155 }
156 }
157
158 return 0x20 + childSize + (entryLength = _stringTable.TotalSize + _entrySize).Align(0x20);
159 }
void Add(string s)
Definition: U8Node.cs:514

◆ OnInitialize()

override bool BrawlLib.SSBB.ResourceNodes.U8Node.OnInitialize ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

115 {
116 return true;
117 }

◆ OnPopulate()

override void BrawlLib.SSBB.ResourceNodes.U8Node.OnPopulate ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

29 {
30 U8Entry* first = Header->Entries;
31 uint count = first->_dataLength - 1;
32 U8Entry* entry = first + 1;
33 sbyte* table = (sbyte*) entry + count * 12;
34 List<U8EntryNode> nodes = new List<U8EntryNode>();
35 U8EntryNode e = null;
36 for (int i = 0; i < count; i++)
37 {
38 if (entry->isFolder)
39 {
40 e = new U8FolderNode {_u8Index = i, _name = new string(table + entry->_stringOffset)};
41
42 e._name = new string(table + entry->_stringOffset);
43 e._u8Index = i;
44 e._u8Parent = (int) entry->_dataOffset;
45 e._u8FirstNotChild = (int) entry->_dataLength;
46 e._u8Type = entry->_type;
47
48 e.Initialize(this, entry, 12);
49
50 nodes.Add(e);
51 }
52 else
53 {
54 DataSource source = new DataSource((VoidPtr) Header + entry->_dataOffset, (int) entry->_dataLength);
55
56 if (entry->_dataLength == 0 || (e = NodeFactory.FromSource(this, source) as U8EntryNode) == null)
57 {
58 e = new ARCEntryNode();
59 e._origSource = source;
60 e._uncompSource = source;
61 }
62
63 e._name = new string(table + entry->_stringOffset);
64 e._u8Index = i;
65 e._u8Parent = -1;
66 e._u8FirstNotChild = -1;
67 e._u8Type = entry->_type;
68
69 e.Initialize(this, e.OriginalSource, e.UncompressedSource);
70
71 nodes.Add(e);
72 }
73
74 entry++;
75 }
76
77 foreach (U8EntryNode x in nodes)
78 {
79 if (x._u8Type == 1)
80 {
81 if (x._u8Parent == 0)
82 {
83 x.Parent = this;
84 }
85 else if (x._u8Parent < nodes.Count)
86 {
87 x.Parent = nodes[x._u8Parent - 1];
88 }
89
90 U8EntryNode t = null;
91 if (x._u8Index + 1 < nodes.Count)
92 {
93 t = nodes[x._u8Index + 1];
94 }
95
96 while (t != null)
97 {
98 t.Parent = x;
99 if (t._u8Index + 1 < nodes.Count && x.ChildEndIndex - 1 != nodes[t._u8Index + 1]._u8Index)
100 {
101 t = nodes[t._u8Index + 1];
102 }
103 else
104 {
105 t = null;
106 }
107 }
108 }
109 }
110
111 IsDirty = false; //Clear up changes from parent reassignments
112 }
virtual bool IsDirty
Definition: ResourceNode.cs:344
string _name
Definition: ResourceNode.cs:139
int _u8Index
Definition: U8Node.cs:396
Definition: VoidPtr.cs:9
Definition: U8.cs:33
byte _type
Definition: U8.cs:36
bool isFolder
Definition: U8.cs:52
buint _dataOffset
Definition: U8.cs:38
buint _dataLength
Definition: U8.cs:39
BUInt24 _stringOffset
Definition: U8.cs:37
U8Entry * Entries
Definition: U8.cs:28

◆ OnRebuild()

override void BrawlLib.SSBB.ResourceNodes.U8Node.OnRebuild ( VoidPtr  address,
int  length,
bool  force 
)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

234 {
235 U8* header = (U8*) address;
236 header->_tag = U8.Tag;
237 header->_entriesLength = (uint) entryLength;
238 header->_entriesOffset = 0x20;
239
240 VoidPtr dataAddress = address + 0x20 + entryLength.Align(0x20);
241 U8Entry* entries = (U8Entry*) (address + 0x20);
242 VoidPtr tableAddr = address + 0x20 + _entrySize;
243 _stringTable.WriteTable(tableAddr);
244
245 header->_firstOffset = (uint) (dataAddress - address);
246
247 entries->_dataLength = (uint) (_entrySize / 12);
248 entries->_type = 1;
249 entries++;
250
251 foreach (U8EntryNode b in Children)
252 {
253 RebuildNode(address, b, ref entries, tableAddr, ref dataAddress, force);
254 }
255 }
void WriteTable(VoidPtr address)
Definition: U8Node.cs:545
Definition: U8.cs:8
uint _tag
Definition: U8.cs:12
buint _entriesLength
Definition: U8.cs:14
const uint Tag
Definition: U8.cs:10
buint _firstOffset
Definition: U8.cs:15
buint _entriesOffset
Definition: U8.cs:13

Property Documentation

◆ AllowedChildTypes

override Type [] BrawlLib.SSBB.ResourceNodes.U8Node.AllowedChildTypes
get

◆ Compression

override string BrawlLib.SSBB.ResourceNodes.U8Node.Compression
getset
23 {
24 get => base.Compression;
25 set => base.Compression = value;
26 }

◆ ResourceFileType

override ResourceType BrawlLib.SSBB.ResourceNodes.U8Node.ResourceFileType
get

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