Disabled setting themes for MinimapIcon, PlayEffect and SetFontSize blocks (temporary fix for issue #68)

This commit is contained in:
Ben Wallis 2018-09-28 17:20:42 +01:00
parent 43e5b30080
commit 3ce2e12f56
2 changed files with 39 additions and 52 deletions

View File

@ -32,8 +32,7 @@ namespace Filtration.Parser.Services
// Converts a string into an ItemFilterCommentBlock maintaining newlines and spaces but removing # characters // Converts a string into an ItemFilterCommentBlock maintaining newlines and spaces but removing # characters
public IItemFilterCommentBlock TranslateStringToItemFilterCommentBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "") public IItemFilterCommentBlock TranslateStringToItemFilterCommentBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "")
{ {
var itemFilterCommentBlock = new ItemFilterCommentBlock(parentItemFilterScript); var itemFilterCommentBlock = new ItemFilterCommentBlock(parentItemFilterScript) {OriginalText = originalString};
itemFilterCommentBlock.OriginalText = originalString;
foreach (var line in new LineReader(() => new StringReader(inputString))) foreach (var line in new LineReader(() => new StringReader(inputString)))
{ {
@ -217,8 +216,7 @@ namespace Filtration.Parser.Services
var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new TextColorBlockItem(); var blockItem = new TextColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem); block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.TextColor; themeComponentType = (int)ThemeComponentType.TextColor;
break; break;
@ -230,8 +228,7 @@ namespace Filtration.Parser.Services
var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BackgroundColorBlockItem(); var blockItem = new BackgroundColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem); block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BackgroundColor; themeComponentType = (int)ThemeComponentType.BackgroundColor;
break; break;
@ -243,8 +240,7 @@ namespace Filtration.Parser.Services
var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BorderColorBlockItem(); var blockItem = new BorderColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem); block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BorderColor; themeComponentType = (int)ThemeComponentType.BorderColor;
break; break;
@ -276,16 +272,8 @@ namespace Filtration.Parser.Services
if (match.Success) if (match.Success)
{ {
string firstValue = match.Groups[1].Value; string firstValue = match.Groups[1].Value;
int secondValue;
if (match.Groups[2].Success) var secondValue = match.Groups[2].Success ? Convert.ToInt16(match.Groups[2].Value) : 79;
{
secondValue = Convert.ToInt16(match.Groups[2].Value);
}
else
{
secondValue = 79;
}
if (lineOption == "PlayAlertSound") if (lineOption == "PlayAlertSound")
{ {
@ -351,15 +339,15 @@ namespace Filtration.Parser.Services
{ {
var blockItemValue = new MapIconBlockItem var blockItemValue = new MapIconBlockItem
{ {
Size = (IconSize)Int16.Parse(match.Groups[1].Value), Size = (IconSize)short.Parse(match.Groups[1].Value),
Color = EnumHelper.GetEnumValueFromDescription<IconColor>(match.Groups[2].Value), Color = EnumHelper.GetEnumValueFromDescription<IconColor>(match.Groups[2].Value),
Shape = EnumHelper.GetEnumValueFromDescription<IconShape>(match.Groups[3].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)) 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; blockItemValue.ThemeComponent = themeComponent;
} }
block.BlockItems.Add(blockItemValue); block.BlockItems.Add(blockItemValue);
@ -416,8 +404,7 @@ namespace Filtration.Parser.Services
if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1) if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1)
{ {
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme; if(!(block.BlockItems.Last() is IBlockItemWithTheme blockItemWithTheme))
if(blockItemWithTheme == null)
{ {
block.BlockItems.Last().Comment = blockComment; block.BlockItems.Last().Comment = blockComment;
} }
@ -427,11 +414,11 @@ namespace Filtration.Parser.Services
{ {
case ThemeComponentType.AlertSound: case ThemeComponentType.AlertSound:
{ {
ThemeComponent themeComponent = null; ThemeComponent themeComponent;
if(blockItemWithTheme is SoundBlockItem) if(blockItemWithTheme is SoundBlockItem item)
{ {
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(), themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue); item.Value, item.SecondValue);
} }
else else
{ {
@ -598,8 +585,7 @@ namespace Filtration.Parser.Services
{ {
var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new TextColorBlockItem(); var blockItem = new TextColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{ {
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor, ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
@ -613,8 +599,7 @@ namespace Filtration.Parser.Services
{ {
var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BackgroundColorBlockItem(); var blockItem = new BackgroundColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{ {
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor, ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
@ -628,8 +613,7 @@ namespace Filtration.Parser.Services
{ {
var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BorderColorBlockItem(); var blockItem = new BorderColorBlockItem {Color = GetColorFromString(result[0].Groups[1].Value)};
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{ {
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor, ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,

View File

@ -97,14 +97,15 @@
DisplayMemberPath="Description" DisplayMemberPath="Description"
SelectedValue="{Binding Color}" SelectedValue="{Binding Color}"
SelectedValuePath="Value" /> 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> <userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}"> <MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/> <Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." /> <Binding Path="." />
</MultiBinding> </MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents> </userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl> </userControls:ThemeComponentSelectionControl>-->
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
@ -133,14 +134,15 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<xctk:ShortUpDown Grid.Column="0" Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Margin="0,0,10,0" /> <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> <userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}"> <MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/> <Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." /> <Binding Path="." />
</MultiBinding> </MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents> </userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl> </userControls:ThemeComponentSelectionControl>-->
</Grid> </Grid>
</DataTemplate> </DataTemplate>
@ -197,14 +199,15 @@
DisplayMemberPath="Description" DisplayMemberPath="Description"
SelectedValue="{Binding Shape}" SelectedValue="{Binding Shape}"
SelectedValuePath="Value" /> 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> <userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}"> <MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/> <Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." /> <Binding Path="." />
</MultiBinding> </MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents> </userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl> </userControls:ThemeComponentSelectionControl>-->
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>