MT observable collections

(UI sync fix)
This commit is contained in:
Westin Miller
2017-10-27 17:52:27 -07:00
parent fdc20d4e9d
commit 6f5142393b
20 changed files with 860 additions and 390 deletions

View File

@@ -2,6 +2,7 @@
using System.Linq;
using Sandbox.Game.Entities;
using Sandbox.ModAPI;
using Torch.Collections;
using Torch.Server.ViewModels.Blocks;
namespace Torch.Server.ViewModels.Entities
@@ -9,7 +10,7 @@ namespace Torch.Server.ViewModels.Entities
public class GridViewModel : EntityViewModel, ILazyLoad
{
private MyCubeGrid Grid => (MyCubeGrid)Entity;
public ObservableList<BlockViewModel> Blocks { get; } = new ObservableList<BlockViewModel>();
public MtObservableList<BlockViewModel> Blocks { get; } = new MtObservableList<BlockViewModel>();
/// <inheritdoc />
public string DescriptiveName { get; }
@@ -34,7 +35,7 @@ namespace Torch.Server.ViewModels.Entities
{
var block = obj.FatBlock as IMyTerminalBlock;
if (block != null)
Blocks.Insert(new BlockViewModel(block, Tree), b => b.Name);
Blocks.Add(new BlockViewModel(block, Tree));
OnPropertyChanged(nameof(Name));
}