Skip to content

Commit

Permalink
Merge branch 'pizzaboxer:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Roblox-Thot authored Oct 6, 2024
2 parents 6b846fc + 2a19b4a commit e0aaad3
Show file tree
Hide file tree
Showing 71 changed files with 1,364 additions and 505 deletions.
40 changes: 39 additions & 1 deletion Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public static void Terminate(ErrorCode exitCode = ErrorCode.ERROR_SUCCESS)
Environment.Exit(exitCodeNum);
}

public static void SoftTerminate(ErrorCode exitCode = ErrorCode.ERROR_SUCCESS)
{
int exitCodeNum = (int)exitCode;

Logger.WriteLine("App::SoftTerminate", $"Terminating with exit code {exitCodeNum} ({exitCode})");

Current.Dispatcher.Invoke(() => Current.Shutdown(exitCodeNum));
}

void GlobalExceptionHandler(object sender, DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;
Expand Down Expand Up @@ -122,6 +131,21 @@ public static void FinalizeExceptionHandling(Exception ex, bool log = true)
return null;
}

public static async void SendStat(string key, string value)
{
if (!Settings.Prop.EnableAnalytics)
return;

try
{
await HttpClient.GetAsync($"https://bloxstraplabs.com/metrics/post?key={key}&value={value}");
}
catch (Exception ex)
{
Logger.WriteException("App::SendStat", ex);
}
}

protected override void OnStartup(StartupEventArgs e)
{
const string LOG_IDENT = "App::OnStartup";
Expand All @@ -132,19 +156,33 @@ protected override void OnStartup(StartupEventArgs e)

Logger.WriteLine(LOG_IDENT, $"Starting {ProjectName} v{Version}");

string userAgent = $"{ProjectName}/{Version}";

if (IsActionBuild)
{
Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from commit {BuildMetadata.CommitHash} ({BuildMetadata.CommitRef})");

if (IsProductionBuild)
userAgent += $" (Production)";
else
userAgent += $" (Artifact {BuildMetadata.CommitHash}, {BuildMetadata.CommitRef})";
}
else
{
Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from {BuildMetadata.Machine}");
userAgent += $" (Build {BuildMetadata.Machine})";
}

Logger.WriteLine(LOG_IDENT, $"Loaded from {Paths.Process}");
Logger.WriteLine(LOG_IDENT, $"Temp path is {Paths.Temp}");
Logger.WriteLine(LOG_IDENT, $"WindowsStartMenu path is {Paths.WindowsStartMenu}");

// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();

HttpClient.Timeout = TimeSpan.FromSeconds(30);
HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository);
HttpClient.DefaultRequestHeaders.Add("User-Agent", userAgent);

LaunchSettings = new LaunchSettings(e.Args);

Expand Down
10 changes: 9 additions & 1 deletion Bloxstrap/Bloxstrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

<ItemGroup>
<Resource Include="Bloxstrap.ico" />
<Resource Include="Resources\Fonts\NotoSansThai-VariableFont_wdth,wght.ttf" />
Expand All @@ -27,6 +27,14 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Icon2008.ico" />
<EmbeddedResource Include="Resources\Icon2011.ico" />
<EmbeddedResource Include="Resources\Icon2017.ico" />
<EmbeddedResource Include="Resources\Icon2019.ico" />
<EmbeddedResource Include="Resources\Icon2022.ico" />
<EmbeddedResource Include="Resources\IconBloxstrap.ico" />
<EmbeddedResource Include="Resources\IconEarly2015.ico" />
<EmbeddedResource Include="Resources\IconLate2015.ico" />
<EmbeddedResource Include="Resources\Mods\Cursor\From2006\ArrowCursor.png" />
<EmbeddedResource Include="Resources\Mods\Cursor\From2006\ArrowFarCursor.png" />
<EmbeddedResource Include="Resources\Mods\Cursor\From2013\ArrowCursor.png" />
Expand Down
Loading

0 comments on commit e0aaad3

Please sign in to comment.