diff --git a/AutoTrackR2/HomePage.xaml.cs b/AutoTrackR2/HomePage.xaml.cs index 99a9c0e..894fa48 100644 --- a/AutoTrackR2/HomePage.xaml.cs +++ b/AutoTrackR2/HomePage.xaml.cs @@ -6,6 +6,7 @@ using System.Windows.Media.Effects; using System.IO; using System.Windows.Documents; using System.Globalization; +using System.Windows.Media.Imaging; namespace AutoTrackR2 { @@ -73,7 +74,7 @@ namespace AutoTrackR2 ProcessStartInfo psi = new ProcessStartInfo { FileName = "powershell.exe", - Arguments = $"-NoProfile -ExecutionPolicy Bypass -File \"C:\\Program Files\\GrieferNET\\AutoTrackR2_Setup\\KillTrackR_MainScript.ps1\"", + Arguments = $"-NoProfile -ExecutionPolicy Bypass -File {scriptPath}", WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory, RedirectStandardOutput = true, RedirectStandardError = true, @@ -116,6 +117,7 @@ namespace AutoTrackR2 // 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"]; @@ -179,12 +181,54 @@ namespace AutoTrackR2 var killBorder = new Border { Style = (Style)Application.Current.Resources["RoundedTextBlockWithBorder"], // Apply border style - Child = killTextBlock // Set the TextBlock inside the Border }; + // Create a Grid to hold the TextBlock and the Image + var killGrid = new Grid + { + Width = 400, // Adjust the width of the Grid + Height = 130, // Adjust the height as needed + }; + + // Define two columns in the Grid: one for the text and one for the image + killGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) }); // Text column + killGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); // Image column + + // Add the TextBlock to the first column of the Grid + Grid.SetColumn(killTextBlock, 0); + killGrid.Children.Add(killTextBlock); + + // Create the Image for the profile + var profileImage = new Image + { + Source = new BitmapImage(new Uri(killParts[7])), // Assuming the 8th part contains the profile image URL + Width = 90, + Height = 90, + Stretch = Stretch.Fill, // Adjust how the image fits + }; + + // Create a Border around the Image + var imageBorder = new Border + { + BorderBrush = accentColorBrush, // Set the border color + BorderThickness = new Thickness(2), // Set the border thickness + Padding = new Thickness(0), // Optional padding inside the border + CornerRadius = new CornerRadius(5), + Margin = new Thickness(10,18,15,18), + Child = profileImage // Set the Image as the content of the Border + }; + + // Add the Border (with the image inside) to the Grid + Grid.SetColumn(imageBorder, 1); + killGrid.Children.Add(imageBorder); + + // Set the Grid as the child of the Border + killBorder.Child = killGrid; + // Add the new Border to the StackPanel inside the Border KillFeedStackPanel.Children.Insert(0, killBorder); } + else { DebugPanel.AppendText(e.Data + Environment.NewLine); diff --git a/AutoTrackR2/KillTrackR_MainScript.ps1 b/AutoTrackR2/KillTrackR_MainScript.ps1 index 18a5d22..b403b21 100644 --- a/AutoTrackR2/KillTrackR_MainScript.ps1 +++ b/AutoTrackR2/KillTrackR_MainScript.ps1 @@ -87,12 +87,51 @@ $versionPattern = "--system-trace-env-id='pub-sc-alpha-(?<gameversion>\d{4}-\d{7 # Lookup Patterns $joinDatePattern = '<span class="label">Enlisted</span>\s*<strong class="value">([^<]+)</strong>' -$orgPattern = '<IMG[^>]*>\s*([^<]+)' $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 +<# +$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 +$enemyOrgs = $page1.links[4].innerHTML + +if ($null -eq $enemyOrgs) { + $enemyOrgs = "-" +} + +# Get UEE Number +if ($($page1.content) -match $ueePattern) { + # 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 Do { # Load gamelog into memory @@ -203,25 +242,20 @@ function Read-LogEntry { $KillTime = (Get-Date).ToUniversalTime().ToString("d MMM yyyy H:mm 'UTC'") $page1 = Invoke-WebRequest -uri "https://robertsspaceindustries.com/citizens/$enemyPilot" - $page2 = Invoke-WebRequest -uri "https://robertsspaceindustries.com/citizens/$enemyPilot/organizations" # Get Enlisted Date if ($($page1.content) -match $joinDatePattern) { $joinDate = $matches[1] - $joinDate = = $date -replace ',', '' + $joinDate = $joinDate -replace ',', '' } else { - $joinDate = "UNKNOWN" + $joinDate = "-" } - # Find Org matches using the regex pattern - $orgMatches = [regex]::matches($($page2.links.innerhtml), $orgPattern) # Check if there are any matches - $enemyOrgs = @() - if ($orgMatches.Count -eq 0) { - $enemyOrgs = "N/A" - } else { - # Loop through each match and display the organization name - $enemyOrgs = $match.Groups[1].Value.Trim() + $enemyOrgs = $page1.links[4].innerHTML + + if ($null -eq $enemyOrgs) { + $enemyOrgs = "-" } # Get UEE Number @@ -229,14 +263,18 @@ function Read-LogEntry { # The matched UEE Citizen Record number is in $matches[1] $citizenRecord = $matches[1] } else { - $citizenRecord = "-1" + $citizenRecord = "-" } - If ($citizenRecord -eq "N/A") { + If ($citizenRecord -eq "n/a") { $citizenRecordAPI = "-1" + $citizenRecord = "-" } Else { $citizenRecordAPI = $citizenRecord } + # Get PFP + $victimPFP = "https://robertsspaceindustries.com$($page1.images[0].src)" + # Send to API # Define the data to send If ($apiUrl -eq $true -and $offlineMode -eq $false){ @@ -248,9 +286,9 @@ function Read-LogEntry { weapon = $weapon method = $damageType loadout_ship = $ship - gameVersion = $GameVersion - gameMode = $GameMode - trackrVersion = $TrackRver + #gameVersion = $GameVersion + #gameMode = $GameMode + #trackrVersion = $TrackRver } # Headers which may or may not be necessary @@ -296,7 +334,7 @@ function Read-LogEntry { Logged = $logMode } - Write-Output "NewKill=break,$enemyPilot,$enemyShip,$($enemyOrgs[0]),$joinDate,$citizenRecord,$killTime" + Write-Output "NewKill=break,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate,$citizenRecord,$killTime,$victimPFP" # Export the object to a CSV # If the CSV file does not exist, it will create a new file with headers.