public GameStudioThumbnailService(SessionViewModel session, GameSettingsProviderService settingsProvider, GameStudioBuilderService assetBuilderService)
        {
            this.session             = session;
            this.assetBuilderService = assetBuilderService;

            generator        = new ThumbnailGenerator((EffectCompilerBase)assetBuilderService.EffectCompiler);
            compilerRegistry = new AssetCompilerRegistry {
                DefaultCompiler = new CustomAssetThumbnailCompiler()
            };
            thumbnailCompiler = new ThumbnailListCompiler(generator, ThumbnailBuilt, compilerRegistry);

            gameSettingsProviderService = settingsProvider;
            gameSettingsProviderService.GameSettingsChanged += GameSettingsChanged;
            UpdateGameSettings(settingsProvider.CurrentGameSettings);
            StartPushNotificationsTask();
        }
Exemplo n.º 2
0
        public override void InitializeSession(SessionViewModel session)
        {
            var fallbackDirectory = UPath.Combine(EditorSettings.FallbackBuildCacheDirectory, new UDirectory(XenkoGameStudio.EditorName));
            var buildDirectory    = fallbackDirectory;

            try
            {
                var package = session.CurrentProject ?? session.LocalPackages.First();
                if (package != null)
                {
                    // In package, we override editor build directory to be per-project and be shared with game build directory
                    buildDirectory = $"{package.PackagePath.GetFullDirectory().ToWindowsPath()}\\obj\\xenko\\assetbuild\\data";
                }

                // Attempt to create the directory to ensure it is valid.
                if (!Directory.Exists(buildDirectory))
                {
                    Directory.CreateDirectory(buildDirectory);
                }
            }
            catch (Exception)
            {
                buildDirectory = fallbackDirectory;
            }

            var pluginService    = session.ServiceProvider.Get <IAssetsPluginService>();
            var previewFactories = new Dictionary <Type, AssetPreviewFactory>();

            foreach (var xenkoPlugin in pluginService.Plugins.OfType <XenkoAssetsPlugin>())
            {
                var pluginTypes = xenkoPlugin.GetType().Assembly.GetTypes();
                foreach (var type in pluginTypes)
                {
                    var localType = type;
                    if (typeof(IAssetPreview).IsAssignableFrom(type))
                    {
                        var previewAttribute = type.GetCustomAttribute <AssetPreviewAttribute>();
                        if (previewAttribute != null)
                        {
                            previewFactories.Add(previewAttribute.AssetType, (builder, game, asset) => (IAssetPreview)Activator.CreateInstance(localType));
                        }
                    }
                }
            }

            var settingsProvider = new GameSettingsProviderService(session);

            session.ServiceProvider.RegisterService(settingsProvider);

            var builderService = new GameStudioBuilderService(session, settingsProvider, buildDirectory);

            session.ServiceProvider.RegisterService(builderService);
            session.ServiceProvider.RegisterService(builderService.Database); // TODO: this should be removed, the AssetBuilderService is reachable from anywhere now

            var previewService = new GameStudioPreviewService(session);

            previewService.RegisterAssetPreviewFactories(previewFactories);
            session.ServiceProvider.RegisterService(previewService);

            var thumbnailService = new GameStudioThumbnailService(session, settingsProvider, builderService);

            session.ServiceProvider.RegisterService(thumbnailService);

            var xenkoDebugService = new XenkoDebugService(session.ServiceProvider);

            session.ServiceProvider.RegisterService(xenkoDebugService);

            GameStudioViewModel.GameStudio.Preview   = new PreviewViewModel(session);
            GameStudioViewModel.GameStudio.Debugging = new DebuggingViewModel(GameStudioViewModel.GameStudio, xenkoDebugService);
        }