Progress on Input roll
This commit is contained in:
parent
42caa87c67
commit
4475f5a9fc
|
@ -49,26 +49,15 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
}
|
||||
|
||||
System.Windows.Forms.Control _c;
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetDC(IntPtr hWnd);
|
||||
|
||||
/// <summary>
|
||||
/// Init.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Init.
|
||||
/// </summary>
|
||||
public GDIRenderer(Graphics g)
|
||||
{
|
||||
_g = g;
|
||||
|
||||
//var clip = _g.Clip.GetHrgn(_g);
|
||||
|
||||
_hdc = _g.GetHdc();
|
||||
SetBkMode(_hdc, 1);
|
||||
|
||||
//SelectClipRgn(_hdc, clip);
|
||||
|
||||
//DeleteObject(clip);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -214,19 +203,90 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
/// <summary>
|
||||
/// Set the text color of the device context.
|
||||
/// </summary>
|
||||
private void SetTextColor(Color color)
|
||||
public void SetTextColor(Color color)
|
||||
{
|
||||
int rgb = (color.B & 0xFF) << 16 | (color.G & 0xFF) << 8 | color.R;
|
||||
SetTextColor(_hdc, rgb);
|
||||
}
|
||||
|
||||
public void SetBackgroundColor(Color color)
|
||||
{
|
||||
int rgb = (color.B & 0xFF) << 16 | (color.G & 0xFF) << 8 | color.R;
|
||||
SetBkColor(_hdc, rgb);
|
||||
}
|
||||
|
||||
public void DrawRectangle(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect)
|
||||
{
|
||||
Rectangle(_hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
|
||||
}
|
||||
|
||||
public void SetBrush(Color color)
|
||||
{
|
||||
int rgb = (color.B & 0xFF) << 16 | (color.G & 0xFF) << 8 | color.R;
|
||||
_brush = CreateSolidBrush(rgb);
|
||||
}
|
||||
|
||||
private IntPtr _brush = IntPtr.Zero;
|
||||
|
||||
public void FillRectangle(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect)
|
||||
{
|
||||
var r = new GDIRect(new Rectangle(nLeftRect, nTopRect, nRightRect, nBottomRect));
|
||||
FillRect(_hdc, ref r, _brush);
|
||||
}
|
||||
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
private struct Rect
|
||||
{
|
||||
private int _left;
|
||||
private int _top;
|
||||
private int _right;
|
||||
private int _bottom;
|
||||
|
||||
public Rect(Rectangle r)
|
||||
{
|
||||
_left = r.Left;
|
||||
_top = r.Top;
|
||||
_bottom = r.Bottom;
|
||||
_right = r.Right;
|
||||
}
|
||||
}
|
||||
// ReSharper restore NotAccessedField.Local
|
||||
|
||||
private struct GDIRect
|
||||
{
|
||||
private int left;
|
||||
private int top;
|
||||
private int right;
|
||||
private int bottom;
|
||||
|
||||
public GDIRect(Rectangle r)
|
||||
{
|
||||
left = r.Left;
|
||||
top = r.Top;
|
||||
bottom = r.Bottom;
|
||||
right = r.Right;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Imports
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetDC(IntPtr hWnd);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern int Rectangle(IntPtr hdc,int nLeftRect,int nTopRect,int nRightRect,int nBottomRect);
|
||||
private static extern int Rectangle(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern int FillRect(IntPtr hDC, [In] ref GDIRect lprc, IntPtr hbr);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern int SetBkMode(IntPtr hdc, int mode);
|
||||
|
@ -237,6 +297,9 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
[DllImport("gdi32.dll")]
|
||||
private static extern int SetTextColor(IntPtr hdc, int color);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern int SetBkColor(IntPtr hdc, int color);
|
||||
|
||||
[DllImport("gdi32.dll", EntryPoint = "GetTextExtentPoint32W")]
|
||||
private static extern int GetTextExtentPoint32(IntPtr hdc, [MarshalAs(UnmanagedType.LPWStr)] string str, int len, ref Size size);
|
||||
|
||||
|
@ -255,23 +318,8 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
[DllImport("gdi32.dll")]
|
||||
private static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
private struct Rect
|
||||
{
|
||||
private int _left;
|
||||
private int _top;
|
||||
private int _right;
|
||||
private int _bottom;
|
||||
|
||||
public Rect(Rectangle r)
|
||||
{
|
||||
_left = r.Left;
|
||||
_top = r.Top;
|
||||
_bottom = r.Bottom;
|
||||
_right = r.Right;
|
||||
}
|
||||
}
|
||||
// ReSharper restore NotAccessedField.Local
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern IntPtr CreateSolidBrush(int color);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -120,7 +120,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
|
||||
|
||||
//HorizontalOrientedColumnWidth
|
||||
//ntr.DrawRectangle
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -132,7 +134,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var start = StartBg;
|
||||
|
||||
ntr.DrawRectangle(StartBg.X, StartBg.Y, Width, Height);
|
||||
//ntr.SetBrush(Color.White);
|
||||
ntr.SetBrush(Color.Aqua);
|
||||
ntr.DrawRectangle(start.X, start.Y, Width, Height);
|
||||
|
||||
ntr.FillRectangle(start.X, start.Y, Width-50, Height-50);
|
||||
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
|
@ -214,14 +220,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
var x = (Columns.Max(c => c.Text.Length) * TextWidth) + CellPadding;
|
||||
var x = HorizontalOrientedColumnWidth;
|
||||
var y = TextHeight + CellPadding;
|
||||
return new Point(x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
var x = 0;
|
||||
var y = TextHeight + CellPadding;
|
||||
var y = TextHeight + (CellPadding * 2);
|
||||
return new Point(x, y);
|
||||
}
|
||||
}
|
||||
|
@ -230,6 +236,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private int HorizontalOrientedColumnWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Columns.Max(c => c.Text.Length) * TextWidth) + (CellPadding * 2);
|
||||
}
|
||||
}
|
||||
|
||||
private int TextHeight
|
||||
{
|
||||
get
|
||||
|
@ -264,7 +278,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public class RollColumns : List<RollColumn>
|
||||
{
|
||||
public void Add(string name, string text, int width, RollColumn.InputType type = RollColumn.InputType.Boolean)
|
||||
public void Add(string name, string text, int width, RollColumn.InputType type = RollColumn.InputType.Text)
|
||||
{
|
||||
Add(new RollColumn
|
||||
{
|
||||
|
@ -280,7 +294,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public class RollColumn
|
||||
{
|
||||
public enum InputType { Boolean, Float }
|
||||
public enum InputType { Boolean, Float, Text }
|
||||
|
||||
public int Width { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
|
|
@ -55,7 +55,69 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void TasStudioExperiment_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
InputView.Columns.AddRange(new []
|
||||
{
|
||||
new RollColumn
|
||||
{
|
||||
Name = "MarkerColumn",
|
||||
Text = "",
|
||||
Width = 40,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "FrameColumn",
|
||||
Text = "Frame",
|
||||
Width = 50,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 Up",
|
||||
Text = "U",
|
||||
Width = 23,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 Down",
|
||||
Text = "D",
|
||||
Width = 23,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 Left",
|
||||
Text = "L",
|
||||
Width = 23,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 Right",
|
||||
Text = "R",
|
||||
Width = 23,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 Select",
|
||||
Text = "s",
|
||||
Width = 23,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 Start",
|
||||
Text = "S",
|
||||
Width = 23,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 B",
|
||||
Text = "B",
|
||||
Width = 23,
|
||||
},
|
||||
new RollColumn
|
||||
{
|
||||
Name = "P1 A",
|
||||
Text = "A",
|
||||
Width = 23,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue