Пример #1
0
        void Initialize([NotNull] World world, int dimension)
        {
            var view = _view;

            DisplayName = "Starting Up - Editor";

            var sharpDxElement = view.SharpDx;
            var game           = new EditorGameFactory().Create(sharpDxElement, IoC.GetAll <IGameComponent>(), world, dimension);

            _game = game;

            Deactivated += ExitGame;

            // this is an extremely dirty hack. SharpDxElement will dispose when Unloaded is called,
            // but that can be triggered by avalondock, while the control should still be kept alive.
            // We can't prevent disposing because SharpDxElement is sealed, and the methods are private.
            // The only option then is to remove the event handler via reflection.
            // We select the method with the matching name and remove it.
            var handlers = GetRoutedEventHandlers(sharpDxElement, FrameworkElement.UnloadedEvent);
            var sharpDxElementDisposer = handlers.FirstOrDefault(b => b.Handler.Method.Name == "HandleUnloaded");

            sharpDxElement.RemoveHandler(FrameworkElement.UnloadedEvent, sharpDxElementDisposer.Handler);
            _game = game;
            _aggregator.Publish(new EditorOpenedMessage(game));
            _aggregator.Publish(new EditorGainedFocusMessage(game));

            DisplayName = String.Format("{0} - Editor", world.Title);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorGameController{TEditorGame}"/> class.
        /// </summary>
        /// <param name="asset">The asset associated with this instance.</param>
        /// <param name="editor">The editor associated with this instance.</param>
        /// <param name="gameFactory">The factory to create the editor game.</param>
        protected EditorGameController([NotNull] AssetViewModel asset, [NotNull] GameEditorViewModel editor, [NotNull] EditorGameFactory <TEditorGame> gameFactory)
        {
            if (asset == null)
            {
                throw new ArgumentNullException(nameof(asset));
            }
            if (editor == null)
            {
                throw new ArgumentNullException(nameof(editor));
            }

            Asset  = asset;
            Editor = editor;
            GameSideNodeContainer = new SessionNodeContainer(asset.Session)
            {
                NodeBuilder = { NodeFactory = new AssetNodeFactory() }
            };

            //Logger = GlobalLogger.GetLogger("Scene");
            Logger    = new LoggerResult();
            debugPage = EditorDebugTools.CreateLogDebugPage(Logger, "Scene");

            // Create the game
            var builderService = asset.ServiceProvider.Get <GameStudioBuilderService>();

            Game = gameFactory(gameContentLoadedTaskSource, builderService.EffectCompiler, builderService.EffectLogPath);
            Game.PackageSettings = asset.ServiceProvider.Get <GameSettingsProviderService>();
            sceneGameThread      = new Thread(SafeAction.Wrap(SceneGameRunThread))
            {
                IsBackground = true, Name = $"EditorGameThread ({asset.Url})"
            };
            sceneGameThread.SetApartmentState(ApartmentState.STA);

            Debug  = new EditorGameDebugService();
            Loader = new EditorContentLoader(this, Logger, asset, Game);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetCompositeHierarchyEditorController{TEditorGame,TAssetPartDesign,TAssetPart,TParentViewModel}"/> class.
 /// </summary>
 /// <param name="asset">The asset associated with this instance.</param>
 /// <param name="editor">The editor associated with this instance.</param>
 /// <param name="gameFactory">The factory to create the editor game.</param>
 protected AssetCompositeHierarchyEditorController([NotNull] AssetViewModel asset, [NotNull] GameEditorViewModel editor, [NotNull] EditorGameFactory <TEditorGame> gameFactory)
     : base(asset, editor, gameFactory)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityHierarchyEditorController"/> class.
 /// </summary>
 /// <param name="asset">The scene associated with this instance.</param>
 /// <param name="editor">The editor associated with this instance.</param>
 /// <param name="gameFactory">The factory to create the editor game.</param>
 protected EntityHierarchyEditorController([NotNull] AssetViewModel asset, [NotNull] EntityHierarchyEditorViewModel editor, [NotNull] EditorGameFactory <EntityHierarchyEditorGame> gameFactory)
     : base(asset, editor, gameFactory)
 {
 }