Refactor activation handling and introduce entity system
Added new `ActivationHandler` class for folder initialization. Added `ProjectService` class for project-related operations. Added `Ghost.Entities` project with entity management classes. Added `EngineEditorWindow` for enhanced user interface. Changed project files to restructure dependencies and remove unused references. Changed `ProjectRepository` to use asynchronous methods for improved performance. Changed data binding in `CreateProjectPage.xaml` and `OpenProjectPage.xaml` to use new data models. Changed `App.xaml.cs` to utilize the new `ActivationHandler` and include additional services. Removed `IActivationHandler` interface and integrated its functionality into `ActivationHandler`. Removed `EditorActivationHandler` as its functionality was merged into `ActivationHandler`. Updated `AssemblyInfo.cs` to include global using directives for entity types. Updated image assets to reflect visual resource changes.
26
Ghost.Editor/ActivationHandler.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Ghost.Data.Resources;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System.IO;
|
||||
|
||||
namespace Ghost.Editor;
|
||||
|
||||
internal static class ActivationHandler
|
||||
{
|
||||
private static void FolderInitialization()
|
||||
{
|
||||
if (!Directory.Exists(DataPath.ApplicationDataFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DataPath.ApplicationDataFolder);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(DataPath.ProjectTemplatesFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DataPath.ProjectTemplatesFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Handle(LaunchActivatedEventArgs args)
|
||||
{
|
||||
FolderInitialization();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Ghost.Editor.View.Pages;
|
||||
using Ghost.Data.Services;
|
||||
using Ghost.Editor.View.Pages;
|
||||
using Ghost.Editor.View.Windows;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
@@ -39,6 +41,8 @@ namespace Ghost.Editor
|
||||
UseContentRoot(AppContext.BaseDirectory).
|
||||
ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddTransient<ProjectService>();
|
||||
|
||||
HostHelper.SetupPageService(context, services);
|
||||
})
|
||||
.Build();
|
||||
@@ -67,7 +71,7 @@ namespace Ghost.Editor
|
||||
{
|
||||
base.OnLaunched(args);
|
||||
|
||||
EditorActivationHandler.Handle(args);
|
||||
ActivationHandler.Handle(args);
|
||||
|
||||
Host.Start();
|
||||
|
||||
|
||||
BIN
Ghost.Editor/Assets/Icon.targetsize-16_altform-lightunplated.png
Normal file
|
After Width: | Height: | Size: 599 B |
BIN
Ghost.Editor/Assets/Icon.targetsize-16_altform-unplated.png
Normal file
|
After Width: | Height: | Size: 580 B |
BIN
Ghost.Editor/Assets/Icon.targetsize-24_altform-lightunplated.png
Normal file
|
After Width: | Height: | Size: 831 B |
BIN
Ghost.Editor/Assets/Icon.targetsize-24_altform-unplated.png
Normal file
|
After Width: | Height: | Size: 825 B |
|
After Width: | Height: | Size: 5.9 KiB |
BIN
Ghost.Editor/Assets/Icon.targetsize-256_altform-unplated.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
Ghost.Editor/Assets/Icon.targetsize-32_altform-lightunplated.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Ghost.Editor/Assets/Icon.targetsize-32_altform-unplated.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Ghost.Editor/Assets/Icon.targetsize-48_altform-lightunplated.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Ghost.Editor/Assets/Icon.targetsize-48_altform-unplated.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
@@ -1,9 +0,0 @@
|
||||
using Ghost.Engine.Constants;
|
||||
using System.IO;
|
||||
|
||||
namespace Ghost.Editor.Constants;
|
||||
|
||||
public static class EditorDataPath
|
||||
{
|
||||
public static string ProjectTemplatesFolder = Path.Combine(EngineDataPath.ApplicationDataFolder, "ProjectsTemplates");
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using Ghost.Editor.Constants;
|
||||
using Ghost.Engine.Constants;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System.IO;
|
||||
|
||||
namespace Ghost.Editor;
|
||||
|
||||
internal static class EditorActivationHandler
|
||||
{
|
||||
private static void FolderInitialization()
|
||||
{
|
||||
if (!Directory.Exists(EngineDataPath.ApplicationDataFolder))
|
||||
{
|
||||
Directory.CreateDirectory(EngineDataPath.ApplicationDataFolder);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(EditorDataPath.ProjectTemplatesFolder))
|
||||
{
|
||||
Directory.CreateDirectory(EditorDataPath.ProjectTemplatesFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Handle(LaunchActivatedEventArgs args)
|
||||
{
|
||||
FolderInitialization();
|
||||
}
|
||||
}
|
||||
@@ -23,22 +23,28 @@
|
||||
<Content Remove="Assets\Icon.altform-unplated_targetsize-256.png" />
|
||||
<Content Remove="Assets\Icon.altform-unplated_targetsize-32.png" />
|
||||
<Content Remove="Assets\Icon.altform-unplated_targetsize-48.png" />
|
||||
<Content Remove="Assets\Icon.scale-100.png" />
|
||||
<Content Remove="Assets\Icon.scale-125.png" />
|
||||
<Content Remove="Assets\Icon.scale-150.png" />
|
||||
<Content Remove="Assets\Icon.scale-200.png" />
|
||||
<Content Remove="Assets\Icon.scale-400.png" />
|
||||
<Content Remove="Assets\Icon.targetsize-16.png" />
|
||||
<Content Remove="Assets\Icon.targetsize-24.png" />
|
||||
<Content Remove="Assets\Icon.targetsize-256.png" />
|
||||
<Content Remove="Assets\Icon.targetsize-32.png" />
|
||||
<Content Remove="Assets\Icon.targetsize-48.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\Icon.scale-100.png" />
|
||||
<None Remove="Assets\Icon.scale-125.png" />
|
||||
<None Remove="Assets\Icon.scale-150.png" />
|
||||
<None Remove="Assets\Icon.scale-200.png" />
|
||||
<None Remove="Assets\Icon.scale-400.png" />
|
||||
<None Remove="Assets\Icon.targetsize-16.png" />
|
||||
<None Remove="Assets\Icon.targetsize-16_altform-unplated.png" />
|
||||
<None Remove="Assets\Icon.targetsize-24.png" />
|
||||
<None Remove="Assets\Icon.targetsize-24_altform-lightunplated.png" />
|
||||
<None Remove="Assets\Icon.targetsize-256.png" />
|
||||
<None Remove="Assets\Icon.targetsize-256_altform-unplated.png" />
|
||||
<None Remove="Assets\Icon.targetsize-32.png" />
|
||||
<None Remove="Assets\Icon.targetsize-32_altform-lightunplated.png" />
|
||||
<None Remove="Assets\Icon.targetsize-48.png" />
|
||||
<None Remove="Assets\Icon.targetsize-48_altform-unplated.png" />
|
||||
<None Remove="Controls\BasicInput\PropertyField.xaml" />
|
||||
<None Remove="Controls\EditorControls.xaml" />
|
||||
<None Remove="View\Pages\Landing\CreateProjectPage.xaml" />
|
||||
<None Remove="View\Pages\Landing\OpenProjectPage.xaml" />
|
||||
<None Remove="View\Windows\EngineEditorWindow.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -64,12 +70,13 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250310001" />
|
||||
<PackageReference Include="WinUIEx" Version="2.5.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ghost.Database\Ghost.Database.csproj" />
|
||||
<ProjectReference Include="..\Ghost.Data\Ghost.Data.csproj" />
|
||||
<ProjectReference Include="..\Ghost.Engine\Ghost.Engine.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -88,9 +95,16 @@
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Resources\" />
|
||||
<Folder Include="Services\" />
|
||||
<Folder Include="ViewModel\Windows\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="View\Windows\EngineEditorWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Controls\BasicInput\PropertyField.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -120,5 +134,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<PublishAot>True</PublishAot>
|
||||
<PublishTrimmed>True</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,25 +0,0 @@
|
||||
using Ghost.Database.Models.Projects;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ghost.Editor.Models.Warpers;
|
||||
|
||||
internal class TemplateInfoWarper(string templatePath, TemplateInfo info)
|
||||
{
|
||||
private const string _ICON_NAME = "icon.png";
|
||||
private const string _PREVIEW_NAME = "preview.png";
|
||||
|
||||
public string directory = Path.GetDirectoryName(templatePath)!;
|
||||
|
||||
public TemplateInfo Info => info;
|
||||
|
||||
public Uri GetIconURI()
|
||||
{
|
||||
return new Uri(Path.Combine(directory, _ICON_NAME));
|
||||
}
|
||||
|
||||
public Uri GetPreviewURI()
|
||||
{
|
||||
return new Uri(Path.Combine(directory, _PREVIEW_NAME));
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,9 @@
|
||||
<uap:VisualElements
|
||||
DisplayName="GhostEngine"
|
||||
Description="GhostEngine"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Icon.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Icon.png" BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" >
|
||||
</uap:DefaultTile >
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Ghost.Editor.View.Pages.Landing;
|
||||
using Ghost.Editor.View.Windows;
|
||||
using Ghost.Editor.ViewModel.Pages.Landing;
|
||||
using Ghost.Editor.ViewModel.Windows;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
@@ -12,11 +11,12 @@ internal static partial class HostHelper
|
||||
public static void SetupPageService(HostBuilderContext context, IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<LandingWindow>();
|
||||
services.AddTransient<LandingViewModel>();
|
||||
|
||||
services.AddTransient<CreateProjectPage>();
|
||||
services.AddTransient<CreateProjectViewModel>();
|
||||
|
||||
services.AddTransient<OpenProjectPage>();
|
||||
|
||||
services.AddSingleton<EngineEditorWindow>();
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:data="using:Ghost.Data.Models"
|
||||
xmlns:editor="using:Ghost.Editor.Controls"
|
||||
xmlns:local="using:Ghost.Editor.View.Pages.Landing"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:warper="using:Ghost.Editor.Models.Warpers"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
@@ -34,7 +34,7 @@
|
||||
ItemsSource="{x:Bind ViewModel.templates}"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedTemplate, Mode=TwoWay}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="warper:TemplateInfoWarper">
|
||||
<DataTemplate x:DataType="data:TemplateData">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -46,7 +46,7 @@
|
||||
Width="24"
|
||||
Height="24">
|
||||
<ImageIcon.Source>
|
||||
<BitmapImage UriSource="{x:Bind GetIconURI()}" />
|
||||
<BitmapImage UriSource="{x:Bind GetIconURI(), Mode=OneWay}" />
|
||||
</ImageIcon.Source>
|
||||
</ImageIcon>
|
||||
<TextBlock
|
||||
@@ -66,7 +66,7 @@
|
||||
Margin="16,0,0,0"
|
||||
Padding="16"
|
||||
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
|
||||
CornerRadius="8">
|
||||
CornerRadius="{StaticResource OverlayCornerRadius}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="300" />
|
||||
<RowDefinition Height="*" />
|
||||
@@ -76,13 +76,19 @@
|
||||
<Grid Grid.Row="0" CornerRadius="4">
|
||||
<Image VerticalAlignment="Center" Stretch="UniformToFill">
|
||||
<Image.Source>
|
||||
<BitmapImage UriSource="{x:Bind ViewModel.SelectedTemplate.GetPreviewURI()}" />
|
||||
<BitmapImage UriSource="{x:Bind ViewModel.SelectedTemplate.GetPreviewURI(), Mode=OneWay}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{ThemeResource CircleElevationBorderBrush}" />
|
||||
Background="{ThemeResource CircleElevationBorderBrush}">
|
||||
<TextBlock
|
||||
Margin="16"
|
||||
VerticalAlignment="Bottom"
|
||||
Foreground="{ThemeResource TextOnAccentFillColorSecondaryBrush}"
|
||||
Text="{x:Bind ViewModel.SelectedTemplate.Info.Description, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="8,0">
|
||||
@@ -106,7 +112,10 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox Grid.Column="0" Text="{x:Bind ViewModel.ProjectLocation, Mode=TwoWay}" />
|
||||
<TextBox
|
||||
Grid.Column="0"
|
||||
IsReadOnly="True"
|
||||
Text="{x:Bind ViewModel.ProjectLocation, Mode=TwoWay}" />
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Margin="4,0,0,0"
|
||||
@@ -122,6 +131,7 @@
|
||||
<Button
|
||||
Width="150"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{x:Bind ViewModel.CreateProjectCommand}"
|
||||
Content="Create"
|
||||
Style="{ThemeResource AccentButtonStyle}" />
|
||||
</Grid>
|
||||
|
||||
@@ -4,25 +4,57 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:data="using:Ghost.Database.Models.Projects"
|
||||
xmlns:data="using:Ghost.Data.Models"
|
||||
xmlns:local="using:Ghost.Editor.View.Pages.Landing"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0" Margin="16,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Margin="12,0,0,0"
|
||||
Style="{StaticResource BodyStrongTextBlockStyle}"
|
||||
Text="Name" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource BodyStrongTextBlockStyle}"
|
||||
Text="Last Open" />
|
||||
<TextBlock
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource BodyStrongTextBlockStyle}"
|
||||
Text="Engine Version" />
|
||||
</Grid>
|
||||
|
||||
<ListView
|
||||
x:Name="ProjectListView"
|
||||
Grid.Row="1"
|
||||
Padding="16"
|
||||
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
|
||||
CornerRadius="{StaticResource OverlayCornerRadius}"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="ListView_ItemClick"
|
||||
ItemsSource="{x:Bind projects}"
|
||||
Visibility="Visible">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="data:ProjectInfo">
|
||||
<Grid>
|
||||
<Grid Padding="4,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Grid.Column="0">
|
||||
@@ -37,12 +69,28 @@
|
||||
Text="{x:Bind Name}" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind Path}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Column="1" Text="{x:Bind LastOpened}" />
|
||||
<TextBlock Grid.Column="2" Text="{x:Bind EngineVersion}" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="16,4"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Bind LastOpened}" />
|
||||
<TextBlock
|
||||
Grid.Column="2"
|
||||
Margin="16,4"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Bind EngineVersion}" />
|
||||
<Button
|
||||
Grid.Column="3"
|
||||
HorizontalAlignment="Right"
|
||||
Background="Transparent"
|
||||
BorderThickness="0">
|
||||
<FontIcon Glyph="" />
|
||||
</Button>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using Ghost.Database.DataContext;
|
||||
using Ghost.Database.Models.Projects;
|
||||
using Ghost.Data.Models;
|
||||
using Ghost.Data.Services;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
@@ -11,17 +12,24 @@ namespace Ghost.Editor.View.Pages.Landing;
|
||||
|
||||
internal sealed partial class OpenProjectPage : Page
|
||||
{
|
||||
private readonly ProjectService _projectService;
|
||||
|
||||
public readonly ObservableCollection<ProjectInfo> projects = new();
|
||||
|
||||
public OpenProjectPage()
|
||||
{
|
||||
foreach (var project in ProjectRepository.LoadProjects())
|
||||
_projectService = App.GetService<ProjectService>();
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
await foreach (var project in _projectService.LoadProjectAsync())
|
||||
{
|
||||
projects.Add(project);
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
if (projects.Count == 0)
|
||||
{
|
||||
PlaceHolderText.Visibility = Visibility.Visible;
|
||||
|
||||
14
Ghost.Editor/View/Windows/EngineEditorWindow.xaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<winex:WindowEx
|
||||
x:Class="Ghost.Editor.View.Windows.EngineEditorWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Ghost.Editor.View.Windows"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:winex="using:WinUIEx"
|
||||
Title="EngineEditorWindow"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid />
|
||||
</winex:WindowEx>
|
||||
16
Ghost.Editor/View/Windows/EngineEditorWindow.xaml.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using WinUIEx;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace Ghost.Editor.View.Windows;
|
||||
/// <summary>
|
||||
/// An empty window that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class EngineEditorWindow : WindowEx
|
||||
{
|
||||
public EngineEditorWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -15,32 +15,47 @@
|
||||
<MicaBackdrop />
|
||||
</Window.SystemBackdrop>
|
||||
|
||||
<Grid Padding="24,32,24,18">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="32" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<SelectorBar
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
SelectionChanged="SelectorBar_SelectionChanged">
|
||||
<SelectorBarItem IsSelected="True" Text="Open">
|
||||
<SelectorBarItem.Icon>
|
||||
<FontIcon Glyph="" />
|
||||
</SelectorBarItem.Icon>
|
||||
</SelectorBarItem>
|
||||
<SelectorBarItem Text="Create">
|
||||
<SelectorBarItem.Icon>
|
||||
<FontIcon Glyph="" />
|
||||
</SelectorBarItem.Icon>
|
||||
</SelectorBarItem>
|
||||
</SelectorBar>
|
||||
<Grid Grid.Row="0">
|
||||
<TextBlock
|
||||
Margin="24,0,0,0"
|
||||
VerticalAlignment="Bottom"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Text="Ghost Engine" />
|
||||
</Grid>
|
||||
|
||||
<Frame
|
||||
x:Name="ContentFrame"
|
||||
Grid.Row="1"
|
||||
Padding="8"
|
||||
IsNavigationStackEnabled="False" />
|
||||
<Grid Grid.Row="1" Padding="24,0,24,18">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<SelectorBar
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
SelectionChanged="SelectorBar_SelectionChanged">
|
||||
<SelectorBarItem IsSelected="True" Text="Open">
|
||||
<SelectorBarItem.Icon>
|
||||
<FontIcon Glyph="" />
|
||||
</SelectorBarItem.Icon>
|
||||
</SelectorBarItem>
|
||||
<SelectorBarItem Text="Create">
|
||||
<SelectorBarItem.Icon>
|
||||
<FontIcon Glyph="" />
|
||||
</SelectorBarItem.Icon>
|
||||
</SelectorBarItem>
|
||||
</SelectorBar>
|
||||
|
||||
<Frame
|
||||
x:Name="ContentFrame"
|
||||
Grid.Row="1"
|
||||
Padding="8"
|
||||
IsNavigationStackEnabled="False" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</winex:WindowEx>
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Ghost.Database.Models.Projects;
|
||||
using Ghost.Editor.Constants;
|
||||
using Ghost.Data.Models;
|
||||
using Ghost.Data.Services;
|
||||
using Ghost.Editor.Contracts;
|
||||
using Ghost.Editor.Helpers;
|
||||
using Ghost.Editor.Models.Warpers;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
namespace Ghost.Editor.ViewModel.Pages.Landing;
|
||||
|
||||
internal partial class CreateProjectViewModel : ObservableRecipient, INavigationAware
|
||||
internal partial class CreateProjectViewModel(ProjectService projectService) : ObservableRecipient, INavigationAware
|
||||
{
|
||||
public ObservableCollection<TemplateInfoWarper> templates = new();
|
||||
public ObservableCollection<TemplateData> templates = new();
|
||||
|
||||
[ObservableProperty]
|
||||
public partial TemplateInfoWarper? SelectedTemplate
|
||||
public partial TemplateData? SelectedTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -39,23 +37,14 @@ internal partial class CreateProjectViewModel : ObservableRecipient, INavigation
|
||||
set;
|
||||
}
|
||||
|
||||
public void OnNavigatedTo(object? parameter)
|
||||
public async void OnNavigatedTo(object? parameter)
|
||||
{
|
||||
DispatcherQueue.GetForCurrentThread().TryEnqueue(DispatcherQueuePriority.High, () =>
|
||||
await foreach (var (path, info) in projectService.GetProjectTemplatesAsync())
|
||||
{
|
||||
foreach (var templatePath in Directory.GetFiles(EditorDataPath.ProjectTemplatesFolder, "template.json", SearchOption.AllDirectories))
|
||||
{
|
||||
var templateInfo = JsonSerializer.Deserialize<TemplateInfo>(File.ReadAllText(templatePath));
|
||||
if (templateInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
templates.Add(new(path, info));
|
||||
}
|
||||
|
||||
templates.Add(new(templatePath, templateInfo));
|
||||
}
|
||||
|
||||
SelectedTemplate = templates.FirstOrDefault();
|
||||
});
|
||||
SelectedTemplate = templates.FirstOrDefault();
|
||||
}
|
||||
|
||||
public void OnNavigatedFrom()
|
||||
@@ -67,4 +56,18 @@ internal partial class CreateProjectViewModel : ObservableRecipient, INavigation
|
||||
{
|
||||
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;
|
||||
await projectService.AddProjectAsync(ProjectName, projectPath, new System.Version(packageVersion.Major, packageVersion.Minor, packageVersion.Build));
|
||||
}
|
||||
}
|
||||