Esempio n. 1
0
        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.");
        }
Esempio n. 2
0
        public Engine(
            Configuration configuration,
            IAudioBackend audioBackend,
            IInputBackend inputBackend,
            IRenderingBackend renderingBackend,
            IGame game)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (audioBackend == null)
            {
                throw new ArgumentNullException(nameof(audioBackend));
            }
            if (inputBackend == null)
            {
                throw new ArgumentNullException(nameof(inputBackend));
            }
            if (renderingBackend == null)
            {
                throw new ArgumentNullException(nameof(renderingBackend));
            }
            if (game == null)
            {
                throw new ArgumentNullException(nameof(game));
            }

            Log.Info("Initializing engine components.");
            var containerBuilder = new ContainerBuilder();

            CommonModules.RegisterAll(containerBuilder);
            EngineModules.RegisterAll(containerBuilder);

            containerBuilder.RegisterInstance(configuration.Core).As <CoreConfiguration>().SingleInstance();
            containerBuilder.RegisterInstance(configuration.Physics).As <PhysicsConfiguration>().SingleInstance();
            containerBuilder.RegisterInstance(configuration.Rendering).As <RenderingConfiguration>().SingleInstance();

            containerBuilder.RegisterInstance(audioBackend).As <IAudioBackend>().SingleInstance();
            containerBuilder.RegisterInstance(inputBackend).As <IInputBackend>().SingleInstance();
            containerBuilder.RegisterInstance(renderingBackend).As <IRenderingBackend>().SingleInstance();

            var componentsRegistry = new ComponentsRegistry(containerBuilder);

            game.RegisterComponents(componentsRegistry);

            _container     = containerBuilder.Build();
            _lifetimeScope = _container.BeginLifetimeScope();

            RunStartUpTasks();

            _gameLoop      = _lifetimeScope.Resolve <IGameLoop>();
            _engineManager = _lifetimeScope.Resolve <IEngineManager>();
            Log.Info("Engine components initialized.");
        }
Esempio n. 3
0
        private void MergeWith(ApplicationConfiguration otherConfiguration)
        {
            // overwrite alias file name
            if (otherConfiguration.DcsBios.AliasFileName != null)
            {
                DcsBios.AliasFileName = otherConfiguration.DcsBios.AliasFileName;
            }

            // just overwrite the config locations
            if (otherConfiguration.DcsBios.ConfigLocations.Any())
            {
                DcsBios.ConfigLocations = otherConfiguration.DcsBios.ConfigLocations;
            }

            // overwrite the bios export settings
            if (otherConfiguration.DcsBios.Export != null)
            {
                DcsBios.Export = otherConfiguration.DcsBios.Export;
            }

            // merge devices
            foreach (var device in otherConfiguration.Osc.Devices)
            {
                Osc.Devices.Add(device);
            }

            // merge common modules
            if (otherConfiguration.CommonModules != null)
            {
                if (CommonModules is null)
                {
                    CommonModules = otherConfiguration.CommonModules;
                }
                else
                {
                    foreach (var module in otherConfiguration.CommonModules)
                    {
                        CommonModules.Add(module);
                    }
                }
            }

            // just overwrite the log level
            LogLevel = otherConfiguration.LogLevel;
        }
Esempio n. 4
0
        public virtual void SetUp()
        {
            var renderingConfigurationBuilder = RenderingConfiguration.CreateBuilder();

            ConfigureRendering(renderingConfigurationBuilder);
            var renderingConfiguration = renderingConfigurationBuilder.Build();

            _renderForm = new RenderForm("IntegrationTestsWindow")
            {
                ClientSize = new Size(renderingConfiguration.ScreenWidth, renderingConfiguration.ScreenWidth)
            };

            if (ShowDebugWindow)
            {
                _renderForm.Show();
            }

            var containerBuilder = new ContainerBuilder();

            // Register configuration
            containerBuilder.RegisterInstance(renderingConfiguration).As <RenderingConfiguration>().SingleInstance();

            // Register engine back-ends
            containerBuilder.RegisterInstance(new CSCoreAudioBackend()).As <IAudioBackend>().SingleInstance();
            containerBuilder.RegisterInstance(new WindowsInputBackend(_renderForm)).As <IInputBackend>().SingleInstance();
            containerBuilder.RegisterInstance(new DirectXRenderingBackend(_renderForm, DriverType.Software)).As <IRenderingBackend>().SingleInstance();

            // Register common modules
            CommonModules.RegisterAll(containerBuilder);

            // Register engine modules
            EngineModules.RegisterAll(containerBuilder);

            // Register test components
            RegisterTestComponents(containerBuilder);

            // Register tested components
            containerBuilder.RegisterType <TSystemUnderTest>().AsSelf().SingleInstance();

            _container     = containerBuilder.Build();
            _lifetimeScope = _container.BeginLifetimeScope();

            SystemUnderTest = _lifetimeScope.Resolve <TSystemUnderTest>();
        }