Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 122 additions & 9 deletions RTXLauncher.Fazor/AboutPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

<root class="about-page">
<div class="auto-layout column">
<groupbox text="The Garry's Mod RTX Launcher">
<groupbox title="The Garry's Mod RTX Launcher">
<div class="auto-layout column">
<label>Based on the original by CR, written by Xenthio and CR.</label>
<label>Current Version: @currentVersion</label>
</div>
</groupbox>

<groupbox text="Updates">
<groupbox title="Updates">
<div class="auto-layout column">
<textentry multiline="true" readonly="true" value="@releaseNotes" style="height: 200px; flex: 1;" />

<div class="update-controls" style="display: flex; flex-direction: row; gap: 10px;">
<combobox @bind-value="selectedUpdateSource" style="width: 200px;">
<combobox value="@selectedUpdateSource" ValueChanged="@OnUpdateSourceChanged" style="width: 200px;">
@foreach (var source in updateSources)
{
<option value="@source">@source</option>
}
</combobox>
<button @onclick="InstallUpdate" disabled="@isCheckingForUpdates">Install</button>
<button @onclick="InstallUpdate" disabled="@(string.IsNullOrEmpty(latestReleaseUrl))">Open Release Page</button>
<button @onclick="CheckForUpdates" disabled="@isCheckingForUpdates">Check for Updates</button>
</div>
</div>
Expand All @@ -41,28 +41,141 @@
private List<string> updateSources = new() { "Stable", "Beta", "Experimental" };
private string selectedUpdateSource = "Stable";
private GitHubService? gitHubService;
private string? latestReleaseUrl;

public AboutPage()
{
gitHubService = new GitHubService();
currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "Unknown";

// Auto-check for updates on page load
CheckForUpdates();
}

private async void CheckForUpdates()
{
if (gitHubService == null) return;

isCheckingForUpdates = true;
releaseNotes = "Checking for updates...";
StateHasChanged();

await System.Threading.Tasks.Task.Delay(1000);
releaseNotes = "No updates available at this time.";
isCheckingForUpdates = false;
StateHasChanged();
try
{
// Check for launcher updates from the RTXLauncher repository
var releases = await gitHubService.FetchReleasesAsync("Xenthio", "RTXLauncher");

if (releases != null && releases.Count > 0)
{
var latestRelease = releases[0]; // First release is the latest
latestReleaseUrl = latestRelease.HtmlUrl;
releaseNotes = $"Latest Release: {latestRelease.Name}\n\n{latestRelease.Body}";

// Compare versions using semantic version parsing
bool updateAvailable = false;
try
{
// Strip 'v' prefix if present
var latestVersionStr = latestRelease.TagName?.TrimStart('v') ?? "0.0.0";
var currentVersionStr = currentVersion.TrimStart('v');

if (System.Version.TryParse(latestVersionStr, out var latestVersion) &&
System.Version.TryParse(currentVersionStr, out var currentVer))
{
updateAvailable = latestVersion > currentVer;
}
else
{
// Fallback to string comparison
updateAvailable = latestRelease.TagName != currentVersion;
}
}
catch
{
// Fallback to string comparison on error
updateAvailable = latestRelease.TagName != currentVersion;
}

if (updateAvailable)
{
releaseNotes = $"⬆️ Update Available!\n\nLatest: {latestRelease.TagName}\nCurrent: {currentVersion}\n\n{latestRelease.Body}";
AddLogToMainWindow($"Update available: {latestRelease.TagName}");
}
else
{
AddLogToMainWindow("You are running the latest version.");
}
}
else
{
releaseNotes = "No updates found.";
}
}
catch (System.Exception ex)
{
releaseNotes = $"Error checking for updates: {ex.Message}";
AddLogToMainWindow($"Failed to check for updates: {ex.Message}");
}
finally
{
isCheckingForUpdates = false;
StateHasChanged();
}
}

private void InstallUpdate()
{
System.Console.WriteLine($"Installing update from {selectedUpdateSource}...");
if (!string.IsNullOrEmpty(latestReleaseUrl))
{
try
{
// Open the release page in the default browser
var psi = new System.Diagnostics.ProcessStartInfo
{
FileName = latestReleaseUrl,
UseShellExecute = true
};
System.Diagnostics.Process.Start(psi);
AddLogToMainWindow($"Opening release page: {latestReleaseUrl}");
}
catch (System.Exception ex)
{
AddLogToMainWindow($"Error opening release page: {ex.Message}");
}
}
else
{
AddLogToMainWindow("No update URL available.");
}
}

private void AddLogToMainWindow(string message)
{
var mainWindow = FindMainWindow();
if (mainWindow != null)
{
mainWindow.AddLogMessage(message);
}
}

private void OnUpdateSourceChanged(string value)
{
selectedUpdateSource = value;
StateHasChanged();
}

private MainWindow? FindMainWindow()
{
var current = Parent;
while (current != null)
{
if (current is MainWindow window)
{
return window;
}
current = current.Parent;
}
return null;
}

protected override int BuildHash()
Expand Down
24 changes: 19 additions & 5 deletions RTXLauncher.Fazor/AdvancedInstallPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<root class="advanced-install-page">
<div class="auto-layout column">
<!-- Vanilla Garry's Mod Install Section -->
<groupbox text="Your Vanilla Garry's Mod Install">
<groupbox title="Your Vanilla Garry's Mod Install">
<div class="auto-layout column">
<div class="info-row" style="display: flex; flex-direction: row; gap: 10px; align-items: center;">
<label class="label-bold">Install Type:</label>
Expand All @@ -35,7 +35,7 @@
</groupbox>

<!-- RTX Install Section -->
<groupbox text="This RTX Install">
<groupbox title="This RTX Install">
<div class="auto-layout column">
<div class="info-row" style="display: flex; flex-direction: row; gap: 10px; align-items: center;">
<label class="label-bold">Install Type:</label>
Expand All @@ -62,7 +62,7 @@
<!-- Dynamic Package List -->
@foreach (var package in packages)
{
<groupbox text="@package.Title">
<groupbox title="@package.Title">
<div class="auto-layout column">
<div class="package-status">
@if (package.HasInstalledVersion)
Expand All @@ -77,7 +77,7 @@

<div class="setting-row" style="display: flex; flex-direction: row; gap: 10px; align-items: center;">
<label>Source:</label>
<combobox @bind-value="package.SelectedSource" style="width: 200px;">
<combobox value="@package.SelectedSource" ValueChanged="@OnPackageSourceChanged" style="width: 200px;">
@foreach (var source in package.Sources)
{
<option value="@source">@source</option>
Expand All @@ -89,7 +89,7 @@
{
<div class="setting-row" style="display: flex; flex-direction: row; gap: 10px; align-items: center;">
<label>Version:</label>
<combobox @bind-value="package.SelectedRelease" style="width: 200px;">
<combobox value="@package.SelectedRelease" ValueChanged="@OnPackageReleaseChanged" style="width: 200px;">
@foreach (var release in package.Releases)
{
<option value="@release">@release.Name</option>
Expand Down Expand Up @@ -199,6 +199,20 @@
isBusy = false;
StateHasChanged();
}

private void OnPackageSourceChanged(string value)
{
// Note: This would need to know which package changed
// For now just trigger state update
StateHasChanged();
}

private void OnPackageReleaseChanged(string value)
{
// Note: This would need to know which package changed
// For now just trigger state update
StateHasChanged();
}

protected override int BuildHash()
{
Expand Down
44 changes: 36 additions & 8 deletions RTXLauncher.Fazor/Assets/SimpleDarkTheme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ $highlight-tint: #096085;
$grey-text: #808080;

$button-face: #505050;
$button-shadow: #282828;
$button-shadow: #808080;
$button-text: #DEDEDE;
$button-highlight: #686868;
$button-dark-shadow: #000000;
$button-highlight: #808080;
$button-dark-shadow: #808080;
$button-light: #808080;

$background: #282828;
Expand All @@ -64,15 +64,19 @@ $theme-border-mid: #808080;
$theme-border-high: #A0A0A0;
$theme-control-mid: #505050;
$theme-control-mid-high: #686868;
$theme-foreground: #DEDEDE; // Alias for $window-text

// Window styling overrides
xguirootpanel {
>.Window {
.Window {
border-radius: 0px;
box-shadow: 0px 0px 8px 1px rgba(0, 0, 0, 0.5);
border: 1px solid $theme-border-low;
background-color: $window;

.window-content {
background-color: $window;
}

&.unfocused {
>.TitleBar {
background-color: $window;
Expand Down Expand Up @@ -130,7 +134,7 @@ xguirootpanel {
}
}
}
}


// Button styling overrides
.button {
Expand Down Expand Up @@ -263,6 +267,7 @@ xguirootpanel {
// TextEntry / TextBox styling overrides
.textentry,
.textbox {
min-height: 22px;
background-color: $button-face;
border-radius: 3px;
border: 1px solid $theme-border-mid;
Expand All @@ -279,11 +284,12 @@ xguirootpanel {
}

// ComboBox / Select styling
.combobox,
.selector {
min-height: 22px;
>.selector_indicator {
border: 0px;
background-color: transparent;
content: "";
background-color: transparent;
font-size: 10px;
top: 2px;
align-items: center;
Expand Down Expand Up @@ -410,4 +416,26 @@ progressbar,
background-color: $theme-control-mid-high;
}
}
}

.selectlist {
.selectlist-item {
&:hover {
background-color: $button-face;
}

&.selected {
background-color: $highlight;
color: $highlight-text;
}
}
}

.simple-border {
border: 1px solid #808080;
border-radius: 3px;
}

.simple-border-bottom {
border-bottom: 1px solid #808080;
}
Loading