mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-06-19 21:19:07 +00:00
KillTally
This commit is contained in:
parent
2b003ef7f8
commit
af8d0a756b
6 changed files with 83 additions and 68 deletions
AutoTrackR2
AutoTrackR2_Setup
|
@ -27,7 +27,7 @@
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- StackPanel for Start and Stop buttons -->
|
<!-- StackPanel for Start and Stop buttons -->
|
||||||
<Border Background="{DynamicResource BackgroundDarkBrush}" BorderBrush="{DynamicResource AccentBrush}" Grid.Row="0" Grid.Column="1" BorderThickness="2" CornerRadius="5" Margin="0,0,0,134"/>
|
<Border Background="{DynamicResource BackgroundDarkBrush}" BorderBrush="{DynamicResource AccentBrush}" Grid.Row="0" Grid.Column="1" BorderThickness="2" CornerRadius="5" Margin="0,0,0,82"/>
|
||||||
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="269" Width="152">
|
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="269" Width="152">
|
||||||
<TextBlock Name="PilotNameTitle" Text="Pilot" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,5,0,0" Foreground="{DynamicResource AltTextBrush}" FontSize="14"/>
|
<TextBlock Name="PilotNameTitle" Text="Pilot" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,5,0,0" Foreground="{DynamicResource AltTextBrush}" FontSize="14"/>
|
||||||
<TextBlock Name="PilotNameTextBox" Text="" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="10" TextAlignment="Center"/>
|
<TextBlock Name="PilotNameTextBox" Text="" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="10" TextAlignment="Center"/>
|
||||||
|
@ -35,7 +35,9 @@
|
||||||
<TextBlock Name="PlayerShipTextBox" Text="" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="10" TextAlignment="Center"/>
|
<TextBlock Name="PlayerShipTextBox" Text="" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="10" TextAlignment="Center"/>
|
||||||
<TextBlock Name="GameModeTitle" Text="Game Mode" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,5,0,0" Foreground="{DynamicResource AltTextBrush}" FontSize="14"/>
|
<TextBlock Name="GameModeTitle" Text="Game Mode" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,5,0,0" Foreground="{DynamicResource AltTextBrush}" FontSize="14"/>
|
||||||
<TextBlock Name="GameModeTextBox" Text="" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="10" TextAlignment="Center"/>
|
<TextBlock Name="GameModeTextBox" Text="" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="10" TextAlignment="Center"/>
|
||||||
<TextBox Name="DebugPanel" Text="" Width="152" Height="136" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="8" BorderThickness="0"/>
|
<TextBlock Name="KillTallyTitle" Text="Kill Tally" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,5,0,0" Foreground="{DynamicResource AltTextBrush}" FontSize="14"/>
|
||||||
|
<TextBlock Name="KillTallyTextBox" Text="" Width="152" Height="20" Background="Transparent" FontFamily="{StaticResource Orbitron}" Margin="0,0,0,0" Foreground="{DynamicResource TextBrush}" FontSize="10" TextAlignment="Center"/>
|
||||||
|
<TextBox x:Name="DebugPanel" Text="" Width="152" Height="98" Background="Transparent" FontFamily="{StaticResource Orbitron}" Foreground="{DynamicResource TextBrush}" FontSize="8" BorderThickness="0" Margin="0,9,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="120" Width="172" >
|
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="120" Width="172" >
|
||||||
<Button Name="StartButton" Content="Start" Width="100" Height="40" Style="{StaticResource ButtonStyle}" FontFamily="{StaticResource Orbitron}" Margin="0,20" Click="StartButton_Click"/>
|
<Button Name="StartButton" Content="Start" Width="100" Height="40" Style="{StaticResource ButtonStyle}" FontFamily="{StaticResource Orbitron}" Margin="0,20" Click="StartButton_Click"/>
|
||||||
|
|
|
@ -109,6 +109,12 @@ namespace AutoTrackR2
|
||||||
GameModeTextBox.Text = gameMode;
|
GameModeTextBox.Text = gameMode;
|
||||||
AdjustFontSize(GameModeTextBox);
|
AdjustFontSize(GameModeTextBox);
|
||||||
}
|
}
|
||||||
|
else if (e.Data.Contains("KillTally="))
|
||||||
|
{
|
||||||
|
string killTally = e.Data.Split('=')[1].Trim();
|
||||||
|
KillTallyTextBox.Text = killTally;
|
||||||
|
AdjustFontSize(KillTallyTextBox);
|
||||||
|
}
|
||||||
else if (e.Data.Contains("NewKill="))
|
else if (e.Data.Contains("NewKill="))
|
||||||
{
|
{
|
||||||
// Parse the kill data
|
// Parse the kill data
|
||||||
|
|
|
@ -97,45 +97,18 @@ $ueePattern = '<p class="entry citizen-record">\s*<span class="label">UEE Citize
|
||||||
|
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
$process = Get-Process | Where-Object {$_.Name -like "AutoTrackR2"}
|
$process = Get-Process | Where-Object {$_.Name -like "AutoTrackR2"}
|
||||||
<#
|
$global:killTally = 0
|
||||||
$enemyPilot = "feezydafox"
|
|
||||||
$enemyShip = "AEGS_Gladius"
|
|
||||||
$KillTime = (Get-Date).ToUniversalTime().ToString("d MMM yyyy H:mm 'UTC'")
|
|
||||||
$page1 = Invoke-WebRequest -uri "https://robertsspaceindustries.com/citizens/$enemyPilot"
|
|
||||||
|
|
||||||
# Get Enlisted Date
|
|
||||||
if ($($page1.content) -match $joinDatePattern) {
|
|
||||||
$joinDate = $matches[1]
|
|
||||||
$joinDate = $joinDate -replace ',', ''
|
|
||||||
} else {
|
|
||||||
$joinDate = "-"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if there are any matches
|
# Load historic kills from csv
|
||||||
$enemyOrgs = $page1.links[4].innerHTML
|
$historicKills = Import-CSV "$scriptFolder\Kill-log.csv" | Sort-Object Descending
|
||||||
|
Try{
|
||||||
if ($null -eq $enemyOrgs) {
|
foreach ($kill in $historicKills) {
|
||||||
$enemyOrgs = "-"
|
Write-Output "NewKill=throwaway,$($kill.EnemyPilot),$($kill.EnemyShip),$($kill.OrgAffiliation),$($kill.Enlisted),$($kill.RecordNumber),$($kill.KillTime),$($kill.PFP)"
|
||||||
}
|
$global:killTally++
|
||||||
|
}
|
||||||
# Get UEE Number
|
} Catch {}
|
||||||
if ($($page1.content) -match $ueePattern) {
|
Write-Output "KillTally=$global:killTally"
|
||||||
# The matched UEE Citizen Record number is in $matches[1]
|
|
||||||
$citizenRecord = $matches[1]
|
|
||||||
} else {
|
|
||||||
$citizenRecord = "-"
|
|
||||||
}
|
|
||||||
If ($citizenRecord -eq "n/a") {
|
|
||||||
$citizenRecordAPI = "-1"
|
|
||||||
$citizenRecord = "-"
|
|
||||||
} Else {
|
|
||||||
$citizenRecordAPI = $citizenRecord
|
|
||||||
}
|
|
||||||
# Get PFP
|
|
||||||
$victimPFP = "https://robertsspaceindustries.com$($page1.images[0].src)"
|
|
||||||
|
|
||||||
Write-Output "NewKill=break,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate,$citizenRecord,$killTime,$victimPFP"
|
|
||||||
#>
|
|
||||||
|
|
||||||
# Match and extract username from gamelog
|
# Match and extract username from gamelog
|
||||||
Do {
|
Do {
|
||||||
|
@ -296,6 +269,8 @@ function Read-LogEntry {
|
||||||
$victimPFP = $page1.images[0].src
|
$victimPFP = $page1.images[0].src
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$global:killTally++
|
||||||
|
Write-Output "KillTally=$global:killTally"
|
||||||
Write-Output "NewKill=throwaway,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate2,$citizenRecord,$killTime,$victimPFP"
|
Write-Output "NewKill=throwaway,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate2,$citizenRecord,$killTime,$victimPFP"
|
||||||
|
|
||||||
$GameMode = $GameMode.ToLower()
|
$GameMode = $GameMode.ToLower()
|
||||||
|
@ -355,6 +330,7 @@ function Read-LogEntry {
|
||||||
GameVersion = $GameVersion
|
GameVersion = $GameVersion
|
||||||
TrackRver = $TrackRver
|
TrackRver = $TrackRver
|
||||||
Logged = $logMode
|
Logged = $logMode
|
||||||
|
PFP = $victimPFP
|
||||||
}
|
}
|
||||||
|
|
||||||
# Export to CSV
|
# Export to CSV
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<!-- Install Button -->
|
<!-- Install Button -->
|
||||||
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="2" Grid.Column="2">
|
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="2" Grid.Column="2">
|
||||||
<Button x:Name="InstallButton" Content="Install Update" Width="150" Height="40" IsEnabled="False"
|
<Button x:Name="InstallButton" Content="Install Update" Width="150" Height="40" IsEnabled="False"
|
||||||
Click="InstallButton_Click" Style="{StaticResource ButtonStyle}" FontFamily="{StaticResource Orbitron}"/>
|
Click="InstallButton_Click" Style="{StaticResource DisabledButtonStyle}" FontFamily="{StaticResource Orbitron}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace AutoTrackR2
|
||||||
{
|
{
|
||||||
public partial class UpdatePage : UserControl
|
public partial class UpdatePage : UserControl
|
||||||
{
|
{
|
||||||
private string currentVersion = "v2.0-beta.1";
|
private string currentVersion = "v2.0-beta.01";
|
||||||
private string latestVersion;
|
private string latestVersion;
|
||||||
|
|
||||||
public UpdatePage()
|
public UpdatePage()
|
||||||
|
@ -33,6 +33,7 @@ namespace AutoTrackR2
|
||||||
if (IsNewVersionAvailable(currentVersion, latestVersion))
|
if (IsNewVersionAvailable(currentVersion, latestVersion))
|
||||||
{
|
{
|
||||||
InstallButton.IsEnabled = true;
|
InstallButton.IsEnabled = true;
|
||||||
|
InstallButton.Style = (Style)FindResource("ButtonStyle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -94,25 +95,25 @@ namespace AutoTrackR2
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InstallButton.IsEnabled = false;
|
InstallButton.IsEnabled = false;
|
||||||
InstallButton.Content = "Installing...";
|
InstallButton.Content = "Preparing to Install...";
|
||||||
|
|
||||||
// Define the download URL
|
// Get the download URL for the latest release
|
||||||
string downloadUrl = "https://github.com/BubbaGumpShrump/AutoTrackR2/releases/download/v2.0-beta.1/AutoTrackR2_Setup.msi";
|
string downloadUrl = await GetLatestMsiDownloadUrlFromGitHub();
|
||||||
|
|
||||||
// Download the installer before closing the app
|
// Download the installer to the user's Downloads folder
|
||||||
string installerPath = await DownloadInstaller(downloadUrl);
|
string installerPath = await DownloadInstallerToDownloads(downloadUrl);
|
||||||
|
|
||||||
// Launch the installer after the download completes
|
// Launch the installer for manual installation
|
||||||
RunInstaller(installerPath);
|
RunInstaller(installerPath);
|
||||||
|
|
||||||
// Gracefully close the app after starting the installer
|
// Gracefully close the app after launching the installer
|
||||||
Application.Current.Shutdown();
|
Application.Current.Shutdown();
|
||||||
|
|
||||||
MessageBox.Show("Update installed successfully. Please restart the application.", "Update Installed", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show("Update installer has been downloaded. Please finish the installation manually.", "Update Ready", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Failed to install update: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show($"Failed to download and launch the installer: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -121,39 +122,69 @@ namespace AutoTrackR2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> DownloadInstaller(string url)
|
private async Task<string> GetLatestMsiDownloadUrlFromGitHub()
|
||||||
{
|
{
|
||||||
string tempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "AutoTrackR2_Setup.msi");
|
using var client = new HttpClient();
|
||||||
|
client.DefaultRequestHeaders.Add("User-Agent", "AutoTrackR2");
|
||||||
|
|
||||||
|
string repoOwner = "BubbaGumpShrump";
|
||||||
|
string repoName = "AutoTrackR2";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Fetch the latest release info from GitHub
|
||||||
|
var url = $"https://api.github.com/repos/{repoOwner}/{repoName}/releases/latest";
|
||||||
|
var response = await client.GetStringAsync(url);
|
||||||
|
|
||||||
|
// Parse the JSON response
|
||||||
|
using var document = System.Text.Json.JsonDocument.Parse(response);
|
||||||
|
var root = document.RootElement;
|
||||||
|
|
||||||
|
// Find the .msi asset in the release
|
||||||
|
foreach (var asset in root.GetProperty("assets").EnumerateArray())
|
||||||
|
{
|
||||||
|
string assetName = asset.GetProperty("name").GetString();
|
||||||
|
if (assetName.EndsWith(".msi"))
|
||||||
|
{
|
||||||
|
return asset.GetProperty("browser_download_url").GetString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("No .msi file found in the latest release.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception($"Error fetching the release data: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<string> DownloadInstallerToDownloads(string url)
|
||||||
|
{
|
||||||
|
// Get the path to the user's Downloads folder
|
||||||
|
string downloadsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Downloads";
|
||||||
|
string installerPath = Path.Combine(downloadsFolder, "AutoTrackR2_Setup.msi");
|
||||||
|
|
||||||
using var client = new HttpClient();
|
using var client = new HttpClient();
|
||||||
var response = await client.GetAsync(url);
|
var response = await client.GetAsync(url);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
using var fs = new System.IO.FileStream(tempFilePath, System.IO.FileMode.Create);
|
// Write the downloaded content to the Downloads folder
|
||||||
|
using var fs = new FileStream(installerPath, FileMode.Create);
|
||||||
await response.Content.CopyToAsync(fs);
|
await response.Content.CopyToAsync(fs);
|
||||||
|
|
||||||
return tempFilePath;
|
return installerPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunInstaller(string installerPath)
|
private void RunInstaller(string installerPath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Prepare the command to run the .msi installer using msiexec
|
// Start the installer manually (this will let the user run it)
|
||||||
var processStartInfo = new System.Diagnostics.ProcessStartInfo
|
System.Diagnostics.Process.Start(installerPath);
|
||||||
{
|
|
||||||
FileName = "msiexec",
|
|
||||||
Arguments = $"/i \"{installerPath}\" /quiet /norestart",
|
|
||||||
UseShellExecute = false, // Ensures that the process runs in the background
|
|
||||||
CreateNoWindow = true // Hides the command prompt window
|
|
||||||
};
|
|
||||||
|
|
||||||
// Start the process (this will run the installer)
|
|
||||||
System.Diagnostics.Process.Start(processStartInfo);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Failed to start the installer: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show($"Failed to open the installer: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,8 +198,8 @@
|
||||||
{
|
{
|
||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:AutoTrackR2_Setup"
|
"ProductName" = "8:AutoTrackR2_Setup"
|
||||||
"ProductCode" = "8:{108D4428-AB25-444D-90C2-E507EA3020D8}"
|
"ProductCode" = "8:{F79114DA-3386-4C48-8836-A39014EFC706}"
|
||||||
"PackageCode" = "8:{0EBFA2DB-5EEC-48A0-9212-E8C33A05CE53}"
|
"PackageCode" = "8:{AE03249A-7FA7-432F-A8D6-D6B34490F51F}"
|
||||||
"UpgradeCode" = "8:{0B78A147-D0DE-4F72-8906-A62611787CA7}"
|
"UpgradeCode" = "8:{0B78A147-D0DE-4F72-8906-A62611787CA7}"
|
||||||
"AspNetVersion" = "8:"
|
"AspNetVersion" = "8:"
|
||||||
"RestartWWWService" = "11:FALSE"
|
"RestartWWWService" = "11:FALSE"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue