diff --git a/src/Artemis.Core/Plugins/Modules/Module.cs b/src/Artemis.Core/Plugins/Modules/Module.cs
index 0892e6ab2..946ce40b9 100644
--- a/src/Artemis.Core/Plugins/Modules/Module.cs
+++ b/src/Artemis.Core/Plugins/Modules/Module.cs
@@ -93,7 +93,13 @@ namespace Artemis.Core.Modules
/// Gets whether this module's activation was due to an override, can only be true if is
/// true
///
- public bool IsActivatedOverride { get; set; }
+ public bool IsActivatedOverride { get; private set; }
+
+ ///
+ /// Gets whether this module should update if is true
+ /// Defaults to true
+ ///
+ public bool UpdateDuringActivationOverride { get; protected set; } = true;
///
/// A list of activation requirements
@@ -180,10 +186,11 @@ namespace Artemis.Core.Modules
return false;
}
-
+
internal virtual void InternalUpdate(double deltaTime)
{
- Update(deltaTime);
+ if (!IsActivatedOverride || UpdateDuringActivationOverride)
+ Update(deltaTime);
}
internal virtual void InternalRender(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo)
diff --git a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs
index 86afbcc0a..498d7475a 100644
--- a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs
+++ b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs
@@ -141,7 +141,8 @@ namespace Artemis.Core.Modules
internal override void InternalUpdate(double deltaTime)
{
- Update(deltaTime);
+ if (!IsActivatedOverride || UpdateDuringActivationOverride)
+ Update(deltaTime);
lock (this)
{
diff --git a/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs b/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs
index 010e32511..488c30c72 100644
--- a/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs
+++ b/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs
@@ -1,5 +1,6 @@
using System;
using System.Timers;
+using Artemis.Core.Modules;
namespace Artemis.Core
{
@@ -53,6 +54,13 @@ namespace Artemis.Core
if (_timer != null)
return;
+ // Don't update during override if that is disabled on the module
+ if (PluginInfo.Instance is Module module)
+ {
+ if (module.IsActivatedOverride && !module.UpdateDuringActivationOverride)
+ return;
+ }
+
_lastEvent = DateTime.Now;
_timer = new Timer(Interval.TotalMilliseconds);
_timer.Elapsed += TimerOnElapsed;
diff --git a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml
index 666924607..640f202f0 100644
--- a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml
+++ b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml
@@ -92,7 +92,7 @@
Placement="Bottom"
CustomPopupPlacementCallback="{x:Static materialDesign:CustomPopupPlacementCallbackHelper.LargePopupCallback}"
PlacementTarget="{Binding ElementName=ColorCodeTextBox}"
- StaysOpen="False"
+ StaysOpen="{Binding StaysOpen, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
PopupAnimation="Fade"
IsOpen="{Binding PopupOpen, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
@@ -101,7 +101,7 @@
-
+
SetValue(PopupOpenProperty, value);
}
+ public bool StaysOpen
+ {
+ get => (bool) GetValue(StaysOpenProperty);
+ set => SetValue(StaysOpenProperty, value);
+ }
+
internal byte ColorOpacity
{
get => (byte) GetValue(ColorOpacityProperty);
@@ -92,6 +101,17 @@ namespace Artemis.UI.Shared
colorPicker._inCallback = false;
}
+ private static void StaysOpenPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var colorPicker = (ColorPicker) d;
+ if (colorPicker._inCallback)
+ return;
+
+ colorPicker._inCallback = true;
+ colorPicker.OnPropertyChanged(nameof(PopupOpen));
+ colorPicker._inCallback = false;
+ }
+
private static void ColorOpacityPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var colorPicker = (ColorPicker) d;
@@ -112,6 +132,12 @@ namespace Artemis.UI.Shared
private void UIElement_OnMouseUp(object sender, MouseButtonEventArgs e)
{
PopupOpen = !PopupOpen;
+ e.Handled = true;
+ }
+
+ private void ColorGradient_OnMouseUp(object sender, MouseButtonEventArgs e)
+ {
+ e.Handled = true;
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs b/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs
index 0d9a9ccd7..a285b1870 100644
--- a/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs
+++ b/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs
@@ -15,7 +15,7 @@ namespace Artemis.UI.Shared
///
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- return value?.ToString();
+ return value?.ToString()?.ToUpper();
}
///
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs
index 7a5996ca3..ff07fee4f 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs
+++ b/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs
@@ -20,10 +20,12 @@ namespace Artemis.UI.Shared
{
}
- internal override void UpdateValue(object model)
+ public override void UpdateValue(object model)
{
DisplayValue = model is T value ? value : default;
}
+
+ internal override object InternalGuard => null;
}
///
@@ -31,9 +33,11 @@ namespace Artemis.UI.Shared
///
public abstract class DataModelDisplayViewModel : PropertyChangedBase
{
+ public abstract void UpdateValue(object model);
+
///
/// Prevents this type being implemented directly, implement instead.
///
- internal abstract void UpdateValue(object model);
+ internal abstract object InternalGuard { get; }
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml
index 6afe0edba..87d3109dd 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml
+++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml
@@ -33,7 +33,7 @@
-
+
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs
index 7d4e23214..f1352e081 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs
+++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs
@@ -1,19 +1,21 @@
using System;
+using System.Linq;
+using System.Windows;
+using System.Windows.Input;
using System.Windows.Media;
using Artemis.Core;
using Artemis.Core.DataModelExpansions;
using Artemis.UI.Shared.Services;
using Stylet;
-// Remove, annoying while working on it
-#pragma warning disable 1591
-
namespace Artemis.UI.Shared.Input
{
- public class DataModelStaticViewModel : PropertyChangedBase
+ public class DataModelStaticViewModel : PropertyChangedBase, IDisposable
{
private readonly IDataModelUIService _dataModelUIService;
+ private readonly Window _rootView;
private Brush _buttonBrush = new SolidColorBrush(Color.FromRgb(171, 71, 188));
+ private DataModelDisplayViewModel _displayViewModel;
private DataModelInputViewModel _inputViewModel;
private string _placeholder = "Enter a value";
private DataModelPropertyAttribute _targetDescription;
@@ -25,6 +27,15 @@ namespace Artemis.UI.Shared.Input
{
TargetType = targetType;
_dataModelUIService = dataModelUIService;
+
+ DisplayViewModel = _dataModelUIService.GetDataModelDisplayViewModel(TargetType, true);
+
+ _rootView = Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive);
+ if (_rootView != null)
+ {
+ _rootView.MouseUp += RootViewOnMouseUp;
+ _rootView.KeyUp += RootViewOnKeyUp;
+ }
}
public Brush ButtonBrush
@@ -39,6 +50,12 @@ namespace Artemis.UI.Shared.Input
set => SetAndNotify(ref _transitionIndex, value);
}
+ public DataModelDisplayViewModel DisplayViewModel
+ {
+ get => _displayViewModel;
+ set => SetAndNotify(ref _displayViewModel, value);
+ }
+
public DataModelInputViewModel InputViewModel
{
get => _inputViewModel;
@@ -60,7 +77,11 @@ namespace Artemis.UI.Shared.Input
public object Value
{
get => _value;
- set => SetAndNotify(ref _value, value);
+ set
+ {
+ if (!SetAndNotify(ref _value, value)) return;
+ DisplayViewModel?.UpdateValue(_value);
+ }
}
public string Placeholder
@@ -69,6 +90,19 @@ namespace Artemis.UI.Shared.Input
set => SetAndNotify(ref _placeholder, value);
}
+ #region IDisposable
+
+ public void Dispose()
+ {
+ if (_rootView != null)
+ {
+ _rootView.MouseUp -= RootViewOnMouseUp;
+ _rootView.KeyUp -= RootViewOnKeyUp;
+ }
+ }
+
+ #endregion
+
public void ActivateInputViewModel()
{
TransitionIndex = 1;
@@ -102,6 +136,30 @@ namespace Artemis.UI.Shared.Input
Value = value;
}
+ #region Event handlers
+
+ private void RootViewOnKeyUp(object sender, KeyEventArgs e)
+ {
+ if (InputViewModel == null)
+ return;
+
+ if (e.Key == Key.Escape)
+ InputViewModel.Cancel();
+ else if (e.Key == Key.Enter)
+ InputViewModel.Submit();
+ }
+
+ private void RootViewOnMouseUp(object sender, MouseButtonEventArgs e)
+ {
+ if (InputViewModel == null)
+ return;
+
+ if (sender is FrameworkElement frameworkElement && !frameworkElement.IsDescendantOf(InputViewModel.View))
+ InputViewModel.Submit();
+ }
+
+ #endregion
+
#region Events
public event EventHandler ValueUpdated;
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs
index 2d3c7292b..f612ec056 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs
+++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs
@@ -38,8 +38,8 @@ namespace Artemis.UI.Shared
if (DisplayValue == null)
return;
- if (DisplayViewModel == null && dataModelUIService.RegisteredDataModelDisplays.Any(d => d.SupportedType == DisplayValue.GetType()))
- dataModelUIService.GetDataModelDisplayViewModel(DisplayValue.GetType());
+ if (DisplayViewModel == null)
+ DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DisplayValue.GetType(), true);
ListType = DisplayValue.GetType();
UpdateDisplayParameters();
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs
index 729e3fe67..df82cecd7 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs
+++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs
@@ -9,9 +9,6 @@ namespace Artemis.UI.Shared
{
private object _displayValue;
private DataModelDisplayViewModel _displayViewModel;
- private bool _showNull;
- private bool _showToString;
- private bool _showViewModel;
internal DataModelPropertyViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo)
{
@@ -29,31 +26,13 @@ namespace Artemis.UI.Shared
set => SetAndNotify(ref _displayViewModel, value);
}
- public bool ShowToString
- {
- get => _showToString;
- set => SetAndNotify(ref _showToString, value);
- }
-
- public bool ShowNull
- {
- get => _showNull;
- set => SetAndNotify(ref _showNull, value);
- }
-
- public bool ShowViewModel
- {
- get => _showViewModel;
- set => SetAndNotify(ref _showViewModel, value);
- }
-
public override void Update(IDataModelUIService dataModelUIService)
{
if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel)
return;
- if (DisplayViewModel == null && dataModelUIService.RegisteredDataModelDisplays.Any(d => d.SupportedType == PropertyInfo.PropertyType))
- dataModelUIService.GetDataModelDisplayViewModel(PropertyInfo.PropertyType);
+ if (DisplayViewModel == null)
+ DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(PropertyInfo.PropertyType, true);
DisplayValue = GetCurrentValue();
UpdateDisplayParameters();
@@ -61,10 +40,6 @@ namespace Artemis.UI.Shared
protected void UpdateDisplayParameters()
{
- ShowToString = DisplayValue != null && DisplayViewModel == null;
- ShowNull = DisplayValue == null;
- ShowViewModel = DisplayValue != null && DisplayViewModel != null;
-
DisplayViewModel?.UpdateValue(DisplayValue);
}
}
diff --git a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.xaml b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.xaml
new file mode 100644
index 000000000..8c748ffaa
--- /dev/null
+++ b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
diff --git a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayViewModel.cs b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayViewModel.cs
new file mode 100644
index 000000000..fef262aa4
--- /dev/null
+++ b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayViewModel.cs
@@ -0,0 +1,26 @@
+namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display
+{
+ public class DefaultDataModelDisplayViewModel : DataModelDisplayViewModel
diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs
index 34c1c4c3a..beccd44bd 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs
@@ -13,6 +13,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
{
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
private readonly IProfileEditorService _profileEditorService;
+ private readonly IDataModelUIService _dataModelUIService;
private DataBinding _dataBinding;
private int _easingTime;
private bool _isEasingTimeEnabled;
@@ -26,10 +27,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
public DataBindingViewModel(DataBindingRegistration registration,
IProfileEditorService profileEditorService,
+ IDataModelUIService dataModelUIService,
IDataBindingsVmFactory dataBindingsVmFactory)
{
Registration = registration;
_profileEditorService = profileEditorService;
+ _dataModelUIService = dataModelUIService;
_dataBindingsVmFactory = dataBindingsVmFactory;
if (Registration.Member != null)
@@ -39,6 +42,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
DataBindingModes = new BindableCollection(EnumUtilities.GetAllValuesAndDescriptions(typeof(DataBindingModeType)));
EasingViewModels = new BindableCollection();
+ TestInputValue = _dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true);
+ TestResultValue = _dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true);
DataBinding = Registration.DataBinding;
@@ -49,6 +54,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
public BindableCollection DataBindingModes { get; }
public BindableCollection EasingViewModels { get; }
+ public DataModelDisplayViewModel TestInputValue { get; }
+ public DataModelDisplayViewModel TestResultValue { get; }
public DataBindingModeType SelectedDataBindingMode
{
@@ -102,18 +109,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
set => SetAndNotify(ref _dataBinding, value);
}
- public TProperty TestInputValue
- {
- get => _testInputValue;
- set => SetAndNotify(ref _testInputValue, value);
- }
-
- public TProperty TestResultValue
- {
- get => _testResultValue;
- set => SetAndNotify(ref _testResultValue, value);
- }
-
public void Dispose()
{
_profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated;
@@ -222,18 +217,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
{
if (DataBinding == null)
{
- TestInputValue = default;
- TestResultValue = default;
+ TestInputValue.UpdateValue(default);
+ TestResultValue.UpdateValue(default);
return;
}
- var currentValue = ActiveItem?.GetTestValue() ?? default(TProperty);
+ var currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty));
- TestInputValue = Registration.Converter.ConvertFromObject(currentValue);
- if (DataBinding != null)
- TestResultValue = DataBinding.GetValue(TestInputValue);
- else
- TestInputValue = default;
+ TestInputValue.UpdateValue(currentValue);
+ TestResultValue.UpdateValue(DataBinding != null ? DataBinding.GetValue(currentValue) : default);
}
private void EnableDataBinding()
diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs
index 73e129427..c66ca6730 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs
@@ -79,11 +79,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
private void ParameterSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e)
{
Modifier.UpdateParameter(e.DataModelVisualizationViewModel.DataModel, e.DataModelVisualizationViewModel.PropertyPath);
+ _profileEditorService.UpdateSelectedProfileElement();
}
private void StaticInputViewModelOnValueUpdated(object sender, DataModelInputStaticEventArgs e)
{
Modifier.UpdateParameter(e.Value);
+ _profileEditorService.UpdateSelectedProfileElement();
}
private void Update()
@@ -155,6 +157,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
DynamicSelectionViewModel.Dispose();
DynamicSelectionViewModel.PropertySelected -= ParameterSelectionViewModelOnPropertySelected;
}
+
+ if (StaticInputViewModel != null)
+ {
+ StaticInputViewModel.Dispose();
+ }
}
}
}
\ 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 6bce31a96..f69d9e7bf 100644
--- a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
+++ b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
@@ -97,21 +97,7 @@
-
-
-
+
diff --git a/src/Artemis.UI/Services/RegistrationService.cs b/src/Artemis.UI/Services/RegistrationService.cs
index 1b036c4df..7261cf312 100644
--- a/src/Artemis.UI/Services/RegistrationService.cs
+++ b/src/Artemis.UI/Services/RegistrationService.cs
@@ -1,6 +1,6 @@
using Artemis.Core;
-using Artemis.UI.DataModelVisualization.Display;
-using Artemis.UI.DataModelVisualization.Input;
+using Artemis.UI.DefaultTypes.DataModel.Display;
+using Artemis.UI.DefaultTypes.DataModel.Input;
using Artemis.UI.PropertyInput;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services;
@@ -36,9 +36,10 @@ namespace Artemis.UI.Services
if (_registeredBuiltInDataModelInputs)
return;
- _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, null);
- _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, Constants.IntegralNumberTypes);
_dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, Constants.FloatNumberTypes);
+ _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, Constants.IntegralNumberTypes);
+ _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, null);
+ _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, null);
_registeredBuiltInDataModelInputs = true;
}
diff --git a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs
index 773256d97..2c2db08cf 100644
--- a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs
+++ b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs
@@ -18,6 +18,7 @@ namespace Artemis.Plugins.Modules.General
DisplayName = "General";
DisplayIcon = "AllInclusive";
ExpandsDataModel = true;
+
ModuleTabs = new List {new ModuleTab("General")};
}