Fix the reading of CustomAlertSounds containing path separators.
This commit is contained in:
@@ -41,13 +41,13 @@ namespace Filtration.Parser.Services
|
||||
itemFilterCommentBlock.Comment += trimmedLine + Environment.NewLine;
|
||||
}
|
||||
|
||||
itemFilterCommentBlock.Comment = itemFilterCommentBlock.Comment.TrimEnd('\r', '\n');
|
||||
|
||||
itemFilterCommentBlock.Comment = itemFilterCommentBlock.Comment.TrimEnd('\r', '\n');
|
||||
|
||||
itemFilterCommentBlock.IsEdited = false;
|
||||
return itemFilterCommentBlock;
|
||||
}
|
||||
|
||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||
// and reading ItemFilterScripts from a file.
|
||||
public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "", bool initialiseBlockGroupHierarchyBuilder = false)
|
||||
{
|
||||
@@ -65,20 +65,20 @@ namespace Filtration.Parser.Services
|
||||
{
|
||||
if (line.StartsWith(@"#"))
|
||||
{
|
||||
if(!showHideFound)
|
||||
{
|
||||
block.Description = line.TrimStart('#').TrimStart(' ');
|
||||
if(!showHideFound)
|
||||
{
|
||||
block.Description = line.TrimStart('#').TrimStart(' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(block.BlockItems.Count > 1)
|
||||
{
|
||||
block.BlockItems.Last().Comment += Environment.NewLine + line.TrimStart('#');
|
||||
}
|
||||
else
|
||||
{
|
||||
block.ActionBlockItem.Comment += Environment.NewLine + line.TrimStart('#');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(block.BlockItems.Count > 1)
|
||||
{
|
||||
block.BlockItems.Last().Comment += Environment.NewLine + line.TrimStart('#');
|
||||
}
|
||||
else
|
||||
{
|
||||
block.ActionBlockItem.Comment += Environment.NewLine + line.TrimStart('#');
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -87,10 +87,10 @@ namespace Filtration.Parser.Services
|
||||
var trimmedLine = fullLine;
|
||||
var blockComment = "";
|
||||
var themeComponentType = -1;
|
||||
if(trimmedLine.IndexOf('#') > 0)
|
||||
{
|
||||
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
|
||||
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
|
||||
if(trimmedLine.IndexOf('#') > 0)
|
||||
{
|
||||
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
|
||||
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
|
||||
}
|
||||
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Filtration.Parser.Services
|
||||
RemoveExistingBlockItemsOfType<TextColorBlockItem>(block);
|
||||
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
|
||||
|
||||
|
||||
var blockItem = new TextColorBlockItem();
|
||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||
block.BlockItems.Add(blockItem);
|
||||
@@ -229,7 +229,7 @@ namespace Filtration.Parser.Services
|
||||
RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block);
|
||||
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
|
||||
|
||||
|
||||
var blockItem = new BackgroundColorBlockItem();
|
||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||
block.BlockItems.Add(blockItem);
|
||||
@@ -242,7 +242,7 @@ namespace Filtration.Parser.Services
|
||||
RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block);
|
||||
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
|
||||
|
||||
|
||||
var blockItem = new BorderColorBlockItem();
|
||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||
block.BlockItems.Add(blockItem);
|
||||
@@ -272,41 +272,41 @@ namespace Filtration.Parser.Services
|
||||
RemoveExistingBlockItemsOfType<CustomSoundBlockItem>(block);
|
||||
|
||||
var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (lineOption == "PlayAlertSound")
|
||||
{
|
||||
var blockItemValue = new SoundBlockItem
|
||||
{
|
||||
Value = firstValue,
|
||||
SecondValue = secondValue
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
var blockItemValue = new PositionalSoundBlockItem
|
||||
{
|
||||
Value = firstValue,
|
||||
SecondValue = secondValue
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
string firstValue = match.Groups[1].Value;
|
||||
int secondValue;
|
||||
|
||||
if (match.Groups[2].Success)
|
||||
{
|
||||
secondValue = Convert.ToInt16(match.Groups[2].Value);
|
||||
}
|
||||
themeComponentType = (int)ThemeComponentType.AlertSound;
|
||||
}
|
||||
else
|
||||
{
|
||||
secondValue = 79;
|
||||
}
|
||||
|
||||
if (lineOption == "PlayAlertSound")
|
||||
{
|
||||
var blockItemValue = new SoundBlockItem
|
||||
{
|
||||
Value = firstValue,
|
||||
SecondValue = secondValue
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
var blockItemValue = new PositionalSoundBlockItem
|
||||
{
|
||||
Value = firstValue,
|
||||
SecondValue = secondValue
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
}
|
||||
themeComponentType = (int)ThemeComponentType.AlertSound;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "GemLevel":
|
||||
@@ -341,49 +341,49 @@ namespace Filtration.Parser.Services
|
||||
{
|
||||
// Only ever use the last Icon item encountered as multiples aren't valid.
|
||||
RemoveExistingBlockItemsOfType<MapIconBlockItem>(block);
|
||||
|
||||
|
||||
// TODO: Get size, color, shape values programmatically
|
||||
var match = Regex.Match(trimmedLine,
|
||||
@"\S+\s+(0|1|2)\s+(Red|Green|Blue|Brown|White|Yellow)\s+(Circle|Diamond|Hexagon|Square|Star|Triangle)\s*([#]?)(.*)",
|
||||
RegexOptions.IgnoreCase);
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
};
|
||||
|
||||
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);
|
||||
themeComponentType = (int)ThemeComponentType.Icon;
|
||||
}
|
||||
|
||||
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);
|
||||
themeComponentType = (int)ThemeComponentType.Icon;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "PlayEffect":
|
||||
{
|
||||
// Only ever use the last BeamColor item encountered as multiples aren't valid.
|
||||
RemoveExistingBlockItemsOfType<PlayEffectBlockItem>(block);
|
||||
|
||||
|
||||
// TODO: Get colors programmatically
|
||||
var match = Regex.Match(trimmedLine, @"\S+\s+(Red|Green|Blue|Brown|White|Yellow)\s*(Temp)?", RegexOptions.IgnoreCase);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
var blockItemValue = new PlayEffectBlockItem
|
||||
{
|
||||
Color = EnumHelper.GetEnumValueFromDescription<EffectColor>(match.Groups[1].Value),
|
||||
Temporary = match.Groups[2].Value.Trim().ToLower() == "temp"
|
||||
};
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
var blockItemValue = new PlayEffectBlockItem
|
||||
{
|
||||
Color = EnumHelper.GetEnumValueFromDescription<EffectColor>(match.Groups[1].Value),
|
||||
Temporary = match.Groups[2].Value.Trim().ToLower() == "temp"
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
themeComponentType = (int)ThemeComponentType.Effect;
|
||||
themeComponentType = (int)ThemeComponentType.Effect;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -394,17 +394,17 @@ namespace Filtration.Parser.Services
|
||||
RemoveExistingBlockItemsOfType<SoundBlockItem>(block);
|
||||
RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block);
|
||||
|
||||
var match = Regex.Match(trimmedLine, @"\S+\s+""(\S+)""");
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
var blockItemValue = new CustomSoundBlockItem
|
||||
{
|
||||
Value = match.Groups[1].Value
|
||||
};
|
||||
var match = Regex.Match(trimmedLine, @"\S+\s+""([^\*\<\>\?|]+)""");
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
var blockItemValue = new CustomSoundBlockItem
|
||||
{
|
||||
Value = match.Groups[1].Value
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
themeComponentType = (int)ThemeComponentType.CustomSound;
|
||||
}
|
||||
themeComponentType = (int)ThemeComponentType.CustomSound;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "MapTier":
|
||||
@@ -412,88 +412,88 @@ namespace Filtration.Parser.Services
|
||||
AddNumericFilterPredicateItemToBlockItems<MapTierBlockItem>(block, trimmedLine);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1)
|
||||
{
|
||||
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme;
|
||||
if(blockItemWithTheme == null)
|
||||
{
|
||||
block.BlockItems.Last().Comment = blockComment;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch((ThemeComponentType)themeComponentType)
|
||||
{
|
||||
case ThemeComponentType.AlertSound:
|
||||
{
|
||||
ThemeComponent themeComponent = null;
|
||||
if(blockItemWithTheme is SoundBlockItem)
|
||||
{
|
||||
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
|
||||
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
|
||||
((PositionalSoundBlockItem)blockItemWithTheme).Value, ((PositionalSoundBlockItem)blockItemWithTheme).SecondValue);
|
||||
}
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.BackgroundColor:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
|
||||
blockComment.Trim(), ((BackgroundColorBlockItem)blockItemWithTheme).Color);
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.BorderColor:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
|
||||
blockComment.Trim(), ((BorderColorBlockItem)blockItemWithTheme).Color);
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.CustomSound:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound,
|
||||
blockComment.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;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.TextColor:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
|
||||
blockComment.Trim(), ((TextColorBlockItem)blockItemWithTheme).Color);
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1)
|
||||
{
|
||||
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme;
|
||||
if(blockItemWithTheme == null)
|
||||
{
|
||||
block.BlockItems.Last().Comment = blockComment;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch((ThemeComponentType)themeComponentType)
|
||||
{
|
||||
case ThemeComponentType.AlertSound:
|
||||
{
|
||||
ThemeComponent themeComponent = null;
|
||||
if(blockItemWithTheme is SoundBlockItem)
|
||||
{
|
||||
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
|
||||
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
|
||||
((PositionalSoundBlockItem)blockItemWithTheme).Value, ((PositionalSoundBlockItem)blockItemWithTheme).SecondValue);
|
||||
}
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.BackgroundColor:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
|
||||
blockComment.Trim(), ((BackgroundColorBlockItem)blockItemWithTheme).Color);
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.BorderColor:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
|
||||
blockComment.Trim(), ((BorderColorBlockItem)blockItemWithTheme).Color);
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.CustomSound:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound,
|
||||
blockComment.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;
|
||||
break;
|
||||
}
|
||||
case ThemeComponentType.TextColor:
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
|
||||
blockComment.Trim(), ((TextColorBlockItem)blockItemWithTheme).Color);
|
||||
blockItemWithTheme.ThemeComponent = themeComponent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
block.IsEdited = false;
|
||||
return block;
|
||||
}
|
||||
@@ -523,7 +523,7 @@ namespace Filtration.Parser.Services
|
||||
private static void AddNumericFilterPredicateItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem
|
||||
{
|
||||
var blockItem = Activator.CreateInstance<T>();
|
||||
|
||||
|
||||
SetNumericFilterPredicateFromString(blockItem.FilterPredicate, inputString);
|
||||
block.BlockItems.Add(blockItem);
|
||||
}
|
||||
@@ -572,12 +572,12 @@ namespace Filtration.Parser.Services
|
||||
var matches = Regex.Match(line, @"(\w+)");
|
||||
var blockComment = "";
|
||||
var trimmedLine = line.Trim();
|
||||
if (trimmedLine.IndexOf('#') > 0)
|
||||
{
|
||||
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
|
||||
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
|
||||
}
|
||||
|
||||
if (trimmedLine.IndexOf('#') > 0)
|
||||
{
|
||||
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
|
||||
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
|
||||
}
|
||||
|
||||
switch (matches.Value)
|
||||
{
|
||||
case "PlayAlertSound":
|
||||
@@ -585,11 +585,11 @@ namespace Filtration.Parser.Services
|
||||
var match = Regex.Match(trimmedLine, @"\s+(\S+) (\d+)");
|
||||
if (!match.Success) break;
|
||||
var blockItem = new SoundBlockItem(match.Groups[1].Value, Convert.ToInt16(match.Groups[2].Value));
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound,
|
||||
blockComment, blockItem.Value, blockItem.SecondValue);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound,
|
||||
blockComment, blockItem.Value, blockItem.SecondValue);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
}
|
||||
blockItems.Add(blockItem);
|
||||
break;
|
||||
@@ -597,14 +597,14 @@ namespace Filtration.Parser.Services
|
||||
case "SetTextColor":
|
||||
{
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
|
||||
|
||||
|
||||
var blockItem = new TextColorBlockItem();
|
||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
|
||||
blockComment, blockItem.Color);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
|
||||
blockComment, blockItem.Color);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
}
|
||||
blockItems.Add(blockItem);
|
||||
break;
|
||||
@@ -612,14 +612,14 @@ namespace Filtration.Parser.Services
|
||||
case "SetBackgroundColor":
|
||||
{
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
|
||||
|
||||
|
||||
var blockItem = new BackgroundColorBlockItem();
|
||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
|
||||
blockComment, blockItem.Color);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
|
||||
blockComment, blockItem.Color);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
}
|
||||
blockItems.Add(blockItem);
|
||||
break;
|
||||
@@ -627,14 +627,14 @@ namespace Filtration.Parser.Services
|
||||
case "SetBorderColor":
|
||||
{
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
|
||||
|
||||
|
||||
var blockItem = new BorderColorBlockItem();
|
||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
|
||||
blockComment, blockItem.Color);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
|
||||
blockComment, blockItem.Color);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
}
|
||||
blockItems.Add(blockItem);
|
||||
break;
|
||||
@@ -644,19 +644,19 @@ namespace Filtration.Parser.Services
|
||||
var match = Regex.Match(trimmedLine, @"\s+(\d+)");
|
||||
if (!match.Success) break;
|
||||
var blockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value));
|
||||
if (_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
|
||||
blockComment, blockItem.Value);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
if (_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
|
||||
{
|
||||
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
|
||||
blockComment, blockItem.Value);
|
||||
blockItem.ThemeComponent = themeComponent;
|
||||
}
|
||||
blockItems.Add(blockItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void AddBlockGroupToBlock(IItemFilterBlock block, string inputString)
|
||||
{
|
||||
var blockGroupText = GetTextAfterFirstComment(inputString);
|
||||
@@ -723,15 +723,15 @@ namespace Filtration.Parser.Services
|
||||
// TODO: Private
|
||||
public string TranslateItemFilterCommentBlockToString(IItemFilterCommentBlock itemFilterCommentBlock)
|
||||
{
|
||||
if (!itemFilterCommentBlock.IsEdited)
|
||||
{
|
||||
return itemFilterCommentBlock.OriginalText;
|
||||
if (!itemFilterCommentBlock.IsEdited)
|
||||
{
|
||||
return itemFilterCommentBlock.OriginalText;
|
||||
}
|
||||
|
||||
// TODO: Tests
|
||||
// TODO: # Section: text?
|
||||
var commentWithHashes = string.Empty;
|
||||
|
||||
var commentWithHashes = string.Empty;
|
||||
|
||||
// Add "# " to the beginning of each line of the comment before saving it
|
||||
foreach (var line in new LineReader(() => new StringReader(itemFilterCommentBlock.Comment)))
|
||||
{
|
||||
@@ -741,15 +741,15 @@ namespace Filtration.Parser.Services
|
||||
// Remove trailing newline
|
||||
return commentWithHashes.TrimEnd('\r', '\n');
|
||||
}
|
||||
|
||||
|
||||
// This method converts an ItemFilterBlock object into a string. This is used for copying a ItemFilterBlock
|
||||
// to the clipboard, and when saving a ItemFilterScript.
|
||||
// TODO: Private
|
||||
public string TranslateItemFilterBlockToString(IItemFilterBlock block)
|
||||
{
|
||||
if(!block.IsEdited)
|
||||
{
|
||||
return block.OriginalText;
|
||||
if(!block.IsEdited)
|
||||
{
|
||||
return block.OriginalText;
|
||||
}
|
||||
|
||||
var outputString = string.Empty;
|
||||
@@ -777,14 +777,14 @@ namespace Filtration.Parser.Services
|
||||
{
|
||||
outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Disabled for the time being. A better solution is needed.
|
||||
// Replace 'Maelström' to prevent encoding problems in other editors
|
||||
//outputString.Replace("Maelström Staff", "Maelstr");
|
||||
//outputString.Replace("Maelström of Chaos", "Maelstr");
|
||||
//outputString.Replace("Maelström", "Maelstr");
|
||||
|
||||
}
|
||||
|
||||
//TODO: Disabled for the time being. A better solution is needed.
|
||||
// Replace 'Maelström' to prevent encoding problems in other editors
|
||||
//outputString.Replace("Maelström Staff", "Maelstr");
|
||||
//outputString.Replace("Maelström of Chaos", "Maelstr");
|
||||
//outputString.Replace("Maelström", "Maelstr");
|
||||
|
||||
return outputString;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user