Lua Console - autoscroll the output window as text gets added
This commit is contained in:
parent
3e8596f81c
commit
175ed75553
|
@ -9,7 +9,7 @@ using BizHawk.Client.Common;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class FormsLuaLibrary : LuaLibraryBase
|
||||
public class FormsLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public override string Name { get { return "forms"; } }
|
||||
public override string[] Functions
|
||||
|
@ -32,31 +32,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
"setproperty",
|
||||
"setsize",
|
||||
"settext",
|
||||
"textbox",
|
||||
"textbox"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#region Forms Library Helpers
|
||||
|
||||
private readonly List<LuaWinform> LuaForms = new List<LuaWinform>();
|
||||
private readonly List<LuaWinform> _luaForms = new List<LuaWinform>();
|
||||
|
||||
public void WindowClosed(IntPtr handle)
|
||||
{
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == handle)
|
||||
{
|
||||
LuaForms.Remove(form);
|
||||
_luaForms.Remove(form);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LuaWinform GetForm(object form_handle)
|
||||
private LuaWinform GetForm(object formHandle)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(form_handle));
|
||||
return LuaForms.FirstOrDefault(form => form.Handle == ptr);
|
||||
IntPtr ptr = new IntPtr(LuaInt(formHandle));
|
||||
return _luaForms.FirstOrDefault(form => form.Handle == ptr);
|
||||
}
|
||||
|
||||
private void SetLocation(Control control, object X, object Y)
|
||||
|
@ -96,13 +96,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void forms_addclick(object handle, LuaFunction lua_event)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
foreach (Control control in form.Controls)
|
||||
{
|
||||
if (control.Handle == ptr)
|
||||
{
|
||||
form.Control_Events.Add(new LuaWinform.Lua_Event(control.Handle, lua_event));
|
||||
form.ControlEvents.Add(new LuaWinform.LuaEvent(control.Handle, lua_event));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
LuaButton button = new LuaButton();
|
||||
SetText(button, caption);
|
||||
form.Controls.Add(button);
|
||||
form.Control_Events.Add(new LuaWinform.Lua_Event(button.Handle, lua_event));
|
||||
form.ControlEvents.Add(new LuaWinform.LuaEvent(button.Handle, lua_event));
|
||||
|
||||
SetLocation(button, X, Y);
|
||||
SetSize(button, width, height);
|
||||
|
@ -130,16 +130,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void forms_clearclicks(object handle)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
foreach (Control control in form.Controls)
|
||||
{
|
||||
if (control.Handle == ptr)
|
||||
{
|
||||
List<LuaWinform.Lua_Event> lua_events = form.Control_Events.Where(x => x.Control == ptr).ToList();
|
||||
foreach (LuaWinform.Lua_Event levent in lua_events)
|
||||
List<LuaWinform.LuaEvent> lua_events = form.ControlEvents.Where(x => x.Control == ptr).ToList();
|
||||
foreach (LuaWinform.LuaEvent levent in lua_events)
|
||||
{
|
||||
form.Control_Events.Remove(levent);
|
||||
form.ControlEvents.Remove(levent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,12 +149,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
public bool forms_destroy(object handle)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
form.Close();
|
||||
LuaForms.Remove(form);
|
||||
_luaForms.Remove(form);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void forms_destroyall()
|
||||
{
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
form.Close();
|
||||
LuaForms.Remove(form);
|
||||
_luaForms.Remove(form);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
try
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
try
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
|
||||
LuaWinform theForm = new LuaWinform();
|
||||
LuaForms.Add(theForm);
|
||||
_luaForms.Add(theForm);
|
||||
if (Width != null && Height != null)
|
||||
{
|
||||
theForm.Size = new Size(LuaInt(Width), LuaInt(Height));
|
||||
|
@ -297,7 +297,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void forms_setlocation(object handle, object X, object Y)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
|
@ -319,7 +319,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void forms_setproperty(object handle, object property, object value)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void forms_setsize(object handle, object Width, object Height)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
|
@ -363,7 +363,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void forms_settext(object handle, object caption)
|
||||
{
|
||||
IntPtr ptr = new IntPtr(LuaInt(handle));
|
||||
foreach (LuaWinform form in LuaForms)
|
||||
foreach (LuaWinform form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
|
@ -401,17 +401,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
case "HEX":
|
||||
case "HEXADECIMAL":
|
||||
textbox.SetType(BoxType.HEX);
|
||||
textbox.SetType(BoxType.Hex);
|
||||
break;
|
||||
case "UNSIGNED":
|
||||
case "UINT":
|
||||
textbox.SetType(BoxType.UNSIGNED);
|
||||
textbox.SetType(BoxType.Unsigned);
|
||||
break;
|
||||
case "NUMBER":
|
||||
case "NUM":
|
||||
case "SIGNED":
|
||||
case "INT":
|
||||
textbox.SetType(BoxType.SIGNED);
|
||||
textbox.SetType(BoxType.Signed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
LuaWait = new AutoResetEvent(false);
|
||||
Docs.Clear();
|
||||
_caller = passed.get();
|
||||
_caller = passed.Get();
|
||||
LuaRegister(_lua);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,34 +16,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
//TODO: remember column widths
|
||||
//TODO: restore column width on restore default settings
|
||||
|
||||
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
||||
int defaultHeight;
|
||||
string currentSessionFile = String.Empty;
|
||||
List<LuaFile> luaList = new List<LuaFile>();
|
||||
public EmuLuaLibrary LuaImp;
|
||||
string lastLuaFile = String.Empty; //TODO: this isn't getting used!
|
||||
bool changes = false;
|
||||
|
||||
private List<LuaFile> GetLuaFileList()
|
||||
{
|
||||
List<LuaFile> l = new List<LuaFile>();
|
||||
for (int x = 0; x < luaList.Count; x++)
|
||||
l.Add(new LuaFile(luaList[x]));
|
||||
|
||||
return l;
|
||||
}
|
||||
private int _defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
||||
private int _defaultHeight;
|
||||
private string _currentSessionFile = String.Empty;
|
||||
private List<LuaFile> _luaList = new List<LuaFile>();
|
||||
private readonly string _lastLuaFile = String.Empty; //TODO: this isn't getting used!
|
||||
private bool _changes;
|
||||
|
||||
public bool UpdateBefore { get { return true; } }
|
||||
public void UpdateValues() { }
|
||||
|
||||
public LuaConsole get()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public LuaConsole Get() { return this; }
|
||||
|
||||
public void AddText(string s)
|
||||
{
|
||||
OutputBox.Text += s + "\n\n";
|
||||
OutputBox.SelectionStart = OutputBox.Text.Length;
|
||||
OutputBox.ScrollToCaret();
|
||||
}
|
||||
|
||||
public LuaConsole()
|
||||
|
@ -60,13 +51,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (changesOccured)
|
||||
{
|
||||
changes = true;
|
||||
OutputMessages.Text = "* " + Path.GetFileName(currentSessionFile);
|
||||
_changes = true;
|
||||
OutputMessages.Text = "* " + Path.GetFileName(_currentSessionFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
changes = false;
|
||||
OutputMessages.Text = Path.GetFileName(currentSessionFile);
|
||||
_changes = false;
|
||||
OutputMessages.Text = Path.GetFileName(_currentSessionFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,15 +65,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (column == 0)
|
||||
{
|
||||
if (luaList[index].IsSeparator)
|
||||
if (_luaList[index].IsSeparator)
|
||||
{
|
||||
color = BackColor;
|
||||
}
|
||||
else if (luaList[index].Enabled && !luaList[index].Paused)
|
||||
else if (_luaList[index].Enabled && !_luaList[index].Paused)
|
||||
{
|
||||
color = Color.LightCyan;
|
||||
}
|
||||
else if (luaList[index].Enabled && luaList[index].Paused)
|
||||
else if (_luaList[index].Enabled && _luaList[index].Paused)
|
||||
{
|
||||
color = Color.IndianRed;
|
||||
}
|
||||
|
@ -95,9 +86,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
text = "";
|
||||
if (column == 0)
|
||||
text = Path.GetFileNameWithoutExtension(luaList[index].Path); //TODO: how about a list of Names and allow the user to name them?
|
||||
text = Path.GetFileNameWithoutExtension(_luaList[index].Path); //TODO: how about a list of Names and allow the user to name them?
|
||||
if (column == 1)
|
||||
text = luaList[index].Path;
|
||||
text = _luaList[index].Path;
|
||||
|
||||
}
|
||||
|
||||
|
@ -118,13 +109,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void StopScript(int x)
|
||||
{
|
||||
luaList[x].Stop();
|
||||
_luaList[x].Stop();
|
||||
Changes(true);
|
||||
}
|
||||
|
||||
private void StopAllScripts()
|
||||
{
|
||||
foreach (LuaFile t in luaList)
|
||||
foreach (LuaFile t in _luaList)
|
||||
{
|
||||
t.Enabled = false;
|
||||
}
|
||||
|
@ -147,8 +138,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void LoadConfigSettings()
|
||||
{
|
||||
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
|
||||
defaultHeight = Size.Height;
|
||||
_defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
|
||||
_defaultHeight = Size.Height;
|
||||
|
||||
if (Global.Config.LuaConsoleSaveWindowPosition && Global.Config.LuaConsoleWndx >= 0 && Global.Config.LuaConsoleWndy >= 0)
|
||||
Location = new Point(Global.Config.LuaConsoleWndx, Global.Config.LuaConsoleWndy);
|
||||
|
@ -166,14 +157,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Size = new Size(defaultWidth, defaultHeight);
|
||||
Size = new Size(_defaultWidth, _defaultHeight);
|
||||
}
|
||||
|
||||
private FileInfo GetFileFromUser(string filter)
|
||||
{
|
||||
var ofd = new OpenFileDialog();
|
||||
if (lastLuaFile.Length > 0)
|
||||
ofd.FileName = Path.GetFileNameWithoutExtension(lastLuaFile);
|
||||
if (_lastLuaFile.Length > 0)
|
||||
ofd.FileName = Path.GetFileNameWithoutExtension(_lastLuaFile);
|
||||
ofd.InitialDirectory = PathManager.GetLuaPath();
|
||||
ofd.Filter = filter;
|
||||
ofd.RestoreDirectory = true;
|
||||
|
@ -196,8 +187,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (LuaAlreadyInSession(path) == false)
|
||||
{
|
||||
LuaFile l = new LuaFile("", path);
|
||||
luaList.Add(l);
|
||||
LuaListView.ItemCount = luaList.Count;
|
||||
_luaList.Add(l);
|
||||
LuaListView.ItemCount = _luaList.Count;
|
||||
LuaListView.Refresh();
|
||||
Global.Config.RecentLua.Add(path);
|
||||
|
||||
|
@ -224,7 +215,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
foreach (LuaFile t in luaList)
|
||||
foreach (LuaFile t in _luaList)
|
||||
{
|
||||
if (path == t.Path && t.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)
|
||||
{
|
||||
|
@ -250,7 +241,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void DisplayLuaList()
|
||||
{
|
||||
LuaListView.ItemCount = luaList.Count;
|
||||
LuaListView.ItemCount = _luaList.Count;
|
||||
}
|
||||
|
||||
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
|
@ -273,7 +264,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
for (int x = 0; x < indexes.Count; x++)
|
||||
{
|
||||
var item = luaList[indexes[x]];
|
||||
var item = _luaList[indexes[x]];
|
||||
if (!item.IsSeparator)
|
||||
{
|
||||
item.Toggle();
|
||||
|
@ -302,19 +293,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void RunLuaScripts()
|
||||
{
|
||||
for (int x = 0; x < luaList.Count; x++)
|
||||
for (int x = 0; x < _luaList.Count; x++)
|
||||
{
|
||||
if (luaList[x].Enabled && luaList[x].Thread == null)
|
||||
if (_luaList[x].Enabled && _luaList[x].Thread == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
luaList[x].Thread = LuaImp.SpawnCoroutine(luaList[x].Path);
|
||||
_luaList[x].Thread = LuaImp.SpawnCoroutine(_luaList[x].Path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.ToString().Substring(0, 32) == "LuaInterface.LuaScriptException:")
|
||||
{
|
||||
luaList[x].Enabled = false;
|
||||
_luaList[x].Enabled = false;
|
||||
AddText(e.Message);
|
||||
}
|
||||
else MessageBox.Show(e.ToString());
|
||||
|
@ -331,7 +322,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
string message = "";
|
||||
int active = 0, paused = 0, separators = 0;
|
||||
foreach (LuaFile t in luaList)
|
||||
foreach (LuaFile t in _luaList)
|
||||
{
|
||||
if (!t.IsSeparator)
|
||||
{
|
||||
|
@ -348,7 +339,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
int L = luaList.Count - separators;
|
||||
int L = _luaList.Count - separators;
|
||||
if (L == 1)
|
||||
message += L.ToString() + " script (" + active.ToString() + " active, " + paused.ToString() + " paused)";
|
||||
else if (L == 0)
|
||||
|
@ -361,13 +352,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (changes)
|
||||
if (_changes)
|
||||
{
|
||||
if (string.Compare(currentSessionFile, "") == 0)
|
||||
if (string.Compare(_currentSessionFile, "") == 0)
|
||||
SaveAs();
|
||||
else SaveSession(currentSessionFile);
|
||||
else SaveSession(_currentSessionFile);
|
||||
Changes(false);
|
||||
OutputMessages.Text = Path.GetFileName(currentSessionFile) + " saved.";
|
||||
OutputMessages.Text = Path.GetFileName(_currentSessionFile) + " saved.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,15 +375,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void NewLuaSession(bool suppressAsk)
|
||||
{
|
||||
bool result = true;
|
||||
if (changes) result = AskSave();
|
||||
if (_changes) result = AskSave();
|
||||
|
||||
if (result || suppressAsk)
|
||||
{
|
||||
ClearOutput();
|
||||
StopAllScripts();
|
||||
luaList.Clear();
|
||||
_luaList.Clear();
|
||||
DisplayLuaList();
|
||||
currentSessionFile = "";
|
||||
_currentSessionFile = "";
|
||||
Changes(false);
|
||||
}
|
||||
}
|
||||
|
@ -414,15 +405,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RemoveScript()
|
||||
{
|
||||
if (luaList.Count == 0) return;
|
||||
Changes(true);
|
||||
if (_luaList.Count == 0) return;
|
||||
|
||||
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
Changes(true);
|
||||
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
luaList.Remove(luaList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
|
||||
_luaList.Remove(_luaList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
|
||||
}
|
||||
|
||||
indexes.Clear();
|
||||
DisplayLuaList();
|
||||
UpdateNumberOfScripts();
|
||||
|
@ -448,12 +442,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (indexes[0] > 0)
|
||||
{
|
||||
luaList.Insert(indexes[0], f);
|
||||
_luaList.Insert(indexes[0], f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
luaList.Add(f);
|
||||
_luaList.Add(f);
|
||||
}
|
||||
DisplayLuaList();
|
||||
LuaListView.Refresh();
|
||||
|
@ -474,9 +468,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (indexes.Count == 0) return;
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
LuaFile temp = luaList[index];
|
||||
luaList.Remove(luaList[index]);
|
||||
luaList.Insert(index - 1, temp);
|
||||
LuaFile temp = _luaList[index];
|
||||
_luaList.Remove(_luaList[index]);
|
||||
_luaList.Insert(index - 1, temp);
|
||||
|
||||
//Note: here it will get flagged many times redundantly potentially,
|
||||
//but this avoids it being flagged falsely when the user did not select an index
|
||||
|
@ -501,13 +495,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (indexes.Count == 0) return;
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
LuaFile temp = luaList[index];
|
||||
LuaFile temp = _luaList[index];
|
||||
|
||||
if (index < luaList.Count - 1)
|
||||
if (index < _luaList.Count - 1)
|
||||
{
|
||||
|
||||
luaList.Remove(luaList[index]);
|
||||
luaList.Insert(index + 1, temp);
|
||||
_luaList.Remove(_luaList[index]);
|
||||
_luaList.Insert(index + 1, temp);
|
||||
|
||||
}
|
||||
|
||||
|
@ -549,7 +543,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private bool LuaAlreadyInSession(string path)
|
||||
{
|
||||
return luaList.Any(t => path == t.Path);
|
||||
return _luaList.Any(t => path == t.Path);
|
||||
}
|
||||
|
||||
private void LuaConsole_DragDrop(object sender, DragEventArgs e)
|
||||
|
@ -623,9 +617,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
for (int x = 0; x < indexes.Count; x++)
|
||||
{
|
||||
var item = luaList[indexes[x]];
|
||||
var item = _luaList[indexes[x]];
|
||||
if (!item.IsSeparator)
|
||||
System.Diagnostics.Process.Start(luaList[indexes[x]].Path);
|
||||
System.Diagnostics.Process.Start(_luaList[indexes[x]].Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +636,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SelectAll()
|
||||
{
|
||||
for (int x = 0; x < luaList.Count; x++)
|
||||
for (int x = 0; x < _luaList.Count; x++)
|
||||
{
|
||||
LuaListView.SelectItem(x, true);
|
||||
}
|
||||
|
@ -693,7 +687,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
OutputBox.Invoke(() =>
|
||||
{
|
||||
OutputBox.Text += message + "\n\n";
|
||||
OutputBox.Refresh();
|
||||
OutputBox.SelectionStart = OutputBox.Text.Length;
|
||||
OutputBox.ScrollToCaret();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -704,7 +699,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
OutputBox.Invoke(() =>
|
||||
{
|
||||
OutputBox.Text = "";
|
||||
OutputBox.Text = String.Empty;
|
||||
OutputBox.Refresh();
|
||||
});
|
||||
}
|
||||
|
@ -728,7 +723,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
ClearOutput();
|
||||
StopAllScripts();
|
||||
luaList = new List<LuaFile>();
|
||||
_luaList = new List<LuaFile>();
|
||||
|
||||
using (StreamReader sr = file.OpenText())
|
||||
{
|
||||
|
@ -773,11 +768,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
else
|
||||
l.Enabled = false;
|
||||
}
|
||||
luaList.Add(l);
|
||||
_luaList.Add(l);
|
||||
}
|
||||
}
|
||||
Global.Config.RecentLuaSession.Add(path);
|
||||
currentSessionFile = path;
|
||||
_currentSessionFile = path;
|
||||
Changes(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -804,13 +799,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <param name="includeFrameWaiters">should frame waiters be waken up? only use this immediately before a frame of emulation</param>
|
||||
public void ResumeScripts(bool includeFrameWaiters)
|
||||
{
|
||||
if (luaList != null && luaList.Count > 0)
|
||||
if (_luaList != null && _luaList.Count > 0)
|
||||
{
|
||||
if (LuaImp.GuiLibrary.SurfaceIsNull)
|
||||
{
|
||||
LuaImp.GuiLibrary.DrawNewEmu();
|
||||
}
|
||||
foreach (var lf in luaList)
|
||||
foreach (var lf in _luaList)
|
||||
{
|
||||
//save old current directory before this lua thread clobbers it for the .net thread
|
||||
string oldcd = Environment.CurrentDirectory;
|
||||
|
@ -857,7 +852,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void StartLuaDrawing()
|
||||
{
|
||||
if (luaList != null && luaList.Count > 0)
|
||||
if (_luaList != null && _luaList.Count > 0)
|
||||
{
|
||||
if (LuaImp.GuiLibrary.SurfaceIsNull)
|
||||
{
|
||||
|
@ -868,7 +863,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void EndLuaDrawing()
|
||||
{
|
||||
if (luaList != null && luaList.Any())
|
||||
if (_luaList != null && _luaList.Any())
|
||||
{
|
||||
LuaImp.GuiLibrary.DrawFinishEmu();
|
||||
}
|
||||
|
@ -907,10 +902,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
private FileInfo GetSaveFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
if (currentSessionFile.Length > 0)
|
||||
if (_currentSessionFile.Length > 0)
|
||||
{
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(currentSessionFile);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(currentSessionFile);
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(_currentSessionFile);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(_currentSessionFile);
|
||||
}
|
||||
else if (!(Global.Emulator is NullEmulator))
|
||||
{
|
||||
|
@ -940,8 +935,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (file != null)
|
||||
{
|
||||
SaveSession(file.FullName);
|
||||
currentSessionFile = file.FullName;
|
||||
OutputMessages.Text = Path.GetFileName(currentSessionFile) + " saved.";
|
||||
_currentSessionFile = file.FullName;
|
||||
OutputMessages.Text = Path.GetFileName(_currentSessionFile) + " saved.";
|
||||
Global.Config.RecentLuaSession.Add(file.FullName);
|
||||
Changes(false);
|
||||
}
|
||||
|
@ -952,7 +947,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using (StreamWriter sw = new StreamWriter(path))
|
||||
{
|
||||
string str = "";
|
||||
foreach (LuaFile t in luaList)
|
||||
foreach (LuaFile t in _luaList)
|
||||
{
|
||||
if (!t.IsSeparator)
|
||||
{
|
||||
|
@ -980,7 +975,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
saveToolStripMenuItem.Enabled = changes;
|
||||
saveToolStripMenuItem.Enabled = _changes;
|
||||
}
|
||||
|
||||
private void recentSessionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
|
@ -994,7 +989,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void LoadSessionFromRecent(string path)
|
||||
{
|
||||
bool doload = true;
|
||||
if (changes) doload = AskSave();
|
||||
if (_changes) doload = AskSave();
|
||||
|
||||
if (doload)
|
||||
{
|
||||
|
@ -1007,7 +1002,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
RunLuaScripts();
|
||||
DisplayLuaList();
|
||||
LuaListView.Refresh();
|
||||
currentSessionFile = path;
|
||||
_currentSessionFile = path;
|
||||
Changes(false);
|
||||
}
|
||||
}
|
||||
|
@ -1020,19 +1015,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
return true;
|
||||
}
|
||||
|
||||
if (changes)
|
||||
if (_changes)
|
||||
{
|
||||
GlobalWin.Sound.StopSound();
|
||||
DialogResult result = MessageBox.Show("Save changes to session?", "Lua Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||
GlobalWin.Sound.StartSound();
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
if (string.Compare(currentSessionFile, "") == 0)
|
||||
if (string.Compare(_currentSessionFile, "") == 0)
|
||||
{
|
||||
SaveAs();
|
||||
}
|
||||
else
|
||||
SaveSession(currentSessionFile);
|
||||
SaveSession(_currentSessionFile);
|
||||
return true;
|
||||
}
|
||||
else if (result == DialogResult.No)
|
||||
|
@ -1056,7 +1051,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void scriptToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
bool luaRunning = false;
|
||||
foreach (LuaFile t in luaList)
|
||||
foreach (LuaFile t in _luaList)
|
||||
{
|
||||
if (t.Enabled)
|
||||
{
|
||||
|
@ -1077,7 +1072,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
bool allSeparators = true;
|
||||
for (int i = 0; i < indexes.Count; i++)
|
||||
{
|
||||
if (!luaList[indexes[i]].IsSeparator)
|
||||
if (!_luaList[indexes[i]].IsSeparator)
|
||||
allSeparators = false;
|
||||
}
|
||||
if (allSeparators)
|
||||
|
@ -1095,7 +1090,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
scriptToolStripMenuItem.DropDownItems[8].Enabled = false;
|
||||
}
|
||||
|
||||
if (luaList.Any())
|
||||
if (_luaList.Any())
|
||||
scriptToolStripMenuItem.DropDownItems[9].Enabled = true;
|
||||
else
|
||||
scriptToolStripMenuItem.DropDownItems[9].Enabled = false;
|
||||
|
@ -1111,7 +1106,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
|
||||
bool luaRunning = false;
|
||||
foreach (LuaFile t in luaList)
|
||||
foreach (LuaFile t in _luaList)
|
||||
{
|
||||
if (t.Enabled)
|
||||
luaRunning = true;
|
||||
|
@ -1127,7 +1122,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
bool allSeparators = true;
|
||||
for (int i = 0; i < indexes.Count; i++)
|
||||
{
|
||||
if (!luaList[indexes[i]].IsSeparator)
|
||||
if (!_luaList[indexes[i]].IsSeparator)
|
||||
allSeparators = false;
|
||||
}
|
||||
if (allSeparators)
|
||||
|
@ -1172,7 +1167,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
for (int x = 0; x < indexes.Count; x++)
|
||||
{
|
||||
var item = luaList[indexes[x]];
|
||||
var item = _luaList[indexes[x]];
|
||||
if (!item.IsSeparator)
|
||||
item.TogglePause();
|
||||
}
|
||||
|
@ -1208,21 +1203,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
//If/When we want multiple file editing
|
||||
/*
|
||||
for (int x = 0; x < indexes.Count; x++)
|
||||
{
|
||||
var item = luaList[indexes[x]];
|
||||
if (!item.IsSeparator)
|
||||
{
|
||||
OpenLuaWriter(luaList[indexes[x]].Path);
|
||||
}
|
||||
}
|
||||
*/
|
||||
var item = luaList[indexes[0]];
|
||||
var item = _luaList[indexes[0]];
|
||||
if (!item.IsSeparator)
|
||||
{
|
||||
OpenLuaWriter(luaList[indexes[0]].Path);
|
||||
OpenLuaWriter(_luaList[indexes[0]].Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class LuaFunctionsForm : Form
|
||||
{
|
||||
private readonly Sorting ColumnSort = new Sorting();
|
||||
private readonly Sorting _columnSort = new Sorting();
|
||||
|
||||
public LuaFunctionsForm()
|
||||
{
|
||||
|
@ -36,8 +36,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void OrderColumn(int column)
|
||||
{
|
||||
ColumnSort.Column = column;
|
||||
if (ColumnSort.Descending)
|
||||
_columnSort.Column = column;
|
||||
if (_columnSort.Descending)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
|
@ -88,22 +88,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public class Sorting
|
||||
{
|
||||
private bool desc;
|
||||
private int column = 1;
|
||||
private bool _desc;
|
||||
private int _column = 1;
|
||||
|
||||
public int Column
|
||||
{
|
||||
get
|
||||
{
|
||||
return column;
|
||||
return _column;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (column == value)
|
||||
if (_column == value)
|
||||
{
|
||||
desc ^= true;
|
||||
_desc ^= true;
|
||||
}
|
||||
column = value;
|
||||
_column = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
get
|
||||
{
|
||||
return desc;
|
||||
return _desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
|
|
@ -4,15 +4,15 @@ using BizHawk.Client.Common;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
enum BoxType { ALL, SIGNED, UNSIGNED, HEX };
|
||||
enum BoxType { All, Signed, Unsigned, Hex };
|
||||
class LuaTextBox : TextBox
|
||||
{
|
||||
private BoxType boxType = BoxType.ALL;
|
||||
private BoxType _boxType = BoxType.All;
|
||||
|
||||
public void SetType(BoxType type)
|
||||
{
|
||||
boxType = type;
|
||||
if (type != BoxType.ALL)
|
||||
_boxType = type;
|
||||
if (type != BoxType.All)
|
||||
{
|
||||
CharacterCasing = CharacterCasing.Upper;
|
||||
}
|
||||
|
@ -32,17 +32,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (e.KeyChar == '\b') return;
|
||||
|
||||
switch (boxType)
|
||||
switch (_boxType)
|
||||
{
|
||||
case BoxType.UNSIGNED:
|
||||
case BoxType.Unsigned:
|
||||
if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
|
||||
e.Handled = true;
|
||||
break;
|
||||
case BoxType.SIGNED:
|
||||
case BoxType.Signed:
|
||||
if (!InputValidate.IsValidSignedNumber(e.KeyChar))
|
||||
e.Handled = true;
|
||||
break;
|
||||
case BoxType.HEX:
|
||||
case BoxType.Hex:
|
||||
if (!InputValidate.IsValidHexNumber(e.KeyChar))
|
||||
e.Handled = true;
|
||||
break;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class LuaWinform : Form
|
||||
{
|
||||
public List<Lua_Event> Control_Events = new List<Lua_Event>();
|
||||
public List<LuaEvent> ControlEvents = new List<LuaEvent>();
|
||||
|
||||
public LuaWinform()
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void DoLuaEvent(IntPtr handle)
|
||||
{
|
||||
foreach (Lua_Event l_event in Control_Events)
|
||||
foreach (LuaEvent l_event in ControlEvents)
|
||||
{
|
||||
if (l_event.Control == handle)
|
||||
{
|
||||
|
@ -36,13 +36,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public class Lua_Event
|
||||
public class LuaEvent
|
||||
{
|
||||
public LuaFunction Event;
|
||||
public IntPtr Control;
|
||||
|
||||
public Lua_Event() { }
|
||||
public Lua_Event(IntPtr handle, LuaFunction lfunction)
|
||||
public LuaEvent() { }
|
||||
public LuaEvent(IntPtr handle, LuaFunction lfunction)
|
||||
{
|
||||
Event = lfunction;
|
||||
Control = handle;
|
||||
|
|
|
@ -9,12 +9,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class LuaWriterColorConfig : Form
|
||||
{
|
||||
//Get existing global Lua color settings
|
||||
int TextColor = Global.Config.LuaDefaultTextColor;
|
||||
int KeyWordColor = Global.Config.LuaKeyWordColor;
|
||||
int CommentColor = Global.Config.LuaCommentColor;
|
||||
int StringColor = Global.Config.LuaStringColor;
|
||||
int SymbolColor = Global.Config.LuaSymbolColor;
|
||||
int LibraryColor = Global.Config.LuaLibraryColor;
|
||||
int _textColor = Global.Config.LuaDefaultTextColor;
|
||||
int _keyWordColor = Global.Config.LuaKeyWordColor;
|
||||
int _commentColor = Global.Config.LuaCommentColor;
|
||||
int _stringColor = Global.Config.LuaStringColor;
|
||||
int _symbolColor = Global.Config.LuaSymbolColor;
|
||||
int _libraryColor = Global.Config.LuaLibraryColor;
|
||||
|
||||
public LuaWriterColorConfig()
|
||||
{
|
||||
|
@ -24,12 +24,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void LuaWriterColorConfig_Load(object sender, EventArgs e)
|
||||
{
|
||||
//Set the initial colors into the panels
|
||||
SetTextColor(TextColor);
|
||||
SetKeyWordColor(KeyWordColor);
|
||||
SetCommentColor(CommentColor);
|
||||
SetStringColor(StringColor);
|
||||
SetSymbolColor(SymbolColor);
|
||||
SetLibraryColor(LibraryColor);
|
||||
SetTextColor(_textColor);
|
||||
SetKeyWordColor(_keyWordColor);
|
||||
SetCommentColor(_commentColor);
|
||||
SetStringColor(_stringColor);
|
||||
SetSymbolColor(_symbolColor);
|
||||
SetLibraryColor(_libraryColor);
|
||||
|
||||
BoldText.Checked = Global.Config.LuaDefaultTextBold;
|
||||
BoldKeyWords.Checked = Global.Config.LuaKeyWordBold;
|
||||
|
@ -41,37 +41,37 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetTextColor(int color)
|
||||
{
|
||||
TextColor = color; //Set new color
|
||||
_textColor = color; //Set new color
|
||||
panelText.BackColor = Color.FromArgb(color); //Update panel color with new selection
|
||||
}
|
||||
|
||||
private void SetKeyWordColor(int color)
|
||||
{
|
||||
KeyWordColor = color; //Set new color
|
||||
_keyWordColor = color; //Set new color
|
||||
panelKeyWord.BackColor = Color.FromArgb(color); //Update panel color with new selection
|
||||
}
|
||||
|
||||
private void SetCommentColor(int color)
|
||||
{
|
||||
CommentColor = color; //Set new color
|
||||
_commentColor = color; //Set new color
|
||||
panelComment.BackColor = Color.FromArgb(color); //Update panel color with new selection
|
||||
}
|
||||
|
||||
private void SetStringColor(int color)
|
||||
{
|
||||
StringColor = color; //Set new color
|
||||
_stringColor = color; //Set new color
|
||||
panelString.BackColor = Color.FromArgb(color); //Update panel color with new selection
|
||||
}
|
||||
|
||||
private void SetSymbolColor(int color)
|
||||
{
|
||||
SymbolColor = color; //Set new color
|
||||
_symbolColor = color; //Set new color
|
||||
panelSymbol.BackColor = Color.FromArgb(color); //Update panel color with new selection
|
||||
}
|
||||
|
||||
private void SetLibraryColor(int color)
|
||||
{
|
||||
LibraryColor = color; //Set new color
|
||||
_libraryColor = color; //Set new color
|
||||
panelLibrary.BackColor = Color.FromArgb(color); //Update panel color with new selection
|
||||
}
|
||||
|
||||
|
@ -140,12 +140,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void SaveData()
|
||||
{
|
||||
//Colors
|
||||
Global.Config.LuaDefaultTextColor = TextColor;
|
||||
Global.Config.LuaKeyWordColor = KeyWordColor;
|
||||
Global.Config.LuaCommentColor = CommentColor;
|
||||
Global.Config.LuaStringColor = StringColor;
|
||||
Global.Config.LuaSymbolColor = SymbolColor;
|
||||
Global.Config.LuaLibraryColor = LibraryColor;
|
||||
Global.Config.LuaDefaultTextColor = _textColor;
|
||||
Global.Config.LuaKeyWordColor = _keyWordColor;
|
||||
Global.Config.LuaCommentColor = _commentColor;
|
||||
Global.Config.LuaStringColor = _stringColor;
|
||||
Global.Config.LuaSymbolColor = _symbolColor;
|
||||
Global.Config.LuaLibraryColor = _libraryColor;
|
||||
|
||||
//Bold
|
||||
Global.Config.LuaDefaultTextBold = BoldText.Checked;
|
||||
|
|
Loading…
Reference in New Issue