mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-08-04 23:19:11 +00:00
Compare commits
No commits in common. "1e0cf4ce0d49e1bbc7f50ce01ea45b9c47fdc411" and "2b805428eb88cb372ce140643c03b85157c7fac3" have entirely different histories.
1e0cf4ce0d
...
2b805428eb
5 changed files with 102 additions and 230 deletions
|
@ -1,9 +1,6 @@
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Threading;
|
|
||||||
using System.IO;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace AutoTrackR2
|
namespace AutoTrackR2
|
||||||
{
|
{
|
||||||
|
@ -12,101 +9,5 @@ namespace AutoTrackR2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : System.Windows.Application
|
public partial class App : System.Windows.Application
|
||||||
{
|
{
|
||||||
private static Mutex _mutex = null;
|
|
||||||
private static bool _mutexOwned = false;
|
|
||||||
private static readonly string CrashLogPath = Path.Combine(
|
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
|
||||||
"AutoTrackR2",
|
|
||||||
"crash.log"
|
|
||||||
);
|
|
||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
|
||||||
{
|
|
||||||
// Ensure crash log directory exists
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(CrashLogPath));
|
|
||||||
|
|
||||||
// Set up unhandled exception handlers
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
||||||
DispatcherUnhandledException += App_DispatcherUnhandledException;
|
|
||||||
|
|
||||||
const string appName = "AutoTrackR2";
|
|
||||||
bool createdNew;
|
|
||||||
|
|
||||||
_mutex = new Mutex(true, appName, out createdNew);
|
|
||||||
_mutexOwned = createdNew;
|
|
||||||
|
|
||||||
if (!createdNew)
|
|
||||||
{
|
|
||||||
// App is already running, silently exit
|
|
||||||
Current.Shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnStartup(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
||||||
{
|
|
||||||
LogCrash(e.ExceptionObject as Exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
|
||||||
{
|
|
||||||
LogCrash(e.Exception);
|
|
||||||
e.Handled = true; // Prevent the application from crashing
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LogCrash(Exception? ex)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
||||||
var logMessage = $"[{timestamp}] CRASH: {ex?.Message}\n" +
|
|
||||||
$"Stack Trace:\n{ex?.StackTrace}\n" +
|
|
||||||
$"Source: {ex?.Source}\n" +
|
|
||||||
$"Target Site: {ex?.TargetSite}\n" +
|
|
||||||
"----------------------------------------\n";
|
|
||||||
|
|
||||||
File.AppendAllText(CrashLogPath, logMessage);
|
|
||||||
|
|
||||||
// Show error message to user
|
|
||||||
MessageBox.Show(
|
|
||||||
"AutoTrackR2 has encountered an error. A crash log has been created.\n" +
|
|
||||||
$"Location: {CrashLogPath}",
|
|
||||||
"AutoTrackR2 Error",
|
|
||||||
MessageBoxButton.OK,
|
|
||||||
MessageBoxImage.Error
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch (Exception logEx)
|
|
||||||
{
|
|
||||||
// If logging fails, at least show a basic error message
|
|
||||||
MessageBox.Show(
|
|
||||||
"AutoTrackR2 has encountered an error and failed to create a crash log.\n" +
|
|
||||||
$"Error: {ex?.Message}",
|
|
||||||
"AutoTrackR2 Error",
|
|
||||||
MessageBoxButton.OK,
|
|
||||||
MessageBoxImage.Error
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
|
||||||
{
|
|
||||||
if (_mutex != null && _mutexOwned)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_mutex.ReleaseMutex();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// Log the mutex release error but don't throw
|
|
||||||
LogCrash(ex);
|
|
||||||
}
|
|
||||||
_mutex.Dispose();
|
|
||||||
}
|
|
||||||
base.OnExit(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Height="389">
|
Height="389">
|
||||||
<!-- Log File -->
|
<!-- Log File -->
|
||||||
<StackPanel Margin="0,5,0,10"
|
<StackPanel Margin="0,10,0,15"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
ToolTip="Set this to the Game.log file in your StarCitizen\LIVE directory."
|
ToolTip="Set this to the Game.log file in your StarCitizen\LIVE directory."
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- API URL -->
|
<!-- API URL -->
|
||||||
<StackPanel Margin="0,0,0,10"
|
<StackPanel Margin="0,0,0,15"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
ToolTip="Need a URL? No idea what to do? Contact heavy_bob on Discord!"
|
ToolTip="Need a URL? No idea what to do? Contact heavy_bob on Discord!"
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- API Key -->
|
<!-- API Key -->
|
||||||
<StackPanel Margin="0,0,0,10"
|
<StackPanel Margin="0,0,0,15"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
ToolTip="Need a key? No idea what to do? Contact heavy_bob on Discord!"
|
ToolTip="Need a key? No idea what to do? Contact heavy_bob on Discord!"
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Video Path -->
|
<!-- Video Path -->
|
||||||
<StackPanel Margin="0,0,0,10"
|
<StackPanel Margin="0,0,0,15"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
ToolTip="The directory where your clipping software saves kills. Check the README."
|
ToolTip="The directory where your clipping software saves kills. Check the README."
|
||||||
|
@ -129,31 +129,18 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Toggle Settings Grid -->
|
<!-- Visor Wipe Toggle Slider -->
|
||||||
<Grid Margin="0,0,0,10">
|
<StackPanel Margin="0,0,0,15"
|
||||||
<Grid.ColumnDefinitions>
|
Orientation="Horizontal">
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
|
|
||||||
<!-- Visor Wipe Toggle -->
|
|
||||||
<StackPanel Grid.Column="0" Grid.Row="0"
|
|
||||||
Orientation="Horizontal"
|
|
||||||
Margin="0,0,5,5">
|
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
ToolTip="Perform a Visor Wipe animation on player kill. Requires AHKv2."
|
ToolTip="Perform a Visor Wipe animation on player kill. Requires AHKv2."
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
Margin="0,4,3,0"/>
|
Margin="0,4,3,5"/>
|
||||||
<TextBlock Text="Visor Wipe:"
|
<TextBlock Text="Visor Wipe:"
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Margin="0,7,0,0"/>
|
Margin="0,7,0,5"/>
|
||||||
<Slider Name="VisorWipeSlider"
|
<Slider Name="VisorWipeSlider"
|
||||||
Minimum="0"
|
Minimum="0"
|
||||||
Maximum="1"
|
Maximum="1"
|
||||||
|
@ -161,24 +148,22 @@
|
||||||
IsSnapToTickEnabled="True"
|
IsSnapToTickEnabled="True"
|
||||||
Value="0"
|
Value="0"
|
||||||
Style="{StaticResource ToggleSliderStyle}"
|
Style="{StaticResource ToggleSliderStyle}"
|
||||||
Margin="10,-4,0,0"
|
Margin="27,-4,0,0"
|
||||||
Width="100"
|
|
||||||
ValueChanged="VisorWipeSlider_ValueChanged"/>
|
ValueChanged="VisorWipeSlider_ValueChanged"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Video Record Toggle -->
|
<!-- Video Record Toggle Slider -->
|
||||||
<StackPanel Grid.Column="1" Grid.Row="0"
|
<StackPanel Margin="0,0,0,15"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal">
|
||||||
Margin="5,0,0,5">
|
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
ToolTip="Automatically clip your last kill. Check the README for more info."
|
ToolTip="Automatically clip your last kill. Check the README for more info."
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
Margin="0,4,3,0"/>
|
Margin="0,4,3,5"/>
|
||||||
<TextBlock Text="Video Record:"
|
<TextBlock Text="Video Record:"
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Margin="0,7,0,0"/>
|
Margin="0,7,0,5"/>
|
||||||
<Slider Name="VideoRecordSlider"
|
<Slider Name="VideoRecordSlider"
|
||||||
Minimum="0"
|
Minimum="0"
|
||||||
Maximum="1"
|
Maximum="1"
|
||||||
|
@ -187,23 +172,21 @@
|
||||||
Value="0"
|
Value="0"
|
||||||
Style="{StaticResource ToggleSliderStyle}"
|
Style="{StaticResource ToggleSliderStyle}"
|
||||||
Margin="10,-4,0,0"
|
Margin="10,-4,0,0"
|
||||||
Width="100"
|
|
||||||
ValueChanged="VideoRecordSlider_ValueChanged"/>
|
ValueChanged="VideoRecordSlider_ValueChanged"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Offline Mode Toggle -->
|
<!-- Offline Mode Toggle Slider -->
|
||||||
<StackPanel Grid.Column="0" Grid.Row="1"
|
<StackPanel Margin="0,0,0,10"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal">
|
||||||
Margin="0,0,5,5">
|
|
||||||
<TextBlock Text="ⓘ"
|
<TextBlock Text="ⓘ"
|
||||||
ToolTip="With Offline Mode enabled, kills will not be submitted to the configured API."
|
ToolTip="With Offline Mode enabled, kills will not be submitted to the configured API."
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
Margin="0,4,3,0"/>
|
Margin="0,4,3,5"/>
|
||||||
<TextBlock Text="Offline Mode:"
|
<TextBlock Text="Offline Mode:"
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Margin="0,7,0,0"/>
|
Margin="0,7,0,5"/>
|
||||||
<Slider Name="OfflineModeSlider"
|
<Slider Name="OfflineModeSlider"
|
||||||
Minimum="0"
|
Minimum="0"
|
||||||
Maximum="1"
|
Maximum="1"
|
||||||
|
@ -211,20 +194,17 @@
|
||||||
IsSnapToTickEnabled="True"
|
IsSnapToTickEnabled="True"
|
||||||
Value="0"
|
Value="0"
|
||||||
Style="{StaticResource ToggleSliderStyle}"
|
Style="{StaticResource ToggleSliderStyle}"
|
||||||
Margin="10,-4,0,0"
|
Margin="12,-4,0,0"
|
||||||
Width="100"
|
|
||||||
ValueChanged="OfflineModeSlider_ValueChanged"/>
|
ValueChanged="OfflineModeSlider_ValueChanged"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Theme Slider -->
|
<!-- 3-Position Toggle Slider -->
|
||||||
<StackPanel Grid.Column="0" Grid.Row="2"
|
<StackPanel Margin="0,0,0,15"
|
||||||
Grid.ColumnSpan="2"
|
Orientation="Horizontal">
|
||||||
Orientation="Horizontal"
|
|
||||||
Margin="0,0,0,5">
|
|
||||||
<TextBlock Text="Theme:"
|
<TextBlock Text="Theme:"
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Margin="0,7,10,0"/>
|
Margin="0,7,0,5"/>
|
||||||
<Slider x:Name="ThemeSlider"
|
<Slider x:Name="ThemeSlider"
|
||||||
Minimum="0"
|
Minimum="0"
|
||||||
Value="0"
|
Value="0"
|
||||||
|
@ -233,8 +213,8 @@
|
||||||
ValueChanged="ThemeSlider_ValueChanged"
|
ValueChanged="ThemeSlider_ValueChanged"
|
||||||
Width="447"
|
Width="447"
|
||||||
Style="{StaticResource ThreePositionSlider}"/>
|
Style="{StaticResource ThreePositionSlider}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Save Button -->
|
<!-- Save Button -->
|
||||||
|
|
|
@ -39,6 +39,7 @@ public partial class ConfigPage : UserControl
|
||||||
|
|
||||||
ApplyToggleModeStyle(OfflineModeSlider.Value, VisorWipeSlider.Value, VideoRecordSlider.Value);
|
ApplyToggleModeStyle(OfflineModeSlider.Value, VisorWipeSlider.Value, VideoRecordSlider.Value);
|
||||||
|
|
||||||
|
|
||||||
const string themeJsonPath = "themes.json";
|
const string themeJsonPath = "themes.json";
|
||||||
var themeJson = File.ReadAllText(themeJsonPath);
|
var themeJson = File.ReadAllText(themeJsonPath);
|
||||||
_themes = JsonSerializer.Deserialize<Dictionary<string, Theme>>(themeJson);
|
_themes = JsonSerializer.Deserialize<Dictionary<string, Theme>>(themeJson);
|
||||||
|
@ -77,19 +78,23 @@ public partial class ConfigPage : UserControl
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will set the loaded config values to the UI controls
|
// This method will set the loaded config values to the UI controls
|
||||||
public void SetConfigValues(string logFile, string apiUrl, string apiKey, string videoPath, int visorWipe, int videoRecord, int offlineMode, int theme)
|
public void SetConfigValues(string logFile, string apiUrl, string apiKey, string videoPath,
|
||||||
|
int visorWipe, int videoRecord, int offlineMode, int theme)
|
||||||
{
|
{
|
||||||
|
// Set the textboxes with the loaded values
|
||||||
LogFilePath.Text = logFile;
|
LogFilePath.Text = logFile;
|
||||||
ApiUrl.Text = apiUrl;
|
ApiUrl.Text = apiUrl;
|
||||||
ApiKey.Password = apiKey;
|
ApiKey.Password = apiKey;
|
||||||
VideoPath.Text = videoPath;
|
VideoPath.Text = videoPath;
|
||||||
VisorWipeSlider.Value = visorWipe;
|
|
||||||
|
// Set the sliders with the loaded values
|
||||||
VideoRecordSlider.Value = videoRecord;
|
VideoRecordSlider.Value = videoRecord;
|
||||||
|
VisorWipeSlider.Value = visorWipe;
|
||||||
OfflineModeSlider.Value = offlineMode;
|
OfflineModeSlider.Value = offlineMode;
|
||||||
ThemeSlider.Value = theme;
|
|
||||||
|
|
||||||
// Handle themes
|
// Handle themes
|
||||||
ApplyTheme(theme);
|
ApplyTheme(theme);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyToggleModeStyle(double offlineModeValue, double visorWipeValue, double videoRecordValue)
|
private void ApplyToggleModeStyle(double offlineModeValue, double visorWipeValue, double videoRecordValue)
|
||||||
|
@ -197,18 +202,18 @@ public partial class ConfigPage : UserControl
|
||||||
// Video Path Browse Button Handler
|
// Video Path Browse Button Handler
|
||||||
private void VideoPathBrowseButton_Click(object sender, RoutedEventArgs e)
|
private void VideoPathBrowseButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var dialog = new Microsoft.Win32.OpenFileDialog();
|
var dialog = new OpenFileDialog();
|
||||||
dialog.ValidateNames = false;
|
|
||||||
dialog.CheckFileExists = false;
|
dialog.CheckFileExists = false;
|
||||||
dialog.CheckPathExists = true;
|
dialog.ValidateNames = false;
|
||||||
dialog.FileName = "Folder Selection";
|
dialog.Filter = "All files|*.*";
|
||||||
|
|
||||||
if (dialog.ShowDialog() == true)
|
if (dialog.ShowDialog() == true && dialog.FileName != null)
|
||||||
{
|
{
|
||||||
|
// Extract only the directory path from the file
|
||||||
string? selectedFolder = Path.GetDirectoryName(dialog.FileName);
|
string? selectedFolder = Path.GetDirectoryName(dialog.FileName);
|
||||||
if (selectedFolder != null)
|
if (selectedFolder != null)
|
||||||
{
|
{
|
||||||
VideoPath.Text = selectedFolder;
|
VideoPath.Text = selectedFolder; // Set the folder path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,8 +320,10 @@ public partial class ConfigPage : UserControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
ConfigManager.ApiKey = ApiKey.Password;
|
ConfigManager.ApiKey = ApiKey.Password;
|
||||||
ConfigManager.ApiUrl = ApiUrl.Text;
|
ConfigManager.ApiUrl = ApiUrl.Text;
|
||||||
ConfigManager.LogFile = LogFilePath.Text;
|
ConfigManager.LogFile = LogFilePath.Text;
|
||||||
|
@ -325,7 +332,6 @@ public partial class ConfigPage : UserControl
|
||||||
ConfigManager.VideoRecord = (int)VideoRecordSlider.Value;
|
ConfigManager.VideoRecord = (int)VideoRecordSlider.Value;
|
||||||
ConfigManager.OfflineMode = (int)OfflineModeSlider.Value;
|
ConfigManager.OfflineMode = (int)OfflineModeSlider.Value;
|
||||||
ConfigManager.Theme = (int)ThemeSlider.Value;
|
ConfigManager.Theme = (int)ThemeSlider.Value;
|
||||||
|
|
||||||
// Save the current config values
|
// Save the current config values
|
||||||
ConfigManager.SaveConfig();
|
ConfigManager.SaveConfig();
|
||||||
// Start the flashing effect
|
// Start the flashing effect
|
||||||
|
@ -398,11 +404,10 @@ public partial class ConfigPage : UserControl
|
||||||
{
|
{
|
||||||
// Set headers
|
// Set headers
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
|
||||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("AutoTrackR2");
|
client.DefaultRequestHeaders.UserAgent.ParseAdd("AutoTrackR");
|
||||||
|
|
||||||
// Create JSON body with version
|
// Empty JSON body
|
||||||
var jsonBody = new { version = "2.10" };
|
var content = new StringContent("{}", Encoding.UTF8, "application/json");
|
||||||
var content = new StringContent(JsonSerializer.Serialize(jsonBody), Encoding.UTF8, "application/json");
|
|
||||||
|
|
||||||
// Send POST
|
// Send POST
|
||||||
var response = await client.PostAsync(modifiedUrl, content);
|
var response = await client.PostAsync(modifiedUrl, content);
|
||||||
|
|
|
@ -42,20 +42,19 @@
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Border and StackPanel for player info -->
|
<!-- StackPanel for Start and Stop buttons -->
|
||||||
<Border Background="{DynamicResource BackgroundDarkBrush}"
|
<Border Background="{DynamicResource BackgroundDarkBrush}"
|
||||||
BorderBrush="{DynamicResource AccentBrush}"
|
BorderBrush="{DynamicResource AccentBrush}"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
BorderThickness="2"
|
BorderThickness="2"
|
||||||
CornerRadius="5"
|
CornerRadius="5"
|
||||||
Margin="0,0,0,10"
|
Margin="0,0,0,82"/>
|
||||||
VerticalAlignment="Top">
|
<StackPanel Grid.Column="1"
|
||||||
<StackPanel
|
VerticalAlignment="Center"
|
||||||
VerticalAlignment="Top"
|
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Width="152"
|
Height="269"
|
||||||
Margin="10,5,10,5">
|
Width="152">
|
||||||
<TextBlock Name="PilotNameTitle"
|
<TextBlock Name="PilotNameTitle"
|
||||||
Text="Pilot"
|
Text="Pilot"
|
||||||
Width="152"
|
Width="152"
|
||||||
|
@ -113,25 +112,6 @@
|
||||||
Foreground="{DynamicResource TextBrush}"
|
Foreground="{DynamicResource TextBrush}"
|
||||||
FontSize="10"
|
FontSize="10"
|
||||||
TextAlignment="Center"/>
|
TextAlignment="Center"/>
|
||||||
<TextBlock Name="LocationTitle"
|
|
||||||
Text="Location"
|
|
||||||
Width="152"
|
|
||||||
Height="20"
|
|
||||||
Background="Transparent"
|
|
||||||
FontFamily="{StaticResource Orbitron}"
|
|
||||||
Margin="0,5,0,0"
|
|
||||||
Foreground="{DynamicResource AltTextBrush}"
|
|
||||||
FontSize="14"/>
|
|
||||||
<TextBlock Name="LocationTextBox"
|
|
||||||
Text="Unknown"
|
|
||||||
Width="152"
|
|
||||||
Height="20"
|
|
||||||
Background="Transparent"
|
|
||||||
FontFamily="{StaticResource Orbitron}"
|
|
||||||
Margin="0,0,0,0"
|
|
||||||
Foreground="{DynamicResource TextBrush}"
|
|
||||||
FontSize="10"
|
|
||||||
TextAlignment="Center"/>
|
|
||||||
<TextBlock Name="KillTallyTitle"
|
<TextBlock Name="KillTallyTitle"
|
||||||
Text="Kill Tally"
|
Text="Kill Tally"
|
||||||
Width="152"
|
Width="152"
|
||||||
|
@ -161,8 +141,7 @@
|
||||||
FontSize="8"
|
FontSize="8"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
Margin="0,9,0,0"/>
|
Margin="0,9,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
|
||||||
<StackPanel Grid.Row="1"
|
<StackPanel Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
|
|
@ -77,11 +77,9 @@ public partial class HomePage : UserControl
|
||||||
GameModeTextBox.Text = "Unknown";
|
GameModeTextBox.Text = "Unknown";
|
||||||
PlayerShipTextBox.Text = "Unknown";
|
PlayerShipTextBox.Text = "Unknown";
|
||||||
PilotNameTextBox.Text = "Unknown";
|
PilotNameTextBox.Text = "Unknown";
|
||||||
LocationTextBox.Text = "Unknown";
|
|
||||||
LocalPlayerData.CurrentGameMode = GameMode.Unknown;
|
LocalPlayerData.CurrentGameMode = GameMode.Unknown;
|
||||||
LocalPlayerData.PlayerShip = string.Empty;
|
LocalPlayerData.PlayerShip = string.Empty;
|
||||||
LocalPlayerData.Username = string.Empty;
|
LocalPlayerData.Username = string.Empty;
|
||||||
LocalPlayerData.LastSeenVehicleLocation = "Unknown";
|
|
||||||
|
|
||||||
// Stop log monitoring if it's running
|
// Stop log monitoring if it's running
|
||||||
if (_isLogHandlerRunning)
|
if (_isLogHandlerRunning)
|
||||||
|
@ -141,8 +139,6 @@ public partial class HomePage : UserControl
|
||||||
AdjustFontSize(PlayerShipTextBox);
|
AdjustFontSize(PlayerShipTextBox);
|
||||||
LocalPlayerData.PlayerShip = data.ShipName;
|
LocalPlayerData.PlayerShip = data.ShipName;
|
||||||
LocalPlayerData.LastSeenVehicleLocation = data.Location;
|
LocalPlayerData.LastSeenVehicleLocation = data.Location;
|
||||||
LocationTextBox.Text = data.Location;
|
|
||||||
AdjustFontSize(LocationTextBox);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -220,12 +216,7 @@ public partial class HomePage : UserControl
|
||||||
// Vehicle Destruction
|
// Vehicle Destruction
|
||||||
TrackREventDispatcher.VehicleDestructionEvent += (data) =>
|
TrackREventDispatcher.VehicleDestructionEvent += (data) =>
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() =>
|
LocalPlayerData.LastSeenVehicleLocation = data.VehicleZone;
|
||||||
{
|
|
||||||
LocalPlayerData.LastSeenVehicleLocation = data.VehicleZone;
|
|
||||||
LocationTextBox.Text = data.VehicleZone;
|
|
||||||
AdjustFontSize(LocationTextBox);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_UIEventsRegistered = true;
|
_UIEventsRegistered = true;
|
||||||
|
@ -233,51 +224,67 @@ public partial class HomePage : UserControl
|
||||||
|
|
||||||
private void AddKillToScreen(KillData killData)
|
private void AddKillToScreen(KillData killData)
|
||||||
{
|
{
|
||||||
// Use resource references instead of creating new brushes
|
// Fetch the dynamic resource for AltTextColor
|
||||||
|
var altTextColorBrush = new SolidColorBrush((Color)Application.Current.Resources["AltTextColor"]);
|
||||||
|
var accentColorBrush = new SolidColorBrush((Color)Application.Current.Resources["AccentColor"]);
|
||||||
|
|
||||||
|
// Fetch the Orbitron FontFamily from resources
|
||||||
|
var orbitronFontFamily = (FontFamily)Application.Current.Resources["Orbitron"];
|
||||||
|
var gemunuFontFamily = (FontFamily)Application.Current.Resources["Gemunu"];
|
||||||
|
|
||||||
|
// Create a new TextBlock for each kill
|
||||||
var killTextBlock = new TextBlock
|
var killTextBlock = new TextBlock
|
||||||
{
|
{
|
||||||
Margin = new Thickness(0, 10, 0, 10),
|
Margin = new Thickness(0, 10, 0, 10),
|
||||||
Style = (Style)Application.Current.Resources["RoundedTextBlock"],
|
Style = (Style)Application.Current.Resources["RoundedTextBlock"], // Apply style for text
|
||||||
FontSize = 14,
|
FontSize = 14,
|
||||||
FontWeight = FontWeights.Bold,
|
FontWeight = FontWeights.Bold,
|
||||||
FontFamily = (FontFamily)Application.Current.Resources["Gemunu"],
|
FontFamily = gemunuFontFamily,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add styled content using Run elements with resource references
|
// Add styled content using Run elements
|
||||||
var titleRun = new Run("Victim Name: ");
|
killTextBlock.Inlines.Add(new Run("Victim Name: ")
|
||||||
titleRun.SetResourceReference(TextElement.ForegroundProperty, "AltTextBrush");
|
{
|
||||||
titleRun.FontFamily = (FontFamily)Application.Current.Resources["Orbitron"];
|
Foreground = altTextColorBrush,
|
||||||
killTextBlock.Inlines.Add(titleRun);
|
FontFamily = orbitronFontFamily,
|
||||||
|
});
|
||||||
killTextBlock.Inlines.Add(new Run($"{killData.EnemyPilot}\n"));
|
killTextBlock.Inlines.Add(new Run($"{killData.EnemyPilot}\n"));
|
||||||
|
|
||||||
titleRun = new Run("Victim Ship: ");
|
// Repeat for other lines
|
||||||
titleRun.SetResourceReference(TextElement.ForegroundProperty, "AltTextBrush");
|
killTextBlock.Inlines.Add(new Run("Victim Ship: ")
|
||||||
titleRun.FontFamily = (FontFamily)Application.Current.Resources["Orbitron"];
|
{
|
||||||
killTextBlock.Inlines.Add(titleRun);
|
Foreground = altTextColorBrush,
|
||||||
|
FontFamily = orbitronFontFamily,
|
||||||
|
});
|
||||||
killTextBlock.Inlines.Add(new Run($"{killData.EnemyShip}\n"));
|
killTextBlock.Inlines.Add(new Run($"{killData.EnemyShip}\n"));
|
||||||
|
|
||||||
titleRun = new Run("Victim Org: ");
|
killTextBlock.Inlines.Add(new Run("Victim Org: ")
|
||||||
titleRun.SetResourceReference(TextElement.ForegroundProperty, "AltTextBrush");
|
{
|
||||||
titleRun.FontFamily = (FontFamily)Application.Current.Resources["Orbitron"];
|
Foreground = altTextColorBrush,
|
||||||
killTextBlock.Inlines.Add(titleRun);
|
FontFamily = orbitronFontFamily,
|
||||||
|
});
|
||||||
killTextBlock.Inlines.Add(new Run($"{killData.OrgAffiliation}\n"));
|
killTextBlock.Inlines.Add(new Run($"{killData.OrgAffiliation}\n"));
|
||||||
|
|
||||||
titleRun = new Run("Join Date: ");
|
killTextBlock.Inlines.Add(new Run("Join Date: ")
|
||||||
titleRun.SetResourceReference(TextElement.ForegroundProperty, "AltTextBrush");
|
{
|
||||||
titleRun.FontFamily = (FontFamily)Application.Current.Resources["Orbitron"];
|
Foreground = altTextColorBrush,
|
||||||
killTextBlock.Inlines.Add(titleRun);
|
FontFamily = orbitronFontFamily,
|
||||||
|
});
|
||||||
killTextBlock.Inlines.Add(new Run($"{killData.Enlisted}\n"));
|
killTextBlock.Inlines.Add(new Run($"{killData.Enlisted}\n"));
|
||||||
|
|
||||||
titleRun = new Run("UEE Record: ");
|
killTextBlock.Inlines.Add(new Run("UEE Record: ")
|
||||||
titleRun.SetResourceReference(TextElement.ForegroundProperty, "AltTextBrush");
|
{
|
||||||
titleRun.FontFamily = (FontFamily)Application.Current.Resources["Orbitron"];
|
Foreground = altTextColorBrush,
|
||||||
killTextBlock.Inlines.Add(titleRun);
|
FontFamily = orbitronFontFamily,
|
||||||
|
});
|
||||||
|
|
||||||
killTextBlock.Inlines.Add(new Run($"{killData.RecordNumber}\n"));
|
killTextBlock.Inlines.Add(new Run($"{killData.RecordNumber}\n"));
|
||||||
|
|
||||||
titleRun = new Run("Kill Time: ");
|
killTextBlock.Inlines.Add(new Run("Kill Time: ")
|
||||||
titleRun.SetResourceReference(TextElement.ForegroundProperty, "AltTextBrush");
|
{
|
||||||
titleRun.FontFamily = (FontFamily)Application.Current.Resources["Orbitron"];
|
Foreground = altTextColorBrush,
|
||||||
killTextBlock.Inlines.Add(titleRun);
|
FontFamily = orbitronFontFamily,
|
||||||
|
});
|
||||||
killTextBlock.Inlines.Add(new Run($"{killData.KillTime}"));
|
killTextBlock.Inlines.Add(new Run($"{killData.KillTime}"));
|
||||||
|
|
||||||
// Create a Border and apply the RoundedTextBlockWithBorder style
|
// Create a Border and apply the RoundedTextBlockWithBorder style
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue