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

Public Member Functions

Bitmap GetImage (int index)
 
bool HasPrimary (int id)
 
ARGBPixel GetPrimaryColor (int id)
 
void SetPrimaryColor (int id, ARGBPixel color)
 
string PrimaryColorName (int id)
 
int ColorCount (int id)
 
ARGBPixel GetColor (int index, int id)
 
void SetColor (int index, int id, ARGBPixel color)
 
bool GetColorConstant (int id)
 
void SetColorConstant (int id, bool constant)
 
override bool OnInitialize ()
 
override void OnRebuild (VoidPtr address, int length, bool force)
 
void Replace (Bitmap bmp)
 
override void Replace (string fileName)
 
override void Export (string outPath)
 
- 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)
 
bool HasPrimary (int id)
 
ARGBPixel GetPrimaryColor (int id)
 
void SetPrimaryColor (int id, ARGBPixel color)
 
string PrimaryColorName (int id)
 
int ColorCount (int id)
 
ARGBPixel GetColor (int index, int id)
 
void SetColor (int index, int id, ARGBPixel color)
 
bool GetColorConstant (int id)
 
void SetColorConstant (int id, bool constant)
 

Public Attributes

int _offset
 
int _length
 
- 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]
 
bool HasPlt [get]
 
WiiPixelFormat TextureFormat [get]
 
WiiPaletteFormat PaletteFormat [get]
 
int Colors [get]
 
int Width [get]
 
int Height [get]
 
int ImageLength [get]
 
int PaletteLength [get]
 
int LevelOfDetail [get]
 
MatTextureMinFilter MinFilter [get, set]
 
MatTextureMagFilter MagFilter [get, set]
 
float LODBias [get, set]
 
int REFTOffset [get]
 
int DataLength [get]
 
int ImageCount [get]
 
ColorPalette Palette [get, set]
 
int TypeCount [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]
 
- Properties inherited from BrawlLib.Imaging.IColorSource
int TypeCount [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

◆ ColorCount()

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.ColorCount ( int  id)
inline

Implements BrawlLib.Imaging.IColorSource.

239 {
240 return Palette != null ? Palette.Entries.Length : 0;
241 }
ColorPalette Palette
Definition: REFTNode.cs:201

◆ Export()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

343 {
344 if (outPath.EndsWith(".png"))
345 {
346 using (Bitmap bmp = GetImage(0))
347 {
348 bmp.Save(outPath, ImageFormat.Png);
349 }
350 }
351 else if (outPath.EndsWith(".tga"))
352 {
353 using (Bitmap bmp = GetImage(0))
354 {
355 bmp.SaveTGA(outPath);
356 }
357 }
358 else if (outPath.EndsWith(".tiff") || outPath.EndsWith(".tif"))
359 {
360 using (Bitmap bmp = GetImage(0))
361 {
362 bmp.Save(outPath, ImageFormat.Tiff);
363 }
364 }
365 else if (outPath.EndsWith(".bmp"))
366 {
367 using (Bitmap bmp = GetImage(0))
368 {
369 bmp.Save(outPath, ImageFormat.Bmp);
370 }
371 }
372 else if (outPath.EndsWith(".jpg") || outPath.EndsWith(".jpeg"))
373 {
374 using (Bitmap bmp = GetImage(0))
375 {
376 bmp.Save(outPath, ImageFormat.Jpeg);
377 }
378 }
379 else if (outPath.EndsWith(".gif"))
380 {
381 using (Bitmap bmp = GetImage(0))
382 {
383 bmp.Save(outPath, ImageFormat.Gif);
384 }
385 }
386 else
387 {
388 base.Export(outPath);
389 }
390 }
Bitmap GetImage(int index)
Definition: REFTNode.cs:179

◆ GetColor()

ARGBPixel BrawlLib.SSBB.ResourceNodes.REFTEntryNode.GetColor ( int  index,
int  id 
)
inline

Implements BrawlLib.Imaging.IColorSource.

244 {
245 return Palette != null ? (ARGBPixel) Palette.Entries[index] : new ARGBPixel();
246 }
Definition: PixelTypes.cs:16

◆ GetColorConstant()

bool BrawlLib.SSBB.ResourceNodes.REFTEntryNode.GetColorConstant ( int  id)
inline

Implements BrawlLib.Imaging.IColorSource.

258 {
259 return false;
260 }

◆ GetImage()

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

Implements BrawlLib.Imaging.IImageSource.

180 {
181 try
182 {
183 if (HasPlt)
184 {
185 return TextureConverter.DecodeIndexed((byte*) Header + 0x20, Width, Height, Palette, index + 1,
186 _format);
187 }
188
189 return TextureConverter.Decode((byte*) Header + 0x20, Width, Height, index + 1, _format);
190 }
191 catch
192 {
193 return null;
194 }
195 }
int Height
Definition: REFTNode.cs:136
bool HasPlt
Definition: REFTNode.cs:128
int Width
Definition: REFTNode.cs:135
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

◆ GetPrimaryColor()

ARGBPixel BrawlLib.SSBB.ResourceNodes.REFTEntryNode.GetPrimaryColor ( int  id)
inline

Implements BrawlLib.Imaging.IColorSource.

221 {
222 return new ARGBPixel();
223 }

◆ HasPrimary()

bool BrawlLib.SSBB.ResourceNodes.REFTEntryNode.HasPrimary ( int  id)
inline

Implements BrawlLib.Imaging.IColorSource.

216 {
217 return false;
218 }

◆ OnInitialize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

269 {
270 base.OnInitialize();
271
272 _unk = Header->_unknown;
273 _format = (WiiPixelFormat) Header->_format;
274 _pltFormat = (WiiPaletteFormat) Header->_pltFormat;
275 numColors = Header->_colorCount;
276 _imgLen = (int) Header->_imagelen;
277 _width = Header->_width;
278 _height = Header->_height;
279 _pltLen = (int) Header->_pltSize;
280 _lod = Header->_mipmap + 1;
281 _minFltr = Header->_min_filt;
282 _magFltr = Header->_mag_filt;
283
284 return false;
285 }
WiiPixelFormat
Definition: Enum.cs:4
WiiPaletteFormat
Definition: Enum.cs:57
bushort _width
Definition: REFT.cs:129
byte _format
Definition: REFT.cs:132
byte _min_filt
Definition: REFT.cs:138
bushort _colorCount
Definition: REFT.cs:134
byte _pltFormat
Definition: REFT.cs:133
buint _imagelen
Definition: REFT.cs:131
buint _pltSize
Definition: REFT.cs:136
buint _unknown
Definition: REFT.cs:128
byte _mipmap
Definition: REFT.cs:137
bushort _height
Definition: REFT.cs:130
byte _mag_filt
Definition: REFT.cs:139

◆ OnRebuild()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

288 {
289 base.OnRebuild(address, length, force);
290
291 REFTImageHeader* header = (REFTImageHeader*) address;
292 header->Set((byte) _minFltr, (byte) _magFltr, (byte) _lodBias);
293 }
void Set(byte min, byte mag, float lodBias)
Definition: REFT.cs:172

◆ PrimaryColorName()

string BrawlLib.SSBB.ResourceNodes.REFTEntryNode.PrimaryColorName ( int  id)
inline

Implements BrawlLib.Imaging.IColorSource.

231 {
232 return null;
233 }

◆ Replace() [1/2]

void BrawlLib.SSBB.ResourceNodes.REFTEntryNode.Replace ( Bitmap  bmp)
inline
296 {
297 FileMap tMap;
298 if (HasPlt)
299 {
301 Palette.Entries.Length, PaletteFormat, QuantizationAlgorithm.MedianCut);
302 }
303 else
304 {
306 }
307
308 ReplaceRaw(tMap);
309 }
Definition: FileMap.cs:10
WiiPaletteFormat PaletteFormat
Definition: REFTNode.cs:133
int LevelOfDetail
Definition: REFTNode.cs:139
virtual void ReplaceRaw(VoidPtr address, int length)
Definition: ResourceNode.cs:847
virtual FileMap EncodeREFTTextureIndexed(Bitmap src, int mipLevels, int numColors, WiiPaletteFormat format, QuantizationAlgorithm algorithm)
Definition: TextureConverter.cs:76
static TextureConverter Get(WiiPixelFormat format)
Definition: TextureConverter.cs:415
virtual FileMap EncodeREFTTexture(Bitmap src, int mipLevels, WiiPaletteFormat format)
Definition: TextureConverter.cs:121
QuantizationAlgorithm
Definition: BitmapExtension.cs:723

◆ Replace() [2/2]

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

312 {
313 string ext = Path.GetExtension(fileName);
314 Bitmap bmp;
315 if (string.Equals(ext, ".tga", StringComparison.OrdinalIgnoreCase))
316 {
317 bmp = TGA.FromFile(fileName);
318 }
319 else if (
320 string.Equals(ext, ".png", StringComparison.OrdinalIgnoreCase) ||
321 string.Equals(ext, ".tif", StringComparison.OrdinalIgnoreCase) ||
322 string.Equals(ext, ".tiff", StringComparison.OrdinalIgnoreCase) ||
323 string.Equals(ext, ".bmp", StringComparison.OrdinalIgnoreCase) ||
324 string.Equals(ext, ".jpg", StringComparison.OrdinalIgnoreCase) ||
325 string.Equals(ext, ".jpeg", StringComparison.OrdinalIgnoreCase) ||
326 string.Equals(ext, ".gif", StringComparison.OrdinalIgnoreCase))
327 {
328 bmp = (Bitmap) Image.FromFile(fileName);
329 }
330 else
331 {
332 base.Replace(fileName);
333 return;
334 }
335
336 using (Bitmap b = bmp)
337 {
338 Replace(b);
339 }
340 }
Definition: TGAImage.cs:120
static unsafe Bitmap FromFile(string path)
Definition: TGAImage.cs:171
void Replace(Bitmap bmp)
Definition: REFTNode.cs:295

◆ SetColor()

void BrawlLib.SSBB.ResourceNodes.REFTEntryNode.SetColor ( int  index,
int  id,
ARGBPixel  color 
)
inline

Implements BrawlLib.Imaging.IColorSource.

249 {
250 if (Palette != null)
251 {
252 Palette.Entries[index] = (Color) color;
254 }
255 }
virtual void SignalPropertyChange()
Definition: ResourceNode.cs:313

◆ SetColorConstant()

void BrawlLib.SSBB.ResourceNodes.REFTEntryNode.SetColorConstant ( int  id,
bool  constant 
)
inline

Implements BrawlLib.Imaging.IColorSource.

263 {
264 }

◆ SetPrimaryColor()

void BrawlLib.SSBB.ResourceNodes.REFTEntryNode.SetPrimaryColor ( int  id,
ARGBPixel  color 
)
inline

Implements BrawlLib.Imaging.IColorSource.

226 {
227 }

Member Data Documentation

◆ _length

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode._length

◆ _offset

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode._offset

Property Documentation

◆ Colors

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.Colors
get

◆ DataLength

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.DataLength
get

◆ HasPlt

bool BrawlLib.SSBB.ResourceNodes.REFTEntryNode.HasPlt
get

◆ Height

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.Height
get

◆ ImageCount

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.ImageCount
get

◆ ImageLength

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.ImageLength
get

◆ LevelOfDetail

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.LevelOfDetail
get

◆ LODBias

float BrawlLib.SSBB.ResourceNodes.REFTEntryNode.LODBias
getset
165 {
166 get => _lodBias;
167 set
168 {
169 _lodBias = value;
171 }
172 }

◆ MagFilter

MatTextureMagFilter BrawlLib.SSBB.ResourceNodes.REFTEntryNode.MagFilter
getset
154 {
155 get => (MatTextureMagFilter) _magFltr;
156 set
157 {
158 _magFltr = (uint) value;
160 }
161 }
MatTextureMagFilter
Definition: MDL0MaterialRefNode.cs:1018

◆ MinFilter

MatTextureMinFilter BrawlLib.SSBB.ResourceNodes.REFTEntryNode.MinFilter
getset
143 {
144 get => (MatTextureMinFilter) _minFltr;
145 set
146 {
147 _minFltr = (uint) value;
149 }
150 }
MatTextureMinFilter
Definition: MDL0MaterialRefNode.cs:1008

◆ Palette

ColorPalette BrawlLib.SSBB.ResourceNodes.REFTEntryNode.Palette
getset
201 {
202 get => HasPlt
203 ? _palette ?? (_palette =
204 TextureConverter.DecodePalette((byte*) Header + 0x20 + Header->_imagelen, Colors, _pltFormat))
205 : null;
206 set
207 {
208 _palette = value;
210 }
211 }
int Colors
Definition: REFTNode.cs:134
static ColorPalette DecodePalette(PLT0v1 *palette)
Definition: TextureConverter.cs:558

◆ PaletteFormat

WiiPaletteFormat BrawlLib.SSBB.ResourceNodes.REFTEntryNode.PaletteFormat
get

◆ PaletteLength

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.PaletteLength
get

◆ REFTOffset

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.REFTOffset
get

◆ ResourceFileType

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

◆ TextureFormat

WiiPixelFormat BrawlLib.SSBB.ResourceNodes.REFTEntryNode.TextureFormat
get

◆ TypeCount

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.TypeCount
get

◆ Width

int BrawlLib.SSBB.ResourceNodes.REFTEntryNode.Width
get

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