This commit is contained in:
Heavy Bob 2025-04-11 10:10:38 +10:00
parent f8446f047e
commit 9b4b25921e
3 changed files with 666 additions and 640 deletions
AutoTrackR2

View file

@ -1,8 +1,7 @@
<Application x:Class="AutoTrackR2.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AutoTrackR2"
StartupUri="MainWindow.xaml">
xmlns:local="clr-namespace:AutoTrackR2">
<Application.Resources>
<FontFamily x:Key="Orbitron">/AutoTrackR2;component/Fonts/Orbitron-Bold.ttf#Orbitron</FontFamily>
<FontFamily x:Key="Roboto">/AutoTrackR2;component/Fonts/Roboto-Regular.ttf#Roboto</FontFamily>
@ -164,11 +163,10 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{DynamicResource BackgroundDarkBrush}"
BorderBrush="{DynamicResource AccentBrush}"
BorderThickness="2"
CornerRadius="5"
Margin="0,1,4,1">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
@ -572,17 +570,26 @@
</Style>
<!-- Standard Slider Style -->
<Style x:Key="SliderStyle" TargetType="Slider">
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="160"/>
<Setter Property="Foreground" Value="{DynamicResource TextBrush}"/>
<Setter Property="Background" Value="{DynamicResource BackgroundDarkBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
<Setter Property="BorderThickness" Value="2"/>
<Style x:Key="SliderStyle"
TargetType="Slider">
<Setter Property="Height"
Value="40"/>
<Setter Property="Width"
Value="160"/>
<Setter Property="Foreground"
Value="{DynamicResource TextBrush}"/>
<Setter Property="Background"
Value="{DynamicResource BackgroundDarkBrush}"/>
<Setter Property="BorderBrush"
Value="{DynamicResource AccentBrush}"/>
<Setter Property="BorderThickness"
Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Slider">
<Grid Width="100" Height="30" HorizontalAlignment="Left">
<Grid Width="100"
Height="30"
HorizontalAlignment="Left">
<!-- Track Background -->
<Border Background="{DynamicResource BackgroundDarkBrush}"
BorderBrush="{DynamicResource AccentBrush}"

View file

@ -22,6 +22,8 @@ namespace AutoTrackR2
private StreamlinkHandler? _streamlinkHandler;
protected override void OnStartup(StartupEventArgs e)
{
try
{
// Ensure crash log directory exists
Directory.CreateDirectory(Path.GetDirectoryName(CrashLogPath));
@ -38,13 +40,26 @@ namespace AutoTrackR2
if (!createdNew)
{
// App is already running, silently exit
// App is already running, show message and exit
MessageBox.Show("AutoTrackR2 is already running.", "AutoTrackR2", MessageBoxButton.OK, MessageBoxImage.Information);
Current.Shutdown();
return;
}
base.OnStartup(e);
// Initialize StreamlinkHandler before creating the main window
_streamlinkHandler = new StreamlinkHandler();
// Create and show the main window
var mainWindow = new MainWindow();
mainWindow.Show();
base.OnStartup(e);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to start AutoTrackR2: {ex.Message}", "AutoTrackR2 Error", MessageBoxButton.OK, MessageBoxImage.Error);
Current.Shutdown();
}
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
@ -94,21 +109,25 @@ namespace AutoTrackR2
}
protected override void OnExit(ExitEventArgs e)
{
if (_mutex != null && _mutexOwned)
{
try
{
if (_mutex != null && _mutexOwned)
{
_mutex.ReleaseMutex();
_mutex.Close();
_mutex = null;
}
}
catch (Exception ex)
{
// Log the mutex release error but don't throw
LogCrash(ex);
}
_mutex.Dispose();
// Log the error but don't prevent shutdown
File.AppendAllText(CrashLogPath, $"[{DateTime.Now}] Error during shutdown: {ex.Message}\n");
}
finally
{
base.OnExit(e);
}
}
}
}

View file

@ -20,7 +20,7 @@ public class ActorDeathEvent : ILogEventHandler
public Regex Pattern { get; }
private Regex _shipManufacturerPattern;
private string _lastKillShip = string.Empty;
private Regex cleanUpPattern = new Regex(@"^(.+?)(?:_\d+)*$");
private Regex cleanUpPattern = new Regex(@"^(.+?)_\d+$");
public ActorDeathEvent()
{