This commit is contained in:
BubbaGumpShrump 2024-12-05 16:55:51 -05:00
parent 6f993bdadf
commit 53c3b3e41a
4 changed files with 40 additions and 34 deletions

View file

@ -77,7 +77,7 @@
<TextBlock Text="Theme:" Foreground="{DynamicResource TextBrush}" FontSize="16" Margin="0,7,0,5"/> <TextBlock Text="Theme:" Foreground="{DynamicResource TextBrush}" FontSize="16" Margin="0,7,0,5"/>
<Slider x:Name="ThemeSlider" <Slider x:Name="ThemeSlider"
Minimum="0" Minimum="0"
Maximum="9" Maximum="10"
Value="0" Value="0"
TickFrequency="1" TickFrequency="1"
IsSnapToTickEnabled="True" IsSnapToTickEnabled="True"

View file

@ -264,7 +264,7 @@ namespace AutoTrackR2
}); });
} }
private void StopButton_Click(object sender, RoutedEventArgs e) public void StopButton_Click(object sender, RoutedEventArgs e)
{ {
if (runningProcess != null && !runningProcess.HasExited) if (runningProcess != null && !runningProcess.HasExited)
{ {

View file

@ -94,7 +94,6 @@ $versionPattern = "--system-trace-env-id='pub-sc-alpha-(?<gameversion>\d{4}-\d{7
# Lookup Patterns # Lookup Patterns
$joinDatePattern = '<span class="label">Enlisted</span>\s*<strong class="value">([^<]+)</strong>' $joinDatePattern = '<span class="label">Enlisted</span>\s*<strong class="value">([^<]+)</strong>'
$ueePattern = '<p class="entry citizen-record">\s*<span class="label">UEE Citizen Record<\/span>\s*<strong class="value">#?(n\/a|\d+)<\/strong>\s*<\/p>' $ueePattern = '<p class="entry citizen-record">\s*<span class="label">UEE Citizen Record<\/span>\s*<strong class="value">#?(n\/a|\d+)<\/strong>\s*<\/p>'
$global:loadout = "Player"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@ -145,7 +144,7 @@ Do {
# Initialize variable to store username # Initialize variable to store username
$global:userName = $null $global:userName = $null
$global:loadOut = $null $global:loadout = "Player"
# Loop through each line in the log to find the matching line # Loop through each line in the log to find the matching line
foreach ($line in $authLog) { foreach ($line in $authLog) {
@ -159,14 +158,14 @@ Do {
$ownerGEID = $matches['OwnerGEID'] $ownerGEID = $matches['OwnerGEID']
If ($ownerGEID -eq $global:userName -and $entity -match $shipManPattern) { If ($ownerGEID -eq $global:userName -and $entity -match $shipManPattern) {
$global:loadOut = $entity $tryloadOut = $entity
If ($global:loadOut -match $cleanupPattern){ If ($tryloadOut -match $cleanupPattern){
$global:loadOut = $matches[1] if ($null -ne $matches[1]){
$global:loadOut = $matches[1]
}
} }
Write-Output "PlayerShip=$global:loadOut"
} }
} }
Write-Output "PlayerShip=$global:loadOut" Write-Output "PlayerShip=$global:loadOut"
If ($line -match $versionPattern){ If ($line -match $versionPattern){
@ -252,13 +251,13 @@ function Read-LogEntry {
# Get Enlisted Date # Get Enlisted Date
if ($($page1.content) -match $joinDatePattern) { if ($($page1.content) -match $joinDatePattern) {
$joinDate = $matches[1] $joinDate = $matches[1]
$joinDate = $joinDate -replace ',', '' $joinDate2 = $joinDate -replace ',', ''
} else { } else {
$joinDate = "-" $joinDate2 = "-"
} }
# Check if there are any matches # Check if there are any matches
$enemyOrgs = $page1.links[4].innerHTML $enemyOrgs = $page1.links[3].innerHTML
if ($null -eq $enemyOrgs) { if ($null -eq $enemyOrgs) {
$enemyOrgs = "-" $enemyOrgs = "-"
@ -281,25 +280,28 @@ function Read-LogEntry {
# Get PFP # Get PFP
$victimPFP = "https://robertsspaceindustries.com$($page1.images[0].src)" $victimPFP = "https://robertsspaceindustries.com$($page1.images[0].src)"
Write-Output "NewKill=throwaway,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate2,$citizenRecord,$killTime,$victimPFP"
$GameMode = $GameMode.ToLower()
# Send to API # Send to API
# Define the data to send # Define the data to send
If ($null -ne $apiUrl -and $offlineMode -eq $false){ If ($null -ne $apiUrl -and $offlineMode -eq $false){
$data = @{ $data = @{
victim_ship = $enemyShip victim_ship = $enemyShip
victim = $enemyPilot victim = $enemyPilot
enlisted = $joinDate enlisted = $joinDate
rsi = $citizenRecordAPI rsi = $citizenRecordAPI
weapon = $weapon weapon = $weapon
method = $damageType method = $damageType
loadout_ship = $ship loadout_ship = $ship
game_version = $GameVersion game_version = $GameVersion
gamemode = $GameMode gamemode = $GameMode
trackr_version = $TrackRver trackr_version = $TrackRver
} }
# Headers which may or may not be necessary # Headers which may or may not be necessary
$headers = @{ $headers = @{
"Authorization" = "Bearer $apiToken" "Authorization" = "Bearer $apiKey"
"Content-Type" = "application/json" "Content-Type" = "application/json"
"User-Agent" = "AutoTrackR2" "User-Agent" = "AutoTrackR2"
} }
@ -312,7 +314,6 @@ function Read-LogEntry {
# Catch and display errors # Catch and display errors
$apiError = $_ $apiError = $_
# Add to output file # Add to output file
Add-Content -Path "$scriptFolder\kill-log.csv" -value $($_)
$logMode = "Err-Local" $logMode = "Err-Local"
} }
} Else { } Else {
@ -327,9 +328,9 @@ function Read-LogEntry {
KillTime = $killTime KillTime = $killTime
EnemyPilot = $enemyPilot EnemyPilot = $enemyPilot
EnemyShip = $enemyShip EnemyShip = $enemyShip
Enlisted = $joinDate Enlisted = $joinDate2
RecordNumber = $citizenRecord RecordNumber = $citizenRecord
OrgAffiliation = $enemyOrgs[0] OrgAffiliation = $enemyOrgs
Player = $player Player = $player
Weapon = $weapon Weapon = $weapon
Ship = $ship Ship = $ship
@ -340,14 +341,12 @@ function Read-LogEntry {
Logged = $logMode Logged = $logMode
} }
Write-Output "NewKill=break,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate,$citizenRecord,$killTime,$victimPFP" # Export to CSV
# Check if the CSV file exists
if (-Not (Test-Path $csvPath)) { if (-Not (Test-Path $csvPath)) {
# If the file does not exist, create it with headers by writing the first object # If file doesn't exist, create it with headers
$killData | Export-Csv -Path $csvPath -NoTypeInformation $killData | Export-Csv -Path $csvPath -NoTypeInformation
} else { } else {
# If the file exists, append the new data # Append data to the existing file
$killData | Export-Csv -Path $csvPath -Append -NoTypeInformation $killData | Export-Csv -Path $csvPath -Append -NoTypeInformation
} }
@ -421,8 +420,8 @@ function Read-LogEntry {
$ownerGEID = $matches['OwnerGEID'] $ownerGEID = $matches['OwnerGEID']
If ($ownerGEID -eq $global:userName -and $entity -match $shipManPattern) { If ($ownerGEID -eq $global:userName -and $entity -match $shipManPattern) {
$global:loadOut = $entity $tryloadOut = $entity
If ($global:loadOut -match $cleanupPattern){ If ($tryloadOut -match $cleanupPattern){
$global:loadOut = $matches[1] $global:loadOut = $matches[1]
} }
Write-Output "PlayerShip=$global:loadOut" Write-Output "PlayerShip=$global:loadOut"

View file

@ -51,7 +51,14 @@ namespace AutoTrackR2
UpdateTabVisuals(); UpdateTabVisuals();
} }
private void CloseWindow(object sender, RoutedEventArgs e) => this.Close(); private void CloseWindow(object sender, RoutedEventArgs e)
{
// If runningProcess is not null and still active, terminate it
homePage.StopButton_Click(sender, e);
// Close the main window
this.Close();
}
private void MinimizeWindow(object sender, RoutedEventArgs e) => this.WindowState = WindowState.Minimized; private void MinimizeWindow(object sender, RoutedEventArgs e) => this.WindowState = WindowState.Minimized;