Skip to content

Commit

Permalink
feeder: rebrandd 'misc features' to features and added a 'standard' o…
Browse files Browse the repository at this point in the history
…ption so it be selectively removed to display only non-standard features (e.g. full single screen tables)
  • Loading branch information
stojy committed Sep 8, 2023
1 parent 3ea3c59 commit a80a6b9
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 45 deletions.
4 changes: 2 additions & 2 deletions ClrVpin/Feeder/FeederResults.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@
</ContentControl>

<ContentControl Template="{StaticResource KeyValueAutoPair}"
controls:GenericAttached.String="Miscellaneous"
controls:GenericAttached.String2="Don't attribute file(s) as 'New' if they contain these features"
controls:GenericAttached.String="Features"
controls:GenericAttached.String2="Filter the tables that contain specific feature(s). Use 'standard' for those tables that don't contain any unusual features."
controls:GenericAttached.Double="110"
controls:GenericAttached.Double2="14">
<ContentControl ContentTemplate="{StaticResource FeatureTypeListMultiFilterChipTemplate}" Content="{Binding GameFiltersViewModel.MiscFeaturesOptionsView }" />
Expand Down
97 changes: 65 additions & 32 deletions ClrVpin/Feeder/FeederResultsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,38 @@ public FeederResultsViewModel(IList<GameItem> gameItems, IList<LocalGame> localG
onlineGame.TableFiles.ForEach(tableFile =>
{
var comment = tableFile.Comment?.ToLower().Trim() ?? string.Empty;
tableFile.IsVirtualOnly = comment.ContainsAny("vr room", "vr standalone") && !comment.ContainsAny("vr room optional");
tableFile.IsFullSingleScreen = (comment.ContainsAny("fss (full single screen)") && !comment.ContainsAny("fss (full single screen) option included"))
|| 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");
if (comment.ContainsAny("vr room", "vr standalone") && !comment.ContainsAny("optional vr room option", "vr room option"))
tableFile.FeatureOptions.Add(MiscFeatureOptionEnum.VirtualRealityOnly);
if ((comment.ContainsAny("fss (full single screen)") && !comment.ContainsAny("fss (full single screen) option included"))
|| tableFile.Urls.Select(u => u.Url).ContainsAny("https://fss-pinball.com"))
tableFile.FeatureOptions.Add(MiscFeatureOptionEnum.FullSingleScreenOnly);
if (comment.ContainsAny("sound mod", "music mod"))
tableFile.FeatureOptions.Add(MiscFeatureOptionEnum.MusicOrSoundMod);
if (comment.ContainsAny("bw mod", "black & white mod", "black and white mod"))
tableFile.FeatureOptions.Add(MiscFeatureOptionEnum.BlackAndWhiteMod);
// any table that doesn't contain at least one feature is considered as 'standard'
if (tableFile.FeatureOptions.Count == 0)
tableFile.FeatureOptions.Add(MiscFeatureOptionEnum.Standard);
tableFile.Simulator = SimulatorOptionHelper.GetEnum(tableFile.TableFormat);
});
onlineGame.B2SFiles.ForEach(backglassFile =>
{
backglassFile.IsFullDmd = backglassFile.Features?.Any(feature => feature?.ToLower().Trim() == "fulldmd") == true ||
backglassFile.Urls?.Any(url => url.Url.ToLower().RemoveChars('-').Contains("fulldmd")) == true;
if (backglassFile.Features?.Any(feature => feature?.ToLower().Trim() == "fulldmd") == true ||
backglassFile.Urls?.Any(url => url.Url.ToLower().RemoveChars('-').Contains("fulldmd")) == true)
{
backglassFile.FeatureOptions.Add(MiscFeatureOptionEnum.FullDmd);
}
// any file that doesn't contain at least one feature is considered 'standard'
if (backglassFile.FeatureOptions.Count == 0)
backglassFile.FeatureOptions.Add(MiscFeatureOptionEnum.Standard);
});
// extract IpdbId
Expand All @@ -93,7 +114,7 @@ public FeederResultsViewModel(IList<GameItem> gameItems, IList<LocalGame> localG
// create the VPS URL
// assign VPS Url (not a fix)
onlineGame.VpsUrl = $@"https://virtual-pinball-spreadsheet.web.app/game/{onlineGame.Id}";
onlineGame.VpsUrl = $"https://virtual-pinball-spreadsheet.web.app/game/{onlineGame.Id}";
// update URL information
onlineGame.AllFileCollections.Select(x => x.Value).SelectMany(x => x).ForEach(file =>
Expand Down Expand Up @@ -168,7 +189,7 @@ public FeederResultsViewModel(IList<GameItem> gameItems, IList<LocalGame> localG
() => Model.Settings.Feeder.SelectedOnlineFileTypeOptions, _ => SelectedOnlineFileTypeUpdated(), includeSelectAll: false, minimumNumberOfSelections: 1),

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

// simulator formats - vpx, fp, etc
// - only applicable online
Expand Down Expand Up @@ -367,22 +388,25 @@ private async Task AllTableUpdateDatabase(bool overwriteProperties)
private void SelectedOnlineFileTypeUpdated()
{
// table file
UpdateMiscFeatureState(OnlineFileTypeEnum.Tables,
UpdateMiscFeatureState(new [] {OnlineFileTypeEnum.Tables},
MiscFeatureOptionEnum.VirtualRealityOnly, MiscFeatureOptionEnum.FullSingleScreenOnly, MiscFeatureOptionEnum.MusicOrSoundMod, MiscFeatureOptionEnum.BlackAndWhiteMod);

var isTableEnabled = Settings.SelectedOnlineFileTypeOptions.Contains(OnlineFileTypeEnum.Tables.GetDescription());
FeatureOptions.UpdateFeatureOptions(isTableEnabled, GameFiltersViewModel.SimulatorOptionsFilterView.ToList(), (int) SimulatorOptionEnum.VirtualPinballX);

// backglass file
UpdateMiscFeatureState(OnlineFileTypeEnum.Backglasses, MiscFeatureOptionEnum.FullDmd);
UpdateMiscFeatureState(new [] {OnlineFileTypeEnum.Backglasses}, MiscFeatureOptionEnum.FullDmd);

// table or backglass file
UpdateMiscFeatureState(new [] {OnlineFileTypeEnum.Tables, OnlineFileTypeEnum.Backglasses}, MiscFeatureOptionEnum.Standard);

UpdateOnlineGameFileDetails();
}

private void UpdateMiscFeatureState(OnlineFileTypeEnum onlineFileType, params MiscFeatureOptionEnum[] miscFeatureOptionEnums)
private void UpdateMiscFeatureState(IEnumerable<OnlineFileTypeEnum> onlineFileTypes, params MiscFeatureOptionEnum[] miscFeatureOptionToUpdate)
{
var isFileTypeEnabled = Settings.SelectedOnlineFileTypeOptions.Contains(onlineFileType.GetDescription());
var miscFeatureOptions = miscFeatureOptionEnums.Select(x => (int)x);
var isFileTypeEnabled = Settings.SelectedOnlineFileTypeOptions.ContainsAny(onlineFileTypes.Select(x => x.GetDescription()));
var miscFeatureOptions = miscFeatureOptionToUpdate.Select(x => (int)x);
var miscFeatureOptionItems = GameFiltersViewModel.MiscFeaturesOptionsView.Where(option => miscFeatureOptions.Contains(option.Id));

// update each of the relevant feature options
Expand Down Expand Up @@ -413,39 +437,48 @@ private void UpdateOnlineGameFileDetails()
// - this is different to the generated 'gameItem updatedAt' which is an aggregation of the all the content and their file timestamps.. refer GameItemsView filtering
file.IsNew = IsNewUpdatedTimestamp(file);
// todo; change to 'add' rather than 'remove'
// treat file as NOT new if any of the following rules are satisfied
// - all URLS are either invalid or missing
//UpdateIsNew(file, fileCollectionTypeEnum, null, () => file.UrlStatusEnum != UrlStatusEnum.Valid);
// - VR only
UpdateIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file is TableFile { IsVirtualOnly: true } && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.VirtualRealityOnly));
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file.FeatureOptions.Contains(MiscFeatureOptionEnum.VirtualRealityOnly) && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.VirtualRealityOnly));
// - FSS only
UpdateIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file is TableFile { IsFullSingleScreen: true } && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.FullSingleScreenOnly));
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file.FeatureOptions.Contains(MiscFeatureOptionEnum.FullSingleScreenOnly) && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.FullSingleScreenOnly));
// - music/sound mod
UpdateIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file is TableFile { IsMusicOrSoundMod: true } && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.MusicOrSoundMod));
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file.FeatureOptions.Contains(MiscFeatureOptionEnum.MusicOrSoundMod) && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.MusicOrSoundMod));
// - black and white mod
UpdateIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file is TableFile { IsBlackWhiteMod: true } && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.BlackAndWhiteMod));
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file.FeatureOptions.Contains(MiscFeatureOptionEnum.BlackAndWhiteMod) && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.BlackAndWhiteMod));
// - standard table
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
file.FeatureOptions.Contains(MiscFeatureOptionEnum.Standard) && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.Standard));
// - full DMD
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Backglasses, () =>
file.FeatureOptions.Contains(MiscFeatureOptionEnum.FullDmd) && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.FullDmd));
// - standard DMD
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Backglasses, () =>
file.FeatureOptions.Contains(MiscFeatureOptionEnum.Standard) && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.Standard));
// - full DMD, true if the DMD is included as part of the backglass
UpdateIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Backglasses, () =>
file is ImageFile { IsFullDmd: true } && !Settings.SelectedMiscFeatureOptions.Contains(MiscFeatureOptionEnum.FullDmd));
// - simulator application, aka file format, e.g. VPX, FP, etc
UpdateIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
ClearIsNew(file, fileCollectionTypeEnum, OnlineFileTypeEnum.Tables, () =>
Settings.SelectedSimulatorOptionFilter.Any() && // shouldn't be possible to have fileType=Tables enabled without a simulator option, but added anyway for peace of mind
!Settings.SelectedSimulatorOptionFilter.Contains((file as TableFile)?.Simulator ?? SimulatorOptionEnum.Unknown));
// download URL status
UpdateIsNew(file, fileCollectionTypeEnum, null, () =>
ClearIsNew(file, fileCollectionTypeEnum, null, () =>
!Settings.SelectedUrlStatusOptions.Contains(file.UrlStatusEnum));
// flag each url within the file - required to allow for simpler view binding
file.Urls.ForEach(url => url.IsNew = file.IsNew);
});
Expand All @@ -468,13 +501,13 @@ private void UpdateOnlineGameFileDetails()
FilterChangedCommand.Execute(null);
}

private static void UpdateIsNew(File file, OnlineFileTypeEnum actualFileCollectionTypeEnum, OnlineFileTypeEnum? requiredOnlineFileTypeEnum, Func<bool> shouldFlagAsNotNew)
private static void ClearIsNew(File file, OnlineFileTypeEnum actualFileCollectionTypeEnum, OnlineFileTypeEnum? requiredOnlineFileTypeEnum, Func<bool> shouldClearIsNew)
{
// update the file's isNew status to false if..
// - file has not already been designated isNew=false
// - the file type is a match, e.g. don't validate isNew for a backglass when checking the simulator type
// - the caller decides that the file should be ignored
if (file.IsNew && (requiredOnlineFileTypeEnum == null || actualFileCollectionTypeEnum == requiredOnlineFileTypeEnum) && shouldFlagAsNotNew())
if (file.IsNew && (requiredOnlineFileTypeEnum == null || actualFileCollectionTypeEnum == requiredOnlineFileTypeEnum) && shouldClearIsNew())
file.IsNew = false;
}

Expand Down
5 changes: 3 additions & 2 deletions ClrVpin/Models/Feeder/MiscFeatureOptionEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ namespace ClrVpin.Models.Feeder;

public enum MiscFeatureOptionEnum
{
[Description("Standard")] Standard,
[Description("Full DMD")] FullDmd,
[Description("VR Only")] VirtualRealityOnly,
[Description("FSS Only")] FullSingleScreenOnly,
[Description("Music/Sound Mod")] MusicOrSoundMod,
[Description("Black & White Mod")] BlackAndWhiteMod,
[Description("Full DMD")] FullDmd
[Description("Black & White Mod")] BlackAndWhiteMod
}
7 changes: 2 additions & 5 deletions ClrVpin/Models/Feeder/Vps/OnlineGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public class File
public UrlDetail[] Urls { get; set; } = Array.Empty<UrlDetail>();

// view model properties
public HashSet<MiscFeatureOptionEnum> FeatureOptions { get; } = new();
public bool IsNew { get; set; }
public UrlStatusEnum UrlStatusEnum { get; set; }
}
Expand All @@ -119,11 +120,11 @@ public class ImageFile : File

// view model properties
public UrlSelection ImageUrlSelection { get; set; }
public bool IsFullDmd { get; set; }
}

// ReSharper disable ClassNeverInstantiated.Global - required for collections as r# doesn't realize this is a json deserialized object
[AddINotifyPropertyChangedInterface]
[Serializable]
public class TableFile : ImageFile
{
[JsonPropertyName("theme")]
Expand All @@ -133,9 +134,5 @@ public class TableFile : ImageFile
public string Comment { get; set; }

// view model properties
public bool IsVirtualOnly { get; set; }
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 @@ -26,6 +26,7 @@ public FeederSettings()
});

SelectedSimulatorOptionFilter = new ObservableCollection<SimulatorOptionEnum> { SimulatorOptionEnum.VirtualPinballX, SimulatorOptionEnum.Unknown };
SelectedMiscFeatureOptions = new ObservableCollection<MiscFeatureOptionEnum> { MiscFeatureOptionEnum.Standard, MiscFeatureOptionEnum.FullDmd };
}

public ObservableCollection<HitTypeEnum> SelectedMatchCriteriaOptions { get; set; } = new();
Expand All @@ -35,7 +36,6 @@ public FeederSettings()
public ObservableCollection<UrlStatusEnum> SelectedUrlStatusOptions { get; set; } = new();

public ObservableCollection<string> SelectedOnlineFileTypeOptions { get; set; } = new();
public ObservableCollection<MiscFeatureOptionEnum> SelectedMiscFeatureOptions { get; set; } = new ();

public ObservableCollection<SimulatorOptionEnum> SelectedSimulatorOptionFilter { get; set; }
public ObservableCollection<MiscFeatureOptionEnum> SelectedMiscFeatureOptions { get; set; }
}
5 changes: 3 additions & 2 deletions ClrVpin/Models/Settings/StaticSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,12 @@ static StaticSettings()

public static readonly EnumOption<MiscFeatureOptionEnum>[] MiscFeatureOptions =
{
new() {Enum = MiscFeatureOptionEnum.Standard, Tip = "Table or backglass files with a 'standard' feature set"},
new() {Enum = MiscFeatureOptionEnum.FullDmd, Tip = "Backglass files that are designed for full DMD"},
new() {Enum = MiscFeatureOptionEnum.VirtualRealityOnly, Tip = "Table files that only support virtual reality"},
new() {Enum = MiscFeatureOptionEnum.FullSingleScreenOnly, Tip = "Table files that are full single screen, e.g. backglass, dmd, and table rendered on a single monitor"},
new() {Enum = MiscFeatureOptionEnum.FullSingleScreenOnly, Tip = "Table files that only support full single screen, e.g. backglass, dmd, and table rendered on a single monitor"},
new() {Enum = MiscFeatureOptionEnum.MusicOrSoundMod, Tip = "Table files that are music and/or sound modifications"},
new() {Enum = MiscFeatureOptionEnum.BlackAndWhiteMod, Tip = "Table files that are black & white modifications"},
new() {Enum = MiscFeatureOptionEnum.FullDmd, Tip = "Backglass files that are designed for full DMD"},
};

// all possible file merge options - to be used elsewhere (feeder)
Expand Down

0 comments on commit a80a6b9

Please sign in to comment.