diff --git a/VTTiny/Editor/Native/FileDialog.cs b/VTTiny/Editor/Native/FileDialog.cs new file mode 100644 index 0000000..a40a98a --- /dev/null +++ b/VTTiny/Editor/Native/FileDialog.cs @@ -0,0 +1,38 @@ +namespace VTTiny.Editor.Native +{ + /// + /// This is the multiplatform wrapper for the open/save file dialog functionality. + /// It just calls back into the platform-specific implementations. + /// + /// NOTE: So far the only FileDialog implementation we have is for Win32. + /// PRs to improve that are welcome. + /// + public static class FileDialog + { + /// + /// Show an open file dialog. + /// + /// The path to the opened file, or nothing. + public static string OpenFile() + { +#if ARCH_WINDOWS + return Win32.FileDialog.OpenFile(); +#else + throw new System.NotImplementedException($"OpenFile() is not yet supported on {System.Runtime.InteropServices.RuntimeInformation.OSDescription}!"); +#endif + } + + /// + /// Show a save file dialog. + /// + /// The path to the saved file, or nothing. + public static string SaveFile() + { +#if ARCH_WINDOWS + return Win32.FileDialog.SaveFile(); +#else + throw new System.NotImplementedException($"SaveFile() is not yet supported on {System.Runtime.InteropServices.RuntimeInformation.OSDescription}!"); +#endif + } + } +} diff --git a/VTTiny/Editor/Native/Win32/FileDialog.cs b/VTTiny/Editor/Native/Win32/FileDialog.cs index 7a75196..f7ab1ca 100644 --- a/VTTiny/Editor/Native/Win32/FileDialog.cs +++ b/VTTiny/Editor/Native/Win32/FileDialog.cs @@ -4,11 +4,8 @@ namespace VTTiny.Editor.Native.Win32 { /// /// This class wraps the Win32 methods for opening open/save file dialog boxes. - /// - /// NOTE: So far this is the only FileDialog implementation we have, it'd be nice to have more cross platform solutions. - /// PRs welcome. /// - public static class FileDialog + internal static class FileDialog { private const string COMDLG_LIBRARY_NAME = "comdlg32"; diff --git a/VTTiny/Editor/UI/Menu/FileMenuCategory.cs b/VTTiny/Editor/UI/Menu/FileMenuCategory.cs index a6c27b4..56ae552 100644 --- a/VTTiny/Editor/UI/Menu/FileMenuCategory.cs +++ b/VTTiny/Editor/UI/Menu/FileMenuCategory.cs @@ -1,5 +1,5 @@ using System; -using VTTiny.Editor.Native.Win32; +using VTTiny.Editor.Native; using VTTiny.Scenery; namespace VTTiny.Editor.UI diff --git a/VTTiny/VTTiny.csproj b/VTTiny/VTTiny.csproj index 4f15e0e..2a845ab 100644 --- a/VTTiny/VTTiny.csproj +++ b/VTTiny/VTTiny.csproj @@ -5,6 +5,19 @@ net6.0 prefetcher + true + true + true + + + + ARCH_WINDOWS + + + ARCH_MACOS + + + ARCH_LINUX