Put theme name over if trailing is not supported
This commit is contained in:
parent
1b8f37ca3a
commit
4f8cb84121
@ -18,7 +18,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||||||
Value = value;
|
Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string OutputText => PrefixText + " " + Value + (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty);
|
public override string OutputText => PrefixText + " " + Value;
|
||||||
|
|
||||||
public override string SummaryText => string.Empty;
|
public override string SummaryText => string.Empty;
|
||||||
public override Color SummaryBackgroundColor => Colors.Transparent;
|
public override Color SummaryBackgroundColor => Colors.Transparent;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@ -19,5 +20,8 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
public override int SortOrder => 25;
|
public override int SortOrder => 25;
|
||||||
public override int Minimum => 11;
|
public override int Minimum => 11;
|
||||||
public override int Maximum => 45;
|
public override int Maximum => 45;
|
||||||
|
|
||||||
|
public override string OutputText => (ThemeComponent != null ? "# " + ThemeComponent.ComponentName + Environment.NewLine : string.Empty) +
|
||||||
|
PrefixText + " " + Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.Extensions;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@ -20,5 +22,8 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
public override int MaximumAllowed => 1;
|
public override int MaximumAllowed => 1;
|
||||||
public override string DisplayHeading => "Minimap Icon";
|
public override string DisplayHeading => "Minimap Icon";
|
||||||
public override int SortOrder => 29;
|
public override int SortOrder => 29;
|
||||||
|
|
||||||
|
public override string OutputText => (ThemeComponent != null ? "# " + ThemeComponent.ComponentName + Environment.NewLine : string.Empty) +
|
||||||
|
PrefixText + " " + (int)Size + " " + Color.GetAttributeDescription() + " " + Shape.GetAttributeDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.Extensions;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@ -19,5 +21,9 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
public override int MaximumAllowed => 1;
|
public override int MaximumAllowed => 1;
|
||||||
public override string DisplayHeading => "Play Effect";
|
public override string DisplayHeading => "Play Effect";
|
||||||
public override int SortOrder => 30;
|
public override int SortOrder => 30;
|
||||||
|
|
||||||
|
public override string OutputText => (ThemeComponent != null ? "# " + ThemeComponent.ComponentName + Environment.NewLine : string.Empty) +
|
||||||
|
PrefixText + " " + Color.GetAttributeDescription() +
|
||||||
|
(Temporary ? " " + "Temp" : string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -945,8 +945,10 @@ namespace Filtration.Parser.Tests.Services
|
|||||||
" PlayAlertSound 3" + Environment.NewLine +
|
" PlayAlertSound 3" + Environment.NewLine +
|
||||||
" DisableDropSound False" + Environment.NewLine +
|
" DisableDropSound False" + Environment.NewLine +
|
||||||
" CustomAlertSound \"test.mp3\" # customSoundTheme" + Environment.NewLine +
|
" CustomAlertSound \"test.mp3\" # customSoundTheme" + Environment.NewLine +
|
||||||
" MinimapIcon 2 Green Triangle # iconTheme" + Environment.NewLine +
|
" # iconTheme" + Environment.NewLine +
|
||||||
" PlayEffect Green Temp # effectTheme" + Environment.NewLine;
|
" MinimapIcon 2 Green Triangle" + Environment.NewLine +
|
||||||
|
" # effectTheme" + Environment.NewLine +
|
||||||
|
" PlayEffect Green Temp" + Environment.NewLine;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||||
|
@ -61,35 +61,30 @@ namespace Filtration.Parser.Services
|
|||||||
var showHideFound = false;
|
var showHideFound = false;
|
||||||
block.OriginalText = originalString;
|
block.OriginalText = originalString;
|
||||||
|
|
||||||
|
var blockComment = new List<string>();
|
||||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||||
{
|
{
|
||||||
if (line.StartsWith(@"#"))
|
if(line.Trim().StartsWith(@"#") || string.IsNullOrWhiteSpace(line))
|
||||||
{
|
{
|
||||||
if(!showHideFound)
|
if(!showHideFound)
|
||||||
{
|
{
|
||||||
block.Description = line.TrimStart('#').TrimStart(' ');
|
block.Description = line.TrimStart('#').TrimStart(' ');
|
||||||
|
blockComment.Clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(block.BlockItems.Count > 1)
|
blockComment.Add(line.Trim().TrimStart('#'));
|
||||||
{
|
|
||||||
block.BlockItems.Last().Comment += Environment.NewLine + line.TrimStart('#');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
block.ActionBlockItem.Comment += Environment.NewLine + line.TrimStart('#');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullLine = line.Trim();
|
var fullLine = line.Trim();
|
||||||
var trimmedLine = fullLine;
|
var trimmedLine = fullLine;
|
||||||
var blockComment = "";
|
var trailingComment = "";
|
||||||
var themeComponentType = -1;
|
var themeComponentType = -1;
|
||||||
if(trimmedLine.IndexOf('#') > 0)
|
if(trimmedLine.IndexOf('#') > 0)
|
||||||
{
|
{
|
||||||
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
|
trailingComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
|
||||||
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
|
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
|
||||||
}
|
}
|
||||||
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
||||||
@ -414,14 +409,10 @@ namespace Filtration.Parser.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1)
|
if (themeComponentType >= 0)
|
||||||
{
|
{
|
||||||
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme;
|
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme;
|
||||||
if(blockItemWithTheme == null)
|
if(!string.IsNullOrWhiteSpace(trailingComment))
|
||||||
{
|
|
||||||
block.BlockItems.Last().Comment = blockComment;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
switch ((ThemeComponentType)themeComponentType)
|
switch ((ThemeComponentType)themeComponentType)
|
||||||
{
|
{
|
||||||
@ -430,12 +421,12 @@ namespace Filtration.Parser.Services
|
|||||||
ThemeComponent themeComponent = null;
|
ThemeComponent themeComponent = null;
|
||||||
if (blockItemWithTheme is SoundBlockItem)
|
if (blockItemWithTheme is SoundBlockItem)
|
||||||
{
|
{
|
||||||
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
|
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, trailingComment.Trim(),
|
||||||
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue);
|
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
|
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, trailingComment.Trim(),
|
||||||
((PositionalSoundBlockItem)blockItemWithTheme).Value, ((PositionalSoundBlockItem)blockItemWithTheme).SecondValue);
|
((PositionalSoundBlockItem)blockItemWithTheme).Value, ((PositionalSoundBlockItem)blockItemWithTheme).SecondValue);
|
||||||
}
|
}
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
@ -444,55 +435,72 @@ namespace Filtration.Parser.Services
|
|||||||
case ThemeComponentType.BackgroundColor:
|
case ThemeComponentType.BackgroundColor:
|
||||||
{
|
{
|
||||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
|
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
|
||||||
blockComment.Trim(), ((BackgroundColorBlockItem)blockItemWithTheme).Color);
|
trailingComment.Trim(), ((BackgroundColorBlockItem)blockItemWithTheme).Color);
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ThemeComponentType.BorderColor:
|
case ThemeComponentType.BorderColor:
|
||||||
{
|
{
|
||||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
|
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
|
||||||
blockComment.Trim(), ((BorderColorBlockItem)blockItemWithTheme).Color);
|
trailingComment.Trim(), ((BorderColorBlockItem)blockItemWithTheme).Color);
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ThemeComponentType.CustomSound:
|
case ThemeComponentType.CustomSound:
|
||||||
{
|
{
|
||||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound,
|
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound,
|
||||||
blockComment.Trim(), ((CustomSoundBlockItem)blockItemWithTheme).Value);
|
trailingComment.Trim(), ((CustomSoundBlockItem)blockItemWithTheme).Value);
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ThemeComponentType.Effect:
|
|
||||||
{
|
|
||||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Effect,
|
|
||||||
blockComment.Trim(), ((EffectColorBlockItem)blockItemWithTheme).Color, ((EffectColorBlockItem)blockItemWithTheme).Temporary);
|
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ThemeComponentType.FontSize:
|
|
||||||
{
|
|
||||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
|
|
||||||
blockComment.Trim(), ((FontSizeBlockItem)blockItemWithTheme).Value);
|
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ThemeComponentType.Icon:
|
|
||||||
{
|
|
||||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, blockComment.Trim(),
|
|
||||||
((IconBlockItem)blockItemWithTheme).Size, ((IconBlockItem)blockItemWithTheme).Color, ((IconBlockItem)blockItemWithTheme).Shape);
|
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ThemeComponentType.TextColor:
|
case ThemeComponentType.TextColor:
|
||||||
{
|
{
|
||||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
|
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
|
||||||
blockComment.Trim(), ((TextColorBlockItem)blockItemWithTheme).Color);
|
trailingComment.Trim(), ((TextColorBlockItem)blockItemWithTheme).Color);
|
||||||
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockComment.Count > 0 && !string.IsNullOrWhiteSpace(blockComment.Last()))
|
||||||
|
{
|
||||||
|
var lastLine = blockComment.Last();
|
||||||
|
blockComment.RemoveAt(blockComment.Count - 1);
|
||||||
|
|
||||||
|
switch ((ThemeComponentType)themeComponentType)
|
||||||
|
{
|
||||||
|
case ThemeComponentType.Effect:
|
||||||
|
{
|
||||||
|
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Effect,
|
||||||
|
lastLine.Trim(), ((EffectColorBlockItem)blockItemWithTheme).Color, ((EffectColorBlockItem)blockItemWithTheme).Temporary);
|
||||||
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ThemeComponentType.FontSize:
|
||||||
|
{
|
||||||
|
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
|
||||||
|
lastLine.Trim(), ((FontSizeBlockItem)blockItemWithTheme).Value);
|
||||||
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ThemeComponentType.Icon:
|
||||||
|
{
|
||||||
|
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, lastLine.Trim(),
|
||||||
|
((IconBlockItem)blockItemWithTheme).Size, ((IconBlockItem)blockItemWithTheme).Color, ((IconBlockItem)blockItemWithTheme).Shape);
|
||||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(blockComment.Count > 0 && block.BlockItems.Count > 0)
|
||||||
|
{
|
||||||
|
block.BlockItems.Last().Comment = string.Join(Environment.NewLine, blockComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockComment.Clear();
|
||||||
}
|
}
|
||||||
block.IsEdited = false;
|
block.IsEdited = false;
|
||||||
return block;
|
return block;
|
||||||
@ -773,9 +781,20 @@ namespace Filtration.Parser.Services
|
|||||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||||
foreach (var blockItem in block.BlockItems.Where(b => b.GetType() != typeof(ActionBlockItem)).OrderBy(b => b.SortOrder))
|
foreach (var blockItem in block.BlockItems.Where(b => b.GetType() != typeof(ActionBlockItem)).OrderBy(b => b.SortOrder))
|
||||||
{
|
{
|
||||||
|
if (!string.IsNullOrEmpty(blockItem.Comment))
|
||||||
|
{
|
||||||
|
foreach(var line in Regex.Split(blockItem.Comment, "\r\n|\r|\n"))
|
||||||
|
{
|
||||||
|
outputString += (!block.Enabled ? _disabledNewLine : _newLine) + "#" + line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (blockItem.OutputText != string.Empty)
|
if (blockItem.OutputText != string.Empty)
|
||||||
{
|
{
|
||||||
outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText;
|
foreach (var line in Regex.Split(blockItem.OutputText, "\r\n|\r|\n"))
|
||||||
|
{
|
||||||
|
outputString += (!block.Enabled ? _disabledNewLine : _newLine) +line;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user