private void lsFrames_SelectedIndexChanged(object sender, EventArgs e) { if (lsFrames.SelectedIndex == -1) { return; } CurrentFrame = CurrentSequence.Frames[lsFrames.SelectedIndex]; CurrentSequence.StartFrame = 0; CurrentSequence.EndFrame = lsFrames.Items.Count - 1; tbFrameDuration.Text = CurrentFrame.Duration.ToString(); }
private void tsRemoveFrame_Click(object sender, EventArgs e) { if (CurrentFrame != null) { if ( MessageBox.Show("Are you sure you want to remove this frame?", "Frame Removal Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { CurrentSequence.Frames.Remove(CurrentFrame); CurrentFrame = null; lsFrames.DataSource = null; lsFrames.DataSource = CurrentSequence.Frames; lsFrames.DisplayMember = "AssetFilename"; } } }
private void tsRemoveSequence_Click(object sender, EventArgs e) { if (CurrentSequence != null) { Sequences.Remove(CurrentSequence); CurrentFrame = null; CurrentSequence = null; tbName.Text = string.Empty; tbFrameDuration.Text = string.Empty; lsFrames.DataSource = null; lsSequences.DataSource = null; lsSequences.DataSource = Sequences; lsSequences.DisplayMember = "Name"; } }
private void tsAddFrame_Click(object sender, EventArgs e) { HasFramesBeenAdded = true; if (CurrentSequence == null) { return; } OpenFileDialog dia = new OpenFileDialog(); dia.Multiselect = true; dia.Filter = "PNG|*.png|JPEG|*.jpg|BMP|*.bmp|GIF|*.bmp|All Files|*.*"; dia.InitialDirectory = Globals.AppSettings.ContentPath; if (dia.ShowDialog() == DialogResult.OK) { for (int i = 0; i < dia.FileNames.Length; i++) { if (!Directory.Exists(Globals.AppSettings.ProjectPath + @"\Temp\")) { Directory.CreateDirectory(Globals.AppSettings.ProjectPath + @"\Temp\"); } // Move the texture to our project -> textures directory File.Copy(dia.FileNames[i], Utilitys.GetDestinationTexturePath(dia.FileNames[i]), true); KeyFrame2D frame = new KeyFrame2D(); frame.AssetFilename = Path.GetFileName(dia.FileNames[i]); frame.Duration = 1; CurrentSequence.Frames.Add(frame); } } lsFrames.DataSource = null; lsFrames.DataSource = CurrentSequence.Frames; lsFrames.DisplayMember = "AssetFilename"; }
private void btnAddActor_Click(object sender, EventArgs e) { if ( MessageBox.Show("Are you sure you want to add this to the scene?", "Add Actor Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } // Disable all thse tbName.Enabled = false; cbRole.Enabled = false; gbSequences.Enabled = false; gbPreview.Enabled = false; btnSave.Enabled = false; pgBar.Style = ProgressBarStyle.Continuous; // Create our actor Actor = new EditorActor(Globals.Game, string.Empty, string.Empty); if (tvSequences.Nodes.Count >= 0) { // Set our Actors Role switch (cbRole.Text) { case "Player": Actor.Role = ActorRole.Player; break; case "Enemy": Actor.Role = ActorRole.Enemy; break; case "NPC": Actor.Role = ActorRole.NPC; break; case "Prop": Actor.Role = ActorRole.Prop; break; } Actor.Name = tbName.Text; // Init our clip player Actor.ClipPlayer = new AnimationPlayer2D(Globals.Game); Actor.ClipPlayer.Initialize(); // Loop thru the Tree view controls Nodes adding our Key Frames to our Clip Player foreach (TreeNode node in tvSequences.Nodes) { // Reset our frame index { int endFrameIndex = (node.Nodes.Count - 1); Sequence2D sequence = new Sequence2D(node.Name); sequence.StartFrame = 0; sequence.EndFrame = endFrameIndex; // Add our Frames foreach (TreeNode child in tvSequences.Nodes[node.Name].Nodes) { KeyFrame2D frame = new KeyFrame2D(); frame.Duration = 1f; frame.AssetFilename = child.Tag.ToString(); sequence.Frames.Add(frame); } // Add our Sequence Actor.ClipPlayer.Sequences.Add(sequence); } } // Generate our Sprite Sheet for the Clip Player SpriteTools.GenerateSpriteSheet(Actor, Globals.AppSettings.ProjectPath, tbName.Text); Actor.ClipPlayer.Texture = Catalyst3D.XNA.Engine.UtilityClasses.Utilitys.TextureFromFile( Globals.Game.GraphicsDevice, Globals.AppSettings.ProjectPath + @"\" + Actor.SpriteSheetFileName); } // Default to the idle sequence if (Actor.Sequences.Count > 0) { Actor.Play(Actor.ClipPlayer.Sequences[0].Name, true); } // Add it to our Scene Globals.ActorAdded.Invoke(Actor); tvSequences.Nodes.Clear(); Close(); }
public bool Contains(KeyFrame2D spriteValue) { return(List.Contains(spriteValue)); }
public int Add(KeyFrame2D spriteValue) { return(List.Add(spriteValue)); }