mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-05-16 14:25:29 +00:00
Fixed kill streak cleanup and added trackrver constant.
This commit is contained in:
parent
36cfdaba8a
commit
3c23f34d3f
6 changed files with 47 additions and 32 deletions
|
@ -20,6 +20,13 @@ namespace AutoTrackR2
|
||||||
"crash.log"
|
"crash.log"
|
||||||
);
|
);
|
||||||
private StreamlinkHandler? _streamlinkHandler;
|
private StreamlinkHandler? _streamlinkHandler;
|
||||||
|
private KillStreakManager? _killStreakManager;
|
||||||
|
|
||||||
|
private void HandleException(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Failed to start AutoTrackR2: {ex.Message}", "AutoTrackR2 Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
Current.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +56,10 @@ namespace AutoTrackR2
|
||||||
// Initialize StreamlinkHandler before creating the main window
|
// Initialize StreamlinkHandler before creating the main window
|
||||||
_streamlinkHandler = new StreamlinkHandler();
|
_streamlinkHandler = new StreamlinkHandler();
|
||||||
|
|
||||||
|
// Initialize KillStreakManager
|
||||||
|
var soundsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sounds");
|
||||||
|
_killStreakManager = new KillStreakManager(soundsPath);
|
||||||
|
|
||||||
// Create and show the main window
|
// Create and show the main window
|
||||||
var mainWindow = new MainWindow();
|
var mainWindow = new MainWindow();
|
||||||
mainWindow.Show();
|
mainWindow.Show();
|
||||||
|
@ -57,8 +68,7 @@ namespace AutoTrackR2
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Failed to start AutoTrackR2: {ex.Message}", "AutoTrackR2 Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
HandleException(ex);
|
||||||
Current.Shutdown();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,24 +120,10 @@ namespace AutoTrackR2
|
||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
protected override void OnExit(ExitEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
// Clean up resources
|
||||||
{
|
_killStreakManager?.Cleanup();
|
||||||
if (_mutex != null && _mutexOwned)
|
_mutex?.Dispose();
|
||||||
{
|
base.OnExit(e);
|
||||||
_mutex.ReleaseMutex();
|
|
||||||
_mutex.Close();
|
|
||||||
_mutex = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// Log the error but don't prevent shutdown
|
|
||||||
File.AppendAllText(CrashLogPath, $"[{DateTime.Now}] Error during shutdown: {ex.Message}\n");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
base.OnExit(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,10 +154,10 @@
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Kill Streak Test Button -->
|
<!-- Kill Streak Test Button -->
|
||||||
|
<!--
|
||||||
<Button Grid.Column="0"
|
<Button Grid.Column="0"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
|
@ -167,12 +167,13 @@
|
||||||
Margin="0,0,0,10"
|
Margin="0,0,0,10"
|
||||||
Style="{StaticResource ButtonStyle}"
|
Style="{StaticResource ButtonStyle}"
|
||||||
Click="TestKillStreakButton_Click"/>
|
Click="TestKillStreakButton_Click"/>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- Left Column Controls -->
|
<!-- Left Column Controls -->
|
||||||
|
|
||||||
<!-- Visor Wipe Toggle -->
|
<!-- Visor Wipe Toggle -->
|
||||||
<StackPanel Grid.Column="0"
|
<StackPanel Grid.Column="0"
|
||||||
Grid.Row="1"
|
Grid.Row="0"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Margin="0,0,5,5">
|
Margin="0,0,5,5">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
|
@ -198,7 +199,7 @@
|
||||||
|
|
||||||
<!-- Video Record Toggle -->
|
<!-- Video Record Toggle -->
|
||||||
<StackPanel Grid.Column="0"
|
<StackPanel Grid.Column="0"
|
||||||
Grid.Row="2"
|
Grid.Row="1"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Margin="0,0,5,5">
|
Margin="0,0,5,5">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
|
@ -224,7 +225,7 @@
|
||||||
|
|
||||||
<!-- Offline Mode Toggle -->
|
<!-- Offline Mode Toggle -->
|
||||||
<StackPanel Grid.Column="0"
|
<StackPanel Grid.Column="0"
|
||||||
Grid.Row="3"
|
Grid.Row="2"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Margin="0,0,5,5">
|
Margin="0,0,5,5">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
|
@ -252,7 +253,7 @@
|
||||||
|
|
||||||
<!-- Streamlink Toggle -->
|
<!-- Streamlink Toggle -->
|
||||||
<StackPanel Grid.Column="1"
|
<StackPanel Grid.Column="1"
|
||||||
Grid.Row="1"
|
Grid.Row="0"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Margin="5,0,0,5">
|
Margin="5,0,0,5">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
|
@ -278,7 +279,7 @@
|
||||||
|
|
||||||
<!-- Streamlink Duration -->
|
<!-- Streamlink Duration -->
|
||||||
<StackPanel Grid.Column="1"
|
<StackPanel Grid.Column="1"
|
||||||
Grid.Row="2"
|
Grid.Row="1"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Margin="5,0,0,5">
|
Margin="5,0,0,5">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
|
@ -309,7 +310,7 @@
|
||||||
|
|
||||||
<!-- Test Streamlink Button -->
|
<!-- Test Streamlink Button -->
|
||||||
<Button Grid.Column="1"
|
<Button Grid.Column="1"
|
||||||
Grid.Row="3"
|
Grid.Row="2"
|
||||||
Content="Test Streamlink"
|
Content="Test Streamlink"
|
||||||
Width="120"
|
Width="120"
|
||||||
Height="30"
|
Height="30"
|
||||||
|
@ -320,7 +321,7 @@
|
||||||
|
|
||||||
<!-- Theme Slider -->
|
<!-- Theme Slider -->
|
||||||
<StackPanel Grid.Column="0"
|
<StackPanel Grid.Column="0"
|
||||||
Grid.Row="5"
|
Grid.Row="3"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Margin="0,0,0,5">
|
Margin="0,0,0,5">
|
||||||
|
|
|
@ -12,6 +12,7 @@ using System.Windows.Media.Effects;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AutoTrackR2.Constants;
|
||||||
|
|
||||||
namespace AutoTrackR2;
|
namespace AutoTrackR2;
|
||||||
|
|
||||||
|
@ -418,7 +419,7 @@ public partial class ConfigPage : UserControl
|
||||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("AutoTrackR2");
|
client.DefaultRequestHeaders.UserAgent.ParseAdd("AutoTrackR2");
|
||||||
|
|
||||||
// Create JSON body with version
|
// Create JSON body with version
|
||||||
var jsonBody = new { version = "2.10" };
|
var jsonBody = new { version = AppConstants.Version };
|
||||||
var content = new StringContent(JsonSerializer.Serialize(jsonBody), Encoding.UTF8, "application/json");
|
var content = new StringContent(JsonSerializer.Serialize(jsonBody), Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
// Send POST
|
// Send POST
|
||||||
|
@ -506,7 +507,7 @@ public partial class ConfigPage : UserControl
|
||||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("AutoTrackR2");
|
client.DefaultRequestHeaders.UserAgent.ParseAdd("AutoTrackR2");
|
||||||
|
|
||||||
// Create JSON body with version
|
// Create JSON body with version
|
||||||
var jsonBody = new { version = "2.10" };
|
var jsonBody = new { version = AppConstants.Version };
|
||||||
var content = new StringContent(JsonSerializer.Serialize(jsonBody), Encoding.UTF8, "application/json");
|
var content = new StringContent(JsonSerializer.Serialize(jsonBody), Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
// Send POST to test endpoint
|
// Send POST to test endpoint
|
||||||
|
|
6
AutoTrackR2/Constants.cs
Normal file
6
AutoTrackR2/Constants.cs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
namespace AutoTrackR2.Constants;
|
||||||
|
|
||||||
|
public static class AppConstants
|
||||||
|
{
|
||||||
|
public const string Version = "2.11";
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ using System.Windows.Media.Imaging;
|
||||||
using AutoTrackR2.LogEventHandlers;
|
using AutoTrackR2.LogEventHandlers;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using AutoTrackR2.Constants;
|
||||||
|
|
||||||
namespace AutoTrackR2;
|
namespace AutoTrackR2;
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public partial class HomePage : UserControl
|
||||||
Method = actorDeathData.DamageType,
|
Method = actorDeathData.DamageType,
|
||||||
RecordNumber = playerData?.UEERecord,
|
RecordNumber = playerData?.UEERecord,
|
||||||
GameVersion = LocalPlayerData.GameVersion ?? "Unknown",
|
GameVersion = LocalPlayerData.GameVersion ?? "Unknown",
|
||||||
TrackRver = "2.10",
|
TrackRver = AppConstants.Version,
|
||||||
Enlisted = playerData?.JoinDate,
|
Enlisted = playerData?.JoinDate,
|
||||||
KillTime = ((DateTimeOffset)DateTime.ParseExact(actorDeathData.Timestamp, "yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal)).ToUnixTimeSeconds().ToString(),
|
KillTime = ((DateTimeOffset)DateTime.ParseExact(actorDeathData.Timestamp, "yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal)).ToUnixTimeSeconds().ToString(),
|
||||||
PFP = playerData?.PFPURL ?? "https://cdn.robertsspaceindustries.com/static/images/account/avatar_default_big.jpg",
|
PFP = playerData?.PFPURL ?? "https://cdn.robertsspaceindustries.com/static/images/account/avatar_default_big.jpg",
|
||||||
|
|
|
@ -105,6 +105,17 @@ public class KillStreakManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Cleanup()
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
_killStreakTimer.Stop();
|
||||||
|
_killStreakTimer.Dispose();
|
||||||
|
_waveOut?.Dispose();
|
||||||
|
_waveOut = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void PlayNextSound()
|
private void PlayNextSound()
|
||||||
{
|
{
|
||||||
if (_soundQueue.Count > 0)
|
if (_soundQueue.Count > 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue