mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-24 23:57:12 -05:00
Revise some GUI interactions, accessibility
https://github.com/kwsch/PKHeX/issues/3758#issuecomment-1417458988 Removes the Level textbox behavior that resets the text to "1" when the textbox is empty. Can be left empty, and will be treated as 1 when values are stored. Adds an accessibility label for the "Make Shiny" button Adds an accessibility description and enter/space keypress to toggle similar to the click event. For determining if something is shiny, if the Shiny button is not tab-able, it is shiny. I wasn't able to get the Shiny star/square indicator to be able to be tabbed to for some reason.
This commit is contained in:
parent
79a05caff5
commit
3d7bfcfe11
|
|
@ -33,10 +33,11 @@ private void InitializeComponent()
|
|||
// GenderToggle
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.Name = "GenderToggle";
|
||||
this.Size = new System.Drawing.Size(18, 18);
|
||||
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.Click += new System.EventHandler(this.GenderToggle_Click);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GenderToggle_KeyDown);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System.Drawing;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Automation;
|
||||
using static PKHeX.WinForms.Properties.Resources;
|
||||
|
||||
namespace PKHeX.WinForms.Controls;
|
||||
|
|
@ -34,11 +36,33 @@ private int SetGender(int value)
|
|||
return value;
|
||||
}
|
||||
|
||||
private void GenderToggle_Click(object sender, System.EventArgs e)
|
||||
private void GenderToggle_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!AllowClick)
|
||||
return;
|
||||
ToggleGender();
|
||||
TryToggle();
|
||||
}
|
||||
|
||||
private void GenderToggle_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode is not (Keys.Enter or Keys.Space))
|
||||
return;
|
||||
|
||||
TryToggle();
|
||||
}
|
||||
|
||||
private void TryToggle()
|
||||
{
|
||||
var result = ToggleGender();
|
||||
if (!result.CanToggle)
|
||||
{
|
||||
AccessibilityObject.RaiseAutomationNotification(AutomationNotificationKind.Other,
|
||||
AutomationNotificationProcessing.All, $"Cannot change gender. Current value is {Gender}.");
|
||||
return;
|
||||
}
|
||||
|
||||
AccessibilityObject.RaiseAutomationNotification(AutomationNotificationKind.Other,
|
||||
AutomationNotificationProcessing.All, $"Gender changed to {Gender}.");
|
||||
}
|
||||
|
||||
public (bool CanToggle, int Value) ToggleGender()
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ private void SaveSpeciesLevelEXP(PKM pk)
|
|||
{
|
||||
pk.Species = (ushort)WinFormsUtil.GetIndex(CB_Species);
|
||||
pk.EXP = Util.ToUInt32(TB_EXP.Text);
|
||||
pk.Stat_Level = Util.ToInt32(TB_Level.Text);
|
||||
pk.Stat_Level = Math.Max(1, Util.ToInt32(TB_Level.Text));
|
||||
}
|
||||
|
||||
private void LoadOT(PKM pk)
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ private void InitializeComponent()
|
|||
this.FLP_PIDLeft = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.Label_PID = new System.Windows.Forms.Label();
|
||||
this.BTN_Shinytize = new System.Windows.Forms.Button();
|
||||
this.PB_ShinyStar = new System.Windows.Forms.PictureBox();
|
||||
this.PB_ShinySquare = new System.Windows.Forms.PictureBox();
|
||||
this.PB_ShinyStar = new PKHeX.WinForms.Controls.SelectablePictureBox();
|
||||
this.PB_ShinySquare = new PKHeX.WinForms.Controls.SelectablePictureBox();
|
||||
this.FLP_PIDRight = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.TB_PID = new System.Windows.Forms.TextBox();
|
||||
this.UC_Gender = new PKHeX.WinForms.Controls.GenderToggle();
|
||||
|
|
@ -428,6 +428,8 @@ private void InitializeComponent()
|
|||
//
|
||||
// BTN_Shinytize
|
||||
//
|
||||
this.BTN_Shinytize.AccessibleDescription = "When pressed, makes the entity shiny.";
|
||||
this.BTN_Shinytize.AccessibleName = "Shiny Button";
|
||||
this.BTN_Shinytize.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.BTN_Shinytize.Location = new System.Drawing.Point(48, 0);
|
||||
this.BTN_Shinytize.Margin = new System.Windows.Forms.Padding(0);
|
||||
|
|
@ -440,6 +442,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_ShinyStar
|
||||
//
|
||||
this.PB_ShinyStar.AccessibleDescription = "Currently Shiny";
|
||||
this.PB_ShinyStar.AccessibleName = "Currently Shiny";
|
||||
this.PB_ShinyStar.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_ShinyStar.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.PB_ShinyStar.Image = global::PKHeX.WinForms.Properties.Resources.rare_icon;
|
||||
this.PB_ShinyStar.InitialImage = global::PKHeX.WinForms.Properties.Resources.rare_icon;
|
||||
|
|
@ -454,6 +459,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_ShinySquare
|
||||
//
|
||||
this.PB_ShinySquare.AccessibleDescription = "Currently Xor0 Square Shiny";
|
||||
this.PB_ShinySquare.AccessibleName = "Currently Xor0 Square Shiny";
|
||||
this.PB_ShinySquare.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_ShinySquare.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.PB_ShinySquare.Image = global::PKHeX.WinForms.Properties.Resources.rare_icon_2;
|
||||
this.PB_ShinySquare.InitialImage = global::PKHeX.WinForms.Properties.Resources.rare_icon_2;
|
||||
|
|
@ -495,6 +503,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// UC_Gender
|
||||
//
|
||||
this.UC_Gender.AccessibleDescription = "Entity Gender Pane";
|
||||
this.UC_Gender.AccessibleName = "Entity Gender Pane";
|
||||
this.UC_Gender.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.UC_Gender.AllowClick = false;
|
||||
this.UC_Gender.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("UC_Gender.BackgroundImage")));
|
||||
this.UC_Gender.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
|
|
@ -2224,6 +2235,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Mark6
|
||||
//
|
||||
this.PB_Mark6.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Mark6.Image = global::PKHeX.WinForms.Properties.Resources.box_mark_06;
|
||||
this.PB_Mark6.InitialImage = global::PKHeX.WinForms.Properties.Resources.box_mark_06;
|
||||
this.PB_Mark6.Location = new System.Drawing.Point(128, 40);
|
||||
|
|
@ -2237,6 +2249,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Mark3
|
||||
//
|
||||
this.PB_Mark3.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Mark3.Image = global::PKHeX.WinForms.Properties.Resources.box_mark_03;
|
||||
this.PB_Mark3.InitialImage = global::PKHeX.WinForms.Properties.Resources.box_mark_03;
|
||||
this.PB_Mark3.Location = new System.Drawing.Point(56, 40);
|
||||
|
|
@ -2250,6 +2263,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Mark5
|
||||
//
|
||||
this.PB_Mark5.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Mark5.Image = global::PKHeX.WinForms.Properties.Resources.box_mark_05;
|
||||
this.PB_Mark5.InitialImage = global::PKHeX.WinForms.Properties.Resources.box_mark_05;
|
||||
this.PB_Mark5.Location = new System.Drawing.Point(104, 40);
|
||||
|
|
@ -2263,6 +2277,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_MarkCured
|
||||
//
|
||||
this.PB_MarkCured.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_MarkCured.Image = global::PKHeX.WinForms.Properties.Resources.anti_pokerus_icon;
|
||||
this.PB_MarkCured.InitialImage = global::PKHeX.WinForms.Properties.Resources.anti_pokerus_icon;
|
||||
this.PB_MarkCured.Location = new System.Drawing.Point(80, 16);
|
||||
|
|
@ -2276,6 +2291,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Mark2
|
||||
//
|
||||
this.PB_Mark2.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Mark2.Image = global::PKHeX.WinForms.Properties.Resources.box_mark_02;
|
||||
this.PB_Mark2.InitialImage = global::PKHeX.WinForms.Properties.Resources.box_mark_02;
|
||||
this.PB_Mark2.Location = new System.Drawing.Point(32, 40);
|
||||
|
|
@ -2289,6 +2305,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_MarkShiny
|
||||
//
|
||||
this.PB_MarkShiny.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_MarkShiny.Image = global::PKHeX.WinForms.Properties.Resources.rare_icon;
|
||||
this.PB_MarkShiny.InitialImage = global::PKHeX.WinForms.Properties.Resources.rare_icon;
|
||||
this.PB_MarkShiny.Location = new System.Drawing.Point(56, 16);
|
||||
|
|
@ -2302,6 +2319,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Mark1
|
||||
//
|
||||
this.PB_Mark1.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Mark1.Image = global::PKHeX.WinForms.Properties.Resources.box_mark_01;
|
||||
this.PB_Mark1.InitialImage = global::PKHeX.WinForms.Properties.Resources.box_mark_01;
|
||||
this.PB_Mark1.Location = new System.Drawing.Point(8, 40);
|
||||
|
|
@ -2315,6 +2333,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Mark4
|
||||
//
|
||||
this.PB_Mark4.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Mark4.Image = global::PKHeX.WinForms.Properties.Resources.box_mark_04;
|
||||
this.PB_Mark4.InitialImage = global::PKHeX.WinForms.Properties.Resources.box_mark_04;
|
||||
this.PB_Mark4.Location = new System.Drawing.Point(80, 40);
|
||||
|
|
@ -2341,6 +2360,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Favorite
|
||||
//
|
||||
this.PB_Favorite.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Favorite.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.PB_Favorite.Image = global::PKHeX.WinForms.Properties.Resources.icon_favo;
|
||||
this.PB_Favorite.InitialImage = global::PKHeX.WinForms.Properties.Resources.icon_favo;
|
||||
|
|
@ -2355,6 +2375,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_Origin
|
||||
//
|
||||
this.PB_Origin.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_Origin.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.PB_Origin.Location = new System.Drawing.Point(48, 0);
|
||||
this.PB_Origin.Margin = new System.Windows.Forms.Padding(0);
|
||||
|
|
@ -2367,6 +2388,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// PB_BattleVersion
|
||||
//
|
||||
this.PB_BattleVersion.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.PB_BattleVersion.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.PB_BattleVersion.Image = global::PKHeX.WinForms.Properties.Resources.icon_btlrom;
|
||||
this.PB_BattleVersion.InitialImage = global::PKHeX.WinForms.Properties.Resources.icon_btlrom;
|
||||
|
|
@ -2390,7 +2412,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// ShinyLeaf
|
||||
//
|
||||
this.ShinyLeaf.Location = new System.Drawing.Point(56, 240);
|
||||
this.ShinyLeaf.AccessibleDescription = "Gen 4 shiny leaf crown control";
|
||||
this.ShinyLeaf.AccessibleName = "Gen 4 shiny leaf crown control";
|
||||
this.ShinyLeaf.Location = new System.Drawing.Point(56, 256);
|
||||
this.ShinyLeaf.Margin = new System.Windows.Forms.Padding(56, 8, 0, 0);
|
||||
this.ShinyLeaf.Name = "ShinyLeaf";
|
||||
this.ShinyLeaf.Size = new System.Drawing.Size(200, 64);
|
||||
|
|
@ -2486,6 +2510,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// UC_OTGender
|
||||
//
|
||||
this.UC_OTGender.AccessibleDescription = "Trainer Gender Pane";
|
||||
this.UC_OTGender.AccessibleName = "Trainer Gender Pane";
|
||||
this.UC_OTGender.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.UC_OTGender.AllowClick = true;
|
||||
this.UC_OTGender.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("UC_OTGender.BackgroundImage")));
|
||||
this.UC_OTGender.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
|
|
@ -2679,6 +2706,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// UC_HTGender
|
||||
//
|
||||
this.UC_HTGender.AccessibleDescription = "Handling Trainer Gender Pane";
|
||||
this.UC_HTGender.AccessibleName = "Handling Trainer Gender Pane";
|
||||
this.UC_HTGender.AccessibleRole = System.Windows.Forms.AccessibleRole.Graphic;
|
||||
this.UC_HTGender.AllowClick = true;
|
||||
this.UC_HTGender.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("UC_HTGender.BackgroundImage")));
|
||||
this.UC_HTGender.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
|
|
@ -3032,8 +3062,8 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.FlowLayoutPanel FLP_PIDLeft;
|
||||
private System.Windows.Forms.Label Label_PID;
|
||||
private System.Windows.Forms.Button BTN_Shinytize;
|
||||
private System.Windows.Forms.PictureBox PB_ShinyStar;
|
||||
private System.Windows.Forms.PictureBox PB_ShinySquare;
|
||||
private PKHeX.WinForms.Controls.SelectablePictureBox PB_ShinyStar;
|
||||
private PKHeX.WinForms.Controls.SelectablePictureBox PB_ShinySquare;
|
||||
private System.Windows.Forms.FlowLayoutPanel FLP_PIDRight;
|
||||
private System.Windows.Forms.TextBox TB_PID;
|
||||
private System.Windows.Forms.Button BTN_RerollPID;
|
||||
|
|
|
|||
|
|
@ -866,17 +866,18 @@ private void UpdateEXPLevel(object sender, EventArgs e)
|
|||
if (sender == TB_EXP)
|
||||
{
|
||||
// Change the Level
|
||||
var input = Util.ToUInt32(TB_EXP.Text);
|
||||
var exp = input;
|
||||
var expInput = Util.ToUInt32(TB_EXP.Text);
|
||||
var expCalc = expInput;
|
||||
var gr = Entity.PersonalInfo.EXPGrowth;
|
||||
int level = Experience.GetLevel(exp, gr);
|
||||
if (level == 100)
|
||||
exp = Experience.GetEXP(100, gr);
|
||||
int lvlExp = Experience.GetLevel(expInput, gr);
|
||||
if (lvlExp == 100)
|
||||
expCalc = Experience.GetEXP(100, gr);
|
||||
|
||||
if (level != Util.ToInt32(TB_Level.Text))
|
||||
TB_Level.Text = level.ToString();
|
||||
if (input != exp && !HaX)
|
||||
TB_EXP.Text = exp.ToString();
|
||||
var lvlInput = Math.Max(1, Util.ToInt32(TB_Level.Text));
|
||||
if (lvlInput != lvlExp)
|
||||
TB_Level.Text = lvlExp.ToString();
|
||||
if (expInput != expCalc && !HaX)
|
||||
TB_EXP.Text = expCalc.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -884,7 +885,7 @@ private void UpdateEXPLevel(object sender, EventArgs e)
|
|||
int input = Util.ToInt32(TB_Level.Text);
|
||||
int level = Math.Max(1, Math.Min(input, 100));
|
||||
|
||||
if (input != level)
|
||||
if (input != level && !string.IsNullOrWhiteSpace(TB_Level.Text))
|
||||
TB_Level.Text = level.ToString();
|
||||
TB_EXP.Text = Experience.GetEXP(level, Entity.PersonalInfo.EXPGrowth).ToString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user