Skip to content

Commit

Permalink
Fix adding new orders clearing a previous new order's name
Browse files Browse the repository at this point in the history
Also added a new observable property for the current order's name, for extra safety
  • Loading branch information
LaughingLeader committed Jun 12, 2023
1 parent fe77d94 commit 6e77329
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion GUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
LostFocus="OrdersComboBox_LostFocus"
SelectedIndex="{Binding SelectedModOrderIndex}"
Tag="{Binding}"
Text="{Binding SelectedModOrder.Name, Mode=TwoWay}">
Text="{Binding SelectedModOrderName, Mode=OneWay}">
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<EventSetter Event="ComboBoxItem.PreviewMouseDown" Handler="OrderComboBox_OnUserClick" />
Expand Down
4 changes: 4 additions & 0 deletions GUI/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ public int SelectedAdventureModIndex
private readonly ObservableAsPropertyHelper<DivinityLoadOrder> _selectedModOrder;
public DivinityLoadOrder SelectedModOrder => _selectedModOrder.Value;

private readonly ObservableAsPropertyHelper<string> _selectedModOrderName;
public string SelectedModOrderName => _selectedModOrderName.Value;

private readonly ObservableAsPropertyHelper<bool> _isBaseLoadOrder;
public bool IsBaseLoadOrder => _isBaseLoadOrder.Value;

Expand Down Expand Up @@ -4637,6 +4640,7 @@ void toggleUpdatesView()

_selectedModOrder = this.WhenAnyValue(x => x.SelectedModOrderIndex, x => x.ModOrderList.Count).
Select(x => ModOrderList.ElementAtOrDefault(x.Item1)).ToProperty(this, nameof(SelectedModOrder));
_selectedModOrderName = this.WhenAnyValue(x => x.SelectedModOrder).WhereNotNull().Select(x => x.Name).ToProperty(this, nameof(SelectedModOrderName), true, RxApp.MainThreadScheduler);
_isBaseLoadOrder = this.WhenAnyValue(x => x.SelectedModOrder).Select(x => x != null && x.IsModSettings).ToProperty(this, nameof(IsBaseLoadOrder), true, RxApp.MainThreadScheduler);

//Throttle in case the index changes quickly in a short timespan
Expand Down

0 comments on commit 6e77329

Please sign in to comment.