diff --git a/Jenkinsfile b/Jenkinsfile index 7180626..a434278 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,8 +39,8 @@ node { } else { buildMode = "Debug" } - bat "rmdir /Q /S \"bin\"" - bat "rmdir /Q /S \"bin-test\"" + bat "IF EXIST \"bin\"rmdir /Q /S \"bin\"" + bat "IF EXIST \"bin-test\" rmdir /Q /S \"bin-test\"" bat "\"${tool 'MSBuild'}msbuild\" Torch.sln /p:Configuration=${buildMode} /p:Platform=x64 /t:Clean" bat "\"${tool 'MSBuild'}msbuild\" Torch.sln /p:Configuration=${buildMode} /p:Platform=x64" } diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj index 3208cd3..d632099 100644 --- a/Torch.Server/Torch.Server.csproj +++ b/Torch.Server/Torch.Server.csproj @@ -221,6 +221,7 @@ + @@ -261,6 +262,9 @@ PluginsControl.xaml + + ProfilerConfigControl.xaml + TorchUI.xaml @@ -349,6 +353,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Torch.Server/ViewModels/Entities/EntityViewModel.cs b/Torch.Server/ViewModels/Entities/EntityViewModel.cs index 08ad9ae..f9b8dcd 100644 --- a/Torch.Server/ViewModels/Entities/EntityViewModel.cs +++ b/Torch.Server/ViewModels/Entities/EntityViewModel.cs @@ -1,4 +1,8 @@ -using VRage.Game.ModAPI; +using System.Windows.Controls; +using Torch.API.Managers; +using Torch.Collections; +using Torch.Managers.Profiler; +using VRage.Game.ModAPI; using VRage.ModAPI; using VRageMath; @@ -9,6 +13,12 @@ namespace Torch.Server.ViewModels.Entities protected EntityTreeViewModel Tree { get; } public IMyEntity Entity { get; } public long Id => Entity.EntityId; + public ProfilerEntryViewModel Profiler + { + get => ProfilerTreeAlias[0]; + set => ProfilerTreeAlias[0] = value; + } + public MtObservableList ProfilerTreeAlias { get; } = new MtObservableList(1){null}; public virtual string Name { @@ -46,6 +56,7 @@ namespace Torch.Server.ViewModels.Entities { Entity = entity; Tree = tree; + Profiler = TorchBase.Instance.Managers.GetManager()?.EntityData(entity, Profiler); } public EntityViewModel() diff --git a/Torch.Server/ViewModels/Entities/GridViewModel.cs b/Torch.Server/ViewModels/Entities/GridViewModel.cs index b591c99..9cbd2cc 100644 --- a/Torch.Server/ViewModels/Entities/GridViewModel.cs +++ b/Torch.Server/ViewModels/Entities/GridViewModel.cs @@ -2,7 +2,9 @@ using System.Linq; using Sandbox.Game.Entities; using Sandbox.ModAPI; +using Torch.API.Managers; using Torch.Collections; +using Torch.Managers.Profiler; using Torch.Server.ViewModels.Blocks; namespace Torch.Server.ViewModels.Entities diff --git a/Torch.Server/ViewModels/ProfilerViewModel.cs b/Torch.Server/ViewModels/ProfilerViewModel.cs new file mode 100644 index 0000000..247f6c8 --- /dev/null +++ b/Torch.Server/ViewModels/ProfilerViewModel.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Torch.API.Managers; +using Torch.Collections; +using Torch.Managers.Profiler; + +namespace Torch.Server.ViewModels +{ + public class ProfilerViewModel : ViewModel + { + public MtObservableList ProfilerTreeAlias { get; } = new MtObservableList(); + + private readonly ProfilerManager _manager; + + public ProfilerViewModel() + { + _manager = null; + } + + public ProfilerViewModel(ProfilerManager profilerManager) + { + _manager = profilerManager; + ProfilerTreeAlias.Add(_manager.SessionData()); + ProfilerTreeAlias.Add(_manager.EntitiesData()); + } + + /// + public bool ProfileGridsUpdate + { + get => _manager?.ProfileGridsUpdate ?? false; + set + { + if (_manager != null) + _manager.ProfileGridsUpdate = value; + OnPropertyChanged(); + } + } + + /// + public bool ProfileBlocksUpdate + { + get => _manager?.ProfileBlocksUpdate ?? false; + set + { + if (_manager != null) + _manager.ProfileBlocksUpdate = value; + OnPropertyChanged(); + } + } + + /// + public bool ProfileEntityComponentsUpdate + { + get => _manager?.ProfileEntityComponentsUpdate ?? false; + set + { + if (_manager != null) + _manager.ProfileEntityComponentsUpdate = value; + OnPropertyChanged(); + } + } + + /// + public bool ProfileGridSystemUpdates + { + get => _manager?.ProfileGridSystemUpdates ?? false; + set + { + if (_manager != null) + _manager.ProfileGridSystemUpdates = value; + OnPropertyChanged(); + } + } + + /// + public bool ProfileSessionComponentsUpdate + { + get => _manager?.ProfileSessionComponentsUpdate ?? false; + set => _manager.ProfileSessionComponentsUpdate = value; + } + } +} diff --git a/Torch.Server/Views/ChatControl.xaml.cs b/Torch.Server/Views/ChatControl.xaml.cs index 6c966cc..a6c1cb7 100644 --- a/Torch.Server/Views/ChatControl.xaml.cs +++ b/Torch.Server/Views/ChatControl.xaml.cs @@ -44,7 +44,7 @@ namespace Torch.Server public void BindServer(ITorchServer server) { _server = (TorchBase)server; - Dispatcher.Invoke(() => + Dispatcher.InvokeAsync(() => { ChatItems.Inlines.Clear(); }); @@ -59,7 +59,7 @@ namespace Torch.Server switch (state) { case TorchSessionState.Loading: - Dispatcher.Invoke(() => ChatItems.Inlines.Clear()); + Dispatcher.InvokeAsync(() => ChatItems.Inlines.Clear()); break; case TorchSessionState.Loaded: { @@ -112,7 +112,7 @@ namespace Torch.Server ChatScroller.ScrollToBottom(); } else - Dispatcher.Invoke(() => InsertMessage(msg)); + Dispatcher.InvokeAsync(() => InsertMessage(msg)); } private void SendButton_Click(object sender, RoutedEventArgs e) diff --git a/Torch.Server/Views/Entities/GridView.xaml b/Torch.Server/Views/Entities/GridView.xaml index e4a63b6..36620ee 100644 --- a/Torch.Server/Views/Entities/GridView.xaml +++ b/Torch.Server/Views/Entities/GridView.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:Torch.Server.Views.Entities" + xmlns:profiler="clr-namespace:Torch.Managers.Profiler;assembly=Torch" xmlns:entities="clr-namespace:Torch.Server.ViewModels.Entities" mc:Ignorable="d"> @@ -18,5 +18,15 @@