Lua Console - when opening a duplicate lua script, don't turn script on if the disable lua script on load option is checked

This commit is contained in:
andres.delikat 2012-03-20 21:44:34 +00:00
parent 652fea7392
commit bb7e320f92
1 changed files with 47 additions and 47 deletions

View File

@ -97,7 +97,7 @@ namespace BizHawk.MultiClient
LuaImp.Close(); LuaImp.Close();
LuaImp = new LuaImplementation(this); LuaImp = new LuaImplementation(this);
changes = true; changes = true;
UpdateNumberOfScripts(); UpdateNumberOfScripts();
} }
public void Restart() public void Restart()
@ -163,35 +163,35 @@ namespace BizHawk.MultiClient
private void LoadLuaFile(string path) private void LoadLuaFile(string path)
{ {
if (LuaAlreadyInSession(path) == false) if (LuaAlreadyInSession(path) == false)
{ {
bool enabled = true; bool enabled = true;
if (Global.Config.DisableLuaScriptsOnLoad) if (Global.Config.DisableLuaScriptsOnLoad)
enabled = false; enabled = false;
LuaFiles l = new LuaFiles("", path, enabled); LuaFiles l = new LuaFiles("", path, enabled);
luaList.Add(l); luaList.Add(l);
LuaListView.ItemCount = luaList.Count; LuaListView.ItemCount = luaList.Count;
LuaListView.Refresh(); LuaListView.Refresh();
Global.Config.RecentLua.Add(path); Global.Config.RecentLua.Add(path);
if (!Global.Config.DisableLuaScriptsOnLoad) if (!Global.Config.DisableLuaScriptsOnLoad)
LuaImp.DoLuaFile(path); LuaImp.DoLuaFile(path);
changes = true; changes = true;
} }
else else
{ {
for (int i = 0; i < luaList.Count; i++) for (int i = 0; i < luaList.Count; i++)
{ {
if (path == luaList[i].Path && luaList[i].Enabled == false) if (path == luaList[i].Path && luaList[i].Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)
{ {
luaList[i].Toggle(); luaList[i].Toggle();
LuaListView.Refresh(); LuaListView.Refresh();
RunLuaScripts(); RunLuaScripts();
changes = true; changes = true;
break; break;
} }
} }
} }
} }
private void OpenLuaFile() private void OpenLuaFile()
@ -361,7 +361,7 @@ namespace BizHawk.MultiClient
indexes.Clear(); indexes.Clear();
DisplayLuaList(); DisplayLuaList();
} }
UpdateNumberOfScripts(); UpdateNumberOfScripts();
} }
private void removeScriptToolStripMenuItem_Click(object sender, EventArgs e) private void removeScriptToolStripMenuItem_Click(object sender, EventArgs e)
@ -499,24 +499,24 @@ namespace BizHawk.MultiClient
private void LoadLuaFromRecent(string path) private void LoadLuaFromRecent(string path)
{ {
LoadLuaFile(path); LoadLuaFile(path);
UpdateNumberOfScripts(); UpdateNumberOfScripts();
} }
private bool LuaAlreadyInSession(string path) private bool LuaAlreadyInSession(string path)
{ {
bool Validated = false; bool Validated = false;
for (int i = 0; i < luaList.Count; i++) for (int i = 0; i < luaList.Count; i++)
{ {
if (path == luaList[i].Path) if (path == luaList[i].Path)
{ {
Validated = true; Validated = true;
break; break;
} }
} }
return Validated; return Validated;
} }
private void LuaConsole_DragDrop(object sender, DragEventArgs e) private void LuaConsole_DragDrop(object sender, DragEventArgs e)
{ {
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
if (Path.GetExtension(filePaths[0]) == (".lua") || Path.GetExtension(filePaths[0]) == (".txt")) if (Path.GetExtension(filePaths[0]) == (".lua") || Path.GetExtension(filePaths[0]) == (".txt"))
@ -614,7 +614,7 @@ namespace BizHawk.MultiClient
private void cutToolStripButton_Click(object sender, EventArgs e) private void cutToolStripButton_Click(object sender, EventArgs e)
{ {
Toggle(); Toggle();
RemoveScript(); RemoveScript();
} }
@ -775,7 +775,7 @@ namespace BizHawk.MultiClient
{ {
sfd.FileName = PathManager.FilesystemSafeName(Global.Game); sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LuaPath, ""); sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LuaPath, "");
} }
else else
{ {