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

Public Member Functions

 TEX0Node ()
 
void SetSharesData (bool value, bool showMessages)
 
PLT0Node GetPaletteNode ()
 
override bool OnInitialize ()
 
override int OnCalculateSize (bool force)
 
override void OnRebuild (VoidPtr address, int length, bool force)
 
Bitmap GetImage (int index)
 
Bitmap GetImage (int index, PLT0Node plt)
 
override void Remove ()
 
void Remove (bool forceRemovePalettes)
 
void Replace (Bitmap bmp)
 
override void Replace (string fileName)
 
override void Export (string outPath)
 
PAT0Node GeneratePAT0 ()
 
PAT0Node GeneratePAT0 (bool force)
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.BRESEntryNode
override bool OnInitialize ()
 
override void Export (string outPath)
 
override byte[] MD5 ()
 Find the MD5 checksum of this node's data. Before calculating the checksum, the data will be copied to a temporary area in memory and PostProcess will be run just as in Export(). More...
 
- 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)
 

Public Attributes

int texSortNum
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.BRESEntryNode
int _version
 
string _originalPath
 
- 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 int DataAlign [get]
 
override int[] SupportedVersions [get]
 
override string Tag [get]
 
bool SharesData [get, set]
 
int Width [get]
 
int Height [get]
 
WiiPixelFormat Format [get]
 
int LevelOfDetail [get]
 
bool HasPalette [get]
 
override string Name [get, set]
 
int ImageCount [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.BRESEntryNode
virtual int DataAlign [get]
 
BRRESNode BRESNode [get]
 
virtual int[] SupportedVersions [get]
 
virtual string Tag [get]
 
int Version [get, set]
 
string OriginalPath [get, set]
 
UserDataCollection UserEntries [get, set]
 
- 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)
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.BRESEntryNode
virtual void OnVersionChanged (int previousVersion)
 
- 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
 

Constructor & Destructor Documentation

◆ TEX0Node()

BrawlLib.SSBB.ResourceNodes.TEX0Node.TEX0Node ( )
inline
32 {
33 _version = 1;
34 }
int _version
Definition: BRRESNode.cs:1045

Member Function Documentation

◆ Export()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.BRESEntryNode.

435 {
436 if (outPath.EndsWith(".png"))
437 {
438 using (Bitmap bmp = GetImage(0))
439 {
440 bmp.Save(outPath, ImageFormat.Png);
441 }
442 }
443 else if (outPath.EndsWith(".tga"))
444 {
445 using (Bitmap bmp = GetImage(0))
446 {
447 bmp.SaveTGA(outPath);
448 }
449 }
450 else if (outPath.EndsWith(".tiff") || outPath.EndsWith(".tif"))
451 {
452 using (Bitmap bmp = GetImage(0))
453 {
454 bmp.Save(outPath, ImageFormat.Tiff);
455 }
456 }
457 else if (outPath.EndsWith(".bmp"))
458 {
459 using (Bitmap bmp = GetImage(0))
460 {
461 bmp.Save(outPath, ImageFormat.Bmp);
462 }
463 }
464 else if (outPath.EndsWith(".jpg") || outPath.EndsWith(".jpeg"))
465 {
466 using (Bitmap bmp = GetImage(0))
467 {
468 bmp.Save(outPath, ImageFormat.Jpeg);
469 }
470 }
471 else if (outPath.EndsWith(".gif"))
472 {
473 using (Bitmap bmp = GetImage(0))
474 {
475 bmp.Save(outPath, ImageFormat.Gif);
476 }
477 }
478 else
479 {
480 base.Export(outPath);
481 }
482 }
Bitmap GetImage(int index)
Definition: TEX0Node.cs:311

◆ GeneratePAT0() [1/2]

PAT0Node BrawlLib.SSBB.ResourceNodes.TEX0Node.GeneratePAT0 ( )
inline
490 {
491 return GeneratePAT0(false);
492 }
PAT0Node GeneratePAT0()
Definition: TEX0Node.cs:489

◆ GeneratePAT0() [2/2]

PAT0Node BrawlLib.SSBB.ResourceNodes.TEX0Node.GeneratePAT0 ( bool  force)
inline
495 {
496 if (Parent == null)
497 {
498 return null;
499 }
500
501 if (Parent is BRESGroupNode && Parent.Parent != null && Parent.Parent is BRRESNode)
502 {
503 // Check if this is part of a sequence
504 if (Regex.Match(Name, @"(\.\d+)?$").Success && Name.LastIndexOf(".") > 0 &&
505 Name.LastIndexOf(".") <= Name.Length && int.TryParse(
506 Name.Substring(Name.LastIndexOf(".") + 1,
507 Name.Length - (Name.LastIndexOf(".") + 1)), out int n))
508 {
509 //Console.WriteLine(_resource.Name.Substring(0, _resource.Name.LastIndexOf(".")) + " is part of a sequence");
510 //Console.WriteLine(_resource.Name.Substring(_resource.Name.LastIndexOf(".") + 1, _resource.Name.Length - (_resource.Name.LastIndexOf(".") + 1)));
511 // Determine the name to match
512 string matchName = Name.Substring(0, Name.LastIndexOf(".")) + ".";
513 BRESGroupNode paletteGroup = ((BRRESNode)Parent.Parent).GetFolder<PLT0Node>();
514 List<string> textureList = new List<string>();
515 List<PLT0Node> paletteList = new List<PLT0Node>();
516 int highestNum = -1;
517 bool isStock = false;
518 bool isStockEx = false;
519 if (matchName.Equals("InfStc.", StringComparison.OrdinalIgnoreCase))
520 {
521 isStock = true;
522 if (Name.Length >= 11)
523 {
524 isStockEx = true;
525 }
526 }
527
528 foreach (TEX0Node tx0 in Parent.Children)
529 {
530 if (tx0.Name.StartsWith(matchName) && tx0.Name.LastIndexOf(".") > 0 &&
531 tx0.Name.LastIndexOf(".") <= tx0.Name.Length &&
532 int.TryParse(
533 tx0.Name.Substring(tx0.Name.LastIndexOf(".") + 1,
534 tx0.Name.Length - (tx0.Name.LastIndexOf(".") + 1)), out int n2) && n2 >= 0 &&
535 !textureList.Contains(tx0.Name))
536 {
537 if (isStock)
538 {
539 if (isStockEx && tx0.Name.Length < 11)
540 {
541 continue;
542 }
543 }
544
545 // Add the matching texture to the texture list for the PAT0
546 textureList.Add(tx0.Name);
547 // Determine the highest number used
548 if (n2 > highestNum)
549 {
550 highestNum = n2;
551 }
552
553 Console.WriteLine(tx0.Name);
554 Console.WriteLine(tx0.HasPalette);
555 if (tx0.HasPalette)
556 {
557 paletteList.Add(tx0.GetPaletteNode());
558 }
559 else
560 {
561 paletteList.Add(null);
562 }
563 }
564 }
565
566 if (textureList.Count <= 0)
567 {
568 return null;
569 }
570
571 PAT0Node newPat0 = new PAT0Node
572 {
573 Name = Name.Substring(0, Name.LastIndexOf(".")).Equals("InfStc")
574 ? "InfStockface_TopN__0"
575 : Name.Substring(0, Name.LastIndexOf(".")),
576 _numFrames = highestNum + 1
577 };
578 PAT0EntryNode pat0Entry = new PAT0EntryNode();
579 newPat0.AddChild(pat0Entry);
580 pat0Entry.Name = Name.Substring(0, Name.LastIndexOf(".")).Equals("InfStc")
581 ? "lambert87"
582 : Name.Substring(0, Name.LastIndexOf("."));
583 PAT0TextureNode pat0Tex = new PAT0TextureNode((PAT0Flags)7, 0);
584 pat0Entry.AddChild(pat0Tex);
585 if (((BRRESNode)Parent.Parent).GetFolder<PAT0Node>() != null &&
586 ((BRRESNode)Parent.Parent).GetFolder<PAT0Node>().FindChildrenByName(newPat0.Name)
587 .Length > 0)
588 {
589 if (force)
590 {
591 while (((BRRESNode)Parent.Parent).GetFolder<PAT0Node>()
592 .FindChildrenByName(newPat0.Name).Length > 0)
593 {
594 ((BRRESNode)Parent.Parent).GetFolder<PAT0Node>()
595 .FindChildrenByName(newPat0.Name)[0].Remove();
596 }
597 }
598 else
599 {
600 DialogResult d = MessageBox.Show(
601 "Would you like to replace the currently existing \"" + newPat0.Name +
602 "\" PAT0 animation?", "PAT0 Generator", MessageBoxButtons.YesNoCancel);
603 if (d == DialogResult.Cancel || d == DialogResult.Abort)
604 {
605 return null;
606 }
607
608 if (d == DialogResult.Yes)
609 {
610 while (((BRRESNode)Parent.Parent).GetFolder<PAT0Node>()
611 .FindChildrenByName(newPat0.Name).Length >
612 0)
613 {
614 ((BRRESNode)Parent.Parent).GetFolder<PAT0Node>()
615 .FindChildrenByName(newPat0.Name)[0].Remove();
616 }
617 }
618 }
619 }
620
621 if (isStock && !isStockEx && !textureList.Contains("InfStc.000"))
622 {
623 textureList.Add("InfStc.000");
624 paletteList.Add(null);
625 }
626 else if (isStock && isStockEx && !textureList.Contains("InfStc.0000"))
627 {
628 textureList.Add("InfStc.0000");
629 paletteList.Add(null);
630 }
631
632 //foreach(string s in textureList)
633 for (int i = 0; i < textureList.Count; ++i)
634 {
635 string s = textureList[i];
636 if (float.TryParse(s.Substring(s.LastIndexOf(".") + 1, s.Length - (s.LastIndexOf(".") + 1)),
637 out float fr))
638 {
639 PAT0TextureEntryNode pat0texEntry = new PAT0TextureEntryNode();
640 pat0Tex.AddChild(pat0texEntry);
641 pat0texEntry.Name = s;
642 pat0texEntry._frame = fr;
643 if (paletteList[i] != null)
644 {
645 pat0Tex.HasPalette = true;
646 pat0texEntry._plt = paletteList[i].Name;
647 }
648 else if ((s == "InfStc.000" || s == "InfStc.0000") && pat0Tex.HasPalette)
649 {
650 pat0texEntry._plt = s;
651 }
652
653 if (fr == 0)
654 {
655 PAT0TextureEntryNode pat0texEntryFinal = new PAT0TextureEntryNode();
656 pat0Tex.AddChild(pat0texEntryFinal);
657 pat0texEntryFinal.Name = s;
658 pat0texEntryFinal._frame = highestNum + 1;
659 if (paletteList[i] != null)
660 {
661 pat0Tex.HasPalette = true;
662 pat0texEntryFinal.Palette = paletteList[i].Name;
663 }
664 else if ((s == "InfStc.000" || s == "InfStc.0000") && pat0Tex.HasPalette)
665 {
666 pat0texEntryFinal._plt = s;
667 }
668 }
669 }
670
671 //newPat0.AddChild
672 }
673
674 pat0Tex._children = pat0Tex._children.OrderBy(o => ((PAT0TextureEntryNode)o)._frame).ToList();
675 if (isStock && !isStockEx && newPat0.FrameCount < 501)
676 {
677 newPat0.FrameCount = 501;
678 }
679 else if (isStockEx && newPat0.FrameCount < 9201)
680 {
681 newPat0.FrameCount = 9201;
682 }
683
684 ((BRRESNode)Parent.Parent).GetOrCreateFolder<PAT0Node>().AddChild(newPat0);
685
686 return newPat0;
687 }
688 else
689 {
690 PAT0Node newPat0 = new PAT0Node
691 {
692 Name = Name,
693 _numFrames = 1
694 };
695 PAT0EntryNode pat0Entry = new PAT0EntryNode();
696 newPat0.AddChild(pat0Entry);
697 pat0Entry.Name = Name;
698 PAT0TextureNode pat0Tex = new PAT0TextureNode((PAT0Flags)7, 0);
699 pat0Entry.AddChild(pat0Tex);
700 PAT0TextureEntryNode pat0texEntry = new PAT0TextureEntryNode();
701 pat0Tex.AddChild(pat0texEntry);
702 pat0texEntry.Name = Name;
703 pat0texEntry._frame = 0;
704 if (HasPalette)
705 {
706 pat0Tex.HasPalette = true;
707 pat0texEntry.Palette = GetPaletteNode().Name;
708 }
709
710 ((BRRESNode)Parent.Parent).GetOrCreateFolder<PAT0Node>().AddChild(newPat0);
711 return newPat0;
712 }
713 }
714
715 return null;
716 }
virtual void Remove()
Definition: ResourceNode.cs:741
ResourceNode[] FindChildrenByName(string name)
Definition: ResourceNode.cs:1558
ResourceNode Parent
Definition: ResourceNode.cs:245
virtual string Name
Definition: ResourceNode.cs:223
virtual void AddChild(ResourceNode child)
Definition: ResourceNode.cs:757
List< ResourceNode > Children
Definition: ResourceNode.cs:262
bool HasPalette
Definition: TEX0Node.cs:106
PLT0Node GetPaletteNode()
Definition: TEX0Node.cs:108
override string Name
Definition: TEX0Node.cs:206
TEX0Node()
Definition: TEX0Node.cs:31
PAT0Flags
Definition: PAT0.cs:9

◆ GetImage() [1/2]

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

Implements BrawlLib.Imaging.IImageSource.

312 {
313 PLT0Node plt = GetPaletteNode();
314 return SharesData ? SourceNode.GetImage(index, plt) : GetImage(index, plt);
315 }
bool SharesData
Definition: TEX0Node.cs:51

◆ GetImage() [2/2]

Bitmap BrawlLib.SSBB.ResourceNodes.TEX0Node.GetImage ( int  index,
PLT0Node  plt 
)
inline
318 {
319 try
320 {
321 if (SharesData && SourceNode != this)
322 {
323 return SourceNode.GetImage(index, plt);
324 }
325
326 if (WorkingUncompressed != DataSource.Empty)
327 {
328 if (plt != null)
329 {
331 (VoidPtr) CommonHeader + _headerLen, _width, _height, plt.Palette, index + 1, _format);
332 }
333
335 (VoidPtr) CommonHeader + _headerLen, _width, _height, index + 1, _format);
336 }
337
338 return null;
339 }
340 catch
341 {
342 return null;
343 }
344 }
DataSource WorkingUncompressed
Definition: ResourceNode.cs:183
Definition: TextureConverter.cs:15
static Bitmap DecodeIndexed(TEX0v1 *texture, PLT0v1 *palette, int mipLevel)
Definition: TextureConverter.cs:439
static Bitmap Decode(VoidPtr addr, int w, int h, int mipLevel, WiiPixelFormat fmt)
Definition: TextureConverter.cs:352
Definition: VoidPtr.cs:9
static readonly DataSource Empty
Definition: ResourceNode.cs:29

◆ GetPaletteNode()

PLT0Node BrawlLib.SSBB.ResourceNodes.TEX0Node.GetPaletteNode ( )
inline
109 {
110 return _parent?._parent == null || !HasPalette
111 ? null
112 : Parent._parent.FindChild("Palettes(NW4R)/" + Name, false) as PLT0Node;
113 }
ResourceNode _parent
Definition: ResourceNode.cs:142
ResourceNode FindChild(string path)
Definition: ResourceNode.cs:1342

◆ OnCalculateSize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

267 {
268 return ExclusiveEntrySize();
269 }

◆ OnInitialize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.BRESEntryNode.

221 {
222 base.OnInitialize();
223 _headerLen = Header1->_headerLen;
224
225 _sharesData = _headerLen > HeaderSize() && new string((sbyte*)WorkingUncompressed.Address + HeaderSize()).StartsWith("TEX0") || WorkingUncompressed.Map != null && _headerLen >= WorkingUncompressed.Map.Length;
226 if (_sharesData)
227 {
228 SetSizeInternal(ExclusiveEntrySize());
229 }
230
231 if (_version == 2)
232 {
233 if (_name == null && Header2->_stringOffset != 0)
234 {
235 _name = Header2->ResourceString;
236 }
237
238 _width = Header2->_width;
239 _height = Header2->_height;
240 _format = Header2->PixelFormat;
241 _lod = Header2->_levelOfDetail;
242 _hasPalette = Header2->HasPalette;
243 }
244 else
245 {
246 if (_name == null && Header1->_stringOffset != 0)
247 {
248 _name = Header1->ResourceString;
249 }
250
251 _width = Header1->_width;
252 _height = Header1->_height;
253 _format = Header1->PixelFormat;
254 _lod = Header1->_levelOfDetail;
255 _hasPalette = Header1->HasPalette;
256 }
257
258 if (_version == 3)
259 {
260 (_userEntries = new UserDataCollection()).Read(Header3->UserData, WorkingUncompressed);
261 }
262
263 return false;
264 }
int Length
Definition: FileMap.cs:19
void SetSizeInternal(int size)
Definition: ResourceNode.cs:799
string _name
Definition: ResourceNode.cs:139
FileMap Map
Definition: ResourceNode.cs:33
VoidPtr Address
Definition: ResourceNode.cs:31
bint _headerLen
Definition: TEX0.cs:14
bint _levelOfDetail
Definition: TEX0.cs:20
bshort _height
Definition: TEX0.cs:18
bshort _width
Definition: TEX0.cs:17
string ResourceString
Definition: TEX0.cs:45
bool HasPalette
Definition: TEX0.cs:63
bint _stringOffset
Definition: TEX0.cs:15
WiiPixelFormat PixelFormat
Definition: TEX0.cs:57
bint _stringOffset
Definition: TEX0.cs:102
bshort _height
Definition: TEX0.cs:105
bint _levelOfDetail
Definition: TEX0.cs:107
bool HasPalette
Definition: TEX0.cs:149
WiiPixelFormat PixelFormat
Definition: TEX0.cs:143
string ResourceString
Definition: TEX0.cs:131
bshort _width
Definition: TEX0.cs:104
UserData * UserData
Definition: TEX0.cs:221

◆ OnRebuild()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

272 {
273 int offset = OffsetToData();
274 if (!SharesData)
275 {
276 Memory.Move(address + offset, WorkingUncompressed.Address + offset, (uint) length - (uint) offset);
277 }
278
279 switch (Version)
280 {
281 case 1:
282 *(TEX0v1*) address = new TEX0v1(Width, Height, Format, LevelOfDetail, offset);
283 break;
284 case 2:
285 *(TEX0v2*) address = new TEX0v2(Width, Height, Format, LevelOfDetail, offset);
286 break;
287 case 3:
288 *(TEX0v3*) address = new TEX0v3(Width, Height, Format, LevelOfDetail, offset);
289 _userEntries.Write(address + TEX0v3.Size);
290 break;
291 }
292 }
Definition: Memory.cs:8
static void Move(VoidPtr dst, VoidPtr src, uint size)
Definition: Memory.cs:9
int Version
Definition: BRRESNode.cs:1052
int Height
Definition: TEX0Node.cs:103
int Width
Definition: TEX0Node.cs:102
WiiPixelFormat Format
Definition: TEX0Node.cs:104
int LevelOfDetail
Definition: TEX0Node.cs:105
Definition: TEX0.cs:9
Definition: TEX0.cs:95
Definition: TEX0.cs:181
const int Size
Definition: TEX0.cs:182

◆ Remove() [1/2]

override void BrawlLib.SSBB.ResourceNodes.TEX0Node.Remove ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

347 {
348 Remove(false);
349 }
override void Remove()
Definition: TEX0Node.cs:346

◆ Remove() [2/2]

void BrawlLib.SSBB.ResourceNodes.TEX0Node.Remove ( bool  forceRemovePalettes)
inline
352 {
353 PLT0Node p = GetPaletteNode();
354 if (HasPalette && p != null && (forceRemovePalettes ||
355 MessageBox.Show("Would you like to delete the associated PLT0?",
356 $"Deleting {Name}", MessageBoxButtons.YesNo) == DialogResult.Yes))
357 {
358 while ((p = GetPaletteNode()) != null)
359 {
360 p.Dispose();
361 p.Remove();
362 }
363 }
364
365 base.Remove();
366 }

◆ Replace() [1/2]

void BrawlLib.SSBB.ResourceNodes.TEX0Node.Replace ( Bitmap  bmp)
inline
400 {
401 FileMap tMap;
402 if (HasPalette)
403 {
404 PLT0Node pn = GetPaletteNode();
405 tMap = TextureConverter.Get(Format).EncodeTextureIndexed(bmp, LevelOfDetail, pn.Colors, pn.Format,
406 QuantizationAlgorithm.MedianCut, out FileMap pMap);
407 pn.ReplaceRaw(pMap);
408 }
409 else
410 {
412 }
413
414 ReplaceRaw(tMap);
415 }
Definition: FileMap.cs:10
virtual void ReplaceRaw(VoidPtr address, int length)
Definition: ResourceNode.cs:847
virtual FileMap EncodeTEX0Texture(Bitmap src, int mipLevels)
Definition: TextureConverter.cs:203
static TextureConverter Get(WiiPixelFormat format)
Definition: TextureConverter.cs:415
virtual FileMap EncodeTextureIndexed(Bitmap src, int mipLevels, int numColors, WiiPaletteFormat format, QuantizationAlgorithm algorithm, out FileMap paletteFile)
Definition: TextureConverter.cs:67
QuantizationAlgorithm
Definition: BitmapExtension.cs:723

◆ Replace() [2/2]

override void BrawlLib.SSBB.ResourceNodes.TEX0Node.Replace ( string  fileName)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

418 {
419 string ext = Path.GetExtension(fileName);
420 if (!string.Equals(ext, ".tex0", StringComparison.OrdinalIgnoreCase))
421 {
423 {
424 dlg.ImageSource = fileName;
425 dlg.ShowDialog(null, this);
426 }
427 }
428 else
429 {
430 base.Replace(fileName);
431 }
432 }
Definition: TextureConverterDialog.cs:24
DialogResult ShowDialog(IWin32Window owner, BRRESNode parent)
Definition: TextureConverterDialog.cs:164

◆ SetSharesData()

void BrawlLib.SSBB.ResourceNodes.TEX0Node.SetSharesData ( bool  value,
bool  showMessages 
)
inline
57 {
58 Bitmap bmp = GetImage(0);
59 bool disableRevert = false;
61 if (!_revertingCS && !value)
62 {
63 if (!showMessages || MessageBox.Show(
64 "Would you like to revert color smashing for the node and all nodes that share data above it? (If your preview looks correct now, say yes. If your preview looks bugged, say no)",
65 "Warning", MessageBoxButtons.YesNo) != DialogResult.Yes)
66 {
67 _sharesData = value;
69 return;
70 }
71
72 _revertingCS = true;
73 disableRevert = true;
74 }
75
76 _sharesData = value;
78 if (!value)
79 {
80 if (t != null && t.SharesData)
81 {
82 t.SharesData = false;
83 }
84
86 {
87 dlg.Automatic = true;
88 dlg.cboFormat.SelectedItem =
89 dlg.LoadImages(bmp);
90 dlg.ShowDialog(null, this);
91 }
92 }
93
94 if (disableRevert)
95 {
96 _revertingCS = false;
97 }
98 }
bool LoadImages(string path)
Definition: TextureConverterDialog.cs:415
virtual void SignalPropertyChange()
Definition: ResourceNode.cs:313
ResourceNode PrevSibling()
Definition: ResourceNode.cs:1719

Member Data Documentation

◆ texSortNum

int BrawlLib.SSBB.ResourceNodes.TEX0Node.texSortNum

Property Documentation

◆ DataAlign

override int BrawlLib.SSBB.ResourceNodes.TEX0Node.DataAlign
get

◆ Format

WiiPixelFormat BrawlLib.SSBB.ResourceNodes.TEX0Node.Format
get

◆ HasPalette

bool BrawlLib.SSBB.ResourceNodes.TEX0Node.HasPalette
get

◆ Height

int BrawlLib.SSBB.ResourceNodes.TEX0Node.Height
get

◆ ImageCount

int BrawlLib.SSBB.ResourceNodes.TEX0Node.ImageCount
get

◆ LevelOfDetail

int BrawlLib.SSBB.ResourceNodes.TEX0Node.LevelOfDetail
get

◆ Name

override string BrawlLib.SSBB.ResourceNodes.TEX0Node.Name
getset
206 {
207 get => base.Name;
208 set
209 {
210 if (HasPalette && GetPaletteNode() != null)
211 {
212 GetPaletteNode().Name = value;
213 }
214
215 base.Name = value;
216 }
217 }

◆ ResourceFileType

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

◆ SharesData

bool BrawlLib.SSBB.ResourceNodes.TEX0Node.SharesData
getset
51 {
52 get => _sharesData;
53 set => SetSharesData(value, true);
54 }
void SetSharesData(bool value, bool showMessages)
Definition: TEX0Node.cs:56

◆ SupportedVersions

override int [] BrawlLib.SSBB.ResourceNodes.TEX0Node.SupportedVersions
get

◆ Tag

override string BrawlLib.SSBB.ResourceNodes.TEX0Node.Tag
get

◆ Width

int BrawlLib.SSBB.ResourceNodes.TEX0Node.Width
get

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