Skip to content

Commit

Permalink
refactor: cleanup unused code from template
Browse files Browse the repository at this point in the history
  • Loading branch information
abdes committed Nov 8, 2024
1 parent 6d007c5 commit 980fac7
Show file tree
Hide file tree
Showing 24 changed files with 37 additions and 687 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public ContentBrowserViewModel(IContainer container, ILoggerFactory? loggerFacto
// Register all local ViewModels and services in the child container
childContainer.RegisterInstance<IViewLocator>(viewLocator);
childContainer.RegisterInstance(new ViewModelToView(viewLocator));
childContainer.Register<ProjectLayoutViewModel>();
childContainer.Register<ProjectLayoutView>();
childContainer.Register<AssetsViewModel>();
childContainer.Register<AssetsView>();
childContainer.Register<TilesLayoutViewModel>();
childContainer.Register<Oxygen.Editor.WorldEditor.ContentBrowser.TilesLayoutView>();
childContainer.Register<ProjectLayoutViewModel>(Reuse.Singleton);
childContainer.Register<ProjectLayoutView>(Reuse.Singleton);
childContainer.Register<AssetsViewModel>(Reuse.Singleton);
childContainer.Register<AssetsView>(Reuse.Singleton);
childContainer.Register<TilesLayoutViewModel>(Reuse.Singleton);
childContainer.Register<TilesLayoutView>(Reuse.Singleton);

var context = new LocalRouterContext() { RootViewModel = this };
var routerContextProvider = new RouterContextProvider(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public partial class WorkspaceViewModel : ObservableObject
[ObservableProperty]
private UIElement? workspaceContent;

// TODO Move the DockViewFactory in the World Editor to the Oxygen.Editor project
/* container.Register<DockViewFactory>(Reuse.Singleton); */

public WorkspaceViewModel(IResolver resolver)
{
var dockViewFactory = new DockViewFactory(resolver);
Expand Down
27 changes: 3 additions & 24 deletions projects/Oxygen.Editor/src/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public App(
this.InitializeComponent();
}

public static UIElement? AppTitlebar { get; set; }

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
base.OnLaunched(args);
Expand All @@ -61,9 +59,6 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
// We just want to exit if navigation fails for some reason
this.router.Events.OfType<NavigationError>().Subscribe(_ => this.lifetime.StopApplication());

Ioc.Default.GetRequiredService<IAppNotificationService>()
.Initialize();

_ = Ioc.Default.GetRequiredService<IActivationService>()
.Where(data => data is LaunchActivatedEventArgs)
.Select(data => data as LaunchActivatedEventArgs)
Expand Down Expand Up @@ -102,12 +97,12 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
}

private static void OnAppUnhandledException(object sender, UnhandledExceptionEventArgs e)
=> OnUnhandledException(e.Exception, shouldShowNotification: true);
=> OnUnhandledException(e.Exception);

private static void OnCurrentDomainUnhandledException(object sender, System.UnhandledExceptionEventArgs e)
=> OnUnhandledException((Exception)e.ExceptionObject, shouldShowNotification: true);
=> OnUnhandledException((Exception)e.ExceptionObject);

private static void OnUnhandledException(Exception ex, bool shouldShowNotification)
private static void OnUnhandledException(Exception ex)
{
/*
* TODO: Log and handle exceptions as appropriate.
Expand All @@ -126,22 +121,6 @@ private static void OnUnhandledException(Exception ex, bool shouldShowNotificati
""";
Debug.WriteLine(message);

if (shouldShowNotification)
{
_ = Ioc.Default.GetService<IAppNotificationService>()
?.Show(
$"""
<toast>
<visual>
<binding template="ToastGeneric">
<text>Unhandled Exception</text>
<text>{ex.Message}</text>
</binding>
</visual>
</toast>
""");
}

Process.GetCurrentProcess()
.Kill();
}
Expand Down
35 changes: 0 additions & 35 deletions projects/Oxygen.Editor/src/Helpers/EnumToBooleanConverter.cs

This file was deleted.

14 changes: 0 additions & 14 deletions projects/Oxygen.Editor/src/Helpers/FrameExtensions.cs

This file was deleted.

28 changes: 0 additions & 28 deletions projects/Oxygen.Editor/src/Helpers/RuntimeHelper.cs

This file was deleted.

88 changes: 0 additions & 88 deletions projects/Oxygen.Editor/src/Helpers/SettingsStorageExtensions.cs

This file was deleted.

36 changes: 18 additions & 18 deletions projects/Oxygen.Editor/src/HostingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ public static void ConfigureApplicationServices(this IContainer container)
container.Register<IFileSystem, RealFileSystem>(Reuse.Singleton);
container.Register<NativeStorageProvider>(Reuse.Singleton);
container.Register<IPathFinder, DevelopmentPathFinder>(Reuse.Singleton); // TODO: release version
container.Register<IThemeSelectorService, ThemeSelectorService>(Reuse.Singleton);
container.Register<IAppNotificationService, AppNotificationService>(Reuse.Singleton);
container.Register<IActivationService, ActivationService>(Reuse.Singleton);

/*
Expand Down Expand Up @@ -122,6 +120,24 @@ public static void ConfigureApplicationServices(this IContainer container)
container.Register<Window, MainWindow>(Reuse.Singleton, serviceKey: Target.Main);

// Views and ViewModels
RegisterViewsAndViewModels(container);
}

private static void CreateLogger(IContainer container)
=> Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Error)
.Enrich.FromLogContext()
.WriteTo.Debug(
new ExpressionTemplate(
"[{@t:HH:mm:ss} {@l:u3} ({Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1)})] {@m:lj}\n{@x}",
new CultureInfo("en-US")))
/* .WriteTo.Seq("http://localhost:5341/") */
.WriteTo.OutputLogView<RichTextBlockSink>(container, theme: Themes.Literate)
.CreateLogger();

private static void RegisterViewsAndViewModels(IContainer container)
{
container.Register<ShellViewModel>(Reuse.Singleton);
container.Register<ShellView>(Reuse.Singleton);

Expand All @@ -134,9 +150,6 @@ public static void ConfigureApplicationServices(this IContainer container)
container.Register<OpenProjectViewModel>(Reuse.Transient);
container.Register<OpenProjectView>(Reuse.Transient);

// TODO Move the DockViewFactory in the World Editor to the Oxygen.Editor project
// container.Register<DockViewFactory>(Reuse.Singleton);

container.Register<WorkspaceViewModel>(Reuse.Transient);
container.Register<WorkspaceView>(Reuse.Transient);
container.Register<SceneDetailsView>(Reuse.Transient);
Expand All @@ -150,17 +163,4 @@ public static void ConfigureApplicationServices(this IContainer container)
container.Register<ContentBrowserView>(Reuse.Transient);
container.Register<ContentBrowserViewModel>(Reuse.Transient);
}

private static void CreateLogger(IContainer container)
=> Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Error)
.Enrich.FromLogContext()
.WriteTo.Debug(
new ExpressionTemplate(
"[{@t:HH:mm:ss} {@l:u3} ({Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1)})] {@m:lj}\n{@x}",
new CultureInfo("en-US")))
/* .WriteTo.Seq("http://localhost:5341/") */
.WriteTo.OutputLogView<RichTextBlockSink>(container, theme: Themes.Literate)
.CreateLogger();
}
2 changes: 1 addition & 1 deletion projects/Oxygen.Editor/src/Oxygen.Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<EnableMsixTooling>true</EnableMsixTooling>
<PublishReadyToRun>true</PublishReadyToRun>
<WindowsAppSDKBootstrapAutoInitializeOptions_OnNoMatch_ShowUI>true</WindowsAppSDKBootstrapAutoInitializeOptions_OnNoMatch_ShowUI>
<WindowsPackageType>None</WindowsPackageType>
<WindowsPackageType>MSIX</WindowsPackageType>

<!-- For the debug symbols package -->
<DebugType>portable</DebugType>
Expand Down
4 changes: 2 additions & 2 deletions projects/Oxygen.Editor/src/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
Expand Down Expand Up @@ -37,7 +37,7 @@
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="ms-resource:AppDisplayName"
DisplayName="Oxygen Editor"
Description="ms-resource:AppDescription"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Expand Down
Loading

0 comments on commit 980fac7

Please sign in to comment.