Skip to content

Commit

Permalink
Fix #30
Browse files Browse the repository at this point in the history
  • Loading branch information
bcssov committed Apr 19, 2020
1 parent 38ead94 commit b1cc721
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
27 changes: 26 additions & 1 deletion src/IronyModManager/ViewModels/MainConflictSolverViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 03-18-2020
//
// Last Modified By : Mario
// Last Modified On : 04-18-2020
// Last Modified On : 04-19-2020
// ***********************************************************************
// <copyright file="MainConflictSolverViewModel.cs" company="Mario">
// Mario
Expand Down Expand Up @@ -171,6 +171,12 @@ public MainConflictSolverControlViewModel(IModService modService, ILocalizationM
/// <value>The mod compare selector.</value>
public virtual ModCompareSelectorControlViewModel ModCompareSelector { get; protected set; }

/// <summary>
/// Gets or sets the index of the previous conflict.
/// </summary>
/// <value>The index of the previous conflict.</value>
public virtual int? PreviousConflictIndex { get; set; }

/// <summary>
/// Gets or sets the resolve.
/// </summary>
Expand Down Expand Up @@ -234,6 +240,8 @@ public void Reset()
/// <param name="conflictResult">The conflict result.</param>
protected virtual void FilterHierarchalConflicts(IConflictResult conflictResult)
{
var index = PreviousConflictIndex;
PreviousConflictIndex = null;
if (conflictResult != null && conflictResult.Conflicts != null)
{
var conflicts = conflictResult.Conflicts.GetHierarchicalDefinitions().ToHashSet();
Expand Down Expand Up @@ -265,6 +273,21 @@ protected virtual void FilterHierarchalConflicts(IConflictResult conflictResult)
conflicts.RemoveWhere(p => p.Children == null || p.Children.Count == 0);
}
HierarchalConflicts = conflicts.ToObservableCollection();
if (SelectedParentConflict != null)
{
var conflictName = SelectedParentConflict.Name;
SelectedParentConflict = null;
var newSelected = HierarchalConflicts.FirstOrDefault(p => p.Name.Equals(conflictName));
if (newSelected != null)
{
PreviousConflictIndex = index;
if (PreviousConflictIndex.GetValueOrDefault() > (newSelected.Children.Count - 1))
{
PreviousConflictIndex = newSelected.Children.Count - 1;
}
SelectedParentConflict = newSelected;
}
}
}
else
{
Expand Down Expand Up @@ -308,6 +331,7 @@ protected override void OnActivated(CompositeDisposable disposables)
{
if (Conflicts?.Conflicts != null && !string.IsNullOrWhiteSpace(s?.Key))
{
PreviousConflictIndex = SelectedParentConflict.Children.ToList().IndexOf(s);
var conflicts = Conflicts.Conflicts.GetByTypeAndId(s.Key).ToObservableCollection();
ModCompareSelector.CollectionName = SelectedModCollection.Name;
ModCompareSelector.IsBinaryConflict = IsBinaryConflict = conflicts?.FirstOrDefault()?.ValueType == Parser.Common.ValueType.Binary;
Expand All @@ -319,6 +343,7 @@ protected override void OnActivated(CompositeDisposable disposables)
}
else
{
PreviousConflictIndex = null;
IgnoreEnabled = false;
}
}).DisposeWith(disposables);
Expand Down
17 changes: 14 additions & 3 deletions src/IronyModManager/Views/MainConflictSolverControlView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
// Created : 03-18-2020
//
// Last Modified By : Mario
// Last Modified On : 04-18-2020
// Last Modified On : 04-19-2020
// ***********************************************************************
// <copyright file="MainConflictSolverControlView.xaml.cs" company="Mario">
// Mario
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Linq;

using System;
using System.Linq;
using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
Expand Down Expand Up @@ -65,7 +66,17 @@ protected override void OnActivated(CompositeDisposable disposables)
};
this.WhenAnyValue(v => v.ViewModel.SelectedParentConflict).Subscribe(s =>
{
conflictList.SelectedIndex = 0;
if (s?.Children.Count > 0)
{
if (ViewModel.PreviousConflictIndex.HasValue)
{
conflictList.SelectedIndex = ViewModel.PreviousConflictIndex.GetValueOrDefault();
}
else
{
conflictList.SelectedIndex = 0;
}
}
}).DisposeWith(disposables);
base.OnActivated(disposables);
}
Expand Down

0 comments on commit b1cc721

Please sign in to comment.