Change syntax to match FilterBlast

Per @Greengroove's feedback, changing syntax to:

[Show|Hide] # grp1 - grp2 - grp3 | mode

mode can be any of these for the new Disable behavior:
"Disable"
"Comment"
"Remove" (slightly different from FilterBlast impl)

Any other mode is treated as the default behavior.

Filtration always writes out as "Disable" or default (none)

Also removed vestigal logging and comments.
This commit is contained in:
Derrick 2017-01-21 17:53:13 -05:00
parent 8e5cd0045f
commit 07fc5588a7
3 changed files with 19 additions and 13 deletions
Filtration.ObjectModel
Filtration.Parser/Services
Filtration/ViewModels

@ -149,11 +149,6 @@ namespace Filtration.ObjectModel
if (BlockGroup.IsChecked != Enabled) if (BlockGroup.IsChecked != Enabled)
{ {
Enabled = BlockGroup.IsChecked; Enabled = BlockGroup.IsChecked;
// DFRICE
Console.WriteLine("TOGGLE! ENABLED=" + (Enabled ? "YES" : "NO"));
// This is a bit hacky. Enabled/Disabled isn't part of BlockItems,
// but we want to piggy back on the Observerable aspect of it.
// Just generate a change event for the Action (Show/Hide) block.
} }
} }
else else

@ -396,11 +396,20 @@ namespace Filtration.Parser.Services
var blockGroupText = inputString.Substring(blockGroupStart + 1).TrimStart(); var blockGroupText = inputString.Substring(blockGroupStart + 1).TrimStart();
if (blockGroupText.StartsWith("!")) var blockGroupModeStart = blockGroupText.IndexOf("|", StringComparison.Ordinal);
if (blockGroupModeStart >= 0)
{ {
block.DisableWithGroup = true; var blockGroupMode = blockGroupText.Substring(blockGroupModeStart + 1).Trim();
blockGroupText = blockGroupText.Substring(1); blockGroupText = blockGroupText.Substring(0, blockGroupModeStart);
//block.Description = block.Description + "--DR--";
// Compatible with http://filterblast.oversoul.xyz/item-filter-syntax.html#smartblocks
// Except that REMOVE is just like COMMENT and DISABLE.
if (blockGroupMode.Equals("Comment", StringComparison.OrdinalIgnoreCase) ||
blockGroupMode.Equals("Remove", StringComparison.OrdinalIgnoreCase) ||
blockGroupMode.Equals("Disable", StringComparison.OrdinalIgnoreCase))
{
block.DisableWithGroup = true;
}
} }
var blockGroups = blockGroupText.Split('-').ToList(); var blockGroups = blockGroupText.Split('-').ToList();
@ -469,7 +478,11 @@ namespace Filtration.Parser.Services
if (block.BlockGroup != null) if (block.BlockGroup != null)
{ {
outputString += (block.DisableWithGroup ? " #! " : " # ") + block.BlockGroup; outputString += " # " + block.BlockGroup;
if (block.DisableWithGroup)
{
outputString += " | Disable";
}
} }
// ReSharper disable once LoopCanBeConvertedToQuery // ReSharper disable once LoopCanBeConvertedToQuery

@ -4,7 +4,6 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Common.ViewModels;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes; using Filtration.ObjectModel.BlockItemTypes;
@ -13,7 +12,7 @@ using Filtration.Views;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
using Xceed.Wpf.Toolkit; using Xceed.Wpf.Toolkit;
namespace Filtration.ViewModels namespace Filtration.ViewModels
{ {
internal interface IItemFilterBlockViewModel internal interface IItemFilterBlockViewModel
@ -370,7 +369,6 @@ namespace Filtration.ViewModels
{ {
IsDirty = true; IsDirty = true;
RaisePropertyChanged(nameof(BlockEnabled)); RaisePropertyChanged(nameof(BlockEnabled));
Console.WriteLine("OnBlockChanged");
} }
public void RefreshBlockPreview() public void RefreshBlockPreview()