mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ComboBox source now uses enum descreption
This commit is contained in:
parent
17ca59d9d5
commit
56fcb7f6d6
@ -134,6 +134,11 @@ namespace Wabbajack.Common
|
||||
|
||||
return attrs.Length > 0 ? ((DescriptionAttribute)attrs[0]).Description : enumerationValue.ToString();
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetAllItems<T>() where T : struct
|
||||
{
|
||||
return Enum.GetValues(typeof(T)).Cast<T>();
|
||||
}
|
||||
}
|
||||
|
||||
public class GameRegistry
|
||||
|
@ -26,6 +26,8 @@ namespace Wabbajack
|
||||
|
||||
private int missingHashFallbackCounter;
|
||||
|
||||
private const string ALL_GAME_TYPE = "All";
|
||||
|
||||
[Reactive]
|
||||
public IErrorResponse Error { get; set; }
|
||||
|
||||
@ -52,7 +54,7 @@ namespace Wabbajack
|
||||
: base(mainWindowVM)
|
||||
{
|
||||
MWVM = mainWindowVM;
|
||||
GameType = "All";
|
||||
GameType = ALL_GAME_TYPE;
|
||||
|
||||
ClearFiltersCommand = ReactiveCommand.Create(
|
||||
() =>
|
||||
@ -60,7 +62,7 @@ namespace Wabbajack
|
||||
OnlyInstalled = false;
|
||||
ShowNSFW = false;
|
||||
Search = string.Empty;
|
||||
GameType = "All";
|
||||
GameType = ALL_GAME_TYPE;
|
||||
});
|
||||
|
||||
var random = new Random();
|
||||
@ -128,13 +130,9 @@ namespace Wabbajack
|
||||
.Debounce(TimeSpan.FromMilliseconds(150), RxApp.MainThreadScheduler)
|
||||
.Select<string, Func<ModListMetadataVM, bool>>(GameType => (vm) =>
|
||||
{
|
||||
if (Enum.TryParse(GameType, out Game gameFilter))
|
||||
{
|
||||
return gameFilter == vm.Metadata.Game;
|
||||
}
|
||||
else if (GameType == "All")
|
||||
if (GameType == ALL_GAME_TYPE)
|
||||
return true;
|
||||
return false;
|
||||
return GameType == EnumExtensions.GetDescription<Game>(vm.Metadata.Game).ToString();
|
||||
}))
|
||||
.Filter(this.WhenAny(x => x.ShowNSFW)
|
||||
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
|
||||
@ -167,8 +165,11 @@ namespace Wabbajack
|
||||
|
||||
private List<string> GetGameTypeEntries()
|
||||
{
|
||||
List<string> gameEntries = new List<string> { "All" };
|
||||
gameEntries.AddRange(Enum.GetNames(typeof(Game)));
|
||||
List<string> gameEntries = new List<string> { ALL_GAME_TYPE };
|
||||
foreach (var gameType in EnumExtensions.GetAllItems<Game>() )
|
||||
{
|
||||
gameEntries.Add(EnumExtensions.GetDescription<Game>(gameType));
|
||||
}
|
||||
return gameEntries;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user