diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 2fcff35a3..c567444ed 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -411,6 +411,7 @@
+
@@ -453,6 +454,9 @@
LayerEditorView.xaml
+
+ LayerConditionView.xaml
+
OverlaysView.xaml
@@ -606,6 +610,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs
index f42a89928..2ffc9d0e8 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs
@@ -1,4 +1,5 @@
-using Artemis.Models.Interfaces;
+using System;
+using Artemis.Models.Interfaces;
namespace Artemis.Modules.Games.TheDivision
{
@@ -20,6 +21,7 @@ namespace Artemis.Modules.Games.TheDivision
public TestTest TestyTest { get; set; }
}
+
public class TestTest
{
public string TestS { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
index 57a5b9df0..48b9924bf 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
@@ -7,52 +7,52 @@
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
d:DesignHeight="416.495" d:DesignWidth="553.608">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Note: For this game to work with Artemis, please open up your Division settings, navigate to 3rd Party and set LED keyboard support to Yes. (This only works if you have Artemis running before starting the game)
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Note: For this game to work with Artemis, please open up your Division settings, navigate to 3rd Party and set LED keyboard support to Yes. (This only works if you have Artemis running before starting the game)
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Artemis/Artemis/Utilities/GeneralHelpers.cs b/Artemis/Artemis/Utilities/GeneralHelpers.cs
index cec2042fc..a024dba1c 100644
--- a/Artemis/Artemis/Utilities/GeneralHelpers.cs
+++ b/Artemis/Artemis/Utilities/GeneralHelpers.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
+using System.Linq;
using System.Reflection;
using System.Security.Principal;
using System.Windows;
@@ -53,33 +54,45 @@ namespace Artemis.Utilities
}
}
- public static List GetPropertyMap(object o)
- {
- var res = new List();
- // No point reinventing the wheel, just serialize it to JSON and parse that
- var json = JObject.FromObject(o, JsonSerializer.CreateDefault());
- res.AddRange(JObjectToPropertyCollection(json));
+ public static List GenerateTypeMap(object o) => GenerateTypeMap(o.GetType().GetProperties());
+ public static List GenerateTypeMap() => GenerateTypeMap(typeof (T).GetProperties());
- return res;
- }
-
- private static List JObjectToPropertyCollection(JObject json)
+ private static List GenerateTypeMap(IEnumerable getProperties,
+ string path = "")
{
- var res = new List();
- foreach (var property in json.Properties())
+ var list = new List();
+ foreach (var propertyInfo in getProperties)
{
- var parent = new PropertyCollection {Name = property.Name};
- foreach (var child in property.Children())
- parent.Children = JObjectToPropertyCollection(child);
+ var parent = new PropertyCollection
+ {
+ Type = propertyInfo.PropertyType.Name,
+ Display = $"{path.Replace(".", " → ")}{propertyInfo.Name}",
+ Path = $"{path}{propertyInfo.Name}"
+ };
- res.Add(parent);
+ if (propertyInfo.PropertyType.BaseType?.Name == "Enum")
+ {
+ parent.EnumValues = Enum.GetNames(propertyInfo.PropertyType);
+ parent.Type = "Enum";
+ }
+
+ list.Add(parent);
+ list.AddRange(GenerateTypeMap(propertyInfo.PropertyType.GetProperties(), path + $"{propertyInfo.Name}."));
}
- return res;
+ return list;
}
public struct PropertyCollection
{
- public string Name { get; set; }
+ public string Display { get; set; }
+ public string Path { get; set; }
+ public string Type { get; set; }
+
+ ///
+ /// Only used if Type is an enumerable
+ ///
+ public string[] EnumValues { get; set; }
+
public List Children { get; set; }
}
}
diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs b/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
new file mode 100644
index 000000000..6d7288c7b
--- /dev/null
+++ b/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
@@ -0,0 +1,100 @@
+using System.Linq;
+using Artemis.Models.Profiles;
+using Artemis.Utilities;
+using Caliburn.Micro;
+
+namespace Artemis.ViewModels.LayerEditor
+{
+ public class LayerConditionViewModel : Screen
+ {
+ private readonly LayerEditorViewModel _conditionModel;
+ private GeneralHelpers.PropertyCollection _selectedDataModelProp;
+ private string _selectedOperator;
+ private bool _userValueIsVisible;
+
+ public LayerConditionViewModel(LayerEditorViewModel conditionModel, LayerConditionModel layerConditionModel,
+ BindableCollection dataModelProps)
+ {
+ _conditionModel = conditionModel;
+
+ LayerConditionModel = layerConditionModel;
+ DataModelProps = dataModelProps;
+ Operators = new BindableCollection();
+ }
+
+ public LayerConditionModel LayerConditionModel { get; set; }
+ public BindableCollection DataModelProps { get; set; }
+ public BindableCollection Operators { get; set; }
+
+ public GeneralHelpers.PropertyCollection SelectedDataModelProp
+ {
+ get { return _selectedDataModelProp; }
+ set
+ {
+ if (value.Equals(_selectedDataModelProp)) return;
+ _selectedDataModelProp = value;
+ OnSelectedItemChangedAction(_selectedDataModelProp);
+ NotifyOfPropertyChange(() => SelectedDataModelProp);
+ }
+ }
+
+ public string SelectedOperator
+ {
+ get { return _selectedOperator; }
+ set
+ {
+ if (value == _selectedOperator) return;
+ _selectedOperator = value;
+ NotifyOfPropertyChange(() => SelectedOperator);
+ }
+ }
+
+ public bool UserValueIsVisible
+ {
+ get { return _userValueIsVisible; }
+ set
+ {
+ if (value == _userValueIsVisible) return;
+ _userValueIsVisible = value;
+ NotifyOfPropertyChange(() => UserValueIsVisible);
+ }
+ }
+
+ public void OnSelectedItemChangedAction(GeneralHelpers.PropertyCollection prop)
+ {
+ Operators.Clear();
+ if (prop.EnumValues != null)
+ {
+ Operators.AddRange(prop.EnumValues);
+ UserValueIsVisible = false;
+ }
+ else
+ switch (prop.Type)
+ {
+ case "Int32":
+ Operators.AddRange(new[]
+ {
+ "Lower than", "Lower or equal to", "Higher than", "Higher or equal to", "Equal to",
+ "Not equal to"
+ });
+ UserValueIsVisible = true;
+ break;
+ case "Boolean":
+ Operators.AddRange(new[] {"False", "True"});
+ UserValueIsVisible = false;
+ break;
+ default:
+ Operators.AddRange(new[] {"Equal to", "Not equal to"});
+ UserValueIsVisible = true;
+ break;
+ }
+
+ SelectedOperator = Operators.First();
+ }
+
+ public void Delete()
+ {
+ _conditionModel.DeleteCondition(this, LayerConditionModel);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs b/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs
index dca5791f4..6532fa054 100644
--- a/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs
@@ -1,9 +1,7 @@
-using System;
-using System.Collections;
-using System.Diagnostics;
-using System.Reflection;
+using System.Linq;
using Artemis.Models.Profiles;
using Artemis.Utilities;
+using Artemis.ViewModels.LayerEditor;
using Caliburn.Micro;
namespace Artemis.ViewModels
@@ -15,13 +13,19 @@ namespace Artemis.ViewModels
public LayerEditorViewModel(LayerModel layer)
{
Layer = layer;
-
DataModelProps = new BindableCollection();
- DataModelProps.AddRange(GeneralHelpers.GetPropertyMap((T)Activator.CreateInstance(typeof(T), new object[] { })));
+ DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap());
+
+ LayerConditionVms =
+ new BindableCollection>(
+ layer.LayerConditions.Select(c => new LayerConditionViewModel(this, c, DataModelProps)));
+
ProposedProperties = new LayerPropertiesModel();
GeneralHelpers.CopyProperties(ProposedProperties, Layer.LayerUserProperties);
}
+ public BindableCollection> LayerConditionVms { get; set; }
+
public LayerModel Layer
{
get { return _layer; }
@@ -37,9 +41,22 @@ namespace Artemis.ViewModels
public LayerPropertiesModel ProposedProperties { get; set; }
+ public void AddCondition()
+ {
+ var condition = new LayerConditionModel();
+ Layer.LayerConditions.Add(condition);
+ LayerConditionVms.Add(new LayerConditionViewModel(this, condition, DataModelProps));
+ }
+
public void Apply()
{
GeneralHelpers.CopyProperties(Layer.LayerUserProperties, ProposedProperties);
}
+
+ public void DeleteCondition(LayerConditionViewModel layerConditionViewModel, LayerConditionModel layerConditionModel)
+ {
+ LayerConditionVms.Remove(layerConditionViewModel);
+ Layer.LayerConditions.Remove(layerConditionModel);
+ }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml b/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml
new file mode 100644
index 000000000..d99c8fb92
--- /dev/null
+++ b/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml.cs b/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml.cs
new file mode 100644
index 000000000..1dd225b05
--- /dev/null
+++ b/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Artemis.Views.LayerEditor
+{
+ ///
+ /// Interaction logic for LayerConditionView.xaml
+ ///
+ public partial class LayerConditionView : UserControl
+ {
+ public LayerConditionView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Artemis/Artemis/Views/LayerEditorView.xaml b/Artemis/Artemis/Views/LayerEditorView.xaml
index b51d4d04b..087e0200d 100644
--- a/Artemis/Artemis/Views/LayerEditorView.xaml
+++ b/Artemis/Artemis/Views/LayerEditorView.xaml
@@ -7,56 +7,26 @@
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
- Title="Artemis | Edit Layer" Height="400" Width="600"
- GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico">
+ Title="Artemis | Edit Layer" Height="800" Width="630"
+ GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico" ResizeMode="NoResize">
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
\ No newline at end of file