Changed the project structure to reflect a shift from `Ghost.App` to `Ghost.Editor`, updating namespaces and class names throughout. Changed the application class in `App.xaml` and `App.xaml.cs` from `GhostApplication` to `EditorApplication`. Changed several service interfaces to reside under `Ghost.Editor.Services.Contracts`, including `IInspectorService`, `INotificationService`, and `IProgressService`. Added `InspectorView` and `InspectorViewModel` classes to manage inspector functionality. Added `NavigationTabView` and `NavigationTabPage` classes to facilitate navigation within the editor. Enhanced `WorldNode` and `EntityNode` classes to support scene graph functionality, including serialization and entity management. Updated the project file `Ghost.Editor.csproj` to reflect the new structure and removed old references. Modified the solution file `GhostEngine.sln` to remove references to `Ghost.App` and include `Ghost.Editor`. Updated unit tests to align with the new namespaces and project structure.
95 lines
2.5 KiB
C#
95 lines
2.5 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Ghost.Data.Models;
|
|
using Ghost.Data.Services;
|
|
using Ghost.Editor.Contracts;
|
|
using Ghost.Editor.Core.AppState;
|
|
using Ghost.Editor.Models;
|
|
using Ghost.Editor.Services;
|
|
using Ghost.Editor.Utilities;
|
|
using Ghost.Engine.Resources;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ghost.Editor.ViewModels.Pages.Landing;
|
|
|
|
internal partial class CreateProjectViewModel(NotificationService notificationService, ProjectService projectService, AppStateMachine stateService) : ObservableObject, INavigationAware
|
|
{
|
|
public ObservableCollection<TemplateData> templates = new();
|
|
|
|
[ObservableProperty]
|
|
public partial TemplateData? SelectedTemplate
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public partial string? ProjectName
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public partial string? ProjectLocation
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public async void OnNavigatedTo(object? parameter)
|
|
{
|
|
templates.Clear();
|
|
await foreach (var (path, info) in ProjectService.GetProjectTemplatesAsync())
|
|
{
|
|
templates.Add(new(path, info));
|
|
}
|
|
|
|
SelectedTemplate = templates.FirstOrDefault();
|
|
}
|
|
|
|
public void OnNavigatedFrom()
|
|
{
|
|
}
|
|
|
|
[RelayCommand]
|
|
private async Task SelectionProjectLocation()
|
|
{
|
|
var folder = await SystemUtilities.OpenFolderPickerAsync();
|
|
if (folder != null)
|
|
{
|
|
ProjectLocation = folder.Path;
|
|
}
|
|
}
|
|
|
|
[RelayCommand]
|
|
private async Task CreateProject()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(ProjectName)
|
|
|| !Directory.Exists(ProjectLocation)
|
|
|| !SelectedTemplate.HasValue)
|
|
{
|
|
notificationService.ShowNotification("Incorrect project info", MessageType.Error);
|
|
return;
|
|
}
|
|
|
|
var result = await projectService.CreateProjectAsync(ProjectName, ProjectLocation, EngineData.s_engineVersion, SelectedTemplate.Value.directory);
|
|
if (!result.success)
|
|
{
|
|
notificationService.ShowNotification(result.message, MessageType.Error);
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
await stateService.TransitionToAsync(StateKey.EngineEditor, result.data);
|
|
}
|
|
catch (System.Exception e)
|
|
{
|
|
notificationService.ShowNotification($"Failed to load project: {e.Message}", MessageType.Error);
|
|
}
|
|
}
|
|
} |