mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-23 17:06:09 -05:00
Make ComboItem a record
This commit is contained in:
parent
e44100a9fd
commit
74ee22e66e
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user