diff --git a/src/DevilDaggersInfo.Web.ApiSpec.DdstatsRust/SupportedOperatingSystem.cs b/src/DevilDaggersInfo.Web.ApiSpec.DdstatsRust/SupportedOperatingSystem.cs index 0a83f4742..798190d0d 100644 --- a/src/DevilDaggersInfo.Web.ApiSpec.DdstatsRust/SupportedOperatingSystem.cs +++ b/src/DevilDaggersInfo.Web.ApiSpec.DdstatsRust/SupportedOperatingSystem.cs @@ -4,4 +4,5 @@ public enum SupportedOperatingSystem { Windows = 1, Linux = 2, + Osx = 3, } diff --git a/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxDialogService.cs b/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxDialogService.cs new file mode 100644 index 000000000..986b0a63b --- /dev/null +++ b/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxDialogService.cs @@ -0,0 +1,35 @@ +namespace DevilDaggersInfo.App.Core.NativeInterface.Services.Osx; + +public class OsxDialogService : INativeDialogService +{ + public void ReportError(string message, Exception? exception = null) + { + ReportError("Error", message, exception); + } + + public void ReportError(string title, string message, Exception? exception = null) + { + if (exception != null) + message += Environment.NewLine + exception.Message; + + Console.WriteLine($"{title}: {message}"); + } + + public void ReportMessage(string title, string message) + { + Console.WriteLine($"{title}{Environment.NewLine}{message}"); + } + + public bool? PromptYesNo(string title, string message) + { + Console.WriteLine($"{title}{Environment.NewLine}{message}"); + Console.WriteLine("Y/N"); + ConsoleKeyInfo key = Console.ReadKey(); + return key.Key switch + { + ConsoleKey.Y => true, + ConsoleKey.N => false, + _ => null, + }; + } +} diff --git a/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxFileSystemService.cs b/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxFileSystemService.cs new file mode 100644 index 000000000..0b53d4136 --- /dev/null +++ b/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxFileSystemService.cs @@ -0,0 +1,24 @@ +using NativeFileDialogSharp; + +namespace DevilDaggersInfo.App.Core.NativeInterface.Services.Osx; + +/// +/// Platform-specific code for interacting with the Linux file system. +/// +public class OsxFileSystemService : INativeFileSystemService +{ + public string? CreateOpenFileDialog(string dialogTitle, string? extensionFilter) + { + return Dialog.FileOpen().Path; + } + + public string? CreateSaveFileDialog(string dialogTitle, string? extensionFilter) + { + return Dialog.FileSave().Path; + } + + public string? SelectDirectory() + { + return Dialog.FolderPicker().Path; + } +} diff --git a/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxMemoryService.cs b/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxMemoryService.cs new file mode 100644 index 000000000..8c44853c6 --- /dev/null +++ b/src/app/DevilDaggersInfo.App.Core.NativeInterface/Services/Osx/OsxMemoryService.cs @@ -0,0 +1,21 @@ +using System.Diagnostics; + +namespace DevilDaggersInfo.App.Core.NativeInterface.Services.Osx; + +public class OsxMemoryService : INativeMemoryService +{ + public void WriteMemory(Process process, long address, byte[] bytes, int offset, int size) + { + // TODO: Implement. + } + + public void ReadMemory(Process process, long address, byte[] bytes, int offset, int size) + { + // TODO: Implement. + } + + public Process? GetDevilDaggersProcess() + { + return Array.Find(Process.GetProcesses(), p => p.ProcessName.StartsWith("devildaggers")); + } +} diff --git a/src/app/DevilDaggersInfo.App.Ui.Base/Platforms/OsxValues.cs b/src/app/DevilDaggersInfo.App.Ui.Base/Platforms/OsxValues.cs new file mode 100644 index 000000000..c4b13b7da --- /dev/null +++ b/src/app/DevilDaggersInfo.App.Ui.Base/Platforms/OsxValues.cs @@ -0,0 +1,13 @@ +using DevilDaggersInfo.Api.App.ProcessMemory; +using DevilDaggersInfo.Types.Web; + +namespace DevilDaggersInfo.App.Ui.Base.Platforms; + +public class OsxValues : IPlatformSpecificValues +{ + public ToolBuildType BuildType => ToolBuildType.OsxWarp; + + public SupportedOperatingSystem OperatingSystem => SupportedOperatingSystem.Osx; + + public string DefaultInstallationPath => string.Empty; +}