Beispiel #1
0
        /// <summary>
        /// Handles the Deserialize event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.SerializeEventArgs"/> instance containing the event data.</param>
        private void Interface_Deserialize(Object sender, SerializeEventArgs e)
        {
            Trace.WriteLine("Deserializing particle effect from " + e.FilePath, "CORE");

            using (new TraceIndenter())
            {
                Trace.WriteLine("Using plugin: " + e.Plugin.Name);
            }

            try
            {
                this.ParticleEffect = e.Plugin.Deserialize(e.FilePath);

                //this.ParticleEffect.Initialise();

                foreach (AbstractEmitter emitter in this.ParticleEffect.Emitters)
                {
                    emitter.Initialise();

                    if (String.IsNullOrEmpty(emitter.ParticleTextureAssetPath))
                    {
                        emitter.ParticleTexture = this.DefaultParticleTexture;
                    }
                    else
                    {
                        bool textureFound = false;

                        foreach (TextureReference reference in this.TextureReferences)
                        {
                            if (reference.GetAssetName() == emitter.ParticleTextureAssetPath)
                            {
                                emitter.ParticleTexture = reference.Texture;

                                textureFound = true;

                                break;
                            }
                        }

                        if (!textureFound)
                        {
                            MessageBox.Show("Could not find texture asset '" + emitter.ParticleTextureAssetPath + "'. " +
                                            "Using default particle texture...", "Asset not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            emitter.ParticleTexture = this.DefaultParticleTexture;
                        }
                    }
                }

                this.Interface.SetParticleEffect(this.ParticleEffect);

                e.Result = CoreOperationResult.OK;
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }
Beispiel #2
0
        protected virtual void OnDeserialize(SerializeEventArgs e)
        {
            Trace.WriteLine("User requires deserialize of particle effect...", "UI");

            using (new TraceIndenter())
            {
                Trace.WriteLine("Filepath:" + e.FilePath);
            }

            using (new HourglassCursor())
            {
                var handler = Interlocked.CompareExchange(ref this.Deserialize, null, null);

                if (handler != null)
                    handler.Invoke(this, e);
            }

            this.AssertOperationOK(e.Result);
        }
Beispiel #3
0
        /// <summary>
        /// Handles the Serialize event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.SerializeEventArgs"/> instance containing the event data.</param>
        private void Interface_Serialize(object sender, SerializeEventArgs e)
        {
            Trace.WriteLine("Serializing particle effect to " + e.FilePath, "CORE");

            using (new TraceIndenter())
            {
                Trace.WriteLine("Using plugin: " + e.Plugin.Name);
            }

            try
            {
                e.Plugin.Serialize(this.ParticleEffect, e.FilePath);

                e.Result = CoreOperationResult.OK;
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }
Beispiel #4
0
        protected virtual void OnDeserialize(SerializeEventArgs e)
        {
            Trace.WriteLine("User requires deserialize of particle effect...", "UI");

            using (new TraceIndenter())
            {
                Trace.WriteLine("Filepath:" + e.FilePath);
            }

            using (new HourglassCursor())
            {
                var handler = Interlocked.CompareExchange(ref this.Deserialize, null, null);

                if (handler != null)
                {
                    handler.Invoke(this, e);
                }
            }

            this.AssertOperationOK(e.Result);
        }
Beispiel #5
0
        /// <summary>
        /// Handles the DropDownItemClicked event of the uxExportMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.ToolStripItemClickedEventArgs"/> instance containing the event data.</param>
        private void uxExportMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var plugin = e.ClickedItem.Tag as IEffectSerializationPlugin;

            this.uxExportEffectDialog.Filter = plugin.FileFilter;

            if (this.uxExportEffectDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var filePath = this.uxExportEffectDialog.FileName;

                    var args = new SerializeEventArgs(plugin, filePath);

                    this.OnSerialize(args);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Handles the DropDownItemClicked event of the uxExportMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.ToolStripItemClickedEventArgs"/> instance containing the event data.</param>
        private void uxExportMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var plugin = e.ClickedItem.Tag as ISerializerPlugin;

            this.uxExportEffectDialog.Filter = plugin.FileFilter;

            if (this.uxExportEffectDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var filePath = this.uxExportEffectDialog.FileName;

                    var args = new SerializeEventArgs(plugin, filePath);

                    this.OnSerialize(args);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Handles the Deserialize event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.SerializeEventArgs"/> instance containing the event data.</param>
        private void Interface_Deserialize(Object sender, SerializeEventArgs e)
        {
            Trace.WriteLine("Deserializing particle effect from " + e.FilePath, "CORE");
            
            using (new TraceIndenter())
            {
                Trace.WriteLine("Using plugin: " + e.Plugin.Name);
            }

            try
            {
                this.ParticleEffect = e.Plugin.Deserialize(e.FilePath);

                //this.ParticleEffect.Initialise();

                foreach (AbstractEmitter emitter in this.ParticleEffect.Emitters)
                {
                    emitter.Initialise();

                    if (String.IsNullOrEmpty(emitter.ParticleTextureAssetPath))
                    {
                        emitter.ParticleTexture = this.DefaultParticleTexture;
                    }
                    else
                    {
                        bool textureFound = false;

                        foreach (TextureReference reference in this.TextureReferences)
                        {
                            if (reference.GetAssetName() == emitter.ParticleTextureAssetPath)
                            {
                                emitter.ParticleTexture = reference.Texture;

                                textureFound = true;

                                break;
                            }
                        }

                        if (!textureFound)
                        {
                            MessageBox.Show("Could not find texture asset '" + emitter.ParticleTextureAssetPath + "'. " +
                                "Using default particle texture...", "Asset not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            emitter.ParticleTexture = this.DefaultParticleTexture;
                        }
                    }
                }

                this.Interface.SetParticleEffect(this.ParticleEffect);

                e.Result = CoreOperationResult.OK;
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Handles the Serialize event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.SerializeEventArgs"/> instance containing the event data.</param>
        private void Interface_Serialize(Object sender, SerializeEventArgs e)
        {
            Trace.WriteLine("Serializing particle effect to " + e.FilePath, "CORE");
            
            using (new TraceIndenter())
            {
                Trace.WriteLine("Using plugin: " + e.Plugin.Name);
            }

            try
            {
                e.Plugin.Serialize(this.ParticleEffect, e.FilePath);

                e.Result = CoreOperationResult.OK;
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }
 protected virtual void OnDeserialize(SerializeEventArgs e)
 {
     if (this.Deserialize != null)
         this.Deserialize(this, e);
 }
Beispiel #10
0
        /// <summary>
        /// Handles the Deserialize event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.SerializeEventArgs"/> instance containing the event data.</param>
        private void Interface_Deserialize(object sender, SerializeEventArgs e)
        {
            try
            {
                this.ParticleEffect = e.Plugin.Deserialize(e.FilePath);

                this.ParticleEffect.Initialise();

                foreach (Emitter emitter in this.ParticleEffect)
                {
                    if (String.IsNullOrEmpty(emitter.ParticleTextureAssetName))
                    {
                        emitter.ParticleTexture = this.DefaultParticleTexture;
                    }
                    else
                    {
                        bool textureFound = false;

                        foreach (TextureReference reference in this.TextureReferences)
                        {
                            if (reference.GetAssetName() == emitter.ParticleTextureAssetName)
                            {
                                emitter.ParticleTexture = reference.Texture;

                                textureFound = true;

                                break;
                            }
                        }

                        if (!textureFound)
                        {
                            MessageBox.Show("Could not find texture asset '" + emitter.ParticleTextureAssetName + "'. " +
                                "Using default particle texture...", "Asset not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            emitter.ParticleTexture = this.DefaultParticleTexture;
                        }
                    }
                }

                this.Interface.SetParticleEffect(this.ParticleEffect);
            }
            catch { 
                throw; }
        }
Beispiel #11
0
 /// <summary>
 /// Handles the Serialize event of the Interface.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="ProjectMercury.EffectEditor.SerializeEventArgs"/> instance containing the event data.</param>
 private void Interface_Serialize(object sender, SerializeEventArgs e)
 {
     try
     {
         e.Plugin.Serialize(this.ParticleEffect, e.FilePath);
     }
     catch { throw; }
 }