Skip to content

Commit aedaef1

Browse files
committed
Merge branch 'main' of https://github.com/pizzaboxer/bloxstrap into wip
2 parents 9e02141 + 534e3bb commit aedaef1

39 files changed

+6890
-823
lines changed

.github/workflows/ci-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040

4141
steps:
4242
- name: Sign and download artifact
43-
uses: signpath/github-action-submit-signing-request@v1
43+
uses: signpath/github-action-submit-signing-request@v1.1
4444
with:
4545
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
4646
organization-id: '107b3de5-057b-42fc-a985-3546e4261775'
@@ -68,7 +68,7 @@ jobs:
6868

6969
steps:
7070
- name: Sign and download artifact
71-
uses: signpath/github-action-submit-signing-request@v1
71+
uses: signpath/github-action-submit-signing-request@v1.1
7272
with:
7373
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
7474
organization-id: '107b3de5-057b-42fc-a985-3546e4261775'

Bloxstrap/App.xaml.cs

+7
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,21 @@ protected override void OnStartup(StartupEventArgs e)
291291
if (installLocation is null)
292292
{
293293
Logger.Initialize(true);
294+
Logger.WriteLine(LOG_IDENT, "Not installed, launching the installer");
294295
LaunchHandler.LaunchInstaller();
295296
}
296297
else
297298
{
298299
Paths.Initialize(installLocation);
299300

301+
Logger.WriteLine(LOG_IDENT, "Entering main logic");
302+
300303
// ensure executable is in the install directory
301304
if (Paths.Process != Paths.Application && !File.Exists(Paths.Application))
305+
{
306+
Logger.WriteLine(LOG_IDENT, "Copying to install directory");
302307
File.Copy(Paths.Process, Paths.Application);
308+
}
303309

304310
Logger.Initialize(LaunchSettings.UninstallFlag.Active);
305311

@@ -328,6 +334,7 @@ protected override void OnStartup(StartupEventArgs e)
328334
}
329335

330336
// you must *explicitly* call terminate when everything is done, it won't be called implicitly
337+
Logger.WriteLine(LOG_IDENT, "Startup finished");
331338
}
332339
}
333340
}

Bloxstrap/Bloxstrap.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<UseWPF>true</UseWPF>
88
<UseWindowsForms>True</UseWindowsForms>
99
<ApplicationIcon>Bloxstrap.ico</ApplicationIcon>
10-
<Version>2.8.2</Version>
11-
<FileVersion>2.8.2</FileVersion>
10+
<Version>2.8.4</Version>
11+
<FileVersion>2.8.4</FileVersion>
1212
<ApplicationManifest>app.manifest</ApplicationManifest>
1313
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1414
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>

Bloxstrap/Bootstrapper.cs

+40
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,30 @@ private void MigrateCompatibilityFlags()
709709
}
710710
}
711711

712+
private void KillRunningRobloxInDirectory(string path)
713+
{
714+
const string LOG_IDENT = "Bootstrapper::KillRunningRobloxInDirectory";
715+
716+
List<Process> processes = new List<Process>();
717+
processes.AddRange(Process.GetProcessesByName(IsStudioLaunch ? "RobloxStudioBeta" : "RobloxPlayerBeta"));
718+
processes.AddRange(Process.GetProcessesByName("RobloxCrashHandler"));
719+
720+
foreach (Process process in processes)
721+
{
722+
try
723+
{
724+
string? processPath = process.MainModule?.FileName;
725+
if (processPath != null && processPath.StartsWith(path))
726+
process.Kill();
727+
}
728+
catch (Exception ex)
729+
{
730+
App.Logger.WriteLine(LOG_IDENT, $"Failed to close process {process.Id}");
731+
App.Logger.WriteException(LOG_IDENT, ex);
732+
}
733+
}
734+
}
735+
712736
private async Task UpgradeRoblox()
713737
{
714738
const string LOG_IDENT = "Bootstrapper::UpgradeRoblox";
@@ -724,6 +748,22 @@ private async Task UpgradeRoblox()
724748

725749
_isInstalling = true;
726750

751+
// make sure nothing is running from the latest version directory before deleting the whole directory
752+
KillRunningRobloxInDirectory(_latestVersionDirectory);
753+
754+
if (Directory.Exists(_latestVersionDirectory))
755+
{
756+
try
757+
{
758+
Directory.Delete(_latestVersionDirectory, true);
759+
}
760+
catch (Exception ex)
761+
{
762+
App.Logger.WriteLine(LOG_IDENT, "Failed to delete the latest version directory");
763+
App.Logger.WriteException(LOG_IDENT, ex);
764+
}
765+
}
766+
727767
Directory.CreateDirectory(_latestVersionDirectory);
728768

729769
var cachedPackageHashes = Directory.GetFiles(Paths.Downloads).Select(x => Path.GetFileName(x));

Bloxstrap/Installer.cs

+20-6
Original file line numberDiff line numberDiff line change
@@ -567,18 +567,32 @@ public static void HandleUpgrade()
567567

568568
if (Utilities.CompareVersions(existingVer, "2.8.2") == VersionComparison.LessThan)
569569
{
570-
try
571-
{
572-
Directory.Delete(Path.Combine(Paths.Base, "Roblox"), true);
573-
}
574-
catch (Exception ex)
570+
string robloxDirectory = Path.Combine(Paths.Base, "Roblox");
571+
572+
if (Directory.Exists(robloxDirectory))
575573
{
576-
App.Logger.WriteException(LOG_IDENT, ex);
574+
try
575+
{
576+
Directory.Delete(robloxDirectory, true);
577+
}
578+
catch (Exception ex)
579+
{
580+
App.Logger.WriteLine(LOG_IDENT, "Failed to delete the Roblox directory");
581+
App.Logger.WriteException(LOG_IDENT, ex);
582+
}
577583
}
578584
}
579585

586+
if (Utilities.CompareVersions(existingVer, "2.8.3") == VersionComparison.LessThan)
587+
{
588+
// force reinstallation
589+
App.State.Prop.Player.VersionGuid = "";
590+
App.State.Prop.Studio.VersionGuid = "";
591+
}
592+
580593
App.Settings.Save();
581594
App.FastFlags.Save();
595+
App.State.Save();
582596
}
583597

584598
if (currentVer is null)

Bloxstrap/JsonManager.cs

+11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ public virtual void Load(bool alertFailure = true)
4747

4848
if (!String.IsNullOrEmpty(message))
4949
Frontend.ShowMessageBox($"{message}\n\n{ex.Message}", System.Windows.MessageBoxImage.Warning);
50+
51+
try
52+
{
53+
// Create a backup of loaded file
54+
File.Copy(FileLocation, FileLocation + ".bak", true);
55+
}
56+
catch (Exception copyEx)
57+
{
58+
App.Logger.WriteLine(LOG_IDENT, $"Failed to create backup file: {FileLocation}.bak");
59+
App.Logger.WriteException(LOG_IDENT, copyEx);
60+
}
5061
}
5162

5263
Save();

Bloxstrap/LaunchHandler.cs

+28
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,68 @@ public static class LaunchHandler
1111
{
1212
public static void ProcessNextAction(NextAction action, bool isUnfinishedInstall = false)
1313
{
14+
const string LOG_IDENT = "LaunchHandler::ProcessNextAction";
15+
1416
switch (action)
1517
{
1618
case NextAction.LaunchSettings:
19+
App.Logger.WriteLine(LOG_IDENT, "Opening settings");
1720
LaunchSettings();
1821
break;
1922

2023
case NextAction.LaunchRoblox:
24+
App.Logger.WriteLine(LOG_IDENT, "Opening Roblox");
2125
LaunchRoblox(LaunchMode.Player);
2226
break;
2327

2428
case NextAction.LaunchRobloxStudio:
29+
App.Logger.WriteLine(LOG_IDENT, "Opening Roblox Studio");
2530
LaunchRoblox(LaunchMode.Studio);
2631
break;
2732

2833
default:
34+
App.Logger.WriteLine(LOG_IDENT, "Closing");
2935
App.Terminate(isUnfinishedInstall ? ErrorCode.ERROR_INSTALL_USEREXIT : ErrorCode.ERROR_SUCCESS);
3036
break;
3137
}
3238
}
3339

3440
public static void ProcessLaunchArgs()
3541
{
42+
const string LOG_IDENT = "LaunchHandler::ProcessLaunchArgs";
43+
3644
// this order is specific
3745

3846
if (App.LaunchSettings.UninstallFlag.Active)
47+
{
48+
App.Logger.WriteLine(LOG_IDENT, "Opening uninstaller");
3949
LaunchUninstaller();
50+
}
4051
else if (App.LaunchSettings.MenuFlag.Active)
52+
{
53+
App.Logger.WriteLine(LOG_IDENT, "Opening settings");
4154
LaunchSettings();
55+
}
4256
else if (App.LaunchSettings.WatcherFlag.Active)
57+
{
58+
App.Logger.WriteLine(LOG_IDENT, "Opening watcher");
4359
LaunchWatcher();
60+
}
4461
else if (App.LaunchSettings.RobloxLaunchMode != LaunchMode.None)
62+
{
63+
App.Logger.WriteLine(LOG_IDENT, $"Opening bootstrapper ({App.LaunchSettings.RobloxLaunchMode})");
4564
LaunchRoblox(App.LaunchSettings.RobloxLaunchMode);
65+
}
4666
else if (!App.LaunchSettings.QuietFlag.Active)
67+
{
68+
App.Logger.WriteLine(LOG_IDENT, "Opening menu");
4769
LaunchMenu();
70+
}
4871
else
72+
{
73+
App.Logger.WriteLine(LOG_IDENT, "Closing - quiet flag active");
4974
App.Terminate();
75+
}
5076
}
5177

5278
public static void LaunchInstaller()
@@ -235,6 +261,8 @@ public static void LaunchRoblox(LaunchMode launchMode)
235261
});
236262

237263
dialog?.ShowBootstrapper();
264+
265+
App.Logger.WriteLine(LOG_IDENT, "Exiting");
238266
}
239267

240268
public static void LaunchWatcher()

Bloxstrap/LaunchSettings.cs

+28-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public LaunchSettings(string[] args)
7272
_flagMap.Add(identifier, flag);
7373
}
7474

75+
int startIdx = 0;
76+
7577
// infer roblox launch uris
7678
if (Args.Length >= 1)
7779
{
@@ -80,23 +82,31 @@ public LaunchSettings(string[] args)
8082
if (arg.StartsWith("roblox:", StringComparison.OrdinalIgnoreCase)
8183
|| arg.StartsWith("roblox-player:", StringComparison.OrdinalIgnoreCase))
8284
{
85+
App.Logger.WriteLine(LOG_IDENT, "Got Roblox player argument");
8386
RobloxLaunchMode = LaunchMode.Player;
8487
RobloxLaunchArgs = arg;
88+
startIdx = 1;
8589
}
8690
}
8791

8892
// parse
89-
for (int i = 0; i < Args.Length; i++)
93+
for (int i = startIdx; i < Args.Length; i++)
9094
{
9195
string arg = Args[i];
9296

9397
if (!arg.StartsWith('-'))
98+
{
99+
App.Logger.WriteLine(LOG_IDENT, $"Invalid argument: {arg}");
94100
continue;
101+
}
95102

96103
string identifier = arg[1..];
97104

98105
if (!_flagMap.TryGetValue(identifier, out LaunchFlag? flag) || flag is null)
106+
{
107+
App.Logger.WriteLine(LOG_IDENT, $"Unknown argument: {identifier}");
99108
continue;
109+
}
100110

101111
flag.Active = true;
102112

@@ -119,31 +129,48 @@ public LaunchSettings(string[] args)
119129

120130
private void ParsePlayer(string? data)
121131
{
132+
const string LOG_IDENT = "LaunchSettings::ParsePlayer";
133+
122134
RobloxLaunchMode = LaunchMode.Player;
123135

124136
if (!String.IsNullOrEmpty(data))
137+
{
138+
App.Logger.WriteLine(LOG_IDENT, "Got Roblox launch arguments");
125139
RobloxLaunchArgs = data;
140+
}
141+
else
142+
{
143+
App.Logger.WriteLine(LOG_IDENT, "No Roblox launch arguments were provided");
144+
}
126145
}
127146

128147
private void ParseStudio(string? data)
129148
{
149+
const string LOG_IDENT = "LaunchSettings::ParseStudio";
150+
130151
RobloxLaunchMode = LaunchMode.Studio;
131152

132153
if (String.IsNullOrEmpty(data))
154+
{
155+
App.Logger.WriteLine(LOG_IDENT, "No Roblox launch arguments were provided");
133156
return;
157+
}
134158

135159
if (data.StartsWith("roblox-studio:"))
136160
{
161+
App.Logger.WriteLine(LOG_IDENT, "Got Roblox Studio launch arguments");
137162
RobloxLaunchArgs = data;
138163
}
139164
else if (data.StartsWith("roblox-studio-auth:"))
140165
{
166+
App.Logger.WriteLine(LOG_IDENT, "Got Roblox Studio Auth launch arguments");
141167
RobloxLaunchMode = LaunchMode.StudioAuth;
142168
RobloxLaunchArgs = data;
143169
}
144170
else
145171
{
146172
// likely a local path
173+
App.Logger.WriteLine(LOG_IDENT, "Got Roblox Studio local place file");
147174
RobloxLaunchArgs = $"-task EditFile -localPlaceFile \"{data}\"";
148175
}
149176
}

0 commit comments

Comments
 (0)