net6 things
This commit is contained in:
@@ -11,19 +11,17 @@ namespace Torch.Server.ViewModels
|
||||
public class BlockLimitViewModel : ViewModel
|
||||
{
|
||||
private SessionSettingsViewModel _sessionSettings;
|
||||
private string _blockType;
|
||||
private short _limit;
|
||||
|
||||
public string BlockType { get => _blockType; set { _blockType = value; OnPropertyChanged(); } }
|
||||
public short Limit { get => _limit; set { _limit = value; OnPropertyChanged(); } }
|
||||
public string BlockType { get; set; }
|
||||
public short Limit { get; set; }
|
||||
|
||||
//public CommandBinding Delete { get; } = new CommandBinding(new DeleteCommand());
|
||||
|
||||
public BlockLimitViewModel(SessionSettingsViewModel sessionSettings, string blockType, short limit)
|
||||
{
|
||||
_sessionSettings = sessionSettings;
|
||||
_blockType = blockType;
|
||||
_limit = limit;
|
||||
BlockType = blockType;
|
||||
Limit = limit;
|
||||
}
|
||||
|
||||
/* TODO: figure out how WPF commands work
|
||||
|
@@ -15,7 +15,7 @@ namespace Torch.Server.ViewModels
|
||||
{
|
||||
public class CheckpointViewModel : ViewModel
|
||||
{
|
||||
private MyObjectBuilder_Checkpoint _checkpoint;
|
||||
private readonly MyObjectBuilder_Checkpoint _checkpoint;
|
||||
//private SessionSettingsViewModel _sessionSettings;
|
||||
|
||||
public CheckpointViewModel(MyObjectBuilder_Checkpoint checkpoint)
|
||||
|
@@ -1,17 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Utils;
|
||||
using Torch.Collections;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Utils;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ModAPI;
|
||||
using Torch.Utils.SteamWorkshopTools;
|
||||
using Torch.Collections;
|
||||
using VRage.GameServices;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
@@ -76,42 +73,30 @@ namespace Torch.Server.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAllModInfosAsync(Action<string> messageHandler = null)
|
||||
public async Task UpdateAllModInfosAsync()
|
||||
{
|
||||
if (Mods.Count() == 0)
|
||||
/*if (!Mods.Any())
|
||||
return;
|
||||
|
||||
var ids = Mods.Select(m => m.PublishedFileId);
|
||||
var workshopService = WebAPI.Instance;
|
||||
Dictionary<ulong, PublishedItemDetails> modInfos = null;
|
||||
|
||||
List<MyWorkshopItem> modInfos;
|
||||
try
|
||||
{
|
||||
modInfos = (await workshopService.GetPublishedFileDetails(ids.ToArray()));
|
||||
modInfos = await WorkshopQueryUtils.GetModsInfo(Mods.Select(b =>
|
||||
new MyObjectBuilder_Checkpoint.ModItem(b.PublishedFileId, b.UgcService, b.IsDependency)));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
Log.Error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Info($"Mods Info successfully retrieved!");
|
||||
Log.Info("Mods Info successfully retrieved!");
|
||||
|
||||
foreach (var mod in Mods)
|
||||
foreach (var modItem in Mods
|
||||
.Select(b => new MyObjectBuilder_Checkpoint.ModItem(b.PublishedFileId, b.UgcService))
|
||||
.Except(modInfos.Select(b => new MyObjectBuilder_Checkpoint.ModItem(b.Id, b.ServiceName))))
|
||||
{
|
||||
if (!modInfos.ContainsKey(mod.PublishedFileId) || modInfos[mod.PublishedFileId] == null)
|
||||
{
|
||||
Log.Error($"Failed to retrieve info for mod with workshop id '{mod.PublishedFileId}'!");
|
||||
}
|
||||
//else if (!modInfo.Tags.Contains(""))
|
||||
else
|
||||
{
|
||||
mod.FriendlyName = modInfos[mod.PublishedFileId].Title;
|
||||
mod.Description = modInfos[mod.PublishedFileId].Description;
|
||||
//mod.Name = modInfos[mod.PublishedFileId].FileName;
|
||||
}
|
||||
}
|
||||
|
||||
Log.Error($"Unable to retreive info about {modItem.PublishedFileId}:{modItem.PublishedServiceName}");
|
||||
}*/
|
||||
}
|
||||
|
||||
public List<string> Administrators { get => _config.Administrators; set => SetValue(x => _config.Administrators = x, value); }
|
||||
|
@@ -25,7 +25,9 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
get => Block?.CustomName ?? "null";
|
||||
set
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
Block.CustomName = value;
|
||||
OnPropertyChanged();
|
||||
@@ -41,7 +43,9 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
get => ((MySlimBlock)Block?.SlimBlock)?.BuiltBy ?? 0;
|
||||
set
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
((MySlimBlock)Block.SlimBlock).TransferAuthorship(value);
|
||||
OnPropertyChanged();
|
||||
|
@@ -3,18 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using NLog;
|
||||
using Sandbox.Game.Entities.Cube;
|
||||
using Sandbox.ModAPI;
|
||||
using Sandbox.ModAPI.Interfaces;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using NLog;
|
||||
using Sandbox.ModAPI.Interfaces.Terminal;
|
||||
|
||||
namespace Torch.Server.ViewModels.Blocks
|
||||
namespace Torch.Server.ViewModels.Entities.Blocks
|
||||
{
|
||||
public static class BlockViewModelGenerator
|
||||
{
|
||||
@@ -27,8 +21,8 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
static BlockViewModelGenerator()
|
||||
{
|
||||
_asmName = new AssemblyName("Torch.Server.ViewModels.Generated");
|
||||
_ab = AppDomain.CurrentDomain.DefineDynamicAssembly(_asmName, AssemblyBuilderAccess.RunAndSave);
|
||||
_mb = _ab.DefineDynamicModule(_asmName.Name);
|
||||
_ab = AssemblyBuilder.DefineDynamicAssembly(_asmName, AssemblyBuilderAccess.RunAndCollect);
|
||||
_mb = _ab.DefineDynamicModule(_asmName.Name ?? "Torch.Server.ViewModels.Generated");
|
||||
}
|
||||
|
||||
public static void GenerateModels()
|
||||
@@ -40,7 +34,6 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
GenerateModel(type);
|
||||
}
|
||||
}
|
||||
_ab.Save("Generated.dll", PortableExecutableKinds.ILOnly, ImageFileMachine.AMD64);
|
||||
}
|
||||
|
||||
public static Type GenerateModel(Type blockType, bool force = false)
|
||||
|
@@ -19,7 +19,9 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
get => _prop.GetValue(Block.Block);
|
||||
set
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
_prop.SetValue(Block.Block, value);
|
||||
OnPropertyChanged();
|
||||
|
@@ -18,21 +18,9 @@ namespace Torch.Server.ViewModels.Entities
|
||||
OnPropertyChanged(SignalPropertyInvalidateControl);
|
||||
}
|
||||
|
||||
private bool _hide;
|
||||
|
||||
/// <summary>
|
||||
/// Should this element be forced into the <see cref="Visibility.Collapsed"/>
|
||||
/// </summary>
|
||||
public bool Hide
|
||||
{
|
||||
get => _hide;
|
||||
protected set
|
||||
{
|
||||
if (_hide == value)
|
||||
return;
|
||||
_hide = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public bool Hide { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
protected EntityTreeViewModel Tree { get; }
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private static Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IMyEntity _backing;
|
||||
public IMyEntity Entity
|
||||
@@ -30,7 +30,9 @@ namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
_backing = value;
|
||||
OnPropertyChanged();
|
||||
#pragma warning disable CS0618
|
||||
EntityControls = TorchBase.Instance?.Managers.GetManager<EntityControlManager>()?.BoundModels(this);
|
||||
#pragma warning restore CS0618
|
||||
// ReSharper disable once ExplicitCallerInfoArgument
|
||||
OnPropertyChanged(nameof(EntityControls));
|
||||
}
|
||||
@@ -46,7 +48,9 @@ namespace Torch.Server.ViewModels.Entities
|
||||
set
|
||||
{
|
||||
if (Entity!=null)
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.DisplayName = value);
|
||||
#pragma warning restore CS0618
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -54,7 +58,7 @@ namespace Torch.Server.ViewModels.Entities
|
||||
private string _descriptiveName;
|
||||
public string DescriptiveName
|
||||
{
|
||||
get => _descriptiveName ?? (_descriptiveName = GetSortedName(EntityTreeViewModel.SortEnum.Name));
|
||||
get => _descriptiveName ??= GetSortedName(EntityTreeViewModel.SortEnum.Name);
|
||||
set => _descriptiveName = value;
|
||||
}
|
||||
|
||||
@@ -140,7 +144,9 @@ namespace Torch.Server.ViewModels.Entities
|
||||
return;
|
||||
|
||||
if (Entity != null)
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.SetPosition(v));
|
||||
#pragma warning restore CS0618
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -176,7 +182,7 @@ namespace Torch.Server.ViewModels.Entities
|
||||
|
||||
public int Compare(EntityViewModel x, EntityViewModel y)
|
||||
{
|
||||
return x.CompareToSort(y, _sort);
|
||||
return x?.CompareToSort(y, _sort) ?? default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -101,7 +101,9 @@ namespace Torch.Server.ViewModels.Entities
|
||||
return;
|
||||
|
||||
_load = true;
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
Blocks.Clear();
|
||||
foreach (var block in Grid.GetFatBlocks().OfType<MyTerminalBlock>())
|
||||
|
@@ -18,12 +18,12 @@ namespace Torch.Server.ViewModels.Entities
|
||||
|
||||
public MtObservableList<GridViewModel> AttachedGrids { get; } = new MtObservableList<GridViewModel>();
|
||||
|
||||
public async Task UpdateAttachedGrids()
|
||||
public Task UpdateAttachedGrids()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
//TODO: fix
|
||||
return;
|
||||
|
||||
AttachedGrids.Clear();
|
||||
/*AttachedGrids.Clear();
|
||||
var box = Entity.WorldAABB;
|
||||
var entities = new List<MyEntity>();
|
||||
await TorchBase.Instance.InvokeAsync(() => MyEntities.GetTopMostEntitiesInBox(ref box, entities)).ConfigureAwait(false);
|
||||
@@ -36,7 +36,7 @@ namespace Torch.Server.ViewModels.Entities
|
||||
}
|
||||
|
||||
AttachedGrids.Add(gridModel);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public VoxelMapViewModel(MyVoxelBase e, EntityTreeViewModel tree) : base(e, tree)
|
||||
|
@@ -41,21 +41,11 @@ namespace Torch.Server.ViewModels
|
||||
public SortedView<EntityViewModel> SortedFloatingObjects { get; }
|
||||
public SortedView<VoxelMapViewModel> SortedVoxelMaps { get; }
|
||||
|
||||
private EntityViewModel _currentEntity;
|
||||
private SortEnum _currentSort;
|
||||
private UserControl _control;
|
||||
|
||||
public EntityViewModel CurrentEntity
|
||||
{
|
||||
get => _currentEntity;
|
||||
set { _currentEntity = value; OnPropertyChanged(nameof(CurrentEntity)); }
|
||||
}
|
||||
public EntityViewModel CurrentEntity { get; set; }
|
||||
|
||||
public SortEnum CurrentSort
|
||||
{
|
||||
get => _currentSort;
|
||||
set => SetValue(ref _currentSort, value);
|
||||
}
|
||||
public SortEnum CurrentSort { get; set; }
|
||||
|
||||
// I hate you today WPF
|
||||
public EntityTreeViewModel() : this(null)
|
||||
@@ -65,7 +55,7 @@ namespace Torch.Server.ViewModels
|
||||
public EntityTreeViewModel(UserControl control)
|
||||
{
|
||||
_control = control;
|
||||
var comparer = new EntityViewModel.Comparer(_currentSort);
|
||||
var comparer = new EntityViewModel.Comparer(CurrentSort);
|
||||
SortedGrids = new SortedView<GridViewModel>(Grids.Values, comparer);
|
||||
SortedCharacters = new SortedView<CharacterViewModel>(Characters.Values, comparer);
|
||||
SortedFloatingObjects = new SortedView<EntityViewModel>(FloatingObjects.Values, comparer);
|
||||
|
@@ -1,17 +1,9 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
using System.Runtime.CompilerServices;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Networking;
|
||||
using VRage.Game;
|
||||
using Torch.Server.Annotations;
|
||||
using Torch.Utils;
|
||||
using Torch.Utils.SteamWorkshopTools;
|
||||
using VRage.GameServices;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
@@ -30,10 +22,8 @@ namespace Torch.Server.ViewModels
|
||||
/// </summary>
|
||||
public string FriendlyName
|
||||
{
|
||||
get { return _modItem.FriendlyName; }
|
||||
set {
|
||||
SetValue(ref _modItem.FriendlyName, value);
|
||||
}
|
||||
get => _modItem.FriendlyName;
|
||||
set => SetValue(ref _modItem.FriendlyName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,11 +31,8 @@ namespace Torch.Server.ViewModels
|
||||
/// </summary>
|
||||
public ulong PublishedFileId
|
||||
{
|
||||
get { return _modItem.PublishedFileId; }
|
||||
set
|
||||
{
|
||||
SetValue(ref _modItem.PublishedFileId, value);
|
||||
}
|
||||
get => _modItem.PublishedFileId;
|
||||
set => SetValue(ref _modItem.PublishedFileId, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,11 +40,8 @@ namespace Torch.Server.ViewModels
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _modItem.Name; }
|
||||
set
|
||||
{
|
||||
SetValue(ref _modItem.FriendlyName, value);
|
||||
}
|
||||
get => _modItem.Name;
|
||||
set => SetValue(ref _modItem.FriendlyName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,11 +50,8 @@ namespace Torch.Server.ViewModels
|
||||
/// </summary>
|
||||
public bool IsDependency
|
||||
{
|
||||
get { return _modItem.IsDependency; }
|
||||
set
|
||||
{
|
||||
SetValue(ref _modItem.IsDependency, value);
|
||||
}
|
||||
get => _modItem.IsDependency;
|
||||
set => SetValue(ref _modItem.IsDependency, value);
|
||||
}
|
||||
|
||||
private string _description;
|
||||
@@ -79,20 +60,14 @@ namespace Torch.Server.ViewModels
|
||||
/// </summary>
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
set
|
||||
{
|
||||
SetValue(ref _description, value);
|
||||
}
|
||||
get => _description;
|
||||
set => SetValue(ref _description, value);
|
||||
}
|
||||
|
||||
public string UgcService
|
||||
{
|
||||
get { return _modItem.PublishedServiceName; }
|
||||
set
|
||||
{
|
||||
SetValue(ref _modItem.PublishedServiceName, value);
|
||||
}
|
||||
get => _modItem.PublishedServiceName;
|
||||
set => SetValue(ref _modItem.PublishedServiceName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -112,34 +87,24 @@ namespace Torch.Server.ViewModels
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateModInfoAsync()
|
||||
{
|
||||
if (UgcService.ToLower() == "mod.io")
|
||||
/*if (UgcService.ToLower() == "mod.io")
|
||||
return true;
|
||||
|
||||
var msg = "";
|
||||
var workshopService = WebAPI.Instance;
|
||||
PublishedItemDetails modInfo = null;
|
||||
|
||||
MyWorkshopItem modInfo;
|
||||
try
|
||||
{
|
||||
modInfo = (await workshopService.GetPublishedFileDetails(new ulong[] { PublishedFileId }))?[PublishedFileId];
|
||||
modInfo = await WorkshopQueryUtils.GetModInfo(_modItem);
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
}
|
||||
if (modInfo == null)
|
||||
{
|
||||
Log.Error($"Failed to retrieve mod with workshop id '{PublishedFileId}'!");
|
||||
Log.Error(e);
|
||||
return false;
|
||||
}
|
||||
//else if (!modInfo.Tags.Contains(""))
|
||||
else
|
||||
{
|
||||
Log.Info($"Mod Info successfully retrieved!");
|
||||
FriendlyName = modInfo.Title;
|
||||
Description = modInfo.Description;
|
||||
//Name = modInfo.FileName;
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.Info("Mod Info successfully retrieved!");
|
||||
FriendlyName = modInfo.Title;
|
||||
Description = modInfo.Description;*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@@ -13,13 +13,7 @@ namespace Torch.Server.ViewModels
|
||||
public class PluginManagerViewModel : ViewModel
|
||||
{
|
||||
public MtObservableList<PluginViewModel> Plugins { get; } = new MtObservableList<PluginViewModel>();
|
||||
|
||||
private PluginViewModel _selectedPlugin;
|
||||
public PluginViewModel SelectedPlugin
|
||||
{
|
||||
get => _selectedPlugin;
|
||||
set { _selectedPlugin = value; OnPropertyChanged(nameof(SelectedPlugin)); }
|
||||
}
|
||||
public PluginViewModel SelectedPlugin { get; set; }
|
||||
|
||||
public PluginManagerViewModel() { }
|
||||
|
||||
|
@@ -72,7 +72,7 @@ namespace Torch.Server.ViewModels
|
||||
case PluginState.Enabled:
|
||||
return Brushes.Transparent;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user