Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
cfbbc54
Game logic engine skeleton
arthurkehrwald Jan 13, 2025
07ab1e6
Restructure
arthurkehrwald Jan 14, 2025
656cd12
Restructure
arthurkehrwald Jan 14, 2025
1f1c81e
Reimplement GetMachineDescription
arthurkehrwald Jan 14, 2025
a7cc9ee
Cosmetic corrections
arthurkehrwald Jan 14, 2025
8866d71
Report initial switch states to MPF
arthurkehrwald Jan 14, 2025
92c15dd
Forward switch changes to MPF
arthurkehrwald Jan 14, 2025
bf8cae2
Implement coil commands
arthurkehrwald Jan 14, 2025
6e93c11
Implement light fade command
arthurkehrwald Jan 14, 2025
57ee04e
Add DMD support
arthurkehrwald Jan 15, 2025
04aad3d
Implement hardware rules
arthurkehrwald Jan 15, 2025
4f4723f
Restructure
arthurkehrwald Jan 16, 2025
580e686
Improve reliability
arthurkehrwald Jan 16, 2025
19f0a4c
Format code
arthurkehrwald Jan 16, 2025
81ff8e0
Format code
arthurkehrwald Jan 16, 2025
0a4c8fb
Remove pointless async from OnInspectorGUI
arthurkehrwald Jan 16, 2025
1890c97
Move MpfArgs to separate file
arthurkehrwald Jan 16, 2025
47bcc17
Format code
arthurkehrwald Jan 16, 2025
b244074
Add copyright notices
arthurkehrwald Jan 16, 2025
896cb7f
Show MPF window on Ubuntu
arthurkehrwald Jan 18, 2025
d48ae60
Formatting
arthurkehrwald Jan 18, 2025
b2d32a2
Use x-terminal-emulator instead of gnome-terminal
arthurkehrwald Jan 19, 2025
6032fd4
Patch for macOS
arthurkehrwald Jan 22, 2025
4ee866c
Port inspector UI to UiToolkit
arthurkehrwald Jan 22, 2025
9186ac9
Add nuget requirements to manifest
arthurkehrwald Jan 22, 2025
ecc7f7a
Delete meta files from previous structure
arthurkehrwald Jan 22, 2025
39a1898
Consistent spelling of game logic engine
arthurkehrwald Jan 23, 2025
726d8e9
Consistent spelling of game logic engine
arthurkehrwald Jan 23, 2025
a58ca7c
Automatically set up sample machine folder
arthurkehrwald Jan 23, 2025
72c229d
Automatically copy executables to build directory
arthurkehrwald Jan 23, 2025
32c3400
Add option to display MPF output in console
arthurkehrwald Jan 23, 2025
7396646
Overhaul inspector
arthurkehrwald Jan 23, 2025
807ffb0
Add icon to MpfGameLogicEngine script
arthurkehrwald Jan 24, 2025
1d1e130
Cosmetic edits
arthurkehrwald Jan 24, 2025
4c8f465
Fix icons
arthurkehrwald Jan 24, 2025
0176275
Retry connection instead of wait on startup
arthurkehrwald Jan 24, 2025
025e311
Ping to establish connection
arthurkehrwald Jan 25, 2025
97b3e16
Log MPF version and connect time
arthurkehrwald Jan 25, 2025
1d8d7eb
Improve fault handling
arthurkehrwald Jan 26, 2025
7788a7b
Replace windows binary with uncompressed version
arthurkehrwald Jan 26, 2025
20698ab
Patch for new binary
arthurkehrwald Jan 26, 2025
ae59bb4
Make get machine description asynchronous
arthurkehrwald Jan 26, 2025
4df171d
Never open MPF window in release builds
arthurkehrwald Jan 26, 2025
66b4aef
Make MpfStarter fields private
arthurkehrwald Jan 27, 2025
a03adb8
Correctly handle overwriting files
arthurkehrwald Jan 27, 2025
50f088b
Remove MPF logs and audits from build
arthurkehrwald Jan 27, 2025
7e4818f
Warn in case of machine description mismatch
arthurkehrwald Jan 27, 2025
f84217e
Fix machine description matching
arthurkehrwald Jan 27, 2025
20470c2
Display mpf state in inspector
arthurkehrwald Jan 27, 2025
6cd1884
Cosmetic changes
arthurkehrwald Jan 28, 2025
1dbf6cf
Refactor
arthurkehrwald Jan 28, 2025
f219b03
Add backwards compatible ping alternative
arthurkehrwald Jan 28, 2025
b1bedce
Add tooltips to inspector
arthurkehrwald Jan 28, 2025
2c3edfc
Add 'assume MPF is running' feature
arthurkehrwald Jan 29, 2025
f184c4f
Grey out all other options in 'AssumeRunning' mode
arthurkehrwald Jan 29, 2025
7399afb
Fix compile errors on Linux
arthurkehrwald Jan 29, 2025
08def00
Improve MPF start failure handling
arthurkehrwald Jan 29, 2025
ff2a199
Add Linux binaries
arthurkehrwald Jan 29, 2025
45a27fb
Avoid timeout issue with GetMachineDescription
arthurkehrwald Jan 29, 2025
23ec750
Add machine folder validation
arthurkehrwald Jan 30, 2025
2003014
Add .DS_Store files to .gitignore
arthurkehrwald Jan 30, 2025
1c140d8
Add macOS binaries
arthurkehrwald Jan 30, 2025
640b007
Reliably kill MPF on shutdown and before start
arthurkehrwald Jan 30, 2025
2abbce4
Fix build postprocessing on macOS
arthurkehrwald Jan 30, 2025
26d0e17
Fix timeout by loss of focus issue
arthurkehrwald Jan 30, 2025
f62705d
Fix AssumeRunning option
arthurkehrwald Jan 30, 2025
1db7704
Update year in copyright notices
arthurkehrwald Jan 30, 2025
b46cbd0
Remove nuget dependencies from package.json
arthurkehrwald Jan 30, 2025
8e4cebb
Fix build pipeline maybe
arthurkehrwald Feb 2, 2025
6fea8f0
Update up/download-artifact actions to v4
arthurkehrwald Feb 2, 2025
aafdd64
Use preinstalled dotnet to build
arthurkehrwald Feb 2, 2025
3f1fe20
Separate upload folder for each platform
arthurkehrwald Feb 2, 2025
59d684d
Another patch for upload v4
arthurkehrwald Feb 2, 2025
7670d30
Install yetanotherhttphandler
arthurkehrwald Feb 4, 2025
ac2639c
Maybe fix build errors
arthurkehrwald Feb 4, 2025
ccf669c
Fix build error maybe
arthurkehrwald Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
33 changes: 16 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,28 @@ jobs:
- os: ubuntu-latest
rid: linux-x64
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- uses: actions/checkout@v4
- name: Build
run: |
cd VisualPinball.Engine.Mpf
dotnet build -c Release -r ${{ matrix.rid }}
# - name: Test
# run: |
# cd VisualPinball.Engine.Mpf.Test
# dotnet run -c Release -r ${{ matrix.rid }}
- run: |
mkdir tmp
cp -r VisualPinball.Engine.Mpf.Unity/Plugins/${{ matrix.rid }} tmp
- uses: actions/upload-artifact@v2
dotnet build -c Release -r ${{ matrix.rid }} -p:InstallYetAnotherHttpHandler=false
- uses: actions/upload-artifact@v4
with:
name: Plugins
path: tmp
name: NuGetDependencies-${{ matrix.rid }}
path: Dependencies/NuGetDependencies/${{ matrix.rid }}
install-yetanotherhttphandler:
name: Install YetAnotherHttpHandler
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: dotnet build /t:InstallYetAnotherHttpHandler
- uses: actions/upload-artifact@v4
with:
name: YetAnotherHttpHandler
path: Dependencies/YetAnotherHttpHandler

dispatch:
runs-on: ubuntu-latest
needs: [ build ]
needs: [ build, install-yetanotherhttphandler ]
if: github.repository == 'VisualPinball/VisualPinball.Engine.Mpf' && github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- uses: peter-evans/repository-dispatch@v1
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ jobs:
registry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dawidd6/action-download-artifact@v2
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
workflow: build
run_id: ${{ github.event.client_payload.artifacts_run_id }}
path: VisualPinball.Engine.Mpf.Unity
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.client_payload.artifacts_run_id }}
- name: Publish
run: |
cd VisualPinball.Engine.Mpf.Unity
echo "//registry.visualpinball.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
npm publish
env:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,25 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch next version
id: nextVersion
uses: VisualPinball/next-version-action@v0.1.7
with:
path: VisualPinball.Engine.Mpf.Unity
tagPrefix: 'v'
- name: Bump
if: ${{ steps.nextVersion.outputs.isBump == 'true' }}
run: |
cd VisualPinball.Engine.Mpf.Unity
npm version ${{ steps.nextVersion.outputs.nextVersion }} --no-git-tag-version
- name: Commit
id: commit
if: ${{ steps.nextVersion.outputs.isBump == 'true' }}
run: |
git config user.name "github-actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add VisualPinball.Engine.Mpf.Unity/package.json
git add package.json
git commit -m "release: ${{ steps.nextVersion.outputs.nextTag }}."
git push
commitish=$(git rev-parse HEAD)
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,9 @@ MigrationBackup/

**/protos/*.cs
VisualPinball.Engine.Mpf/machine/data/

# macOS meta files
*.DS_Store

Dependencies/
Dependencies.meta
File renamed without changes.
140 changes: 140 additions & 0 deletions Editor/BuildPostprocessing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
// Visual Pinball Engine
// Copyright (C) 2025 freezy and VPE Team
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.IO;
using System.Linq;
using NLog;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using Logger = NLog.Logger;

namespace VisualPinball.Engine.Mpf.Unity.Editor
{
public class BuildPostprocessing : IPostprocessBuildWithReport
{
int IOrderedCallback.callbackOrder => 0;

private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

private const string _unsupportedPlaformMessage =
"Visual Pinball Engine does not ship with an MPF executable for the build "
+ "platform '{}}.' The build will not work unless MPF is installed "
+ "on the end-user's device";

void IPostprocessBuildWithReport.OnPostprocessBuild(BuildReport report)
{
if (
report.summary.result == BuildResult.Failed
|| report.summary.result == BuildResult.Cancelled
)
return;

var streamingAssetsPath = FindStreamingAssets(
report.summary.platform,
report.summary.outputPath
);
CleanMachineFolder(streamingAssetsPath);
AddMpfBinaries(report.summary.platform, streamingAssetsPath);
}

private static string FindStreamingAssets(BuildTarget platform, string buildExePath)
{
string dataDir;

if (
platform
is BuildTarget.StandaloneWindows
or BuildTarget.StandaloneWindows64
or BuildTarget.StandaloneLinux64
)
{
dataDir = Directory
.GetDirectories(Directory.GetParent(buildExePath).ToString(), "*_Data")
.FirstOrDefault();
}
else if (platform is BuildTarget.StandaloneOSX)
{
dataDir = Path.Combine(buildExePath, "Contents", "Resources", "Data");
}
else
{
throw new PlatformNotSupportedException(
string.Format(_unsupportedPlaformMessage, platform)
);
}

return Path.Combine(dataDir, "StreamingAssets");
}

private static void AddMpfBinaries(BuildTarget platform, string streamingAssetsPath)
{
Logger.Info("Adding MPF binaries to build...");
// Get the directory of the MPF package from the Unity package manager
var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(
typeof(BuildPostprocessing).Assembly
);

var binaryDirName = platform switch
{
BuildTarget.StandaloneLinux64 => Constants.MpfBinaryDirLinux,
BuildTarget.StandaloneOSX => Constants.MpfBinaryDirMacOS,
BuildTarget.StandaloneWindows => Constants.MpfBinaryDirWindows,
BuildTarget.StandaloneWindows64 => Constants.MpfBinaryDirWindows,
_ => throw new PlatformNotSupportedException(
string.Format(_unsupportedPlaformMessage, platform)
),
};
var sourcePath = Path.Combine(
packageInfo.resolvedPath,
Constants.MpfBinariesDirName,
binaryDirName
);

var destPath = Path.Combine(
streamingAssetsPath,
Constants.MpfBinariesDirName,
binaryDirName
);

Directory.CreateDirectory(destPath);
CopyUtil.CopyDirectory(sourcePath, destPath, recursive: true, overwrite: true);

Logger.Info("Successfully added MPF binaries to build.");
}

private static void CleanMachineFolder(string streamingAssetsPath)
{
Logger.Info("Removing log files and audits from machine folder...");

var machineFolders = Directory
.GetDirectories(streamingAssetsPath)
.Where((dir) => File.Exists(Path.Combine(dir, "config", "config.yaml")));

foreach (var mf in machineFolders)
{
// Delete log files from previous runs
var logDir = Path.Combine(mf, "logs");
var logFiles = Directory.GetFiles(logDir, "*.log", SearchOption.TopDirectoryOnly);
foreach (var logFile in logFiles)
File.Delete(logFile);

// Delete audits file (contains statistics about previous runs)
var auditsFile = Path.Combine(mf, "data", "audits.yaml");
if (File.Exists(auditsFile))
File.Delete(auditsFile);
}

Logger.Info("Successfully removed log files and audits from machine folder.");
}
}
}
11 changes: 11 additions & 0 deletions Editor/BuildPostprocessing.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions Editor/CopyUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Visual Pinball Engine
// Copyright (C) 2025 freezy and VPE Team
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System.IO;

namespace VisualPinball.Engine.Mpf.Unity.Editor
{
public static class CopyUtil
{
// Source: https://learn.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
public static void CopyDirectory(
string sourceDir,
string destinationDir,
bool recursive,
bool overwrite
)
{
var dir = new DirectoryInfo(sourceDir);

if (!dir.Exists)
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");

DirectoryInfo[] dirs = dir.GetDirectories();
Directory.CreateDirectory(destinationDir);

foreach (FileInfo file in dir.GetFiles())
{
if (file.Extension == ".meta")
continue;
string targetFilePath = Path.Combine(destinationDir, file.Name);
if (overwrite || !File.Exists(targetFilePath))
file.CopyTo(targetFilePath, overwrite);
}

if (recursive)
{
foreach (DirectoryInfo subDir in dirs)
{
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
CopyDirectory(subDir.FullName, newDestinationDir, true, overwrite);
}
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/CopyUtil.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor/Inspector.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading