Files
DorkNet/launcher/Backend/RecRoomPicker.cs
T
Alexa 446a23da2b launcher: rewrite as native WPF, drop PhotinoNET/WebView2
Initial v0.1 (commit df9dac0) used PhotinoNET wrapping WebView2 + HTML/JS,
but rendered as a blank window on first run — WebView2 + file:// URI
quirks. Switching to native WPF: built into the .NET 9 Windows SDK
(no NuGet), single-file self-contained publish, instant window open.

All Backend/*.cs orchestration logic carried over unchanged (they're
UI-framework-agnostic). Replaced:
- Program.cs (PhotinoNET bootstrap) -> App.xaml(.cs) + MainWindow.xaml(.cs)
- ui/index.html + style.css + app.js -> MainWindow.xaml (XAML views) +
  App.xaml resource styles
- Backend/MessageBridge.cs (JS<->C# router) -> direct method calls in
  MainWindow.xaml.cs code-behind

RecRoomPicker now uses Microsoft.Win32.OpenFolderDialog (added in .NET 8)
instead of WinForms FolderBrowserDialog — keeps the project WPF-only.
Backend files needed explicit 'using System.IO;' since the WPF SDK
doesn't include it in implicit usings.
2026-05-27 00:44:28 +03:00

45 lines
1.8 KiB
C#

using System.IO;
using Microsoft.Win32;
namespace DorkNet.Launcher.Backend;
/// <summary>Windows folder picker for the user's
/// <c>Recroom_Release_Data</c> directory. Per project policy: never
/// auto-detect via Steam library scanning, always ask the user.
///
/// <para>Uses <see cref="OpenFolderDialog"/> (added in .NET 8) so we
/// don't need to drag WinForms into a WPF project for one dialog.</para></summary>
public static class RecRoomPicker
{
public static string? Pick(string? initialPath = null)
{
var dlg = new OpenFolderDialog
{
Title = "Select your Rec Room install's *_Data folder " +
"(e.g. Recroom_Release_Data inside the install).",
InitialDirectory = initialPath ?? Environment.GetFolderPath(
Environment.SpecialFolder.ProgramFilesX86),
Multiselect = false,
};
return dlg.ShowDialog() == true ? dlg.FolderName : null;
}
/// <summary>Quick sanity check that the picked path looks like a
/// Rec Room install. Doesn't validate the build version — that's
/// the patcher's job. Just checks for the canonical files so we
/// catch "user picked their Documents folder" mistakes early.</summary>
public static (bool ok, string reason) Validate(string path)
{
if (string.IsNullOrEmpty(path)) return (false, "no path selected");
if (!Directory.Exists(path)) return (false, $"folder does not exist: {path}");
// Recroom_Release_Data/StreamingAssets is the consistent
// checkable subfolder across all Rec Room builds we target.
var streaming = Path.Combine(path, "StreamingAssets");
if (!Directory.Exists(streaming))
return (false, "folder is missing StreamingAssets — pick the *_Data folder inside your Rec Room install");
return (true, "");
}
}