1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Pre-refactor commit

This commit is contained in:
SpoinkyNL 2016-05-15 23:13:31 +02:00
parent 8cb783f5f8
commit bbbbad7504
13 changed files with 234 additions and 96 deletions

View File

@ -451,6 +451,7 @@
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
<Compile Include="Modules\Games\RocketLeague\RocketLeagueViewModel.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\LayerKeyboardViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\LayerConditionViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\LayerDynamicPropertiesViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\LayerEditorViewModel.cs" />
@ -490,6 +491,9 @@
<Compile Include="Modules\Games\Witcher3\Witcher3View.xaml.cs">
<DependentUpon>Witcher3View.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LayerEditor\LayerKeyboardView.xaml.cs">
<DependentUpon>LayerKeyboardView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LayerEditor\LayerConditionView.xaml.cs">
<DependentUpon>LayerConditionView.xaml</DependentUpon>
</Compile>
@ -499,6 +503,9 @@
<Compile Include="Views\LayerEditor\LayerEditorView.xaml.cs">
<DependentUpon>LayerEditorView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LayerEditor\LayerMouseView.xaml.cs">
<DependentUpon>LayerMouseView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\OverlaysView.xaml.cs">
<DependentUpon>OverlaysView.xaml</DependentUpon>
</Compile>
@ -666,6 +673,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\LayerEditor\LayerKeyboardView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\LayerEditor\LayerConditionView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -678,6 +689,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\LayerEditor\LayerMouseView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\OverlaysView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -27,7 +27,7 @@ namespace Artemis.Models.Profiles
/// </summary>
public LayerPropertyType LayerPropertyType { get; set; }
internal void ApplyProperty<T>(IGameDataModel data, LayerPropertiesModel userProps, LayerPropertiesModel props)
internal void ApplyProperty(IGameDataModel data, LayerPropertiesModel userProps, LayerPropertiesModel props)
{
if (LayerPropertyType == LayerPropertyType.PercentageOf)
Apply(props, userProps, data, int.Parse(PercentageSource));

View File

@ -100,7 +100,7 @@ namespace Artemis.Models.Profiles
if (preview)
return;
foreach (var dynamicProperty in LayerProperties)
dynamicProperty.ApplyProperty<T>(dataModel, UserProps, CalcProps);
dynamicProperty.ApplyProperty(dataModel, UserProps, CalcProps);
}
public void Reorder(LayerModel selectedLayer, bool moveUp)

View File

@ -1,8 +1,10 @@
using System.Drawing;
using System;
using System.Drawing;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities.GameState;
using Newtonsoft.Json;
using Ninject.Extensions.Logging;
namespace Artemis.Modules.Games.CounterStrike
{
@ -17,6 +19,7 @@ namespace Artemis.Modules.Games.CounterStrike
Initialized = false;
}
public ILogger Logger { get; set; }
public int Scale { get; set; }
public override void Dispose()
@ -61,7 +64,16 @@ namespace Artemis.Modules.Games.CounterStrike
return;
// Parse the JSON
GameDataModel = JsonConvert.DeserializeObject<CounterStrikeDataModel>(jsonString);
try
{
GameDataModel = JsonConvert.DeserializeObject<CounterStrikeDataModel>(jsonString);
}
catch (Exception ex)
{
Logger.Error(ex, "Failed to deserialize CS:GO JSON");
throw;
}
}
}
}

View File

@ -57,7 +57,7 @@ namespace Artemis.Utilities
public Image GetFrame(int index)
{
_gifImage.SelectActiveFrame(_dimension, index); //find the frame
return (Image) _gifImage.Clone(); //return a copy of it
return _gifImage;
}
}
}

View File

@ -6,7 +6,7 @@ using Caliburn.Micro;
namespace Artemis.ViewModels.LayerEditor
{
public class LayerDynamicPropertiesViewModel : Screen
public class LayerDynamicPropertiesViewModel : PropertyChangedBase
{
private readonly LayerModel _layer;
private readonly string _property;

View File

@ -26,6 +26,7 @@ namespace Artemis.ViewModels.LayerEditor
private LayerType _layerType;
private LayerModel _proposedLayer;
private LayerPropertiesModel _proposedProperties;
private LayerKeyboardViewModel _layerKeyboardViewModel;
public LayerEditorViewModel(IGameDataModel gameDataModel, KeyboardProvider activeKeyboard, LayerModel layer)
{
@ -161,10 +162,27 @@ namespace Artemis.ViewModels.LayerEditor
return;
Layer.LayerType = LayerType;
if (LayerType != LayerType.Keyboard && LayerType != LayerType.KeyboardGif)
LayerKeyboardViewModel = null;
if ((LayerType == LayerType.Keyboard || LayerType == LayerType.KeyboardGif) && LayerKeyboardViewModel == null)
LayerKeyboardViewModel = new LayerKeyboardViewModel();
NotifyOfPropertyChange(() => KeyboardGridIsVisible);
NotifyOfPropertyChange(() => GifGridIsVisible);
}
public LayerKeyboardViewModel LayerKeyboardViewModel
{
get { return _layerKeyboardViewModel; }
set
{
if (Equals(value, _layerKeyboardViewModel)) return;
_layerKeyboardViewModel = value;
NotifyOfPropertyChange(() => LayerKeyboardViewModel);
}
}
public void AddCondition()
{
var condition = new LayerConditionModel();

View File

@ -0,0 +1,8 @@
using Caliburn.Micro;
namespace Artemis.ViewModels.LayerEditor
{
public class LayerKeyboardViewModel : PropertyChangedBase
{
}
}

View File

@ -98,103 +98,17 @@
Content="Advanced" Width="97" VerticalAlignment="Bottom" />
<!-- Advanced settings - Keyboard -->
<Grid x:Name="KeyboardGridIsVisible" Grid.Row="5" Grid.ColumnSpan="4" Grid.Column="0">
<!-- Colors -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,13,10,0" FontSize="13.333" Text="Color(s):"
VerticalAlignment="Top" Height="18" />
<Border Grid.Row="0" Grid.Column="1" Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
<ncore:ColorBox Brush="{Binding Path=ProposedProperties.Brush, Mode=TwoWay}" Height="24" />
</Border>
<ContentControl Grid.Row="5" Grid.ColumnSpan="4" Grid.Column="0" x:Name="LayerAdvancedKeyboardViewModel" />
<!-- ContainedBrush -->
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Contained colors:"
VerticalAlignment="Center" Height="18" />
<controls:ToggleSwitch IsChecked="{Binding Path=ProposedProperties.ContainedBrush, Mode=TwoWay}"
Grid.Row="0"
Grid.Column="3" OnLabel="Yes" OffLabel="No" Margin="10,1,5,1"
VerticalAlignment="Center"
Height="36" />
<!-- Animation -->
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
VerticalAlignment="Center"
Height="18" />
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Source={StaticResource AnimationEnumValues}}"
Margin="10,10,10,0" SelectedItem="{Binding Path=ProposedProperties.Animation}"
VerticalAlignment="Top" Height="22">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- Animation Speed -->
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="1" Grid.Column="3" VerticalAlignment="Center"
TickPlacement="None" TickFrequency="0.05"
Value="{Binding Path=ProposedProperties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
SmallChange="1" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
<!-- Dynamic -->
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
<!-- Dynamic property views -->
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="HeightProperties" />
<ContentControl Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" x:Name="WidthProperties" />
<ContentControl Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
</Grid>
<!-- Advanced settings - Keyboard -->
<Grid x:Name="GifGridIsVisible" Grid.Row="5" Grid.ColumnSpan="4" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,13,10,0" FontSize="13.333" Text="GIF file:"
VerticalAlignment="Top" Height="18" />
<Grid Grid.Row="0" Grid.Column="1" ColumnSpan="3" Margin="5,10,10,0" VerticalAlignment="Top">
<TextBox Height="23" TextWrapping="Wrap" Margin="5,0,30,0"
Text="{Binding Path=Layer.GifFile, Mode=TwoWay}" />
<Button x:Name="BrowseGif" Content="..." RenderTransformOrigin="-0.039,-0.944"
HorizontalAlignment="Right" Width="25" Style="{DynamicResource SquareButtonStyle}" Height="25" />
</Grid>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,13,10,0" FontSize="13.333"
Foreground="{DynamicResource HighlightBrush}"
Text="Note: It is recommended to use very tiny gifs (25x7 per example). Any higher will degrade performance without any noticeable quality difference."
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" />
</Grid>
<!-- Advanced settings - Mouse -->
<ContentControl Grid.Row="5" Grid.ColumnSpan="4" Grid.Column="0" x:Name="MouseProperties" />
<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,20"
Height="30" />
<Button Grid.Row="6" Grid.Column="1" x:Name="PreSelect" Content="Reset" VerticalAlignment="Bottom"
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,0,0,20"
Height="30" />
</Grid>
</controls:MetroWindow>

View File

@ -0,0 +1,103 @@
<UserControl x:Class="Artemis.Views.LayerEditor.LayerKeyboardView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<!-- Colors -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<!-- Animation -->
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
VerticalAlignment="Center"
Height="18" />
<ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Source={StaticResource AnimationEnumValues}}"
Margin="10,10,10,0" SelectedItem="{Binding Path=ProposedProperties.Animation}"
VerticalAlignment="Top" Height="22">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- Animation Speed -->
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
TickPlacement="None" TickFrequency="0.05"
Value="{Binding Path=ProposedProperties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
<!-- ClippingType -->
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10, 13, 10, 10" FontSize="13.333" Text="Clipping type:"
VerticalAlignment="Center" Height="23"/>
<controls:ToggleSwitch IsChecked="{Binding Path=ProposedProperties.ContainedBrush, Mode=TwoWay}"
Grid.Row="1"
Grid.Column="1" OnLabel="Contain" OffLabel="Cut-off" Margin="10,1,5,1"
VerticalAlignment="Center"
Height="36" />
<!-- Colors -->
<StackPanel Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Orientation="Horizontal" x:Name="KeyboardGridIsVisible">
<TextBlock Margin="10,13,10,0" FontSize="13.333" Text="Color(s):"
VerticalAlignment="Top" Height="18" Width="130" />
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
<ncore:ColorBox Brush="{Binding Path=ProposedProperties.Brush, Mode=TwoWay}" Height="24" Width="134" />
</Border>
</StackPanel>
<!-- GIF settings -->
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" x:Name="GifGridIsVisible">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,5,10,0" FontSize="13.333" Text="GIF file:"
VerticalAlignment="Top" Height="18" />
<Grid Grid.Row="0" Grid.Column="1" ColumnSpan="3" Margin="5,2,10,0" VerticalAlignment="Top">
<TextBox Height="23" TextWrapping="Wrap" Margin="5,0,30,0"
Text="{Binding Path=Layer.GifFile, Mode=TwoWay}" />
<Button x:Name="BrowseGif" Content="..." RenderTransformOrigin="-0.039,-0.944"
HorizontalAlignment="Right" Width="25" Style="{DynamicResource SquareButtonStyle}" Height="25" />
</Grid>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
Foreground="{DynamicResource HighlightBrush}"
Text="Note: It is recommended to use very tiny gifs (25x7 per example, for size per keyboard see FAQ). Any higher will degrade performance without any noticeable quality difference."
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" />
</Grid>
<!-- Dynamic -->
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
<!-- Dynamic property views -->
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="HeightProperties" />
<ContentControl Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" x:Name="WidthProperties" />
<ContentControl Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
</Grid>
</UserControl>

View File

@ -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
{
/// <summary>
/// Interaction logic for LayerKeyboardView.xaml
/// </summary>
public partial class LayerKeyboardView : UserControl
{
public LayerKeyboardView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,12 @@
<UserControl x:Class="Artemis.Views.LayerEditor.LayerMouseView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:Artemis.Views.LayerEditor"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</UserControl>

View File

@ -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
{
/// <summary>
/// Interaction logic for LayerMouseView.xaml
/// </summary>
public partial class LayerMouseView : UserControl
{
public LayerMouseView()
{
InitializeComponent();
}
}
}