mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-05-25 17:35:31 +00:00
Remove Update and Stats page. Fix Feezy theme.
This commit is contained in:
parent
4059eba481
commit
2dcf2e3571
8 changed files with 6 additions and 221 deletions
|
@ -293,11 +293,11 @@ namespace AutoTrackR2
|
|||
break;
|
||||
case 16: // Feezy
|
||||
UpdateThemeColors(
|
||||
(Color)ColorConverter.ConvertFromString("#FFA500"), // Accent/Border - Orange
|
||||
(Color)ColorConverter.ConvertFromString("#FFE4B5"), // Button - Moccasin
|
||||
(Color)ColorConverter.ConvertFromString("#FFF8DC"), // Background - Cornsilk
|
||||
(Color)ColorConverter.ConvertFromString("#8B4513"), // Text - Saddle Brown
|
||||
(Color)ColorConverter.ConvertFromString("#FF7F50") // AltText - Coral
|
||||
(Color)ColorConverter.ConvertFromString("#FFA500"), // Accent/Border
|
||||
(Color)ColorConverter.ConvertFromString("#1B0C04"), // Button
|
||||
(Color)ColorConverter.ConvertFromString("#1B0C04"), // Background
|
||||
(Color)ColorConverter.ConvertFromString("#FFE4B5"), // Text
|
||||
(Color)ColorConverter.ConvertFromString("#FFE4B5") // AltText
|
||||
);
|
||||
ChangeLogo("/Assets/chibifox.png", (Color)ColorConverter.ConvertFromString("#FFA500"));
|
||||
break;
|
||||
|
|
|
@ -178,7 +178,7 @@ public partial class HomePage : UserControl
|
|||
Method = actorDeathData.DamageType,
|
||||
RecordNumber = playerData?.UEERecord,
|
||||
GameVersion = LocalPlayerData.GameVersion ?? "Unknown",
|
||||
TrackRver = UpdatePage.currentVersion.Replace("v", "") ?? "Unknown",
|
||||
TrackRver = LocalPlayerData.GameVersion?.Replace("v", "") ?? "Unknown",
|
||||
Enlisted = playerData?.JoinDate,
|
||||
KillTime = DateTime.UtcNow.ToString("dd MMM yyyy HH:mm"),
|
||||
PFP = playerData?.PFPURL ?? "https://cdn.robertsspaceindustries.com/static/images/account/avatar_default_big.jpg"
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
<StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5,0,0,0">
|
||||
<Image x:Name="Logo" Height="138" Source="/Assets/AutoTrackR.png" Stretch="Fill" Width="141" RenderOptions.BitmapScalingMode="Fant"/>
|
||||
<Button Content="Home" Name="HomeTab" Margin="10,40,10,10" Height="40" Style="{StaticResource TabButtonStyle}" Click="TabButton_Click"/>
|
||||
<Button Content="Stats" Name="StatsTab" Margin="10" Height="40" Style="{StaticResource TabButtonStyle}" Click="TabButton_Click"/>
|
||||
<Button Content="Update" Name="UpdateTab" Margin="10" Height="40" Style="{StaticResource TabButtonStyle}" Click="TabButton_Click"/>
|
||||
<Button Content="Config" Name="ConfigTab" Margin="10" Height="40" Style="{StaticResource TabButtonStyle}" Click="TabButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -93,14 +93,6 @@ namespace AutoTrackR2
|
|||
// Reuse the existing HomePage instance
|
||||
ContentControl.Content = homePage;
|
||||
}
|
||||
else if (clickedTabName == "StatsTab")
|
||||
{
|
||||
ContentControl.Content = new StatsPage();
|
||||
}
|
||||
else if (clickedTabName == "UpdateTab")
|
||||
{
|
||||
ContentControl.Content = new UpdatePage();
|
||||
}
|
||||
else if (clickedTabName == "ConfigTab")
|
||||
{
|
||||
ContentControl.Content = new ConfigPage(this);
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<UserControl x:Class="AutoTrackR2.StatsPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Height="396" Width="626">
|
||||
<Grid Background="{DynamicResource BackgroundLightBrush}">
|
||||
<TextBlock Text="Stats and graphs coming soon!" FontSize="24" Foreground="{DynamicResource TextBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -1,12 +0,0 @@
|
|||
using System.Windows.Controls;
|
||||
|
||||
namespace AutoTrackR2
|
||||
{
|
||||
public partial class StatsPage : UserControl
|
||||
{
|
||||
public StatsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<UserControl x:Class="AutoTrackR2.UpdatePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Height="396" Width="626">
|
||||
<Grid Background="{DynamicResource BackgroundLightBrush}">
|
||||
<Grid Margin="0,0,5,7">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Current Version Display -->
|
||||
<StackPanel Orientation="Horizontal" Margin="10" Grid.Row="0">
|
||||
<TextBlock Text="Current Version: " FontSize="16" FontWeight="Bold" VerticalAlignment="Center" Foreground="{DynamicResource AltTextBrush}" />
|
||||
<TextBlock x:Name="CurrentVersionText" Text="2.0-beta.0" FontSize="16" VerticalAlignment="Center" Foreground="{DynamicResource TextBrush}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Available Version Display -->
|
||||
<StackPanel Orientation="Horizontal" Margin="10" Grid.Row="1">
|
||||
<TextBlock Text="Available Version: " FontSize="16" FontWeight="Bold" VerticalAlignment="Center" Foreground="{DynamicResource AltTextBrush}"/>
|
||||
<TextBlock x:Name="AvailableVersionText" Text="Checking..." FontSize="16" VerticalAlignment="Center" Foreground="{DynamicResource TextBrush}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20" Grid.Row="2">
|
||||
<TextBlock Text="Still a work in progress. Please uninstall current version before installing update." FontSize="16" Foreground="{DynamicResource TextBrush}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Install Button -->
|
||||
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="2" Grid.Column="2">
|
||||
<Button x:Name="InstallButton" Content="Download Update" Width="150" Height="40" IsEnabled="False"
|
||||
Click="InstallButton_Click" Style="{StaticResource DisabledButtonStyle}" FontFamily="{StaticResource Orbitron}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -1,146 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace AutoTrackR2
|
||||
{
|
||||
public partial class UpdatePage : UserControl
|
||||
{
|
||||
public static string currentVersion = "v2.09";
|
||||
private string? latestVersion = string.Empty;
|
||||
|
||||
public UpdatePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
CurrentVersionText.Text = currentVersion;
|
||||
CheckForUpdates();
|
||||
}
|
||||
|
||||
private async void CheckForUpdates()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Fetch the latest release info from GitHub
|
||||
latestVersion = await GetLatestVersionFromGitHub();
|
||||
|
||||
// Update the Available Version field
|
||||
AvailableVersionText.Text = latestVersion;
|
||||
|
||||
// Enable the Install button if a new version is available
|
||||
if (IsNewVersionAvailable(currentVersion, latestVersion))
|
||||
{
|
||||
InstallButton.IsEnabled = true;
|
||||
InstallButton.Style = (Style)FindResource("ButtonStyle");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AvailableVersionText.Text = "Error checking updates.";
|
||||
MessageBox.Show($"Failed to check for updates: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> GetLatestVersionFromGitHub()
|
||||
{
|
||||
using var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Add("User-Agent", "AutoTrackR2");
|
||||
|
||||
string repoOwner = "BubbaGumpShrump";
|
||||
string repoName = "AutoTrackR2";
|
||||
|
||||
try
|
||||
{
|
||||
// Attempt to fetch the latest release
|
||||
var url = $"https://api.github.com/repos/{repoOwner}/{repoName}/releases/latest";
|
||||
var response = await client.GetStringAsync(url);
|
||||
|
||||
// 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() ?? "unknown";
|
||||
|
||||
return tagName;
|
||||
}
|
||||
catch (HttpRequestException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
// Fallback to releases list if 'latest' not found
|
||||
var url = $"https://api.github.com/repos/{repoOwner}/{repoName}/releases";
|
||||
var response = await client.GetStringAsync(url);
|
||||
|
||||
using var document = System.Text.Json.JsonDocument.Parse(response);
|
||||
var root = document.RootElement;
|
||||
|
||||
// Get the tag name of the first release
|
||||
if (root.GetArrayLength() > 0)
|
||||
{
|
||||
var firstRelease = root[0];
|
||||
var tagName = firstRelease.GetProperty("tag_name").GetString() ?? "unknown";
|
||||
return tagName;
|
||||
}
|
||||
|
||||
throw new Exception("No releases found.");
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsNewVersionAvailable(string currentVersion, string latestVersion)
|
||||
{
|
||||
// Return true if the versions are different
|
||||
return !currentVersion.Equals(latestVersion, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private void InstallButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
InstallButton.IsEnabled = false;
|
||||
InstallButton.Content = "Preparing to Update...";
|
||||
|
||||
// Get the path to the update.ps1 script
|
||||
string scriptPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "update.ps1");
|
||||
|
||||
// Run the PowerShell script
|
||||
RunPowerShellScript(scriptPath);
|
||||
|
||||
// Gracefully close the app after running the script
|
||||
Application.Current.Shutdown();
|
||||
|
||||
MessageBox.Show("Update process has started. Please follow the instructions in the PowerShell script.", "Update Started", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Failed to run the update script: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
InstallButton.IsEnabled = true;
|
||||
InstallButton.Content = "Install Update";
|
||||
}
|
||||
}
|
||||
|
||||
private void RunPowerShellScript(string scriptPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Prepare the command to run the PowerShell script with elevation (admin rights)
|
||||
var processStartInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = "powershell.exe",
|
||||
Arguments = $"-ExecutionPolicy Bypass -File \"{scriptPath}\"", // Allow script to run
|
||||
Verb = "runas", // Request elevation (admin rights)
|
||||
UseShellExecute = true, // Use the shell to execute the process
|
||||
CreateNoWindow = false // Show the PowerShell window
|
||||
};
|
||||
|
||||
// Start the PowerShell process to run the script with admin rights
|
||||
System.Diagnostics.Process.Start(processStartInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Failed to run the PowerShell script with admin rights: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue