-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Got the basics going :) * Added documentation * Made splash screen a little smaller. * Versioning * Fixed up splash screen; looks nicer now. * Added logging and missing documentation * Fixed up security hotspots * Added unit testing
- Loading branch information
1 parent
da814bc
commit 80d907c
Showing
26 changed files
with
649 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Application x:Class="FinalEngine.Editor.Desktop.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> | ||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml" /> | ||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" /> | ||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Controls.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// <copyright file="App.xaml.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Desktop; | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Windows; | ||
using FinalEngine.Editor.Desktop.Views; | ||
using FinalEngine.Editor.ViewModels; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
/// <summary> | ||
/// Interaction logic for App.xaml. | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
/// <summary> | ||
/// Starts up the main application on the current platform. | ||
/// </summary> | ||
/// <param name="e"> | ||
/// A <see cref="StartupEventArgs"/> that contains the event data. | ||
/// </param> | ||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
var viewModel = ConfigureServices().GetRequiredService<IMainViewModel>(); | ||
|
||
var view = new MainView() | ||
{ | ||
DataContext = viewModel, | ||
}; | ||
|
||
view.ShowDialog(); | ||
} | ||
|
||
/// <summary> | ||
/// Builds the configuration used throughout the lifetime of the application. | ||
/// </summary> | ||
/// <returns> | ||
/// The newly created <see cref="IConfiguration"/> to be used throughout the lifetime of the application. | ||
/// </returns> | ||
private static IConfiguration BuildConfiguration() | ||
{ | ||
string environment = Debugger.IsAttached ? "Development" : "Production"; | ||
|
||
return new ConfigurationBuilder() | ||
.SetBasePath(Directory.GetCurrentDirectory()) | ||
.AddJsonFile($"appsettings.{environment}.json") | ||
.Build(); | ||
} | ||
|
||
/// <summary> | ||
/// Configures the services to be consumed by the application. | ||
/// </summary> | ||
/// <returns> | ||
/// The newly configured <see cref="IServiceProvider"/>. | ||
/// </returns> | ||
private static IServiceProvider ConfigureServices() | ||
{ | ||
var services = new ServiceCollection(); | ||
var configuration = BuildConfiguration(); | ||
|
||
services.AddLogging(builder => | ||
{ | ||
builder | ||
.AddConsole() | ||
.AddFile(configuration.GetSection("LoggingOptions")); | ||
}); | ||
|
||
services.AddSingleton<IMainViewModel, MainViewModel>(); | ||
|
||
return services.BuildServiceProvider(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// <copyright file="AssemblyInfo.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
using System.Windows; | ||
|
||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] |
67 changes: 67 additions & 0 deletions
67
FinalEngine.Editor.Desktop/FinalEngine.Editor.Desktop.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<UseWPF>true</UseWPF> | ||
<TargetFramework>net7.0-windows</TargetFramework> | ||
<LangVersion>11.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<AnalysisMode>All</AnalysisMode> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<Platforms>x64</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Resources\Images\Splash\splash.png" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="..\Styling\StyleCop\Other\stylecop.json" Link="stylecop.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Dirkster.AvalonDock" Version="4.71.2" /> | ||
<PackageReference Include="Dirkster.AvalonDock.Themes.VS2013" Version="4.71.2" /> | ||
<PackageReference Include="MahApps.Metro" Version="2.4.9" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" /> | ||
<PackageReference Include="OpenTK.GLWpfControl" Version="4.2.3" /> | ||
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\FinalEngine.Editor.ViewModels\FinalEngine.Editor.ViewModels.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<SplashScreen Include="Resources\Images\Splash\splash.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</SplashScreen> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.Development.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="appsettings.Production.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// <copyright file="AssemblyInfo.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: CLSCompliant(false)] | ||
[assembly: ComVisible(false)] | ||
[assembly: AssemblyTitle("FinalEngine.Editor.Desktop")] | ||
[assembly: AssemblyDescription("The main application editor for Final Engine games.")] | ||
[assembly: Guid("F7A6671B-2CA9-442D-883D-BF61738420A0")] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<mah:MetroWindow x:Name="Window" | ||
x:Class="FinalEngine.Editor.Desktop.Views.MainView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Width="800" | ||
Height="450" | ||
GlowBrush="{DynamicResource MahApps.Brushes.Accent2}" | ||
NonActiveGlowBrush="{DynamicResource MahApps.Brushes.Accent4}" | ||
BorderThickness="2" | ||
WindowStartupLocation="CenterScreen" | ||
WindowState="Maximized" | ||
Title="{Binding Title}"> | ||
|
||
<!-- KEY BINDINGS --> | ||
<Window.InputBindings> | ||
<KeyBinding Gesture="Alt+F4" Command="{Binding ExitCommand}" CommandParameter="{Binding ElementName=Window}" /> | ||
</Window.InputBindings> | ||
|
||
<!-- MAIN MENU --> | ||
<mah:MetroWindow.LeftWindowCommands> | ||
<mah:WindowCommands ShowLastSeparator="False"> | ||
<Menu IsMainMenu="True"> | ||
<MenuItem Header="_File"> | ||
<MenuItem Header="E_xit" InputGestureText="Alt+F4" Command="{Binding ExitCommand}" CommandParameter="{Binding ElementName=Window}" /> | ||
</MenuItem> | ||
</Menu> | ||
</mah:WindowCommands> | ||
</mah:MetroWindow.LeftWindowCommands> | ||
</mah:MetroWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// <copyright file="MainView.xaml.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Desktop.Views; | ||
|
||
using FinalEngine.Editor.ViewModels.Interaction; | ||
using MahApps.Metro.Controls; | ||
|
||
/// <summary> | ||
/// Interaction logic for MainView.xaml. | ||
/// </summary> | ||
public partial class MainView : MetroWindow, ICloseable | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MainView"/> class. | ||
/// </summary> | ||
public MainView() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"LoggingOptions": { | ||
"PathFormat": "Logs/FinalEnine.Editor.Desktop - {Date}.txt", | ||
"LogLevel": { | ||
"Default": "Debug" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"LoggingOptions": { | ||
"PathFormat": "Logs/FinalEnine.Editor.Desktop - {Date}.txt", | ||
"LogLevel": { | ||
"Default": "Information" | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
FinalEngine.Editor.ViewModels/FinalEngine.Editor.ViewModels.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<LangVersion>11.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<AnalysisMode>All</AnalysisMode> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<Platforms>x64</Platforms> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<NoWarn>CA1848</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="..\Styling\StyleCop\Other\stylecop.json" Link="stylecop.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\FinalEngine.Utilities\FinalEngine.Utilities.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// <copyright file="IMainViewModel.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.ViewModels; | ||
|
||
using CommunityToolkit.Mvvm.Input; | ||
using FinalEngine.Editor.ViewModels.Interaction; | ||
|
||
/// <summary> | ||
/// Defines an interface that represents the main view. | ||
/// </summary> | ||
public interface IMainViewModel | ||
{ | ||
/// <summary> | ||
/// Gets the exit command. | ||
/// </summary> | ||
/// <value> | ||
/// The exit command. | ||
/// </value> | ||
IRelayCommand<ICloseable?> ExitCommand { get; } | ||
|
||
/// <summary> | ||
/// Gets the title. | ||
/// </summary> | ||
/// <value> | ||
/// The title. | ||
/// </value> | ||
string Title { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// <copyright file="ICloseable.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.ViewModels.Interaction; | ||
|
||
/// <summary> | ||
/// Defines an interface that provides a method for closing a view. | ||
/// </summary> | ||
public interface ICloseable | ||
{ | ||
/// <summary> | ||
/// Closes the view. | ||
/// </summary> | ||
void Close(); | ||
} |
Oops, something went wrong.