Exemple #1
0
 protected EntityHierarchyEditorGame(TaskCompletionSource <bool> gameContentLoadedTaskSource, IEffectCompiler effectCompiler, string effectLogPath)
 {
     this.gameContentLoadedTaskSource = gameContentLoadedTaskSource;
     this.effectCompiler = effectCompiler;
     this.effectLogPath  = effectLogPath;
     CreateScenePipeline();
 }
Exemple #2
0
        protected override void Destroy()
        {
            // Mark effect system as destroyed (so that async effect compilation are ignored)
            lock (cachedEffects)
            {
                // Clear effects
                foreach (var effect in cachedEffects)
                {
                    effect.Value.ReleaseInternal();
                }
                cachedEffects.Clear();

                // Mark as not initialized anymore
                isInitialized = false;
            }

#if XENKO_PLATFORM_WINDOWS_DESKTOP
            if (directoryWatcher != null)
            {
                directoryWatcher.Modified -= FileModifiedEvent;
                directoryWatcher.Dispose();
                directoryWatcher = null;
            }
#endif

            Compiler?.Dispose();
            Compiler = null;

            base.Destroy();
        }
Exemple #3
0
 protected EntityHierarchyEditorGame(TaskCompletionSource <bool> gameContentLoadedTaskSource, IEffectCompiler effectCompiler, string effectLogPath)
 {
     this.gameContentLoadedTaskSource = gameContentLoadedTaskSource;
     this.effectCompiler = effectCompiler;
     this.effectLogPath  = effectLogPath;
     this.TreatNotFocusedLikeMinimized = false;
     this.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = true;
     this.WindowMinimumUpdateRate.MinimumElapsedTime           = TimeSpan.Zero;
     this.MinimizedMinimumUpdateRate.MinimumElapsedTime        = TimeSpan.FromSeconds(1.0);
     CreateScenePipeline();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="EffectCompilerSystem" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        public EffectCompilerSystem(Game game)
            : base(game)
        {
            effectsCompilable = new List<Effect>();
            effectsToAlwaysCheck = new List<Effect>();
            effectsToCheck = new List<Effect>();
            effectsToRecompile = new List<Effect>();
            effectsToReset = new List<EffectToRebind>();
            effectsToResetTemp = new List<EffectToRebind>();
            resetEvent = new AutoResetEvent(false);
            endThreadCompilerEvent = new AutoResetEvent(false);
            Enabled = true;
#if !W8CORE
            compiler = new EffectCompiler();
#endif
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EffectCompilerSystem" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        public EffectCompilerSystem(Game game)
            : base(game)
        {
            effectsCompilable      = new List <Effect>();
            effectsToAlwaysCheck   = new List <Effect>();
            effectsToCheck         = new List <Effect>();
            effectsToRecompile     = new List <Effect>();
            effectsToReset         = new List <EffectToRebind>();
            effectsToResetTemp     = new List <EffectToRebind>();
            resetEvent             = new AutoResetEvent(false);
            endThreadCompilerEvent = new AutoResetEvent(false);
            Enabled = true;
#if !W8CORE
            compiler = new EffectCompiler();
#endif
        }
Exemple #6
0
 public PreviewGame(IEffectCompiler effectCompiler)
 {
     this.effectCompiler = effectCompiler;
 }
Exemple #7
0
 private static PrefabEditorGame CreateEditorGame(TaskCompletionSource <bool> gameContentLoadedTaskSource, IEffectCompiler effectCompiler, string effectLogPath)
 {
     return(new PrefabEditorGame(gameContentLoadedTaskSource, effectCompiler, effectLogPath));
 }
Exemple #8
0
        private void CompileEffectFiles(object sender, MouseEventArgs e)
        {
            Platform platform   = (Platform)platformSelection.SelectedIndex;
            String   filePath   = filePathTextBox.Text;
            String   outputPath = outputPathTextBox.Text;

            if (String.IsNullOrEmpty(filePath) || !Directory.Exists(filePath))
            {
                MessageBox.Show("Please select a valid file path.");
                return;
            }

            if (String.IsNullOrEmpty(filePath) || !Directory.Exists(outputPath))
            {
                MessageBox.Show("Please select a valid output file path.");
                return;
            }

            int count = effectFilesListBox.CheckedItems.Count;

            if (count == 0)
            {
                progressLabel.Text = "No Files selected.";
                return;
            }

            //Get the file names
            List <String> files = new List <String>();

            bool overwriteAll = overwriteCheck.Checked;

            for (int i = 0; i < count; i++)
            {
                String file = effectFilesListBox.CheckedItems[i] as String;
                if (overwriteAll)
                {
                    files.Add(file);
                }
                else if (AskOverwrite(Path.Combine(outputPath, file)))
                {
                    files.Add(file);
                }
            }

            if (files.Count == 0)
            {
                progressLabel.Text = "Compilation aborted.";
                return;
            }

            //Setup compiler
            IEffectCompiler compiler = CreatePlatformCompiler(platform);

            compiler.Init();

            compileProgressBar.Maximum = count * 2;

            //Compile each effect.
            int count2 = 0;

            Effect[] effects;
            try {
                effects = compiler.Compile(files.ToArray(), delegate() {
                    compileProgressBar.PerformStep();
                    count2++;
                    progressLabel.Text = String.Format("Compiling file %d of %d", count2, count);
                });
            } catch (Exception ce) {
                compiler.Dispose();
                compileProgressBar.Value = 0;
                progressLabel.Text       = "Error compiling files.";
                MessageBox.Show(ce.Message, "Error", MessageBoxButtons.OK);
                return;
            }

            //Save via the binary exporter.
            try {
                BinaryExporter exporter = new BinaryExporter();
                count2 = 0;
                foreach (Effect effect in effects)
                {
                    FileStream fs = File.Create(Path.Combine(outputPath, effect.Name + ".tebo"));
                    exporter.Save(effect, fs);
                    fs.Flush();
                    fs.Close();
                    compileProgressBar.PerformStep();
                    count2++;
                    progressLabel.Text = String.Format("Saving file %d of %d", count2, count);
                }
            } catch (Exception ee) {
                compiler.Dispose();
                compileProgressBar.Value = 0;
                progressLabel.Text       = "Error saving files.";
                MessageBox.Show(ee.Message, "Error", MessageBoxButtons.OK);
                return;
            }

            //Cleanup
            compiler.Dispose();
            compileProgressBar.Value = 0;
            progressLabel.Text       = "Compilation finished, waiting...";
        }
Exemple #9
0
 public SceneEditorGame(TaskCompletionSource <bool> gameContentLoadedTaskSource, IEffectCompiler effectCompiler, string effectLogPath)
     : base(gameContentLoadedTaskSource, effectCompiler, effectLogPath)
 {
 }
Exemple #10
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Initialisation
        //---------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of a Purple# <see cref="EffectCompiler"/>.
        /// </summary>
        private EffectCompiler()
        {
            current = Device.Instance.PlugIn.EffectCompiler;
        }