diff --git a/src/Artemis.Core/Services/DataModelService.cs b/src/Artemis.Core/Services/DataModelService.cs
index b5f323a57..fb56e547b 100644
--- a/src/Artemis.Core/Services/DataModelService.cs
+++ b/src/Artemis.Core/Services/DataModelService.cs
@@ -64,6 +64,15 @@ namespace Artemis.Core.Services
}
}
+ public DataModel GetPluginDataModel(Plugin plugin)
+ {
+ if (plugin is Module module)
+ return module.InternalDataModel;
+ if (plugin is BaseDataModelExpansion dataModelExpansion)
+ return dataModelExpansion.InternalDataModel;
+ return null;
+ }
+
private void PluginServiceOnPluginEnabled(object sender, PluginEventArgs e)
{
if (e.PluginInfo.Instance is Module module && module.InternalExpandsMainDataModel)
diff --git a/src/Artemis.Core/Services/Interfaces/IDataModelService.cs b/src/Artemis.Core/Services/Interfaces/IDataModelService.cs
index c8a1089e0..60efedd3f 100644
--- a/src/Artemis.Core/Services/Interfaces/IDataModelService.cs
+++ b/src/Artemis.Core/Services/Interfaces/IDataModelService.cs
@@ -1,5 +1,6 @@
using System.Collections.ObjectModel;
using Artemis.Core.Models;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.DataModels;
namespace Artemis.Core.Services.Interfaces
@@ -19,5 +20,11 @@ namespace Artemis.Core.Services.Interfaces
///
///
void RemoveExpansion(DataModel baseDataModelExpansion);
+
+ ///
+ /// If found, returns the data model of the provided plugin
+ ///
+ /// Should be a module with a data model or a data model expansion
+ DataModel GetPluginDataModel(Plugin plugin);
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/DataModelVisualization/DataModelListViewModel.cs b/src/Artemis.UI/DataModelVisualization/DataModelListViewModel.cs
index dc121c50e..12dba6f05 100644
--- a/src/Artemis.UI/DataModelVisualization/DataModelListViewModel.cs
+++ b/src/Artemis.UI/DataModelVisualization/DataModelListViewModel.cs
@@ -33,7 +33,7 @@ namespace Artemis.UI.DataModelVisualization
foreach (var item in List)
{
DataModelVisualizationViewModel child;
- if (Children.Count < index)
+ if (Children.Count <= index)
{
child = CreateChild(item);
Children.Add(child);
diff --git a/src/Artemis.UI/DataModelVisualization/DataModelPropertyViewModel.cs b/src/Artemis.UI/DataModelVisualization/DataModelPropertyViewModel.cs
index bae43b1d5..49ab9f955 100644
--- a/src/Artemis.UI/DataModelVisualization/DataModelPropertyViewModel.cs
+++ b/src/Artemis.UI/DataModelVisualization/DataModelPropertyViewModel.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Reflection;
+using System.Reflection;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
namespace Artemis.UI.DataModelVisualization
@@ -12,25 +11,13 @@ namespace Artemis.UI.DataModelVisualization
Parent = parent;
PropertyDescription = propertyDescription;
}
-
- public bool IsListProperty { get; set; }
- public string ListDescription { get; set; }
- public Type PropertyType { get; set; }
-
+
public override void Update()
{
if (PropertyInfo != null && Parent?.Model != null)
- {
- IsListProperty = false;
Model = PropertyInfo.GetValue(Parent.Model);
- PropertyType = PropertyInfo.PropertyType;
- }
- else if (Parent is DataModelListViewModel listViewModel)
- {
- IsListProperty = true;
- ListDescription = $"List item [{listViewModel.List.IndexOf(Model)}]";
- PropertyType = Model.GetType();
- }
+
+ UpdateListStatus();
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/DataModelVisualization/DataModelViewModel.cs b/src/Artemis.UI/DataModelVisualization/DataModelViewModel.cs
index a690a1c95..d0bd30c2e 100644
--- a/src/Artemis.UI/DataModelVisualization/DataModelViewModel.cs
+++ b/src/Artemis.UI/DataModelVisualization/DataModelViewModel.cs
@@ -1,8 +1,6 @@
-using System;
-using System.Reflection;
+using System.Reflection;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
-using Humanizer;
using Stylet;
namespace Artemis.UI.DataModelVisualization
@@ -45,6 +43,8 @@ namespace Artemis.UI.DataModelVisualization
foreach (var dataModelVisualizationViewModel in Children)
dataModelVisualizationViewModel.Update();
+
+ UpdateListStatus();
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/DataModelVisualization/DataModelVisualizationViewModel.cs b/src/Artemis.UI/DataModelVisualization/DataModelVisualizationViewModel.cs
index 6a59bc69c..404584c05 100644
--- a/src/Artemis.UI/DataModelVisualization/DataModelVisualizationViewModel.cs
+++ b/src/Artemis.UI/DataModelVisualization/DataModelVisualizationViewModel.cs
@@ -10,11 +10,16 @@ namespace Artemis.UI.DataModelVisualization
{
public abstract class DataModelVisualizationViewModel : PropertyChangedBase
{
- public PropertyInfo PropertyInfo { get; protected set; }
public DataModelPropertyAttribute PropertyDescription { get; protected set; }
+ public PropertyInfo PropertyInfo { get; protected set; }
+ public Type PropertyType { get; set; }
+
public DataModelVisualizationViewModel Parent { get; protected set; }
public object Model { get; set; }
+ public bool IsListProperty { get; set; }
+ public string ListDescription { get; set; }
+
public abstract void Update();
protected DataModelVisualizationViewModel CreateChild(PropertyInfo propertyInfo)
@@ -59,5 +64,20 @@ namespace Artemis.UI.DataModelVisualization
return null;
}
+
+ protected void UpdateListStatus()
+ {
+ if (Parent is DataModelListViewModel listViewModel)
+ {
+ IsListProperty = true;
+ ListDescription = $"List item [{listViewModel.List.IndexOf(Model)}]";
+ PropertyType = Model.GetType();
+ }
+ else
+ {
+ IsListProperty = false;
+ PropertyType = PropertyInfo?.PropertyType;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
index 65a8ac1eb..ef97ae43f 100644
--- a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
+++ b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
@@ -8,16 +8,74 @@
xmlns:s="https://github.com/canton7/Stylet"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:plugins="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:DataModelDebugViewModel}">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Filter module
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+ []
+
+
+
+
@@ -30,10 +88,10 @@
[List]
-
+
@@ -47,24 +105,24 @@
[]
+ Visibility="{Binding IsListProperty, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}" />
-
+
-
+
+ Visibility="{Binding Model, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Inverted}" />
diff --git a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs
index 23e02ed7f..8012db24d 100644
--- a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs
+++ b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs
@@ -1,4 +1,8 @@
-using System.Timers;
+using System.Collections.Generic;
+using System.Linq;
+using System.Timers;
+using Artemis.Core.Events;
+using Artemis.Core.Services.Interfaces;
using Artemis.UI.DataModelVisualization;
using Artemis.UI.Services;
using Stylet;
@@ -8,11 +12,15 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
public class DataModelDebugViewModel : Screen
{
private readonly IDataModelVisualizationService _dataModelVisualizationService;
+ private readonly IPluginService _pluginService;
private readonly Timer _updateTimer;
+ private bool _isModuleFilterEnabled;
+ private Core.Plugins.Abstract.Module _selectedModule;
- public DataModelDebugViewModel(IDataModelVisualizationService dataModelVisualizationService)
+ public DataModelDebugViewModel(IDataModelVisualizationService dataModelVisualizationService, IPluginService pluginService)
{
_dataModelVisualizationService = dataModelVisualizationService;
+ _pluginService = pluginService;
_updateTimer = new Timer(500);
_updateTimer.Elapsed += (sender, args) => MainDataModel.Update();
@@ -21,15 +29,65 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
public DataModelViewModel MainDataModel { get; set; }
+ public string PropertySearch { get; set; }
+ public List Modules { get; set; }
+
+ public Core.Plugins.Abstract.Module SelectedModule
+ {
+ get => _selectedModule;
+ set
+ {
+ _selectedModule = value;
+ GetDataModel();
+ }
+ }
+
+ public bool IsModuleFilterEnabled
+ {
+ get => _isModuleFilterEnabled;
+ set
+ {
+ _isModuleFilterEnabled = value;
+
+ if (!IsModuleFilterEnabled)
+ SelectedModule = null;
+ else
+ GetDataModel();
+ }
+ }
+
protected override void OnActivate()
{
- MainDataModel = _dataModelVisualizationService.GetMainDataModelVisualization();
+ GetDataModel();
_updateTimer.Start();
+ _pluginService.PluginEnabled += PluginServiceOnPluginToggled;
+ _pluginService.PluginDisabled += PluginServiceOnPluginToggled;
+
+ PopulateModules();
}
protected override void OnDeactivate()
{
_updateTimer.Stop();
+ _pluginService.PluginEnabled -= PluginServiceOnPluginToggled;
+ _pluginService.PluginDisabled -= PluginServiceOnPluginToggled;
+ }
+
+ private void GetDataModel()
+ {
+ MainDataModel = SelectedModule != null
+ ? _dataModelVisualizationService.GetPluginDataModelVisualization(SelectedModule)
+ : _dataModelVisualizationService.GetMainDataModelVisualization();
+ }
+
+ private void PluginServiceOnPluginToggled(object? sender, PluginEventArgs e)
+ {
+ PopulateModules();
+ }
+
+ private void PopulateModules()
+ {
+ Modules = _pluginService.GetPluginsOfType().Where(p => p.Enabled).ToList();
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/Services/DataModelVisualizationService.cs b/src/Artemis.UI/Services/DataModelVisualizationService.cs
index 73570da85..8e7e2a54d 100644
--- a/src/Artemis.UI/Services/DataModelVisualizationService.cs
+++ b/src/Artemis.UI/Services/DataModelVisualizationService.cs
@@ -1,4 +1,5 @@
-using Artemis.Core.Services.Interfaces;
+using Artemis.Core.Plugins.Abstract;
+using Artemis.Core.Services.Interfaces;
using Artemis.UI.DataModelVisualization;
using Artemis.UI.Services.Interfaces;
@@ -17,14 +18,26 @@ namespace Artemis.UI.Services
{
var viewModel = new DataModelViewModel();
foreach (var dataModelExpansion in _dataModelService.DataModelExpansions)
- viewModel.Children.Add(new DataModelViewModel(null,dataModelExpansion, dataModelExpansion.DataModelDescription, viewModel));
+ viewModel.Children.Add(new DataModelViewModel(null, dataModelExpansion, dataModelExpansion.DataModelDescription, viewModel));
return viewModel;
}
+
+ public DataModelViewModel GetPluginDataModelVisualization(Plugin plugin)
+ {
+ var dataModel = _dataModelService.GetPluginDataModel(plugin);
+ if (dataModel == null)
+ return null;
+
+ var viewModel = new DataModelViewModel();
+ viewModel.Children.Add(new DataModelViewModel(null, dataModel, dataModel.DataModelDescription, viewModel));
+ return viewModel;
+ }
}
public interface IDataModelVisualizationService : IArtemisUIService
{
- public DataModelViewModel GetMainDataModelVisualization();
+ DataModelViewModel GetMainDataModelVisualization();
+ DataModelViewModel GetPluginDataModelVisualization(Plugin plugin);
}
}
\ No newline at end of file
diff --git a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs
index e029fb6d3..5a349de3b 100644
--- a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs
+++ b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs
@@ -31,7 +31,6 @@ namespace Artemis.Plugins.Modules.General
DataModel.IntsList[0] = _rand.Next();
DataModel.IntsList[2] = _rand.Next();
-
base.Update(deltaTime);
}