Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Disabled setting themes for MinimapIcon, PlayEffect and SetFontSize b…
Browse files Browse the repository at this point in the history
…locks (temporary fix for issue #68)
  • Loading branch information
ben-wallis committed Sep 28, 2018
1 parent 43e5b30 commit 3ce2e12
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 52 deletions.
76 changes: 30 additions & 46 deletions Filtration.Parser/Services/ItemFilterBlockTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchy
// Converts a string into an ItemFilterCommentBlock maintaining newlines and spaces but removing # characters
public IItemFilterCommentBlock TranslateStringToItemFilterCommentBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "")
{
var itemFilterCommentBlock = new ItemFilterCommentBlock(parentItemFilterScript);
itemFilterCommentBlock.OriginalText = originalString;
var itemFilterCommentBlock = new ItemFilterCommentBlock(parentItemFilterScript) {OriginalText = originalString};

foreach (var line in new LineReader(() => new StringReader(inputString)))
{
Expand Down Expand Up @@ -216,9 +215,8 @@ public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IIt
RemoveExistingBlockItemsOfType<TextColorBlockItem>(block);

var result = Regex.Matches(trimmedLine, @"([\w\s]*)");

var blockItem = new TextColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);

var blockItem = new TextColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.TextColor;
break;
Expand All @@ -229,9 +227,8 @@ public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IIt
RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block);

var result = Regex.Matches(trimmedLine, @"([\w\s]*)");

var blockItem = new BackgroundColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);

var blockItem = new BackgroundColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BackgroundColor;
break;
Expand All @@ -242,9 +239,8 @@ public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IIt
RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block);

var result = Regex.Matches(trimmedLine, @"([\w\s]*)");

var blockItem = new BorderColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);

var blockItem = new BorderColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BorderColor;
break;
Expand Down Expand Up @@ -275,17 +271,9 @@ public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IIt

if (match.Success)
{
string firstValue = match.Groups[1].Value;
int secondValue;

if (match.Groups[2].Success)
{
secondValue = Convert.ToInt16(match.Groups[2].Value);
}
else
{
secondValue = 79;
}
string firstValue = match.Groups[1].Value;

var secondValue = match.Groups[2].Success ? Convert.ToInt16(match.Groups[2].Value) : 79;

if (lineOption == "PlayAlertSound")
{
Expand Down Expand Up @@ -349,17 +337,17 @@ public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IIt

if (match.Success)
{
var blockItemValue = new MapIconBlockItem
{
Size = (IconSize)Int16.Parse(match.Groups[1].Value),
Color = EnumHelper.GetEnumValueFromDescription<IconColor>(match.Groups[2].Value),
Shape = EnumHelper.GetEnumValueFromDescription<IconShape>(match.Groups[3].Value)
var blockItemValue = new MapIconBlockItem
{
Size = (IconSize)short.Parse(match.Groups[1].Value),
Color = EnumHelper.GetEnumValueFromDescription<IconColor>(match.Groups[2].Value),
Shape = EnumHelper.GetEnumValueFromDescription<IconShape>(match.Groups[3].Value)
};


var themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, match.Groups[5].Value.Trim(),
blockItemValue.Size, blockItemValue.Color, blockItemValue.Shape);
if(match.Groups[4].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[5].Value))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, match.Groups[5].Value.Trim(),
blockItemValue.Size, blockItemValue.Color, blockItemValue.Shape);
{
blockItemValue.ThemeComponent = themeComponent;
}
block.BlockItems.Add(blockItemValue);
Expand Down Expand Up @@ -415,9 +403,8 @@ public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IIt
}

if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1)
{
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme;
if(blockItemWithTheme == null)
{
if(!(block.BlockItems.Last() is IBlockItemWithTheme blockItemWithTheme))
{
block.BlockItems.Last().Comment = blockComment;
}
Expand All @@ -427,11 +414,11 @@ public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IIt
{
case ThemeComponentType.AlertSound:
{
ThemeComponent themeComponent = null;
if(blockItemWithTheme is SoundBlockItem)
ThemeComponent themeComponent;
if(blockItemWithTheme is SoundBlockItem item)
{
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue);
item.Value, item.SecondValue);
}
else
{
Expand Down Expand Up @@ -597,9 +584,8 @@ public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFil
case "SetTextColor":
{
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");

var blockItem = new TextColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);

var blockItem = new TextColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
Expand All @@ -612,9 +598,8 @@ public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFil
case "SetBackgroundColor":
{
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");

var blockItem = new BackgroundColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);

var blockItem = new BackgroundColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
Expand All @@ -627,9 +612,8 @@ public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFil
case "SetBorderColor":
{
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");

var blockItem = new BorderColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);

var blockItem = new BorderColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
Expand Down
15 changes: 9 additions & 6 deletions Filtration/UserControls/BlockItemControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@
DisplayMemberPath="Description"
SelectedValue="{Binding Color}"
SelectedValuePath="Value" />
<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}" Margin="0,2,0,0">
<!-- Disabled until there is a solution to GitHub Issue #68 (certain block items do not support trailing comments) -->
<!--<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}" Margin="0,2,0,0">
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." />
</MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl>
</userControls:ThemeComponentSelectionControl>-->
</StackPanel>
</DataTemplate>

Expand Down Expand Up @@ -133,14 +134,15 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<xctk:ShortUpDown Grid.Column="0" Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Margin="0,0,10,0" />
<userControls:ThemeComponentSelectionControl Grid.Column="1" ThemeComponent="{Binding ThemeComponent}">
<!-- Disabled until there is a solution to GitHub Issue #68 (certain block items do not support trailing comments) -->
<!--<userControls:ThemeComponentSelectionControl Grid.Column="1" ThemeComponent="{Binding ThemeComponent}">
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." />
</MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl>
</userControls:ThemeComponentSelectionControl>-->
</Grid>
</DataTemplate>

Expand Down Expand Up @@ -197,14 +199,15 @@
DisplayMemberPath="Description"
SelectedValue="{Binding Shape}"
SelectedValuePath="Value" />
<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}" Margin="0,2,0,0">
<!-- Disabled until there is a solution to GitHub Issue #68 (certain block items do not support trailing comments) -->
<!--<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}" Margin="0,2,0,0">
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." />
</MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl>
</userControls:ThemeComponentSelectionControl>-->
</StackPanel>
</DataTemplate>

Expand Down

0 comments on commit 3ce2e12

Please sign in to comment.