Minor clean

collapse some expressions
handle some compiler messages
This commit is contained in:
Kurt 2020-10-03 18:59:36 -07:00
parent 816f24e3db
commit 7efaa5ab71
4 changed files with 27 additions and 105 deletions

View File

@ -141,8 +141,10 @@ public T Value
}
// ReSharper disable once UnusedMember.Local
#pragma warning disable CA1822 // do not make this static, we want it to show up in a property grid as a readonly value
[Description("Type of Value this Block stores")]
public string ValueType => typeof(T).Name;
#pragma warning restore CA1822
public WrappedValueView(SCBlock block, object currentValue)
{

View File

@ -493,83 +493,28 @@ private void B_SaveBoxBin_Click(object sender, EventArgs e)
}
// Subfunction Save Buttons //
private void B_OpenWondercards_Click(object sender, EventArgs e)
private static void OpenDialog(Form f)
{
using var form = new SAV_Wondercard(SAV, sender as DataMysteryGift);
form.ShowDialog();
f.ShowDialog();
f.Dispose();
}
private void B_OpenPokepuffs_Click(object sender, EventArgs e)
{
using var form = new SAV_Pokepuff(SAV);
form.ShowDialog();
}
private void B_OpenPokeBeans_Click(object sender, EventArgs e)
{
using var form = new SAV_Pokebean(SAV);
form.ShowDialog();
}
private void B_OpenItemPouch_Click(object sender, EventArgs e)
{
using var form = new SAV_Inventory(SAV);
form.ShowDialog();
}
private void B_OpenBerryField_Click(object sender, EventArgs e)
{
using var form = new SAV_BerryFieldXY((SAV6XY) SAV);
form.ShowDialog();
}
private void B_OpenPokeblocks_Click(object sender, EventArgs e)
{
using var form = new SAV_PokeBlockORAS(SAV);
form.ShowDialog();
}
private void B_OpenSuperTraining_Click(object sender, EventArgs e)
{
using var form = new SAV_SuperTrain(SAV);
form.ShowDialog();
}
private void B_OpenSecretBase_Click(object sender, EventArgs e)
{
using var form = new SAV_SecretBase(SAV);
form.ShowDialog();
}
private void B_CellsStickers_Click(object sender, EventArgs e)
{
using var form = new SAV_ZygardeCell(SAV);
form.ShowDialog();
}
private void B_LinkInfo_Click(object sender, EventArgs e)
{
using var form = new SAV_Link6(SAV);
form.ShowDialog();
}
private void B_Roamer_Click(object sender, EventArgs e)
{
using var form = new SAV_Roamer3(SAV);
form.ShowDialog();
}
private void B_OpenApricorn_Click(object sender, EventArgs e)
{
using var form = new SAV_Apricorn((SAV4HGSS) SAV);
form.ShowDialog();
}
private void B_CGearSkin_Click(object sender, EventArgs e)
{
using var form = new SAV_CGearSkin(SAV);
form.ShowDialog();
}
private void B_OpenWondercards_Click(object sender, EventArgs e) => OpenDialog(new SAV_Wondercard(SAV, sender as DataMysteryGift));
private void B_OpenPokepuffs_Click(object sender, EventArgs e) => OpenDialog(new SAV_Pokepuff(SAV));
private void B_OpenPokeBeans_Click(object sender, EventArgs e) => OpenDialog(new SAV_Pokebean(SAV));
private void B_OpenItemPouch_Click(object sender, EventArgs e) => OpenDialog(new SAV_Inventory(SAV));
private void B_OpenBerryField_Click(object sender, EventArgs e) => OpenDialog(new SAV_BerryFieldXY((SAV6XY)SAV));
private void B_OpenPokeblocks_Click(object sender, EventArgs e) => OpenDialog(new SAV_PokeBlockORAS(SAV));
private void B_OpenSuperTraining_Click(object sender, EventArgs e) => OpenDialog(new SAV_SuperTrain(SAV));
private void B_OpenSecretBase_Click(object sender, EventArgs e) => OpenDialog(new SAV_SecretBase(SAV));
private void B_CellsStickers_Click(object sender, EventArgs e) => OpenDialog(new SAV_ZygardeCell(SAV));
private void B_LinkInfo_Click(object sender, EventArgs e) => OpenDialog(new SAV_Link6(SAV));
private void B_Roamer_Click(object sender, EventArgs e) => OpenDialog(new SAV_Roamer3(SAV));
private void B_OpenApricorn_Click(object sender, EventArgs e) => OpenDialog(new SAV_Apricorn((SAV4HGSS)SAV));
private void B_CGearSkin_Click(object sender, EventArgs e) => OpenDialog(new SAV_CGearSkin(SAV));
private void B_OpenTrainerInfo_Click(object sender, EventArgs e) => OpenDialog(GetTrainerEditor(SAV));
private void B_OpenOPowers_Click(object sender, EventArgs e) => OpenDialog(new SAV_OPower((ISaveBlock6Main)SAV));
private void B_OpenHoneyTreeEditor_Click(object sender, EventArgs e) => OpenDialog(new SAV_HoneyTree((SAV4Sinnoh)SAV));
private void B_OpenEventFlags_Click(object sender, EventArgs e)
{
@ -585,19 +530,12 @@ private void B_OpenEventFlags_Click(object sender, EventArgs e)
private void B_OpenBoxLayout_Click(object sender, EventArgs e)
{
using var form = new SAV_BoxLayout(SAV, Box.CurrentBox);
form.ShowDialog();
OpenDialog(new SAV_BoxLayout(SAV, Box.CurrentBox));
Box.ResetBoxNames(); // fix box names
Box.ResetSlots(); // refresh box background
UpdateBoxViewers(all: true); // update subviewers
}
private void B_OpenTrainerInfo_Click(object sender, EventArgs e)
{
using var form = GetTrainerEditor(SAV);
form.ShowDialog();
}
private static Form GetTrainerEditor(SaveFile sav)
{
return sav switch
@ -665,7 +603,7 @@ private static Form GetAccessorForm(SaveFile sav)
};
}
private static Form GetPropertyForm(SaveFile sav)
private static Form GetPropertyForm(object sav)
{
var form = new Form
{
@ -679,14 +617,6 @@ private static Form GetPropertyForm(SaveFile sav)
return form;
}
private void B_OpenOPowers_Click(object sender, EventArgs e)
{
if (!(SAV is ISaveBlock6Main op))
return;
using var form = new SAV_OPower(op);
form.ShowDialog();
}
private void B_OpenFriendSafari_Click(object sender, EventArgs e)
{
if (!(SAV is SAV6XY xy))
@ -742,21 +672,11 @@ private void B_OpenRTCEditor_Click(object sender, EventArgs e)
sav2.ResetRTC();
break;
case 3:
var form = new SAV_RTC3(SAV);
form.ShowDialog();
form.Dispose();
OpenDialog(new SAV_RTC3(SAV));
break;
}
}
private void B_OpenHoneyTreeEditor_Click(object sender, EventArgs e)
{
if (!(SAV is SAV4Sinnoh s))
return;
using var form = new SAV_HoneyTree(s);
form.ShowDialog();
}
private void B_OUTPasserby_Click(object sender, EventArgs e)
{
if (SAV.Generation != 6)
@ -1160,7 +1080,7 @@ private void ToggleViewSubEditors(SaveFile sav)
B_MailBox.Enabled = sav is SAV2 || sav is SAV3 || sav is SAV4 || sav is SAV5;
B_Raids.Enabled = sav is SAV8SWSH;
B_RaidArmor.Enabled = sav is SAV8SWSH swsh && swsh.MaxSpeciesID >= (int) Species.Zarude;
B_RaidArmor.Enabled = sav is SAV8SWSH swsh && swsh.SaveRevision >= 1;
B_Blocks.Enabled = true;
SL_Extra.SAV = sav;

View File

@ -193,7 +193,7 @@ private void SetUGScores()
SAV.UG_Flags = (uint)U_Flags.Value;
}
private string[] SanitizeList(string[] inputlist)
private static string[] SanitizeList(string[] inputlist)
{
string[] listSorted = inputlist.Where(x => !string.IsNullOrEmpty(x)).ToArray();
Array.Sort(listSorted);

View File

@ -72,7 +72,7 @@ private static void VerifyAll(string folder, string name, bool isValid)
{
var info = legality.Info;
var result = legality.Results.Concat(info.Moves).Concat(info.Relearn);
var invalid = result.Where(z => z != null && !z.Valid);
var invalid = result.Where(z => z?.Valid == false);
var msg = string.Join(Environment.NewLine, invalid.Select(z => z.Comment));
legality.Valid.Should().BeTrue($"because the file '{fn}' should be Valid, but found:{Environment.NewLine}{msg}");
}