N64 VirtualPad - when a movie is active show the previous frame's line on the analog control

This commit is contained in:
adelikat 2014-05-16 13:40:21 +00:00
parent f975e3da8b
commit f88640fddb
3 changed files with 66 additions and 3 deletions

View File

@ -1,6 +1,8 @@
using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public sealed class AnalogControlPanel : Panel
@ -8,6 +10,7 @@ namespace BizHawk.Client.EmuHawk
public int X = 0;
public int Y = 0;
public bool HasValue = false;
public string Controller = "P1";
private readonly Brush _white_brush = Brushes.White;
private readonly Brush _black_brush = Brushes.Black;
@ -18,6 +21,7 @@ namespace BizHawk.Client.EmuHawk
private readonly Pen _blue_pen;
private readonly Bitmap dot = new Bitmap(7, 7);
private readonly Bitmap graydot = new Bitmap(7, 7);
public AnalogControlPanel()
{
@ -42,6 +46,12 @@ namespace BizHawk.Client.EmuHawk
g.FillRectangle(_red_brush, 2, 0, 3, 7);
g.FillRectangle(_red_brush, 1, 1, 5, 5);
g.FillRectangle(_red_brush, 0, 2, 7, 3);
Graphics gg = Graphics.FromImage(graydot);
gg.Clear(Color.Transparent);
gg.FillRectangle(Brushes.Gray, 2, 0, 3, 7);
gg.FillRectangle(Brushes.Gray, 1, 1, 5, 5);
gg.FillRectangle(Brushes.Gray, 0, 2, 7, 3);
}
private int RealToGFX(int val)
@ -52,8 +62,16 @@ namespace BizHawk.Client.EmuHawk
private int GFXToReal(int val)
{
int ret = (val * 2);
if (ret > Max) ret = Max;
if (ret < Min) ret = Min;
if (ret > Max)
{
ret = Max;
}
if (ret < Min)
{
ret = Min;
}
return ret;
}
@ -68,6 +86,22 @@ namespace BizHawk.Client.EmuHawk
e.Graphics.DrawLine(_black_pen, 64, 0, 64, 127);
e.Graphics.DrawLine(_black_pen, 0, 63, 127, 63);
if (Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished)
{
var mnemonicStr = Global.MovieSession.Movie.GetInput(Global.Emulator.Frame - 1);
var m = new MovieControllerAdapter { Type = Global.MovieSession.MovieControllerAdapter.Type };
m.SetControllersAsMnemonic(mnemonicStr);
var x = m.GetFloat(Controller + " X Axis");
var y = m.GetFloat(Controller + " Y Axis");
var xx = RealToGFX((int)x);
var yy = RealToGFX((int)y);
e.Graphics.DrawLine(new Pen(Brushes.Gray), 64, 63, xx, 127 - yy);
e.Graphics.DrawImage(graydot, xx - 3, 127 - yy - 3);
}
//Line
if (HasValue)
{

View File

@ -97,6 +97,18 @@ namespace BizHawk.Client.EmuHawk
{
Pads.ForEach(pad => pad.Clear());
}
if (Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished)
{
Pads
.Where(x => x is VirtualPadN64)
.Cast<VirtualPadN64>()
.ToList()
.ForEach(x =>
{
x.RefreshAnalog();
});
}
}
public VirtualPadForm()

View File

@ -10,7 +10,19 @@ namespace BizHawk.Client.EmuHawk
{
public partial class VirtualPadN64 : UserControl, IVirtualPad
{
public string Controller { get; set; }
private string _controllerNum = string.Empty;
public string Controller
{
get
{
return _controllerNum;
}
set
{
AnalogControl1.Controller = _controllerNum = value;
}
}
private int old_X = 0;
private int old_Y = 0;
@ -144,6 +156,11 @@ namespace BizHawk.Client.EmuHawk
SetAnalogControlFromNumerics();
}
public void RefreshAnalog()
{
AnalogControl1.Refresh();
}
public void set_analog(bool hasValue, int X, int Y)
{
int? x = hasValue ? X : (int?)null;