Added: - New `ProgressService` class for managing progress indicators. - New `AssetDatabase`, `AssetOpenHandlerAttribute`, and `AsyncAssetOpenHandlerAttribute` classes for asset handling. - `Ghost.UnitTest` project for unit testing with associated files and configurations. Changed: - `ActivationHandler` class to ensure correct handling of `LaunchActivatedEventArgs`. - `App.xaml.cs` to register `INotificationService` and `IProgressService`, replacing `StackedNotificationService`. - `OnLaunched` method in `App.xaml.cs` to correctly call `ActivationHandler.Handle(args)` and start the host. - `INavigationAware` interface from internal to public for broader access. - `EditorState.cs` to activate `EditorApplication` with the current service provider. - Property names in `AssetItem` and `ExplorerItem` structs to `Name` and `FullName`. - `NotificationService` class to implement `INotificationService` and refactor notification handling. - `AssetPathToGlyphConverter` to handle file extensions consistently. - Bindings in `ProjectPage.xaml` and `ProjectPage.xaml.cs` to use `FullName` instead of `Path`. - `EngineEditorWindow` and `LandingWindow` classes to utilize new notification and progress services. - `Logger` class to include a new method for logging errors with exceptions. Updated: - Manifest files and project files to reflect new structure and dependencies. - Solution file `GhostEngine.sln` to include the new unit test project. - Added several new test classes and methods in `UnitTests.cs`.
93 lines
1.9 KiB
C#
93 lines
1.9 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Ghost.Engine.Models;
|
|
using Ghost.Engine.Services;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace Ghost.Editor.ViewModels.Pages.EngineEditor;
|
|
|
|
internal partial class ConsoleViewModel : ObservableObject
|
|
{
|
|
[ObservableProperty]
|
|
public partial ObservableCollection<LogMessage> Logs
|
|
{
|
|
get; set;
|
|
} = new();
|
|
|
|
[ObservableProperty]
|
|
public partial bool ShowInfo
|
|
{
|
|
get; set;
|
|
} = true;
|
|
|
|
[ObservableProperty]
|
|
public partial bool ShowWarning
|
|
{
|
|
get; set;
|
|
} = true;
|
|
|
|
[ObservableProperty]
|
|
public partial bool ShowError
|
|
{
|
|
get; set;
|
|
} = true;
|
|
|
|
[ObservableProperty]
|
|
public partial bool ShowStackTrace
|
|
{
|
|
get; set;
|
|
} = false;
|
|
|
|
[ObservableProperty]
|
|
public partial LogMessage? SelectedLog
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public ConsoleViewModel()
|
|
{
|
|
foreach (var log in Logger.Logs)
|
|
{
|
|
Logs.Add(log);
|
|
}
|
|
|
|
Logger.OnLogsUpdate += UpdateLogs;
|
|
}
|
|
|
|
~ConsoleViewModel()
|
|
{
|
|
Logger.OnLogsUpdate -= UpdateLogs;
|
|
}
|
|
|
|
private void UpdateLogs(LogChangeType updateType)
|
|
{
|
|
switch (updateType)
|
|
{
|
|
case LogChangeType.LogAdded:
|
|
Logs.Add(Logger.Logs[^1]);
|
|
break;
|
|
case LogChangeType.LogRemoved:
|
|
if (Logs.Count > 0)
|
|
{
|
|
Logs.RemoveAt(0);
|
|
}
|
|
break;
|
|
case LogChangeType.LogsCleared:
|
|
Logs.Clear();
|
|
break;
|
|
}
|
|
}
|
|
|
|
partial void OnShowStackTraceChanged(bool value)
|
|
{
|
|
Logger.HasStackTrace = value;
|
|
Logger.LogInfo($"Stack trace visibility set to {value}.");
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void ClearLogs()
|
|
{
|
|
Logger.Clear();
|
|
}
|
|
}
|