Skip to content

Commit

Permalink
Merge pull request #12 from HazelnutCheese/ME2CFG-11
Browse files Browse the repository at this point in the history
ME2CFG-11 Complete UI Rework to Metis Mod Launcher
  • Loading branch information
HazelnutCheese authored Feb 25, 2023
2 parents 487eb2d + 045569d commit 158fa73
Show file tree
Hide file tree
Showing 203 changed files with 14,529 additions and 2,198 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2022
Copyright (c) 2023

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
26 changes: 25 additions & 1 deletion ModEngine2ConfigTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,42 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModEngine2ConfigTool", "ModEngine2ConfigTool\ModEngine2ConfigTool.csproj", "{457A461C-6A42-4E01-8E48-7641E8BF65FB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModEngine2ConfigTool", "ModEngine2ConfigTool\ModEngine2ConfigTool.csproj", "{457A461C-6A42-4E01-8E48-7641E8BF65FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "Setup\Setup.wixproj", "{90362680-4791-4663-B577-16C9DDF69A36}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Debug|x86.ActiveCfg = Debug|Any CPU
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Debug|x86.Build.0 = Debug|Any CPU
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Release|Any CPU.Build.0 = Release|Any CPU
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Release|x86.ActiveCfg = Release|Any CPU
{457A461C-6A42-4E01-8E48-7641E8BF65FB}.Release|x86.Build.0 = Release|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Debug|x86.ActiveCfg = Debug|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Debug|x86.Build.0 = Debug|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Release|Any CPU.Build.0 = Release|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Release|x86.ActiveCfg = Release|Any CPU
{29265AA2-155E-4FE8-AAA5-7B0BF8C76CE0}.Release|x86.Build.0 = Release|Any CPU
{90362680-4791-4663-B577-16C9DDF69A36}.Debug|Any CPU.ActiveCfg = Debug|x86
{90362680-4791-4663-B577-16C9DDF69A36}.Debug|x86.ActiveCfg = Debug|x86
{90362680-4791-4663-B577-16C9DDF69A36}.Debug|x86.Build.0 = Debug|x86
{90362680-4791-4663-B577-16C9DDF69A36}.Release|Any CPU.ActiveCfg = Release|x86
{90362680-4791-4663-B577-16C9DDF69A36}.Release|x86.ActiveCfg = Release|x86
{90362680-4791-4663-B577-16C9DDF69A36}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions ModEngine2ConfigTool/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />
<ResourceDictionary Source="Views\Styles\TextBlockStyles.xaml" />
<ResourceDictionary Source="Views\Styles\ButtonStyles.xaml" />
<ResourceDictionary Source="Views\Styles\ComboBoxStyles.xaml" />
<materialDesign:BundledTheme BaseTheme="Dark"
PrimaryColor="Orange"
SecondaryColor="Orange" />
<ResourceDictionary Source="Views\Styles\MetisUiConstants.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand Down
93 changes: 25 additions & 68 deletions ModEngine2ConfigTool/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using ModEngine2ConfigTool.Services;
using Autofac;
using ModEngine2ConfigTool.Services;
using ModEngine2ConfigTool.ViewModels;
using Sherlog;
using Sherlog.Appenders;
using Sherlog.Formatters;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using System.Windows;

Expand All @@ -18,99 +13,61 @@ namespace ModEngine2ConfigTool
/// </summary>
public partial class App : Application
{
public static Logger Logger { get; private set; }

public static string DataStorage { get; }

public static ConfigurationService ConfigurationService { get; }

public const string AppName = "Metis Mod Launcher";
public const string DialogHostId = "MainWindowDialogHost";

static App()
{
if(Debugger.IsAttached)
{
DataStorage = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"ModEngine2ConfigTool");
}
else
{
DataStorage = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"ModEngine2ConfigTool");
}
private readonly IContainer _serviceContainer;

ConfigureLogging();
Logger = Logger.GetLogger(nameof(App));
ConfigurationService = new ConfigurationService();
public App(IContainer serviceContainer)
{
_serviceContainer = serviceContainer;
}

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

ConfigureLogging();

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Current.DispatcherUnhandledException += Dispatcher_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

// Initialise Services
ProfileService.Initialise();
var mainWindow = new MainWindow();
var mainViewModel = new MainWindowVm(
mainWindow,
_serviceContainer);

var mainViewModel = new MainWindowViewModel();
var mainWindow = new MainWindow(mainViewModel);
mainWindow.DataContext = mainViewModel;

mainWindow.Show();
}

private void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message);
Logger.Error(e.Exception.ToString());
if(e.Exception?.InnerException is not null)
{
MessageBox.Show(e.Exception.InnerException?.Message);
}
else
{
MessageBox.Show(e.Exception?.Message);
}

Log.Instance.Error(e.Exception?.ToString());

e.SetObserved();
}

private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message);
Logger.Error(e.Exception.ToString());
Log.Instance.Error(e.Exception.ToString());
e.Handled = true;
}

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show(e.ExceptionObject.ToString());
Logger.Error(e.ExceptionObject.ToString());
}

private static void ConfigureLogging()
{
var messageFormatter = new LogMessageFormatter();
var timestampFormatter = new TimestampFormatter(
() => DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));

var consoleAppender = new ConsoleAppender(new Dictionary<LogLevel, ConsoleColor>
{
{LogLevel.Trace, ConsoleColor.Cyan},
{LogLevel.Debug, ConsoleColor.Blue},
{LogLevel.Info, ConsoleColor.White},
{LogLevel.Warn, ConsoleColor.Yellow},
{LogLevel.Error, ConsoleColor.Red},
{LogLevel.Fatal, ConsoleColor.Magenta},
});

var logFileName = DateTime.Now.ToString("yyyy-M-dd_ModEngine2Config.log");
var fileAppender = new FileWriterAppender(logFileName);

Logger.AddAppender((logger, level, message) =>
{
message = messageFormatter.FormatMessage(logger, level, message);
message = timestampFormatter.FormatMessage(logger, level, message);
consoleAppender.WriteLine(logger, level, message);
fileAppender.WriteLine(logger, level, message);
});
Log.Instance.Error(e.ExceptionObject.ToString());
}
}
}
21 changes: 21 additions & 0 deletions ModEngine2ConfigTool/CommandLineArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using PowerArgs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ModEngine2ConfigTool
{
public class CommandLineArgs
{
[ArgShortcut("-p")]
public string? ProfileId { get; set; }

[ArgShortcut("-c")]
public string? AppSettings { get; set; }

[ArgShortcut("-l")]
public string? AppData { get; set; }
}
}
Loading

0 comments on commit 158fa73

Please sign in to comment.