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

Public Member Functions

Bitmap GetImage (int index)
 
override void OnPopulate ()
 
override bool OnInitialize ()
 
bool HasFolder< T > ()
 
BRESGroupNode GetFolder< T > ()
 
BRESGroupNode GetOrCreateFolder< T > ()
 
CreateResource< T > (string name)
 
void ExportToFolder (string outFolder)
 
void ExportToFolder (string outFolder, string imageExtension)
 
void ExportToFolder (string outFolder, string imageExtension, string modelExtension)
 
void ReplaceFromFolder (string inFolder)
 
void ReplaceFromFolder (string inFolder, string imageExtension)
 
void ImportFolder (string inFolder)
 
override int OnCalculateSize (bool force)
 
override void OnRebuild (VoidPtr address, int size, bool force)
 
void ImportGIF (string file)
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
bool isModelData ()
 
bool isTextureData ()
 
void UpdateName ()
 
override void Initialize (ResourceNode parent, DataSource origSource, DataSource uncompSource)
 
- 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 ()
 
Bitmap GetImage (int index)
 

Properties

override ResourceType ResourceFileType [get]
 
override Type[] AllowedChildTypes [get]
 
int ImageCount [get]
 
int NumModels [get]
 
int NumFacepoints [get]
 
int NumVertices [get]
 
int NumTriangles [get]
 
int NumNodes [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
override ResourceType ResourceFileType [get]
 
override string Compression [get, set]
 
ARCFileType FileType [get, set]
 
short FileIndex [get, set]
 
byte GroupID [get, set]
 
int AbsoluteIndex [get]
 
short RedirectIndex [get, set]
 
string RedirectTargetName [get]
 
string RedirectTarget [get, set]
 
ResourceNode RedirectNode [get]
 
- 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]
 
- Properties inherited from BrawlLib.Imaging.IImageSource
int ImageCount [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.ARCEntryNode
ResourceType _resourceType = ResourceType.ARCEntry
 
- 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.ARCEntryNode
virtual string GetName ()
 
virtual string GetName (string fileType)
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void ForceReplacedEvent ()
 
virtual void MergeInternal ()
 
- Protected Attributes inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
ResourceNode redirectTargetNode
 
- Events inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
SelectEventHandler SelectChild
 
EventHandler UpdateProps
 
MoveEventHandler MovedUp
 
ResourceEventHandler Disposing
 
ResourceChildEventHandler ChildAdded
 
ResourceChildInsertEventHandler ChildInserted
 

Member Function Documentation

◆ CreateResource< T >()

T BrawlLib.SSBB.ResourceNodes.BRRESNode.CreateResource< T > ( string  name)
inline
Type Constraints
T :BRESEntryNode 
323 : BRESEntryNode
324 {
325 BRESGroupNode group = GetOrCreateFolder<T>();
326 if (group == null)
327 {
328 return null;
329 }
330
331 T n = Activator.CreateInstance<T>();
332 n.Name = group.FindName(name);
333 group.AddChild(n);
334
335 return n;
336 }
BRESGroupNode GetOrCreateFolder< T >()
Definition: BRRESNode.cs:241

◆ ExportToFolder() [1/3]

void BrawlLib.SSBB.ResourceNodes.BRRESNode.ExportToFolder ( string  outFolder)
inline
339 {
340 ExportToFolder(outFolder, ".tex0");
341 }
void ExportToFolder(string outFolder)
Definition: BRRESNode.cs:338

◆ ExportToFolder() [2/3]

void BrawlLib.SSBB.ResourceNodes.BRRESNode.ExportToFolder ( string  outFolder,
string  imageExtension 
)
inline
344 {
345 ExportToFolder(outFolder, imageExtension, ".mdl0");
346 }

◆ ExportToFolder() [3/3]

void BrawlLib.SSBB.ResourceNodes.BRRESNode.ExportToFolder ( string  outFolder,
string  imageExtension,
string  modelExtension 
)
inline
349 {
350 if (!Directory.Exists(outFolder))
351 {
352 Directory.CreateDirectory(outFolder);
353 }
354
355 string ext = "";
356 bool extract = true;
357 foreach (BRESGroupNode group in Children)
358 {
359 extract = true;
360 if (group.Type == BRESGroupNode.BRESGroupType.Textures)
361 {
362 ext = imageExtension;
363 }
364 else if (group.Type == BRESGroupNode.BRESGroupType.Models)
365 {
366 ext = modelExtension;
367 }
368 else if (group.Type == BRESGroupNode.BRESGroupType.CHR0)
369 {
370 ext = ".chr0";
371 }
372 else if (group.Type == BRESGroupNode.BRESGroupType.CLR0)
373 {
374 ext = ".clr0";
375 }
376 else if (group.Type == BRESGroupNode.BRESGroupType.SRT0)
377 {
378 ext = ".srt0";
379 }
380 else if (group.Type == BRESGroupNode.BRESGroupType.SHP0)
381 {
382 ext = ".shp0";
383 }
384 else if (group.Type == BRESGroupNode.BRESGroupType.PAT0)
385 {
386 ext = ".pat0";
387 }
388 else if (group.Type == BRESGroupNode.BRESGroupType.VIS0)
389 {
390 ext = ".vis0";
391 }
392 else if (group.Type == BRESGroupNode.BRESGroupType.SCN0)
393 {
394 ext = ".scn0";
395 }
396 else if (group.Type == BRESGroupNode.BRESGroupType.Palettes)
397 {
398 ext = ".plt0";
399 if (imageExtension != ".tex0")
400 {
401 extract = false;
402 }
403 }
404 else
405 {
406 extract = false;
407 }
408
409 if (extract)
410 {
411 foreach (BRESEntryNode entry in group.Children)
412 {
413 entry.Export(Path.Combine(outFolder, entry.Name + ext));
414 }
415 }
416 }
417 }
List< ResourceNode > Children
Definition: ResourceNode.cs:262

◆ GetFolder< T >()

BRESGroupNode BrawlLib.SSBB.ResourceNodes.BRRESNode.GetFolder< T > ( )
inline
Type Constraints
T :BRESEntryNode 
220 : BRESEntryNode
221 {
222 if (!HasChildren)
223 {
224 return null;
225 }
226
227 foreach (BRESGroupNode gr in Children)
228 {
229 if (gr.HasChildren)
230 {
231 if (gr.Children[0] is T)
232 {
233 return gr;
234 }
235 }
236 }
237
238 return null;
239 }
virtual bool HasChildren
Definition: ResourceNode.cs:185

◆ GetImage()

Bitmap BrawlLib.SSBB.ResourceNodes.BRRESNode.GetImage ( int  index)
inline

Implements BrawlLib.Imaging.IImageSource.

32 {
33 if (GetFolder<TEX0Node>() == null || GetFolder<TEX0Node>().Children.Count <= index)
34 {
35 return null;
36 }
37
38 return (GetFolder<TEX0Node>().Children[index] as IImageSource)?.GetImage(0);
39 }
Definition: IImageSource.cs:7

◆ GetOrCreateFolder< T >()

BRESGroupNode BrawlLib.SSBB.ResourceNodes.BRRESNode.GetOrCreateFolder< T > ( )
inline
Type Constraints
T :BRESEntryNode 
241 : BRESEntryNode
242 {
243 string groupName;
244 BRESGroupNode.BRESGroupType type;
245 if (typeof(T) == typeof(TEX0Node))
246 {
247 type = BRESGroupNode.BRESGroupType.Textures;
248 groupName = "Textures(NW4R)";
249 }
250 else if (typeof(T) == typeof(PLT0Node))
251 {
252 type = BRESGroupNode.BRESGroupType.Palettes;
253 groupName = "Palettes(NW4R)";
254 }
255 else if (typeof(T) == typeof(MDL0Node))
256 {
257 type = BRESGroupNode.BRESGroupType.Models;
258 groupName = "3DModels(NW4R)";
259 }
260 else if (typeof(T) == typeof(CHR0Node))
261 {
262 type = BRESGroupNode.BRESGroupType.CHR0;
263 groupName = "AnmChr(NW4R)";
264 }
265 else if (typeof(T) == typeof(CLR0Node))
266 {
267 type = BRESGroupNode.BRESGroupType.CLR0;
268 groupName = "AnmClr(NW4R)";
269 }
270 else if (typeof(T) == typeof(SRT0Node))
271 {
272 type = BRESGroupNode.BRESGroupType.SRT0;
273 groupName = "AnmTexSrt(NW4R)";
274 }
275 else if (typeof(T) == typeof(PAT0Node))
276 {
277 type = BRESGroupNode.BRESGroupType.PAT0;
278 groupName = "AnmTexPat(NW4R)";
279 }
280 else if (typeof(T) == typeof(SHP0Node))
281 {
282 type = BRESGroupNode.BRESGroupType.SHP0;
283 groupName = "AnmShp(NW4R)";
284 }
285 else if (typeof(T) == typeof(VIS0Node))
286 {
287 type = BRESGroupNode.BRESGroupType.VIS0;
288 groupName = "AnmVis(NW4R)";
289 }
290 else if (typeof(T) == typeof(SCN0Node))
291 {
292 type = BRESGroupNode.BRESGroupType.SCN0;
293 groupName = "AnmScn(NW4R)";
294 }
295 else if (typeof(T) == typeof(RASDNode))
296 {
297 type = BRESGroupNode.BRESGroupType.External;
298 groupName = "External";
299 }
300 else
301 {
302 return null;
303 }
304
305 BRESGroupNode group = null;
306 foreach (BRESGroupNode node in Children)
307 {
308 if (node.Type == type)
309 {
310 group = node;
311 break;
312 }
313 }
314
315 if (group == null)
316 {
317 AddChild(group = new BRESGroupNode(groupName, type));
318 }
319
320 return group;
321 }
virtual void AddChild(ResourceNode child)
Definition: ResourceNode.cs:757

◆ HasFolder< T >()

bool BrawlLib.SSBB.ResourceNodes.BRRESNode.HasFolder< T > ( )
inline
Type Constraints
T :BRESEntryNode 
199 : BRESEntryNode
200 {
201 if (!HasChildren)
202 {
203 return false;
204 }
205
206 foreach (BRESGroupNode gr in Children)
207 {
208 if (gr.HasChildren)
209 {
210 if (gr.Children[0] is T)
211 {
212 return true;
213 }
214 }
215 }
216
217 return false;
218 }

◆ ImportFolder()

void BrawlLib.SSBB.ResourceNodes.BRRESNode.ImportFolder ( string  inFolder)
inline
489 {
490 DirectoryInfo dir = new DirectoryInfo(inFolder);
491 FileInfo[] files;
492
493 files = dir.GetFiles();
494 foreach (FileInfo info in files)
495 {
496 string ext = Path.GetExtension(info.FullName).ToUpper();
497 if (ext == ".PNG" || ext == ".TGA" || ext == ".BMP" || ext == ".JPG" || ext == ".JPEG" ||
498 ext == ".GIF" || ext == ".TIF" || ext == ".TIFF")
499 {
501 {
502 dlg.ImageSource = info.FullName;
503 dlg.ShowDialog(null, this);
504 }
505 }
506 else if (ext == ".TEX0")
507 {
508 TEX0Node node = NodeFactory.FromFile(null, info.FullName) as TEX0Node;
509 GetOrCreateFolder<TEX0Node>().AddChild(node);
510 }
511 else if (ext == ".MDL0")
512 {
513 MDL0Node node = NodeFactory.FromFile(null, info.FullName) as MDL0Node;
514 GetOrCreateFolder<MDL0Node>().AddChild(node);
515 }
516 else if (ext == ".CHR0")
517 {
518 CHR0Node node = NodeFactory.FromFile(null, info.FullName) as CHR0Node;
519 GetOrCreateFolder<CHR0Node>().AddChild(node);
520 }
521 else if (ext == ".CLR0")
522 {
523 CLR0Node node = NodeFactory.FromFile(null, info.FullName) as CLR0Node;
524 GetOrCreateFolder<CLR0Node>().AddChild(node);
525 }
526 else if (ext == ".SRT0")
527 {
528 SRT0Node node = NodeFactory.FromFile(null, info.FullName) as SRT0Node;
529 GetOrCreateFolder<SRT0Node>().AddChild(node);
530 }
531 else if (ext == ".SHP0")
532 {
533 SHP0Node node = NodeFactory.FromFile(null, info.FullName) as SHP0Node;
534 GetOrCreateFolder<SHP0Node>().AddChild(node);
535 }
536 else if (ext == ".PAT0")
537 {
538 PAT0Node node = NodeFactory.FromFile(null, info.FullName) as PAT0Node;
539 GetOrCreateFolder<PAT0Node>().AddChild(node);
540 }
541 else if (ext == ".VIS0")
542 {
543 VIS0Node node = NodeFactory.FromFile(null, info.FullName) as VIS0Node;
544 GetOrCreateFolder<VIS0Node>().AddChild(node);
545 }
546 }
547 }
Definition: TextureConverterDialog.cs:24
DialogResult ShowDialog(IWin32Window owner, BRRESNode parent)
Definition: TextureConverterDialog.cs:164

◆ ImportGIF()

void BrawlLib.SSBB.ResourceNodes.BRRESNode.ImportGIF ( string  file)
inline
637 {
638 Action<object, DoWorkEventArgs> work = (object sender, DoWorkEventArgs e) =>
639 {
640 GifDecoder decoder = new GifDecoder();
641 decoder.Read(file, null);
642 e.Result = decoder;
643 };
644 Action<object, RunWorkerCompletedEventArgs> completed = (object sender, RunWorkerCompletedEventArgs e) =>
645 {
646 GifDecoder decoder = e.Result as GifDecoder;
647 string s = Path.GetFileNameWithoutExtension(file);
648 PAT0Node p = CreateResource<PAT0Node>(s);
649 p._loop = true;
650 p.CreateEntry();
651
652 PAT0TextureNode textureNode = p.Children[0].Children[0] as PAT0TextureNode;
653 PAT0TextureEntryNode entry = textureNode.Children[0] as PAT0TextureEntryNode;
654
655 //Get the number of images in the file
656 int frames = decoder.GetFrameCount();
657
658 //The framecount will be created by adding up each image delay.
659 float frameCount = 0;
660
661 bool resized = false;
662 int w = 0, h = 0;
663 Action<int, int> onResized = (newW, newH) =>
664 {
665 if (resized != true)
666 {
667 w = newW;
668 h = newH;
669 resized = true;
670 }
671 };
672
674 {
675 using (ProgressWindow progress = new ProgressWindow(RootNode._mainForm, "GIF to PAT0 converter",
676 "Converting, please wait...", true))
677 {
678 Bitmap prev = null;
679
680 progress.Begin(0, frames, 0);
681 for (int i = 0; i < frames; i++, entry = new PAT0TextureEntryNode())
682 {
683 if (progress.Cancelled)
684 {
685 break;
686 }
687
688 string name = s + "." + i;
689
690 dlg.ImageSource = name + ".";
691
692 using (Bitmap img = (Bitmap) decoder.GetFrame(i))
693 {
694 if (i == 0)
695 {
696 dlg.LoadImages(img.Copy());
697 dlg.Resized += onResized;
698 if (dlg.ShowDialog(null, this) != DialogResult.OK)
699 {
700 return;
701 }
702
703 textureNode._hasTex = dlg.TextureData != null;
704 textureNode._hasPlt = dlg.PaletteData != null;
705
706 prev = img.Copy();
707 }
708 else
709 {
710 //Draw the current image over the previous
711 //This is because some GIFs use pixels of the previous frame
712 //in order to compress the overall image data
713 using (Graphics graphics = Graphics.FromImage(prev))
714 {
715 graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
716 graphics.CompositingQuality = CompositingQuality.HighQuality;
717 graphics.CompositingMode = CompositingMode.SourceOver;
718 graphics.SmoothingMode = SmoothingMode.HighQuality;
719 graphics.DrawImage(img, 0, 0, prev.Width, prev.Height);
720 }
721
722 dlg.LoadImages(prev.Copy());
723 if (resized)
724 {
725 dlg.ResizeImage(w, h);
726 }
727 else
728 {
729 dlg.UpdatePreview();
730 }
731
732 dlg.EncodeSource();
733
734 textureNode.AddChild(entry);
735 }
736 }
737
738 entry._frame = (float) Math.Round(frameCount, 2);
739 frameCount += decoder.GetDelay(i) / 1000.0f * 60.0f;
740
741 if (textureNode._hasTex)
742 {
743 entry.Texture = name;
744 }
745
746 if (textureNode._hasPlt)
747 {
748 entry.Palette = name;
749 }
750
751 progress.Update(progress.CurrentValue + 1);
752 }
753
754 progress.Finish();
755 prev?.Dispose();
756 }
757 }
758
759 p._numFrames = (ushort) (frameCount + 0.5f);
760 };
761
762 using (BackgroundWorker b = new BackgroundWorker())
763 {
764 b.DoWork += new DoWorkEventHandler(work);
765 b.RunWorkerCompleted += new RunWorkerCompletedEventHandler(completed);
766 b.RunWorkerAsync();
767 }
768 }
Definition: GifDecoder.cs:54
Image GetFrame(int n)
Definition: GifDecoder.cs:342
int GetFrameCount()
Definition: GifDecoder.cs:156
int GetDelay(int n)
Definition: GifDecoder.cs:140
int Read(Stream inStream)
Definition: GifDecoder.cs:369
Definition: ProgressWindow.cs:8
void Update(float value)
Definition: ProgressWindow.cs:79
void Begin(float min, float max, float current)
Definition: ProgressWindow.cs:51
void Finish()
Definition: ProgressWindow.cs:86
float CurrentValue
Definition: ProgressWindow.cs:114
bool Cancelled
Definition: ProgressWindow.cs:120
void ResizeImage(int w, int h)
Definition: TextureConverterDialog.cs:1797
bool LoadImages(string path)
Definition: TextureConverterDialog.cs:415
void EncodeSource()
Definition: TextureConverterDialog.cs:922
ResourceNode RootNode
Definition: ResourceNode.cs:175
Form _mainForm
Definition: ResourceNode.cs:130

◆ OnCalculateSize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

553 {
554 int size = BRESHeader.Size;
555 _rootSize = 0x20 + Children.Count * 0x10;
556
557 //Get entry count and data start
558 _numEntries = 0;
559 //Children.Sort(NodeComparer.Instance);
560 foreach (BRESGroupNode n in Children)
561 {
562 //n.Children.Sort(NodeComparer.Instance);
563 _rootSize += n.Children.Count * 0x10 + 0x18;
564 _numEntries += n.Children.Count;
565 }
566
567 size += _rootSize;
568
569 //Get strings and advance entry offset
570 _stringTable.Clear();
571 foreach (BRESGroupNode n in Children)
572 {
573 _stringTable.Add(n.Name);
574 foreach (BRESEntryNode c in n.Children)
575 {
576 size = size.Align(c.DataAlign) + c.CalculateSize(force);
577 c.GetStrings(_stringTable);
578 }
579 }
580
581 _strOffset = size = size.Align(4);
582
583 size += _stringTable.GetTotalSize();
584
585 return size.Align(0x80);
586 }
int GetTotalSize()
Definition: StringTable.cs:21
void Add(string s)
Definition: StringTable.cs:13
void Clear()
Definition: StringTable.cs:32
Definition: BRES.cs:8
const int Size
Definition: BRES.cs:10

◆ OnInitialize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

193 {
194 base.OnInitialize();
195
196 return Group->_numEntries > 0;
197 }
bint _numEntries
Definition: Common.cs:384

◆ OnPopulate()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

183 {
184 ResourceGroup* group = Group;
185 for (int i = 0; i < group->_numEntries; i++)
186 {
187 new BRESGroupNode(new string((sbyte*) group + group->First[i]._stringOffset)).Initialize(this,
188 (VoidPtr) group + group->First[i]._dataOffset, 0);
189 }
190 }
Definition: VoidPtr.cs:9
bint _dataOffset
Definition: Common.cs:480
bint _stringOffset
Definition: Common.cs:479
Definition: Common.cs:380
ResourceEntry * First
Definition: Common.cs:405

◆ OnRebuild()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

589 {
590 BRESHeader* header = (BRESHeader*) address;
591 *header = new BRESHeader(size, _numEntries + 1);
592
593 ROOTHeader* rootHeader = header->First;
594 *rootHeader = new ROOTHeader(_rootSize, Children.Count);
595
596 ResourceGroup* pMaster = &rootHeader->_master;
597 ResourceGroup* rGroup = (ResourceGroup*) pMaster->EndAddress;
598
599 //Write string table
600 _stringTable.WriteTable(address + _strOffset);
601
602 VoidPtr dataAddr = (VoidPtr) rootHeader + _rootSize;
603
604 int gIndex = 1;
605 foreach (BRESGroupNode g in Children)
606 {
607 ResourceEntry.Build(pMaster, gIndex++, rGroup, (BRESString*) _stringTable[g.Name]);
608
609 *rGroup = new ResourceGroup(g.Children.Count);
610 ResourceEntry* nEntry = rGroup->First;
611
612 int rIndex = 1;
613 foreach (BRESEntryNode n in g.Children)
614 {
615 //Align data
616 dataAddr = ((int) dataAddr).Align(n.DataAlign);
617
618 ResourceEntry.Build(rGroup, rIndex++, dataAddr, (BRESString*) _stringTable[n.Name]);
619
620 //Rebuild entry
621 int len = n._calcSize;
622 n.Rebuild(dataAddr, len, force);
623 n.PostProcess(address, dataAddr, len, _stringTable);
624 dataAddr += len;
625 }
626
627 g._changed = false;
628
629 //Advance to next group
630 rGroup = (ResourceGroup*) rGroup->EndAddress;
631 }
632
633 _stringTable.Clear();
634 }
void WriteTable(VoidPtr address)
Definition: StringTable.cs:50
ROOTHeader * First
Definition: BRES.cs:20
Definition: BRES.cs:126
Definition: BRES.cs:59
ResourceGroup _master
Definition: BRES.cs:64
Definition: Common.cs:472
static void Build(ResourceGroup *group, int index, VoidPtr dataAddress, BRESString *pString)
Definition: Common.cs:557
VoidPtr EndAddress
Definition: Common.cs:406

◆ ReplaceFromFolder() [1/2]

void BrawlLib.SSBB.ResourceNodes.BRRESNode.ReplaceFromFolder ( string  inFolder)
inline
420 {
421 ReplaceFromFolder(inFolder, ".tex0");
422 }
void ReplaceFromFolder(string inFolder)
Definition: BRRESNode.cs:419

◆ ReplaceFromFolder() [2/2]

void BrawlLib.SSBB.ResourceNodes.BRRESNode.ReplaceFromFolder ( string  inFolder,
string  imageExtension 
)
inline
425 {
426 DirectoryInfo dir = new DirectoryInfo(inFolder);
427 FileInfo[] files = dir.GetFiles();
428 string ext = "*";
429 foreach (BRESGroupNode group in Children)
430 {
431 if (group.Type == BRESGroupNode.BRESGroupType.Textures)
432 {
433 ext = imageExtension;
434 }
435 else if (group.Type == BRESGroupNode.BRESGroupType.Palettes)
436 {
437 ext = ".plt0";
438 }
439 else if (group.Type == BRESGroupNode.BRESGroupType.Models)
440 {
441 ext = ".mdl0";
442 }
443 else if (group.Type == BRESGroupNode.BRESGroupType.CHR0)
444 {
445 ext = ".chr0";
446 }
447 else if (group.Type == BRESGroupNode.BRESGroupType.CLR0)
448 {
449 ext = ".clr0";
450 }
451 else if (group.Type == BRESGroupNode.BRESGroupType.SRT0)
452 {
453 ext = ".srt0";
454 }
455 else if (group.Type == BRESGroupNode.BRESGroupType.SHP0)
456 {
457 ext = ".shp0";
458 }
459 else if (group.Type == BRESGroupNode.BRESGroupType.PAT0)
460 {
461 ext = ".pat0";
462 }
463 else if (group.Type == BRESGroupNode.BRESGroupType.VIS0)
464 {
465 ext = ".vis0";
466 }
467 else if (group.Type == BRESGroupNode.BRESGroupType.SCN0)
468 {
469 ext = ".scn0";
470 }
471
472 foreach (BRESEntryNode entry in group.Children)
473 {
474 //Find file name for entry
475 foreach (FileInfo info in files)
476 {
477 if (info.Extension.Equals(ext, StringComparison.OrdinalIgnoreCase) &&
478 info.Name.Equals(entry.Name + ext, StringComparison.OrdinalIgnoreCase))
479 {
480 entry.Replace(info.FullName);
481 break;
482 }
483 }
484 }
485 }
486 }

Property Documentation

◆ AllowedChildTypes

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

◆ ImageCount

int BrawlLib.SSBB.ResourceNodes.BRRESNode.ImageCount
get

◆ NumFacepoints

int BrawlLib.SSBB.ResourceNodes.BRRESNode.NumFacepoints
get
73 {
74 get
75 {
76 if (Properties.Settings.Default.CompatibilityMode)
77 {
78 return -1;
79 }
80
81 //Populate();
82 if (GetFolder<MDL0Node>() == null)
83 {
84 return 0;
85 }
86
87 int count = 0;
88 foreach (MDL0Node m in GetFolder<MDL0Node>().Children)
89 {
90 count += m.NumFacepoints;
91 }
92
93 return count;
94 }
95 }

◆ NumModels

int BrawlLib.SSBB.ResourceNodes.BRRESNode.NumModels
get
45 {
46 get
47 {
48 if (Properties.Settings.Default.CompatibilityMode)
49 {
50 return -1;
51 }
52
53 //Populate();
54 if (GetFolder<MDL0Node>() == null)
55 {
56 return 0;
57 }
58
59 int count = 0;
60 foreach (MDL0Node m in GetFolder<MDL0Node>().Children)
61 {
62 count += 1;
63 }
64
65 return count;
66 }
67 }

◆ NumNodes

int BrawlLib.SSBB.ResourceNodes.BRRESNode.NumNodes
get
156 {
157 get
158 {
159 if (Properties.Settings.Default.CompatibilityMode)
160 {
161 return -1;
162 }
163
164 //Populate();
165 if (GetFolder<MDL0Node>() == null)
166 {
167 return 0;
168 }
169
170 int count = 0;
171 foreach (MDL0Node m in GetFolder<MDL0Node>().Children)
172 {
173 count += m.NumNodes;
174 }
175
176 return count;
177 }
178 }

◆ NumTriangles

int BrawlLib.SSBB.ResourceNodes.BRRESNode.NumTriangles
get
129 {
130 get
131 {
132 if (Properties.Settings.Default.CompatibilityMode)
133 {
134 return -1;
135 }
136
137 //Populate();
138 if (GetFolder<MDL0Node>() == null)
139 {
140 return 0;
141 }
142
143 int count = 0;
144 foreach (MDL0Node m in GetFolder<MDL0Node>().Children)
145 {
146 count += m.NumTriangles;
147 }
148
149 return count;
150 }
151 }

◆ NumVertices

int BrawlLib.SSBB.ResourceNodes.BRRESNode.NumVertices
get
102 {
103 get
104 {
105 if (Properties.Settings.Default.CompatibilityMode)
106 {
107 return -1;
108 }
109
110 //Populate();
111 if (GetFolder<MDL0Node>() == null)
112 {
113 return 0;
114 }
115
116 int count = 0;
117 foreach (MDL0Node m in GetFolder<MDL0Node>().Children)
118 {
119 count += m.NumVertices;
120 }
121
122 return count;
123 }
124 }

◆ ResourceFileType

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

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