Skip to content

Commit

Permalink
Tweaked game launcher style and member sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ilexp committed Dec 28, 2020
1 parent 3ff8524 commit 4e100a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
49 changes: 24 additions & 25 deletions Source/Core/Duality/Launcher/DualityLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public DualityLauncher(LauncherArgs launcherArgs = null)
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;

// Set up console logging
this.AddGlobalOutput(new ConsoleLogOutput());
this.AddLogOutput(new ConsoleLogOutput());

// Set up file logging
try
Expand All @@ -42,7 +42,7 @@ public DualityLauncher(LauncherArgs launcherArgs = null)
logfileWriter.AutoFlush = true;
this.disposables.Push(logfileWriter);

this.AddGlobalOutput(new TextWriterLogOutput(logfileWriter));
this.AddLogOutput(new TextWriterLogOutput(logfileWriter));
}
catch (Exception e)
{
Expand Down Expand Up @@ -75,6 +75,27 @@ public DualityLauncher(LauncherArgs launcherArgs = null)
};
this.window = DualityApp.OpenWindow(options);
}
public void Dispose()
{
this.window.Dispose();

// Shut down the Duality core
DualityApp.Terminate();

AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;

foreach (ILogOutput logOutput in this.logOutputs)
{
Logs.RemoveGlobalOutput(logOutput);
}
this.logOutputs.Clear();

foreach (IDisposable disposable in this.disposables)
{
disposable.Dispose();
}
this.disposables.Clear();
}

/// <summary>
/// Runs duality. This will block till the game ends.
Expand All @@ -93,7 +114,7 @@ public void Run()
/// Adds a global log output and also makes sure its removed when <see cref="Dispose"/> is called
/// </summary>
/// <param name="logOutput"></param>
public void AddGlobalOutput(ILogOutput logOutput)
private void AddLogOutput(ILogOutput logOutput)
{
this.logOutputs.Add(logOutput);
Logs.AddGlobalOutput(logOutput);
Expand All @@ -107,27 +128,5 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
}
catch (Exception) { /* Ensure we're not causing any further exception by logging... */ }
}

public void Dispose()
{
this.window.Dispose();

// Shut down the Duality core
DualityApp.Terminate();

AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;

foreach (ILogOutput logOutput in this.logOutputs)
{
Logs.RemoveGlobalOutput(logOutput);
}
this.logOutputs.Clear();

foreach (IDisposable disposable in this.disposables)
{
disposable.Dispose();
}
this.disposables.Clear();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ internal static class Program
[STAThread]
public static void Main(string[] args)
{
var launcherArgs = new LauncherArgs(args);
LauncherArgs launcherArgs = new LauncherArgs(args);

if (launcherArgs.IsDebugging|| launcherArgs.IsRunFromEditor) ShowConsole();
if (launcherArgs.IsDebugging|| launcherArgs.IsRunFromEditor)
ShowConsole();

using (var launcher = new DualityLauncher(launcherArgs))
using (DualityLauncher launcher = new DualityLauncher(launcherArgs))
{
launcher.Run();
}
Expand Down

1 comment on commit 4e100a9

@IgorTheLight
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that was a last update? :-(

Please sign in to comment.