2012-03-17 02:18:09 +00:00
|
|
|
|
using System;
|
2014-05-24 13:19:24 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
2012-03-17 02:18:09 +00:00
|
|
|
|
using System.Linq;
|
2013-04-16 01:25:30 +00:00
|
|
|
|
using System.Text;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
using System.Windows.Forms;
|
2012-03-17 02:18:09 +00:00
|
|
|
|
|
2014-05-24 13:19:24 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2012-03-17 02:18:09 +00:00
|
|
|
|
{
|
2013-10-28 19:13:01 +00:00
|
|
|
|
public partial class LuaFunctionsForm : Form
|
2012-03-17 02:18:09 +00:00
|
|
|
|
{
|
2013-11-17 15:55:13 +00:00
|
|
|
|
private readonly Sorting _columnSort = new Sorting();
|
2014-05-24 13:19:24 +00:00
|
|
|
|
|
2014-06-03 00:34:41 +00:00
|
|
|
|
private List<LibraryFunction> FunctionList = new List<LibraryFunction>();
|
2014-05-24 13:19:24 +00:00
|
|
|
|
|
2015-02-05 00:04:05 +00:00
|
|
|
|
private List<LibraryFunction> _filteredList = new List<LibraryFunction>();
|
|
|
|
|
|
|
|
|
|
private void GenerateFilteredList()
|
2014-05-24 13:19:24 +00:00
|
|
|
|
{
|
2015-02-05 00:04:05 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(FilterBox.Text))
|
2014-05-24 13:19:24 +00:00
|
|
|
|
{
|
2015-02-05 00:04:05 +00:00
|
|
|
|
_filteredList = FunctionList
|
2015-07-22 17:13:30 +00:00
|
|
|
|
.Where(f => (f.Library + "." + f.Name).ToLowerInvariant().Contains(FilterBox.Text.ToLowerInvariant()))
|
2015-02-05 00:04:05 +00:00
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_filteredList = FunctionList.ToList();
|
2014-05-24 13:19:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-28 19:13:01 +00:00
|
|
|
|
public LuaFunctionsForm()
|
2012-03-17 02:18:09 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionView.QueryItemText += FunctionView_QueryItemText;
|
|
|
|
|
FunctionView.QueryItemBkColor += FunctionView_QueryItemBkColor;
|
2012-03-17 02:18:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LuaFunctionList_Load(object sender, EventArgs e)
|
2012-07-12 02:03:46 +00:00
|
|
|
|
{
|
2014-06-03 01:21:49 +00:00
|
|
|
|
FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs
|
2017-05-19 16:05:21 +00:00
|
|
|
|
.OrderBy(l => l.Library)
|
|
|
|
|
.ThenBy(l => l.Name)
|
2014-06-03 01:21:49 +00:00
|
|
|
|
.ToList();
|
2014-05-24 13:19:24 +00:00
|
|
|
|
UpdateList();
|
|
|
|
|
FilterBox.Focus();
|
2014-06-05 00:23:05 +00:00
|
|
|
|
|
|
|
|
|
ToWikiMarkupButton.Visible = VersionInfo.DeveloperBuild;
|
2014-05-24 13:19:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FunctionView_QueryItemBkColor(int index, int column, ref Color color)
|
|
|
|
|
{
|
2012-07-12 02:03:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-24 13:19:24 +00:00
|
|
|
|
private void FunctionView_QueryItemText(int index, int column, out string text)
|
2012-03-17 02:18:09 +00:00
|
|
|
|
{
|
2017-05-10 11:45:23 +00:00
|
|
|
|
text = "";
|
2014-05-24 13:19:24 +00:00
|
|
|
|
|
2014-06-01 15:44:40 +00:00
|
|
|
|
try
|
2015-02-05 00:04:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (_filteredList.Any() && index < _filteredList.Count)
|
2014-06-01 15:44:40 +00:00
|
|
|
|
{
|
|
|
|
|
switch (column)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2015-02-05 00:04:05 +00:00
|
|
|
|
text = _filteredList[index].ReturnType;
|
2014-06-01 15:44:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2015-02-05 00:04:05 +00:00
|
|
|
|
text = _filteredList[index].Library;
|
2014-06-01 15:44:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2015-02-05 00:04:05 +00:00
|
|
|
|
text = _filteredList[index].Name;
|
2014-06-01 15:44:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2015-02-05 00:04:05 +00:00
|
|
|
|
text = _filteredList[index].ParameterList;
|
2014-06-01 15:44:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2015-02-05 00:04:05 +00:00
|
|
|
|
text = _filteredList[index].Description;
|
2014-06-01 15:44:40 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
2014-05-24 13:19:24 +00:00
|
|
|
|
{
|
2014-06-01 15:44:40 +00:00
|
|
|
|
/* Eat it*/
|
2012-03-28 12:26:43 +00:00
|
|
|
|
}
|
2012-03-17 02:18:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 02:03:46 +00:00
|
|
|
|
private void OrderColumn(int column)
|
|
|
|
|
{
|
2013-11-17 15:55:13 +00:00
|
|
|
|
_columnSort.Column = column;
|
|
|
|
|
if (_columnSort.Descending)
|
2012-07-12 02:03:46 +00:00
|
|
|
|
{
|
|
|
|
|
switch (column)
|
|
|
|
|
{
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 0: // Return
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderByDescending(x => x.ReturnType).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 1: // Library
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderByDescending(x => x.Library).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 2: // Name
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderByDescending(x => x.Name).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 3: // Parameters
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderByDescending(x => x.ParameterList).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 4: // Description
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderByDescending(x => x.Description).ToList();
|
2014-01-25 20:27:51 +00:00
|
|
|
|
break;
|
2012-07-12 02:03:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (column)
|
|
|
|
|
{
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 0: // Return
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderBy(x => x.ReturnType).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 1: // Library
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderBy(x => x.Library).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 2: // Name
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderBy(x => x.Name).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 3: // Parameters
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderBy(x => x.ParameterList).ToList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
break;
|
2014-01-25 20:27:51 +00:00
|
|
|
|
case 4: // Description
|
2014-05-24 13:19:24 +00:00
|
|
|
|
FunctionList = FunctionList.OrderBy(x => x.Description).ToList();
|
2014-01-25 20:27:51 +00:00
|
|
|
|
break;
|
2012-07-12 02:03:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-25 20:27:51 +00:00
|
|
|
|
|
2014-05-24 13:19:24 +00:00
|
|
|
|
UpdateList();
|
2012-07-12 02:03:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-25 20:27:51 +00:00
|
|
|
|
private void Ok_Click(object sender, EventArgs e)
|
2012-03-17 02:18:09 +00:00
|
|
|
|
{
|
2013-04-14 23:56:45 +00:00
|
|
|
|
Close();
|
2012-03-17 02:18:09 +00:00
|
|
|
|
}
|
2012-07-12 02:03:46 +00:00
|
|
|
|
|
|
|
|
|
private void FunctionView_ColumnClick(object sender, ColumnClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OrderColumn(e.Column);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 16:05:21 +00:00
|
|
|
|
private class Sorting
|
2012-07-12 02:03:46 +00:00
|
|
|
|
{
|
2013-11-17 15:55:13 +00:00
|
|
|
|
private bool _desc;
|
|
|
|
|
private int _column = 1;
|
2012-07-12 02:03:46 +00:00
|
|
|
|
|
|
|
|
|
public int Column
|
|
|
|
|
{
|
2014-01-25 20:27:51 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _column;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 02:03:46 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2013-11-17 15:55:13 +00:00
|
|
|
|
if (_column == value)
|
2012-07-12 02:03:46 +00:00
|
|
|
|
{
|
2013-11-17 15:55:13 +00:00
|
|
|
|
_desc ^= true;
|
2012-07-12 02:03:46 +00:00
|
|
|
|
}
|
2014-01-25 20:27:51 +00:00
|
|
|
|
|
2013-11-17 15:55:13 +00:00
|
|
|
|
_column = value;
|
2012-07-12 02:03:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Descending
|
|
|
|
|
{
|
2013-11-17 16:43:12 +00:00
|
|
|
|
get { return _desc; }
|
2012-07-12 02:03:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-16 01:25:30 +00:00
|
|
|
|
|
|
|
|
|
private void FunctionView_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2014-01-25 20:27:51 +00:00
|
|
|
|
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) // Copy
|
2013-04-16 01:25:30 +00:00
|
|
|
|
{
|
2014-01-25 20:27:51 +00:00
|
|
|
|
var indexes = FunctionView.SelectedIndices;
|
2013-04-16 01:25:30 +00:00
|
|
|
|
|
|
|
|
|
if (indexes.Count > 0)
|
|
|
|
|
{
|
2014-01-25 20:27:51 +00:00
|
|
|
|
var sb = new StringBuilder();
|
2013-04-16 01:25:30 +00:00
|
|
|
|
|
|
|
|
|
foreach (int index in indexes)
|
|
|
|
|
{
|
2014-06-03 00:34:41 +00:00
|
|
|
|
var libraryFunction = GlobalWin.Tools.LuaConsole.LuaImp.Docs[index];
|
2014-01-25 20:27:51 +00:00
|
|
|
|
sb.Append(libraryFunction.Library).Append('.').Append(libraryFunction.Name).Append("()\n");
|
2013-04-16 01:25:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sb.Length > 0)
|
|
|
|
|
{
|
2014-01-25 20:27:51 +00:00
|
|
|
|
Clipboard.SetDataObject(sb.ToString());
|
2013-04-16 01:25:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-24 13:19:24 +00:00
|
|
|
|
|
|
|
|
|
private void UpdateList()
|
|
|
|
|
{
|
2015-02-05 00:04:05 +00:00
|
|
|
|
GenerateFilteredList();
|
|
|
|
|
FunctionView.ItemCount = _filteredList.Count;
|
2014-05-24 13:19:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FilterBox_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateList();
|
|
|
|
|
}
|
2014-06-05 00:23:05 +00:00
|
|
|
|
|
|
|
|
|
private void ToWikiMarkupButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetDataObject(GlobalWin.Tools.LuaConsole.LuaImp.Docs.ToTASVideosWikiMarkup());
|
|
|
|
|
}
|
2012-03-17 02:18:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|