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);
|
||||
}
|
||||
|
||||
[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
|
||||
{
|
||||
public ItemFilterScriptTranslatorTestUtility()
|
||||
|
||||
@@ -50,7 +50,7 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.*")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
@@ -35,3 +35,4 @@ Map Fragments
|
||||
Hideout Doodads
|
||||
Microtransactions
|
||||
Divination Card
|
||||
Jewel
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Utilities;
|
||||
|
||||
@@ -28,10 +30,10 @@ namespace Filtration.Services
|
||||
|
||||
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();
|
||||
|
||||
var itemClasses = _fileSystemService.ReadFileAsString("Resources\\ItemClasses.txt");
|
||||
var itemClasses = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemClasses.txt");
|
||||
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace Filtration.Translators
|
||||
}
|
||||
|
||||
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 lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
||||
|
||||
|
||||
@@ -171,6 +171,19 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
_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)
|
||||
|
||||
@@ -49,8 +49,6 @@ namespace Filtration.ViewModels
|
||||
private readonly IUpdateCheckService _updateCheckService;
|
||||
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private bool _activeDocumentIsScript;
|
||||
private bool _activeDocumentIsTheme;
|
||||
|
||||
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
||||
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
||||
@@ -75,51 +73,51 @@ namespace Filtration.ViewModels
|
||||
_messageBoxService = messageBoxService;
|
||||
|
||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => _activeDocumentIsScript);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
|
||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
||||
|
||||
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
|
||||
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, ActiveDocumentIsEditable);
|
||||
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
|
||||
() => _activeDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
|
||||
() => _activeDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => _activeDocumentIsScript);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => _activeDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => _activeDocumentIsScript);
|
||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => _activeDocumentIsScript);
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript);
|
||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
||||
() =>
|
||||
ActiveDocumentIsTheme && _activeDocumentIsTheme &&
|
||||
ActiveDocumentIsTheme && ActiveDocumentIsTheme &&
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => _activeDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => _activeDocumentIsScript);
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => _activeDocumentIsScript);
|
||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => _activeDocumentIsScript);
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
|
||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
|
||||
{
|
||||
@@ -154,7 +152,8 @@ namespace Filtration.ViewModels
|
||||
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
||||
EditMasterThemeCommand.RaiseCanExecuteChanged();
|
||||
CreateThemeCommand.RaiseCanExecuteChanged();
|
||||
SetActiveDocumentStatusProperties();
|
||||
RaisePropertyChanged("ActiveDocumentIsScript");
|
||||
RaisePropertyChanged("ActiveDocumentIsTheme");
|
||||
RaisePropertyChanged("ShowAdvancedStatus");
|
||||
break;
|
||||
}
|
||||
@@ -171,8 +170,6 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
});
|
||||
CheckForUpdates();
|
||||
ActiveDocumentIsScript = false;
|
||||
ActiveDocumentIsTheme = false;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
get { return _activeDocumentIsScript; }
|
||||
private set
|
||||
{
|
||||
_activeDocumentIsScript = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; }
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsTheme
|
||||
{
|
||||
get { return _activeDocumentIsTheme; }
|
||||
private set
|
||||
{
|
||||
_activeDocumentIsTheme = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; }
|
||||
}
|
||||
|
||||
public bool ActiveScriptHasSelectedBlock
|
||||
|
||||
Reference in New Issue
Block a user