soopercool101 / BrawlCrate

BrawlBox/BrawlTools Fork, Wii File Editor
https://discord.gg/s7c8763
GNU Lesser General Public License v3.0
148 stars 38 forks source link

Error when replacing tex0 using BRRES.CreateResource() in python #50

Closed Superjosh00 closed 1 year ago

Superjosh00 commented 1 year ago

Im attempting to automate a bit of work with python

First I create a tex0 resoucenode with (I get miscdat70 earlier in the script): new = miscdat70.CreateResource[BrawlLib.SSBB.ResourceNodes.TEX0Node]("TEX0Node")

Then I attempt to add a png to it with new.Replace(pngpath)

Then this error is thrown. Clicking apply ends up actually applying the texture but I cant really automate it any further when it errors

System.ArgumentOutOfRangeExeption

Value of '0' is not valid for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'. Parameter name: Value at System.Windows.Forms.NumericUpDown.set_Value(Decimal value) at BrawlLib.Internal.Windows.Forms.TextureConverterDialog.OnShown(EventArgs e) at System.Windows.Forms.Form.CallShownEvent() at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, >Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean >preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

soopercool101 commented 1 year ago

Replace doesn't work with PNG, only TEX0. You'll need to convert it using the TextureConverterDialog, see BrawlInstaller for an example there: https://github.com/squidgy617/BrawlInstallerPlugins/blob/1cd46f573a8de046684f3815a1022869e3fe65ba/Lib/BrawlInstallerLib.py#L215_L232