Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.4.2 alpha #15

Merged
merged 32 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
64aa599
Updated application version. Updated packages for Horizon.Testing to …
TheHeadmaster Jul 26, 2024
9c8be93
Added ReactiveUI and ReactiveUI.WPF packages. Added view/viewmodel au…
TheHeadmaster Jul 26, 2024
df96b1c
Suppressed NU1701.
TheHeadmaster Jul 26, 2024
a1403a7
Upgraded System.Text.Json to latest version to fix vulnerability.
TheHeadmaster Jul 26, 2024
0236743
Added numerous packages that will be used for the application stack.
TheHeadmaster Jul 26, 2024
60abe09
Added Resources folder. Implemented logging. Removed revision hash fr…
TheHeadmaster Jul 26, 2024
60dacb3
Added Resources folder. Implemented logging. Removed revision hash fr…
TheHeadmaster Jul 26, 2024
7fc97a0
Merge branch '0.4.2-alpha' of https://github.com/TheHeadmaster/Horizo…
TheHeadmaster Jul 26, 2024
e3372fb
Added documentation comments. Subscribed to closing events for cleanu…
TheHeadmaster Jul 26, 2024
353528c
Renamed MainWindow to Workspace. Added LoadingSplash and startup task…
TheHeadmaster Jul 26, 2024
d06dbbe
Added "Closing" log on exit.
TheHeadmaster Jul 26, 2024
e074a67
Changed filename template and extension of logs.
TheHeadmaster Jul 26, 2024
5c8833f
Completed LoadingSplash visuals. Added Splash.png.
TheHeadmaster Jul 26, 2024
7ad0dfe
Made SetDebugFlag static.
TheHeadmaster Jul 27, 2024
e926b57
Added MainMenu control. Added MainMenu to Workspace. Added ViewModel …
TheHeadmaster Jul 27, 2024
8e12b23
Turned on "Allow Unsafe Blocks". Added KeyConstants (will be used lat…
TheHeadmaster Jul 27, 2024
49bc9d5
Added WindowButtonDefinition.
TheHeadmaster Jul 27, 2024
f083e5d
Added DialogDefinition.
TheHeadmaster Jul 27, 2024
52c1df5
Added AvalonDockDefinition and AvalonDock themes.
TheHeadmaster Jul 27, 2024
c0d97db
Added ScrollViewerDefinition.
TheHeadmaster Jul 27, 2024
bfbb0d8
Added MenuScrollViewerDefinition.
TheHeadmaster Jul 27, 2024
ed8682f
Added Menu, Submenu, Toolbar, and Header definitions.
TheHeadmaster Jul 27, 2024
a7c1ca7
Added Horizon.png. Added Key, Key Space, Key Medium, and Key Windows …
TheHeadmaster Jul 27, 2024
5e11afd
Redesigned DialogDefinition to be like WindowDefinition. Replaced har…
TheHeadmaster Jul 27, 2024
9d8436c
Changed Workspace to be maximized by default.
TheHeadmaster Jul 27, 2024
bd8dc68
Created JsonFile, UniqueJsonFile, and ProjectFile.
TheHeadmaster Jul 28, 2024
3f25926
Added UserDirectory method to App class.
TheHeadmaster Jul 28, 2024
e533380
Suppressed CS0436 warnings in project file. Added Newtonsoft.Json pac…
TheHeadmaster Jul 28, 2024
413d467
Added CommandsViewModel, which will hold the common commands between …
TheHeadmaster Jul 28, 2024
244ada4
Added NewProjectWindow and NewProjectWindowViewModel. Hooked up NewPr…
TheHeadmaster Jul 28, 2024
e651c27
Added documentation comment to CreateNewProject.
TheHeadmaster Jul 28, 2024
4ae5f9b
Added validator to help with common validation functions. Added NewPr…
TheHeadmaster Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Horizon.Installer/Package.wxs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="Horizon" Compressed="yes" Scope="perMachine" Manufacturer="The Headmaster" Version="0.4.1" UpgradeCode="f629909a-bc3c-4e54-a352-c3fcd75c44f6">
<Package Name="Horizon" Compressed="yes" Scope="perMachine" Manufacturer="The Headmaster" Version="0.4.2" UpgradeCode="f629909a-bc3c-4e54-a352-c3fcd75c44f6">
<?define Horizon_TargetDir=$(var.Horizon.TargetDir)?>
<MediaTemplate EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
Expand Down
18 changes: 12 additions & 6 deletions Horizon.Testing/Horizon.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
Expand All @@ -10,11 +10,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 10 additions & 5 deletions Horizon/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<Application x:Class="Horizon.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Horizon"
StartupUri="MainWindow.xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/UI/Brushes.xaml" />
<ResourceDictionary Source="Resources/UI/Controls.xaml" />
<ResourceDictionary Source="Resources/UI/Animations.xaml" />
<ResourceDictionary Source="Resources/UI/Converters.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
</Application>
192 changes: 189 additions & 3 deletions Horizon/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,198 @@
using System.Configuration;
using System.Data;
using Horizon.ObjectModel;
using Horizon.View.Windows;
using Horizon.ViewModel;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Serilog;
using Serilog.Formatting.Compact;
using Splat;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Threading;

namespace Horizon;

/// <summary>
/// Interaction logic for App.xaml
/// Handles application startup and metadata.
/// </summary>
public partial class App : Application
{
/// <summary>
/// Gets whether this application is running in debug mode or not.
/// </summary>
public static bool IsDebug { get; private set; }

private static string? userDirectory;

/// <summary>
/// Gets the User directory for this application.
/// </summary>
public static string UserDirectory
{
get
{
if (userDirectory is null)
{
userDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Horizon");

if (!Directory.Exists(userDirectory))
{
Directory.CreateDirectory(userDirectory);
}
}

return userDirectory;
}
}

/// <summary>
/// Gets the version of the application as a string.
/// </summary>
public static string Version { get; private set; } = Assembly.GetExecutingAssembly()
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? "unknown-alpha";

/// <inheritdoc cref="CommandsViewModel" />
[Reactive]
public static CommandsViewModel ViewModel { get; } = new CommandsViewModel();

public static List<ProjectTemplate> AvailableTemplates { get; set; } = [new() { Name = "Starbound Mod Project", Description = "A mod project for the game Starbound", Tags = ["Starbound", "Mod"] }];

/// <summary>
/// The workspace.
/// </summary>
private static Workspace? workspace;

/// <summary>
/// Gets all the startup tasks that run while the splash screen is displayed.
/// </summary>
/// <returns></returns>
private Queue<(string label, Action action)> GetStartupTasks()
{
Queue<(string label, Action action)> tasks = new();

tasks.Enqueue(("Initializing...", this.InitializeApplication));

tasks.Enqueue(("Opening...", () => Current.Dispatcher.Invoke(() =>
{
workspace = new();
Current.MainWindow = workspace;
})));

return tasks;
}

/// <inheritdoc />
protected override async void OnStartup(StartupEventArgs args)
{
SetDebugFlag();
this.InitializeLogging();
base.OnStartup(args);

Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());

LoadingSplash splash = new();

splash.Show();

if (splash.ViewModel is not null)
{
await splash.ViewModel.StartRunningInBackground(this.GetStartupTasks());
}

splash.Close();

Log.Information("Initialization complete.");

workspace!.Show();
}

/// <summary>
/// Initializes the application in the background.
/// </summary>
private void InitializeApplication()
{
// TODO: Place any other startup tasks here, such as loading the most recent project, checking for updates, etc.
}

/// <summary>
/// Initializes logging and emits welcome messages.
/// </summary>
private void InitializeLogging()
{
LoggerConfiguration config = new();

if (IsDebug)
{
config.MinimumLevel.Debug();
}
else
{
config.MinimumLevel.Information();
}

if (!Directory.Exists("Logs"))
{
Directory.CreateDirectory("Logs");
}

DateTime now = DateTime.UtcNow;
string fileName = $"Session @ UTC {now.Year}-{now.Month:D2}-{now.Day:D2} {now.Hour:D2}-{now.Minute:D2}-{now.Second:D2}";

config.WriteTo.Debug(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {Message:lj}{NewLine}{Exception}")
.WriteTo.File(new CompactJsonFormatter(), $"Logs/{fileName}.log");

Log.Logger = config.CreateLogger();

Log.Information("Welcome to Horizon Version {Version}", Version);

if (IsDebug)
{
Log.Warning("This assembly is running in DEBUG mode.");
}

AppDomain.CurrentDomain.UnhandledException += this.OnUnhandledException;
this.DispatcherUnhandledException += this.OnUnhandledException;
}

/// <summary>
/// Fires when the <see cref="AppDomain" /> throws an exception that wasn't handled.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The event arguments.</param>
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs args)
{
Log.Fatal((Exception)args.ExceptionObject, "Horizon encountered a critical error!");
}

/// <summary>
/// Fires when the WPF <see cref="Dispatcher" /> throws an exception that wasn't handled.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The event arguments.</param>
private void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs args)
{
Log.Fatal(args.Exception, "Horizon encountered a critical error!");
}

/// <summary>
/// Sets the debug flag.
/// </summary>
private static void SetDebugFlag()
{
#if DEBUG
IsDebug = true;
#endif
}

/// <inheritdoc />
protected override void OnExit(ExitEventArgs args)
{
Log.Information("Closing...");

base.OnExit(args);

Log.CloseAndFlush();
}
}
4 changes: 4 additions & 0 deletions Horizon/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ReactiveUI />
<MethodBoundaryAspect />
</Weavers>
63 changes: 62 additions & 1 deletion Horizon/Horizon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,29 @@
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF>
<VersionPrefix>0.4.1</VersionPrefix>
<VersionPrefix>0.4.2</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<ApplicationIcon>Horizon.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>0436;1701;1702;NU1701</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>0436;1701;1702;NU1701</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Remove="Horizon.ico" />
<None Remove="Resources\Images\Horizon.png" />
<None Remove="Resources\Images\Key Medium.png" />
<None Remove="Resources\Images\Key Space.png" />
<None Remove="Resources\Images\Key Windows.png" />
<None Remove="Resources\Images\Key.png" />
<None Remove="Resources\Images\Splash.png" />
</ItemGroup>

<ItemGroup>
Expand All @@ -22,4 +38,49 @@
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dirkster.AvalonDock" Version="4.72.1" />
<PackageReference Include="Dirkster.AvalonDock.Themes.VS2013" Version="4.72.1" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.1" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="Fody" Version="6.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FodyHelpers" Version="6.8.1" />
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" />
<PackageReference Include="JetBrains.ExternalAnnotations" Version="10.2.151" />
<PackageReference Include="MethodBoundaryAspect.Fody" Version="2.0.149" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="Nito.AsyncEx.Tasks" Version="5.1.2" />
<PackageReference Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="1.3.1" />
<PackageReference Include="ReactiveUI" Version="20.1.1" />
<PackageReference Include="ReactiveUI.Events.WPF" Version="15.1.1" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="ReactiveUI.Testing" Version="20.1.1" />
<PackageReference Include="ReactiveUI.Validation" Version="4.0.9" />
<PackageReference Include="ReactiveUI.WPF" Version="20.1.1" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="5.0.0" />
<PackageReference Include="StringMath" Version="4.1.2" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\Images\Horizon.png" />
<Resource Include="Resources\Images\Key Medium.png" />
<Resource Include="Resources\Images\Key Space.png" />
<Resource Include="Resources\Images\Key Windows.png" />
<Resource Include="Resources\Images\Key.png" />
<Resource Include="Resources\Images\Splash.png" />
</ItemGroup>

</Project>
12 changes: 0 additions & 12 deletions Horizon/MainWindow.xaml

This file was deleted.

14 changes: 0 additions & 14 deletions Horizon/MainWindow.xaml.cs

This file was deleted.

Loading