Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 a99cdb7826 feat(app): Change executable... opens in the game's own folder (beta.19 PR-2)
The owner's request of 2026-10-12: the file dialog of Change executable...
opened wherever the last file dialog was, and the pick is almost always
another file of the same install.

GameFolder.StartFolder derives the folder from the row's path - the only
place one is stored: the install folder a store boundary names (InstallRoot:
steamapps\common\X, GOG Galaxy\Games\X, Epic Games\X, GamesInstalled\X), above
an Unreal package's <Project>\Binaries\Win64 where no boundary is recognised,
else the executable's folder; the nearest folder still there when that one is
gone (a Not installed entry); null for a drive that is not connected, where
Windows opens its last folder. It asks the file system, so the page runs it off
the UI thread. IGamePicker.PickExecutable takes the folder; Add game passes
none and keeps Windows' own choice.

Tests: GameFolderTests (each layout, a gone folder, an absent drive),
GameDetailViewModelTests.ChangingTheExecutableOpensThePickInTheGamesOwnFolder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:10:56 +07:00
12 changed files with 231 additions and 13 deletions

No files matched your search

+7
View File
@@ -28,6 +28,13 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Changed
- **Change executable… opens in the game's own folder** — the install folder a store made (`steamapps\common\<game>`
and the like), or above an Unreal game's `Binaries\Win64`, else the folder the executable is in — instead of wherever
the last file dialog was. For a game whose folder is gone it opens at the nearest folder still there
(`docs/08_UI.md` §Games).
### Fixed
- **An imported game is no longer one of its helpers, and an RPG Maker MV/MZ game behind a launcher is its runtime.**
+4 -1
View File
@@ -299,7 +299,10 @@ All screens are `Page`s registered with the navigation page provider and navigat
> fields), **the row's executable path under the subtitle and Change executable… since 2026-09-21** (a store import
> guesses the executable and everything downstream is keyed on it; the pick re-points the row, which comes back
> hooking-off and unconsented like a new game, consent revoked over the pipe first, a block never cleared —
> `05_DETECTION` §Library import), **one App per data folder since 2026-09-21** (`Services.SingleInstance`: a named mutex and a named event keyed on a hash of the data directory, claimed in `Program.Main` after Velopack's hooks and before any window; a later start sets the event and exits 0, and the first instance brings its window forward through `ShellHost.Reveal` — from the tray too. Nothing stopped a second App before: the owner's log shows two started 360 ms apart, two tray icons, a second log file. `--diag` never claims), ~~**the guard-bypass switch since 2026-09-21**~~ **withdrawn 2026-09-22** (the card, its dialog, the session mark and the export line are gone; a blocked row's toggle is disabled and `Safety_Blocked_Toggle_Format` is the whole story; a refusal or unhook notice that turned hooking off ends with `Safety_HookingTurnedOff` — `19_SAFETY` §What a finding does to the game), **Supports** (from `capability_flags`; ~~empty until P4's scan writes it, and the card says so~~ **written by the Agent's detection sweep since P4 PR-1, 2026-09-14** — the rule ids as product names via `CapabilityNames`, "not scanned yet" only until the Agent's next tick) beside
> `05_DETECTION` §Library import; **since beta.19 the file dialog opens in the game's own folder** — `GameFolder.StartFolder`:
> the store boundary's install folder (`InstallRoot`), an Unreal package's root above `<Project>\Binaries\Win64`, else
> the executable's folder, and the nearest folder still there when that one is gone; nothing for a drive that is not
> connected, where Windows opens its last folder; owner request 2026-10-12, `GameFolderTests`), **one App per data folder since 2026-09-21** (`Services.SingleInstance`: a named mutex and a named event keyed on a hash of the data directory, claimed in `Program.Main` after Velopack's hooks and before any window; a later start sets the event and exits 0, and the first instance brings its window forward through `ShellHost.Reveal` — from the tray too. Nothing stopped a second App before: the owner's log shows two started 360 ms apart, two tray icons, a second log file. `--diag` never claims), ~~**the guard-bypass switch since 2026-09-21**~~ **withdrawn 2026-09-22** (the card, its dialog, the session mark and the export line are gone; a blocked row's toggle is disabled and `Safety_Blocked_Toggle_Format` is the whole story; a refusal or unhook notice that turned hooking off ends with `Safety_HookingTurnedOff` — `19_SAFETY` §What a finding does to the game), **Supports** (from `capability_flags`; ~~empty until P4's scan writes it, and the card says so~~ **written by the Agent's detection sweep since P4 PR-1, 2026-09-14** — the rule ids as product names via `CapabilityNames`, "not scanned yet" only until the Agent's next tick) beside
> **Last session measured** (upscaler · resolution, frame generation, the non-N/A chips — accent pills, from the
> hooks). Hooking: the toggle is `OneWay` from the row and its command runs `HookingConsent`; a refusal, a
> mismatch or a failure is a persistent `InfoBar` on the page (never a toast); a blocked row disables the
+2 -2
View File
@@ -69,8 +69,8 @@ stopped, hooking turned off — each with one button that only says you have rea
- **At the top:** the name, publisher, version, store and engine, the `.exe` path, the last session, the last measured
session's frame rate and its ray-tracing chips. **Edit…** changes the name, publisher, version and notes. **Change
executable…** points the entry at another `.exe` and turns hooking back off. **Remove…** asks whether to keep the
game's sessions.
executable…** points the entry at another `.exe` and turns hooking back off; its file dialog opens in the game's own
folder. **Remove…** asks whether to keep the game's sessions.
- **Recording** — off, FrameLedger ignores the program completely: for a launcher or a tool that is not a game.
- **Hooking** — on, the game is measured. A warning comes first, and you type `I ACCEPT THE INJECTION RISK` to go on.
Read [Anti-cheat and safety](04-anti-cheat-and-safety.md) before you do.
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.IO;
using FrameLedger.Infrastructure.Detection;
namespace FrameLedger.App.Services;
/// <summary>
/// The folder Change executable… opens in (beta.19, owner request 2026-10-12): the game's own root folder rather than
/// wherever Windows' dialog was last — the pick is almost always another file of the same install.
/// </summary>
/// <remarks>
/// <para>
/// The root is <see cref="InstallRoot.Resolve"/>'s — the folder a store boundary names (<c>steamapps\common\X</c>,
/// <c>GOG Galaxy\Games\X</c>, <c>Epic Games\X</c>, <c>GamesInstalled\X</c>) — and, where no boundary is recognised, out of
/// an Unreal package's <c>&lt;root&gt;\&lt;Project&gt;\Binaries\Win64</c> to <c>&lt;root&gt;</c>, else the executable's own
/// folder. Only the row's path is stored (no install folder), so this is derived, never remembered.
/// </para>
/// <para>
/// An entry whose folder is gone (*Not installed*) opens at the nearest folder above it that is still there; an entry on a
/// drive that is not connected gets null, and the dialog opens where Windows last was. It asks the file system, so its
/// caller runs it off the UI thread: a share that went away can take seconds to answer.
/// </para>
/// </remarks>
public static class GameFolder
{
/// <summary>The folder to open the pick in for an entry at <paramref name="exePath"/>, or null when there is none.</summary>
public static string? StartFolder(string exePath)
{
ArgumentException.ThrowIfNullOrWhiteSpace(exePath);
string full;
try
{
full = Path.GetFullPath(exePath);
}
catch (Exception ex) when (ex is ArgumentException or NotSupportedException or PathTooLongException)
{
return null;
}
string? drive = Path.GetPathRoot(full);
if (string.IsNullOrEmpty(drive) || !Directory.Exists(drive))
{
return null;
}
string exeDirectory = Path.GetDirectoryName(full) ?? drive;
string root = InstallRoot.Resolve(full);
if (string.Equals(root, exeDirectory, StringComparison.OrdinalIgnoreCase) && UnrealRoot(exeDirectory) is { } unreal)
{
root = unreal;
}
for (string? folder = root; !string.IsNullOrEmpty(folder); folder = Path.GetDirectoryName(folder))
{
if (Directory.Exists(folder))
{
return folder;
}
}
return drive;
}
/// <summary><c>&lt;root&gt;\&lt;Project&gt;\Binaries\Win64</c> (or <c>WinGDK</c>) → <c>&lt;root&gt;</c>; null for any other folder.</summary>
private static string? UnrealRoot(string exeDirectory)
{
string platform = Path.GetFileName(exeDirectory);
string? binaries = Path.GetDirectoryName(exeDirectory);
bool unreal = (string.Equals(platform, "Win64", StringComparison.OrdinalIgnoreCase) || string.Equals(platform, "WinGDK", StringComparison.OrdinalIgnoreCase))
&& binaries is not null && string.Equals(Path.GetFileName(binaries), "Binaries", StringComparison.OrdinalIgnoreCase);
string? project = unreal ? Path.GetDirectoryName(binaries) : null;
return project is null ? null : Path.GetDirectoryName(project);
}
}
+9 -1
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.IO;
using Microsoft.Win32;
namespace FrameLedger.App.Services;
@@ -8,7 +9,7 @@ namespace FrameLedger.App.Services;
/// <summary>The WPF <see cref="OpenFileDialog"/> for FR-1.1.</summary>
public sealed class GamePicker : IGamePicker
{
public string? PickExecutable()
public string? PickExecutable(string? initialDirectory = null)
{
var dialog = new OpenFileDialog
{
@@ -17,6 +18,13 @@ public sealed class GamePicker : IGamePicker
CheckFileExists = true,
Multiselect = false,
};
// InitialDirectory opens the dialog there whatever folder it remembers (DefaultDirectory would only be a fallback).
if (!string.IsNullOrEmpty(initialDirectory) && Directory.Exists(initialDirectory))
{
dialog.InitialDirectory = initialDirectory;
}
return dialog.ShowDialog() == true ? dialog.FileName : null;
}
}
+5 -1
View File
@@ -7,5 +7,9 @@ namespace FrameLedger.App.Services;
public interface IGamePicker
{
/// <summary>The chosen executable's full path, or null when the user cancelled.</summary>
string? PickExecutable();
/// <param name="initialDirectory">
/// The folder the dialog opens in (beta.19: Change executable… opens in the game's own folder, <see cref="GameFolder"/>);
/// null leaves it to Windows, which opens where the last pick was.
/// </param>
string? PickExecutable(string? initialDirectory = null);
}
@@ -801,7 +801,8 @@ public sealed partial class GameDetailViewModel : ObservableObject
/// <summary>
/// A store import guesses the executable (Steam names none), and everything downstream is keyed on it: a wrong guess
/// is a game that can never be matched. The pick is the user's own; the row comes back hooking-off and unconsented,
/// exactly as a new game would, and consent is revoked over the pipe first, as removal does.
/// exactly as a new game would, and consent is revoked over the pipe first, as removal does. The dialog opens in the
/// game's own folder (beta.19, <see cref="GameFolder"/>), asked off the UI thread.
/// </summary>
private async Task ChangeExecutableCoreAsync()
{
@@ -810,7 +811,9 @@ public sealed partial class GameDetailViewModel : ObservableObject
return;
}
string? path = _picker.PickExecutable();
string current = Game.Fingerprint.ExePath;
string? folder = await Task.Run(() => GameFolder.StartFolder(current)).ConfigureAwait(true);
string? path = _picker.PickExecutable(folder);
if (path is null || string.Equals(ExecutableIdentity.Normalise(path), Game.Fingerprint.ExePath, StringComparison.OrdinalIgnoreCase))
{
return;
@@ -107,12 +107,19 @@ public sealed class GameDetailViewModelTests
private sealed class FakePicker(string? path) : IGamePicker
{
public string? PickExecutable() => path;
/// <summary>The folder each pick was asked to open in.</summary>
public List<string?> Folders { get; } = [];
public string? PickExecutable(string? initialDirectory = null)
{
Folders.Add(initialDirectory);
return path;
}
}
private static async Task<(GameDetailViewModel Vm, FakeAgent Agent, FakePrompt Prompt, FakeNavigator Nav, FakeStrip Strip)> BuildAsync(
ScratchLedger s, long gameId, RemoveGameChoice remove = RemoveGameChoice.Cancel, GameMetadata? edit = null, string? pick = null,
FakeAgent? withAgent = null, RegisteredSettings? settings = null, UiMode? mode = null)
FakeAgent? withAgent = null, RegisteredSettings? settings = null, UiMode? mode = null, FakePicker? picker = null)
{
FakeAgent agent = withAgent ?? new FakeAgent();
var prompt = new FakePrompt();
@@ -121,7 +128,7 @@ public sealed class GameDetailViewModelTests
var vm = new GameDetailViewModel(s.Library, new GameSelection { GameId = gameId }, new HookingConsent(agent, prompt), nav,
new FakeConfirmations(remove), new FakeEdit(edit), strip, new NoSummaries(),
new Charts.SessionSeriesLoader(s.Sessions), new Infrastructure.Persistence.SqliteHardwareSnapshotRepository(s.Db), new SessionSelection(),
new FakePicker(pick), settings, mode: mode);
picker ?? new FakePicker(pick), settings, mode: mode);
Task pending = vm.Pending;
await pending.ConfigureAwait(false);
return (vm, agent, prompt, nav, strip);
@@ -815,6 +822,36 @@ public sealed class GameDetailViewModelTests
}
}
/// <summary>
/// beta.19 (owner request 2026-10-12): the pick opens in the game's own root folder — a Steam install's folder under
/// <c>steamapps\common</c>, not the <c>bin\x64</c> the executable sits in, and not wherever the dialog was last.
/// </summary>
[Fact]
public async Task ChangingTheExecutableOpensThePickInTheGamesOwnFolder()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
string library = Path.Combine(Path.GetTempPath(), "fl-pick-" + Guid.NewGuid().ToString("N"));
string install = Path.Combine(library, "steamapps", "common", "Title");
Directory.CreateDirectory(Path.Combine(install, "bin", "x64"));
try
{
GameRow game = await s.GameAsync("Title", Infrastructure.Io.ExecutableIdentity.Normalise(Path.Combine(install, "bin", "x64", "Title.exe")));
var picker = new FakePicker(null);
(GameDetailViewModel vm, _, _, _, FakeStrip strip) = await BuildAsync(s, game.Id, picker: picker);
vm.ChangeExecutableCommand.Execute(null);
Task pending = vm.Pending;
await pending;
picker.Folders.Should().Equal([install], "the install root under steamapps\\common, not bin\\x64");
strip.Lines.Should().BeEmpty("a cancelled pick changes nothing");
}
finally
{
Directory.Delete(library, recursive: true);
}
}
[Fact]
public async Task ChangingTheExecutableToAnUnreadableFileOrCancellingChangesNothing()
{
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.IO;
using FluentAssertions;
using FrameLedger.App.Services;
namespace FrameLedger.App.Tests;
/// <summary>
/// Where Change executable… opens (beta.19, owner request 2026-10-12): the game's root folder for each layout the library
/// holds — a store's install folder, an Unreal package outside a store, a loose folder — the nearest folder still there for
/// an entry whose folder is gone, and nothing for a drive that is not connected.
/// </summary>
public sealed class GameFolderTests : IDisposable
{
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-gamefolder-" + Guid.NewGuid().ToString("N"));
public GameFolderTests() => Directory.CreateDirectory(_dir);
public void Dispose() => Directory.Delete(_dir, recursive: true);
private string Sub(params string[] parts)
{
string p = Path.Combine([_dir, .. parts]);
Directory.CreateDirectory(p);
return p;
}
[Fact]
public void AStoreInstallOpensAtItsFolderUnderTheStoresBoundary()
{
string install = Sub("SteamLibrary", "steamapps", "common", "Lies of P");
string bin = Sub("SteamLibrary", "steamapps", "common", "Lies of P", "LiesofP", "Binaries", "Win64");
GameFolder.StartFolder(Path.Combine(bin, "LiesofP-Win64-Shipping.exe")).Should().Be(install);
}
[Fact]
public void AnUnrealPackageOutsideAStoreOpensAboveItsProjectFolder()
{
string root = Sub("Games", "Hell Is Us");
string bin = Sub("Games", "Hell Is Us", "HellIsUs", "Binaries", "Win64");
GameFolder.StartFolder(Path.Combine(bin, "HellIsUs-Win64-Shipping.exe")).Should().Be(root, "<root>\\<Project>\\Binaries\\Win64 is Unreal's own layout");
}
[Fact]
public void ALooseFolderOpensWhereTheExecutableIs()
{
string game = Sub("it", "a-dolls-locket-remake", "Dolls Locket");
GameFolder.StartFolder(Path.Combine(game, "notification_helper.exe")).Should().Be(game);
}
[Fact]
public void AFolderThatIsGoneOpensAtTheNearestOneStillThere()
{
string library = Sub("it");
GameFolder.StartFolder(Path.Combine(library, "uninstalled", "Sub", "Game.exe")).Should().Be(library, "the entry reads Not installed; its library folder is still there");
}
[Fact]
public void ADriveThatIsNotConnectedOpensNowhereInParticular()
{
char? absent = null;
for (char letter = 'Z'; letter >= 'D'; letter--)
{
if (!Directory.Exists(letter + @":\"))
{
absent = letter;
break;
}
}
Assert.SkipWhen(absent is null, "every drive letter from D to Z is in use on this machine");
GameFolder.StartFolder(absent + @":\Games\Title\Title.exe").Should().BeNull("Windows then opens where the last pick was");
}
}
@@ -37,7 +37,7 @@ public sealed class GamesViewModelTests
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
public string? PickExecutable(string? initialDirectory = null) => null;
}
private sealed class NoStrip : IMessageStrip
@@ -129,7 +129,7 @@ public sealed partial class PagesLoadTests
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
public string? PickExecutable(string? initialDirectory = null) => null;
}
private sealed class NoTheme : IThemeApplier
@@ -92,7 +92,7 @@ public sealed class SessionDeletionAndOverviewTests
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
public string? PickExecutable(string? initialDirectory = null) => null;
}
/// <summary>The summary windows, counting how often they were asked to close the deleted sessions' ones.</summary>