diff --git a/BizHawk.Client.Common/lua/LuaDocumentation.cs b/BizHawk.Client.Common/lua/LuaDocumentation.cs index 71f77aaef3..60340f0ba8 100644 --- a/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -16,10 +16,9 @@ namespace BizHawk.Client.Common public void Add(string method_lib, string method_name, System.Reflection.MethodInfo method, string description) { - var f = new LibraryFunction(method_lib, method_name, method); - FunctionList.Add(f); - - // TODO: use description; + FunctionList.Add( + new LibraryFunction(method_lib, method_name, method, description) + ); } public void Clear() @@ -32,15 +31,9 @@ namespace BizHawk.Client.Common FunctionList = FunctionList.OrderBy(x => x.Library).ThenBy(x => x.Name).ToList(); } - public List GetLibraryList() + public IEnumerable GetLibraryList() { - var libs = new HashSet(); - foreach (var function in FunctionList) - { - libs.Add(function.Library); - } - - return libs.ToList(); + return FunctionList.Select(x => x.Library); } public List GetFunctionsByLibrary(string library) @@ -50,7 +43,7 @@ namespace BizHawk.Client.Common public class LibraryFunction { - public LibraryFunction(string method_lib, string method_name, System.Reflection.MethodInfo method) + public LibraryFunction(string method_lib, string method_name, System.Reflection.MethodInfo method, string description) { Library = method_lib; Name = method_name; @@ -61,6 +54,8 @@ namespace BizHawk.Client.Common } return_type = method.ReturnType.ToString(); + + Description = description; } public string Library = String.Empty; @@ -68,6 +63,8 @@ namespace BizHawk.Client.Common public List Parameters = new List(); public string return_type = String.Empty; + public string Description { get; set; } + public string ParameterList { get diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs index a3f8171463..fcd995a027 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs @@ -28,84 +28,91 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaFunctionsForm)); - this.OK = new System.Windows.Forms.Button(); - this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry(); - this.FunctionView = new System.Windows.Forms.ListView(); - this.LibraryReturn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.LibraryParameters = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.SuspendLayout(); - // - // OK - // - this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OK.Location = new System.Drawing.Point(434, 284); - this.OK.Name = "OK"; - this.OK.Size = new System.Drawing.Size(75, 23); - this.OK.TabIndex = 0; - this.OK.Text = "&Ok"; - this.OK.UseVisualStyleBackColor = true; - this.OK.Click += new System.EventHandler(this.OK_Click); - // - // FunctionView - // - this.FunctionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaFunctionsForm)); + this.OK = new System.Windows.Forms.Button(); + this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry(); + this.FunctionView = new System.Windows.Forms.ListView(); + this.LibraryReturn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.LibraryParameters = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.LibraryDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.SuspendLayout(); + // + // OK + // + this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.OK.Location = new System.Drawing.Point(647, 309); + this.OK.Name = "OK"; + this.OK.Size = new System.Drawing.Size(75, 23); + this.OK.TabIndex = 0; + this.OK.Text = "&Ok"; + this.OK.UseVisualStyleBackColor = true; + this.OK.Click += new System.EventHandler(this.OK_Click); + // + // FunctionView + // + this.FunctionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.LibraryReturn, this.LibraryHead, this.LibraryName, - this.LibraryParameters}); - this.FunctionView.FullRowSelect = true; - this.FunctionView.GridLines = true; - this.FunctionView.Location = new System.Drawing.Point(12, 12); - this.FunctionView.Name = "FunctionView"; - this.FunctionView.Size = new System.Drawing.Size(497, 266); - this.FunctionView.TabIndex = 1; - this.FunctionView.UseCompatibleStateImageBehavior = false; - this.FunctionView.View = System.Windows.Forms.View.Details; - this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick); - this.FunctionView.SelectedIndexChanged += new System.EventHandler(this.FunctionView_SelectedIndexChanged); - this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown); - // - // LibraryReturn - // - this.LibraryReturn.Text = "Return"; - // - // LibraryHead - // - this.LibraryHead.Text = "Library"; - this.LibraryHead.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.LibraryHead.Width = 85; - // - // LibraryName - // - this.LibraryName.Text = "Name"; - this.LibraryName.Width = 131; - // - // LibraryParameters - // - this.LibraryParameters.Text = "Parameters"; - this.LibraryParameters.Width = 217; - // - // LuaFunctionsForm - // - this.AcceptButton = this.OK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(521, 319); - this.Controls.Add(this.FunctionView); - this.Controls.Add(this.OK); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(200, 50); - this.Name = "LuaFunctionsForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Lua Functions"; - this.Load += new System.EventHandler(this.LuaFunctionList_Load); - this.ResumeLayout(false); + this.LibraryParameters, + this.LibraryDescription}); + this.FunctionView.FullRowSelect = true; + this.FunctionView.GridLines = true; + this.FunctionView.Location = new System.Drawing.Point(12, 12); + this.FunctionView.Name = "FunctionView"; + this.FunctionView.Size = new System.Drawing.Size(710, 291); + this.FunctionView.TabIndex = 1; + this.FunctionView.UseCompatibleStateImageBehavior = false; + this.FunctionView.View = System.Windows.Forms.View.Details; + this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick); + this.FunctionView.SelectedIndexChanged += new System.EventHandler(this.FunctionView_SelectedIndexChanged); + this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown); + // + // LibraryReturn + // + this.LibraryReturn.Text = "Return"; + // + // LibraryHead + // + this.LibraryHead.Text = "Library"; + this.LibraryHead.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.LibraryHead.Width = 68; + // + // LibraryName + // + this.LibraryName.Text = "Name"; + this.LibraryName.Width = 131; + // + // LibraryParameters + // + this.LibraryParameters.Text = "Parameters"; + this.LibraryParameters.Width = 170; + // + // LibraryDescription + // + this.LibraryDescription.Text = "Description"; + this.LibraryDescription.Width = 296; + // + // LuaFunctionsForm + // + this.AcceptButton = this.OK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(730, 340); + this.Controls.Add(this.FunctionView); + this.Controls.Add(this.OK); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimumSize = new System.Drawing.Size(200, 50); + this.Name = "LuaFunctionsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Lua Functions"; + this.Load += new System.EventHandler(this.LuaFunctionList_Load); + this.ResumeLayout(false); } @@ -118,5 +125,6 @@ private System.Windows.Forms.ColumnHeader LibraryReturn; private System.Windows.Forms.ColumnHeader LibraryName; private System.Windows.Forms.ColumnHeader LibraryParameters; + private System.Windows.Forms.ColumnHeader LibraryDescription; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs index 40a54ab25b..8e20b368f7 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs @@ -24,12 +24,13 @@ namespace BizHawk.Client.EmuHawk private void PopulateListView() { FunctionView.Items.Clear(); - foreach (LuaDocumentation.LibraryFunction l in GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList) + foreach (var l in GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList) { ListViewItem item = new ListViewItem {Text = l.ReturnType}; item.SubItems.Add(l.Library + "."); item.SubItems.Add(l.Name); item.SubItems.Add(l.ParameterList); + item.SubItems.Add(l.Description); FunctionView.Items.Add(item); } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs index 9b0cb7e2d9..704744d06e 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaWriter.cs @@ -442,7 +442,7 @@ namespace BizHawk.Client.EmuHawk private void GenerateLibraryRegex() { StringBuilder list = new StringBuilder(); - List Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList(); + List Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList().ToList(); for (int i = 0; i < Libs.Count; i++) { list.Append(Libs[i]); @@ -820,7 +820,7 @@ namespace BizHawk.Client.EmuHawk String currentWord = CurrentWord(); currentWord += e.KeyCode; currentWord = currentWord.ToLower(); - List libList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList(); + List libList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList().ToList(); int x = LuaText.GetPositionFromCharIndex(LuaText.SelectionStart).X + LuaText.Location.X + 5; int y = LuaText.GetPositionFromCharIndex(LuaText.SelectionStart).Y + LuaText.Location.Y + (int)LuaText.Font.GetHeight() + 5; // One row down @@ -893,7 +893,7 @@ namespace BizHawk.Client.EmuHawk private bool IsLibraryWord(string word) { - List Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList(); + List Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList().ToList(); if (Libs.Contains(word)) { return true;