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

Public Member Functions

override bool OnInitialize ()
 
override void OnPopulate ()
 
override void OnRebuild (VoidPtr address, int length, bool force)
 
override void Export (string outPath)
 
override int OnCalculateSize (bool force)
 
void CreateEntry ()
 
- 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 ()
 

Public Attributes

int[] _usageIndices = new int[11]
 
TextureIndices _texIndices
 
IndirectTextureIndices _indIndices
 
- 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
 

Properties

override ResourceType ResourceFileType [get]
 
override Type[] AllowedChildTypes [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)
 
- 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

◆ CreateEntry()

void BrawlLib.SSBB.ResourceNodes.SRT0EntryNode.CreateEntry ( )
inline
672 {
673 bool indirect = false;
674 int value = 0;
675 foreach (SRT0TextureNode t in Children)
676 {
677 if (t._textureIndex == value && !t._indirect)
678 {
679 value++;
680 }
681 }
682
683 if (value == 8)
684 {
685 indirect = true;
686 value = 0;
687 foreach (SRT0TextureNode t in Children)
688 {
689 if (t._textureIndex == value && t._indirect)
690 {
691 value++;
692 }
693 }
694
695 if (value == 3)
696 {
697 return;
698 }
699 }
700
701 SRT0TextureNode node = new SRT0TextureNode(value, indirect);
702 AddChild(node);
703 }
virtual void AddChild(ResourceNode child)
Definition: ResourceNode.cs:757
List< ResourceNode > Children
Definition: ResourceNode.cs:262

◆ Export()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

597 {
598 StringTable table = new StringTable {Name};
599
600 int totalLength = OnCalculateSize(true) + table.GetTotalSize();
601 using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
602 FileShare.None, 8, FileOptions.RandomAccess))
603 {
604 stream.SetLength(totalLength);
605 using (FileMap map = FileMap.FromStream(stream))
606 {
607 _dataAddr = map.Address + _entryLength;
608 Rebuild(map.Address, totalLength, true);
609 table.WriteTable(_dataAddr + _dataLength);
610 PostProcess(map.Address, table);
611 }
612 }
613
614 //string temp1 = Path.GetTempFileName();
615 //string temp2 = Path.GetTempFileName();
616
617 //Parent.Rebuild();
618 //Parent.Export(temp1);
619
620 //int index = Parent.Children.IndexOf(this);
621
622 //using (ResourceNode copied = NodeFactory.FromFile(null, temp1)) {
623 // for (int i = 0; i < index; i++) {
624 // copied.RemoveChild(copied.Children[0]);
625 // }
626 // while (copied.Children.Count > 1) {
627 // copied.RemoveChild(copied.Children[1]);
628 // }
629 // copied.Export(temp2);
630 //}
631
632 //using (ResourceNode copied = NodeFactory.FromFile(null, temp2)) {
633 // SRT0EntryNode entry = (SRT0EntryNode)copied.Children[0];
634 // int dataLen = entry.OnCalculateSize(true);
635 // using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 8, FileOptions.RandomAccess)) {
636 // stream.SetLength(dataLen);
637 // using (FileMap map = FileMap.FromStream(stream))
638 // Memory.Move(map.Address, entry.WorkingSource.Address, (uint)dataLen);
639 // }
640 //}
641
642 //File.Delete(temp1);
643 //File.Delete(temp2);
644 }
Definition: FileMap.cs:10
static FileMap FromStream(FileStream stream)
Definition: FileMap.cs:117
VoidPtr Address
Definition: FileMap.cs:16
virtual void Rebuild()
Definition: ResourceNode.cs:987
virtual string Name
Definition: ResourceNode.cs:223
override int OnCalculateSize(bool force)
Definition: SRT0Node.cs:646

◆ OnCalculateSize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

647 {
648 _texIndices = 0;
649 _indIndices = 0;
650 _dataLength = 0;
651 _entryLength = 12;
652 foreach (SRT0TextureNode n in Children)
653 {
654 if (n._indirect)
655 {
656 _indIndices |= (IndirectTextureIndices) (1 << n._textureIndex);
657 }
658 else
659 {
660 _texIndices |= (TextureIndices) (1 << n._textureIndex);
661 }
662
663 n.CalculateSize(true);
664 _entryLength += 4 + n._entryLength;
665 _dataLength += n._dataLength;
666 }
667
668 return _entryLength + _dataLength;
669 }
TextureIndices _texIndices
Definition: SRT0Node.cs:521
IndirectTextureIndices _indIndices
Definition: SRT0Node.cs:522
IndirectTextureIndices
Definition: SRT0.cs:230
TextureIndices
Definition: SRT0.cs:217

◆ OnInitialize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

525 {
526 if (_name == null && Header->_stringOffset != 0)
527 {
528 _name = Header->ResourceString;
529 }
530
531 _texIndices = (TextureIndices) (int) Header->_textureIndices;
532 _indIndices = (IndirectTextureIndices) (int) Header->_indirectIndices;
533
534 for (int i = 0; i < 8; i++)
535 {
536 _usageIndices[i] = (Header->_textureIndices >> i) & 1;
537 }
538
539 for (int i = 0; i < 3; i++)
540 {
541 _usageIndices[i + 8] = (Header->_indirectIndices >> i) & 1;
542 }
543
544 return _texIndices > 0 || _indIndices > 0;
545 }
string _name
Definition: ResourceNode.cs:139
int[] _usageIndices
Definition: SRT0Node.cs:519

◆ OnPopulate()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

554 {
555 VoidPtr addr;
556 int index = 0;
557 for (int i = 0; i < 11; i++)
558 {
559 if (_usageIndices[i] == 1)
560 {
561 new SRT0TextureNode(i >= 8 ? i - 8 : i, i >= 8).Initialize(this,
562 new DataSource(addr = Header->GetEntry(index++), ((SRT0TextureEntry*) addr)->Code.DataSize()));
563 }
564 }
565 }
Definition: VoidPtr.cs:9

◆ OnRebuild()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

571 {
572 SRT0Entry* header = (SRT0Entry*) address;
573
574 header->_textureIndices = (int) _texIndices;
575 header->_indirectIndices = (int) _indIndices;
576
577 int offset = 12 + Children.Count * 4;
578 VoidPtr entryAddress = address + offset;
579
580 int prevOffset = 0;
581 for (int i = 0; i < Children.Count; i++)
582 {
583 SRT0TextureNode n = (SRT0TextureNode) Children[i];
584
585 n._dataAddr = _dataAddr;
586
587 header->SetOffset(i, offset + prevOffset);
588 n.Rebuild(entryAddress, n._entryLength, true);
589
590 entryAddress += n._entryLength;
591 prevOffset += n._entryLength;
592 _dataAddr += n._dataLength;
593 }
594 }

Member Data Documentation

◆ _indIndices

IndirectTextureIndices BrawlLib.SSBB.ResourceNodes.SRT0EntryNode._indIndices

◆ _texIndices

TextureIndices BrawlLib.SSBB.ResourceNodes.SRT0EntryNode._texIndices

◆ _usageIndices

int [] BrawlLib.SSBB.ResourceNodes.SRT0EntryNode._usageIndices = new int[11]

Property Documentation

◆ AllowedChildTypes

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

◆ ResourceFileType

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

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