forked from Misaki/GhostEngine
Update editor
This commit is contained in:
@@ -1,30 +1,67 @@
|
||||
using Ghost.Data.Resources;
|
||||
using Ghost.Data.Services;
|
||||
using Ghost.Editor.Core;
|
||||
using Ghost.Editor.Core.Utilities;
|
||||
using Ghost.Editor.Models;
|
||||
using Ghost.Engine;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ghost.Editor;
|
||||
|
||||
internal static class ActivationHandler
|
||||
{
|
||||
private static void FolderInitialization()
|
||||
public static LaunchArguments ParseArguments(ReadOnlySpan<char> args)
|
||||
{
|
||||
if (!Directory.Exists(DataPath.s_applicationDataFolder))
|
||||
var arguments = new LaunchArguments();
|
||||
var properties = typeof(LaunchArguments).GetProperties();
|
||||
var split = args.Split(' ');
|
||||
|
||||
while (split.MoveNext())
|
||||
{
|
||||
Directory.CreateDirectory(DataPath.s_applicationDataFolder);
|
||||
var range = split.Current;
|
||||
var arg = args[range.Start..range.End];
|
||||
if (arg.Length > 2)
|
||||
{
|
||||
if (arg[0] == '-' && arg[1] == '-')
|
||||
{
|
||||
var argName = arg[2..];
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var propName = property.Name;
|
||||
var attr = property.GetCustomAttributes<ArgumentNameAttribute>(false).FirstOrDefault();
|
||||
if (attr != null)
|
||||
{
|
||||
propName = attr.Name;
|
||||
}
|
||||
|
||||
if (argName.Equals(propName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (split.MoveNext())
|
||||
{
|
||||
var valueRange = split.Current;
|
||||
var value = args[valueRange.Start..valueRange.End];
|
||||
var convertedValue = Convert.ChangeType(value.ToString(), property.PropertyType);
|
||||
|
||||
property.SetValue(arguments, convertedValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Directory.Exists(DataPath.s_projectTemplateFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DataPath.s_projectTemplateFolder);
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public static void Handle(LaunchActivatedEventArgs args)
|
||||
public static async Task HandleAsync(LaunchArguments args)
|
||||
{
|
||||
FolderInitialization();
|
||||
ProjectService.EnsureDefaultTemplate();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
TypeCache.Init();
|
||||
((EngineCore)App.GetService<IEngineContext>()).Init();
|
||||
});
|
||||
|
||||
EditorApplication.Initialize(((App)(Application.Current)).Host.Services);
|
||||
// TODO: Initialize other subsystems here.
|
||||
// await Task.Delay(10000); // Wait 10 seconds to simulate work.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user