Fix: Pro Pattern Import

I beefed the UsageCompatibility addition by accidentally deleting the exception catch when cleaning up some comments and thus killed the WritePatternPRO method lol. Absolute unit of a goose.

Took the opportunity to moved the compat to the other data manip in the buttom methods instead of the load methods.
This commit is contained in:
Josh (vector_cmdr) 2026-02-14 01:56:04 +11:00
parent 17d64fe680
commit 9a3f5fb5af
6 changed files with 159 additions and 202 deletions

View File

@ -153,6 +153,7 @@ public static DesignPatternPRO ReadPatternPROAtOffset(ReadOnlySpan<byte> data, i
public void WritePatternPRO(DesignPatternPRO p, Span<byte> data, int index)
{
if ((uint)index >= PatternCount)
throw new ArgumentOutOfRangeException(nameof(index));
p.Data.CopyTo(data[(PatternsPRO + (index * DesignPatternPRO.SIZE))..]);
ReadOnlySpan<byte> editedflag = [0x00];
editedflag.CopyTo(data[(PatternsProEditFlagStart + index)..]); // set edited flag for designs name import to be correct in game

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,6 @@ private void InitializeComponent()
PB_Pattern = new System.Windows.Forms.PictureBox();
CM_Picture = new System.Windows.Forms.ContextMenuStrip(components);
Menu_SavePNG = new System.Windows.Forms.ToolStripMenuItem();
CB_Pattern_OverwriteDesigner = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)PB_Palette).BeginInit();
((System.ComponentModel.ISupportInitialize)PB_Pattern).BeginInit();
CM_Picture.SuspendLayout();
@ -174,21 +173,10 @@ private void InitializeComponent()
Menu_SavePNG.Text = "Save .png";
Menu_SavePNG.Click += Menu_SavePNG_Click;
//
// CB_Pattern_OverwriteDesigner
//
CB_Pattern_OverwriteDesigner.AutoSize = true;
CB_Pattern_OverwriteDesigner.Location = new System.Drawing.Point(263, 288);
CB_Pattern_OverwriteDesigner.Name = "CB_Pattern_OverwriteDesigner";
CB_Pattern_OverwriteDesigner.Size = new System.Drawing.Size(126, 19);
CB_Pattern_OverwriteDesigner.TabIndex = 35;
CB_Pattern_OverwriteDesigner.Text = "Overwrite Designer";
CB_Pattern_OverwriteDesigner.UseVisualStyleBackColor = true;
//
// PatternEditor
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(592, 328);
Controls.Add(CB_Pattern_OverwriteDesigner);
Controls.Add(PB_Palette);
Controls.Add(L_PatternName);
Controls.Add(B_DumpLoadDesign);
@ -225,6 +213,5 @@ private void InitializeComponent()
private System.Windows.Forms.PictureBox PB_Pattern;
private System.Windows.Forms.ContextMenuStrip CM_Picture;
private System.Windows.Forms.ToolStripMenuItem Menu_SavePNG;
private System.Windows.Forms.CheckBox CB_Pattern_OverwriteDesigner;
}
}

View File

@ -4,7 +4,6 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.Intrinsics.Arm;
using System.Windows.Forms;
namespace NHSE.WinForms;
@ -136,6 +135,19 @@ private void B_LoadDesign_Click(object sender, EventArgs e)
d.ChangeOrigins(player0, d.Data);
}
if (d.UsageCompatibility is not (0xEE00 or 0xEE02)) // known valid values (00=non-transparent, 02=transparent)
{
using var image = d.GetImage();
if (ContainsTransparentPixels(image))
{
d.UsageCompatibility = 0xEE02; // set to transparent
}
else
{
d.UsageCompatibility = 0xEE00; // reset to default value (non-transparent)
}
}
Patterns[Index] = d;
LoadPattern(d);
RepopulateList(Index);
@ -166,27 +178,6 @@ public bool ContainsTransparentPixels(Bitmap image)
private void LoadPattern(DesignPattern designPattern)
{
if (designPattern.UsageCompatibility is not (0xEE00 or 0xEE02)) // known valid values (00=non-transparent, 02=transparent)
{
using var image = designPattern.GetImage();
if (ContainsTransparentPixels(image))
{
designPattern.UsageCompatibility = 0xEE02; // set to transparent
}
else
{
designPattern.UsageCompatibility = 0xEE00; // reset to default value (non-transparent)
}
}
if (CB_Pattern_OverwriteDesigner.Checked)
{
designPattern.PlayerID = Player.Personal.PlayerID;
designPattern.PlayerName = Player.Personal.PlayerName;
designPattern.TownID = Player.Personal.TownID;
designPattern.TownName = Player.Personal.TownName;
}
PB_Pattern.Image = ImageUtil.ResizeImage(designPattern.GetImage(), DesignPattern.Width * scale, DesignPattern.Height * scale);
PB_Palette.Image = ImageUtil.ResizeImage(designPattern.GetPalette(), 150, 10);
L_PatternName.Text = designPattern.DesignName + Environment.NewLine +

View File

@ -46,7 +46,6 @@ private void InitializeComponent()
PB_Sheet1 = new System.Windows.Forms.PictureBox();
PB_Sheet3 = new System.Windows.Forms.PictureBox();
PB_Sheet2 = new System.Windows.Forms.PictureBox();
CB_Pattern_OverwriteDesigner = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)PB_Palette).BeginInit();
((System.ComponentModel.ISupportInitialize)PB_Sheet0).BeginInit();
CM_Picture.SuspendLayout();
@ -213,21 +212,10 @@ private void InitializeComponent()
PB_Sheet2.TabIndex = 36;
PB_Sheet2.TabStop = false;
//
// CB_Pattern_OverwriteDesigner
//
CB_Pattern_OverwriteDesigner.AutoSize = true;
CB_Pattern_OverwriteDesigner.Location = new System.Drawing.Point(263, 288);
CB_Pattern_OverwriteDesigner.Name = "CB_Pattern_OverwriteDesigner";
CB_Pattern_OverwriteDesigner.Size = new System.Drawing.Size(126, 19);
CB_Pattern_OverwriteDesigner.TabIndex = 38;
CB_Pattern_OverwriteDesigner.Text = "Overwrite Designer";
CB_Pattern_OverwriteDesigner.UseVisualStyleBackColor = true;
//
// PatternEditorPRO
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(592, 328);
Controls.Add(CB_Pattern_OverwriteDesigner);
Controls.Add(PB_Sheet3);
Controls.Add(PB_Sheet2);
Controls.Add(PB_Sheet1);
@ -273,6 +261,5 @@ private void InitializeComponent()
private System.Windows.Forms.PictureBox PB_Sheet1;
private System.Windows.Forms.PictureBox PB_Sheet3;
private System.Windows.Forms.PictureBox PB_Sheet2;
private System.Windows.Forms.CheckBox CB_Pattern_OverwriteDesigner;
}
}

View File

@ -4,7 +4,6 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace NHSE.WinForms;
@ -135,6 +134,9 @@ private void B_LoadDesign_Click(object sender, EventArgs e)
d.ChangeOrigins(player0, d.Data);
}
if (d.UsageCompatibility is not (0xEE01 or 0xEE05)) // known valid values (01=pro, 05=default_unused)
d.UsageCompatibility = 0xEE01; // reset to default pro design
Patterns[Index] = d;
LoadPattern(d);
RepopulateList(Index);
@ -150,17 +152,6 @@ private void RepopulateList(int index)
private void LoadPattern(DesignPatternPRO dp)
{
if (dp.UsageCompatibility is not (0xEE01 or 0xEE05)) // known valid values (01=pro, 05=default_unused)
dp.UsageCompatibility = 0xEE01; // reset to default pro design
if (CB_Pattern_OverwriteDesigner.Checked)
{
dp.PlayerID = Player.Personal.PlayerID;
dp.PlayerName = Player.Personal.PlayerName;
dp.TownID = Player.Personal.TownID;
dp.TownName = Player.Personal.TownName;
}
const int w = DesignPatternPRO.Width * scale;
const int h = DesignPatternPRO.Height * scale;
PB_Sheet0.Image = ImageUtil.ResizeImage(dp.GetImage(0), w, h);