forked from antonpup/Aurora
-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement auto gsi installation for payday 2
- Loading branch information
Aytackydln
committed
Sep 6, 2024
1 parent
96049bf
commit c52c008
Showing
5 changed files
with
159 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Pd2GsiUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.IO; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using AuroraRgb.Properties; | ||
using AuroraRgb.Utils.Steam; | ||
using ICSharpCode.SharpZipLib.Zip; | ||
|
||
namespace AuroraRgb.Profiles.Payday_2.GSI; | ||
|
||
public static class Pd2GsiUtils | ||
{ | ||
/// <summary> | ||
/// Installs GSI mod for Payday 2 | ||
/// </summary> | ||
/// <returns>error message if fails</returns> | ||
public static async Task<string?> InstallMod() | ||
{ | ||
var pd2Path = await SteamUtils.GetGamePathAsync(218620); | ||
|
||
if (string.IsNullOrWhiteSpace(pd2Path)) | ||
{ | ||
return "Payday 2 is not installed through Steam.\r\nCould not install the GSI mod."; | ||
} | ||
|
||
if (!Directory.Exists(pd2Path)) | ||
{ | ||
return "Payday 2 directory is not found.\r\nCould not install the GSI mod."; | ||
} | ||
|
||
if (!Directory.Exists(Path.Combine(pd2Path, "mods"))) | ||
{ | ||
return "BLT Hook was not found.\r\nCould not install the GSI mod."; | ||
} | ||
|
||
//create GSI config folder, in case game is not run with GSI mod installed | ||
var gsiConfigDir = Path.Combine(pd2Path, "GSI"); | ||
Directory.CreateDirectory(gsiConfigDir); | ||
|
||
//copy gsi config file | ||
using var gsiConfigFile = new MemoryStream(Resources.PD2_GSI); | ||
await File.WriteAllBytesAsync(Path.Combine(pd2Path, "GSI", "Aurora.xml"), gsiConfigFile.ToArray()); | ||
|
||
// extract mod | ||
await ExtractPd2Mod(pd2Path); | ||
|
||
return null; | ||
} | ||
|
||
private static async Task ExtractPd2Mod(string pd2Path) | ||
{ | ||
const string zipUrl = "https://github.com/Aurora-RGB/Payday2-GSI/archive/refs/heads/main.zip"; | ||
var modFolder = Path.Combine(pd2Path, "mods", "GSI"); | ||
using var webClient = new WebClient(); | ||
using var zipStream = new MemoryStream(webClient.DownloadData(zipUrl)); | ||
await using var zipInputStream = new ZipInputStream(zipStream); | ||
while (zipInputStream.GetNextEntry() is { } entry) | ||
{ | ||
if (!entry.IsFile) | ||
continue; | ||
|
||
var entryName = entry.Name; | ||
var fullPath = Path.Combine(modFolder, entryName).Replace("\\Payday2-GSI-main", ""); | ||
|
||
Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); | ||
|
||
await using var entryFileStream = File.Create(fullPath); | ||
await zipInputStream.CopyToAsync(entryFileStream); | ||
} | ||
} | ||
} |
18 changes: 14 additions & 4 deletions
18
Project-Aurora/Project-Aurora/Profiles/Payday 2/PD2Application.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
using AuroraRgb.Profiles.Payday_2.Layers; | ||
using System.Threading.Tasks; | ||
using AuroraRgb.Profiles.Payday_2.GSI; | ||
using AuroraRgb.Profiles.Payday_2.Layers; | ||
using AuroraRgb.Settings; | ||
|
||
namespace AuroraRgb.Profiles.Payday_2; | ||
|
||
public class PD2 : Application | ||
public class PD2 : GsiApplication | ||
{ | ||
public PD2() | ||
: base(new LightEventConfig { | ||
Name = "Payday 2", | ||
ID = "pd2", | ||
AppID= "218620", | ||
ProcessNames = new[] { "payday2_win32_release.exe" }, | ||
ProcessNames = ["payday2_win32_release.exe"], | ||
SettingsType = typeof(FirstTimeApplicationSettings), | ||
ProfileType = typeof(PD2Profile), | ||
OverviewControlType = typeof(Pd2), | ||
GameStateType = typeof(GSI.GameState_PD2), | ||
GameStateType = typeof(GameState_PD2), | ||
IconURI = "Resources/pd2_64x64.png" | ||
}) | ||
{ | ||
AllowLayer<PD2BackgroundLayerHandler>(); | ||
AllowLayer<PD2FlashbangLayerHandler>(); | ||
AllowLayer<PD2StatesLayerHandler>(); | ||
} | ||
|
||
protected override async Task<bool> DoInstallGsi() | ||
{ | ||
var errorMessage = await Pd2GsiUtils.InstallMod(); | ||
return errorMessage == null; | ||
} | ||
} |
99 changes: 48 additions & 51 deletions
99
Project-Aurora/Project-Aurora/Profiles/Payday 2/PD2Profile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,59 @@ | ||
using System.Drawing; | ||
using AuroraRgb.Profiles.Payday_2.Layers; | ||
using AuroraRgb.Settings; | ||
using AuroraRgb.Settings.Layers; | ||
using Common.Devices; | ||
|
||
namespace AuroraRgb.Profiles.Payday_2 | ||
namespace AuroraRgb.Profiles.Payday_2; | ||
|
||
public class PD2Profile : ApplicationProfile | ||
{ | ||
public class PD2Profile : ApplicationProfile | ||
public override void Reset() | ||
{ | ||
public PD2Profile() : base() | ||
{ | ||
|
||
} | ||
|
||
public override void Reset() | ||
{ | ||
base.Reset(); | ||
Layers = new System.Collections.ObjectModel.ObservableCollection<Layer> | ||
base.Reset(); | ||
Layers = | ||
[ | ||
new Layer("Payday 2 Flashbang", new PD2FlashbangLayerHandler()), | ||
new Layer("Health Indicator", new PercentLayerHandler | ||
{ | ||
new Layer("Payday 2 Flashbang", new Payday_2.Layers.PD2FlashbangLayerHandler()), | ||
new Layer("Health Indicator", new PercentLayerHandler() | ||
Properties = new PercentLayerHandlerProperties | ||
{ | ||
Properties = new PercentLayerHandlerProperties() | ||
{ | ||
_PrimaryColor = Color.FromArgb(0, 255, 0), | ||
SecondaryColor = Color.FromArgb(255, 0, 0), | ||
PercentType = PercentEffectType.Progressive_Gradual, | ||
_Sequence = new KeySequence(new DeviceKeys[] { | ||
DeviceKeys.F1, DeviceKeys.F2, DeviceKeys.F3, DeviceKeys.F4, | ||
DeviceKeys.F5, DeviceKeys.F6, DeviceKeys.F7, DeviceKeys.F8, | ||
DeviceKeys.F9, DeviceKeys.F10, DeviceKeys.F11, DeviceKeys.F12 | ||
}), | ||
BlinkThreshold = 0.0, | ||
BlinkDirection = false, | ||
VariablePath = new VariablePath("LocalPlayer/Health/Current"), | ||
MaxVariablePath = new VariablePath("LocalPlayer/Health/Max") | ||
}, | ||
}), | ||
new Layer("Ammo Indicator", new PercentLayerHandler() | ||
_PrimaryColor = Color.FromArgb(0, 255, 0), | ||
SecondaryColor = Color.FromArgb(255, 0, 0), | ||
PercentType = PercentEffectType.Progressive_Gradual, | ||
_Sequence = new KeySequence([ | ||
DeviceKeys.F1, DeviceKeys.F2, DeviceKeys.F3, DeviceKeys.F4, | ||
DeviceKeys.F5, DeviceKeys.F6, DeviceKeys.F7, DeviceKeys.F8, | ||
DeviceKeys.F9, DeviceKeys.F10, DeviceKeys.F11, DeviceKeys.F12 | ||
]), | ||
BlinkThreshold = 0.0, | ||
BlinkDirection = false, | ||
VariablePath = new VariablePath("LocalPlayer/Health/Current"), | ||
MaxVariablePath = new VariablePath("LocalPlayer/Health/Max") | ||
}, | ||
}), | ||
|
||
new Layer("Ammo Indicator", new PercentLayerHandler | ||
{ | ||
Properties = new PercentLayerHandlerProperties | ||
{ | ||
Properties = new PercentLayerHandlerProperties() | ||
{ | ||
_PrimaryColor = Color.FromArgb(0, 0, 255), | ||
SecondaryColor = Color.FromArgb(255, 0, 0), | ||
PercentType = PercentEffectType.Progressive_Gradual, | ||
_Sequence = new KeySequence(new DeviceKeys[] { | ||
DeviceKeys.ONE, DeviceKeys.TWO, DeviceKeys.THREE, DeviceKeys.FOUR, | ||
DeviceKeys.FIVE, DeviceKeys.SIX, DeviceKeys.SEVEN, DeviceKeys.EIGHT, | ||
DeviceKeys.NINE, DeviceKeys.ZERO, DeviceKeys.MINUS, DeviceKeys.EQUALS | ||
}), | ||
BlinkThreshold = 0.0, | ||
BlinkDirection = false, | ||
VariablePath = new VariablePath("LocalPlayer/Weapons/SelectedWeapon/Current_Clip"), | ||
MaxVariablePath = new VariablePath("LocalPlayer/Weapons/SelectedWeapon/Max_Clip") | ||
}, | ||
}), | ||
new Layer("Payday 2 States", new Payday_2.Layers.PD2StatesLayerHandler()), | ||
new Layer("Payday 2 Background", new Payday_2.Layers.PD2BackgroundLayerHandler()) | ||
}; | ||
} | ||
_PrimaryColor = Color.FromArgb(0, 0, 255), | ||
SecondaryColor = Color.FromArgb(255, 0, 0), | ||
PercentType = PercentEffectType.Progressive_Gradual, | ||
_Sequence = new KeySequence([ | ||
DeviceKeys.ONE, DeviceKeys.TWO, DeviceKeys.THREE, DeviceKeys.FOUR, | ||
DeviceKeys.FIVE, DeviceKeys.SIX, DeviceKeys.SEVEN, DeviceKeys.EIGHT, | ||
DeviceKeys.NINE, DeviceKeys.ZERO, DeviceKeys.MINUS, DeviceKeys.EQUALS | ||
]), | ||
BlinkThreshold = 0.0, | ||
BlinkDirection = false, | ||
VariablePath = new VariablePath("LocalPlayer/Weapons/SelectedWeapon/Current_Clip"), | ||
MaxVariablePath = new VariablePath("LocalPlayer/Weapons/SelectedWeapon/Max_Clip") | ||
}, | ||
}), | ||
|
||
new Layer("Payday 2 States", new PD2StatesLayerHandler()), | ||
new Layer("Payday 2 Background", new PD2BackgroundLayerHandler()) | ||
]; | ||
} | ||
} | ||
} |