From 1142252015e5b8cc78ef2250b4c386d83b8ce72c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 17 Aug 2022 21:51:38 +0200 Subject: [PATCH] reformat & cleanup --- GameBundle/.config/dotnet-tools.json | 18 +- GameBundle/Options.cs | 114 ++++---- GameBundle/Program.cs | 380 +++++++++++++-------------- Test/GameImpl.cs | 40 +-- Test/Program.cs | 14 +- Test/Test.csproj | 8 +- 6 files changed, 287 insertions(+), 287 deletions(-) diff --git a/GameBundle/.config/dotnet-tools.json b/GameBundle/.config/dotnet-tools.json index 9c23529..ad7abd7 100644 --- a/GameBundle/.config/dotnet-tools.json +++ b/GameBundle/.config/dotnet-tools.json @@ -1,12 +1,12 @@ { - "version": 1, - "isRoot": true, - "tools": { - "nulastudio.ncbeauty": { - "version": "1.2.9.3", - "commands": [ - "ncbeauty" - ] + "version": 1, + "isRoot": true, + "tools": { + "nulastudio.ncbeauty": { + "version": "1.2.9.3", + "commands": [ + "ncbeauty" + ] + } } - } } \ No newline at end of file diff --git a/GameBundle/Options.cs b/GameBundle/Options.cs index f16df56..9dcd2a0 100644 --- a/GameBundle/Options.cs +++ b/GameBundle/Options.cs @@ -2,68 +2,68 @@ using System; using System.Collections.Generic; using CommandLine; -namespace GameBundle { - public class Options { +namespace GameBundle; - [Option('s', "source", HelpText = "The location of the .csproj file that should be built and bundled. By default, the current directory is scanned for one")] - public string SourceFile { get; set; } - [Option('o', "output", Default = "bin/Bundled", HelpText = "The location of the directory that the bundles should be stored in")] - public string OutputDirectory { get; set; } - [Option('v', "verbose", HelpText = "Display verbose output while building")] - public bool Verbose { get; set; } +public class Options { - [Option('w', "win", HelpText = "Bundle for windows")] - public bool BuildWindows { get; set; } - [Option('l', "linux", HelpText = "Bundle for linux")] - public bool BuildLinux { get; set; } - [Option('m', "mac", HelpText = "Bundle for mac")] - public bool BuildMac { get; set; } - [Option("win-rid", Default = "win-x64", HelpText = "The RID to use for windows builds")] - public string WindowsRid { get; set; } - [Option("linux-rid", Default = "linux-x64", HelpText = "The RID to use for linux builds")] - public string LinuxRid { get; set; } - [Option("mac-rid", Default = "osx-x64", HelpText = "The RID to use for mac builds")] - public string MacRid { get; set; } + [Option('s', "source", HelpText = "The location of the .csproj file that should be built and bundled. By default, the current directory is scanned for one")] + public string SourceFile { get; set; } + [Option('o', "output", Default = "bin/Bundled", HelpText = "The location of the directory that the bundles should be stored in")] + public string OutputDirectory { get; set; } + [Option('v', "verbose", HelpText = "Display verbose output while building")] + public bool Verbose { get; set; } - [Option('W', "win-arm", HelpText = "Bundle for windows arm")] - public bool BuildWindowsArm { get; set; } - [Option('L', "linux-arm", HelpText = "Bundle for linux arm")] - public bool BuildLinuxArm { get; set; } - [Option('M', "mac-arm", HelpText = "Bundle for mac arm")] - public bool BuildMacArm { get; set; } - [Option("win-arm-rid", Default = "win-arm64", HelpText = "The RID to use for windows arm builds")] - public string WindowsArmRid { get; set; } - [Option("linux-arm-rid", Default = "linux-arm64", HelpText = "The RID to use for linux arm builds")] - public string LinuxArmRid { get; set; } - [Option("mac-arm-rid", Default = "osx-arm64", HelpText = "The RID to use for mac arm builds")] - public string MacArmRid { get; set; } + [Option('w', "win", HelpText = "Bundle for windows")] + public bool BuildWindows { get; set; } + [Option('l', "linux", HelpText = "Bundle for linux")] + public bool BuildLinux { get; set; } + [Option('m', "mac", HelpText = "Bundle for mac")] + public bool BuildMac { get; set; } + [Option("win-rid", Default = "win-x64", HelpText = "The RID to use for windows builds")] + public string WindowsRid { get; set; } + [Option("linux-rid", Default = "linux-x64", HelpText = "The RID to use for linux builds")] + public string LinuxRid { get; set; } + [Option("mac-rid", Default = "osx-x64", HelpText = "The RID to use for mac builds")] + public string MacRid { get; set; } - [Option('z', "zip", HelpText = "Store the build results in zip files instead of folders")] - public bool Zip { get; set; } - [Option('b', "mac-bundle", HelpText = "Create an app bundle for mac")] - public bool MacBundle { get; set; } - [Option("mac-bundle-resources", Default = new[] {"Content", "*.icns"}, HelpText = "When creating an app bundle for mac, things that should go into the Resources folder rather than the MacOS folder")] - public IEnumerable MacBundleResources { get; set; } - [Option("mac-bundle-ignore", HelpText = "When creating an app bundle for mac, things that should be left out of the mac bundle and stay in the output folder")] - public IEnumerable MacBundleIgnore { get; set; } + [Option('W', "win-arm", HelpText = "Bundle for windows arm")] + public bool BuildWindowsArm { get; set; } + [Option('L', "linux-arm", HelpText = "Bundle for linux arm")] + public bool BuildLinuxArm { get; set; } + [Option('M', "mac-arm", HelpText = "Bundle for mac arm")] + public bool BuildMacArm { get; set; } + [Option("win-arm-rid", Default = "win-arm64", HelpText = "The RID to use for windows arm builds")] + public string WindowsArmRid { get; set; } + [Option("linux-arm-rid", Default = "linux-arm64", HelpText = "The RID to use for linux arm builds")] + public string LinuxArmRid { get; set; } + [Option("mac-arm-rid", Default = "osx-arm64", HelpText = "The RID to use for mac arm builds")] + public string MacArmRid { get; set; } - [Option("skip-lib", HelpText = "When bundling, skip beautifying the output by moving files to the library folder")] - public bool SkipLib { get; set; } - [Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")] - public IEnumerable ExcludedFiles { get; set; } - [Option("lib-name", Default = "Lib", HelpText = "The name of the library folder that is created")] - public string LibFolder { get; set; } + [Option('z', "zip", HelpText = "Store the build results in zip files instead of folders")] + public bool Zip { get; set; } + [Option('b', "mac-bundle", HelpText = "Create an app bundle for mac")] + public bool MacBundle { get; set; } + [Option("mac-bundle-resources", Default = new[] {"Content", "*.icns"}, HelpText = "When creating an app bundle for mac, things that should go into the Resources folder rather than the MacOS folder")] + public IEnumerable MacBundleResources { get; set; } + [Option("mac-bundle-ignore", HelpText = "When creating an app bundle for mac, things that should be left out of the mac bundle and stay in the output folder")] + public IEnumerable MacBundleIgnore { get; set; } - [Option('t', "trim", HelpText = "Trim the application when publishing")] - public bool Trim { get; set; } - [Option('c', "config", Default = "Release", HelpText = "The build configuration to use")] - public string BuildConfig { get; set; } - [Option('a', "build-args", HelpText = "Additional arguments that should be passed to the dotnet publish command")] - public string BuildArgs { get; set; } - [Option('n', "name-builds", HelpText = "Name the build output directories by the name of the executable")] - public bool NameBuilds { get; set; } - [Option('N', "name-addition", HelpText = "An additional string of text that should be included in the names of the output directories")] - public string NameAddition { get; set; } + [Option("skip-lib", HelpText = "When bundling, skip beautifying the output by moving files to the library folder")] + public bool SkipLib { get; set; } + [Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")] + public IEnumerable ExcludedFiles { get; set; } + [Option("lib-name", Default = "Lib", HelpText = "The name of the library folder that is created")] + public string LibFolder { get; set; } + + [Option('t', "trim", HelpText = "Trim the application when publishing")] + public bool Trim { get; set; } + [Option('c', "config", Default = "Release", HelpText = "The build configuration to use")] + public string BuildConfig { get; set; } + [Option('a', "build-args", HelpText = "Additional arguments that should be passed to the dotnet publish command")] + public string BuildArgs { get; set; } + [Option('n', "name-builds", HelpText = "Name the build output directories by the name of the executable")] + public bool NameBuilds { get; set; } + [Option('N', "name-addition", HelpText = "An additional string of text that should be included in the names of the output directories")] + public string NameAddition { get; set; } - } } \ No newline at end of file diff --git a/GameBundle/Program.cs b/GameBundle/Program.cs index 8bfff99..c251eb8 100644 --- a/GameBundle/Program.cs +++ b/GameBundle/Program.cs @@ -7,213 +7,213 @@ using System.Linq; using System.Text.RegularExpressions; using CommandLine; -namespace GameBundle { - internal static class Program { +namespace GameBundle; - private static int Main(string[] args) { - return new Parser(c => { - c.HelpWriter = Console.Error; - c.EnableDashDash = true; - }).ParseArguments(args).MapResult(Run, _ => -1); +internal static class Program { + + private static int Main(string[] args) { + return new Parser(c => { + c.HelpWriter = Console.Error; + c.EnableDashDash = true; + }).ParseArguments(args).MapResult(Program.Run, _ => -1); + } + + private static int Run(Options options) { + // make sure all of the required tools are installed + if (Program.RunProcess(options, "dotnet", "tool restore", AppDomain.CurrentDomain.BaseDirectory) != 0) { + Console.WriteLine("dotnet tool restore failed, aborting"); + return -1; } - private static int Run(Options options) { - // make sure all of the required tools are installed - if (RunProcess(options, "dotnet", "tool restore", AppDomain.CurrentDomain.BaseDirectory) != 0) { - Console.WriteLine("dotnet tool restore failed, aborting"); + var proj = Program.GetProjectFile(options); + if (proj == null || !proj.Exists) { + Console.WriteLine("Project file not found, aborting"); + return -1; + } + Console.WriteLine($"Bundling project {proj.FullName}"); + + var builtAnything = false; + var toBuild = new List { + // regular builds + new("windows", "win", options.WindowsRid, options.BuildWindows), + new("linux", "linux", options.LinuxRid, options.BuildLinux), + new("mac", "mac", options.MacRid, options.BuildMac, false, d => options.MacBundle ? Program.CreateMacBundle(options, d) : 0), + // arm builds + new("windows arm", "win-arm", options.WindowsArmRid, options.BuildWindowsArm, true), + new("linux arm", "linux-arm", options.LinuxArmRid, options.BuildLinuxArm, true), + new("mac arm", "mac-arm", options.MacArmRid, options.BuildMacArm, true, d => options.MacBundle ? Program.CreateMacBundle(options, d) : 0) + }; + foreach (var config in toBuild) { + if (config.ShouldBuild) { + Console.WriteLine($"Bundling for {config.DisplayName}"); + var res = Program.Publish(options, proj, config); + if (res != 0) + return res; + builtAnything = true; + } + } + if (!builtAnything) + Console.WriteLine("No build took place. Supply -w, -l or -m arguments or see available arguments using --help."); + + Console.WriteLine("Done"); + return 0; + } + + private static int Publish(Options options, FileInfo proj, BuildConfig config) { + var buildDir = Program.GetBuildDir(options, config.DirectoryName); + var publishResult = Program.RunProcess(options, "dotnet", $"publish \"{proj.FullName}\" -o \"{buildDir.FullName}\" -r {config.Rid} --self-contained -c {options.BuildConfig} /p:PublishTrimmed={options.Trim} {options.BuildArgs}"); + if (publishResult != 0) + return publishResult; + + // Run beauty + if (!options.SkipLib && !config.SkipLib) { + var excludes = $"\"{string.Join(";", options.ExcludedFiles)}\""; + var log = options.Verbose ? "Detail" : "Error"; + var beautyResult = Program.RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True --noflag=True \"{buildDir.FullName}\" \"{options.LibFolder}\" {excludes}", AppDomain.CurrentDomain.BaseDirectory); + if (beautyResult != 0) + return beautyResult; + } + + // Rename build folder if named builds are enabled + if (options.NameBuilds) { + var name = Program.GetBuildName(options, buildDir); + if (name == null) { + Console.WriteLine("Couldn't determine build name, aborting"); return -1; } - - var proj = GetProjectFile(options); - if (proj == null || !proj.Exists) { - Console.WriteLine("Project file not found, aborting"); - return -1; - } - Console.WriteLine($"Bundling project {proj.FullName}"); - - var builtAnything = false; - var toBuild = new List { - // regular builds - new("windows", "win", options.WindowsRid, options.BuildWindows), - new("linux", "linux", options.LinuxRid, options.BuildLinux), - new("mac", "mac", options.MacRid, options.BuildMac, false, d => options.MacBundle ? CreateMacBundle(options, d) : 0), - // arm builds - new("windows arm", "win-arm", options.WindowsArmRid, options.BuildWindowsArm, true), - new("linux arm", "linux-arm", options.LinuxArmRid, options.BuildLinuxArm, true), - new("mac arm", "mac-arm", options.MacArmRid, options.BuildMacArm, true, d => options.MacBundle ? CreateMacBundle(options, d) : 0) - }; - foreach (var config in toBuild) { - if (config.ShouldBuild) { - Console.WriteLine($"Bundling for {config.DisplayName}"); - var res = Publish(options, proj, config); - if (res != 0) - return res; - builtAnything = true; - } - } - if (!builtAnything) - Console.WriteLine("No build took place. Supply -w, -l or -m arguments or see available arguments using --help."); - - Console.WriteLine("Done"); - return 0; - } - - private static int Publish(Options options, FileInfo proj, BuildConfig config) { - var buildDir = GetBuildDir(options, config.DirectoryName); - var publishResult = RunProcess(options, "dotnet", $"publish \"{proj.FullName}\" -o \"{buildDir.FullName}\" -r {config.Rid} --self-contained -c {options.BuildConfig} /p:PublishTrimmed={options.Trim} {options.BuildArgs}"); - if (publishResult != 0) - return publishResult; - - // Run beauty - if (!options.SkipLib && !config.SkipLib) { - var excludes = $"\"{string.Join(";", options.ExcludedFiles)}\""; - var log = options.Verbose ? "Detail" : "Error"; - var beautyResult = RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True --noflag=True \"{buildDir.FullName}\" \"{options.LibFolder}\" {excludes}", AppDomain.CurrentDomain.BaseDirectory); - if (beautyResult != 0) - return beautyResult; - } - - // Rename build folder if named builds are enabled - if (options.NameBuilds) { - var name = GetBuildName(options, buildDir); - if (name == null) { - Console.WriteLine("Couldn't determine build name, aborting"); - return -1; - } - var dest = Path.Combine(buildDir.Parent.FullName, $"{name}-{buildDir.Name}"); - if (Directory.Exists(dest)) - Directory.Delete(dest, true); - buildDir.MoveTo(dest); - if (options.Verbose) - Console.WriteLine($"Moved build directory to {buildDir.FullName}"); - } - - // Run any additional actions like creating the mac bundle - if (config.AdditionalAction != null) { - var result = config.AdditionalAction.Invoke(buildDir); - if (result != 0) - return result; - } - - // Zip the output if required - if (options.Zip) { - var zipLocation = Path.Combine(buildDir.Parent.FullName, $"{buildDir.Name}.zip"); - if (File.Exists(zipLocation)) - File.Delete(zipLocation); - ZipFile.CreateFromDirectory(buildDir.FullName, zipLocation, CompressionLevel.Optimal, true); - buildDir.Delete(true); - if (options.Verbose) - Console.WriteLine($"Zipped build to {zipLocation}"); - } - return 0; - } - - private static int RunProcess(Options options, string program, string args, string workingDir = "") { + var dest = Path.Combine(buildDir.Parent.FullName, $"{name}-{buildDir.Name}"); + if (Directory.Exists(dest)) + Directory.Delete(dest, true); + buildDir.MoveTo(dest); if (options.Verbose) - Console.WriteLine($"> {program} {args}"); - var info = new ProcessStartInfo(program, args) {WorkingDirectory = workingDir}; - if (!options.Verbose) - info.CreateNoWindow = true; - var process = Process.Start(info); - process.WaitForExit(); + Console.WriteLine($"Moved build directory to {buildDir.FullName}"); + } + + // Run any additional actions like creating the mac bundle + if (config.AdditionalAction != null) { + var result = config.AdditionalAction.Invoke(buildDir); + if (result != 0) + return result; + } + + // Zip the output if required + if (options.Zip) { + var zipLocation = Path.Combine(buildDir.Parent.FullName, $"{buildDir.Name}.zip"); + if (File.Exists(zipLocation)) + File.Delete(zipLocation); + ZipFile.CreateFromDirectory(buildDir.FullName, zipLocation, CompressionLevel.Optimal, true); + buildDir.Delete(true); if (options.Verbose) - Console.WriteLine($"{program} finished with exit code {process.ExitCode}"); - return process.ExitCode; + Console.WriteLine($"Zipped build to {zipLocation}"); + } + return 0; + } + + private static int RunProcess(Options options, string program, string args, string workingDir = "") { + if (options.Verbose) + Console.WriteLine($"> {program} {args}"); + var info = new ProcessStartInfo(program, args) {WorkingDirectory = workingDir}; + if (!options.Verbose) + info.CreateNoWindow = true; + var process = Process.Start(info); + process.WaitForExit(); + if (options.Verbose) + Console.WriteLine($"{program} finished with exit code {process.ExitCode}"); + return process.ExitCode; + } + + private static FileInfo GetProjectFile(Options options) { + if (!string.IsNullOrEmpty(options.SourceFile)) + return new FileInfo(options.SourceFile); + var dir = new DirectoryInfo("."); + foreach (var file in dir.EnumerateFiles()) { + if (Path.GetExtension(file.FullName).Contains("proj")) + return file; + } + return null; + } + + private static int CreateMacBundle(Options options, DirectoryInfo buildDir) { + var buildName = Program.GetBuildName(options, buildDir); + var app = buildDir.CreateSubdirectory($"{buildName}.app"); + var contents = app.CreateSubdirectory("Contents"); + var resources = contents.CreateSubdirectory("Resources"); + var macOs = contents.CreateSubdirectory("MacOS"); + var resRegex = options.MacBundleResources.Select(Program.GlobRegex).ToArray(); + var ignoreRegex = options.MacBundleIgnore.Select(Program.GlobRegex).ToArray(); + + if (options.Verbose) + Console.WriteLine($"Creating app bundle {app}"); + + foreach (var file in buildDir.GetFiles()) { + if (ignoreRegex.Any(r => r.IsMatch(file.Name))) + continue; + var destDir = resRegex.Any(r => r.IsMatch(file.Name)) ? resources : macOs; + if (file.Name.EndsWith("plist") || file.Name == "PkgInfo") + destDir = contents; + file.MoveTo(Path.Combine(destDir.FullName, file.Name), true); + } + foreach (var sub in buildDir.GetDirectories()) { + if (sub.Name == app.Name || ignoreRegex.Any(r => r.IsMatch(sub.Name))) + continue; + var destDir = resRegex.Any(r => r.IsMatch(sub.Name)) ? resources : macOs; + var dest = new DirectoryInfo(Path.Combine(destDir.FullName, sub.Name)); + if (dest.Exists) + dest.Delete(true); + sub.MoveTo(dest.FullName); } - private static FileInfo GetProjectFile(Options options) { - if (!string.IsNullOrEmpty(options.SourceFile)) - return new FileInfo(options.SourceFile); - var dir = new DirectoryInfo("."); - foreach (var file in dir.EnumerateFiles()) { - if (Path.GetExtension(file.FullName).Contains("proj")) - return file; - } - return null; - } - - private static int CreateMacBundle(Options options, DirectoryInfo buildDir) { - var buildName = GetBuildName(options, buildDir); - var app = buildDir.CreateSubdirectory($"{buildName}.app"); - var contents = app.CreateSubdirectory("Contents"); - var resources = contents.CreateSubdirectory("Resources"); - var macOs = contents.CreateSubdirectory("MacOS"); - var resRegex = options.MacBundleResources.Select(GlobRegex).ToArray(); - var ignoreRegex = options.MacBundleIgnore.Select(GlobRegex).ToArray(); - + var info = Path.Combine(contents.FullName, "PkgInfo"); + if (!File.Exists(info)) { + File.WriteAllText(info, "APPL????"); if (options.Verbose) - Console.WriteLine($"Creating app bundle {app}"); - - foreach (var file in buildDir.GetFiles()) { - if (ignoreRegex.Any(r => r.IsMatch(file.Name))) - continue; - var destDir = resRegex.Any(r => r.IsMatch(file.Name)) ? resources : macOs; - if (file.Name.EndsWith("plist") || file.Name == "PkgInfo") - destDir = contents; - file.MoveTo(Path.Combine(destDir.FullName, file.Name), true); - } - foreach (var sub in buildDir.GetDirectories()) { - if (sub.Name == app.Name || ignoreRegex.Any(r => r.IsMatch(sub.Name))) - continue; - var destDir = resRegex.Any(r => r.IsMatch(sub.Name)) ? resources : macOs; - var dest = new DirectoryInfo(Path.Combine(destDir.FullName, sub.Name)); - if (dest.Exists) - dest.Delete(true); - sub.MoveTo(dest.FullName); - } - - var info = Path.Combine(contents.FullName, "PkgInfo"); - if (!File.Exists(info)) { - File.WriteAllText(info, "APPL????"); - if (options.Verbose) - Console.WriteLine($"Creating package info at {info}"); - } - - return 0; + Console.WriteLine($"Creating package info at {info}"); } - private static Regex GlobRegex(string s) { - return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", ".")); + return 0; + } + + private static Regex GlobRegex(string s) { + return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", ".")); + } + + private static DirectoryInfo GetBuildDir(Options options, string name) { + if (options.NameAddition != null) + name = $"{options.NameAddition}-{name}"; + return new DirectoryInfo(Path.Combine(Path.GetFullPath(options.OutputDirectory), name)); + } + + private static string GetBuildName(Options options, DirectoryInfo buildDir) { + // determine build name based on the names of the exe or binary that have a matching dll file + var files = buildDir.GetFiles(); + foreach (var file in files) { + if (file.Extension != ".exe" && file.Extension != string.Empty) + continue; + var name = Path.GetFileNameWithoutExtension(file.Name); + if (files.Any(f => f.Extension == ".dll" && Path.GetFileNameWithoutExtension(f.Name) == name)) + return name; } + return null; + } - private static DirectoryInfo GetBuildDir(Options options, string name) { - if (options.NameAddition != null) - name = $"{options.NameAddition}-{name}"; - return new DirectoryInfo(Path.Combine(Path.GetFullPath(options.OutputDirectory), name)); - } + private readonly struct BuildConfig { - private static string GetBuildName(Options options, DirectoryInfo buildDir) { - // determine build name based on the names of the exe or binary that have a matching dll file - var files = buildDir.GetFiles(); - foreach (var file in files) { - if (file.Extension != ".exe" && file.Extension != string.Empty) - continue; - var name = Path.GetFileNameWithoutExtension(file.Name); - if (files.Any(f => f.Extension == ".dll" && Path.GetFileNameWithoutExtension(f.Name) == name)) - return name; - } - return null; - } - - private readonly struct BuildConfig { - - public readonly string DisplayName; - public readonly string DirectoryName; - public readonly string Rid; - public readonly bool ShouldBuild; - public readonly bool SkipLib; - public readonly Func AdditionalAction; - - public BuildConfig(string displayName, string directoryName, string rid, bool shouldBuild, bool skipLib = false, Func additionalAction = null) { - this.DisplayName = displayName; - this.DirectoryName = directoryName; - this.Rid = rid; - this.ShouldBuild = shouldBuild; - this.SkipLib = skipLib; - this.AdditionalAction = additionalAction; - } + public readonly string DisplayName; + public readonly string DirectoryName; + public readonly string Rid; + public readonly bool ShouldBuild; + public readonly bool SkipLib; + public readonly Func AdditionalAction; + public BuildConfig(string displayName, string directoryName, string rid, bool shouldBuild, bool skipLib = false, Func additionalAction = null) { + this.DisplayName = displayName; + this.DirectoryName = directoryName; + this.Rid = rid; + this.ShouldBuild = shouldBuild; + this.SkipLib = skipLib; + this.AdditionalAction = additionalAction; } } + } \ No newline at end of file diff --git a/Test/GameImpl.cs b/Test/GameImpl.cs index 09f102d..33a44ac 100644 --- a/Test/GameImpl.cs +++ b/Test/GameImpl.cs @@ -2,28 +2,28 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MLEM.Startup; -namespace Test { - public class GameImpl : MlemGame { +namespace Test; - public static GameImpl Instance { get; private set; } - private Texture2D texture; +public class GameImpl : MlemGame { - public GameImpl() { - Instance = this; - } - - protected override void LoadContent() { - base.LoadContent(); - this.texture = LoadContent("Textures/Test"); - } - - protected override void DoDraw(GameTime gameTime) { - this.GraphicsDevice.Clear(Color.Black); - base.DoDraw(gameTime); - this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(10)); - this.SpriteBatch.Draw(this.texture, Vector2.Zero, Color.White); - this.SpriteBatch.End(); - } + public static GameImpl Instance { get; private set; } + private Texture2D texture; + public GameImpl() { + GameImpl.Instance = this; } + + protected override void LoadContent() { + base.LoadContent(); + this.texture = MlemGame.LoadContent("Textures/Test"); + } + + protected override void DoDraw(GameTime gameTime) { + this.GraphicsDevice.Clear(Color.Black); + base.DoDraw(gameTime); + this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(10)); + this.SpriteBatch.Draw(this.texture, Vector2.Zero, Color.White); + this.SpriteBatch.End(); + } + } \ No newline at end of file diff --git a/Test/Program.cs b/Test/Program.cs index d9ed80f..fe44ba9 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -1,14 +1,14 @@ using Microsoft.Xna.Framework; using MLEM.Misc; -namespace Test { - public static class Program { +namespace Test; - public static void Main() { - TextInputWrapper.Current = new TextInputWrapper.DesktopGl((w, c) => w.TextInput += c); - using var game = new GameImpl(); - game.Run(); - } +public static class Program { + public static void Main() { + TextInputWrapper.Current = new TextInputWrapper.DesktopGl((w, c) => w.TextInput += c); + using var game = new GameImpl(); + game.Run(); } + } \ No newline at end of file diff --git a/Test/Test.csproj b/Test/Test.csproj index d4482b5..05870fb 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -1,5 +1,5 @@  - + Exe net6.0 @@ -7,17 +7,17 @@ false Test Project - + - + - + \ No newline at end of file