mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Layer editor progress
This commit is contained in:
parent
1d648fe606
commit
1a6c4d55da
@ -378,6 +378,7 @@
|
|||||||
<DependentUpon>Offsets.settings</DependentUpon>
|
<DependentUpon>Offsets.settings</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Utilities\ColorHelpers.cs" />
|
<Compile Include="Utilities\ColorHelpers.cs" />
|
||||||
|
<Compile Include="Utilities\ExtensionMethods.cs" />
|
||||||
<Compile Include="Utilities\GameState\GameDataReceivedEventArgs.cs" />
|
<Compile Include="Utilities\GameState\GameDataReceivedEventArgs.cs" />
|
||||||
<Compile Include="Utilities\GameState\GameStateWebServer.cs" />
|
<Compile Include="Utilities\GameState\GameStateWebServer.cs" />
|
||||||
<Compile Include="Utilities\GeneralHelpers.cs" />
|
<Compile Include="Utilities\GeneralHelpers.cs" />
|
||||||
|
|||||||
@ -11,8 +11,6 @@ namespace Artemis.KeyboardProviders.Logitech
|
|||||||
{
|
{
|
||||||
internal class Orion : KeyboardProvider
|
internal class Orion : KeyboardProvider
|
||||||
{
|
{
|
||||||
private string _versionString;
|
|
||||||
|
|
||||||
public Orion()
|
public Orion()
|
||||||
{
|
{
|
||||||
Name = "Logitech G910 RGB";
|
Name = "Logitech G910 RGB";
|
||||||
|
|||||||
12
Artemis/Artemis/Utilities/ExtensionMethods.cs
Normal file
12
Artemis/Artemis/Utilities/ExtensionMethods.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Artemis.Utilities
|
||||||
|
{
|
||||||
|
public static class ExtensionMethods
|
||||||
|
{
|
||||||
|
public static string SplitCamelCase(this string str)
|
||||||
|
{
|
||||||
|
return Regex.Replace(Regex.Replace(str, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2"), @"(\p{Ll})(\P{Ll})", "$1 $2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,7 +11,6 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
|
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
|
||||||
{
|
{
|
||||||
private string _activeEffectName;
|
private string _activeEffectName;
|
||||||
private bool _enabled;
|
|
||||||
private GeneralSettings _generalSettings;
|
private GeneralSettings _generalSettings;
|
||||||
private string _selectedKeyboardProvider;
|
private string _selectedKeyboardProvider;
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace Artemis.ViewModels
|
|||||||
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
|
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
|
||||||
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
|
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
|
||||||
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
|
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
|
||||||
// _divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
|
_divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
@ -33,7 +33,7 @@ namespace Artemis.ViewModels
|
|||||||
ActivateItem(_counterStrikeVm);
|
ActivateItem(_counterStrikeVm);
|
||||||
ActivateItem(_dota2Vm);
|
ActivateItem(_dota2Vm);
|
||||||
ActivateItem(_witcher3Vm);
|
ActivateItem(_witcher3Vm);
|
||||||
// ActivateItem(_divisionVm);
|
ActivateItem(_divisionVm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Models.Profiles;
|
using Artemis.Models.Profiles;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
@ -7,24 +8,67 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
{
|
{
|
||||||
public class LayerConditionViewModel<T> : Screen
|
public class LayerConditionViewModel<T> : Screen
|
||||||
{
|
{
|
||||||
|
private readonly NamedOperator[] _boolOperators =
|
||||||
|
{
|
||||||
|
new NamedOperator("True", "== True"),
|
||||||
|
new NamedOperator("False", "== False")
|
||||||
|
};
|
||||||
|
|
||||||
private readonly LayerEditorViewModel<T> _conditionModel;
|
private readonly LayerEditorViewModel<T> _conditionModel;
|
||||||
|
|
||||||
|
private readonly NamedOperator[] _int32Operators =
|
||||||
|
{
|
||||||
|
new NamedOperator("Lower than", "<"),
|
||||||
|
new NamedOperator("Lower or equal to", "<="),
|
||||||
|
new NamedOperator("Higher than", ">"),
|
||||||
|
new NamedOperator("Higher or equal to", ">="),
|
||||||
|
new NamedOperator("Equal to", "=="),
|
||||||
|
new NamedOperator("Not equal to", "!=")
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly NamedOperator[] _operators =
|
||||||
|
{
|
||||||
|
new NamedOperator("Equal to", "=="),
|
||||||
|
new NamedOperator("Not equal to", "!=")
|
||||||
|
};
|
||||||
|
|
||||||
|
private bool _preselecting;
|
||||||
|
|
||||||
private GeneralHelpers.PropertyCollection _selectedDataModelProp;
|
private GeneralHelpers.PropertyCollection _selectedDataModelProp;
|
||||||
private string _selectedOperator;
|
private NamedOperator _selectedOperator;
|
||||||
|
private string _userValue;
|
||||||
private bool _userValueIsVisible;
|
private bool _userValueIsVisible;
|
||||||
|
|
||||||
public LayerConditionViewModel(LayerEditorViewModel<T> conditionModel, LayerConditionModel layerConditionModel,
|
public LayerConditionViewModel(LayerEditorViewModel<T> conditionModel, LayerConditionModel layerConditionModel,
|
||||||
BindableCollection<GeneralHelpers.PropertyCollection> dataModelProps)
|
BindableCollection<GeneralHelpers.PropertyCollection> dataModelProps)
|
||||||
{
|
{
|
||||||
_conditionModel = conditionModel;
|
_conditionModel = conditionModel;
|
||||||
|
_preselecting = false;
|
||||||
|
|
||||||
LayerConditionModel = layerConditionModel;
|
LayerConditionModel = layerConditionModel;
|
||||||
DataModelProps = dataModelProps;
|
DataModelProps = dataModelProps;
|
||||||
Operators = new BindableCollection<string>();
|
Operators = new BindableCollection<NamedOperator>();
|
||||||
|
|
||||||
|
PropertyChanged += UpdateModel;
|
||||||
|
PropertyChanged += UpdateForm;
|
||||||
|
|
||||||
|
PreSelect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UserValue
|
||||||
|
{
|
||||||
|
get { return _userValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == _userValue) return;
|
||||||
|
_userValue = value;
|
||||||
|
NotifyOfPropertyChange(() => UserValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayerConditionModel LayerConditionModel { get; set; }
|
public LayerConditionModel LayerConditionModel { get; set; }
|
||||||
public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; }
|
public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; }
|
||||||
public BindableCollection<string> Operators { get; set; }
|
public BindableCollection<NamedOperator> Operators { get; set; }
|
||||||
|
|
||||||
public GeneralHelpers.PropertyCollection SelectedDataModelProp
|
public GeneralHelpers.PropertyCollection SelectedDataModelProp
|
||||||
{
|
{
|
||||||
@ -33,21 +77,10 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
{
|
{
|
||||||
if (value.Equals(_selectedDataModelProp)) return;
|
if (value.Equals(_selectedDataModelProp)) return;
|
||||||
_selectedDataModelProp = value;
|
_selectedDataModelProp = value;
|
||||||
OnSelectedItemChangedAction(_selectedDataModelProp);
|
|
||||||
NotifyOfPropertyChange(() => SelectedDataModelProp);
|
NotifyOfPropertyChange(() => SelectedDataModelProp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SelectedOperator
|
|
||||||
{
|
|
||||||
get { return _selectedOperator; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == _selectedOperator) return;
|
|
||||||
_selectedOperator = value;
|
|
||||||
NotifyOfPropertyChange(() => SelectedOperator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool UserValueIsVisible
|
public bool UserValueIsVisible
|
||||||
{
|
{
|
||||||
@ -60,31 +93,47 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSelectedItemChangedAction(GeneralHelpers.PropertyCollection prop)
|
public NamedOperator SelectedOperator
|
||||||
{
|
{
|
||||||
Operators.Clear();
|
get { return _selectedOperator; }
|
||||||
if (prop.EnumValues != null)
|
set
|
||||||
{
|
{
|
||||||
Operators.AddRange(prop.EnumValues);
|
if (value.Equals(_selectedOperator)) return;
|
||||||
|
_selectedOperator = value;
|
||||||
|
NotifyOfPropertyChange(() => SelectedOperator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles updating the form to match the selected data model property
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void UpdateForm(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName != "SelectedDataModelProp")
|
||||||
|
return;
|
||||||
|
|
||||||
|
Operators.Clear();
|
||||||
|
if (SelectedDataModelProp.EnumValues != null)
|
||||||
|
{
|
||||||
|
Operators.AddRange(
|
||||||
|
SelectedDataModelProp.EnumValues.Select(val => new NamedOperator(val.SplitCamelCase(), "== " + val)));
|
||||||
UserValueIsVisible = false;
|
UserValueIsVisible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
switch (prop.Type)
|
switch (SelectedDataModelProp.Type)
|
||||||
{
|
{
|
||||||
case "Int32":
|
case "Int32":
|
||||||
Operators.AddRange(new[]
|
Operators.AddRange(_int32Operators);
|
||||||
{
|
|
||||||
"Lower than", "Lower or equal to", "Higher than", "Higher or equal to", "Equal to",
|
|
||||||
"Not equal to"
|
|
||||||
});
|
|
||||||
UserValueIsVisible = true;
|
UserValueIsVisible = true;
|
||||||
break;
|
break;
|
||||||
case "Boolean":
|
case "Boolean":
|
||||||
Operators.AddRange(new[] {"False", "True"});
|
Operators.AddRange(_boolOperators);
|
||||||
UserValueIsVisible = false;
|
UserValueIsVisible = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Operators.AddRange(new[] {"Equal to", "Not equal to"});
|
Operators.AddRange(_operators);
|
||||||
UserValueIsVisible = true;
|
UserValueIsVisible = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -92,9 +141,59 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
SelectedOperator = Operators.First();
|
SelectedOperator = Operators.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles saving user input to the model
|
||||||
|
/// TODO: Data validation?
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void UpdateModel(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
// Don't mess with model during preselect
|
||||||
|
if (_preselecting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Only care about these fields
|
||||||
|
if (e.PropertyName != "UserValue" &&
|
||||||
|
e.PropertyName != "SelectedOperator" &&
|
||||||
|
e.PropertyName != "SelectedDataModelProp")
|
||||||
|
return;
|
||||||
|
|
||||||
|
LayerConditionModel.Field = SelectedDataModelProp.Path;
|
||||||
|
LayerConditionModel.Operator = SelectedOperator.Value;
|
||||||
|
LayerConditionModel.Value = UserValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setup the current UI elements to show the backing model
|
||||||
|
/// </summary>
|
||||||
|
private void PreSelect()
|
||||||
|
{
|
||||||
|
_preselecting = true;
|
||||||
|
SelectedDataModelProp = DataModelProps.FirstOrDefault(m => m.Path == LayerConditionModel.Field);
|
||||||
|
SelectedOperator = Operators.FirstOrDefault(o => o.Value == LayerConditionModel.Operator);
|
||||||
|
UserValue = LayerConditionModel.Value;
|
||||||
|
_preselecting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete the current model from the parent
|
||||||
|
/// </summary>
|
||||||
public void Delete()
|
public void Delete()
|
||||||
{
|
{
|
||||||
_conditionModel.DeleteCondition(this, LayerConditionModel);
|
_conditionModel.DeleteCondition(this, LayerConditionModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct NamedOperator
|
||||||
|
{
|
||||||
|
public string Display { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
|
||||||
|
public NamedOperator(string display, string value)
|
||||||
|
{
|
||||||
|
Display = display;
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<!-- Left -->
|
<!-- Left -->
|
||||||
<ComboBox x:Name="DataModelProps" Grid.Column="0" Width="250" MaxDropDownHeight="125"
|
<ComboBox x:Name="DataModelProps" Grid.Column="0" Width="229" MaxDropDownHeight="125"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Top">
|
HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<!-- Center -->
|
<!-- Center -->
|
||||||
<TextBlock Grid.Column="1" Text="is" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,3,0,0" />
|
<TextBlock Grid.Column="1" Text="is" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,3,0,0" />
|
||||||
<ComboBox x:Name="Operators" Grid.Column="2" Width="150" MaxDropDownHeight="125" HorizontalAlignment="Center"
|
<ComboBox x:Name="Operators" Grid.Column="2" Width="150" MaxDropDownHeight="125" HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Top" />
|
VerticalAlignment="Top" DisplayMemberPath="Display" />
|
||||||
|
|
||||||
<!-- Right -->
|
<!-- Right -->
|
||||||
<Grid Grid.Column="3" HorizontalAlignment="Left" Margin="10,0,0,0" Width="152">
|
<Grid Grid.Column="3" HorizontalAlignment="Left" Margin="10,0,0,0" Width="152">
|
||||||
|
|||||||
@ -9,24 +9,57 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Artemis | Edit Layer" Height="800" Width="630"
|
Title="Artemis | Edit Layer" Height="800" Width="630"
|
||||||
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico" ResizeMode="NoResize">
|
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico" ResizeMode="NoResize">
|
||||||
<Grid>
|
<Grid Margin="10,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="25*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="53*" />
|
||||||
|
<ColumnDefinition Width="25*" />
|
||||||
|
<ColumnDefinition Width="53*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" FontSize="16" Text="Display if.." />
|
<!-- Header -->
|
||||||
<ListBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="LayerConditionVms" />
|
<Label Grid.Row="0" Grid.ColumnSpan="4" FontSize="20" HorizontalAlignment="Left">
|
||||||
<Button Grid.Row="2" Grid.Column="0" x:Name="AddCondition" Content="Add condition" VerticalAlignment="Top"
|
<Label.Content>
|
||||||
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10" />
|
<StackPanel Orientation="Horizontal">
|
||||||
<Button Grid.Row="3" Grid.Column="0" x:Name="Apply" Content="Apply" VerticalAlignment="Bottom"
|
<TextBlock Text="{Binding Path=Layer.Name}" />
|
||||||
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10" />
|
<TextBlock Text=" - Basics" />
|
||||||
|
</StackPanel>
|
||||||
|
</Label.Content>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<!-- Layer name -->
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10" FontSize="16" Text="Name:" />
|
||||||
|
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Name" Margin="10" />
|
||||||
|
|
||||||
|
<!-- Layer type -->
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10" FontSize="16" Text="Type:" />
|
||||||
|
<ComboBox Grid.Row="1" Grid.Column="3" x:Name="Operators" Margin="10" />
|
||||||
|
|
||||||
|
<!-- Condition editor -->
|
||||||
|
<Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" FontSize="20" Content="Display if.." />
|
||||||
|
<ScrollViewer Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Height="145">
|
||||||
|
<ListBox x:Name="LayerConditionVms" />
|
||||||
|
</ScrollViewer>
|
||||||
|
<Button Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="AddCondition" Content="Add condition" VerticalAlignment="Top"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,10,0,0"
|
||||||
|
Height="20" />
|
||||||
|
|
||||||
|
<!-- Advanced -->
|
||||||
|
<Label Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" FontSize="20" HorizontalAlignment="Left"
|
||||||
|
Content="Advanced" />
|
||||||
|
|
||||||
|
<Button Grid.Row="6" Grid.Column="0" x:Name="Apply" Content="Apply" VerticalAlignment="Bottom"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,0,0,10"
|
||||||
|
Height="20" Grid.ColumnSpan="2" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</controls:MetroWindow>
|
</controls:MetroWindow>
|
||||||
Loading…
x
Reference in New Issue
Block a user