Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
48a7f24
Windows seems done
VasilisThePikachu Jan 20, 2024
831222d
OOPs forgor
VasilisThePikachu Jan 20, 2024
68279e9
OOPS
VasilisThePikachu Jan 20, 2024
4c1429e
PJB bullied me to making this good
VasilisThePikachu Jan 20, 2024
14c3eb6
Commiting so i can work on my macbook
VasilisThePikachu Jan 23, 2024
e17c3f6
MacOS
VasilisThePikachu Feb 7, 2024
81adfa2
I prefer doing this
VasilisThePikachu Feb 7, 2024
1017326
I give up on macos, im just gonna send over whatever i had
VasilisThePikachu Feb 14, 2024
6fb5187
Merge branch 'master' of ssh://github.com/space-wizards/SS14.Launcher…
VasilisThePikachu Mar 13, 2024
dac3514
Start of Robust Toolbox file extensions
VasilisThePikachu Mar 13, 2024
83b38e4
file extensions
VasilisThePikachu Mar 17, 2024
0c74a42
Remove debug code and finish windows
VasilisThePikachu Mar 17, 2024
b74cfec
Shitty bug fix for when you drop a content bundle that has a space in…
VasilisThePikachu Mar 17, 2024
f9d3f4f
ok but like maybe
VasilisThePikachu Apr 5, 2024
d380786
Ok no maybe
VasilisThePikachu Apr 10, 2024
934044f
Send this to my macbook please work
VasilisThePikachu Apr 10, 2024
5102306
a
VasilisThePikachu May 6, 2024
e4059dd
A
VasilisThePikachu Jul 20, 2024
01b3bae
Merge remote-tracking branch 'upstream/master' into protocol
VasilisThePikachu Jul 20, 2024
fd427b2
Why apple
VasilisThePikachu Jul 20, 2024
10865dd
123 im gonna squash this anyway later
VasilisThePikachu Jul 22, 2024
e135cba
Fix conflict
VasilisThePikachu Jul 26, 2024
0682c24
Fix macos kinda
VasilisThePikachu Jul 26, 2024
e2d1eac
MACOS IS DONE BOZOS FUCK YOU APPLE
VasilisThePikachu Jul 27, 2024
1535cd1
MacOS improvements (unregistration is fully correct idk)
VasilisThePikachu Jul 27, 2024
0f756e9
Merge branch 'master' of ssh://github.com/space-wizards/SS14.Launcher…
VasilisThePikachu Feb 8, 2025
b5bd6c2
I am back
VasilisThePikachu Feb 8, 2025
3ec486c
Merge remote-tracking branch 'origin/protocol' into protocol
VasilisThePikachu Feb 8, 2025
efa192a
Merge branch 'master' of ssh://github.com/space-wizards/SS14.Launcher…
VasilisThePikachu Mar 4, 2025
9533fbc
Forgor
VasilisThePikachu Mar 4, 2025
c45841e
Replace obsolete UrlsOpened with IActivatableLifetime
VasilisThePikachu Mar 4, 2025
e7ec6c4
Confirm dialog
VasilisThePikachu Mar 4, 2025
352040a
Add zip mimetype for linux
VasilisThePikachu Mar 4, 2025
64ff1ef
Protocol text
VasilisThePikachu Mar 4, 2025
88731ca
Popup and error handling
VasilisThePikachu Mar 8, 2025
2c8d16a
Options popup
VasilisThePikachu Mar 8, 2025
10d6b7e
Last min stuff here
VasilisThePikachu Mar 8, 2025
4cd593d
Confirmation
VasilisThePikachu Mar 8, 2025
51adba9
No point in checking it twice
VasilisThePikachu Mar 8, 2025
ddcd768
Catch all and warning fix
VasilisThePikachu Mar 9, 2025
dc4b9da
Correct the MimeTypes for Linux
VasilisThePikachu Mar 9, 2025
68521e0
Better generic error
VasilisThePikachu Mar 9, 2025
f8ebe91
Protocol update check
VasilisThePikachu Mar 9, 2025
61cdd7a
Fix minor goof
VasilisThePikachu Mar 10, 2025
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
4 changes: 4 additions & 0 deletions PublishFiles/SS14.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ Version=1.0
Type=Application
Exec=env ./SS14.Launcher %u
Name=Space Station 14
Comment=Open source Multiplayer Disaster Simulator
Categories=Game;
Keywords=ss14;
MimeType=x-scheme-handler/ss14s;x-scheme-handler/ss14;application/rtbundle;application/rtreplay;application/zip
32 changes: 32 additions & 0 deletions PublishFiles/Space Station 14 Launcher.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,37 @@
-->
<key>CFBundleIconFile</key>
<string>ss14</string>
<key>CFBundleIdentifier</key>
<string>com.spacestation14.launcher</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.spacestation14.launcher</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ss14</string>
<string>ss14s</string>
</array>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>rtreplay</string>
<string>rtbundle</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>ss14</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>CFBundleTypeName</key>
<string>Robust Toolbox Bundle File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
</dict>
</plist>
15 changes: 15 additions & 0 deletions PublishFiles/ss14-mime-type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/rtbundle">
<comment>Robust Toolbox Game Bundle</comment>
<glob pattern="*.rtbundle"/>
</mime-type>
<mime-type type="application/rtreplay">
<comment>Robust Toolbox Replay</comment>
<glob pattern="*.rtreplay"/>
</mime-type>
</mime-info>
<!--
mkdir -p ~/.local/share/mime && cp ./ss14-mime.type.xml ~/.local/share/mime && update-mime-database ~/.local/share/mime
cp ~/.local/share/applications/SS14.desktop && update-desktop-database ~/.local/share/applications
-->
59 changes: 58 additions & 1 deletion SS14.Launcher.Bootstrap/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using Microsoft.Win32;
using System.Linq;

namespace SS14.Launcher.Bootstrap
{
Expand All @@ -11,6 +12,53 @@ public static void Main(string[] args)
{
UnfuckDotnetRoot();

if (args.Contains("--register-protocol"))
{
// ss14s://
var key = Registry.ClassesRoot.CreateSubKey("ss14s");
key!.SetValue("URL Protocol", "Space Station 14 Secure protocol");
key = key.CreateSubKey("Shell\\Open\\Command");
key!.SetValue("", $"\"{AppDomain.CurrentDomain.BaseDirectory}Space Station 14 Launcher.exe\" \"%1\"");
key.Close();

// ss14://
key = Registry.ClassesRoot.CreateSubKey("ss14");
key!.SetValue("URL Protocol", "Space Station 14 protocol");
key = key.CreateSubKey("Shell\\Open\\Command");
key!.SetValue("", $"\"{AppDomain.CurrentDomain.BaseDirectory}Space Station 14 Launcher.exe\" \"%1\"");
key.Close();

// RobustToolbox (required for the file extensions)
key = Registry.ClassesRoot.CreateSubKey("RobustToolbox");
key!.SetValue("", "Robust Toolbox Bundle File");
var icon = key.CreateSubKey("DefaultIcon");
icon!.SetValue("", $"{AppDomain.CurrentDomain.BaseDirectory}Space Station 14 Launcher.exe");
key = key.CreateSubKey("Shell\\Open\\Command");
key!.SetValue("", $"\"{AppDomain.CurrentDomain.BaseDirectory}Space Station 14 Launcher.exe\" \"%1\"");
key.Close();

// .rtbundle
key = Registry.ClassesRoot.CreateSubKey(".rtbundle");
key!.SetValue("", "RobustToolbox");
key.Close();

// .rtreplay
key = Registry.ClassesRoot.CreateSubKey(".rtreplay");
key!.SetValue("", "RobustToolbox");
key.Close();

Environment.Exit(0);
}
if (args.Contains("--unregister-protocol"))
{
Registry.ClassesRoot.DeleteSubKeyTree("ss14s");
Registry.ClassesRoot.DeleteSubKeyTree("ss14");
Registry.ClassesRoot.DeleteSubKeyTree("RobustToolbox");
Registry.ClassesRoot.DeleteSubKeyTree(".rtbundle");
Registry.ClassesRoot.DeleteSubKeyTree(".rtreplay");
Environment.Exit(0);
}

var path = typeof(Program).Assembly.Location;
var ourDir = Path.GetDirectoryName(path);
Debug.Assert(ourDir != null);
Expand All @@ -19,7 +67,16 @@ public static void Main(string[] args)
var exeDir = Path.Combine(ourDir, "bin", "SS14.Launcher.exe");

Environment.SetEnvironmentVariable("DOTNET_ROOT", dotnetDir);
Process.Start(new ProcessStartInfo(exeDir));
if (args.Length > 0)
{
// blursed
// thanks anonymous for how to make args pass in properly
Process.Start(new ProcessStartInfo(exeDir, string.Join("", args.Select((str) => $"\"{str}\" "))));
}
else
{
Process.Start(new ProcessStartInfo(exeDir));
}
}

private static void UnfuckDotnetRoot()
Expand Down
21 changes: 19 additions & 2 deletions SS14.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
Expand Down Expand Up @@ -43,6 +42,24 @@ public App()
public App(OverrideAssetsManager overrideAssets)
{
_overrideAssets = overrideAssets;

if (Current?.TryGetFeature<IActivatableLifetime>(out var lifetime) == true)
{
lifetime.Activated += OnOSXUrlsOpened;
}
}

private void OnOSXUrlsOpened(object? sender, ActivatedEventArgs e)
{
// I think this only works on macOS anyway? Well I will leave this here just so I don't surprise myself later.
if (!OperatingSystem.IsMacOS())
return;

var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
Program.ParseCommandLineArgs(args[1..], new LauncherMessaging());
}
}

public override void Initialize()
Expand Down Expand Up @@ -148,7 +165,7 @@ private void OnStartup(object? s, ControlledApplicationLifetimeStartupEventArgs
GC.Collect();
};

var lc = new LauncherCommands(viewModel);
var lc = new LauncherCommands(viewModel, window.StorageProvider);
lc.RunCommandTask();
Locator.CurrentMutable.RegisterConstant(lc);
msgr.StartServerTask(lc);
Expand Down
54 changes: 54 additions & 0 deletions SS14.Launcher/Assets/Locale/en-US/text.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ tab-development-disable-signing = Disable Engine Signature Checks
tab-development-disable-signing-desc = { "[" }DEV ONLY] Disables verification of engine signatures. DO NOT ENABLE UNLESS YOU KNOW EXACTLY WHAT YOU'RE DOING.
tab-development-enable-engine-override = Enable engine override
tab-development-enable-engine-override-desc = Override path to load engine zips from (release/ in RobustToolbox)
tab-development-force-register-os-protocols = Force Register OS Protocols
tab-development-force-unregister-os-protocols = Force Unegister OS Protocols

## Strings for the "home" tab

Expand Down Expand Up @@ -338,6 +340,9 @@ tab-options-disable-signing = Disable Engine Signature Checks
tab-options-disable-signing-desc = { "[" }DEV ONLY] Disables verification of engine signatures. DO NOT ENABLE UNLESS YOU KNOW EXACTLY WHAT YOU'RE DOING.
tab-options-hub-settings = Hub Settings
tab-options-hub-settings-desc = Change what hub server or servers you would like to use to fetch the server list.
tab-options-os-protocol = Register/Unregister File extensions & URL protocol
tab-options-os-protocol-desc = Register the launcher to your operating system, this will allow you to use ss14(s):// links on web browsers and file extensions like .rtreplay.

tab-options-desc-incompatible = This option is incompatible with your platform and has been disabled.

## For the language selection menu.
Expand All @@ -352,3 +357,52 @@ language-selector-help-translate = Want to help translate? You can!
language-selector-system-language = System language ({ $languageName })
# Used for contents of each language button.
language-selector-language = { $languageName } ({ $englishName })

# Strings for the dialog box for protocol registration
protocols-dialog-title = OS protocol registration
protocols-dialog-content =
Would you like to allow the launcher to be able to open special links and files?

This will allow you to launch replay files by just double clicking them on your
computer, or allow you to join a server directly from your web browser.

You can disable this feature later on in options.
protocols-dialog-content-success =
The launcher has been successfully registered to your operating system!

You can now use ss14(s):// links on web browsers and file extensions like .rtreplay
protocols-dialog-content-update =
The launcher's special links/file extension registration seems to be out of date.

Want to update it?
protocols-dialog-content-action-question =
You are about to { $action } the operating system protocols for the Launcher

Do you want to continue?
protocols-dialog-action-register = Register
protocols-dialog-action-unregister = Unregister
protocols-dialog-confirm = For sure!
protocols-dialog-deny = No Thanks
protocols-dialog-continue = Yes, please continue
protocols-dialog-back = Keep it as is
protocols-dialog-ok = Yay
protocols-dialog-error-title = OS protocol error
protocols-dialog-error-windows-uac =
It appears we were unable to register the launcher to Windows
Do you have administrator rights to this computer? Or deny the admin prompt?

Want to try again?
protocols-dialog-error-macos-translocation =
It appears we were unable to register the launcher to MacOS

MacOS Gatekeeper sandboxing is currently active on the launcher, please move
the Space Station 14 Launcher into your Applications folder.
protocols-dialog-error-generic =
It appears we were unable to register the launcher to your operating system.

If this continues, please contact our Discord, Github or forum to report
this Bug. And provide a copy of your launcher log file.

Want to try again?
protocols-dialog-error-again = Try again
protocols-dialog-error-ok = Ok
31 changes: 31 additions & 0 deletions SS14.Launcher/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using System.Threading.Tasks;
using Mono.Unix;
using Serilog;
using SS14.Launcher.Localization;
using SS14.Launcher.Views;
using TerraFX.Interop.Windows;
using Win = TerraFX.Interop.Windows.Windows;

Expand Down Expand Up @@ -202,4 +204,33 @@ public static unsafe int MessageBoxHelper(string text, string caption, uint type
return Win.MessageBoxW(HWND.NULL, (ushort*)pText, (ushort*)pCaption, type);
}
}

// Has two buttons, Confirm/Deny that returns true or false respectively
public static async Task<bool> ConfirmDialogBuilder(MainWindow control, string title, string dialogContent, string confirmButtonText, string cancelButtonText)
{
var dialog = new ConfirmDialog
{
Title = LocalizationManager.Instance.GetString(title),
DialogContent = LocalizationManager.Instance.GetString(dialogContent),
ConfirmButtonText = LocalizationManager.Instance.GetString(confirmButtonText),
CancelButtonText = LocalizationManager.Instance.GetString(cancelButtonText),
};

var answer = await dialog.ShowDialog<bool>(control);

return answer;
}

// Only one button and no bool is returned.
public static async Task OkDialogBuilder(MainWindow control, string title, string dialogContent, string confirmButtonText)
{
var dialog = new OkDialog()
{
Title = LocalizationManager.Instance.GetString(title),
DialogContent = LocalizationManager.Instance.GetString(dialogContent),
ButtonText = LocalizationManager.Instance.GetString(confirmButtonText),
};

await dialog.ShowDialog<bool>(control);
}
}
16 changes: 15 additions & 1 deletion SS14.Launcher/LauncherCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using Serilog;
using Splat;
Expand All @@ -18,13 +19,15 @@ public class LauncherCommands
private MainWindowViewModel _windowVm;
private LoginManager _loginMgr;
private LauncherMessaging _msgr;
private readonly IStorageProvider _storageProvider;
public readonly Channel<string> CommandChannel;

public LauncherCommands(MainWindowViewModel windowVm)
public LauncherCommands(MainWindowViewModel windowVm, IStorageProvider provider)
{
_windowVm = windowVm;
_loginMgr = Locator.Current.GetRequiredService<LoginManager>();
_msgr = Locator.Current.GetRequiredService<LauncherMessaging>();
_storageProvider = provider;

CommandChannel = Channel.CreateUnbounded<string>();
}
Expand Down Expand Up @@ -157,6 +160,16 @@ private async Task RunSingleCommand(string cmd)
// Used by the "pass URI as argument" logic, doesn't need to bother with safety measures
await Connect(cmd.Substring(1));
}
else if (cmd.StartsWith("b"))
{
// Content bundle file
var uri = new Uri(cmd.Substring(1));
var thingy = await _storageProvider.TryGetFileFromPathAsync(uri);
if (thingy != null)
await Task.Run(() => ConnectingViewModel.StartContentBundle(_windowVm, thingy));
else
Log.Error("File does not exist. Aborting");
}
else
{
Log.Error($"Unhandled launcher command: {cmd}");
Expand All @@ -169,5 +182,6 @@ private async Task RunSingleCommand(string cmd)
public const string RedialWaitCommand = ":RedialWait";
public const string BlankReasonCommand = "r";
public static string ConstructConnectCommand(Uri uri) => "c" + uri.ToString();
public static string ConstructContentBundleCommand(string fileName) => "b" + fileName;
}

2 changes: 1 addition & 1 deletion SS14.Launcher/LauncherMessaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public bool SendCommandsOrClaim(string[] commands, bool sendAnyway = true)
catch (Exception)
{
// Ok, so we're server (we hope)
Console.WriteLine("We are primary launcher (or primary launcher is out for lunch)");
Console.WriteLine("We are the primary launcher (or primary launcher is out for lunch)");
}

// Try to create server
Expand Down
5 changes: 5 additions & 0 deletions SS14.Launcher/Models/Data/CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public static readonly CVarDef<bool> HasDismissedEarlyAccessWarning
/// </summary>
public static readonly CVarDef<bool> WineWarningShown = CVarDef.Create("WineWarningShown", false);

/// <summary>
/// Has the user been shown the protocols alert?
/// </summary>
public static readonly CVarDef<bool> HasSeenProtocolsDialog = CVarDef.Create("HasSeenProtocolsDialog", false);

/// <summary>
/// Language the user selected. Null means it should be automatically selected based on system language.
/// </summary>
Expand Down
Loading
Loading