private void OnReBakeSpriteSheet(bool showresult) { try { // Generate our Sprite Sheet SpriteTools.GenerateSpriteSheet(conRenderer.Actor, Globals.AppSettings.ProjectPath, conRenderer.Actor.Name); Image img = Image.FromFile(Globals.AppSettings.ProjectPath + @"\" + conRenderer.Actor.SpriteSheetFileName); MemoryStream stream = new MemoryStream(); img.Save(stream, ImageFormat.Png); // Load the stream into a texture2D object conRenderer.Actor.ClipPlayer.Texture = Texture2D.FromStream(Globals.Game.GraphicsDevice, stream); // Close the Stream stream.Close(); if (showresult) { MessageBox.Show("Sprite sheet was successfully rebaked .."); } } catch (Exception er) { throw new Exception(er.Message); } }
private void btnClose_Click(object sender, EventArgs e) { if (HasFramesBeenAdded) { Actor actor = (Actor)Globals.RenderWindow.CurrentSelectedObject; if (actor != null) { // Bake new sprite sheet! SpriteTools.GenerateSpriteSheet(actor, Globals.AppSettings.ProjectPath, Path.GetFileName(actor.SpriteSheetFileName)); } else { MessageBox.Show(@"Error: The sprite sheet failed to be re-baked!"); } } Globals.IsDialogWindowOpen = false; Service.CloseDropDown(); }
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(); }