Skip to content

Commit

Permalink
feeder: changed dynamic application combo box to static simulator chi…
Browse files Browse the repository at this point in the history
…p, also removed the redundant check from the top level filter and instead relying on the granula file filter instead
  • Loading branch information
stojy committed Aug 22, 2023
1 parent 81ac87b commit 8dcd7c9
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 47 deletions.
24 changes: 9 additions & 15 deletions ClrVpin/Feeder/FeederResults.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,22 +430,16 @@
<ContentControl ContentTemplate="{StaticResource FeatureTypeListMultiFilterChipTemplate}" Content="{Binding GameFiltersViewModel.TechnologyTypeOptionsView}" />
</ContentControl>

<!--<ComboBox ItemsSource="{Binding GameFiltersViewModel.TypesFilterView}"
SelectedItem="{Binding Path=Settings.SelectedTypeFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="Type"
Style="{StaticResource ComboBoxStyle}"
Width="60" Margin="0,0,0,0"
ToolTip="Filter the tables based on the table construction technology: PM (Purely Mechanical), EM (Electromechanical), SS (Solid State).">
<b:Interaction.Triggers>
<controls:RoutedEventTrigger RoutedEvent="ComboBox.SelectionChanged">
<b:InvokeCommandAction Command="{Binding FilterChangedCommand}" />
</controls:RoutedEventTrigger>
</b:Interaction.Triggers>
</ComboBox>-->

<ContentControl Template="{StaticResource KeyValueAutoPair}"
controls:GenericAttached.String="Simulator"
controls:GenericAttached.String2="Filter the tables based on the simulator application. Ignored for unmatched tables."
controls:GenericAttached.Double="110"
controls:GenericAttached.Double2="14">
<ContentControl ContentTemplate="{StaticResource FeatureTypeListMultiFilterChipTemplate}" Content="{Binding GameFiltersViewModel.SimulatorOptionsFilterView}" />
</ContentControl>


<ComboBox ItemsSource="{Binding GameFiltersViewModel.SimulatorFormatsFilterView}"
<!--<ComboBox ItemsSource="{Binding GameFiltersViewModel.SimulatorFormatsFilterView}"
SelectedItem="{Binding Path=Settings.SelectedSimulatorFormatFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="Simulator"
Style="{StaticResource ComboBoxStyle}"
Expand All @@ -456,7 +450,7 @@
<b:InvokeCommandAction Command="{Binding ApplicationFormatChangedCommand}" />
</controls:RoutedEventTrigger>
</b:Interaction.Triggers>
</ComboBox>
</ComboBox>-->


<ContentControl Template="{StaticResource KeyValueAutoPair}"
Expand Down
19 changes: 10 additions & 9 deletions ClrVpin/Feeder/FeederResultsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public FeederResultsViewModel(IList<GameItem> gameItems, IList<LocalGame> localG
|| tableFile.Urls.Select(u => u.Url).ContainsAny("https://fss-pinball.com");
tableFile.IsMusicOrSoundMod = comment.ContainsAny("sound mod", "music mod");
tableFile.IsBlackWhiteMod = comment.ContainsAny("bw mod", "black & white mod", "black and white mod");
tableFile.Simulator = SimulatorOptionHelper.GetEnum(tableFile.TableFormat);
});
onlineGame.B2SFiles.ForEach(backglassFile =>
{
Expand Down Expand Up @@ -142,10 +143,6 @@ public FeederResultsViewModel(IList<GameItem> gameItems, IList<LocalGame> localG
(!Settings.SelectedTechnologyTypeOptions.Any() ||
Settings.SelectedTechnologyTypeOptions.Contains(gameItem.TechnologyType ?? TechnologyTypeOptionEnum.Unknown)) &&
// simulator type
// - todo; not required at this level?
(Settings.SelectedSimulatorFormatFilter == null || gameItem.OnlineGame?.TableFormats.Contains(Settings.SelectedSimulatorFormatFilter) == true) &&
// manufacture name
(Settings.SelectedManufacturerFilter == null || gameItem.Manufacturer.Contains(Settings.SelectedManufacturerFilter, StringComparison.OrdinalIgnoreCase)) &&
Expand Down Expand Up @@ -175,12 +172,17 @@ public FeederResultsViewModel(IList<GameItem> gameItems, IList<LocalGame> localG
() => Model.Settings.Feeder.SelectedOnlineFileTypeOptions, _ => UpdateOnlineGameFileDetails(), includeSelectAll: false, minimumNumberOfSelections: 1),

MiscFeaturesOptionsView = FeatureOptions.CreateFeatureOptionsMultiSelectionView(StaticSettings.MiscFeatureOptions,
() => Model.Settings.Feeder.SelectedMiscFeatureOptions, _ => UpdateOnlineGameFileDetails(), includeSelectAll: false)
() => Model.Settings.Feeder.SelectedMiscFeatureOptions, _ => UpdateOnlineGameFileDetails(), includeSelectAll: false),


// simulator formats - vpx, fp, etc
// - only applicable online
SimulatorOptionsFilterView = FeatureOptions.CreateFeatureOptionsMultiSelectionView(StaticSettings.SimulatorOptions,
() => Model.Settings.Feeder.SelectedSimulatorOptionFilter, _ => UpdateOnlineGameFileDetails(), includeSelectAll: false, minimumNumberOfSelections: 1),
};

// invoke online game file update to handle IsNew which is time sensitive
UpdatedFilterTimeChanged = new ActionCommand(UpdateOnlineGameFileDetails);
ApplicationFormatChangedCommand = new ActionCommand(UpdateOnlineGameFileDetails);

NavigateToUrlCommand = new ActionCommand<string>(url => Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }));

Expand Down Expand Up @@ -237,7 +239,6 @@ public FeederResultsViewModel(IList<GameItem> gameItems, IList<LocalGame> localG
public ICommand DynamicFilteringCommand { get; }
public ICommand FilterChangedCommand { get; set; }
public ICommand UpdatedFilterTimeChanged { get; set; }
public ICommand ApplicationFormatChangedCommand { get; }

public ICommand NavigateToUrlCommand { get; }
public ICommand AllTableAddMissingDatabaseInfoCommand { get; }
Expand Down Expand Up @@ -297,7 +298,7 @@ private async Task ShowSummary()
// simplified summary of the FeederStatisticsViewModel info
var restrictedGameItems = GameItems.Where(gameItem =>
!gameItem.IsOriginal &&
gameItem.OnlineGame?.TableFormats.Contains(ApplicationFormatEnum.VirtualPinballX) == true &&
gameItem.OnlineGame?.TableFormats.Contains(SimulatorAbbreviationEnum.VirtualPinballX) == true &&
gameItem.OnlineGame?.TableDownload == TableDownloadOptionEnum.Available).ToList();
var matchedManufacturedCount = restrictedGameItems.Count(gameItem => gameItem.TableMatchType is TableMatchOptionEnum.LocalAndOnline);
var missingManufacturedCount = restrictedGameItems.Count(gameItem => gameItem.TableMatchType is TableMatchOptionEnum.OnlineOnly);
Expand Down Expand Up @@ -418,7 +419,7 @@ private void UpdateOnlineGameFileDetails()
// - simulator application, aka file format, e.g. VPX, FP, etc
UpdateIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
Settings.SelectedSimulatorFormatFilter != null && (file as TableFile)?.TableFormat != Settings.SelectedSimulatorFormatFilter);
!Settings.SelectedSimulatorOptionFilter.Contains((file as TableFile)?.Simulator ?? SimulatorOptionEnum.Unknown));
// flag each url within the file - required to allow for simpler view binding
file.Urls.ForEach(url => url.IsNew = file.IsNew);
Expand Down
2 changes: 1 addition & 1 deletion ClrVpin/Feeder/FeederUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private static List<GameItem> MergeLocalAndOnlineGames(IEnumerable<LocalGame> lo

// logging - missing games
var missingGames = onlineGames
.Where(onlineGame => !onlineGame.IsOriginal && onlineGame.TableFormats.Contains(ApplicationFormatEnum.VirtualPinballX) && onlineGame.TableDownload == TableDownloadOptionEnum.Available && onlineGame.Hit == null)
.Where(onlineGame => !onlineGame.IsOriginal && onlineGame.TableFormats.Contains(SimulatorAbbreviationEnum.VirtualPinballX) && onlineGame.TableDownload == TableDownloadOptionEnum.Available && onlineGame.Hit == null)
.OrderBy(onlineGame => onlineGame.Name)
.ToList();
Logger.Info($"Fuzzy matching: missing table count={missingGames.Count} (only exists in the online feed.. restricted to tables that are manufactured, VPX, and available for download)");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
namespace ClrVpin.Models.Feeder;

public static class ApplicationFormatEnum
public static class SimulatorAbbreviationEnum
{
public const string VirtualPinballX = "VPX";
// ReSharper disable once UnusedMember.Global
public const string FuturePinball = "FP";
// ReSharper disable once UnusedMember.Global
public const string PinballFx = "FX";
// ReSharper disable once UnusedMember.Global
public const string PinballFx2 = "FX2";
// ReSharper disable once UnusedMember.Global
public const string PinballFx3 = "FX3";
}
11 changes: 11 additions & 0 deletions ClrVpin/Models/Feeder/SimulatorOptionEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.ComponentModel;

namespace ClrVpin.Models.Feeder;

public enum SimulatorOptionEnum
{
[Description("Virtual Pinball")] VirtualPinballX,
[Description("Future Pinball")] FuturePinball,
[Description("FX Pinball")] PinballFx,
[Description("Unknown")] Unknown
}
19 changes: 19 additions & 0 deletions ClrVpin/Models/Feeder/SimulatorOptionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace ClrVpin.Models.Feeder;

public static class SimulatorOptionHelper
{
public static SimulatorOptionEnum? GetEnum(string stringType)
{
SimulatorOptionEnum? simulatorOptionEnum = stringType switch
{
SimulatorAbbreviationEnum.VirtualPinballX => SimulatorOptionEnum.VirtualPinballX,
SimulatorAbbreviationEnum.FuturePinball => SimulatorOptionEnum.FuturePinball,
SimulatorAbbreviationEnum.PinballFx => SimulatorOptionEnum.PinballFx,
SimulatorAbbreviationEnum.PinballFx2 => SimulatorOptionEnum.PinballFx,
SimulatorAbbreviationEnum.PinballFx3 => SimulatorOptionEnum.PinballFx,
_ => null
};

return simulatorOptionEnum;
}
}
1 change: 1 addition & 0 deletions ClrVpin/Models/Feeder/Vps/OnlineGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ public class TableFile : ImageFile
public bool IsFullSingleScreen { get; set; }
public bool IsMusicOrSoundMod { get; set; }
public bool IsBlackWhiteMod { get; set; }
public SimulatorOptionEnum? Simulator { get; set; } // converted from TableFormat
}
4 changes: 2 additions & 2 deletions ClrVpin/Models/Settings/FeederSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public FeederSettings()
OnlineFileTypeEnum.DMDs.GetDescription(),
});

SelectedSimulatorFormatFilter = ApplicationFormatEnum.VirtualPinballX;
SelectedSimulatorOptionFilter = new ObservableCollection<SimulatorOptionEnum> { SimulatorOptionEnum.VirtualPinballX, SimulatorOptionEnum.Unknown };
}

public ObservableCollection<HitTypeEnum> SelectedMatchCriteriaOptions { get; set; } = new();
Expand All @@ -37,5 +37,5 @@ public FeederSettings()
public ObservableCollection<string> SelectedOnlineFileTypeOptions { get; set; } = new();
public ObservableCollection<MiscFeatureOptionEnum> SelectedMiscFeatureOptions { get; set; } = new ();

public string SelectedSimulatorFormatFilter { get; set; }
public ObservableCollection<SimulatorOptionEnum> SelectedSimulatorOptionFilter { get; set; }
}
10 changes: 10 additions & 0 deletions ClrVpin/Models/Settings/StaticSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static StaticSettings()
FixFeedOptions.ForEach(x => x.Description = x.Enum.GetDescription());
PresetDateOptions.ForEach(x => x.Description = x.Enum.GetDescription());
MiscFeatureOptions.ForEach(x => x.Description = x.Enum.GetDescription());
SimulatorOptions.ForEach(x => x.Description = x.Enum.GetDescription());

// explorer
MissingFileOptions.ForEach(x => x.Description = x.Enum.GetDescription());
Expand Down Expand Up @@ -120,6 +121,15 @@ static StaticSettings()
new() {Enum = TechnologyTypeOptionEnum.Unknown, Tip = "Unknown table technology type"},
};

// all possible simulator applications - to be used elsewhere (feeder)
public static readonly EnumOption<SimulatorOptionEnum>[] SimulatorOptions =
{
new() {Enum = SimulatorOptionEnum.VirtualPinballX, Tip = "Virtual Pinball X (including VP9)"},
new() {Enum = SimulatorOptionEnum.FuturePinball, Tip = "Future Pinball"},
new() {Enum = SimulatorOptionEnum.PinballFx, Tip = "FX Pinball (includes FX1, FX2, and FX3)"},
new() {Enum = SimulatorOptionEnum.Unknown, Tip = "Unknown simulator"},
};

// all possible missing file options - to be used elsewhere (explorer)
public static readonly EnumOption<ContentTypeEnum>[] MissingFileOptions =
ImportantContentTypes.Select(contentType => new EnumOption<ContentTypeEnum> { Enum = contentType }).ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ClrVpin.Models.Shared.Enums;

public static class TechnologyTypeHelper
public static class TechnologyTypeOptionHelper
{
public static TechnologyTypeOptionEnum? GetEnum(string stringType)
{
Expand Down
2 changes: 1 addition & 1 deletion ClrVpin/Models/Shared/Game/GameItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void Update(LocalGame localGame)

TableMatchType = GetTableMatchEnum();

TechnologyType = TechnologyTypeHelper.GetEnum(Type);
TechnologyType = TechnologyTypeOptionHelper.GetEnum(Type);
}


Expand Down
6 changes: 3 additions & 3 deletions ClrVpin/Shared/GameCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface IGameCollections
IList<string> Themes { get; }
IList<string> Authors { get; }
// ReSharper disable once UnusedMemberInSuper.Global
IList<string> Formats { get; }
IList<string> SimulatorFormats { get; }

public void Update();
}
Expand All @@ -47,7 +47,7 @@ public GameCollections(IList<GameItem> gameItems, Action updatedAction)
public IList<string> Pups { get; private set; }
public IList<string> Themes { get; private set; }
public IList<string> Authors { get; private set; }
public IList<string> Formats { get; private set; }
public IList<string> SimulatorFormats { get; private set; }

public void Update()
{
Expand All @@ -62,7 +62,7 @@ public void Update()
Types = _gameItems.Select(x => x.Types).SelectManyUnique();

// table formats - vpx, fp, etc.. only available via online
Formats = _gameItems.SelectMany(x => x.OnlineGame?.TableFormats ?? new List<string>()).Distinct().Where(x => x != null).OrderBy(x => x).ToList();
SimulatorFormats = _gameItems.SelectMany(x => x.OnlineGame?.TableFormats ?? new List<string>()).Distinct().Where(x => x != null).OrderBy(x => x).ToList();

Themes = _gameItems.Select(x => x.Themes).SelectManyUnique();
Players = _gameItems.Select(x => x.Players).SelectManyUnique();
Expand Down
11 changes: 1 addition & 10 deletions ClrVpin/Shared/GameFiltersViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public GameFiltersViewModel(ListCollectionView<GameItem> gameItemsView, IGameCol
public ListCollectionView<string> YearsBeginFilterView { get; private set; }
public ListCollectionView<string> YearsEndFilterView { get; private set; }
public ListCollectionView<FeatureType.FeatureType> TechnologyTypeOptionsView { get; private set; }
public ListCollectionView<string> SimulatorFormatsFilterView { get; private set; }
public ListCollectionView<FeatureType.FeatureType> PresetDateOptionsView { get; }
public ListCollectionView<FeatureType.FeatureType> TableManufacturedOptionsView { get; }

Expand All @@ -47,6 +46,7 @@ public GameFiltersViewModel(ListCollectionView<GameItem> gameItemsView, IGameCol
public ListCollectionView<FeatureType.FeatureType> UrlStatusOptionsView { get; init; }
public ListCollectionView<FeatureType.FeatureType> OnlineFileTypeOptionsView { get; init; }
public ListCollectionView<FeatureType.FeatureType> MiscFeaturesOptionsView { get; init; }
public ListCollectionView<FeatureType.FeatureType> SimulatorOptionsFilterView { get; init; }

// explorer specific views
public ListCollectionView<FeatureType.FeatureType> MissingFilesOptionsView { get; set; }
Expand All @@ -60,8 +60,6 @@ public void Refresh(int? debounceMilliseconds = null)
ManufacturersFilterView.RefreshDebounce(debounceMilliseconds);
YearsBeginFilterView.RefreshDebounce(debounceMilliseconds);
YearsEndFilterView.RefreshDebounce(debounceMilliseconds);
//TechnologyTypeOptionsView.RefreshDebounce(debounceMilliseconds);
SimulatorFormatsFilterView?.RefreshDebounce(debounceMilliseconds); // not used by all VMs, e.g. Explorer
}

// todo; improve: private method and only invoke once during initialization (i.e. don't recreate LCVs) using an ObservableCollection (from GameCollection) instead of List
Expand Down Expand Up @@ -91,13 +89,6 @@ public void UpdateFilterViews()
// filter the 'years to' list to reflect what's displayed in the games list, i.e. taking into account ALL of the existing filter criteria
Filter = yearString => Filter(() => _gameItemsView.Any(x => x.Year == yearString))
};

// table formats - vpx, fp, etc
// - only available via online
SimulatorFormatsFilterView = new ListCollectionView<string>(_gameCollections.Formats)
{
Filter = format => Filter(() => _gameItemsView.Any(x => x.OnlineGame?.TableFormats.Contains(format) == true))
};
}

private bool Filter(Func<bool> dynamicFilteringFunc)
Expand Down

0 comments on commit 8dcd7c9

Please sign in to comment.