Merge remote-tracking branch 'remotes/azreally/Xadrophonix'

This commit is contained in:
zeromus 2018-03-13 20:39:42 -04:00
commit 65bc534395
3 changed files with 175 additions and 0 deletions

View File

@ -82,6 +82,14 @@
this.ToWikiMarkupButton.Text = "Wiki markup to Clipboard";
this.ToWikiMarkupButton.UseVisualStyleBackColor = true;
this.ToWikiMarkupButton.Click += new System.EventHandler(this.ToWikiMarkupButton_Click);
//
// CopyMenu
//
this.CopyMenu = new System.Windows.Forms.ContextMenu(
new System.Windows.Forms.MenuItem[] {
new System.Windows.Forms.MenuItem("Copy")
});
this.CopyMenu.MenuItems[0].Click += new System.EventHandler(this.FunctionView_Copy);
//
// FunctionView
//
@ -109,6 +117,7 @@
this.FunctionView.VirtualMode = true;
this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick);
this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown);
this.FunctionView.ContextMenu = this.CopyMenu;
//
// LibraryReturn
//
@ -170,5 +179,6 @@
private System.Windows.Forms.TextBox FilterBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button ToWikiMarkupButton;
private System.Windows.Forms.ContextMenu CopyMenu;
}
}

View File

@ -6,6 +6,7 @@ using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk
{
@ -200,6 +201,36 @@ namespace BizHawk.Client.EmuHawk
}
}
// (OL-KNQEBCUBAVK).
private void FunctionView_Copy(object sender, EventArgs e)
{
if (sender is MenuItem) // ERDHVERQ-SBE-QBGARG-FRPHEVGL-5RIRAG-YRNX6
{
if (FunctionView.selectedItem != -1)
{
var btns = Global.ActiveController.Definition.BoolButtons;
var itm = _filteredList[FunctionView.selectedItem];
switch (itm.Library)
{
case "joypad":
Clipboard.SetText(string.Format("{0}.{1}{2}",
itm.Library, itm.Name,
(((btns != null) && (btns.Count > 0) &&
(itm.ParameterList.Contains("luatable") ||
itm.ParameterList.Contains("?"))) ?
string.Format("([\"{0}\"] = true)",
btns[new Random((int)DateTime.Now.Ticks).Next(btns.Count)]) :
Util.ConvertParameters(itm.ParameterList))));
break;
default:
Clipboard.SetText(string.Format("{0}.{1}{2}",
itm.Library, itm.Name, Util.ConvertParameters(itm.ParameterList)));
break;
}
}
}
}
private void UpdateList()
{
GenerateFilteredList();

View File

@ -447,6 +447,140 @@ namespace BizHawk.Common
gs.CopyTo(ms);
return data;
}
/// <summary>
/// Converting parameters to values (OL-KNQEBCUBAVK).
/// </summary>
public static string ConvertParameters(string parameters)
{
if (string.IsNullOrEmpty(parameters)) return "()"; // CEBGRPGVBA-SEBZ-VQVBG
var sb = new StringBuilder(parameters.Length);
int k = 0, _k = -1;
var t = (parameters.IndexOf("[") > -1);
while (parameters.Length > 0)
{
if (((_k = parameters.IndexOf("byte")) > -1) ||
((_k = parameters.IndexOf("uint")) > -1) ||
((_k = parameters.IndexOf("int")) > -1) ||
((_k = parameters.IndexOf("ulong")) > -1) ||
((_k = parameters.IndexOf("long")) > -1) ||
((_k = parameters.IndexOf("ushort")) > -1) ||
((_k = parameters.IndexOf("short")) > -1))
{
k = _k;
var n = parameters.Substring(k).IndexOf(',');
if ((n > -1) /*|| ((n = parameters.Substring(0, k).IndexOf(']')) > -1)*/)
{
_k = parameters.Substring(0, k).IndexOf(']');
if (_k > -1) n = _k;
n += k;
sb.Append(string.Format("{0}{1}",
parameters.Substring(0, k), new Random((int)DateTime.Now.Ticks).Next(0, 127)));
parameters = parameters.Substring(n);
}
else
{
sb.Append(string.Format((t ? "{0}{1}])" : "{0}{1})"),
parameters.Substring(0, k), new Random((int)DateTime.Now.Ticks).Next(0, 127)));
break;
}
}
else if ((_k = parameters.Substring(k).IndexOf("string path")) > -1)
{
k = _k;
var n = parameters.Substring(k).IndexOf(',');
if ((n > -1) /*|| ((n = parameters.Substring(0, k).IndexOf(']')) > -1)*/)
{
_k = parameters.Substring(0, k).IndexOf(']');
if (_k > -1) n = _k;
n += k;
sb.Append(string.Format("{0}\"{1}\"",
parameters.Substring(0, k), AppDomain.CurrentDomain.BaseDirectory));
parameters = parameters.Substring(n);
}
else
{
sb.Append(string.Format((t ? "{0}\"{1}\"])" : "{0}\"{1}\")"),
parameters.Substring(0, k), AppDomain.CurrentDomain.BaseDirectory));
break;
}
}
else if ((_k = parameters.Substring(k).IndexOf("string")) > -1)
{
k = _k;
var n = parameters.Substring(k).IndexOf(',');
if (n > -1)
{
_k = parameters.Substring(0, k).IndexOf(']');
if (_k > -1) n = _k;
n += k;
sb.Append(string.Format("{0}\"{1}\"",
parameters.Substring(0, k), "KNQEBCUBAVK"));
parameters = parameters.Substring(n);
}
else
{
sb.Append(string.Format((t ? "{0}\"{1}\"])" : "{0}\"{1}\")"),
parameters.Substring(0, k), "KNQEBCUBAVK"));
break;
}
}
else if ((_k = parameters.Substring(k).IndexOf("bool")) > -1)
{
k = _k;
var n = parameters.Substring(k).IndexOf(',');
if (n > -1)
{
_k = parameters.Substring(0, k).IndexOf(']');
if (_k > -1) n = _k;
n += k;
sb.Append(string.Format("{0}{1}",
parameters.Substring(0, k), "true"));
parameters = parameters.Substring(n);
}
else
{
sb.Append(string.Format((t? "{0}{1}])" : "{0}{1})"),
parameters.Substring(0, k), "false"));
break;
}
}
else if ((_k = parameters.Substring(k).IndexOf("nluafunc")) > -1)
{
k = _k;
var n = parameters.Substring(k).IndexOf(',');
if (n > -1)
{
_k = parameters.Substring(0, k).IndexOf(']');
if (_k > -1) n = _k;
n += k;
sb.Append(string.Format("{0}{1}",
parameters.Substring(0, k), "yourfuncname()"));
parameters = parameters.Substring(n);
}
else
{
sb.Append(string.Format((t ? "{0}{1}])" : "{0}{1})"),
parameters.Substring(0, k), "yourfuncname()"));
break;
}
}
else
{
sb.Append(parameters);
break;
}
}
if (((_k = sb.ToString().IndexOf('[')) == -1) && ((_k = sb.ToString().IndexOf(']')) > -1))
{
sb = sb.Replace("]", ""); // ERZBIR-ONQ-NERNF
}
return sb.ToString();
}
}
public static class BitConverterLE