diff --git a/Horizon/App.xaml.cs b/Horizon/App.xaml.cs index 0d77916..e0503e4 100644 --- a/Horizon/App.xaml.cs +++ b/Horizon/App.xaml.cs @@ -1,5 +1,4 @@ -using Horizon.ObjectModel; -using Horizon.View.Windows; +using Horizon.View.Windows; using Horizon.ViewModel; using ReactiveUI; using ReactiveUI.Fody.Helpers; @@ -53,17 +52,37 @@ public static string UserDirectory ?.GetCustomAttribute() ?.InformationalVersion ?? "unknown-alpha"; - /// + /// [Reactive] - public static CommandsViewModel ViewModel { get; } = new CommandsViewModel(); + public static CommandsViewModel CommandsViewModel { get; } = new(); - public static List AvailableTemplates { get; set; } = [new() { Name = "Starbound Mod Project", Description = "A mod project for the game Starbound", Tags = ["Starbound", "Mod"] }]; + [Reactive] + public static AppViewModel ViewModel { get; } = new(); + + public static string AppDataDirectory + { + get + { + if (appDataDirectory is null) + { + appDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Horizon"); + if (!Directory.Exists(appDataDirectory)) + { + Directory.CreateDirectory(appDataDirectory); + } + } + + return appDataDirectory; + } + } /// /// The workspace. /// private static Workspace? workspace; + private static string? appDataDirectory; + /// /// Gets all the startup tasks that run while the splash screen is displayed. /// diff --git a/Horizon/View/Controls/MainMenu.xaml.cs b/Horizon/View/Controls/MainMenu.xaml.cs index 5f80baa..65e862a 100644 --- a/Horizon/View/Controls/MainMenu.xaml.cs +++ b/Horizon/View/Controls/MainMenu.xaml.cs @@ -24,7 +24,7 @@ public MainMenu() this.NewProjectMenuItem.Events() .Click .Select(x => new Unit()) - .InvokeCommand(App.ViewModel, x => x.NewProjectDialog) + .InvokeCommand(App.CommandsViewModel, x => x.NewProjectDialog) .DisposeWith(dispose); }); } diff --git a/Horizon/View/Windows/Workspace.xaml.cs b/Horizon/View/Windows/Workspace.xaml.cs index 3016901..225fa2b 100644 --- a/Horizon/View/Windows/Workspace.xaml.cs +++ b/Horizon/View/Windows/Workspace.xaml.cs @@ -28,7 +28,7 @@ public Workspace() /// The disposable. private void Interactions(CompositeDisposable dispose) { - App.ViewModel + App.CommandsViewModel .NewProjectDialogInteraction .RegisterHandler(interaction => { diff --git a/Horizon/ViewModel/NewProjectWindowViewModel.cs b/Horizon/ViewModel/NewProjectWindowViewModel.cs index 169e7fc..2678de7 100644 --- a/Horizon/ViewModel/NewProjectWindowViewModel.cs +++ b/Horizon/ViewModel/NewProjectWindowViewModel.cs @@ -4,6 +4,7 @@ using Nito.Disposables.Internals; using ReactiveUI; using ReactiveUI.Fody.Helpers; +using System.Collections.ObjectModel; using System.IO; using System.Reactive.Linq; @@ -68,5 +69,6 @@ public NewProjectWindowViewModel() [Reactive] public ProjectFile Project { get; set; } = new() { Name = "Project Name", FilePath = Path.Combine(App.UserDirectory, "Project.horizon") }; - public List AvailableTemplates { get; init; } = []; + [Reactive] + public ObservableCollection AvailableTemplates { get; init; } = []; } \ No newline at end of file