Fixed multiline comment saving
This commit is contained in:
parent
523a9553d9
commit
9cf4d86cb0
|
@ -471,11 +471,15 @@ namespace Filtration.Parser.Services
|
||||||
|
|
||||||
public string TranslateItemFilterBlockBaseToString(IItemFilterBlockBase itemFilterBlockBase)
|
public string TranslateItemFilterBlockBaseToString(IItemFilterBlockBase itemFilterBlockBase)
|
||||||
{
|
{
|
||||||
var itemFilterBlock = itemFilterBlockBase as IItemFilterBlock;
|
if (itemFilterBlockBase is IItemFilterBlock itemFilterBlock)
|
||||||
if (itemFilterBlock != null) return TranslateItemFilterBlockToString(itemFilterBlock);
|
{
|
||||||
|
return TranslateItemFilterBlockToString(itemFilterBlock);
|
||||||
|
}
|
||||||
|
|
||||||
var itemFilterCommentBlock = itemFilterBlockBase as IItemFilterCommentBlock;
|
if (itemFilterBlockBase is IItemFilterCommentBlock itemFilterCommentBlock)
|
||||||
if (itemFilterCommentBlock != null) return TranslateItemFilterCommentBlockToString(itemFilterCommentBlock);
|
{
|
||||||
|
return TranslateItemFilterCommentBlockToString(itemFilterCommentBlock);
|
||||||
|
}
|
||||||
|
|
||||||
throw new InvalidOperationException("Unable to translate unknown ItemFilterBlock type");
|
throw new InvalidOperationException("Unable to translate unknown ItemFilterBlock type");
|
||||||
}
|
}
|
||||||
|
@ -483,10 +487,18 @@ namespace Filtration.Parser.Services
|
||||||
// TODO: Private
|
// TODO: Private
|
||||||
public string TranslateItemFilterCommentBlockToString(IItemFilterCommentBlock itemFilterCommentBlock)
|
public string TranslateItemFilterCommentBlockToString(IItemFilterCommentBlock itemFilterCommentBlock)
|
||||||
{
|
{
|
||||||
// TODO: Handle multi-line
|
|
||||||
// TODO: Tests
|
// TODO: Tests
|
||||||
// TODO: # Section: text?
|
// TODO: # Section: text?
|
||||||
return $"#{itemFilterCommentBlock.Comment}";
|
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)))
|
||||||
|
{
|
||||||
|
commentWithHashes += $"# {line.TrimStart(' ')}{Environment.NewLine}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove trailing newline
|
||||||
|
return commentWithHashes.TrimEnd('\r', '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method converts an ItemFilterBlock object into a string. This is used for copying a ItemFilterBlock
|
// This method converts an ItemFilterBlock object into a string. This is used for copying a ItemFilterBlock
|
||||||
|
|
|
@ -126,7 +126,11 @@ namespace Filtration.Parser.Services
|
||||||
// Process the script header
|
// Process the script header
|
||||||
for (var i = 0; i < conditionBoundaries.Skip(1).First().StartLine; i++)
|
for (var i = 0; i < conditionBoundaries.Skip(1).First().StartLine; i++)
|
||||||
{
|
{
|
||||||
if (lines[i].StartsWith("#"))
|
if (lines[i].StartsWith("# EnableBlockGroups"))
|
||||||
|
{
|
||||||
|
script.ItemFilterScriptSettings.BlockGroupsEnabled = true;
|
||||||
|
}
|
||||||
|
else if (lines[i].StartsWith("#"))
|
||||||
{
|
{
|
||||||
script.Description += lines[i].Substring(1).Trim(' ') + Environment.NewLine;
|
script.Description += lines[i].Substring(1).Trim(' ') + Environment.NewLine;
|
||||||
}
|
}
|
||||||
|
@ -235,6 +239,11 @@ namespace Filtration.Parser.Services
|
||||||
outputString += "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" +
|
outputString += "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" +
|
||||||
Environment.NewLine;
|
Environment.NewLine;
|
||||||
|
|
||||||
|
if (script.ItemFilterScriptSettings.BlockGroupsEnabled)
|
||||||
|
{
|
||||||
|
outputString += "# EnableBlockGroups" + Environment.NewLine;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(script.Description))
|
if (!string.IsNullOrEmpty(script.Description))
|
||||||
{
|
{
|
||||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||||
|
@ -251,7 +260,7 @@ namespace Filtration.Parser.Services
|
||||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||||
foreach (var block in script.ItemFilterBlocks)
|
foreach (var block in script.ItemFilterBlocks)
|
||||||
{
|
{
|
||||||
outputString += _blockTranslator.TranslateItemFilterBlockToString(block as ItemFilterBlock) + Environment.NewLine;
|
outputString += _blockTranslator.TranslateItemFilterBlockBaseToString(block) + Environment.NewLine;
|
||||||
|
|
||||||
if (Settings.Default.ExtraLineBetweenBlocks)
|
if (Settings.Default.ExtraLineBetweenBlocks)
|
||||||
{
|
{
|
||||||
|
|
|
@ -536,6 +536,8 @@
|
||||||
<None Include="Resources\AlertSounds\SH22Vaal.wav">
|
<None Include="Resources\AlertSounds\SH22Vaal.wav">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<Resource Include="Resources\Icons\redo_icon.png" />
|
||||||
|
<Resource Include="Resources\Icons\undo_icon.png" />
|
||||||
<Content Include="Resources\ItemBaseTypes.txt" />
|
<Content Include="Resources\ItemBaseTypes.txt" />
|
||||||
<Content Include="Resources\ItemClasses.txt" />
|
<Content Include="Resources\ItemClasses.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -50,7 +50,7 @@ using System.Windows;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.15")]
|
[assembly: AssemblyVersion("0.16")]
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||||
[assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")]
|
[assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")]
|
||||||
|
|
|
@ -7,7 +7,10 @@ namespace Filtration.UserControls
|
||||||
{
|
{
|
||||||
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
|
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
ScrollIntoView(e.AddedItems[0]);
|
if (e.AddedItems.Count > 0)
|
||||||
|
{
|
||||||
|
ScrollIntoView(e.AddedItems[0]);
|
||||||
|
}
|
||||||
base.OnSelectionChanged(e);
|
base.OnSelectionChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,23 +32,29 @@
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1">
|
<StackPanel Grid.Row="0" Grid.Column="1">
|
||||||
<TextBlock FontWeight="Black">Filtration</TextBlock>
|
<TextBlock FontWeight="Black">Filtration</TextBlock>
|
||||||
<TextBlock Text="{Binding Version}" />
|
<TextBlock Text="{Binding Version}" />
|
||||||
<TextBlock>Copyright © 2015</TextBlock>
|
<TextBlock>Copyright © 2017</TextBlock>
|
||||||
<TextBlock>Created by Ben Wallis</TextBlock>
|
<TextBlock>Created by Ben Wallis</TextBlock>
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
<Hyperlink NavigateUri="https://github.com/ben-wallis/Filtration/" extensions:HyperlinkExtensions.IsExternal="True">https://github.com/ben-wallis/Filtration/</Hyperlink>
|
<Hyperlink NavigateUri="https://github.com/ben-wallis/Filtration/" extensions:HyperlinkExtensions.IsExternal="True">https://github.com/ben-wallis/Filtration/</Hyperlink>
|
||||||
<LineBreak />
|
<LineBreak />
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" TextWrapping="Wrap">
|
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" TextWrapping="Wrap" Margin="0,0,20,0">
|
||||||
As you may be able to tell from the MSPaint logo that I have expertly applied a lens flare to, I am not an artist. If you'd like to create a swanky logo for Filtration please
|
As you may be able to tell from the MSPaint logo that I have expertly applied a lens flare to, I am not an artist. If you'd like to create a swanky logo for Filtration please
|
||||||
get in touch via e-mail or IRC.
|
get in touch via e-mail or IRC.
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1">
|
<StackPanel Grid.Row="0" Grid.Column="1">
|
||||||
<TextBlock FontWeight="Bold">Contact</TextBlock>
|
<StackPanel>
|
||||||
<TextBlock TextWrapping="Wrap">IRC: irc.freenode.net #filtration</TextBlock>
|
<TextBlock FontWeight="Bold">Contact</TextBlock>
|
||||||
<TextBlock TextWrapping="Wrap">E-mail: ben-wallis@users.noreply.github.com</TextBlock>
|
<TextBlock TextWrapping="Wrap">IRC: irc.freenode.net #filtration</TextBlock>
|
||||||
<TextBlock TextWrapping="Wrap">In-Game: AtomYcX</TextBlock>
|
<TextBlock TextWrapping="Wrap">E-mail: ben-wallis@users.noreply.github.com</TextBlock>
|
||||||
|
<TextBlock TextWrapping="Wrap">In-Game: AtomYcX</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock FontWeight="Bold"><LineBreak/>Special Thanks</TextBlock>
|
||||||
|
<TextBlock TextWrapping="Wrap">GlenCFL - Implemented support for the item filter 3.1 changes</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ScrollViewer Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="0,20,0,0" >
|
<ScrollViewer Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="0,20,0,0" >
|
||||||
<TextBlock TextWrapping="Wrap" FontStyle="Italic">
|
<TextBlock TextWrapping="Wrap" FontStyle="Italic">
|
||||||
|
|
|
@ -19,10 +19,8 @@
|
||||||
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
|
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
|
||||||
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
|
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
|
||||||
<KeyBinding Command="{Binding NewScriptCommand}" Modifiers="Control" Key="N" />
|
<KeyBinding Command="{Binding NewScriptCommand}" Modifiers="Control" Key="N" />
|
||||||
|
<KeyBinding Command="{Binding UndoCommand}" Modifiers="Control" Key="Z" />
|
||||||
<!-- Undo/Redo support incomplete -->
|
<KeyBinding Command="{Binding RedoCommand}" Modifiers="Control" Key="Y" />
|
||||||
<!--<KeyBinding Command="{Binding UndoCommand}" Modifiers="Control" Key="Z" />
|
|
||||||
<KeyBinding Command="{Binding RedoCommand}" Modifiers="Control" Key="Y" />-->
|
|
||||||
</fluent:RibbonWindow.InputBindings>
|
</fluent:RibbonWindow.InputBindings>
|
||||||
<utility:RoutedCommandHandlers.Commands>
|
<utility:RoutedCommandHandlers.Commands>
|
||||||
<utility:RoutedCommandHandler RoutedCommand="{StaticResource OpenScriptRoutedCommand}" Command="{Binding OpenScriptCommand}" />
|
<utility:RoutedCommandHandler RoutedCommand="{StaticResource OpenScriptRoutedCommand}" Command="{Binding OpenScriptCommand}" />
|
||||||
|
@ -89,12 +87,10 @@
|
||||||
<fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" ToolTip="Paste Style (Ctrl+Shift+V)" />
|
<fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" ToolTip="Paste Style (Ctrl+Shift+V)" />
|
||||||
<fluent:Button Header="Copy Script" Command="{Binding CopyScriptCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
|
<fluent:Button Header="Copy Script" Command="{Binding CopyScriptCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
|
||||||
</fluent:RibbonGroupBox>
|
</fluent:RibbonGroupBox>
|
||||||
|
<fluent:RibbonGroupBox Header="Undo">
|
||||||
<!-- Undo/Redo support incomplete -->
|
|
||||||
<!--<fluent:RibbonGroupBox Header="Undo">
|
|
||||||
<fluent:Button Header="Undo" Command="{Binding UndoCommand}" ToolTip="Undo" SizeDefinition="Middle" Icon="{StaticResource UndoIcon}" />
|
<fluent:Button Header="Undo" Command="{Binding UndoCommand}" ToolTip="Undo" SizeDefinition="Middle" Icon="{StaticResource UndoIcon}" />
|
||||||
<fluent:Button Header="Redo" Command="{Binding RedoCommand}" ToolTip="Redo" SizeDefinition="Middle" Icon="{StaticResource RedoIcon}" />
|
<fluent:Button Header="Redo" Command="{Binding RedoCommand}" ToolTip="Redo" SizeDefinition="Middle" Icon="{StaticResource RedoIcon}" />
|
||||||
</fluent:RibbonGroupBox>-->
|
</fluent:RibbonGroupBox>
|
||||||
<fluent:RibbonGroupBox Header="Blocks">
|
<fluent:RibbonGroupBox Header="Blocks">
|
||||||
<fluent:Button Header="Add Block" Command="{Binding AddBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource AddBlockIcon}" />
|
<fluent:Button Header="Add Block" Command="{Binding AddBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource AddBlockIcon}" />
|
||||||
<fluent:Button Header="Add Section" Command="{Binding AddSectionCommand}" SizeDefinition="Middle" Icon="{StaticResource AddSectionIcon}" />
|
<fluent:Button Header="Add Section" Command="{Binding AddSectionCommand}" SizeDefinition="Middle" Icon="{StaticResource AddSectionIcon}" />
|
||||||
|
|
Loading…
Reference in New Issue