Make ComboItem a record

This commit is contained in:
Kurt 2020-12-28 11:57:34 -08:00
parent e44100a9fd
commit 74ee22e66e
2 changed files with 3 additions and 22 deletions

View File

@ -1,26 +1,7 @@
using System;
namespace PKHeX.Core
namespace PKHeX.Core
{
/// <summary>
/// Key Value pair for a displayed <see cref="T:System.String" /> and underlying <see cref="T:System.Int32" /> value.
/// </summary>
public readonly struct ComboItem : IEquatable<int>
{
public string Text { get; }
public int Value { get; }
public ComboItem(string text, int value)
{
Text = text;
Value = value;
}
public bool Equals(ComboItem other) => Value == other.Value && string.Equals(Text, other.Text);
public bool Equals(int other) => Value == other;
public override bool Equals(object obj) => obj is ComboItem other && Equals(other);
public override int GetHashCode() => Value;
public static bool operator ==(ComboItem left, ComboItem right) => left.Equals(right);
public static bool operator !=(ComboItem left, ComboItem right) => !(left == right);
}
public record ComboItem(string Text, int Value);
}

View File

@ -731,7 +731,7 @@ private void GetHallStat()
bool c = curspe == species;
CHK_HallCurrent.Checked = c;
CHK_HallCurrent.Text = curspe > 0 && curspe <= SAV.MaxSpeciesID
? "Current: " + CB_Species.Items.OfType<ComboItem>().FirstOrDefault(x => x.Value == curspe).Text
? $"Current: {SpeciesName.GetSpeciesName(curspe, GameLanguage.GetLanguageIndex(Main.CurrentLanguage))}"
: "Current: (none)";
int s = 0;