Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-Write Payday 2 Effects - Fixes #2133 & #1160 #2134

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions Project-Aurora/Project-Aurora/Profiles/Payday 2/Control_PD2.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,13 @@
<TabControl>
<TabItem Header="Overview for Payday 2">
<Grid>
<TextBlock Margin="10,30,0,0" VerticalAlignment="Top" TextWrapping="Wrap" HorizontalAlignment="Left" Width="770"><Run Text="In order for Payday 2 support to work, you have to install the BLT Lua hook"/><Run Text=", BeardLib"/><Run Text=" and the GSI mod for Payday 2. Press the &quot;Get BLT Hook&quot; button to be taken to the BLT download page"/><Run Text=". Press the &quot;Get"/><Run Text=" BeardLib"/><Run Text="&quot;"/><Run Text=" button to be taken to its github page where it can be downloaded"/><Run Text=". Afterwards, you can press &quot;Install GSI for Payday 2&quot; to automatically install the GSI mod. (You need to have the BLT hook for GSI mod to function)"/></TextBlock>
<Button x:Name="get_hook_button" Content="Get BLT Hook" HorizontalAlignment="Left" Margin="10,83,0,0" VerticalAlignment="Top" Click="get_hook_button_Click"/>
<Button x:Name="get_lib_button" Content="Get BeardLib" HorizontalAlignment="Left" Margin="91,83,0,0" VerticalAlignment="Top" Click="get_lib_button_Click"/>
<Button x:Name="install_mod_button" Content="Install GSI for Payday 2" HorizontalAlignment="Left" Margin="10,108,0,0" VerticalAlignment="Top" Click="install_mod_button_Click" Width="153"/>
<TextBlock Margin="10,30,0,0" VerticalAlignment="Top" TextWrapping="Wrap" HorizontalAlignment="Left" Width="770">Payday 2 requires the following mods to function: SuperBLT (base mod), BeardLib (base mod extender), GSI (Aurora GSI integration).<LineBreak></LineBreak><LineBreak></LineBreak>To install, firstly click <Bold>Get SuperBLT</Bold> and follow the website's instructions to install.<LineBreak></LineBreak>Then, click <Bold>Get BeardLib</Bold> and follow the instructions to install.<LineBreak></LineBreak>Finally, click <Bold>Install GSI for Payday 2</Bold> and Aurora will install the GSI mod.</TextBlock>
<Button x:Name="get_hook_button" Content="Get SuperBLT" HorizontalAlignment="Left" Margin="10,120,0,0" VerticalAlignment="Top" Click="get_hook_button_Click" RenderTransformOrigin="0.515,2.264" Width="80"/>
<Button x:Name="get_lib_button" Content="Get BeardLib" HorizontalAlignment="Left" Margin="95,120,0,0" VerticalAlignment="Top" Click="get_lib_button_Click" Width="75"/>
<Button x:Name="install_mod_button" Content="Install GSI for Payday 2" HorizontalAlignment="Left" Margin="10,145,0,0" VerticalAlignment="Top" Click="install_mod_button_Click" Width="160"/>
<CheckBox x:Name="game_enabled" Content="Enable Aurora to provide lighting effects with Payday 2" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Checked="game_enabled_Checked" Unchecked="game_enabled_Checked"/>
</Grid>
</TabItem>
<TabItem Header="Preview">
<Grid>
<Label Content="Level Phase:" HorizontalAlignment="Left" Margin="10,41,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="preview_levelphase" HorizontalAlignment="Left" Margin="90,43,0,0" VerticalAlignment="Top" Width="200" IsSynchronizedWithCurrentItem="True" SelectedIndex="0" ItemsSource="{u:EnumToItemsSource {x:Type e:LevelPhase}}" DisplayMemberPath="Text" SelectedValuePath="Value" SelectionChanged="preview_levelphase_SelectionChanged"/>
<Label Content="Health:" HorizontalAlignment="Left" Margin="10,103,0,0" VerticalAlignment="Top"/>
<Slider x:Name="preview_health_slider" HorizontalAlignment="Left" Margin="62,107,0,0" VerticalAlignment="Top" Width="114" Maximum="100" SmallChange="1" ValueChanged="preview_health_slider_ValueChanged"/>
<Label x:Name="preview_health_amount" Content="0%" HorizontalAlignment="Left" Margin="181,103,0,0" VerticalAlignment="Top"/>
<Label Content="Ammo:" HorizontalAlignment="Left" Margin="10,134,0,0" VerticalAlignment="Top"/>
<Slider x:Name="preview_ammo_slider" HorizontalAlignment="Left" Margin="62,138,0,0" VerticalAlignment="Top" Width="114" Maximum="100" SmallChange="1" ValueChanged="preview_ammo_slider_ValueChanged"/>
<Label x:Name="preview_ammo_amount" Content="0%" HorizontalAlignment="Left" Margin="181,134,0,0" VerticalAlignment="Top"/>
<Label Content="Suspicion:" HorizontalAlignment="Left" Margin="10,165,0,0" VerticalAlignment="Top"/>
<Slider x:Name="preview_suspicion_slider" HorizontalAlignment="Left" Margin="78,169,0,0" VerticalAlignment="Top" Width="98" Maximum="100" SmallChange="1" ValueChanged="preview_suspicion_slider_ValueChanged"/>
<Label x:Name="preview_suspicion_amount" Content="0%" HorizontalAlignment="Left" Margin="181,165,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.692,3.115"/>
<Label Content="Player State:" HorizontalAlignment="Left" Margin="10,72,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="preview_playerstate" HorizontalAlignment="Left" Margin="90,74,0,0" VerticalAlignment="Top" Width="200" IsSynchronizedWithCurrentItem="True" SelectedIndex="0" ItemsSource="{u:EnumToItemsSource {x:Type e:PlayerState}}" DisplayMemberPath="Text" SelectedValuePath="Value" SelectionChanged="preview_playerstate_SelectionChanged"/>
<CheckBox x:Name="preview_swansong" Content="Is player in Swan Song" HorizontalAlignment="Left" Margin="13,196,0,0" VerticalAlignment="Top" Checked="preview_swansong_Checked" Unchecked="preview_swansong_Checked"/>
<Label Content="Flashbang amount:" HorizontalAlignment="Left" Margin="10,216,0,0" VerticalAlignment="Top"/>
<Slider x:Name="preview_flashbang_slider" HorizontalAlignment="Left" Margin="126,222,0,0" VerticalAlignment="Top" Width="98" Maximum="100" SmallChange="1" ValueChanged="preview_flashbang_slider_ValueChanged"/>
<Label x:Name="preview_flashbang_amount" Content="0%" HorizontalAlignment="Left" Margin="229,218,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.692,3.115"/>
<Label Content="Game State:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="preview_gamestate" HorizontalAlignment="Left" Margin="90,12,0,0" VerticalAlignment="Top" Width="200" IsSynchronizedWithCurrentItem="True" SelectedIndex="0" ItemsSource="{u:EnumToItemsSource {x:Type e:GameStates}}" DisplayMemberPath="Text" SelectedValuePath="Value" SelectionChanged="preview_gamestate_SelectionChanged"/>
</Grid>
</TabItem>
</TabControl>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void game_enabled_Checked(object sender, RoutedEventArgs e)

private void get_hook_button_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"http://paydaymods.com/download/"));
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"https://superblt.znix.xyz/#superblt"));
}

private void install_mod_button_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -92,83 +92,9 @@ private void install_mod_button_Click(object sender, RoutedEventArgs e)
}
}

private void preview_gamestate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (IsLoaded)
{
(profile_manager.Config.Event._game_state as GameState_PD2).Game.State = (GSI.Nodes.GameStates)preview_gamestate.SelectedValue;
}
}

private void preview_levelphase_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (IsLoaded)
{
(profile_manager.Config.Event._game_state as GameState_PD2).Level.Phase = (GSI.Nodes.LevelPhase)preview_levelphase.SelectedValue;
}
}

private void preview_playerstate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (IsLoaded)
{
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.State = (GSI.Nodes.PlayerState)preview_playerstate.SelectedValue;
}
}

private void preview_health_slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
int hp_val = (int)this.preview_health_slider.Value;
if (this.preview_health_amount is Label)
{
this.preview_health_amount.Content = hp_val + "%";
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.Health.Current = hp_val;
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.Health.Max = 100;
}
}

private void preview_ammo_slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
int ammo_val = (int)this.preview_ammo_slider.Value;
if (this.preview_ammo_amount is Label)
{
this.preview_ammo_amount.Content = ammo_val + "%";
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.Weapons.SelectedWeapon.Current_Clip = ammo_val;
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.Weapons.SelectedWeapon.Max_Clip = 100;
}
}

private void preview_suspicion_slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
float susp_val = (float)this.preview_suspicion_slider.Value;
if (this.preview_suspicion_amount is Label)
{
this.preview_suspicion_amount.Content = (int)susp_val + "%";
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.SuspicionAmount = susp_val / 100.0f;
}
}

private void preview_flashbang_slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
float flash_val = (float)this.preview_flashbang_slider.Value;
if (this.preview_flashbang_amount is Label)
{
this.preview_flashbang_amount.Content = (int)flash_val + "%";
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.FlashAmount = flash_val / 100.0f;
}
}

private void preview_swansong_Checked(object sender, RoutedEventArgs e)
{
if (IsLoaded && sender is CheckBox && (sender as CheckBox).IsChecked.HasValue)
{
(profile_manager.Config.Event._game_state as GameState_PD2).Players.LocalPlayer.IsSwanSong = (sender as CheckBox).IsChecked.Value;
}
}

private void get_lib_button_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"https://github.com/simon-wh/PAYDAY-2-BeardLib"));
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"https://modworkshop.net/mod/14924"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<UserControl
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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
x:Class="Aurora.Profiles.Payday_2.Layers.Control_PD2MaskOnAnimationLayer"
mc:Ignorable="d" Loaded="UserControl_Loaded">
<Grid/>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Aurora.Settings;
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 Aurora.Profiles.Payday_2.Layers
{
/// <summary>
/// Interaction logic for Control_WinningTeamLayer.xaml
/// </summary>
public partial class Control_PD2MaskOnAnimationLayer : UserControl
{
public Control_PD2MaskOnAnimationLayer()
{
InitializeComponent();
}

public Control_PD2MaskOnAnimationLayer(PD2MaskOnAnimationLayerHandler datacontext)
{
InitializeComponent();

this.DataContext = datacontext;
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.Loaded -= UserControl_Loaded;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Aurora.Profiles.Payday_2.Layers
{
[Obsolete]
public class PD2BackgroundLayerHandlerProperties : LayerHandlerProperties2Color<PD2BackgroundLayerHandlerProperties>
{
public Color? _AmbientColor { get; set; }
Expand Down Expand Up @@ -100,6 +101,7 @@ public override void Default()

}

[Obsolete]
public class PD2BackgroundLayerHandler : LayerHandler<PD2BackgroundLayerHandlerProperties>
{
private float no_return_flashamount = 1.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Aurora.Profiles.Payday_2.Layers
{
[Obsolete]
public class PD2FlashbangLayerHandlerProperties : LayerHandlerProperties2Color<PD2FlashbangLayerHandlerProperties>
{
public Color? _FlashbangColor { get; set; }
Expand All @@ -37,6 +38,7 @@ public override void Default()

}

[Obsolete]
public class PD2FlashbangLayerHandler : LayerHandler<PD2FlashbangLayerHandlerProperties>
{
protected override UserControl CreateControl()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using Aurora.EffectsEngine;
using Aurora.EffectsEngine.Animations;
using Aurora.Profiles.CSGO.GSI;
using Aurora.Profiles.CSGO.GSI.Nodes;
using Aurora.Profiles.Payday_2.GSI;
using Aurora.Profiles.Payday_2.GSI.Nodes;
using Aurora.Settings;
using Aurora.Settings.Layers;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace Aurora.Profiles.Payday_2.Layers
{
public class PD2MaskOnAnimationLayerHandler : LayerHandler
{
private readonly AnimationTrack[] tracks =
{
new AnimationTrack("Track 0", 1.0f, 0.0f)
};

private long previoustime = 0;
private long currenttime = 0;

private static float effectKeyframe = 0.0f;
private const float effectAnimationTime = 1.0f;

private bool showAnimation = false;
private bool animationRun = false;

protected override UserControl CreateControl()
{
return new Control_PD2MaskOnAnimationLayer(this);
}

public override EffectLayer Render(IGameState state)
{
previoustime = currenttime;
currenttime = Utils.Time.GetMillisecondsSinceEpoch();

EffectLayer effectLayer = new EffectLayer("PD2 - Mask On Animation");
AnimationMix animationMix = new AnimationMix();

if (state is GameState_PD2 gameState_PD2)
{
if (animationRun && (gameState_PD2.LocalPlayer.State == PlayerState.Civilian || gameState_PD2.LocalPlayer.State == PlayerState.Undefined || gameState_PD2.LocalPlayer.State == PlayerState.Mask_Off))
{
animationRun = false;
}

if ((gameState_PD2.LocalPlayer.State == PlayerState.Standard) && !animationRun && !showAnimation)
{
this.SetTracks(PD2Colours.PlayerState_Standard);
animationMix.Clear();
showAnimation = true;
}

if (showAnimation)
{
animationMix = new AnimationMix(tracks);

effectLayer.Fill(PD2Colours.PlayerState_Civilian);
animationMix.Draw(effectLayer.GetGraphics(), effectKeyframe);
effectKeyframe += (currenttime - previoustime) / 1000.0f;

if (effectKeyframe >= effectAnimationTime)
{
showAnimation = false;
animationRun = true;
effectKeyframe = 0;
}
}
}

return effectLayer;
}

public override void SetApplication(Application profile)
{
base.SetApplication(profile);
}

private void SetTracks(Color color)
{
for (int i = 0; i < tracks.Length; i++)
{
tracks[i].SetFrame(
0.0f,
new AnimationFilledCircle(
(int)(Effects.canvas_width_center * 0.9),
Effects.canvas_height_center,
0,
PD2Colours.GameTheme,
4)
);

tracks[i].SetFrame(
1.0f,
new AnimationFilledCircle(
(int)(Effects.canvas_width_center * 0.9),
Effects.canvas_height_center,
Effects.canvas_biggest / 2.0f,
PD2Colours.GameTheme,
4)
);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Aurora.Profiles.Payday_2.Layers
{
[Obsolete]
public class PD2StatesLayerHandlerProperties : LayerHandlerProperties2Color<PD2StatesLayerHandlerProperties>
{
public Color? _DownedColor { get; set; }
Expand Down Expand Up @@ -58,6 +59,7 @@ public override void Default()

}

[Obsolete]
public class PD2StatesLayerHandler : LayerHandler<PD2StatesLayerHandlerProperties>
{
protected override UserControl CreateControl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public PD2()
{
AllowLayer<PD2BackgroundLayerHandler>();
AllowLayer<PD2FlashbangLayerHandler>();
AllowLayer<PD2StatesLayerHandler>();
AllowLayer<PD2StatesLayerHandler>();
AllowLayer<PD2MaskOnAnimationLayerHandler>();
}
}
}
Loading