Misc nullable handling update for winforms

Didn't enable it; there's some side effects from properties that used to be null in PKHeX.Core
there's probably more, but just handling a few.
Closes #2642
This commit is contained in:
Kurt
2020-01-18 13:27:48 -08:00
parent 9b0b0cb1a6
commit f3a9a9d7c2
2 changed files with 13 additions and 10 deletions

View File

@@ -135,10 +135,10 @@ public BoxManipulatorWF(SAVEditor editor)
protected override bool CanManipulateRegion(int start, int end, string prompt, string fail)
{
if (prompt != null && WinFormsUtil.Prompt(MessageBoxButtons.YesNo, prompt) != DialogResult.Yes)
if (!string.IsNullOrEmpty(prompt) && WinFormsUtil.Prompt(MessageBoxButtons.YesNo, prompt) != DialogResult.Yes)
return false;
bool canModify = base.CanManipulateRegion(start, end, prompt, fail);
if (!canModify && fail != null)
if (!canModify && !string.IsNullOrEmpty(fail))
WinFormsUtil.Alert(fail);
return canModify;
}

View File

@@ -265,8 +265,9 @@ private void ResetDaycare()
else
{
L_SlotOccupied[i].Text = $"{i + 1}: ✘";
if (pb.Image != null)
pb.Image = ImageUtil.ChangeOpacity(pb.Image, 0.6);
var current = pb.Image;
if (current != null)
pb.Image = ImageUtil.ChangeOpacity(current, 0.6);
}
}
@@ -275,12 +276,13 @@ private void ResetDaycare()
DayCare_HasEgg.Checked = egg == true;
var seed = SAV.GetDaycareRNGSeed(SAV.DaycareIndex);
if (seed != null)
bool hasSeed = !string.IsNullOrEmpty(seed);
if (hasSeed)
{
TB_RNGSeed.MaxLength = SAV.DaycareSeedSize;
TB_RNGSeed.Text = seed;
}
L_DaycareSeed.Visible = TB_RNGSeed.Visible = seed != null;
L_DaycareSeed.Visible = TB_RNGSeed.Visible = hasSeed;
}
private PictureBox UpdateSlot(int relIndex)
@@ -369,7 +371,7 @@ public void FinishBoxManipulation(string message, bool all, int count)
{
SetPKMBoxes();
UpdateBoxViewers(all);
if (message != null)
if (!string.IsNullOrWhiteSpace(message))
WinFormsUtil.Alert(message + $" ({count})");
else
SystemSounds.Asterisk.Play();
@@ -848,7 +850,7 @@ public bool OpenPCBoxBin(byte[] input, out string c)
public bool OpenBattleVideo(BattleVideo b, out string c)
{
if (b == null || SAV.Generation != b.Generation)
if (SAV.Generation != b.Generation)
{
c = MsgSaveBoxImportVideoFailGeneration;
return false;
@@ -1142,9 +1144,10 @@ private void ToggleViewMisc(SaveFile sav)
{
case 6:
case 7:
TB_GameSync.Enabled = sav.GameSyncID != null;
var gsid = sav.GameSyncID;
TB_GameSync.Enabled = !string.IsNullOrEmpty(gsid);
TB_GameSync.MaxLength = sav.GameSyncIDSize;
TB_GameSync.Text = (sav.GameSyncID ?? 0.ToString()).PadLeft(sav.GameSyncIDSize, '0');
TB_GameSync.Text = (string.IsNullOrEmpty(gsid) ? 0.ToString() : gsid).PadLeft(sav.GameSyncIDSize, '0');
break;
}
}