Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Test
run: dotnet test tests/BmsConfig.Tests -c Release

- name: Build Config.exe
run: dotnet build src/BmsConfig -c Release

- uses: actions/upload-artifact@v4
with:
name: Config
path: src/BmsConfig/bin/Release/net48/Config.exe
33 changes: 33 additions & 0 deletions BmsConfig.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BmsConfig", "src\BmsConfig\BmsConfig.csproj", "{3F6A1E2B-7C4D-4B8E-9A21-5D0C8E7F1A34}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7C1BC3C5-1EFA-4868-96B2-A8BC16B97E68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BmsConfig.Tests", "tests\BmsConfig.Tests\BmsConfig.Tests.csproj", "{5CA0860D-108F-425E-BD4A-DDB5459AF34C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F6A1E2B-7C4D-4B8E-9A21-5D0C8E7F1A34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F6A1E2B-7C4D-4B8E-9A21-5D0C8E7F1A34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F6A1E2B-7C4D-4B8E-9A21-5D0C8E7F1A34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F6A1E2B-7C4D-4B8E-9A21-5D0C8E7F1A34}.Release|Any CPU.Build.0 = Release|Any CPU
{5CA0860D-108F-425E-BD4A-DDB5459AF34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CA0860D-108F-425E-BD4A-DDB5459AF34C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CA0860D-108F-425E-BD4A-DDB5459AF34C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CA0860D-108F-425E-BD4A-DDB5459AF34C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5CA0860D-108F-425E-BD4A-DDB5459AF34C} = {7C1BC3C5-1EFA-4868-96B2-A8BC16B97E68}
EndGlobalSection
EndGlobal
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,32 @@ New Config tool for Falcon BMS -- replacement for the legacy F4Patch-based Confi

![Opening Screen](.github/images/Mockup1.png)

![Listview Screen](.github/images/Mockup2.png)
![Listview Screen](.github/images/Mockup2.png)
### Building

Requires the .NET SDK (8.0 or later) on Windows -- or Visual Studio 2022 -- and produces a single, dependency-free `Config.exe` targeting .NET Framework 4.8 (AnyCPU, 64-bit preferred):

```
dotnet build src/BmsConfig -c Release
```

Output: `src/BmsConfig/bin/Release/net48/Config.exe`. Copy it into the root of a BMS install (the registry `baseDir`), next to the `User` folder.

Unit tests for the cfg parser/model run anywhere (including Linux):

```
dotnet test tests/BmsConfig.Tests
```

Every push is built on GitHub Actions (`.github/workflows/build.yml`); `Config.exe` is attached to each run as an artifact.

### Source layout

| Path | Purpose |
| --- | --- |
| `src/BmsConfig/Core/CfgDocument.cs` | Line-preserving cfg parser/editor: comments, blank lines and ordering round-trip untouched; edits replace only the value token; new lines go above the Launcher cut line. UTF-8, written without BOM. |
| `src/BmsConfig/Core/ValueConverter.cs` | Datatypes (from the `g_b`/`g_n`/`g_f`/`g_s` name prefix), `Range:[..]` and `Enum:[..]` parsing, input validation/conversion (hex ints, no float exponents/NaN/Inf, fancy-quote stripping), and the feature-flag regexes. |
| `src/BmsConfig/Core/ConfigSet.cs` | Merges `Falcon BMS.cfg` → `User.cfg` → `VR.cfg` (last writer wins), assigns categories, and writes edits back to disk immediately. |
| `src/BmsConfig/Core/BmsInstalls.cs` | Finds side-by-side installs under `HKLM\SOFTWARE\WOW6432Node\Benchmark Sims`. |
| `src/BmsConfig/MainWindow.xaml(.cs)` | The master/detail UI. |
| `src/BmsConfig/Themes/` | Dark / Light palettes, and the control styles. |
14 changes: 14 additions & 0 deletions src/BmsConfig/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Application x:Class="BmsConfig.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- The palette (Dark.xaml or Light.xaml) is inserted at index 0 by ThemeManager. -->
<ResourceDictionary Source="Themes/Dark.xaml" />
<ResourceDictionary Source="Themes/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
24 changes: 24 additions & 0 deletions src/BmsConfig/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Windows;
using System.Windows.Threading;

namespace BmsConfig
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
// Dark.xaml is loaded statically (so the designer has a palette); replace it with the user's choice.
Resources.MergedDictionaries.RemoveAt(0);
ThemeManager.Initialize();

DispatcherUnhandledException += OnUnhandledException;
base.OnStartup(e);
}

void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.Exception.ToString(), "Unexpected error", MessageBoxButton.OK, MessageBoxImage.Error);
e.Handled = true;
}
}
}
42 changes: 42 additions & 0 deletions src/BmsConfig/BmsConfig.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net48</TargetFramework>
<UseWPF>true</UseWPF>
<AssemblyName>Config</AssemblyName>
<RootNamespace>BmsConfig</RootNamespace>
<LangVersion>7.3</LangVersion>

<!-- AnyCPU, 64-bit preferred (runs natively as x64 or ARM64, and as x86 on 32-bit Windows). -->
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>

<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Config.ico</ApplicationIcon>

<Product>Falcon BMS Config Editor</Product>
<Company>Benchmark Sims</Company>
<Version>1.0.0</Version>

<!-- Single exe: no app.config, no satellite assemblies, no pdb next to the exe in Release. -->
<GenerateSupportedRuntime>false</GenerateSupportedRuntime>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<DebugType Condition="'$(Configuration)' == 'Release'">embedded</DebugType>

<!-- Allow building on non-Windows hosts (eg. CI); the output is identical. -->
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<ItemGroup>
<!-- Build-time only: .NET Framework reference assemblies, so no targeting pack needs to be installed. Not shipped. -->
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<Resource Include="Config.ico" />
<Resource Include="Logo.png" />
</ItemGroup>

</Project>
Binary file added src/BmsConfig/Config.ico
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions src/BmsConfig/Core/BmsInstalls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Win32;

namespace BmsConfig.Core
{
public sealed class BmsInstall
{
public string Name { get; private set; }
public string BaseDir { get; private set; }
public string ConfigFolder { get { return Path.Combine(BaseDir, "User", "Config"); } }

public BmsInstall(string name, string baseDir)
{
Name = name;
BaseDir = baseDir;
}

public override string ToString() { return Name + " - " + BaseDir; }
}

/// <summary>
/// Finds the side-by-side BMS installs, listed under HKLM\SOFTWARE\WOW6432Node\Benchmark Sims.
/// </summary>
public static class BmsInstalls
{
public static List<BmsInstall> Discover()
{
List<BmsInstall> installs = new List<BmsInstall>();
try
{
// The 32-bit registry view maps to WOW6432Node from a 64-bit process, and to the
// native hive from a 32-bit process -- so this works regardless of process bitness.
using (RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))

Check warning on line 35 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryView.Registry32' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 35 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryHive.LocalMachine' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 35 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.OpenBaseKey(RegistryHive, RegistryView)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 35 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryHive.LocalMachine' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 35 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryView.Registry32' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 35 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.OpenBaseKey(RegistryHive, RegistryView)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
using (RegistryKey root = hklm.OpenSubKey(@"SOFTWARE\Benchmark Sims"))

Check warning on line 36 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.OpenSubKey(string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 36 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.OpenSubKey(string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{
if (root != null)
{
foreach (string subKeyName in root.GetSubKeyNames())

Check warning on line 40 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.GetSubKeyNames()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 40 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.GetSubKeyNames()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{
using (RegistryKey sub = root.OpenSubKey(subKeyName))

Check warning on line 42 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.OpenSubKey(string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.OpenSubKey(string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{
string baseDir = (sub != null) ? sub.GetValue("baseDir") as string : null;

Check warning on line 44 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.GetValue(string?)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in src/BmsConfig/Core/BmsInstalls.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RegistryKey.GetValue(string?)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
if (!string.IsNullOrWhiteSpace(baseDir))
installs.Add(new BmsInstall(subKeyName, baseDir.Trim()));
}
}
}
}
}
catch (Exception)
{
// No registry (or no access) -- the user can still browse to a folder.
}

installs.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
return installs;
}

/// <summary>The install whose baseDir contains the given exe directory, if any.</summary>
public static BmsInstall FindContaining(IEnumerable<BmsInstall> installs, string exeDir)
{
string dir = NormalizeDir(exeDir);
if (dir == null)
return null;

BmsInstall best = null;
foreach (BmsInstall install in installs)
{
string baseDir = NormalizeDir(install.BaseDir);
if (baseDir == null)
continue;

if (string.Equals(dir, baseDir, StringComparison.OrdinalIgnoreCase)
|| dir.StartsWith(baseDir + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
if (best == null || baseDir.Length > NormalizeDir(best.BaseDir).Length)
best = install;
}
}
return best;
}

static string NormalizeDir(string dir)
{
if (string.IsNullOrWhiteSpace(dir))
return null;
try
{
return Path.GetFullPath(dir).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
}
catch (Exception)
{
return null;
}
}
}
}
Loading
Loading