mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-05-22 08:45:30 +00:00
Fixed all the cursed warnings when building.
Fixed all the values that can be nullable on the client.
This commit is contained in:
parent
2cd80970a4
commit
1acae27793
6 changed files with 52 additions and 29 deletions
|
@ -399,11 +399,14 @@ namespace AutoTrackR2
|
|||
dialog.ValidateNames = false;
|
||||
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);
|
||||
VideoPath.Text = selectedFolder; // Set the folder path
|
||||
string? selectedFolder = Path.GetDirectoryName(dialog.FileName);
|
||||
if (selectedFolder != null)
|
||||
{
|
||||
VideoPath.Text = selectedFolder; // Set the folder path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,6 +415,11 @@ namespace AutoTrackR2
|
|||
Slider slider = (Slider)sender;
|
||||
|
||||
// Build the dynamic file path for the current user
|
||||
if (string.IsNullOrEmpty(ConfigManager.AHKScriptFolder))
|
||||
{
|
||||
MessageBox.Show("AHK script folder path is not configured.", "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
string filePath = Path.Combine(
|
||||
ConfigManager.AHKScriptFolder,
|
||||
"visorwipe.ahk"
|
||||
|
@ -524,7 +532,7 @@ namespace AutoTrackR2
|
|||
|
||||
private void FlashSaveButton()
|
||||
{
|
||||
string originalText = SaveButton.Content.ToString();
|
||||
string? originalText = SaveButton.Content?.ToString() ?? string.Empty;
|
||||
SaveButton.Content = "Saved";
|
||||
|
||||
// Save button color change effect
|
||||
|
|
|
@ -26,6 +26,10 @@ public partial class HomePage : UserControl
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (string.IsNullOrEmpty(ConfigManager.KillHistoryFile))
|
||||
{
|
||||
throw new InvalidOperationException("KillHistoryFile path is not configured.");
|
||||
}
|
||||
_killHistoryManager = new KillHistoryManager(ConfigManager.KillHistoryFile);
|
||||
|
||||
// Set the TextBlock text
|
||||
|
@ -51,7 +55,7 @@ public partial class HomePage : UserControl
|
|||
}
|
||||
}
|
||||
|
||||
private void CheckStarCitizenStatus(object sender, ElapsedEventArgs e)
|
||||
private void CheckStarCitizenStatus(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
bool isRunning = IsStarCitizenRunning();
|
||||
Dispatcher.Invoke(() =>
|
||||
|
@ -311,7 +315,7 @@ public partial class HomePage : UserControl
|
|||
// Create the Image for the profile
|
||||
var profileImage = new Image
|
||||
{
|
||||
Source = new BitmapImage(new Uri(killData.PFP)), // Assuming the 8th part contains the profile image URL
|
||||
Source = new BitmapImage(new Uri(killData.PFP ?? "https://cdn.robertsspaceindustries.com/static/images/account/avatar_default_big.jpg")),
|
||||
Width = 90,
|
||||
Height = 90,
|
||||
Stretch = Stretch.Fill, // Adjust how the image fits
|
||||
|
@ -392,8 +396,13 @@ public partial class HomePage : UserControl
|
|||
textBlock.FontSize = fontSize;
|
||||
}
|
||||
|
||||
public static void RunAHKScript(string path)
|
||||
public static void RunAHKScript(string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(ConfigManager.AHKScriptFolder))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string scriptPath = Path.Combine(ConfigManager.AHKScriptFolder, path);
|
||||
|
||||
if (!File.Exists(scriptPath))
|
||||
|
|
|
@ -19,7 +19,7 @@ public struct VehicleDestructionData
|
|||
public class VehicleDestructionEvent : ILogEventHandler
|
||||
{
|
||||
public Regex Pattern { get; }
|
||||
|
||||
|
||||
public VehicleDestructionEvent()
|
||||
{
|
||||
Pattern = new Regex("""
|
||||
|
@ -34,6 +34,10 @@ public class VehicleDestructionEvent : ILogEventHandler
|
|||
|
||||
public void Handle(LogEntry entry)
|
||||
{
|
||||
if (entry.Message == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var match = Pattern.Match(entry.Message);
|
||||
if (!match.Success)
|
||||
{
|
||||
|
|
|
@ -46,8 +46,12 @@ public class LogHandler
|
|||
new RequestJumpFailedEvent()
|
||||
];
|
||||
|
||||
public LogHandler(string logPath)
|
||||
public LogHandler(string? logPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(logPath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(logPath), "Log path cannot be null or empty");
|
||||
}
|
||||
_logPath = logPath;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace AutoTrackR2
|
|||
}
|
||||
}
|
||||
|
||||
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void MainWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// Clean up resources
|
||||
homePage?.Cleanup();
|
||||
|
@ -163,10 +163,10 @@ namespace AutoTrackR2
|
|||
|
||||
// Set the fields in ConfigPage.xaml.cs based on the loaded config
|
||||
configPage.SetConfigValues(
|
||||
ConfigManager.LogFile,
|
||||
ConfigManager.ApiUrl,
|
||||
ConfigManager.ApiKey,
|
||||
ConfigManager.VideoPath,
|
||||
ConfigManager.LogFile ?? string.Empty,
|
||||
ConfigManager.ApiUrl ?? string.Empty,
|
||||
ConfigManager.ApiKey ?? string.Empty,
|
||||
ConfigManager.VideoPath ?? string.Empty,
|
||||
ConfigManager.VisorWipe,
|
||||
ConfigManager.VideoRecord,
|
||||
ConfigManager.OfflineMode,
|
||||
|
@ -177,17 +177,14 @@ namespace AutoTrackR2
|
|||
|
||||
public static class ConfigManager
|
||||
{
|
||||
public static string LogFile { get; set; }
|
||||
public static string KillHistoryFile { get; set; }
|
||||
|
||||
public static string AHKScriptFolder { get; set; }
|
||||
|
||||
public static string VisorWipeScript { get; set; }
|
||||
public static string VideoRecordScript { get; set; }
|
||||
|
||||
public static string ApiUrl { get; set; }
|
||||
public static string ApiKey { get; set; }
|
||||
public static string VideoPath { get; set; }
|
||||
public static string? LogFile { get; set; } = string.Empty;
|
||||
public static string? KillHistoryFile { get; set; } = string.Empty;
|
||||
public static string? AHKScriptFolder { get; set; } = string.Empty;
|
||||
public static string? VisorWipeScript { get; set; } = string.Empty;
|
||||
public static string? VideoRecordScript { get; set; } = string.Empty;
|
||||
public static string? ApiUrl { get; set; } = string.Empty;
|
||||
public static string? ApiKey { get; set; } = string.Empty;
|
||||
public static string? VideoPath { get; set; } = string.Empty;
|
||||
public static int VisorWipe { get; set; }
|
||||
public static int VideoRecord { get; set; }
|
||||
public static int OfflineMode { get; set; }
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace AutoTrackR2
|
|||
public partial class UpdatePage : UserControl
|
||||
{
|
||||
public static string currentVersion = "v2.09";
|
||||
private string latestVersion;
|
||||
private string? latestVersion = string.Empty;
|
||||
|
||||
public UpdatePage()
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ namespace AutoTrackR2
|
|||
// Parse the JSON using System.Text.Json
|
||||
using var document = System.Text.Json.JsonDocument.Parse(response);
|
||||
var root = document.RootElement;
|
||||
var tagName = root.GetProperty("tag_name").GetString();
|
||||
var tagName = root.GetProperty("tag_name").GetString() ?? "unknown";
|
||||
|
||||
return tagName;
|
||||
}
|
||||
|
@ -77,7 +77,8 @@ namespace AutoTrackR2
|
|||
if (root.GetArrayLength() > 0)
|
||||
{
|
||||
var firstRelease = root[0];
|
||||
return firstRelease.GetProperty("tag_name").GetString();
|
||||
var tagName = firstRelease.GetProperty("tag_name").GetString() ?? "unknown";
|
||||
return tagName;
|
||||
}
|
||||
|
||||
throw new Exception("No releases found.");
|
||||
|
@ -90,7 +91,7 @@ namespace AutoTrackR2
|
|||
return !currentVersion.Equals(latestVersion, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private async void InstallButton_Click(object sender, RoutedEventArgs e)
|
||||
private void InstallButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue