Re-flow Stat editor for alignment/showing all text

Some languages have localized these labels to long strings; previously they were truncated (probably frustrating); now, they all show (wrapped text is the best I can do -- better than truncating?)
This commit is contained in:
Kurt 2026-03-12 01:29:58 -05:00
parent 2f95536b13
commit bb363a7a3d
5 changed files with 838 additions and 954 deletions

View File

@ -2015,7 +2015,7 @@ private void InitializeComponent()
MC_Move1.Name = "MC_Move1"; MC_Move1.Name = "MC_Move1";
MC_Move1.PP = 0; MC_Move1.PP = 0;
MC_Move1.PPUps = 0; MC_Move1.PPUps = 0;
MC_Move1.SelectedMove = (ushort)0; MC_Move1.SelectedMove = 0;
MC_Move1.Size = new System.Drawing.Size(246, 27); MC_Move1.Size = new System.Drawing.Size(246, 27);
MC_Move1.TabIndex = 1; MC_Move1.TabIndex = 1;
// //
@ -2029,7 +2029,7 @@ private void InitializeComponent()
MC_Move2.Name = "MC_Move2"; MC_Move2.Name = "MC_Move2";
MC_Move2.PP = 0; MC_Move2.PP = 0;
MC_Move2.PPUps = 0; MC_Move2.PPUps = 0;
MC_Move2.SelectedMove = (ushort)0; MC_Move2.SelectedMove = 0;
MC_Move2.Size = new System.Drawing.Size(246, 27); MC_Move2.Size = new System.Drawing.Size(246, 27);
MC_Move2.TabIndex = 2; MC_Move2.TabIndex = 2;
// //
@ -2043,7 +2043,7 @@ private void InitializeComponent()
MC_Move3.Name = "MC_Move3"; MC_Move3.Name = "MC_Move3";
MC_Move3.PP = 0; MC_Move3.PP = 0;
MC_Move3.PPUps = 0; MC_Move3.PPUps = 0;
MC_Move3.SelectedMove = (ushort)0; MC_Move3.SelectedMove = 0;
MC_Move3.Size = new System.Drawing.Size(246, 27); MC_Move3.Size = new System.Drawing.Size(246, 27);
MC_Move3.TabIndex = 3; MC_Move3.TabIndex = 3;
// //
@ -2057,7 +2057,7 @@ private void InitializeComponent()
MC_Move4.Name = "MC_Move4"; MC_Move4.Name = "MC_Move4";
MC_Move4.PP = 0; MC_Move4.PP = 0;
MC_Move4.PPUps = 0; MC_Move4.PPUps = 0;
MC_Move4.SelectedMove = (ushort)0; MC_Move4.SelectedMove = 0;
MC_Move4.Size = new System.Drawing.Size(246, 27); MC_Move4.Size = new System.Drawing.Size(246, 27);
MC_Move4.TabIndex = 4; MC_Move4.TabIndex = 4;
// //
@ -3307,7 +3307,7 @@ private void InitializeComponent()
// //
// StatusView // StatusView
// //
StatusView.Location = new System.Drawing.Point(2, 303); StatusView.Location = new System.Drawing.Point(2, 322);
StatusView.Margin = new System.Windows.Forms.Padding(0); StatusView.Margin = new System.Windows.Forms.Padding(0);
StatusView.Name = "StatusView"; StatusView.Name = "StatusView";
StatusView.Size = new System.Drawing.Size(64, 64); StatusView.Size = new System.Drawing.Size(64, 64);

File diff suppressed because it is too large Load Diff

View File

@ -658,38 +658,106 @@ private void SetStatOrder(StatEditorStatOrder order)
if (order == StatOrder) if (order == StatOrder)
return; return;
// https://stackoverflow.com/a/30219698
// WinForms hack to create the handles and avoid Z-order changing on visibility toggle.
// Otherwise, our stat ordering may be incorrect if we change it more than once.
foreach (Control ctrl in FLP_Stats.Controls)
_ = ctrl.Handle;
// In Generation 1, Special Defense and Special Attack are combined. // In Generation 1, Special Defense and Special Attack are combined.
// Additionally, Speed is shown before Special. // Additionally, Speed is shown before Special.
const int baseIndex = 1;
if (order == StatEditorStatOrder.Gen1Special) if (order == StatEditorStatOrder.Gen1Special)
{ {
FLP_SpD.Visible = Label_SPA.Visible = false; SetStatGridRow(3, 4); // Speed
SetStatGridRow(4, 5); // Special
SetStatVisibility(5, false);
Label_SPA.Visible = false;
Label_SPC.Visible = true; Label_SPC.Visible = true;
FLP_Stats.Controls.SetChildIndex(FLP_Spe, baseIndex + 3); // Speed
} }
else if (order == StatEditorStatOrder.Current) else if (order == StatEditorStatOrder.Current)
{ {
FLP_SpD.Visible = Label_SPA.Visible = true; SetStatGridRow(4, 4); // SpA
SetStatGridRow(3, 6); // Speed
SetStatVisibility(5, true);
Label_SPA.Visible = true;
Label_SPC.Visible = false; Label_SPC.Visible = false;
FLP_Stats.Controls.SetChildIndex(FLP_Spe, baseIndex + 5); // Speed
} }
else else
{ {
throw new ArgumentOutOfRangeException(nameof(order), order, null); throw new ArgumentOutOfRangeException(nameof(order), order, null);
} }
UpdateStatGridRowHeights();
StatOrder = order; StatOrder = order;
} }
private float GetStatRowHeight() => TLP_StatGrid.RowStyles.Count > 1 ? TLP_StatGrid.RowStyles[1].Height : 0;
private void UpdateStatGridRowHeights()
{
var height = GetStatRowHeight();
for (int row = 1; row <= 6; row++) // Iterate over stat rows (1-based index)
TLP_StatGrid.RowStyles[row].Height = IsStatRowVisible(row) ? height : 0;
}
private bool IsStatRowVisible(int row)
{
for (int i = 0; i < L_Stats.Length; i++)
{
Control label = (i == 4) ? FLP_SPA : L_Stats[i];
if (label.Visible && TLP_StatGrid.GetRow(label) == row)
return true;
}
return false;
}
private void SetStatVisibility(int statIndex, bool visible)
{
L_Stats[statIndex].Visible = visible;
MT_Base[statIndex].Visible = visible;
MT_IVs[statIndex].Visible = visible;
MT_EVs[statIndex].Visible = visible;
MT_AVs[statIndex].Visible = visible;
MT_GVs[statIndex].Visible = visible;
MT_Stats[statIndex].Visible = visible;
}
private void SetStatGridRow(int statIndex, int row)
{
Control stat = (statIndex == 4) ? FLP_SPA : L_Stats[statIndex];
TLP_StatGrid.SetRow(stat, row);
TLP_StatGrid.SetRow(MT_Base[statIndex], row);
TLP_StatGrid.SetRow(MT_IVs[statIndex], row);
TLP_StatGrid.SetRow(MT_EVs[statIndex], row);
TLP_StatGrid.SetRow(MT_AVs[statIndex], row);
TLP_StatGrid.SetRow(MT_GVs[statIndex], row);
TLP_StatGrid.SetRow(MT_Stats[statIndex], row);
}
private void SetTotalRowVisible(bool visible)
{
var total = TLP_StatGrid.RowStyles[7];
total.SizeType = visible ? SizeType.AutoSize : SizeType.Absolute;
total.Height = 0; // AutoSize will ignore the height, but Absolute needs it to be zero to hide properly.
}
private static void SetColumnVisible(TableLayoutPanel panel, int index, bool visible)
{
if ((uint)index >= panel.ColumnStyles.Count)
return;
var style = panel.ColumnStyles[index];
// toggle individual control visibility in column
foreach (Control c in panel.Controls)
{
if (panel.GetColumn(c) == index)
c.Visible = visible;
}
style.SizeType = !visible ? SizeType.AutoSize : SizeType.Absolute;
}
public void ToggleInterface(PKM pk, byte format) public void ToggleInterface(PKM pk, byte format)
{ {
FLP_StatsTotal.Visible = format >= 3; SetTotalRowVisible(format >= 3);
FLP_Characteristic.Visible = format >= 3; FLP_Characteristic.Visible = format >= 3;
FLP_HPType.Visible = format <= 7 || pk is PB8; FLP_HPType.Visible = format <= 7 || pk is PB8;
FLP_TeraType.Visible = FLP_TeraInner.Visible = pk is ITeraType; FLP_TeraType.Visible = FLP_TeraInner.Visible = pk is ITeraType;
@ -698,9 +766,11 @@ public void ToggleInterface(PKM pk, byte format)
FLP_AlphaNoble.Visible = pk is IAlpha; FLP_AlphaNoble.Visible = pk is IAlpha;
CHK_IsNoble.Visible = pk is PA8; CHK_IsNoble.Visible = pk is PA8;
// Update stat ordering if necessary. Gen 1 shows Speed before Special, and combines Special Attack and Special Defense into one "Special" stat.
// Later gens show Speed after Special, and have separate Special Attack and Special Defense stats.
SetStatOrder(format == 1 ? StatEditorStatOrder.Gen1Special : StatEditorStatOrder.Current); SetStatOrder(format == 1 ? StatEditorStatOrder.Gen1Special : StatEditorStatOrder.Current);
switch (format) switch (format) // EV Mask (Gen1/2 is 16-bit as opposed to 8-bit in later gens)
{ {
case 1 or 2: case 1 or 2:
TB_IVHP.Enabled = false; TB_IVHP.Enabled = false;
@ -712,27 +782,26 @@ public void ToggleInterface(PKM pk, byte format)
break; break;
} }
var showAV = pk is IAwakened; // Misc stat properties: toggle columns if present for object.
Label_AVs.Visible = TB_AVTotal.Visible = BTN_RandomAVs.Visible = showAV; var showAVs = pk is IAwakened;
foreach (var mtb in MT_AVs) var showGVs = pk is IGanbaru;
mtb.Visible = showAV; var showEVs = !showAVs || HaX;
Label_EVs.Visible = TB_EVTotal.Visible = BTN_RandomEVs.Visible = !showAV; SetColumnVisible(TLP_StatGrid, 3, showEVs);
foreach (var mtb in MT_EVs) SetColumnVisible(TLP_StatGrid, 4, showAVs);
mtb.Visible = !showAV; SetColumnVisible(TLP_StatGrid, 5, showGVs);
BTN_RandomEVs.Visible = showEVs;
BTN_RandomAVs.Visible = showAVs;
// no randomizing GVs; maxing/zeroing is all that is needed.
FLP_PKMEditors.PerformLayout(); FLP_PKMEditors.PerformLayout();
return;
var showGV = pk is IGanbaru; static void SetEVMaskSize(Size s, string mask, ReadOnlySpan<MaskedTextBox> arr)
Label_GVs.Visible = showGV;
foreach (var mtb in MT_GVs)
mtb.Visible = showGV;
static void SetEVMaskSize(Size s, string Mask, MaskedTextBox[] arr)
{ {
foreach (var ctrl in arr) foreach (var ctrl in arr)
{ {
ctrl.Size = s; ctrl.Size = s;
ctrl.Mask = Mask; ctrl.Mask = mask;
} }
} }
} }

View File

@ -162,7 +162,7 @@ private void InitializeComponent()
// //
B_PopoutBox.ContextMenuStrip = PopoutMenu; B_PopoutBox.ContextMenuStrip = PopoutMenu;
B_PopoutBox.Image = Properties.Resources.popout; B_PopoutBox.Image = Properties.Resources.popout;
B_PopoutBox.Location = new System.Drawing.Point(3, 3); B_PopoutBox.Location = new System.Drawing.Point(3, 15);
B_PopoutBox.Margin = new System.Windows.Forms.Padding(0); B_PopoutBox.Margin = new System.Windows.Forms.Padding(0);
B_PopoutBox.Name = "B_PopoutBox"; B_PopoutBox.Name = "B_PopoutBox";
B_PopoutBox.Size = new System.Drawing.Size(24, 24); B_PopoutBox.Size = new System.Drawing.Size(24, 24);
@ -174,13 +174,13 @@ private void InitializeComponent()
// //
PopoutMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_PopoutBoxSingle, Menu_PopoutBoxAll }); PopoutMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { Menu_PopoutBoxSingle, Menu_PopoutBoxAll });
PopoutMenu.Name = "PopoutMenu"; PopoutMenu.Name = "PopoutMenu";
PopoutMenu.Size = new System.Drawing.Size(181, 70); PopoutMenu.Size = new System.Drawing.Size(137, 48);
// //
// Menu_PopoutBoxSingle // Menu_PopoutBoxSingle
// //
Menu_PopoutBoxSingle.Image = Properties.Resources.open; Menu_PopoutBoxSingle.Image = Properties.Resources.open;
Menu_PopoutBoxSingle.Name = "Menu_PopoutBoxSingle"; Menu_PopoutBoxSingle.Name = "Menu_PopoutBoxSingle";
Menu_PopoutBoxSingle.Size = new System.Drawing.Size(180, 22); Menu_PopoutBoxSingle.Size = new System.Drawing.Size(136, 22);
Menu_PopoutBoxSingle.Text = "Single Box"; Menu_PopoutBoxSingle.Text = "Single Box";
Menu_PopoutBoxSingle.Click += Menu_PopoutBoxSingle_Click; Menu_PopoutBoxSingle.Click += Menu_PopoutBoxSingle_Click;
// //
@ -188,7 +188,7 @@ private void InitializeComponent()
// //
Menu_PopoutBoxAll.Image = Properties.Resources.database; Menu_PopoutBoxAll.Image = Properties.Resources.database;
Menu_PopoutBoxAll.Name = "Menu_PopoutBoxAll"; Menu_PopoutBoxAll.Name = "Menu_PopoutBoxAll";
Menu_PopoutBoxAll.Size = new System.Drawing.Size(180, 22); Menu_PopoutBoxAll.Size = new System.Drawing.Size(136, 22);
Menu_PopoutBoxAll.Text = "All Boxes"; Menu_PopoutBoxAll.Text = "All Boxes";
Menu_PopoutBoxAll.Click += Menu_PopoutBoxAll_Click; Menu_PopoutBoxAll.Click += Menu_PopoutBoxAll_Click;
// //
@ -196,7 +196,7 @@ private void InitializeComponent()
// //
B_SearchBox.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; B_SearchBox.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
B_SearchBox.Image = Properties.Resources.other; B_SearchBox.Image = Properties.Resources.other;
B_SearchBox.Location = new System.Drawing.Point(414, 3); B_SearchBox.Location = new System.Drawing.Point(414, 15);
B_SearchBox.Margin = new System.Windows.Forms.Padding(0); B_SearchBox.Margin = new System.Windows.Forms.Padding(0);
B_SearchBox.Name = "B_SearchBox"; B_SearchBox.Name = "B_SearchBox";
B_SearchBox.Size = new System.Drawing.Size(24, 24); B_SearchBox.Size = new System.Drawing.Size(24, 24);
@ -214,7 +214,7 @@ private void InitializeComponent()
Box.CurrentBox = -1; Box.CurrentBox = -1;
Box.Editor = null; Box.Editor = null;
Box.FlagIllegal = false; Box.FlagIllegal = false;
Box.Location = new System.Drawing.Point(107, 7); Box.Location = new System.Drawing.Point(107, 19);
Box.M = null; Box.M = null;
Box.Name = "Box"; Box.Name = "Box";
Box.Size = new System.Drawing.Size(251, 187); Box.Size = new System.Drawing.Size(251, 187);

View File

@ -383,7 +383,7 @@ public void InitializeComponent()
// //
splitContainer1.Panel2.Controls.Add(C_SAV); splitContainer1.Panel2.Controls.Add(C_SAV);
splitContainer1.Panel2.Padding = new System.Windows.Forms.Padding(0, 0, 1, 3); splitContainer1.Panel2.Padding = new System.Windows.Forms.Padding(0, 0, 1, 3);
splitContainer1.Size = new System.Drawing.Size(864, 367); splitContainer1.Size = new System.Drawing.Size(864, 383);
splitContainer1.SplitterDistance = 400; splitContainer1.SplitterDistance = 400;
splitContainer1.SplitterWidth = 1; splitContainer1.SplitterWidth = 1;
splitContainer1.TabIndex = 105; splitContainer1.TabIndex = 105;
@ -426,7 +426,7 @@ public void InitializeComponent()
PKME_Tabs.Location = new System.Drawing.Point(0, 0); PKME_Tabs.Location = new System.Drawing.Point(0, 0);
PKME_Tabs.Margin = new System.Windows.Forms.Padding(0); PKME_Tabs.Margin = new System.Windows.Forms.Padding(0);
PKME_Tabs.Name = "PKME_Tabs"; PKME_Tabs.Name = "PKME_Tabs";
PKME_Tabs.Size = new System.Drawing.Size(400, 367); PKME_Tabs.Size = new System.Drawing.Size(400, 383);
PKME_Tabs.TabIndex = 103; PKME_Tabs.TabIndex = 103;
PKME_Tabs.Unicode = true; PKME_Tabs.Unicode = true;
PKME_Tabs.LegalityChanged += PKME_Tabs_LegalityChanged; PKME_Tabs.LegalityChanged += PKME_Tabs_LegalityChanged;
@ -446,7 +446,7 @@ public void InitializeComponent()
C_SAV.Menu_Redo = null; C_SAV.Menu_Redo = null;
C_SAV.Menu_Undo = null; C_SAV.Menu_Undo = null;
C_SAV.Name = "C_SAV"; C_SAV.Name = "C_SAV";
C_SAV.Size = new System.Drawing.Size(462, 364); C_SAV.Size = new System.Drawing.Size(462, 380);
C_SAV.TabIndex = 104; C_SAV.TabIndex = 104;
C_SAV.ViewIndex = -1; C_SAV.ViewIndex = -1;
C_SAV.RequestCloneData += ClickClone; C_SAV.RequestCloneData += ClickClone;
@ -470,7 +470,7 @@ public void InitializeComponent()
// splitContainer2.Panel2 // splitContainer2.Panel2
// //
splitContainer2.Panel2.Controls.Add(splitContainer1); splitContainer2.Panel2.Controls.Add(splitContainer1);
splitContainer2.Size = new System.Drawing.Size(864, 393); splitContainer2.Size = new System.Drawing.Size(864, 409);
splitContainer2.SplitterDistance = 25; splitContainer2.SplitterDistance = 25;
splitContainer2.SplitterWidth = 1; splitContainer2.SplitterWidth = 1;
splitContainer2.TabIndex = 106; splitContainer2.TabIndex = 106;
@ -480,7 +480,7 @@ public void InitializeComponent()
AllowDrop = true; AllowDrop = true;
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
ClientSize = new System.Drawing.Size(864, 393); ClientSize = new System.Drawing.Size(864, 409);
Controls.Add(splitContainer2); Controls.Add(splitContainer2);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
Icon = Properties.Resources.Icon; Icon = Properties.Resources.Icon;