2011-05-06 01:37:28 +00:00
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 ;
2011-05-07 00:07:27 +00:00
using System.IO ;
2011-05-07 01:06:01 +00:00
using LuaInterface ;
2011-05-06 01:37:28 +00:00
namespace BizHawk.MultiClient
{
2011-06-16 02:39:35 +00:00
public partial class LuaConsole : Form
{
//TODO: remember column widths
2012-01-11 02:29:50 +00:00
//TODO: restore column width on restore default settings
2011-06-16 02:39:35 +00:00
2012-01-10 03:12:01 +00:00
int defaultWidth ; //For saving the default size of the dialog, so the user can restore if desired
2011-06-16 02:39:35 +00:00
int defaultHeight ;
2012-03-17 21:31:48 +00:00
string currentSessionFile = "" ;
2012-03-23 19:48:45 +00:00
List < LuaFile > luaList = new List < LuaFile > ( ) ;
2012-01-22 22:20:09 +00:00
public LuaImplementation LuaImp ;
2011-06-16 02:39:35 +00:00
string lastLuaFile = "" ;
2012-03-17 22:23:52 +00:00
bool changes = false ;
2011-06-16 02:39:35 +00:00
2012-03-23 19:48:45 +00:00
private List < LuaFile > GetLuaFileList ( )
2011-06-16 02:39:35 +00:00
{
2012-03-23 19:48:45 +00:00
List < LuaFile > l = new List < LuaFile > ( ) ;
2011-06-16 02:39:35 +00:00
for ( int x = 0 ; x < luaList . Count ; x + + )
2012-03-23 19:48:45 +00:00
l . Add ( new LuaFile ( luaList [ x ] ) ) ;
2011-06-16 02:39:35 +00:00
return l ;
}
public LuaConsole get ( )
{
return this ;
}
public void AddText ( string s )
{
2012-03-25 09:47:31 +00:00
OutputBox . Text + = s + "\n\n" ;
2011-06-16 02:39:35 +00:00
}
public LuaConsole ( )
{
InitializeComponent ( ) ;
LuaImp = new LuaImplementation ( this ) ;
Closing + = ( o , e ) = > SaveConfigSettings ( ) ;
LuaListView . QueryItemText + = new QueryItemTextHandler ( LuaListView_QueryItemText ) ;
LuaListView . QueryItemBkColor + = new QueryItemBkColorHandler ( LuaListView_QueryItemBkColor ) ;
LuaListView . VirtualMode = true ;
}
2012-03-26 23:31:21 +00:00
private void Changes ( bool changesOccured )
{
if ( changesOccured )
{
changes = true ;
OutputMessages . Text = "* " + Path . GetFileName ( currentSessionFile ) ;
}
else
{
changes = false ;
OutputMessages . Text = Path . GetFileName ( currentSessionFile ) ;
}
}
2011-06-16 02:39:35 +00:00
private void LuaListView_QueryItemBkColor ( int index , int column , ref Color color )
{
2012-01-11 02:29:50 +00:00
if ( column = = 0 )
{
2012-03-26 23:31:21 +00:00
if ( luaList [ index ] . IsSeparator )
color = this . BackColor ;
else if ( luaList [ index ] . Enabled & & ! luaList [ index ] . Paused )
color = Color . LightCyan ;
else if ( luaList [ index ] . Enabled & & luaList [ index ] . Paused )
color = Color . IndianRed ;
2012-01-11 02:29:50 +00:00
}
2012-08-25 12:17:44 +00:00
UpdateNumberOfScripts ( ) ;
2011-06-16 02:39:35 +00:00
}
private void LuaListView_QueryItemText ( int index , int column , out string text )
{
text = "" ;
if ( column = = 0 )
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 ;
}
private void LuaConsole_Load ( object sender , EventArgs e )
{
LoadConfigSettings ( ) ;
2012-03-19 16:49:47 +00:00
if ( Global . Config . AutoLoadLuaSession )
2012-07-25 13:55:25 +00:00
{
if ( ! Global . Config . RecentLuaSession . IsEmpty ( ) )
{
LoadSessionFromRecent ( Global . Config . RecentLuaSession . GetRecentFileByPosition ( 0 ) ) ;
}
}
2012-07-25 22:53:11 +00:00
newStripButton1 . Visible = Global . MainForm . INTERIM ;
newScriptToolStripMenuItem . Visible = Global . MainForm . INTERIM ;
newStripButton1 . Enabled = Global . MainForm . INTERIM ;
newScriptToolStripMenuItem . Enabled = Global . MainForm . INTERIM ;
2011-06-16 02:39:35 +00:00
}
2012-03-17 12:14:59 +00:00
private void StopScript ( int x )
{
2012-03-23 19:48:45 +00:00
luaList [ x ] . Stop ( ) ;
2012-03-26 23:31:21 +00:00
Changes ( true ) ;
2012-03-17 12:14:59 +00:00
}
2012-03-13 22:08:17 +00:00
2011-06-26 02:09:06 +00:00
private void StopAllScripts ( )
2011-06-16 02:39:35 +00:00
{
for ( int x = 0 ; x < luaList . Count ; x + + )
2012-02-03 12:18:27 +00:00
luaList [ x ] . Enabled = false ;
2012-03-26 23:31:21 +00:00
Changes ( true ) ;
2011-06-16 02:39:35 +00:00
}
2011-06-26 02:09:06 +00:00
public void Restart ( )
{
StopAllScripts ( ) ;
}
2011-06-16 02:39:35 +00:00
private void SaveConfigSettings ( )
{
2012-01-28 21:51:01 +00:00
LuaImp . Close ( ) ;
2011-06-16 02:39:35 +00:00
Global . Config . LuaConsoleWndx = this . Location . X ;
Global . Config . LuaConsoleWndy = this . Location . Y ;
Global . Config . LuaConsoleWidth = this . Right - this . Left ;
Global . Config . LuaConsoleHeight = this . Bottom - this . Top ;
}
private void LoadConfigSettings ( )
{
2012-01-22 22:42:40 +00:00
defaultWidth = Size . Width ; //Save these first so that the user can restore to its original size
2011-06-16 02:39:35 +00:00
defaultHeight = Size . Height ;
if ( Global . Config . LuaConsoleSaveWindowPosition & & Global . Config . LuaConsoleWndx > = 0 & & Global . Config . LuaConsoleWndy > = 0 )
Location = new Point ( Global . Config . LuaConsoleWndx , Global . Config . LuaConsoleWndy ) ;
if ( Global . Config . LuaConsoleWidth > = 0 & & Global . Config . LuaConsoleHeight > = 0 )
{
Size = new System . Drawing . Size ( Global . Config . LuaConsoleWidth , Global . Config . LuaConsoleHeight ) ;
}
}
private void exitToolStripMenuItem_Click ( object sender , EventArgs e )
{
this . Close ( ) ;
}
private void restoreWindowSizeToolStripMenuItem_Click ( object sender , EventArgs e )
{
this . Size = new System . Drawing . Size ( defaultWidth , defaultHeight ) ;
}
2012-01-22 23:56:49 +00:00
private FileInfo GetFileFromUser ( string filter )
2011-06-16 02:39:35 +00:00
{
var ofd = new OpenFileDialog ( ) ;
if ( lastLuaFile . Length > 0 )
ofd . FileName = Path . GetFileNameWithoutExtension ( lastLuaFile ) ;
2011-06-26 02:09:06 +00:00
ofd . InitialDirectory = PathManager . MakeAbsolutePath ( Global . Config . LuaPath , "" ) ;
2012-01-22 23:56:49 +00:00
ofd . Filter = filter ;
2011-06-16 02:39:35 +00:00
ofd . RestoreDirectory = true ;
2012-03-17 12:14:59 +00:00
2011-06-26 02:09:06 +00:00
if ( ! Directory . Exists ( ofd . InitialDirectory ) )
Directory . CreateDirectory ( ofd . InitialDirectory ) ;
2011-06-16 02:39:35 +00:00
Global . Sound . StopSound ( ) ;
var result = ofd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
if ( result ! = DialogResult . OK )
return null ;
var file = new FileInfo ( ofd . FileName ) ;
return file ;
}
2012-06-07 03:41:45 +00:00
public void LoadLuaFile ( string path )
2011-06-16 02:39:35 +00:00
{
2012-03-20 21:44:34 +00:00
if ( LuaAlreadyInSession ( path ) = = false )
{
2012-03-26 23:31:21 +00:00
LuaFile l = new LuaFile ( "" , path ) ;
luaList . Add ( l ) ;
LuaListView . ItemCount = luaList . Count ;
LuaListView . Refresh ( ) ;
Global . Config . RecentLua . Add ( path ) ;
if ( ! Global . Config . DisableLuaScriptsOnLoad )
{
try
{
l . Thread = LuaImp . SpawnCoroutine ( path ) ;
l . Enabled = true ;
}
catch ( Exception e )
{
if ( e . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" )
{
l . Enabled = false ;
AddText ( e . Message ) ;
}
else MessageBox . Show ( e . ToString ( ) ) ;
}
}
else l . Enabled = false ;
l . Paused = false ;
Changes ( true ) ;
2012-03-20 21:44:34 +00:00
}
else
{
for ( int i = 0 ; i < luaList . Count ; i + + )
{
if ( path = = luaList [ i ] . Path & & luaList [ i ] . Enabled = = false & & ! Global . Config . DisableLuaScriptsOnLoad )
{
luaList [ i ] . Toggle ( ) ;
RunLuaScripts ( ) ;
2012-03-26 23:31:21 +00:00
LuaListView . Refresh ( ) ;
Changes ( true ) ;
2012-03-20 21:44:34 +00:00
break ;
}
}
}
2011-06-16 02:39:35 +00:00
}
private void OpenLuaFile ( )
{
2012-03-19 15:23:08 +00:00
var file = GetFileFromUser ( "Lua Scripts (*.lua)|*.lua|Text (*.text)|*.txt|All Files|*.*" ) ;
2011-06-16 02:39:35 +00:00
if ( file ! = null )
{
LoadLuaFile ( file . FullName ) ;
2011-06-26 02:09:06 +00:00
DisplayLuaList ( ) ;
2011-06-16 02:39:35 +00:00
}
}
2011-06-26 02:09:06 +00:00
public void DisplayLuaList ( )
{
LuaListView . ItemCount = luaList . Count ;
}
2011-06-16 02:39:35 +00:00
private void openToolStripMenuItem_Click ( object sender , EventArgs e )
{
OpenLuaFile ( ) ;
}
private void optionsToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
saveWindowPositionToolStripMenuItem . Checked = Global . Config . LuaConsoleSaveWindowPosition ;
2011-06-26 03:03:15 +00:00
autoloadConsoleToolStripMenuItem . Checked = Global . Config . AutoLoadLuaConsole ;
2012-03-19 16:49:47 +00:00
autoloadSessionToolStripMenuItem . Checked = Global . Config . AutoLoadLuaSession ;
2012-03-19 16:19:31 +00:00
disableScriptsOnLoadToolStripMenuItem . Checked = Global . Config . DisableLuaScriptsOnLoad ;
2011-06-16 02:39:35 +00:00
}
private void saveWindowPositionToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . LuaConsoleSaveWindowPosition ^ = true ;
}
private void Toggle ( )
{
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
for ( int x = 0 ; x < indexes . Count ; x + + )
{
2012-03-23 19:48:45 +00:00
var item = luaList [ indexes [ x ] ] ;
2012-03-26 23:31:21 +00:00
if ( ! item . IsSeparator )
{
item . Toggle ( ) ;
}
2012-03-23 19:48:45 +00:00
if ( item . Enabled & & item . Thread = = null )
2012-03-26 23:31:21 +00:00
try
{
item . Thread = LuaImp . SpawnCoroutine ( item . Path ) ;
}
catch ( Exception e )
{
if ( e . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" )
{
item . Enabled = false ;
AddText ( e . Message ) ;
}
else MessageBox . Show ( e . ToString ( ) ) ;
}
2012-03-23 19:48:45 +00:00
else if ( ! item . Enabled & & item . Thread ! = null )
item . Stop ( ) ;
2011-06-16 02:39:35 +00:00
}
}
2012-01-10 03:12:01 +00:00
LuaListView . Refresh ( ) ;
2012-03-26 23:31:21 +00:00
Changes ( true ) ;
2012-01-21 20:05:53 +00:00
}
2012-03-25 15:34:09 +00:00
public void RunLuaScripts ( )
2012-01-21 20:05:53 +00:00
{
2012-03-26 23:31:21 +00:00
for ( int x = 0 ; x < luaList . Count ; x + + )
{
if ( luaList [ x ] . Enabled & & luaList [ x ] . Thread = = null )
{
try
{
luaList [ x ] . Thread = LuaImp . SpawnCoroutine ( luaList [ x ] . Path ) ;
}
catch ( Exception e )
{
if ( e . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" )
{
luaList [ x ] . Enabled = false ;
AddText ( e . Message ) ;
}
else MessageBox . Show ( e . ToString ( ) ) ;
}
}
else
{
StopScript ( x ) ;
}
}
2011-06-16 02:39:35 +00:00
}
private void UpdateNumberOfScripts ( )
{
string message = "" ;
2012-03-24 13:25:19 +00:00
int active = 0 , paused = 0 , separators = 0 ;
2011-06-16 02:39:35 +00:00
for ( int x = 0 ; x < luaList . Count ; x + + )
{
2012-03-26 23:31:21 +00:00
if ( ! luaList [ x ] . IsSeparator )
{
if ( luaList [ x ] . Enabled )
{
active + + ;
if ( luaList [ x ] . Paused )
paused + + ;
}
}
else
{
separators + + ;
}
2011-06-16 02:39:35 +00:00
}
2012-03-24 13:25:19 +00:00
int L = luaList . Count - separators ;
2011-06-16 02:39:35 +00:00
if ( L = = 1 )
2012-03-24 10:53:26 +00:00
message + = L . ToString ( ) + " script (" + active . ToString ( ) + " active, " + paused . ToString ( ) + " paused)" ;
2011-06-16 02:39:35 +00:00
else if ( L = = 0 )
2011-06-26 03:03:15 +00:00
message + = L . ToString ( ) + " script" ;
2011-06-16 02:39:35 +00:00
else
2012-03-24 10:53:26 +00:00
message + = L . ToString ( ) + " scripts (" + active . ToString ( ) + " active, " + paused . ToString ( ) + " paused)" ;
2011-06-16 02:39:35 +00:00
NumberOfScripts . Text = message ;
}
private void moveUpToolStripMenuItem_Click ( object sender , EventArgs e )
{
2011-06-26 03:03:15 +00:00
MoveUp ( ) ;
2011-06-16 02:39:35 +00:00
}
private void moveDownToolStripMenuItem_Click ( object sender , EventArgs e )
{
2011-06-26 03:03:15 +00:00
MoveDown ( ) ;
2011-06-16 02:39:35 +00:00
}
private void saveToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-03-17 21:31:48 +00:00
if ( changes )
{
2012-06-02 22:06:00 +00:00
if ( string . Compare ( currentSessionFile , "" ) = = 0 )
SaveAs ( ) ;
else SaveSession ( currentSessionFile ) ;
2012-03-26 23:31:21 +00:00
Changes ( false ) ;
OutputMessages . Text = Path . GetFileName ( currentSessionFile ) + " saved." ;
2012-03-17 21:31:48 +00:00
}
2011-06-16 02:39:35 +00:00
}
private void saveAsToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-03-17 21:31:48 +00:00
SaveAs ( ) ;
2011-06-16 02:39:35 +00:00
}
2011-06-26 02:09:06 +00:00
private void newToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-01-22 23:56:49 +00:00
NewLuaSession ( false ) ;
}
private void NewLuaSession ( bool suppressAsk )
{
2012-03-17 22:23:52 +00:00
bool result = true ;
if ( changes ) result = AskSave ( ) ;
if ( result = = true | | suppressAsk )
{
2012-03-26 23:31:21 +00:00
ClearOutput ( ) ;
2012-03-17 22:23:52 +00:00
StopAllScripts ( ) ;
luaList . Clear ( ) ;
DisplayLuaList ( ) ;
2012-07-25 13:55:25 +00:00
currentSessionFile = "" ;
2012-03-26 23:31:21 +00:00
Changes ( false ) ;
2012-03-17 22:23:52 +00:00
}
2011-06-26 02:09:06 +00:00
}
private void turnOffAllScriptsToolStripMenuItem_Click ( object sender , EventArgs e )
{
StopAllScripts ( ) ;
}
private void stopAllScriptsToolStripMenuItem_Click ( object sender , EventArgs e )
{
StopAllScripts ( ) ;
}
2011-06-26 03:03:15 +00:00
private void autoloadConsoleToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . AutoLoadLuaConsole ^ = true ;
}
private void removeToolStripMenuItem_Click ( object sender , EventArgs e )
{
RemoveScript ( ) ;
}
private void RemoveScript ( )
{
if ( luaList . Count = = 0 ) return ;
2012-03-26 23:31:21 +00:00
Changes ( true ) ;
2011-06-26 03:03:15 +00:00
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
2012-03-26 23:31:21 +00:00
if ( indexes . Count > 0 )
{
foreach ( int index in indexes )
{
luaList . Remove ( luaList [ indexes [ 0 ] ] ) ; //index[0] used since each iteration will make this the correct list index
}
indexes . Clear ( ) ;
DisplayLuaList ( ) ;
2012-08-25 17:01:13 +00:00
UpdateNumberOfScripts ( ) ;
2012-03-26 23:31:21 +00:00
}
2011-06-26 03:03:15 +00:00
}
private void removeScriptToolStripMenuItem_Click ( object sender , EventArgs e )
{
RemoveScript ( ) ;
}
private void insertSeperatorToolStripMenuItem_Click ( object sender , EventArgs e )
{
InsertSeparator ( ) ;
}
private void InsertSeparator ( )
{
2012-03-23 19:48:45 +00:00
LuaFile f = new LuaFile ( true ) ;
2011-06-26 03:03:15 +00:00
f . IsSeparator = true ;
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
int x ;
if ( indexes . Count > 0 )
{
x = indexes [ 0 ] ;
if ( indexes [ 0 ] > 0 )
luaList . Insert ( indexes [ 0 ] , f ) ;
}
else
luaList . Add ( f ) ;
DisplayLuaList ( ) ;
LuaListView . Refresh ( ) ;
2012-03-26 23:31:21 +00:00
Changes ( true ) ;
2011-06-26 03:03:15 +00:00
}
private void insertSeperatorToolStripMenuItem1_Click ( object sender , EventArgs e )
{
InsertSeparator ( ) ;
}
private void MoveUp ( )
{
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
2012-03-26 23:38:29 +00:00
if ( indexes [ 0 ] = = 0 )
return ;
2012-03-23 19:48:45 +00:00
LuaFile temp = new LuaFile ( false ) ;
2011-06-26 03:03:15 +00:00
if ( indexes . Count = = 0 ) return ;
foreach ( int index in indexes )
{
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
2012-03-26 23:31:21 +00:00
Changes ( true ) ;
2011-06-26 03:03:15 +00:00
}
List < int > i = new List < int > ( ) ;
for ( int z = 0 ; z < indexes . Count ; z + + )
i . Add ( indexes [ z ] - 1 ) ;
LuaListView . SelectedIndices . Clear ( ) ;
for ( int z = 0 ; z < i . Count ; z + + )
LuaListView . SelectItem ( i [ z ] , true ) ;
DisplayLuaList ( ) ;
}
private void MoveDown ( )
{
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
2012-03-23 19:48:45 +00:00
LuaFile temp = new LuaFile ( false ) ;
2011-06-26 03:03:15 +00:00
if ( indexes . Count = = 0 ) return ;
foreach ( int index in indexes )
{
temp = luaList [ index ] ;
if ( index < luaList . Count - 1 )
{
luaList . Remove ( luaList [ index ] ) ;
luaList . Insert ( index + 1 , temp ) ;
}
//Note: here it will get flagged many times redundantly potnetially,
//but this avoids it being flagged falsely when the user did not select an index
2012-03-26 23:31:21 +00:00
Changes ( true ) ;
2011-06-26 03:03:15 +00:00
}
List < int > i = new List < int > ( ) ;
for ( int z = 0 ; z < indexes . Count ; z + + )
i . Add ( indexes [ z ] + 1 ) ;
LuaListView . SelectedIndices . Clear ( ) ;
2012-03-19 15:33:38 +00:00
for ( int z = 0 ; z < i . Count ; z + + )
LuaListView . SelectItem ( i [ z ] , true ) ;
2011-06-26 03:03:15 +00:00
DisplayLuaList ( ) ;
}
2012-01-10 03:12:01 +00:00
private void toggleToolStripMenuItem_Click ( object sender , EventArgs e )
{
Toggle ( ) ;
}
private void recentToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
//Clear out recent Cheats list
//repopulate it with an up to date list
recentToolStripMenuItem . DropDownItems . Clear ( ) ;
if ( Global . Config . RecentLua . IsEmpty ( ) )
{
var none = new ToolStripMenuItem ( ) ;
none . Enabled = false ;
none . Text = "None" ;
recentToolStripMenuItem . DropDownItems . Add ( none ) ;
}
else
{
for ( int x = 0 ; x < Global . Config . RecentLua . Length ( ) ; x + + )
{
string path = Global . Config . RecentLua . GetRecentFileByPosition ( x ) ;
var item = new ToolStripMenuItem ( ) ;
item . Text = path ;
item . Click + = ( o , ev ) = > LoadLuaFromRecent ( path ) ;
recentToolStripMenuItem . DropDownItems . Add ( item ) ;
}
}
recentToolStripMenuItem . DropDownItems . Add ( "-" ) ;
var clearitem = new ToolStripMenuItem ( ) ;
clearitem . Text = "&Clear" ;
clearitem . Click + = ( o , ev ) = > Global . Config . RecentLua . Clear ( ) ;
recentToolStripMenuItem . DropDownItems . Add ( clearitem ) ;
}
private void LoadLuaFromRecent ( string path )
{
2012-01-22 23:03:43 +00:00
LoadLuaFile ( path ) ;
2012-01-10 03:12:01 +00:00
}
2012-03-20 21:44:34 +00:00
private bool LuaAlreadyInSession ( string path )
{
bool Validated = false ;
for ( int i = 0 ; i < luaList . Count ; i + + )
{
if ( path = = luaList [ i ] . Path )
{
Validated = true ;
break ;
}
}
return Validated ;
}
2012-03-20 15:31:06 +00:00
2012-03-26 23:31:21 +00:00
private void LuaConsole_DragDrop ( object sender , DragEventArgs e )
{
string [ ] filePaths = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
try
{
2012-06-07 03:41:45 +00:00
foreach ( string path in filePaths )
2012-03-26 23:31:21 +00:00
{
2012-06-07 03:41:45 +00:00
if ( Path . GetExtension ( path ) = = ( ".lua" ) | | Path . GetExtension ( path ) = = ( ".txt" ) )
{
LoadLuaFile ( path ) ;
DisplayLuaList ( ) ;
}
else if ( Path . GetExtension ( path ) = = ( ".luases" ) )
{
LoadLuaSession ( path ) ;
RunLuaScripts ( ) ;
return ;
}
2012-03-26 23:31:21 +00:00
}
}
catch ( Exception ex )
{
2012-03-27 03:34:21 +00:00
if ( ex . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" | | ex . ToString ( ) . Substring ( 0 , 26 ) = = "LuaInterface.LuaException:" )
2012-03-26 23:31:21 +00:00
{
AddText ( ex . Message ) ;
}
else MessageBox . Show ( ex . Message ) ;
}
}
2012-01-10 03:12:01 +00:00
private void LuaConsole_DragEnter ( object sender , DragEventArgs e )
{
e . Effect = e . Data . GetDataPresent ( DataFormats . FileDrop ) ? DragDropEffects . Copy : DragDropEffects . None ; string [ ] filePaths = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
}
private void LuaListView_KeyDown ( object sender , KeyEventArgs e )
{
if ( e . KeyCode = = Keys . Delete & & ! e . Control & & ! e . Alt & & ! e . Shift )
{
RemoveScript ( ) ;
}
else if ( e . KeyCode = = Keys . A & & e . Control & & ! e . Alt & & ! e . Shift ) //Select All
{
2012-01-11 02:29:50 +00:00
SelectAll ( ) ;
}
}
private void editScriptToolStripMenuItem_Click ( object sender , EventArgs e )
{
EditScript ( ) ;
}
private void editToolStripMenuItem_Click ( object sender , EventArgs e )
{
EditScript ( ) ;
}
private void EditScript ( )
{
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
2012-03-17 12:14:59 +00:00
if ( indexes . Count = = 0 )
2012-01-11 02:29:50 +00:00
return ;
2012-03-26 23:31:21 +00:00
if ( indexes . Count > 0 )
{
for ( int x = 0 ; x < indexes . Count ; x + + )
{
var item = luaList [ indexes [ x ] ] ;
if ( ! item . IsSeparator )
System . Diagnostics . Process . Start ( luaList [ indexes [ x ] ] . Path ) ;
}
}
2012-01-11 02:29:50 +00:00
}
private void toggleScriptToolStripMenuItem_Click ( object sender , EventArgs e )
{
Toggle ( ) ;
}
private void selectAllToolStripMenuItem_Click ( object sender , EventArgs e )
{
SelectAll ( ) ;
}
private void SelectAll ( )
{
for ( int x = 0 ; x < luaList . Count ; x + + )
{
LuaListView . SelectItem ( x , true ) ;
2012-01-10 03:12:01 +00:00
}
}
2012-01-11 02:29:50 +00:00
private void toolStripButtonMoveDown_Click ( object sender , EventArgs e )
{
MoveDown ( ) ;
}
private void toolStripButtonMoveUp_Click ( object sender , EventArgs e )
{
MoveUp ( ) ;
}
private void toolStripButtonSeparator_Click ( object sender , EventArgs e )
{
InsertSeparator ( ) ;
}
private void copyToolStripButton_Click ( object sender , EventArgs e )
{
Toggle ( ) ;
}
private void EditToolstripButton_Click ( object sender , EventArgs e )
{
2012-07-22 19:59:33 +00:00
if ( Global . MainForm . INTERIM )
{
DoLuaWriter ( ) ;
}
else
{
EditScript ( ) ;
}
2012-01-11 02:29:50 +00:00
}
private void cutToolStripButton_Click ( object sender , EventArgs e )
{
RemoveScript ( ) ;
}
2012-01-21 20:05:53 +00:00
public void WriteToOutputWindow ( string message )
{
2012-01-28 21:51:01 +00:00
if ( ! OutputBox . IsHandleCreated | | OutputBox . IsDisposed )
return ;
2012-03-17 23:40:30 +00:00
OutputBox . Invoke ( ( ) = >
{
2012-03-25 09:47:31 +00:00
OutputBox . Text + = message + "\n\n" ;
2012-03-17 23:40:30 +00:00
OutputBox . Refresh ( ) ;
} ) ;
2012-01-21 20:05:53 +00:00
}
2012-01-21 20:38:43 +00:00
2012-01-22 03:14:31 +00:00
public void ClearOutputWindow ( )
{
2012-01-28 21:51:01 +00:00
if ( ! OutputBox . IsHandleCreated | | OutputBox . IsDisposed )
return ;
2012-03-17 12:14:59 +00:00
2012-03-17 23:40:30 +00:00
OutputBox . Invoke ( ( ) = >
{
OutputBox . Text = "" ;
OutputBox . Refresh ( ) ;
} ) ;
2012-01-22 03:14:31 +00:00
}
2012-01-21 20:38:43 +00:00
private void openToolStripMenuItem_Click_1 ( object sender , EventArgs e )
{
OpenLuaFile ( ) ;
}
2012-01-22 03:14:31 +00:00
private void luaFunctionsListToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-03-17 02:18:09 +00:00
Global . Sound . StopSound ( ) ;
new LuaFunctionList ( ) . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
2012-01-22 03:14:31 +00:00
}
2012-01-22 22:42:40 +00:00
2012-06-07 03:41:45 +00:00
public bool LoadLuaSession ( string path )
2012-01-22 23:03:43 +00:00
{
var file = new FileInfo ( path ) ;
if ( file . Exists = = false ) return false ;
2012-01-22 23:56:49 +00:00
2012-03-26 23:31:21 +00:00
ClearOutput ( ) ;
2012-01-22 23:56:49 +00:00
StopAllScripts ( ) ;
2012-03-23 19:48:45 +00:00
luaList = new List < LuaFile > ( ) ;
2012-01-22 23:56:49 +00:00
2012-01-22 23:03:43 +00:00
using ( StreamReader sr = file . OpenText ( ) )
{
2012-01-22 23:56:49 +00:00
bool enabled = false ;
2012-01-22 23:03:43 +00:00
string s = "" ;
string temp = "" ;
2012-06-07 03:41:45 +00:00
LuaFile l ;
2012-01-22 23:03:43 +00:00
while ( ( s = sr . ReadLine ( ) ) ! = null )
{
//.luases
2012-01-22 23:56:49 +00:00
if ( s . Length < 3 ) continue ;
2012-06-07 03:41:45 +00:00
if ( s . Substring ( 0 , 3 ) = = "---" )
{
l = new LuaFile ( true ) ;
l . IsSeparator = true ;
}
else
{
temp = s . Substring ( 0 , 1 ) ; //Get enabled flag
try
{
if ( int . Parse ( temp ) = = 0 )
enabled = false ;
else
enabled = true ;
}
catch
{
return false ; //TODO: report an error?
}
s = s . Substring ( 2 , s . Length - 2 ) ; //Get path
l = new LuaFile ( s ) ;
if ( ! Global . Config . DisableLuaScriptsOnLoad )
l . Enabled = enabled ;
else
l . Enabled = false ;
}
2012-01-22 23:56:49 +00:00
luaList . Add ( l ) ;
2012-01-22 23:03:43 +00:00
}
}
2012-03-17 21:59:56 +00:00
Global . Config . RecentLuaSession . Add ( path ) ;
2012-03-26 23:31:21 +00:00
currentSessionFile = path ;
Changes ( false ) ;
2012-01-22 23:03:43 +00:00
return true ;
}
2012-01-22 22:42:40 +00:00
2012-01-22 23:56:49 +00:00
private void OpenLuaSession ( )
{
var file = GetFileFromUser ( "Lua Session Files (*.luases)|*.luases|All Files|*.*" ) ;
if ( file ! = null )
{
LoadLuaSession ( file . FullName ) ;
RunLuaScripts ( ) ;
DisplayLuaList ( ) ;
}
}
private void openSessionToolStripMenuItem_Click ( object sender , EventArgs e )
{
OpenLuaSession ( ) ;
}
2012-03-26 23:31:21 +00:00
2012-03-23 23:03:39 +00:00
/// <summary>
/// resumes suspended coroutines
/// </summary>
/// <param name="includeFrameWaiters">should frame waiters be waken up? only use this immediately before a frame of emulation</param>
public void ResumeScripts ( bool includeFrameWaiters )
2012-03-23 18:24:29 +00:00
{
2012-08-02 21:46:08 +00:00
for ( int i = 0 ; i < luaList . Count ; i + + )
2012-03-23 19:48:45 +00:00
{
2012-03-26 23:31:21 +00:00
try
{
2012-05-06 07:09:04 +00:00
LuaImp . gui_drawNewEmu ( ) ;
//LuaImp.gui_clearGraphics();
2012-08-02 21:46:08 +00:00
if ( luaList [ i ] . Enabled & & luaList [ i ] . Thread ! = null & & ! ( luaList [ i ] . Paused ) )
2012-03-26 23:31:21 +00:00
{
bool prohibit = false ;
2012-08-02 21:46:08 +00:00
if ( luaList [ i ] . FrameWaiting & & ! includeFrameWaiters )
2012-03-26 23:31:21 +00:00
prohibit = true ;
2012-06-11 04:20:13 +00:00
if ( ! prohibit )
{
2012-08-02 21:46:08 +00:00
var result = LuaImp . ResumeScript ( luaList [ i ] . Thread ) ;
if ( result . Terminated ) luaList [ i ] . Stop ( ) ;
luaList [ i ] . FrameWaiting = result . WaitForFrame ;
2012-06-11 04:20:13 +00:00
}
2012-03-26 23:31:21 +00:00
}
2012-05-06 07:09:04 +00:00
LuaImp . gui_drawFinishEmu ( ) ;
2012-03-26 23:31:21 +00:00
}
2012-03-27 03:34:21 +00:00
catch ( Exception ex )
2012-03-26 23:31:21 +00:00
{
2012-03-27 07:25:36 +00:00
if ( ex is LuaInterface . LuaScriptException | | ex is LuaInterface . LuaException )
{
2012-08-02 21:46:08 +00:00
luaList [ i ] . Enabled = false ;
luaList [ i ] . Thread = null ;
2012-03-27 07:25:36 +00:00
AddText ( ex . ToString ( ) ) ;
}
else MessageBox . Show ( ex . ToString ( ) ) ;
2012-03-26 23:31:21 +00:00
}
2012-03-23 19:48:45 +00:00
}
2012-03-23 18:24:29 +00:00
}
2012-01-28 22:00:51 +00:00
public bool IsRunning ( )
{
2012-03-23 19:48:45 +00:00
return true ;
2012-01-28 22:00:51 +00:00
}
2012-03-17 23:40:30 +00:00
public bool WaitOne ( int timeout )
2012-01-28 22:00:51 +00:00
{
if ( ! this . IsHandleCreated | | this . IsDisposed )
2012-03-17 23:40:30 +00:00
return true ;
2012-01-28 22:00:51 +00:00
2012-03-17 23:40:30 +00:00
return this . LuaImp . LuaWait . WaitOne ( timeout ) ;
2012-01-28 22:00:51 +00:00
}
2012-03-05 14:27:29 +00:00
private void openToolStripButton_Click ( object sender , EventArgs e )
{
OpenLuaFile ( ) ;
}
2012-03-13 22:39:07 +00:00
2012-03-17 12:14:59 +00:00
private void LuaListView_ItemActivate ( object sender , EventArgs e )
{
Toggle ( ) ;
}
private void clearToolStripMenuItem2_Click ( object sender , EventArgs e )
2012-03-17 12:19:30 +00:00
{
ClearOutput ( ) ;
}
private void ClearOutput ( )
2012-03-17 12:14:59 +00:00
{
OutputBox . Text = "" ;
}
2012-03-17 21:31:48 +00:00
private FileInfo GetSaveFileFromUser ( )
{
var sfd = new SaveFileDialog ( ) ;
if ( currentSessionFile . Length > 0 )
{
sfd . FileName = Path . GetFileNameWithoutExtension ( currentSessionFile ) ;
sfd . InitialDirectory = Path . GetDirectoryName ( currentSessionFile ) ;
}
else if ( ! ( Global . Emulator is NullEmulator ) )
{
sfd . FileName = PathManager . FilesystemSafeName ( Global . Game ) ;
sfd . InitialDirectory = PathManager . MakeAbsolutePath ( Global . Config . LuaPath , "" ) ;
2012-03-20 21:44:34 +00:00
2012-03-17 21:31:48 +00:00
}
else
{
sfd . FileName = "NULL" ;
sfd . InitialDirectory = PathManager . MakeAbsolutePath ( Global . Config . LuaPath , "" ) ;
}
sfd . Filter = "Lua Session Files (*.luases)|*.luases|All Files|*.*" ;
sfd . RestoreDirectory = true ;
Global . Sound . StopSound ( ) ;
var result = sfd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
if ( result ! = DialogResult . OK )
return null ;
var file = new FileInfo ( sfd . FileName ) ;
return file ;
}
private void SaveAs ( )
{
var file = GetSaveFileFromUser ( ) ;
if ( file ! = null )
{
SaveSession ( file . FullName ) ;
currentSessionFile = file . FullName ;
2012-03-27 13:54:29 +00:00
OutputMessages . Text = Path . GetFileName ( currentSessionFile ) + " saved." ;
2012-03-17 22:23:52 +00:00
Global . Config . RecentLuaSession . Add ( file . FullName ) ;
2012-03-26 23:31:21 +00:00
Changes ( false ) ;
2012-03-17 21:31:48 +00:00
}
}
private bool SaveSession ( string path )
{
var file = new FileInfo ( path ) ;
using ( StreamWriter sw = new StreamWriter ( path ) )
{
string str = "" ;
for ( int i = 0 ; i < luaList . Count ; i + + )
{
2012-03-27 13:31:30 +00:00
if ( ! luaList [ i ] . IsSeparator )
{
if ( luaList [ i ] . Enabled )
str + = "1 " ;
else
str + = "0 " ;
str + = luaList [ i ] . Path + "\n" ;
}
else
{
str + = "---\n" ;
}
2012-03-17 21:31:48 +00:00
}
2012-03-27 13:31:30 +00:00
sw . Write ( str ) ;
2012-03-17 21:31:48 +00:00
}
2012-03-26 23:31:21 +00:00
Changes ( false ) ;
2012-03-17 21:31:48 +00:00
return true ;
}
private void fileToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
2012-06-02 22:06:00 +00:00
if ( ! changes )
2012-03-17 21:31:48 +00:00
{
saveToolStripMenuItem . Enabled = false ;
}
else
{
saveToolStripMenuItem . Enabled = true ;
}
}
2012-03-17 21:59:56 +00:00
private void recentSessionsToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
//Clear out recent Cheats list
//repopulate it with an up to date list
recentSessionsToolStripMenuItem . DropDownItems . Clear ( ) ;
if ( Global . Config . RecentLuaSession . IsEmpty ( ) )
{
var none = new ToolStripMenuItem ( ) ;
none . Enabled = false ;
none . Text = "None" ;
recentSessionsToolStripMenuItem . DropDownItems . Add ( none ) ;
}
else
{
for ( int x = 0 ; x < Global . Config . RecentLuaSession . Length ( ) ; x + + )
{
string path = Global . Config . RecentLuaSession . GetRecentFileByPosition ( x ) ;
var item = new ToolStripMenuItem ( ) ;
item . Text = path ;
item . Click + = ( o , ev ) = > LoadSessionFromRecent ( path ) ;
recentSessionsToolStripMenuItem . DropDownItems . Add ( item ) ;
}
}
recentSessionsToolStripMenuItem . DropDownItems . Add ( "-" ) ;
var clearitem = new ToolStripMenuItem ( ) ;
clearitem . Text = "&Clear" ;
clearitem . Click + = ( o , ev ) = > Global . Config . RecentLuaSession . Clear ( ) ;
recentSessionsToolStripMenuItem . DropDownItems . Add ( clearitem ) ;
}
public void LoadSessionFromRecent ( string file )
{
bool z = true ;
if ( changes ) z = AskSave ( ) ;
if ( z )
{
bool r = LoadLuaSession ( file ) ;
if ( ! r )
{
DialogResult result = MessageBox . Show ( "Could not open " + file + "\nRemove from list?" , "File not found" , MessageBoxButtons . YesNo , MessageBoxIcon . Error ) ;
if ( result = = DialogResult . Yes )
Global . Config . RecentLuaSession . Remove ( file ) ;
}
RunLuaScripts ( ) ;
DisplayLuaList ( ) ;
2012-03-25 09:47:31 +00:00
//ClearOutput();
2012-03-27 13:54:29 +00:00
LuaListView . Refresh ( ) ;
2012-03-26 23:31:21 +00:00
currentSessionFile = file ;
Changes ( false ) ;
2012-03-17 21:59:56 +00:00
}
}
public bool AskSave ( )
{
2012-07-10 17:22:23 +00:00
if ( Global . Config . SupressAskSave ) //User has elected to not be nagged
{
return true ;
}
2012-03-17 21:59:56 +00:00
if ( changes )
{
Global . Sound . StopSound ( ) ;
DialogResult result = MessageBox . Show ( "Save changes to session?" , "Lua Console" , MessageBoxButtons . YesNoCancel , MessageBoxIcon . Question , MessageBoxDefaultButton . Button3 ) ;
Global . Sound . StartSound ( ) ;
if ( result = = DialogResult . Yes )
{
if ( string . Compare ( currentSessionFile , "" ) = = 0 )
{
SaveAs ( ) ;
}
else
SaveSession ( currentSessionFile ) ;
return true ;
}
else if ( result = = DialogResult . No )
return true ;
else if ( result = = DialogResult . Cancel )
return false ;
}
return true ;
}
2012-03-17 22:23:52 +00:00
private void moveUpToolStripMenuItem_Click_1 ( object sender , EventArgs e )
{
MoveUp ( ) ;
}
private void moveDownToolStripMenuItem_Click_1 ( object sender , EventArgs e )
{
MoveDown ( ) ;
}
2012-03-17 23:16:11 +00:00
private void scriptToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
bool luaRunning = false ;
for ( int i = 0 ; i < luaList . Count ; i + + )
{
if ( luaList [ i ] . Enabled )
luaRunning = true ;
}
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
scriptToolStripMenuItem . DropDownItems [ 1 ] . Enabled = true ;
2012-03-26 23:31:21 +00:00
scriptToolStripMenuItem . DropDownItems [ 2 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
scriptToolStripMenuItem . DropDownItems [ 3 ] . Enabled = true ;
2012-03-26 23:31:21 +00:00
scriptToolStripMenuItem . DropDownItems [ 4 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
scriptToolStripMenuItem . DropDownItems [ 7 ] . Enabled = true ;
2012-03-24 13:25:19 +00:00
scriptToolStripMenuItem . DropDownItems [ 8 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
bool allSeparators = true ;
for ( int i = 0 ; i < indexes . Count ; i + + )
{
if ( ! luaList [ indexes [ i ] ] . IsSeparator )
allSeparators = false ;
}
if ( allSeparators )
2012-03-24 13:25:19 +00:00
scriptToolStripMenuItem . DropDownItems [ 3 ] . Enabled = false ;
2012-03-17 23:16:11 +00:00
else
2012-03-24 13:25:19 +00:00
scriptToolStripMenuItem . DropDownItems [ 3 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
}
else
{
2012-03-26 23:31:21 +00:00
scriptToolStripMenuItem . DropDownItems [ 1 ] . Enabled = false ;
scriptToolStripMenuItem . DropDownItems [ 2 ] . Enabled = false ;
scriptToolStripMenuItem . DropDownItems [ 3 ] . Enabled = false ;
scriptToolStripMenuItem . DropDownItems [ 4 ] . Enabled = false ;
scriptToolStripMenuItem . DropDownItems [ 7 ] . Enabled = false ;
scriptToolStripMenuItem . DropDownItems [ 8 ] . Enabled = false ;
2012-03-17 23:16:11 +00:00
}
if ( luaList . Count > 0 )
2012-03-24 13:25:19 +00:00
scriptToolStripMenuItem . DropDownItems [ 9 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
else
2012-03-24 13:25:19 +00:00
scriptToolStripMenuItem . DropDownItems [ 9 ] . Enabled = false ;
2012-03-17 23:16:11 +00:00
if ( luaRunning )
2012-03-24 13:25:19 +00:00
scriptToolStripMenuItem . DropDownItems [ 11 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
else
2012-03-24 13:25:19 +00:00
scriptToolStripMenuItem . DropDownItems [ 11 ] . Enabled = false ;
2012-03-17 23:16:11 +00:00
}
private void contextMenuStrip1_Opening ( object sender , CancelEventArgs e )
{
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
bool luaRunning = false ;
for ( int i = 0 ; i < luaList . Count ; i + + )
{
if ( luaList [ i ] . Enabled )
luaRunning = true ;
}
if ( indexes . Count > 0 )
{
contextMenuStrip1 . Items [ 0 ] . Enabled = true ;
contextMenuStrip1 . Items [ 1 ] . Enabled = true ;
contextMenuStrip1 . Items [ 2 ] . Enabled = true ;
2012-03-26 23:31:21 +00:00
contextMenuStrip1 . Items [ 3 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
bool allSeparators = true ;
for ( int i = 0 ; i < indexes . Count ; i + + )
{
if ( ! luaList [ indexes [ i ] ] . IsSeparator )
allSeparators = false ;
}
if ( allSeparators )
2012-03-24 13:25:19 +00:00
contextMenuStrip1 . Items [ 2 ] . Enabled = false ;
2012-03-17 23:16:11 +00:00
else
2012-03-24 13:25:19 +00:00
contextMenuStrip1 . Items [ 2 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
}
else
{
contextMenuStrip1 . Items [ 0 ] . Enabled = false ;
contextMenuStrip1 . Items [ 1 ] . Enabled = false ;
contextMenuStrip1 . Items [ 2 ] . Enabled = false ;
2012-03-26 23:31:21 +00:00
contextMenuStrip1 . Items [ 3 ] . Enabled = true ;
2012-03-17 23:16:11 +00:00
}
if ( luaRunning )
{
contextMenuStrip1 . Items [ 5 ] . Visible = true ;
2012-03-24 13:25:19 +00:00
contextMenuStrip1 . Items [ 6 ] . Visible = true ;
2012-03-17 23:16:11 +00:00
}
else
{
contextMenuStrip1 . Items [ 5 ] . Visible = false ;
2012-03-24 13:25:19 +00:00
contextMenuStrip1 . Items [ 6 ] . Visible = false ;
2012-03-17 23:16:11 +00:00
}
}
2012-03-19 16:19:31 +00:00
private void disableScriptsOnLoadToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . DisableLuaScriptsOnLoad ^ = true ;
}
2012-03-19 16:49:47 +00:00
private void autoloadSessionToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . AutoLoadLuaSession ^ = true ;
}
2012-03-24 10:53:26 +00:00
2012-03-26 23:31:21 +00:00
private void toolStripButton1_Click ( object sender , EventArgs e )
{
TogglePause ( ) ;
}
private void TogglePause ( )
{
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
for ( int x = 0 ; x < indexes . Count ; x + + )
{
var item = luaList [ indexes [ x ] ] ;
if ( ! item . IsSeparator )
item . TogglePause ( ) ;
}
}
LuaListView . Refresh ( ) ;
}
private void pauseResumeToolStripMenuItem_Click ( object sender , EventArgs e )
{
TogglePause ( ) ;
}
private void toolStripButton1_Click_1 ( object sender , EventArgs e )
{
TogglePause ( ) ;
}
private void resumePauseToolStripMenuItem_Click ( object sender , EventArgs e )
{
TogglePause ( ) ;
}
2012-03-28 20:49:58 +00:00
private void onlineDocumentationToolStripMenuItem_Click ( object sender , EventArgs e )
{
System . Diagnostics . Process . Start ( "http://tasvideos.org/BizHawk/LuaFunctions.html" ) ;
}
2012-07-19 04:19:24 +00:00
2012-07-22 19:59:33 +00:00
private void DoLuaWriter ( )
2012-07-22 20:25:53 +00:00
{
ListView . SelectedIndexCollection indexes = LuaListView . SelectedIndices ;
if ( indexes . Count = = 0 )
return ;
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 ] ] ;
if ( ! item . IsSeparator )
{
OpenLuaWriter ( luaList [ indexes [ 0 ] ] . Path ) ;
}
}
}
private void OpenLuaWriter ( string path )
2012-07-19 04:19:24 +00:00
{
LuaWriter writer = new LuaWriter ( ) ;
2012-07-22 20:25:53 +00:00
writer . CurrentFile = path ;
2012-07-19 04:19:24 +00:00
writer . Show ( ) ;
}
2012-07-25 17:36:26 +00:00
private void newScriptToolStripMenuItem_Click ( object sender , EventArgs e )
{
NewScript ( ) ;
}
private void NewScript ( )
{
OpenLuaWriter ( null ) ;
}
private void newStripButton1_Click ( object sender , EventArgs e )
{
NewScript ( ) ;
}
2011-06-16 02:39:35 +00:00
}
2011-05-06 01:37:28 +00:00
}