forked from Misaki/GhostEngine
Added a new static class `AssetsPath` for asset management. Added a new icon file (`icon-256.ico`) for UI representation. Added new package references to enhance functionality. Added internals visibility attributes for better testing. Added a new `EngineEditorViewModel` class for MVVM support. Added a new `GameObject` class for component management. Added a new `BitSet` class for efficient bit manipulation. Added various utility classes to support the new entity system. Changed the `ID` property in `ProjectInfo` to internal. Changed the `AddProjectAsync` method to return the created `ProjectInfo`. Changed the connection string retrieval method to use the new `Command` constant. Changed the `DataPath` class to use `readonly` fields for folder paths. Changed the `ActivationHandler` class to use new `DataPath` constants. Changed the `OpenProjectPage` layout and interaction for better UI. Updated the target framework to a newer version for compatibility. Updated the `ProjectService` to use new constants from `DataPath`. Updated the `World` class to improve entity management. Refactored the `ProjectRepository` class to encapsulate SQL commands. Refactored the `Transform` class to use properties for better encapsulation.
79 lines
2.1 KiB
C#
79 lines
2.1 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.Helpers;
|
|
using Ghost.Editor.View.Windows;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Windows.ApplicationModel;
|
|
|
|
namespace Ghost.Editor.ViewModel.Pages.Landing;
|
|
|
|
internal partial class CreateProjectViewModel(ProjectService projectService) : ObservableRecipient, 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)
|
|
{
|
|
await foreach (var (path, info) in projectService.GetProjectTemplatesAsync())
|
|
{
|
|
templates.Add(new(path, info));
|
|
}
|
|
|
|
SelectedTemplate = templates.FirstOrDefault();
|
|
}
|
|
|
|
public void OnNavigatedFrom()
|
|
{
|
|
}
|
|
|
|
[RelayCommand]
|
|
private async Task SelectionProjectLocation()
|
|
{
|
|
ProjectLocation = (await SystemUtilities.OpenFolderPickerAsync())?.Path ?? string.Empty;
|
|
}
|
|
|
|
[RelayCommand]
|
|
private async Task CreateProject()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(ProjectName) || !Directory.Exists(ProjectLocation) || SelectedTemplate == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var projectPath = await projectService.CreateProjectAsync(ProjectName, ProjectLocation, SelectedTemplate.directory);
|
|
|
|
var packageVersion = Package.Current.Id.Version;
|
|
var newProject = await projectService.AddProjectAsync(ProjectName, projectPath, new System.Version(packageVersion.Major, packageVersion.Minor, packageVersion.Build));
|
|
|
|
if (EngineEditorWindow.TryLoadProject(newProject))
|
|
{
|
|
App.GetService<LandingWindow>().Close();
|
|
}
|
|
}
|
|
} |