private void App_OnStartup(object sender, StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; BindingErrorListener.EnableExceptionOnBindingError(); LogFactory.ConfigureFileTarget("GeishaEditor.log"); var log = LogFactory.Create(typeof(App)); log.Info("Geisha Editor is being started."); var containerBuilder = new ContainerBuilder(); CommonModules.RegisterAll(containerBuilder); EngineModules.RegisterAll(containerBuilder); EditorModules.RegisterAll(containerBuilder); containerBuilder.RegisterInstance(new CSCoreAudioBackend()).As <IAudioBackend>(); containerBuilder.RegisterInstance(new DirectXRenderingBackend()).As <IRenderingBackend>(); _container = containerBuilder.Build(); _lifetimeScope = _container.BeginLifetimeScope(); ViewRepository.Default.RegisterViewsFromCurrentlyLoadedAssemblies(); var mainViewModel = _lifetimeScope.Resolve <MainViewModel>(); _mainWindow = new MainWindow(mainViewModel); _mainWindow.Show(); _mainWindow.LoadLayout(); log.Info("Geisha Editor started successfully."); }
/// <summary> /// Initializes Geisha Engine for specified <paramref name="game" /> and starts the game loop. /// </summary> /// <param name="game"><see cref="IGame" /> instance providing custom game functionality.</param> public static void Run(IGame game) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; LogFactory.ConfigureFileTarget("GeishaEngine.log"); var log = LogFactory.Create(typeof(GeishaEngineForWindows)); log.Info("Starting engine."); log.Info("Loading configuration from file."); var configuration = Configuration.LoadFromFile(EngineConfigFile); Application.SetHighDpiMode(HighDpiMode.SystemAware); using (var form = new RenderForm(game.WindowTitle) { ClientSize = new Size(configuration.Rendering.ScreenWidth, configuration.Rendering.ScreenHeight), AllowUserResizing = false }) { using var engine = new Engine( configuration, new CSCoreAudioBackend(), new WindowsInputBackend(form), new DirectXRenderingBackend(form, DriverType.Hardware), game ); log.Info("Engine started successfully."); RenderLoop.Run(form, () => { // ReSharper disable AccessToDisposedClosure engine.Update(); if (engine.IsScheduledForShutdown) { form.Close(); } // ReSharper restore AccessToDisposedClosure }); } log.Info("Engine shutdown completed."); }