mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Updated Rocket League to use the profile editor
This commit is contained in:
parent
3e47ffeff7
commit
ddc63473a3
@ -1,12 +1,9 @@
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.GameState;
|
||||
using Newtonsoft.Json;
|
||||
using Color = System.Windows.Media.Color;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
@ -68,8 +65,6 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
if (!jsonString.Contains("Counter-Strike: Global Offensive"))
|
||||
return;
|
||||
|
||||
|
||||
Debug.WriteLine("Got data");
|
||||
// Parse the JSON
|
||||
GameDataModel = JsonConvert.DeserializeObject<CounterStrikeDataModel>(jsonString);
|
||||
}
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Models.Interfaces;
|
||||
|
||||
namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
internal class RocketLeagueDataModel : IGameDataModel
|
||||
public class RocketLeagueDataModel : IGameDataModel
|
||||
{
|
||||
public int Boost { get; set; }
|
||||
public List<GeneralHelpers.PropertyCollection> Properties { get; }
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
using Artemis.Utilities.Memory;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -17,13 +12,8 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
public class RocketLeagueModel : GameModel
|
||||
{
|
||||
private int _boostAmount;
|
||||
private bool _boostGrowing;
|
||||
private KeyboardRectangle _boostRect;
|
||||
private bool _contextualColor;
|
||||
private Memory _memory;
|
||||
private GamePointersCollection _pointer;
|
||||
private int _previousBoost;
|
||||
|
||||
public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager)
|
||||
{
|
||||
@ -49,105 +39,44 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
Initialized = false;
|
||||
|
||||
_contextualColor = Settings.ContextualColor;
|
||||
|
||||
_boostRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
|
||||
{
|
||||
ColorHelpers.ToDrawingColor(Settings.MainColor),
|
||||
ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
|
||||
}, LinearGradientMode.Horizontal);
|
||||
|
||||
Updater.GetPointers();
|
||||
_pointer = JsonConvert.DeserializeObject<GamePointersCollection>(Offsets.Default.RocketLeague);
|
||||
|
||||
var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName);
|
||||
_memory = new Memory(tempProcess);
|
||||
GameDataModel = new RocketLeagueDataModel();
|
||||
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (_boostGrowing)
|
||||
return;
|
||||
if (_memory == null)
|
||||
if (Profile == null || GameDataModel == null || _memory == null)
|
||||
return;
|
||||
|
||||
var offsets = _pointer.GameAddresses.First(ga => ga.Description == "Boost").ToString();
|
||||
var boostAddress = _memory.GetAddress("\"RocketLeague.exe\"" + offsets);
|
||||
var boostFloat = _memory.ReadFloat(boostAddress)*100/3;
|
||||
|
||||
_previousBoost = _boostAmount;
|
||||
_boostAmount = (int) Math.Ceiling(boostFloat);
|
||||
((RocketLeagueDataModel) GameDataModel).Boost = (int) Math.Ceiling(boostFloat);
|
||||
|
||||
// Take care of any reading errors resulting in an OutOfMemory on draw
|
||||
if (_boostAmount < 0)
|
||||
_boostAmount = 0;
|
||||
if (_boostAmount > 100)
|
||||
_boostAmount = 100;
|
||||
if (((RocketLeagueDataModel) GameDataModel).Boost < 0)
|
||||
((RocketLeagueDataModel) GameDataModel).Boost = 0;
|
||||
if (((RocketLeagueDataModel) GameDataModel).Boost > 100)
|
||||
((RocketLeagueDataModel) GameDataModel).Boost = 100;
|
||||
|
||||
_boostRect.Width =
|
||||
(int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
|
||||
|
||||
if (_contextualColor)
|
||||
{
|
||||
if (_boostAmount < 33)
|
||||
_boostRect.Colors = new List<Color> {Color.Red};
|
||||
else if (_boostAmount >= 33 && _boostAmount < 66)
|
||||
_boostRect.Colors = new List<Color> {Color.Yellow};
|
||||
else if (_boostAmount >= 66)
|
||||
_boostRect.Colors = new List<Color> {Color.Lime};
|
||||
}
|
||||
|
||||
Task.Run(() => GrowIfHigher());
|
||||
}
|
||||
|
||||
private void GrowIfHigher()
|
||||
{
|
||||
if (_boostAmount <= _previousBoost || _boostGrowing)
|
||||
return;
|
||||
|
||||
_boostGrowing = true;
|
||||
const int amountOfSteps = 6;
|
||||
|
||||
var difference = _boostAmount - _previousBoost;
|
||||
var differenceStep = difference/amountOfSteps;
|
||||
var differenceStepRest = difference%amountOfSteps;
|
||||
_boostAmount = _previousBoost;
|
||||
_boostRect.Width =
|
||||
(int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
|
||||
|
||||
for (var i = 0; i < amountOfSteps; i++)
|
||||
{
|
||||
if (differenceStepRest > 0)
|
||||
{
|
||||
differenceStepRest -= 1;
|
||||
_boostAmount += 1;
|
||||
_boostRect.Width =
|
||||
(int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
|
||||
}
|
||||
_boostAmount += differenceStep;
|
||||
_boostRect.Width =
|
||||
(int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
|
||||
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
_boostGrowing = false;
|
||||
foreach (var layerModel in Profile.Layers)
|
||||
layerModel.Update<RocketLeagueDataModel>(GameDataModel);
|
||||
}
|
||||
|
||||
public override Bitmap GenerateBitmap()
|
||||
{
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
if (_boostRect == null)
|
||||
if (Profile == null || GameDataModel == null)
|
||||
return null;
|
||||
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.Clear(Color.Transparent);
|
||||
_boostRect.Draw(g);
|
||||
}
|
||||
return bitmap;
|
||||
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
||||
return Profile.GenerateBitmap<RocketLeagueDataModel>(keyboardRect, GameDataModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,46 +40,8 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Main color -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Main boost display color
|
||||
</TextBlock>
|
||||
<xctk:ColorPicker x:Name="MainColor"
|
||||
SelectedColor="{Binding Path=GameSettings.MainColor, Mode=TwoWay}"
|
||||
Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
|
||||
|
||||
<!-- Secondary color -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Secondary boost display color
|
||||
</TextBlock>
|
||||
<xctk:ColorPicker x:Name="SecondaryColor"
|
||||
SelectedColor="{Binding Path=GameSettings.SecondaryColor, Mode=TwoWay}"
|
||||
Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
|
||||
|
||||
<!-- Secondary color -->
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Color bar according to boost amount
|
||||
</TextBlock>
|
||||
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ContextualColor, Mode=TwoWay}"
|
||||
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
|
||||
Margin="0,0,-5,0" Width="114" />
|
||||
|
||||
<!-- Info text -->
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
|
||||
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
|
||||
MaxWidth="510" TextAlignment="Justify">
|
||||
Tip: To find a color combination you like, start an exhibition match, pickup 100 boost and play around with the colors.
|
||||
They'll appear on your keyboard immediately! Once you're satisfied don't forget to click save changes.
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="VersionText" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center"
|
||||
Margin="0,8"
|
||||
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
|
||||
Foreground="{DynamicResource HighlightBrush}" MaxWidth="510" TextAlignment="Justify" />
|
||||
<!-- Profile editor -->
|
||||
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" Margin="0,0,-30,0" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
using Artemis.Managers;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Memory;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -21,10 +23,15 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
// Create effect model and add it to MainManager
|
||||
GameModel = new RocketLeagueModel(mainManager, (RocketLeagueSettings) GameSettings);
|
||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||
|
||||
SetVersionText();
|
||||
|
||||
ProfileEditor = new ProfileEditorViewModel<RocketLeagueDataModel>(MainManager, GameModel);
|
||||
ProfileEditor.PropertyChanged += ProfileUpdater;
|
||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
||||
}
|
||||
|
||||
public ProfileEditorViewModel<RocketLeagueDataModel> ProfileEditor { get; set; }
|
||||
|
||||
public static string Name => "Rocket League";
|
||||
|
||||
public string VersionText
|
||||
@ -40,6 +47,12 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
|
||||
public RocketLeagueModel RocketLeagueModel { get; set; }
|
||||
|
||||
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "SelectedProfile")
|
||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
||||
}
|
||||
|
||||
private void SetVersionText()
|
||||
{
|
||||
if (!General.Default.EnablePointersUpdate)
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
</TextBlock>
|
||||
|
||||
<!-- Profile editor -->
|
||||
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" />
|
||||
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" Margin="0,0,-30,0" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
|
||||
@ -135,6 +135,7 @@ namespace Artemis.Utilities
|
||||
_layerModel.CalcProps.Animation == LayerAnimation.SlideRight ||
|
||||
_layerModel.CalcProps.Animation == LayerAnimation.SlideUp)
|
||||
{
|
||||
// TODO: if (_layerModel.CalcProps.ContainedBrush)
|
||||
c.PushClip(new RectangleGeometry(_rectangle));
|
||||
c.DrawRectangle(brush, null, _firstRect);
|
||||
c.DrawRectangle(brush, null, _secondRect);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Managers;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
private string _name;
|
||||
private GeneralHelpers.PropertyCollection _selectedSource;
|
||||
private GeneralHelpers.PropertyCollection _selectedTarget;
|
||||
private bool _sourcesIsVisible;
|
||||
private bool _userSourceIsVisible;
|
||||
private LayerPropertyType _layerPropertyType;
|
||||
|
||||
public LayerDynamicPropertiesViewModel(string property,
|
||||
BindableCollection<GeneralHelpers.PropertyCollection> dataModelProps, LayerModel layer)
|
||||
@ -37,6 +40,21 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
Sources.AddRange(dataModelProps.Where(p => p.Type == "Int32"));
|
||||
|
||||
PropertyChanged += OnPropertyChanged;
|
||||
|
||||
SelectedTarget = dataModelProps.FirstOrDefault(p => p.Path == LayerDynamicPropertiesModel.GameProperty);
|
||||
SelectedSource = dataModelProps.FirstOrDefault(p => p.Path == LayerDynamicPropertiesModel.PercentageSource);
|
||||
LayerPropertyType = LayerDynamicPropertiesModel.LayerPropertyType;
|
||||
}
|
||||
|
||||
public LayerPropertyType LayerPropertyType
|
||||
{
|
||||
get { return _layerPropertyType; }
|
||||
set
|
||||
{
|
||||
if (value == _layerPropertyType) return;
|
||||
_layerPropertyType = value;
|
||||
NotifyOfPropertyChange(() => LayerPropertyType);
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
@ -87,17 +105,40 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the underlying model
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public bool SourcesIsVisible
|
||||
{
|
||||
get { return _sourcesIsVisible; }
|
||||
set
|
||||
{
|
||||
if (value == _sourcesIsVisible) return;
|
||||
_sourcesIsVisible = value;
|
||||
NotifyOfPropertyChange(() => SourcesIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
public bool UserSourceIsVisible
|
||||
{
|
||||
get { return _userSourceIsVisible; }
|
||||
set
|
||||
{
|
||||
if (value == _userSourceIsVisible) return;
|
||||
_userSourceIsVisible = value;
|
||||
NotifyOfPropertyChange(() => UserSourceIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "SelectedTarget")
|
||||
LayerDynamicPropertiesModel.GameProperty = SelectedTarget.Path;
|
||||
if (e.PropertyName == "SelectedSource")
|
||||
LayerDynamicPropertiesModel.PercentageSource = SelectedSource.Path;
|
||||
if (e.PropertyName == "LayerPropertyType")
|
||||
{
|
||||
LayerDynamicPropertiesModel.LayerPropertyType = LayerPropertyType;
|
||||
UserSourceIsVisible = (LayerPropertyType == LayerPropertyType.PercentageOf);
|
||||
SourcesIsVisible = (LayerPropertyType == LayerPropertyType.PercentageOfProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@
|
||||
xmlns:utilities="clr-namespace:Artemis.Utilities"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:profileEnumerations="clr-namespace:Artemis.Models.Profiles"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="40" d:DesignWidth="500">
|
||||
|
||||
@ -49,7 +50,7 @@
|
||||
</ComboBox>
|
||||
|
||||
<!-- Dynamic type -->
|
||||
<ComboBox SelectedItem="{Binding Path=LayerDynamicPropertiesModel.LayerPropertyType}" Grid.Column="2"
|
||||
<ComboBox SelectedItem="{Binding Path=LayerPropertyType}" Grid.Column="2"
|
||||
ItemsSource="{Binding Source={StaticResource DynamicPropertyValues}}"
|
||||
Margin="10,0" VerticalAlignment="Center" Height="22">
|
||||
<ComboBox.ItemTemplate>
|
||||
@ -59,22 +60,28 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<!-- PercentageOf property -->
|
||||
<ComboBox x:Name="Sources" Grid.Column="3" Margin="10,0" MaxDropDownHeight="125"
|
||||
VerticalAlignment="Center" Height="22">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid MinWidth="522">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding Path=Display}" HorizontalAlignment="Left" />
|
||||
<TextBlock Grid.Column="1" FontWeight="Bold" Text="{Binding Path=DisplayType}"
|
||||
HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<!-- PercentageOfProperty -->
|
||||
<StackPanel Grid.Column="3" x:Name="SourcesIsVisible" VerticalAlignment="Center">
|
||||
<ComboBox x:Name="Sources" Margin="10,0" MaxDropDownHeight="125" Height="22">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid MinWidth="522">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding Path=Display}" HorizontalAlignment="Left" />
|
||||
<TextBlock Grid.Column="1" FontWeight="Bold" Text="{Binding Path=DisplayType}"
|
||||
HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<!-- PercentageOf -->
|
||||
<StackPanel Grid.Column="3" x:Name="UserSourceIsVisible" VerticalAlignment="Center">
|
||||
<controls:NumericUpDown Margin="10,0" Height="22" Value="{Binding Path=LayerDynamicPropertiesModel.PercentageSource, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Loading…
x
Reference in New Issue
Block a user