Can now make Animated Gifs Huzzah

This commit is contained in:
offspring131313 2012-03-04 20:37:49 +00:00
parent a76ea9c520
commit 099cf590b6
6 changed files with 217 additions and 14 deletions

View File

@ -465,6 +465,12 @@
//GB settings
public GBControllerTemplate GBController = new GBControllerTemplate();
public GBControllerTemplate GBAutoController = new GBControllerTemplate();
//GIF Animator Settings
public int GifAnimatorNumFrames;
public int GifAnimatorFrameSkip;
public int GifAnimatorSpeed;
public bool GifAnimatorReversable;
}
public class SMSControllerTemplate

View File

@ -107,6 +107,8 @@
this.screenshotF12ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.screenshotAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.screenshotClipboardToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.animatedGIFConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.makeAnimatedGIFToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.emulationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -259,7 +261,7 @@
this.screenshotToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.closeROMToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.showMenuToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.animatedGIFConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.makeAnimatedGifAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.StatusSlot0.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
@ -877,7 +879,9 @@
this.screenshotF12ToolStripMenuItem,
this.screenshotAsToolStripMenuItem,
this.screenshotClipboardToolStripMenuItem,
this.animatedGIFConfigToolStripMenuItem});
this.animatedGIFConfigToolStripMenuItem,
this.makeAnimatedGIFToolStripMenuItem,
this.makeAnimatedGifAsToolStripMenuItem});
this.screenshotToolStripMenuItem.Name = "screenshotToolStripMenuItem";
this.screenshotToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.screenshotToolStripMenuItem.Text = "Screenshot";
@ -904,6 +908,20 @@
this.screenshotClipboardToolStripMenuItem.Text = "Screenshot -> Clipboard";
this.screenshotClipboardToolStripMenuItem.Click += new System.EventHandler(this.screenshotClipboardToolStripMenuItem_Click);
//
// animatedGIFConfigToolStripMenuItem
//
this.animatedGIFConfigToolStripMenuItem.Name = "animatedGIFConfigToolStripMenuItem";
this.animatedGIFConfigToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.animatedGIFConfigToolStripMenuItem.Text = "Animated GIF Config";
this.animatedGIFConfigToolStripMenuItem.Click += new System.EventHandler(this.animatedGIFConfigToolStripMenuItem_Click);
//
// makeAnimatedGIFToolStripMenuItem
//
this.makeAnimatedGIFToolStripMenuItem.Name = "makeAnimatedGIFToolStripMenuItem";
this.makeAnimatedGIFToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.makeAnimatedGIFToolStripMenuItem.Text = "Make Animated GIF";
this.makeAnimatedGIFToolStripMenuItem.Click += new System.EventHandler(this.makeAnimatedGIFToolStripMenuItem_Click);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
@ -2128,12 +2146,12 @@
this.showMenuToolStripMenuItem.Text = "Show Menu";
this.showMenuToolStripMenuItem.Click += new System.EventHandler(this.showMenuToolStripMenuItem_Click);
//
// animatedGIFConfigToolStripMenuItem
// makeAnimatedGifAsToolStripMenuItem
//
this.animatedGIFConfigToolStripMenuItem.Name = "animatedGIFConfigToolStripMenuItem";
this.animatedGIFConfigToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.animatedGIFConfigToolStripMenuItem.Text = "Animated GIF Config";
this.animatedGIFConfigToolStripMenuItem.Click += new System.EventHandler(this.animatedGIFConfigToolStripMenuItem_Click);
this.makeAnimatedGifAsToolStripMenuItem.Name = "makeAnimatedGifAsToolStripMenuItem";
this.makeAnimatedGifAsToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.makeAnimatedGifAsToolStripMenuItem.Text = "Make Animated Gif As..";
this.makeAnimatedGifAsToolStripMenuItem.Click += new System.EventHandler(this.makeAnimatedGifAsToolStripMenuItem_Click);
//
// MainForm
//
@ -2396,6 +2414,8 @@
private System.Windows.Forms.ToolStripMenuItem forumsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem screenshotClipboardToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem animatedGIFConfigToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem makeAnimatedGIFToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem makeAnimatedGifAsToolStripMenuItem;
}
}

View File

@ -2553,7 +2553,7 @@ namespace BizHawk.MultiClient
/// <param name="reversable">Flag for making the gif loop back and forth</param>
/// <param name="filename">location to save the file</param>
/// <returns>false if the parameters are incorrect, true if it completes</returns>
public bool makeAnimatedGif(int num_images, int frameskip, int gifSpeed, bool reversable, String filename)
public bool AnimatedGif(int num_images, int frameskip, int gifSpeed, bool reversable, String filename)
{
if (num_images < 1 || frameskip < 1 || gifSpeed == 0) return false;//Exits if settings are bad
#region declare/insantiate variables
@ -2661,5 +2661,36 @@ namespace BizHawk.MultiClient
g.Show();
}
private void makeAnimatedGIFToolStripMenuItem_Click(object sender, EventArgs e)
{
makeAnimatedGif();
}
private void makeAnimatedGif()
{
string path = String.Format(PathManager.ScreenshotPrefix(Global.Game) + "AGIF.{0:yyyy-MM-dd HH.mm.ss}.gif", DateTime.Now);
AnimatedGif(Global.Config.GifAnimatorNumFrames, Global.Config.GifAnimatorFrameSkip, Global.Config.GifAnimatorSpeed, Global.Config.GifAnimatorReversable, path);
}
private void makeAnimatedGif(string path)
{
AnimatedGif(Global.Config.GifAnimatorNumFrames, Global.Config.GifAnimatorFrameSkip, Global.Config.GifAnimatorSpeed, Global.Config.GifAnimatorReversable, path);
}
private void makeAnimatedGifAsToolStripMenuItem_Click(object sender, EventArgs e)
{
string path = String.Format(PathManager.ScreenshotPrefix(Global.Game) + "AGIF.{0:yyyy-MM-dd HH.mm.ss}.gif", DateTime.Now);
SaveFileDialog sfd = new SaveFileDialog();
sfd.InitialDirectory = Path.GetDirectoryName(path);
sfd.FileName = Path.GetFileName(path);
sfd.Filter = "GIF File (*.gif)|*.gif";
Global.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
if (result != DialogResult.OK)
return;
makeAnimatedGif(sfd.FileName);
}
}
}

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.261
// Runtime Version:4.0.30319.239
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.

View File

@ -29,34 +29,128 @@
private void InitializeComponent()
{
this.Exit = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.TB_Frame_Skip = new System.Windows.Forms.TextBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.TB_Num_Frames = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// Exit
//
this.Exit.Location = new System.Drawing.Point(197, 227);
this.Exit.Location = new System.Drawing.Point(12, 108);
this.Exit.Name = "Exit";
this.Exit.Size = new System.Drawing.Size(75, 23);
this.Exit.TabIndex = 0;
this.Exit.Text = "E&xit";
this.Exit.TabIndex = 5;
this.Exit.Text = "&Save";
this.Exit.UseVisualStyleBackColor = true;
this.Exit.Click += new System.EventHandler(this.Exit_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(73, 85);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(93, 17);
this.checkBox1.TabIndex = 4;
this.checkBox1.Text = "Reverse Loop";
this.checkBox1.UseVisualStyleBackColor = true;
//
// TB_Frame_Skip
//
this.TB_Frame_Skip.Location = new System.Drawing.Point(108, 32);
this.TB_Frame_Skip.Name = "TB_Frame_Skip";
this.TB_Frame_Skip.Size = new System.Drawing.Size(58, 20);
this.TB_Frame_Skip.TabIndex = 2;
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(108, 58);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(58, 21);
this.comboBox1.TabIndex = 3;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 35);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 13);
this.label1.TabIndex = 8;
this.label1.Text = "Frames to Skip:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 61);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(90, 13);
this.label2.TabIndex = 9;
this.label2.Text = "Animation Speed:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 9);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 13);
this.label3.TabIndex = 7;
this.label3.Text = "Length of GIF:";
//
// TB_Num_Frames
//
this.TB_Num_Frames.Location = new System.Drawing.Point(108, 6);
this.TB_Num_Frames.Name = "TB_Num_Frames";
this.TB_Num_Frames.Size = new System.Drawing.Size(58, 20);
this.TB_Num_Frames.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(93, 108);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "&Cancel";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// GifAnimator
//
this.AcceptButton = this.Exit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.ClientSize = new System.Drawing.Size(184, 140);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.TB_Num_Frames);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.TB_Frame_Skip);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.Exit);
this.Name = "GifAnimator";
this.Text = "GifAnimator";
this.Load += new System.EventHandler(this.GifAnimator_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button Exit;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.TextBox TB_Frame_Skip;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox TB_Num_Frames;
private System.Windows.Forms.Button button1;
}
}

View File

@ -18,10 +18,62 @@ namespace BizHawk.MultiClient
private void GifAnimator_Load(object sender, EventArgs e)
{
comboBox1.Items.AddRange(new object[] { "x1/32", "x1/16", "x1/8", "x1/4", "x1/2", "x1", "x2", "x4", "x8", "x16", "x32" });
switch (Global.Config.GifAnimatorSpeed)
{
case (-32): comboBox1.SelectedIndex = 0; break;
case (-16): comboBox1.SelectedIndex = 1; break;
case (-8): comboBox1.SelectedIndex = 2; break;
case (-4): comboBox1.SelectedIndex = 3; break;
case (-2): comboBox1.SelectedIndex = 4; break;
case (1): comboBox1.SelectedIndex = 5; break;
case (2): comboBox1.SelectedIndex = 6; break;
case (4): comboBox1.SelectedIndex = 7; break;
case (8): comboBox1.SelectedIndex = 8; break;
case (16): comboBox1.SelectedIndex = 9; break;
case (32): comboBox1.SelectedIndex = 10; break;
default: comboBox1.SelectedIndex = 5; break;
}
if (Global.Config.GifAnimatorNumFrames == 0) Global.Config.GifAnimatorNumFrames = 1;
if (Global.Config.GifAnimatorFrameSkip == 0) Global.Config.GifAnimatorFrameSkip = 1;
TB_Frame_Skip.Text = Global.Config.GifAnimatorFrameSkip.ToString();
TB_Num_Frames.Text = Global.Config.GifAnimatorNumFrames.ToString();
checkBox1.Checked = Global.Config.GifAnimatorReversable;
}
private void Exit_Click(object sender, EventArgs e)
{
int FrameSkip;
int NumFrames;
if (!Int32.TryParse(TB_Frame_Skip.Text, out FrameSkip) || !Int32.TryParse(TB_Num_Frames.Text, out NumFrames) || FrameSkip < 1 || NumFrames < 1)
{
MessageBox.Show("The values you've selected are invalid");
return;
}
Global.Config.GifAnimatorNumFrames = NumFrames;
Global.Config.GifAnimatorFrameSkip = FrameSkip;
Global.Config.GifAnimatorReversable = checkBox1.Checked;
switch (comboBox1.SelectedIndex)
{
case (0): Global.Config.GifAnimatorSpeed = -32; break;
case (1): Global.Config.GifAnimatorSpeed = -16; break;
case (2): Global.Config.GifAnimatorSpeed = -8; break;
case (3): Global.Config.GifAnimatorSpeed = -4; break;
case (4): Global.Config.GifAnimatorSpeed = -2; break;
case (5): Global.Config.GifAnimatorSpeed = 1; break;
case (6): Global.Config.GifAnimatorSpeed = 2; break;
case (7): Global.Config.GifAnimatorSpeed = 4; break;
case (8): Global.Config.GifAnimatorSpeed = 8; break;
case (9): Global.Config.GifAnimatorSpeed = 16; break;
case (10): Global.Config.GifAnimatorSpeed = 32; break;
}
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}