mods loading fixes
This commit is contained in:
@@ -234,9 +234,11 @@ namespace Torch.Server.Managers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var world = DedicatedConfig.Worlds.FirstOrDefault(x => x.WorldPath == DedicatedConfig.LoadWorld) ?? new WorldViewModel(DedicatedConfig.LoadWorld);
|
var world = DedicatedConfig.SelectedWorld;
|
||||||
|
|
||||||
world.Checkpoint.SessionName = DedicatedConfig.WorldName;
|
world.Checkpoint.SessionName = string.IsNullOrEmpty(DedicatedConfig.WorldName)
|
||||||
|
? Path.GetDirectoryName(DedicatedConfig.LoadWorld)
|
||||||
|
: DedicatedConfig.WorldName;
|
||||||
world.WorldConfiguration.Settings = DedicatedConfig.SessionSettings;
|
world.WorldConfiguration.Settings = DedicatedConfig.SessionSettings;
|
||||||
world.WorldConfiguration.Mods.Clear();
|
world.WorldConfiguration.Mods.Clear();
|
||||||
|
|
||||||
@@ -268,7 +270,7 @@ namespace Torch.Server.Managers
|
|||||||
private void ValidateInstance(string path)
|
private void ValidateInstance(string path)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.Combine(path, "Saves"));
|
Directory.CreateDirectory(Path.Combine(path, "Saves"));
|
||||||
Directory.CreateDirectory(Path.Combine(path, "Mods"));
|
// Directory.CreateDirectory(Path.Combine(path, "Mods"));
|
||||||
var configPath = Path.Combine(path, CONFIG_NAME);
|
var configPath = Path.Combine(path, CONFIG_NAME);
|
||||||
if (File.Exists(configPath))
|
if (File.Exists(configPath))
|
||||||
return;
|
return;
|
||||||
|
@@ -33,6 +33,9 @@ public static class CheckpointLoadPatch
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world.KeenCheckpoint.Settings = world.WorldConfiguration.Settings;
|
||||||
|
world.KeenCheckpoint.Mods = world.WorldConfiguration.Mods;
|
||||||
|
|
||||||
__result = world.Checkpoint;
|
__result = world.Checkpoint;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -5,8 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:viewModels="clr-namespace:Torch.Server.ViewModels"
|
xmlns:viewModels="clr-namespace:Torch.Server.ViewModels"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
MouseMove="UserControl_MouseMove">
|
|
||||||
<!--<UserControl.DataContext>
|
<!--<UserControl.DataContext>
|
||||||
<viewModels:ConfigDedicatedViewModel />
|
<viewModels:ConfigDedicatedViewModel />
|
||||||
</UserControl.DataContext>-->
|
</UserControl.DataContext>-->
|
||||||
@@ -18,7 +17,7 @@
|
|||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<Style TargetType="Grid" x:Key="RootGridStyle">
|
<Style TargetType="Grid" x:Key="RootGridStyle">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding Mode=OneWay, UpdateSourceTrigger=PropertyChanged, BindingGroupName=RootEnabledBinding}" Value="{x:Null}">
|
<DataTrigger Binding="{Binding Mode=OneWay, BindingGroupName=RootEnabledBinding}" Value="{x:Null}">
|
||||||
<Setter Property="IsEnabled" Value="False"/>
|
<Setter Property="IsEnabled" Value="False"/>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
@@ -36,28 +35,25 @@
|
|||||||
<RowDefinition Height="80px"/>
|
<RowDefinition Height="80px"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<DataGrid Name="ModList" Grid.Column="0" Grid.ColumnSpan="1" ItemsSource="{Binding UpdateSourceTrigger=PropertyChanged}"
|
<DataGrid Name="ModList" Grid.Column="0" ItemsSource="{Binding Mods}"
|
||||||
Sorting="ModList_Sorting"
|
|
||||||
SelectionMode="Single"
|
SelectionMode="Single"
|
||||||
SelectionUnit="FullRow"
|
SelectionUnit="FullRow"
|
||||||
AllowDrop="True"
|
AllowDrop="True"
|
||||||
CanUserReorderColumns="False"
|
CanUserReorderColumns="False"
|
||||||
CanUserSortColumns="True"
|
CanUserSortColumns="True"
|
||||||
PreviewMouseLeftButtonDown="ModList_MouseLeftButtonDown"
|
|
||||||
MouseLeftButtonUp="ModList_MouseLeftButtonUp"
|
|
||||||
SelectedCellsChanged="ModList_Selected"
|
SelectedCellsChanged="ModList_Selected"
|
||||||
AutoGenerateColumns="False">
|
AutoGenerateColumns="False">
|
||||||
<!--:DesignSource="{d:DesignInstance Type={x:Type MyObjectBuilder_Checkpoint:ModItem, CreateList=True}}">-->
|
<!--:DesignSource="{d:DesignInstance Type={x:Type MyObjectBuilder_Checkpoint:ModItem, CreateList=True}}">-->
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Workshop Id"
|
<DataGridTextColumn Header="Workshop Id"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Binding="{Binding PublishedFileId, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}">
|
Binding="{Binding PublishedFileId}">
|
||||||
|
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="Name"
|
<DataGridTextColumn Header="Name"
|
||||||
Width="*"
|
Width="*"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Binding="{Binding FriendlyName, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}">
|
Binding="{Binding FriendlyName}">
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
<DataGrid.ItemContainerStyle>
|
<DataGrid.ItemContainerStyle>
|
||||||
@@ -78,12 +74,12 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</DataGrid.ItemContainerStyle>
|
</DataGrid.ItemContainerStyle>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<ScrollViewer Grid.Column="2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Background="#1b2838">
|
<ScrollViewer Grid.Row="0" Grid.Column="2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Background="#1b2838">
|
||||||
<TextBlock Name="ModDescription" TextWrapping="Wrap" Foreground="White" Padding="2px"
|
<TextBlock Name="ModDescription" TextWrapping="Wrap" Foreground="White" Padding="2px"
|
||||||
Text="{Binding ElementName=ModList, Path=SelectedItem.Description}">
|
Text="{Binding ElementName=ModList, Path=SelectedItem.Description}">
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
<Grid Grid.Row="2" Margin="0 0 0 6px">
|
<Grid Grid.Row="1" Grid.Column="0" Margin="0 0 0 6px">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@@ -98,10 +94,10 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<CheckBox Name="ShowDependencyModsCheckBox" VerticalAlignment="Center"
|
<CheckBox Name="ShowDependencyModsCheckBox" VerticalAlignment="Center"
|
||||||
HorizontalAlignment="Left" Margin="6px 0" Grid.Column="0" Grid.Row="0"/>
|
HorizontalAlignment="Left" Margin="6px 0" Grid.Column="0" Grid.Row="0"/>
|
||||||
<Label Content="Show Dependency Mods" Padding="0" Margin="6px 0" Grid.Column="1" VerticalAlignment="Center"/>
|
<Label Content="Show Dependency Mods" Padding="0" Margin="6px 0" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"/>
|
||||||
<Label Content="ID/URL:" Padding="0" Margin="6px 0" HorizontalAlignment="Left"
|
<Label Content="ID/URL:" Padding="0" Margin="6px 0" HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Center" Grid.Column="0" Grid.Row="1"/>
|
VerticalAlignment="Center" Grid.Column="0" Grid.Row="1"/>
|
||||||
<TextBox Name="AddModIDTextBox" Grid.Column="1" VerticalContentAlignment="Center"
|
<TextBox Name="AddModIdTextBox" Grid.Column="1" VerticalContentAlignment="Center"
|
||||||
HorizontalAlignment="Stretch" MinWidth="100px" Margin="6px 4px" Grid.Row="1"/>
|
HorizontalAlignment="Stretch" MinWidth="100px" Margin="6px 4px" Grid.Row="1"/>
|
||||||
<ComboBox Grid.Column="2" Grid.Row="1" x:Name="UgcServiceTypeBox" SelectionChanged="UgcServiceTypeBox_OnSelectionChanged" SelectedValuePath="Value" DisplayMemberPath="Key"/>
|
<ComboBox Grid.Column="2" Grid.Row="1" x:Name="UgcServiceTypeBox" SelectionChanged="UgcServiceTypeBox_OnSelectionChanged" SelectedValuePath="Value" DisplayMemberPath="Key"/>
|
||||||
<Button Content="Add" Grid.Column="3" Margin="6px 0" Width="60px" Height="40px" Click="AddBtn_OnClick" Grid.Row="1"/>
|
<Button Content="Add" Grid.Column="3" Margin="6px 0" Width="60px" Height="40px" Click="AddBtn_OnClick" Grid.Row="1"/>
|
||||||
@@ -110,6 +106,6 @@
|
|||||||
<Button Content="Bulk Edit" Grid.Column="5" Margin="6px 0" Width="60px" Height="40px" Click="BulkButton_OnClick" Grid.Row="1"/>
|
<Button Content="Bulk Edit" Grid.Column="5" Margin="6px 0" Width="60px" Height="40px" Click="BulkButton_OnClick" Grid.Row="1"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Button Content="Save Config" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="6px" Grid.Column="3" Width="80px" Height="40px" Click="SaveBtn_OnClick"/>
|
<Button Content="Save Config" Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="6px" Grid.Column="3" Width="80px" Height="40px" Click="SaveBtn_OnClick"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@@ -1,32 +1,15 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
using VRage.Game;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using Sandbox.Engine.Networking;
|
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.Server.Managers;
|
using Torch.Server.Managers;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using Torch.Server.ViewModels;
|
using Torch.Server.ViewModels;
|
||||||
using Torch.Server.Annotations;
|
|
||||||
using Torch.Collections;
|
|
||||||
using Torch.Utils;
|
using Torch.Utils;
|
||||||
using Torch.Views;
|
using Torch.Views;
|
||||||
|
|
||||||
@@ -35,14 +18,12 @@ namespace Torch.Server.Views
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for ModListControl.xaml
|
/// Interaction logic for ModListControl.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ModListControl : UserControl, INotifyPropertyChanged
|
public partial class ModListControl : UserControl
|
||||||
{
|
{
|
||||||
private static Logger Log = LogManager.GetLogger(nameof(ModListControl));
|
private static Logger Log = LogManager.GetLogger(nameof(ModListControl));
|
||||||
private InstanceManager _instanceManager;
|
private InstanceManager _instanceManager;
|
||||||
ModItemInfo _draggedMod;
|
|
||||||
bool _hasOrderChanged = false;
|
|
||||||
bool _isSortedByLoadOrder = true;
|
|
||||||
private readonly ITorchConfig _config;
|
private readonly ITorchConfig _config;
|
||||||
|
private ConfigDedicatedViewModel _viewModel;
|
||||||
|
|
||||||
//private List<BindingExpression> _bindingExpressions = new List<BindingExpression>();
|
//private List<BindingExpression> _bindingExpressions = new List<BindingExpression>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,9 +32,11 @@ namespace Torch.Server.Views
|
|||||||
public ModListControl()
|
public ModListControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
#pragma warning disable CS0618
|
||||||
_instanceManager = TorchBase.Instance.Managers.GetManager<InstanceManager>();
|
_instanceManager = TorchBase.Instance.Managers.GetManager<InstanceManager>();
|
||||||
_instanceManager.InstanceLoaded += _instanceManager_InstanceLoaded;
|
|
||||||
_config = TorchBase.Instance.Config;
|
_config = TorchBase.Instance.Config;
|
||||||
|
#pragma warning restore CS0618
|
||||||
|
_instanceManager.InstanceLoaded += _instanceManager_InstanceLoaded;
|
||||||
//var mods = _instanceManager.DedicatedConfig?.Mods;
|
//var mods = _instanceManager.DedicatedConfig?.Mods;
|
||||||
//if( mods != null)
|
//if( mods != null)
|
||||||
// DataContext = new ObservableCollection<MyObjectBuilder_Checkpoint.ModItem>();
|
// DataContext = new ObservableCollection<MyObjectBuilder_Checkpoint.ModItem>();
|
||||||
@@ -67,24 +50,14 @@ namespace Torch.Server.Views
|
|||||||
//Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(ApplyStyles));
|
//Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(ApplyStyles));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ModListControl_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ResetSorting()
|
|
||||||
{
|
|
||||||
CollectionViewSource.GetDefaultView(ModList.ItemsSource).SortDescriptions.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void _instanceManager_InstanceLoaded(ConfigDedicatedViewModel obj)
|
private void _instanceManager_InstanceLoaded(ConfigDedicatedViewModel obj)
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.InvokeAsync(() =>
|
||||||
DataContext = obj?.Mods ?? new MtObservableList<ModItemInfo>();
|
{
|
||||||
|
_viewModel = obj;
|
||||||
|
DataContext = obj;
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
((MtObservableList<ModItemInfo>)DataContext).CollectionChanged += OnModlistUpdate;
|
|
||||||
if (obj is { })
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await obj.UpdateAllModInfosAsync();
|
await obj.UpdateAllModInfosAsync();
|
||||||
@@ -93,13 +66,6 @@ namespace Torch.Server.Views
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnModlistUpdate(object sender, NotifyCollectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
ModList.Items.Refresh();
|
|
||||||
//if (e.Action == NotifyCollectionChangedAction.Remove)
|
|
||||||
// _instanceManager.SaveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
|
private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_instanceManager.SaveConfig();
|
_instanceManager.SaveConfig();
|
||||||
@@ -108,31 +74,28 @@ namespace Torch.Server.Views
|
|||||||
|
|
||||||
private void AddBtn_OnClick(object sender, RoutedEventArgs e)
|
private void AddBtn_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (TryExtractId(AddModIDTextBox.Text, out ulong id))
|
if (TryExtractId(AddModIdTextBox.Text, out ulong id))
|
||||||
{
|
{
|
||||||
var mod = new ModItemInfo(ModItemUtils.Create(id, UgcServiceTypeBox.SelectedValue?.ToString()));
|
var mod = new ModItemInfo(ModItemUtils.Create(id, UgcServiceTypeBox.SelectedValue?.ToString()));
|
||||||
|
|
||||||
_instanceManager.DedicatedConfig.Mods.Add(mod);
|
_instanceManager.DedicatedConfig.Mods.Add(mod);
|
||||||
Task.Run(mod.UpdateModInfoAsync)
|
Task.Run(mod.UpdateModInfoAsync)
|
||||||
.ContinueWith((t) =>
|
.ContinueWith(_ =>
|
||||||
{
|
|
||||||
Dispatcher.Invoke(() =>
|
|
||||||
{
|
{
|
||||||
_instanceManager.DedicatedConfig.Save();
|
_instanceManager.DedicatedConfig.Save();
|
||||||
});
|
});
|
||||||
});
|
AddModIdTextBox.Text = "";
|
||||||
AddModIDTextBox.Text = "";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModIDTextBox.BorderBrush = Brushes.Red;
|
AddModIdTextBox.BorderBrush = Brushes.Red;
|
||||||
Log.Warn("Invalid mod id!");
|
Log.Warn("Invalid mod id!");
|
||||||
MessageBox.Show("Invalid mod id!");
|
MessageBox.Show("Invalid mod id!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void RemoveBtn_OnClick(object sender, RoutedEventArgs e)
|
private void RemoveBtn_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var modList = ((MtObservableList<ModItemInfo>)DataContext);
|
var modList = _viewModel.Mods;
|
||||||
if (ModList.SelectedItem is ModItemInfo mod && modList.Contains(mod))
|
if (ModList.SelectedItem is ModItemInfo mod && modList.Contains(mod))
|
||||||
modList.Remove(mod);
|
modList.Remove(mod);
|
||||||
}
|
}
|
||||||
@@ -150,113 +113,9 @@ namespace Torch.Server.Views
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ModList_Sorting(object sender, DataGridSortingEventArgs e)
|
|
||||||
{
|
|
||||||
Log.Info($"Sorting by '{e.Column.Header}'");
|
|
||||||
if (e.Column == ModList.Columns[0])
|
|
||||||
{
|
|
||||||
var dataView = CollectionViewSource.GetDefaultView(ModList.ItemsSource);
|
|
||||||
dataView.SortDescriptions.Clear();
|
|
||||||
dataView.Refresh();
|
|
||||||
_isSortedByLoadOrder = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_isSortedByLoadOrder = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ModList_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
||||||
{
|
|
||||||
//return;
|
|
||||||
|
|
||||||
_draggedMod = (ModItemInfo) TryFindRowAtPoint((UIElement) sender, e.GetPosition(ModList))?.DataContext;
|
|
||||||
|
|
||||||
//DraggedMod = (ModItemInfo) ModList.SelectedItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DataGridRow TryFindRowAtPoint(UIElement reference, Point point)
|
|
||||||
{
|
|
||||||
var element = reference.InputHitTest(point) as DependencyObject;
|
|
||||||
if (element == null)
|
|
||||||
return null;
|
|
||||||
if (element is DataGridRow row)
|
|
||||||
return row;
|
|
||||||
else
|
|
||||||
return TryFindParent<DataGridRow>(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static T TryFindParent<T>(DependencyObject child) where T : DependencyObject
|
|
||||||
{
|
|
||||||
DependencyObject parent;
|
|
||||||
if (child == null)
|
|
||||||
return null;
|
|
||||||
if (child is ContentElement contentElement)
|
|
||||||
{
|
|
||||||
parent = ContentOperations.GetParent(contentElement);
|
|
||||||
if (parent == null && child is FrameworkContentElement fce)
|
|
||||||
parent = fce.Parent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parent = VisualTreeHelper.GetParent(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent is T result)
|
|
||||||
return result;
|
|
||||||
else
|
|
||||||
return TryFindParent<T>(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UserControl_MouseMove(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (_draggedMod == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_isSortedByLoadOrder)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var targetMod = (ModItemInfo)TryFindRowAtPoint((UIElement)sender, e.GetPosition(ModList))?.DataContext;
|
|
||||||
if( targetMod != null && !ReferenceEquals(_draggedMod, targetMod))
|
|
||||||
{
|
|
||||||
_hasOrderChanged = true;
|
|
||||||
var modList = (MtObservableList<ModItemInfo>)DataContext;
|
|
||||||
modList.Move(modList.IndexOf(targetMod), _draggedMod);
|
|
||||||
//modList.RemoveAt(modList.IndexOf(_draggedMod));
|
|
||||||
//modList.Insert(modList.IndexOf(targetMod), _draggedMod);
|
|
||||||
ModList.Items.Refresh();
|
|
||||||
ModList.SelectedItem = _draggedMod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ModList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
||||||
{
|
|
||||||
if (!_isSortedByLoadOrder)
|
|
||||||
{
|
|
||||||
var targetMod = (ModItemInfo)TryFindRowAtPoint((UIElement)sender, e.GetPosition(ModList))?.DataContext;
|
|
||||||
if (targetMod != null && !ReferenceEquals(_draggedMod, targetMod))
|
|
||||||
{
|
|
||||||
var msg = "Drag and drop is only available when sorted by load order!";
|
|
||||||
Log.Warn(msg);
|
|
||||||
MessageBox.Show(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if (DraggedMod != null && HasOrderChanged)
|
|
||||||
//Log.Info("Dragging over, saving...");
|
|
||||||
//_instanceManager.SaveConfig();
|
|
||||||
_draggedMod = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
|
||||||
[NotifyPropertyChangedInvocator]
|
|
||||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
||||||
{
|
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ModList_Selected(object sender, SelectedCellsChangedEventArgs e)
|
private void ModList_Selected(object sender, SelectedCellsChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_draggedMod != null)
|
if( e.AddedCells.Count > 0)
|
||||||
ModList.SelectedItem = _draggedMod;
|
|
||||||
else if( e.AddedCells.Count > 0)
|
|
||||||
ModList.SelectedItem = e.AddedCells[0].Item;
|
ModList.SelectedItem = e.AddedCells[0].Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +124,7 @@ namespace Torch.Server.Views
|
|||||||
var editor = new CollectionEditor();
|
var editor = new CollectionEditor();
|
||||||
|
|
||||||
//let's see just how poorly we can do this
|
//let's see just how poorly we can do this
|
||||||
var modList = ((MtObservableList<ModItemInfo>)DataContext).ToList();
|
var modList = _viewModel.Mods.ToList();
|
||||||
var idList = modList.Select(m => m.ToString()).ToList();
|
var idList = modList.Select(m => m.ToString()).ToList();
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
//blocking
|
//blocking
|
||||||
|
Reference in New Issue
Block a user