Compare commits
6 Commits
LootExplos
...
0.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58de6f06b9 | ||
|
|
af2dace29a | ||
|
|
59cf604430 | ||
|
|
93a51e7829 | ||
|
|
9d928a374a | ||
|
|
b5788504cb |
@@ -353,6 +353,39 @@ namespace Filtration.Tests.Translators
|
|||||||
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateStringToItemFilterScript_DisabledBlockWithBlockGroup_ReturnsCorrectBlock()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputScript = "Show" + Environment.NewLine +
|
||||||
|
" ItemLevel > 2" + Environment.NewLine +
|
||||||
|
" SetTextColor 255 40 0" + Environment.NewLine +
|
||||||
|
Environment.NewLine +
|
||||||
|
"#Disabled Block Start" + Environment.NewLine +
|
||||||
|
"# This is a disabled block" + Environment.NewLine +
|
||||||
|
"#Show#My Block Group" + Environment.NewLine +
|
||||||
|
"# ItemLevel > 2" + Environment.NewLine +
|
||||||
|
"#Disabled Block End";
|
||||||
|
|
||||||
|
|
||||||
|
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||||
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(
|
||||||
|
b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()))
|
||||||
|
.Returns(new ItemFilterBlockGroup("My Block Group", null));
|
||||||
|
|
||||||
|
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||||
|
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
|
||||||
|
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||||
|
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||||
|
Assert.AreEqual("My Block Group", secondBlock.BlockGroup.GroupName);
|
||||||
|
}
|
||||||
|
|
||||||
private class ItemFilterScriptTranslatorTestUtility
|
private class ItemFilterScriptTranslatorTestUtility
|
||||||
{
|
{
|
||||||
public ItemFilterScriptTranslatorTestUtility()
|
public ItemFilterScriptTranslatorTestUtility()
|
||||||
|
|||||||
@@ -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.6.*")]
|
[assembly: AssemblyVersion("0.8.*")]
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||||
@@ -34,4 +34,5 @@ Fishing Rods
|
|||||||
Map Fragments
|
Map Fragments
|
||||||
Hideout Doodads
|
Hideout Doodads
|
||||||
Microtransactions
|
Microtransactions
|
||||||
Divination Card
|
Divination Card
|
||||||
|
Jewel
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
using Filtration.Common.Services;
|
using Filtration.Common.Services;
|
||||||
using Filtration.Utilities;
|
using Filtration.Utilities;
|
||||||
|
|
||||||
@@ -28,10 +30,10 @@ namespace Filtration.Services
|
|||||||
|
|
||||||
private void PopulateStaticData()
|
private void PopulateStaticData()
|
||||||
{
|
{
|
||||||
var itemBaseTypes = _fileSystemService.ReadFileAsString("Resources\\ItemBaseTypes.txt");
|
var itemBaseTypes = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemBaseTypes.txt");
|
||||||
ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList();
|
ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList();
|
||||||
|
|
||||||
var itemClasses = _fileSystemService.ReadFileAsString("Resources\\ItemClasses.txt");
|
var itemClasses = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemClasses.txt");
|
||||||
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
|
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace Filtration.Translators
|
|||||||
}
|
}
|
||||||
|
|
||||||
lines[i] = lines[i].TrimStart('#');
|
lines[i] = lines[i].TrimStart('#');
|
||||||
|
lines[i] = lines[i].Replace("#", " # ");
|
||||||
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
|
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
|
||||||
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,19 @@ namespace Filtration.ViewModels
|
|||||||
{
|
{
|
||||||
_activeDocument = null;
|
_activeDocument = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Replace _activeScriptViewModel and _activeThemeViewModel with a better solution.
|
||||||
|
|
||||||
|
if (document.IsScript && _activeScriptViewModel == (IItemFilterScriptViewModel) document)
|
||||||
|
{
|
||||||
|
_activeScriptViewModel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.IsTheme && _activeThemeViewModel == (IThemeEditorViewModel)document)
|
||||||
|
{
|
||||||
|
_activeThemeViewModel = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SwitchActiveDocument(IDocument document)
|
public void SwitchActiveDocument(IDocument document)
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ namespace Filtration.ViewModels
|
|||||||
private readonly IUpdateCheckService _updateCheckService;
|
private readonly IUpdateCheckService _updateCheckService;
|
||||||
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
||||||
private readonly IMessageBoxService _messageBoxService;
|
private readonly IMessageBoxService _messageBoxService;
|
||||||
private bool _activeDocumentIsScript;
|
|
||||||
private bool _activeDocumentIsTheme;
|
|
||||||
|
|
||||||
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
||||||
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
||||||
@@ -75,51 +73,51 @@ namespace Filtration.ViewModels
|
|||||||
_messageBoxService = messageBoxService;
|
_messageBoxService = messageBoxService;
|
||||||
|
|
||||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => _activeDocumentIsScript);
|
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
|
||||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||||
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
||||||
|
|
||||||
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
|
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
|
||||||
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
||||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
CloseCommand = new RelayCommand(OnCloseDocumentCommand, ActiveDocumentIsEditable);
|
||||||
|
|
||||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
PasteCommand = new RelayCommand(OnPasteCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
|
|
||||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
|
|
||||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
|
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
||||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
|
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
||||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
|
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
|
||||||
() => _activeDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
() => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
|
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
|
||||||
() => _activeDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
() => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => _activeDocumentIsScript);
|
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
||||||
|
|
||||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => _activeDocumentIsScript);
|
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript);
|
||||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => _activeDocumentIsScript);
|
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript);
|
||||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => _activeDocumentIsScript);
|
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);
|
||||||
|
|
||||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
||||||
() =>
|
() =>
|
||||||
ActiveDocumentIsTheme && _activeDocumentIsTheme &&
|
ActiveDocumentIsTheme && ActiveDocumentIsTheme &&
|
||||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||||
|
|
||||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => _activeDocumentIsScript);
|
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => _activeDocumentIsScript);
|
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||||
|
|
||||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => _activeDocumentIsScript);
|
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
|
||||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => _activeDocumentIsScript);
|
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
|
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
|
||||||
{
|
{
|
||||||
@@ -154,7 +152,8 @@ namespace Filtration.ViewModels
|
|||||||
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
||||||
EditMasterThemeCommand.RaiseCanExecuteChanged();
|
EditMasterThemeCommand.RaiseCanExecuteChanged();
|
||||||
CreateThemeCommand.RaiseCanExecuteChanged();
|
CreateThemeCommand.RaiseCanExecuteChanged();
|
||||||
SetActiveDocumentStatusProperties();
|
RaisePropertyChanged("ActiveDocumentIsScript");
|
||||||
|
RaisePropertyChanged("ActiveDocumentIsTheme");
|
||||||
RaisePropertyChanged("ShowAdvancedStatus");
|
RaisePropertyChanged("ShowAdvancedStatus");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -171,8 +170,6 @@ namespace Filtration.ViewModels
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
CheckForUpdates();
|
CheckForUpdates();
|
||||||
ActiveDocumentIsScript = false;
|
|
||||||
ActiveDocumentIsTheme = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand OpenScriptCommand { get; private set; }
|
public RelayCommand OpenScriptCommand { get; private set; }
|
||||||
@@ -280,30 +277,14 @@ namespace Filtration.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetActiveDocumentStatusProperties()
|
|
||||||
{
|
|
||||||
ActiveDocumentIsScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
|
|
||||||
ActiveDocumentIsTheme = AvalonDockWorkspaceViewModel.ActiveDocument is ThemeEditorViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ActiveDocumentIsScript
|
public bool ActiveDocumentIsScript
|
||||||
{
|
{
|
||||||
get { return _activeDocumentIsScript; }
|
get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; }
|
||||||
private set
|
|
||||||
{
|
|
||||||
_activeDocumentIsScript = value;
|
|
||||||
RaisePropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ActiveDocumentIsTheme
|
public bool ActiveDocumentIsTheme
|
||||||
{
|
{
|
||||||
get { return _activeDocumentIsTheme; }
|
get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; }
|
||||||
private set
|
|
||||||
{
|
|
||||||
_activeDocumentIsTheme = value;
|
|
||||||
RaisePropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ActiveScriptHasSelectedBlock
|
public bool ActiveScriptHasSelectedBlock
|
||||||
|
|||||||
Reference in New Issue
Block a user