Misc tweaks

Closes #3878

Pictures are Zoom instead of AutoSize so there's no need to downscale or dynamically position the smaller 2.
Fix my oopsie on docked tabs (hid the Cancel/Save button!), change sizing.
This commit is contained in:
Kurt 2023-05-11 20:56:45 -07:00
parent 54b663ae6f
commit 34f4df3d4b
3 changed files with 34 additions and 40 deletions

View file

@ -29,21 +29,22 @@ public static class DXT1
var color0 = ReadUInt16LittleEndian(span);
var color1 = ReadUInt16LittleEndian(span[2..]);
var indices = ReadUInt32LittleEndian(span[4..]);
uint indices = ReadUInt32LittleEndian(span[4..]);
GetColors(colors, color0, color1);
for (int pixelY = 0; pixelY < 4; pixelY++)
{
var baseIndex = (((4 * y) + pixelY) * width) + (x * 4);
var baseShift = (4 * pixelY);
int baseIndex = (((4 * y) + pixelY) * width) + (x * 4);
int baseShift = (4 * pixelY);
for (int pixelX = 0; pixelX < 4; pixelX++)
{
int pixelIndex = baseIndex + pixelX;
var shift = (baseShift + pixelX) << 1;
var index = (indices >> shift) & 0x3;
var color = colors[(int)index];
var dest = result[(pixelIndex * 4)..];
int shift = (baseShift + pixelX) << 1;
int index = (int)(indices >> shift) & 0x3;
var color = colors[index];
dest[0] = color.B;
dest[1] = color.G;
dest[2] = color.R;
@ -56,17 +57,17 @@ public static class DXT1
private static void GetColors(Span<Color> colors, ushort color0, ushort color1)
{
colors[0] = RGB565ToColor(color0);
colors[1] = RGB565ToColor(color1);
var c0 = colors[0] = RGB565ToColor(color0);
var c1 = colors[1] = RGB565ToColor(color1);
if (color0 > color1)
{
colors[2] = Lerp(colors[0], colors[1], 1f / 3f);
colors[3] = Lerp(colors[0], colors[1], 2f / 3f);
colors[2] = Lerp(c0, c1, 1f / 3f);
colors[3] = Lerp(c0, c1, 2f / 3f);
}
else
{
colors[2] = Lerp(colors[0], colors[1], 0.5f);
colors[2] = Lerp(c0, c1, 0.5f);
colors[3] = default; // 0
}
}
@ -82,14 +83,15 @@ public static class DXT1
b = (byte)(b << 3 | b >> 2);
return new(0xFF, r, g, b);
}
private static Color Lerp(Color c1, Color c2, float t)
{
int r = (int)(c1.R + ((c2.R - c1.R) * t));
int g = (int)(c1.G + ((c2.G - c1.G) * t));
int b = (int)(c1.B + ((c2.B - c1.B) * t));
int aVal = (int)(c1.A + ((c2.A - c1.A) * t));
byte r = (byte)(c1.R + ((c2.R - c1.R) * t));
byte g = (byte)(c1.G + ((c2.G - c1.G) * t));
byte b = (byte)(c1.B + ((c2.B - c1.B) * t));
byte a = (byte)(c1.A + ((c2.A - c1.A) * t));
return new((byte)aVal, (byte)r, (byte)g, (byte)b);
return new(a, r, g, b);
}
private readonly record struct Color(byte A, byte R, byte G, byte B);

View file

@ -129,10 +129,10 @@ namespace PKHeX.WinForms
// B_Cancel
//
B_Cancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
B_Cancel.Location = new System.Drawing.Point(345, 440);
B_Cancel.Location = new System.Drawing.Point(281, 360);
B_Cancel.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
B_Cancel.Name = "B_Cancel";
B_Cancel.Size = new System.Drawing.Size(101, 36);
B_Cancel.Size = new System.Drawing.Size(100, 32);
B_Cancel.TabIndex = 0;
B_Cancel.Text = "Cancel";
B_Cancel.UseVisualStyleBackColor = true;
@ -141,10 +141,10 @@ namespace PKHeX.WinForms
// B_Save
//
B_Save.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
B_Save.Location = new System.Drawing.Point(453, 440);
B_Save.Location = new System.Drawing.Point(391, 360);
B_Save.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
B_Save.Name = "B_Save";
B_Save.Size = new System.Drawing.Size(101, 36);
B_Save.Size = new System.Drawing.Size(100, 32);
B_Save.TabIndex = 1;
B_Save.Text = "Save";
B_Save.UseVisualStyleBackColor = true;
@ -618,15 +618,15 @@ namespace PKHeX.WinForms
//
// TC_Editor
//
TC_Editor.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
TC_Editor.Controls.Add(Tab_Overview);
TC_Editor.Controls.Add(Tab_MiscValues);
TC_Editor.Controls.Add(Tab_Images);
TC_Editor.Dock = System.Windows.Forms.DockStyle.Fill;
TC_Editor.Location = new System.Drawing.Point(0, 0);
TC_Editor.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
TC_Editor.Name = "TC_Editor";
TC_Editor.SelectedIndex = 0;
TC_Editor.Size = new System.Drawing.Size(496, 361);
TC_Editor.Size = new System.Drawing.Size(496, 352);
TC_Editor.TabIndex = 54;
//
// Tab_Overview
@ -656,7 +656,7 @@ namespace PKHeX.WinForms
Tab_Overview.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
Tab_Overview.Name = "Tab_Overview";
Tab_Overview.Padding = new System.Windows.Forms.Padding(5, 4, 5, 4);
Tab_Overview.Size = new System.Drawing.Size(488, 333);
Tab_Overview.Size = new System.Drawing.Size(488, 324);
Tab_Overview.TabIndex = 0;
Tab_Overview.Text = "Overview";
Tab_Overview.UseVisualStyleBackColor = true;
@ -732,7 +732,7 @@ namespace PKHeX.WinForms
Tab_MiscValues.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
Tab_MiscValues.Name = "Tab_MiscValues";
Tab_MiscValues.Padding = new System.Windows.Forms.Padding(5, 4, 5, 4);
Tab_MiscValues.Size = new System.Drawing.Size(501, 360);
Tab_MiscValues.Size = new System.Drawing.Size(488, 324);
Tab_MiscValues.TabIndex = 4;
Tab_MiscValues.Text = "Misc";
Tab_MiscValues.UseVisualStyleBackColor = true;
@ -862,7 +862,7 @@ namespace PKHeX.WinForms
//
// L_X
//
L_X.Location = new System.Drawing.Point(9, 21);
L_X.Location = new System.Drawing.Point(9, 16);
L_X.Margin = new System.Windows.Forms.Padding(0);
L_X.Name = "L_X";
L_X.Size = new System.Drawing.Size(110, 31);
@ -877,7 +877,7 @@ namespace PKHeX.WinForms
Tab_Images.Controls.Add(P_CurrPhoto);
Tab_Images.Location = new System.Drawing.Point(4, 24);
Tab_Images.Name = "Tab_Images";
Tab_Images.Size = new System.Drawing.Size(501, 360);
Tab_Images.Size = new System.Drawing.Size(488, 324);
Tab_Images.TabIndex = 5;
Tab_Images.Text = "Images";
Tab_Images.UseVisualStyleBackColor = true;
@ -886,7 +886,7 @@ namespace PKHeX.WinForms
//
P_InitialIcon.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
P_InitialIcon.Cursor = System.Windows.Forms.Cursors.Hand;
P_InitialIcon.Location = new System.Drawing.Point(410, 169);
P_InitialIcon.Location = new System.Drawing.Point(387, 146);
P_InitialIcon.Name = "P_InitialIcon";
P_InitialIcon.Size = new System.Drawing.Size(88, 88);
P_InitialIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
@ -898,7 +898,7 @@ namespace PKHeX.WinForms
//
P_CurrIcon.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
P_CurrIcon.Cursor = System.Windows.Forms.Cursors.Hand;
P_CurrIcon.Location = new System.Drawing.Point(410, 37);
P_CurrIcon.Location = new System.Drawing.Point(387, 16);
P_CurrIcon.Name = "P_CurrIcon";
P_CurrIcon.Size = new System.Drawing.Size(88, 88);
P_CurrIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
@ -910,9 +910,9 @@ namespace PKHeX.WinForms
//
P_CurrPhoto.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
P_CurrPhoto.Cursor = System.Windows.Forms.Cursors.Hand;
P_CurrPhoto.Location = new System.Drawing.Point(3, 37);
P_CurrPhoto.Location = new System.Drawing.Point(16, 16);
P_CurrPhoto.Name = "P_CurrPhoto";
P_CurrPhoto.Size = new System.Drawing.Size(320, 220);
P_CurrPhoto.Size = new System.Drawing.Size(362, 218);
P_CurrPhoto.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
P_CurrPhoto.TabIndex = 77;
P_CurrPhoto.TabStop = false;
@ -921,7 +921,7 @@ namespace PKHeX.WinForms
// SAV_Trainer9
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(496, 361);
ClientSize = new System.Drawing.Size(496, 401);
Controls.Add(TC_Editor);
Controls.Add(B_Save);
Controls.Add(B_Cancel);

View file

@ -61,14 +61,6 @@ public partial class SAV_Trainer9 : Form
P_CurrPhoto.Image = GetImage(blocks, KPictureProfileCurrent, KPictureProfileCurrentWidth, KPictureProfileCurrentHeight);
P_CurrIcon.Image = GetImage(blocks, KPictureIconCurrent, KPictureIconCurrentWidth, KPictureIconCurrentHeight);
P_InitialIcon.Image = GetImage(blocks, KPictureIconInitial, KPictureIconInitialWidth, KPictureIconInitialHeight);
P_CurrPhoto.Height = P_CurrPhoto.Image.Height / 4;
P_CurrPhoto.Width = P_CurrPhoto.Image.Width / 4;
P_CurrIcon.Height = P_CurrIcon.Image.Height / 4;
P_CurrIcon.Width = P_CurrIcon.Image.Width / 4;
P_InitialIcon.Height = P_InitialIcon.Image.Height / 4;
P_InitialIcon.Width = P_InitialIcon.Image.Width / 4;
P_CurrIcon.Location = P_CurrPhoto.Location with { X = P_CurrPhoto.Location.X + P_CurrPhoto.Width + 8 };
P_InitialIcon.Location = P_CurrIcon.Location with { Y = P_CurrIcon.Location.Y + P_CurrIcon.Height + 8 };
}
private readonly bool Loading;