2011-05-06 01:37:28 +00:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Drawing ;
using System.Linq ;
using System.Windows.Forms ;
2011-05-07 00:07:27 +00:00
using System.IO ;
2011-05-06 01:37:28 +00:00
2013-11-25 23:24:26 +00:00
using BizHawk.Common ;
2013-10-25 00:57:23 +00:00
using BizHawk.Client.Common ;
2013-11-04 01:39:19 +00:00
using BizHawk.Emulation.Common ;
2013-10-25 00:57:23 +00:00
2013-11-03 03:54:37 +00:00
namespace BizHawk.Client.EmuHawk
2011-05-06 01:37:28 +00:00
{
2013-11-03 01:02:17 +00:00
public partial class LuaConsole : Form , IToolForm
2011-06-16 02:39:35 +00:00
{
2013-11-25 21:01:38 +00:00
//TODO:
//remember column widths and restore column width on restore default settings
//column click
//column reorder
2011-06-16 02:39:35 +00:00
2013-10-28 19:13:01 +00:00
public EmuLuaLibrary LuaImp ;
2011-06-16 02:39:35 +00:00
2013-11-25 21:01:38 +00:00
private int _defaultWidth ;
2013-11-17 15:55:13 +00:00
private int _defaultHeight ;
2013-11-25 23:24:26 +00:00
private readonly LuaFileList _luaList ;
2011-06-16 02:39:35 +00:00
2013-11-03 01:02:17 +00:00
public bool UpdateBefore { get { return true ; } }
public void UpdateValues ( ) { }
2013-11-17 15:55:13 +00:00
public LuaConsole Get ( ) { return this ; }
2011-06-16 02:39:35 +00:00
2013-11-25 21:01:38 +00:00
public void ConsoleLog ( string message )
2011-06-16 02:39:35 +00:00
{
2013-11-25 21:01:38 +00:00
OutputBox . Text + = message + Environment . NewLine + Environment . NewLine ;
2013-11-17 15:55:13 +00:00
OutputBox . SelectionStart = OutputBox . Text . Length ;
OutputBox . ScrollToCaret ( ) ;
2011-06-16 02:39:35 +00:00
}
public LuaConsole ( )
{
2013-11-25 23:24:26 +00:00
_luaList = new LuaFileList
2013-11-25 21:01:38 +00:00
{
ChangedCallback = SessionChangedCallback ,
LoadCallback = ClearOutputWindow
} ;
2011-06-16 02:39:35 +00:00
InitializeComponent ( ) ;
2013-10-28 19:13:01 +00:00
LuaImp = new EmuLuaLibrary ( this ) ;
2011-06-16 02:39:35 +00:00
Closing + = ( o , e ) = > SaveConfigSettings ( ) ;
2013-04-14 23:56:45 +00:00
LuaListView . QueryItemText + = LuaListView_QueryItemText ;
LuaListView . QueryItemBkColor + = LuaListView_QueryItemBkColor ;
2011-06-16 02:39:35 +00:00
LuaListView . VirtualMode = true ;
}
private void LuaConsole_Load ( object sender , EventArgs e )
{
LoadConfigSettings ( ) ;
2013-09-07 03:15:29 +00:00
if ( Global . Config . RecentLuaSession . AutoLoad )
2012-07-25 13:55:25 +00:00
{
2013-07-16 01:59:59 +00:00
if ( ! Global . Config . RecentLuaSession . Empty )
2012-07-25 13:55:25 +00:00
{
2013-09-06 21:23:59 +00:00
LoadSessionFromRecent ( Global . Config . RecentLuaSession [ 0 ] ) ;
2012-07-25 13:55:25 +00:00
}
}
2012-07-25 22:53:11 +00:00
2013-11-25 00:44:18 +00:00
NewScriptToolbarItem . Visible = VersionInfo . INTERIM ;
NewScriptMenuItem . Visible = VersionInfo . INTERIM ;
2011-06-16 02:39:35 +00:00
}
2011-06-26 02:09:06 +00:00
public void Restart ( )
{
2013-11-25 21:01:38 +00:00
_luaList . StopAllScripts ( ) ;
2011-06-16 02:39:35 +00:00
}
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 )
{
2013-11-25 02:08:45 +00:00
var luaFile = new LuaFile ( String . Empty , path ) ;
2013-11-25 00:44:18 +00:00
_luaList . Add ( luaFile ) ;
2013-11-17 15:55:13 +00:00
LuaListView . ItemCount = _luaList . Count ;
2012-03-26 23:31:21 +00:00
LuaListView . Refresh ( ) ;
Global . Config . RecentLua . Add ( path ) ;
if ( ! Global . Config . DisableLuaScriptsOnLoad )
{
try
{
2013-11-25 00:44:18 +00:00
luaFile . Thread = LuaImp . SpawnCoroutine ( path ) ;
luaFile . Enabled = true ;
2012-03-26 23:31:21 +00:00
}
catch ( Exception e )
{
if ( e . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" )
{
2013-11-25 00:44:18 +00:00
luaFile . Enabled = false ;
2013-11-25 21:01:38 +00:00
ConsoleLog ( e . Message ) ;
2012-03-26 23:31:21 +00:00
}
else MessageBox . Show ( e . ToString ( ) ) ;
}
}
2013-11-25 00:44:18 +00:00
else luaFile . Enabled = false ;
luaFile . Paused = false ;
2012-03-20 21:44:34 +00:00
}
else
{
2013-11-25 02:08:45 +00:00
foreach ( var file in _luaList )
2012-03-20 21:44:34 +00:00
{
2013-11-25 02:08:45 +00:00
if ( path = = file . Path & & file . Enabled = = false & & ! Global . Config . DisableLuaScriptsOnLoad )
2012-03-20 21:44:34 +00:00
{
2013-11-25 02:08:45 +00:00
file . Toggle ( ) ;
2012-03-20 21:44:34 +00:00
break ;
}
}
2013-11-25 21:01:38 +00:00
RunLuaScripts ( ) ;
UpdateDialog ( ) ;
2012-03-20 21:44:34 +00:00
}
2011-06-16 02:39:35 +00:00
}
2013-11-25 00:44:18 +00:00
public void UpdateDialog ( )
2011-06-26 02:09:06 +00:00
{
2013-11-17 15:55:13 +00:00
LuaListView . ItemCount = _luaList . Count ;
2013-11-25 21:01:38 +00:00
UpdateNumberOfScripts ( ) ;
2011-06-26 02:09:06 +00:00
}
2012-03-25 15:34:09 +00:00
public void RunLuaScripts ( )
2012-01-21 20:05:53 +00:00
{
2013-11-25 23:24:26 +00:00
foreach ( var t in _luaList )
2012-03-26 23:31:21 +00:00
{
2013-11-25 23:24:26 +00:00
if ( t . Enabled & & t . Thread = = null )
2012-03-26 23:31:21 +00:00
{
try
{
2013-11-25 23:24:26 +00:00
t . Thread = LuaImp . SpawnCoroutine ( t . Path ) ;
2012-03-26 23:31:21 +00:00
}
catch ( Exception e )
{
if ( e . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" )
{
2013-11-25 23:24:26 +00:00
t . Enabled = false ;
2013-11-25 21:01:38 +00:00
ConsoleLog ( e . Message ) ;
2012-03-26 23:31:21 +00:00
}
else MessageBox . Show ( e . ToString ( ) ) ;
}
}
else
{
2013-11-25 23:24:26 +00:00
t . Stop ( ) ;
2013-11-25 21:01:38 +00:00
_luaList . Changes = true ;
}
}
}
private void SessionChangedCallback ( )
{
OutputMessages . Text =
( _luaList . Changes ? "* " : String . Empty ) +
Path . GetFileName ( _luaList . Filename ) ;
}
private void LuaListView_QueryItemBkColor ( int index , int column , ref Color color )
{
if ( column = = 0 )
{
if ( _luaList [ index ] . IsSeparator )
{
color = BackColor ;
}
else if ( _luaList [ index ] . Enabled & & ! _luaList [ index ] . Paused )
{
color = Color . LightCyan ;
}
else if ( _luaList [ index ] . Enabled & & _luaList [ index ] . Paused )
{
color = Color . IndianRed ;
2012-03-26 23:31:21 +00:00
}
}
2013-11-25 21:01:38 +00:00
UpdateNumberOfScripts ( ) ;
}
private void LuaListView_QueryItemText ( int index , int column , out string text )
{
text = String . Empty ;
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 SaveConfigSettings ( )
{
LuaImp . Close ( ) ;
Global . Config . LuaConsoleWndx = Location . X ;
Global . Config . LuaConsoleWndy = Location . Y ;
Global . Config . LuaConsoleWidth = Right - Left ;
Global . Config . LuaConsoleHeight = Bottom - Top ;
}
private void LoadConfigSettings ( )
{
_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 ) ;
if ( Global . Config . LuaConsoleWidth > = 0 & & Global . Config . LuaConsoleHeight > = 0 )
{
Size = new Size ( Global . Config . LuaConsoleWidth , Global . Config . LuaConsoleHeight ) ;
}
}
2013-11-25 23:24:26 +00:00
private static FileInfo GetFileFromUser ( string filter )
2013-11-25 21:01:38 +00:00
{
2013-11-25 23:24:26 +00:00
var ofd = new OpenFileDialog
{
InitialDirectory = PathManager . GetLuaPath ( ) ,
Filter = filter , RestoreDirectory = true
} ;
2013-11-25 21:01:38 +00:00
if ( ! Directory . Exists ( ofd . InitialDirectory ) )
2013-11-25 23:24:26 +00:00
{
2013-11-25 21:01:38 +00:00
Directory . CreateDirectory ( ofd . InitialDirectory ) ;
2013-11-25 23:24:26 +00:00
}
2013-11-25 21:01:38 +00:00
GlobalWin . Sound . StopSound ( ) ;
var result = ofd . ShowDialog ( ) ;
GlobalWin . Sound . StartSound ( ) ;
2013-11-25 23:24:26 +00:00
return result = = DialogResult . OK ? new FileInfo ( ofd . FileName ) : null ;
2011-06-16 02:39:35 +00:00
}
private void UpdateNumberOfScripts ( )
{
2013-11-25 02:08:45 +00:00
var message = String . Empty ;
2012-03-24 13:25:19 +00:00
int active = 0 , paused = 0 , separators = 0 ;
2013-11-25 02:08:45 +00:00
foreach ( var file in _luaList )
2011-06-16 02:39:35 +00:00
{
2013-11-25 02:08:45 +00:00
if ( ! file . IsSeparator )
2012-03-26 23:31:21 +00:00
{
2013-11-25 02:08:45 +00:00
if ( file . Enabled )
2012-03-26 23:31:21 +00:00
{
active + + ;
2013-11-25 02:08:45 +00:00
if ( file . Paused )
{
2012-03-26 23:31:21 +00:00
paused + + ;
2013-11-25 02:08:45 +00:00
}
2012-03-26 23:31:21 +00:00
}
}
else
{
separators + + ;
}
2011-06-16 02:39:35 +00:00
}
2013-11-25 02:08:45 +00:00
var L = _luaList . Count - separators ;
2013-11-25 00:44:18 +00:00
2011-06-16 02:39:35 +00:00
if ( L = = 1 )
2013-11-25 00:44:18 +00:00
{
2013-11-25 02:08:45 +00:00
message + = L + " script (" + active + " active, " + paused + " paused)" ;
2013-11-25 00:44:18 +00:00
}
2011-06-16 02:39:35 +00:00
else if ( L = = 0 )
2013-11-25 00:44:18 +00:00
{
2013-11-25 21:01:38 +00:00
message + = L + " scripts" ;
2013-11-25 00:44:18 +00:00
}
2011-06-16 02:39:35 +00:00
else
2013-11-25 00:44:18 +00:00
{
2013-11-25 02:08:45 +00:00
message + = L + " scripts (" + active + " active, " + paused + " paused)" ;
2013-11-25 00:44:18 +00:00
}
2011-06-16 02:39:35 +00:00
NumberOfScripts . Text = message ;
}
2013-11-25 00:44:18 +00:00
private void LoadLuaFromRecent ( string path )
2011-06-16 02:39:35 +00:00
{
2013-11-25 00:44:18 +00:00
LoadLuaFile ( path ) ;
2011-06-16 02:39:35 +00:00
}
2013-11-25 00:44:18 +00:00
private bool LuaAlreadyInSession ( string path )
2011-06-16 02:39:35 +00:00
{
2013-11-25 00:44:18 +00:00
return _luaList . Any ( t = > path = = t . Path ) ;
2011-06-16 02:39:35 +00:00
}
2011-06-26 02:09:06 +00:00
2013-11-25 00:44:18 +00:00
public void WriteToOutputWindow ( string message )
2011-06-26 02:09:06 +00:00
{
2013-11-25 00:44:18 +00:00
if ( ! OutputBox . IsHandleCreated | | OutputBox . IsDisposed )
return ;
OutputBox . Invoke ( ( ) = >
{
OutputBox . Text + = message + "\n\n" ;
OutputBox . SelectionStart = OutputBox . Text . Length ;
OutputBox . ScrollToCaret ( ) ;
} ) ;
2012-01-22 23:56:49 +00:00
}
2013-11-25 00:44:18 +00:00
public void ClearOutputWindow ( )
2012-01-22 23:56:49 +00:00
{
2013-11-25 00:44:18 +00:00
if ( ! OutputBox . IsHandleCreated | | OutputBox . IsDisposed )
return ;
2012-03-17 22:23:52 +00:00
2013-11-25 00:44:18 +00:00
OutputBox . Invoke ( ( ) = >
2012-03-17 22:23:52 +00:00
{
2013-11-25 00:44:18 +00:00
OutputBox . Text = String . Empty ;
OutputBox . Refresh ( ) ;
} ) ;
2011-06-26 02:09:06 +00:00
}
2013-11-25 00:44:18 +00:00
public bool LoadLuaSession ( string path )
2011-06-26 02:09:06 +00:00
{
2013-11-25 21:01:38 +00:00
return _luaList . LoadLuaSession ( path ) ;
2011-06-26 03:03:15 +00:00
}
2013-11-25 00:44:18 +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 )
2011-06-26 03:03:15 +00:00
{
2013-11-25 00:44:18 +00:00
if ( _luaList ! = null & & _luaList . Count > 0 )
2011-06-26 03:03:15 +00:00
{
2013-11-25 00:44:18 +00:00
if ( LuaImp . GuiLibrary . SurfaceIsNull )
{
LuaImp . GuiLibrary . DrawNewEmu ( ) ;
}
foreach ( var lf in _luaList )
{
//save old current directory before this lua thread clobbers it for the .net thread
2013-11-25 02:08:45 +00:00
var oldcd = Environment . CurrentDirectory ;
2011-06-26 03:03:15 +00:00
2013-11-25 00:44:18 +00:00
try
{
//LuaImp.gui_clearGraphics();
if ( lf . Enabled & & lf . Thread ! = null & & ! ( lf . Paused ) )
{
2013-11-25 02:08:45 +00:00
var prohibit = lf . FrameWaiting & & ! includeFrameWaiters ;
2013-11-25 00:44:18 +00:00
if ( ! prohibit )
{
//restore this lua thread's preferred current directory
if ( lf . CurrentDirectory ! = null )
{
Environment . CurrentDirectory = lf . CurrentDirectory ;
}
var result = LuaImp . ResumeScript ( lf . Thread ) ;
if ( result . Terminated ) lf . Stop ( ) ;
lf . FrameWaiting = result . WaitForFrame ;
2011-06-26 03:03:15 +00:00
2013-11-25 00:44:18 +00:00
//if the lua thread changed its current directory, capture that here
lf . CurrentDirectory = Environment . CurrentDirectory ;
}
}
}
catch ( Exception ex )
{
if ( ex is LuaInterface . LuaScriptException | | ex is LuaInterface . LuaException )
{
lf . Enabled = false ;
lf . Thread = null ;
2013-11-25 21:01:38 +00:00
ConsoleLog ( ex . ToString ( ) ) ;
2013-11-25 00:44:18 +00:00
}
else MessageBox . Show ( ex . ToString ( ) ) ;
}
2011-06-26 03:03:15 +00:00
2013-11-25 00:44:18 +00:00
//restore the current directory
Environment . CurrentDirectory = oldcd ;
}
}
//LuaImp.gui_drawFinishEmu();
2011-06-26 03:03:15 +00:00
}
2013-11-25 00:44:18 +00:00
public void StartLuaDrawing ( )
2011-06-26 03:03:15 +00:00
{
2013-11-25 21:01:38 +00:00
if ( _luaList . Any ( ) )
2011-06-26 03:03:15 +00:00
{
2013-11-25 00:44:18 +00:00
if ( LuaImp . GuiLibrary . SurfaceIsNull )
2011-06-26 03:03:15 +00:00
{
2013-11-25 00:44:18 +00:00
LuaImp . GuiLibrary . DrawNewEmu ( ) ;
2011-06-26 03:03:15 +00:00
}
}
2013-11-25 00:44:18 +00:00
}
2011-06-26 03:03:15 +00:00
2013-11-25 00:44:18 +00:00
public void EndLuaDrawing ( )
{
2013-11-25 21:01:38 +00:00
if ( _luaList . Any ( ) )
2013-04-14 23:56:45 +00:00
{
2013-11-25 00:44:18 +00:00
LuaImp . GuiLibrary . DrawFinishEmu ( ) ;
2013-04-14 23:56:45 +00:00
}
2011-06-26 03:03:15 +00:00
}
2012-01-10 03:12:01 +00:00
2013-11-25 00:44:18 +00:00
public bool WaitOne ( int timeout )
2012-01-10 03:12:01 +00:00
{
2013-11-25 00:44:18 +00:00
if ( ! IsHandleCreated | | IsDisposed )
{
return true ;
}
2012-01-10 03:12:01 +00:00
2013-11-25 00:44:18 +00:00
return LuaImp . LuaWait . WaitOne ( timeout ) ;
2012-01-10 03:12:01 +00:00
}
2013-11-25 00:44:18 +00:00
private FileInfo GetSaveFileFromUser ( )
2012-03-20 21:44:34 +00:00
{
2013-11-25 00:44:18 +00:00
var sfd = new SaveFileDialog ( ) ;
2013-11-25 21:01:38 +00:00
if ( ! String . IsNullOrWhiteSpace ( _luaList . Filename ) )
2012-01-11 02:29:50 +00:00
{
2013-11-25 21:01:38 +00:00
sfd . FileName = Path . GetFileNameWithoutExtension ( _luaList . Filename ) ;
sfd . InitialDirectory = Path . GetDirectoryName ( _luaList . Filename ) ;
2012-01-10 03:12:01 +00:00
}
2013-11-25 00:44:18 +00:00
else if ( ! ( Global . Emulator is NullEmulator ) )
2012-07-22 19:59:33 +00:00
{
2013-11-25 00:44:18 +00:00
sfd . FileName = PathManager . FilesystemSafeName ( Global . Game ) ;
sfd . InitialDirectory = PathManager . GetLuaPath ( ) ;
2012-07-22 19:59:33 +00:00
}
else
{
2013-11-25 00:44:18 +00:00
sfd . FileName = "NULL" ;
sfd . InitialDirectory = PathManager . GetLuaPath ( ) ;
2012-07-22 19:59:33 +00:00
}
2013-11-25 00:44:18 +00:00
sfd . Filter = "Lua Session Files (*.luases)|*.luases|All Files|*.*" ;
sfd . RestoreDirectory = true ;
GlobalWin . Sound . StopSound ( ) ;
var result = sfd . ShowDialog ( ) ;
GlobalWin . Sound . StartSound ( ) ;
if ( result ! = DialogResult . OK )
return null ;
var file = new FileInfo ( sfd . FileName ) ;
return file ;
2012-01-11 02:29:50 +00:00
}
2013-11-25 00:44:18 +00:00
private void SaveSessionAs ( )
2012-01-22 03:14:31 +00:00
{
2013-11-25 00:44:18 +00:00
var file = GetSaveFileFromUser ( ) ;
if ( file ! = null )
2012-03-17 23:40:30 +00:00
{
2013-11-25 21:01:38 +00:00
_luaList . SaveSession ( file . FullName ) ;
OutputMessages . Text = Path . GetFileName ( _luaList . Filename ) + " saved." ;
2013-11-25 00:44:18 +00:00
}
2012-01-22 03:14:31 +00:00
}
2012-01-22 22:42:40 +00:00
2013-11-25 00:44:18 +00:00
public void LoadSessionFromRecent ( string path )
2012-01-22 23:56:49 +00:00
{
2013-11-25 02:08:45 +00:00
var doload = true ;
2013-11-25 21:01:38 +00:00
if ( _luaList . Changes ) doload = AskSave ( ) ;
2013-11-25 00:44:18 +00:00
if ( doload )
2012-01-22 23:56:49 +00:00
{
2013-11-25 21:01:38 +00:00
if ( ! _luaList . LoadLuaSession ( path ) )
2013-11-25 00:44:18 +00:00
{
ToolHelpers . HandleLoadError ( Global . Config . RecentLuaSession , path ) ;
}
else
{
RunLuaScripts ( ) ;
UpdateDialog ( ) ;
2013-11-25 21:01:38 +00:00
_luaList . Changes = false ;
2013-11-25 00:44:18 +00:00
}
2012-01-22 23:56:49 +00:00
}
}
2013-11-25 00:44:18 +00:00
public bool AskSave ( )
2012-01-22 23:56:49 +00:00
{
2013-11-25 00:44:18 +00:00
if ( Global . Config . SupressAskSave )
{
return true ;
}
2012-03-26 23:31:21 +00:00
2013-11-25 21:01:38 +00:00
if ( _luaList . Changes )
2012-10-06 16:13:45 +00:00
{
2013-11-25 00:44:18 +00:00
GlobalWin . Sound . StopSound ( ) ;
2013-11-25 02:08:45 +00:00
var result = MessageBox . Show ( "Save changes to session?" , "Lua Console" , MessageBoxButtons . YesNoCancel , MessageBoxIcon . Question , MessageBoxDefaultButton . Button3 ) ;
2013-11-25 00:44:18 +00:00
GlobalWin . Sound . StartSound ( ) ;
if ( result = = DialogResult . Yes )
2012-03-26 23:31:21 +00:00
{
2013-11-25 21:01:38 +00:00
if ( ! String . IsNullOrWhiteSpace ( _luaList . Filename ) )
2012-03-26 23:31:21 +00:00
{
2013-11-25 21:01:38 +00:00
_luaList . SaveSession ( ) ;
2012-03-26 23:31:21 +00:00
}
2013-11-25 00:44:18 +00:00
else
2012-03-27 07:25:36 +00:00
{
2013-11-25 21:01:38 +00:00
SaveSessionAs ( ) ;
2012-03-27 07:25:36 +00:00
}
2012-11-29 18:42:13 +00:00
2013-11-25 00:44:18 +00:00
return true ;
}
else if ( result = = DialogResult . No )
{
return true ;
}
else if ( result = = DialogResult . Cancel )
{
return false ;
2013-04-14 23:56:45 +00:00
}
2012-03-23 19:48:45 +00:00
}
2013-11-25 00:44:18 +00:00
return true ;
2012-10-06 16:13:45 +00:00
}
2013-11-25 02:08:45 +00:00
private static void OpenLuaWriter ( string path )
2012-10-06 16:13:45 +00:00
{
2013-11-25 02:08:45 +00:00
var writer = new LuaWriter { CurrentFile = path } ;
2013-11-25 00:44:18 +00:00
writer . Show ( ) ;
2012-03-23 18:24:29 +00:00
}
2013-11-25 00:44:18 +00:00
private Point GetPromptPoint ( )
2012-01-28 22:00:51 +00:00
{
2013-11-25 02:08:45 +00:00
return PointToScreen (
new Point ( LuaListView . Location . X + 30 , LuaListView . Location . Y + 30 )
) ;
2012-01-28 22:00:51 +00:00
}
2012-03-05 14:27:29 +00:00
2013-11-25 00:44:18 +00:00
private IEnumerable < int > SelectedIndices
2012-03-05 14:27:29 +00:00
{
2013-11-25 00:55:56 +00:00
get { return LuaListView . SelectedIndices . Cast < int > ( ) ; }
2012-03-05 14:27:29 +00:00
}
2012-03-13 22:39:07 +00:00
2013-11-25 00:44:18 +00:00
private IEnumerable < LuaFile > SelectedItems
2012-03-17 12:14:59 +00:00
{
2013-11-25 00:55:56 +00:00
get { return SelectedIndices . Select ( index = > _luaList [ index ] ) ; }
2012-03-17 12:14:59 +00:00
}
2013-11-25 00:44:18 +00:00
private IEnumerable < LuaFile > SelectedFiles
2012-03-17 12:19:30 +00:00
{
2013-11-25 00:44:18 +00:00
get { return SelectedItems . Where ( x = > ! x . IsSeparator ) ; }
2012-03-17 12:19:30 +00:00
}
2013-11-25 00:44:18 +00:00
#region Events
2012-03-17 21:31:48 +00:00
2013-11-25 00:44:18 +00:00
#region File Menu
private void FileSubMenu_DropDownOpened ( object sender , EventArgs e )
2012-03-17 21:31:48 +00:00
{
2013-11-25 21:01:38 +00:00
SaveSessionMenuItem . Enabled = _luaList . Changes ;
2012-03-17 21:31:48 +00:00
}
2013-11-25 00:44:18 +00:00
private void RecentSessionsSubMenu_DropDownOpened ( object sender , EventArgs e )
2012-03-17 21:31:48 +00:00
{
2013-11-25 00:44:18 +00:00
RecentSessionsSubMenu . DropDownItems . Clear ( ) ;
RecentSessionsSubMenu . DropDownItems . AddRange (
ToolHelpers . GenerateRecentMenu ( Global . Config . RecentLuaSession , LoadSessionFromRecent )
) ;
2012-03-17 21:31:48 +00:00
}
2013-11-25 00:44:18 +00:00
private void RecentScriptsSubMenu_DropDownOpened ( object sender , EventArgs e )
2012-03-17 21:31:48 +00:00
{
2013-11-25 00:44:18 +00:00
RecentScriptsSubMenu . DropDownItems . Clear ( ) ;
RecentScriptsSubMenu . DropDownItems . AddRange (
ToolHelpers . GenerateRecentMenu ( Global . Config . RecentLua , LoadLuaFromRecent )
) ;
2012-03-17 21:31:48 +00:00
}
2013-11-25 00:44:18 +00:00
private void NewSessionMenuItem_Click ( object sender , EventArgs e )
2012-03-17 21:31:48 +00:00
{
2013-11-25 21:01:38 +00:00
var result = ! _luaList . Changes | | AskSave ( ) ;
2013-11-25 00:44:18 +00:00
if ( result )
{
_luaList . Clear ( ) ;
2013-11-25 21:01:38 +00:00
ClearOutputWindow ( ) ;
2013-11-25 00:44:18 +00:00
UpdateDialog ( ) ;
}
2012-03-17 21:31:48 +00:00
}
2012-03-17 21:59:56 +00:00
2013-11-25 00:44:18 +00:00
private void OpenSessionMenuItem_Click ( object sender , EventArgs e )
2012-03-17 21:59:56 +00:00
{
2013-11-25 00:44:18 +00:00
var file = GetFileFromUser ( "Lua Session Files (*.luases)|*.luases|All Files|*.*" ) ;
if ( file ! = null )
{
2013-11-25 21:01:38 +00:00
_luaList . LoadLuaSession ( file . FullName ) ;
2013-11-25 00:44:18 +00:00
RunLuaScripts ( ) ;
UpdateDialog ( ) ;
2013-11-25 21:01:38 +00:00
_luaList . Changes = false ;
2013-11-25 00:44:18 +00:00
}
2012-03-17 21:59:56 +00:00
}
2013-11-25 00:44:18 +00:00
private void SaveSessionMenuItem_Click ( object sender , EventArgs e )
2012-03-17 21:59:56 +00:00
{
2013-11-25 21:01:38 +00:00
if ( _luaList . Changes )
2012-03-17 21:59:56 +00:00
{
2013-11-25 21:01:38 +00:00
if ( ! String . IsNullOrWhiteSpace ( _luaList . Filename ) )
2012-03-17 21:59:56 +00:00
{
2013-11-25 21:01:38 +00:00
_luaList . SaveSession ( ) ;
2013-09-09 21:36:26 +00:00
}
else
{
2013-11-25 21:01:38 +00:00
SaveSessionAs ( ) ;
2012-03-17 21:59:56 +00:00
}
2013-11-25 00:44:18 +00:00
2013-11-25 21:01:38 +00:00
OutputMessages . Text = Path . GetFileName ( _luaList . Filename ) + " saved." ;
2012-03-17 21:59:56 +00:00
}
}
2013-11-25 00:44:18 +00:00
private void SaveSessionAsMenuItem_Click ( object sender , EventArgs e )
2012-03-17 21:59:56 +00:00
{
2013-11-25 00:44:18 +00:00
SaveSessionAs ( ) ;
}
private void ExitMenuItem_Click ( object sender , EventArgs e )
{
Close ( ) ;
}
#endregion
#region Script
private void ScriptSubMenu_DropDownOpened ( object sender , EventArgs e )
{
ToggleScriptMenuItem . Enabled =
PauseScriptMenuItem . Enabled =
EditScriptMenuItem . Enabled =
SelectedFiles . Any ( ) ;
RemoveScriptMenuItem . Enabled =
MoveUpMenuItem . Enabled =
MoveDownMenuItem . Enabled =
SelectedIndices . Any ( ) ;
SelectAllMenuItem . Enabled = _luaList . Any ( ) ;
StopAllScriptsMenuItem . Enabled = _luaList . Any ( script = > script . Enabled ) ;
RegisteredFunctionsMenuItem . Enabled = GlobalWin . Tools . LuaConsole . LuaImp . RegisteredFunctions . Any ( ) ;
NewScriptMenuItem . Visible = VersionInfo . INTERIM ;
}
private void NewScriptMenuItem_Click ( object sender , EventArgs e )
{
OpenLuaWriter ( null ) ;
}
private void OpenScriptMenuItem_Click ( object sender , EventArgs e )
{
var file = GetFileFromUser ( "Lua Scripts (*.lua)|*.lua|Text (*.text)|*.txt|All Files|*.*" ) ;
if ( file ! = null )
2012-07-10 17:22:23 +00:00
{
2013-11-25 00:44:18 +00:00
LoadLuaFile ( file . FullName ) ;
UpdateDialog ( ) ;
2012-07-10 17:22:23 +00:00
}
2013-11-25 00:44:18 +00:00
}
2012-07-10 17:22:23 +00:00
2013-11-25 00:44:18 +00:00
private void ToggleScriptMenuItem_Click ( object sender , EventArgs e )
{
2013-11-25 21:01:38 +00:00
foreach ( var item in SelectedFiles )
2012-03-17 21:59:56 +00:00
{
2013-11-25 21:01:38 +00:00
item . Toggle ( ) ;
2013-11-25 00:44:18 +00:00
if ( item . Enabled & & item . Thread = = null )
{
try
2012-03-17 21:59:56 +00:00
{
2013-11-25 00:44:18 +00:00
item . Thread = LuaImp . SpawnCoroutine ( item . Path ) ;
2012-03-17 21:59:56 +00:00
}
2013-11-25 00:44:18 +00:00
catch ( Exception ex )
2013-11-17 17:17:18 +00:00
{
2013-11-25 00:44:18 +00:00
if ( ex . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" )
{
item . Enabled = false ;
2013-11-25 21:01:38 +00:00
ConsoleLog ( ex . Message ) ;
2013-11-25 00:44:18 +00:00
}
else
{
MessageBox . Show ( ex . ToString ( ) ) ;
}
2013-11-17 17:17:18 +00:00
}
2012-03-17 21:59:56 +00:00
}
2013-11-25 00:44:18 +00:00
else if ( ! item . Enabled & & item . Thread ! = null )
2013-11-17 17:17:18 +00:00
{
2013-11-25 00:44:18 +00:00
item . Stop ( ) ;
2013-11-17 17:17:18 +00:00
}
2012-03-17 21:59:56 +00:00
}
2013-11-25 00:44:18 +00:00
LuaListView . Refresh ( ) ;
2013-11-25 21:01:38 +00:00
_luaList . Changes = true ;
2012-03-17 21:59:56 +00:00
}
2012-03-17 22:23:52 +00:00
2013-11-25 00:44:18 +00:00
private void PauseScriptMenuItem_Click ( object sender , EventArgs e )
2012-03-17 22:23:52 +00:00
{
2013-11-25 00:44:18 +00:00
SelectedFiles . ToList ( ) . ForEach ( x = > x . TogglePause ( ) ) ;
LuaListView . Refresh ( ) ;
2012-03-17 22:23:52 +00:00
}
2013-11-25 00:44:18 +00:00
private void EditScriptMenuItem_Click ( object sender , EventArgs e )
2012-03-17 22:23:52 +00:00
{
2013-11-25 00:44:18 +00:00
SelectedFiles . ToList ( ) . ForEach ( file = > System . Diagnostics . Process . Start ( file . Path ) ) ;
2012-03-17 22:23:52 +00:00
}
2012-03-17 23:16:11 +00:00
2013-11-25 00:44:18 +00:00
private void RemoveScriptMenuItem_Click ( object sender , EventArgs e )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
if ( SelectedItems . Any ( ) )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
foreach ( var item in SelectedItems )
2013-04-14 23:56:45 +00:00
{
2013-11-25 00:44:18 +00:00
_luaList . Remove ( item ) ;
2013-04-14 23:56:45 +00:00
}
2013-11-25 00:44:18 +00:00
UpdateDialog ( ) ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 00:44:18 +00:00
}
2012-03-17 23:16:11 +00:00
2013-11-25 00:44:18 +00:00
private void InsertSeparatorMenuItem_Click ( object sender , EventArgs e )
{
var indices = SelectedIndices . ToList ( ) ;
if ( indices . Any ( ) & & indices . Last ( ) < _luaList . Count )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
_luaList . Insert ( indices . Last ( ) , LuaFile . SeparatorInstance ) ;
2012-03-17 23:16:11 +00:00
}
else
{
2013-11-25 00:44:18 +00:00
_luaList . Add ( LuaFile . SeparatorInstance ) ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 00:44:18 +00:00
UpdateDialog ( ) ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 00:44:18 +00:00
private void MoveUpMenuItem_Click ( object sender , EventArgs e )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
var indices = SelectedIndices . ToList ( ) ;
if ( indices . Count = = 0 | | indices [ 0 ] = = 0 )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
return ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 02:08:45 +00:00
foreach ( var index in indices )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
var file = _luaList [ index ] ;
_luaList . Remove ( file ) ;
_luaList . Insert ( index - 1 , file ) ;
}
2012-03-17 23:16:11 +00:00
2013-11-25 00:44:18 +00:00
var newindices = indices . Select ( t = > t - 1 ) . ToList ( ) ;
LuaListView . SelectedIndices . Clear ( ) ;
2013-11-25 02:08:45 +00:00
foreach ( var newi in newindices )
2013-11-25 00:44:18 +00:00
{
LuaListView . SelectItem ( newi , true ) ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 00:44:18 +00:00
UpdateDialog ( ) ;
}
private void MoveDownMenuItem_Click ( object sender , EventArgs e )
{
var indices = SelectedIndices . ToList ( ) ;
if ( indices . Count = = 0 | | indices . Last ( ) = = _luaList . Count - 1 )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
return ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 23:24:26 +00:00
for ( var i = indices . Count - 1 ; i > = 0 ; i - - )
2012-03-17 23:16:11 +00:00
{
2013-11-25 23:24:26 +00:00
var file = _luaList [ indices [ i ] ] ;
2013-11-25 00:44:18 +00:00
_luaList . Remove ( file ) ;
2013-11-25 23:24:26 +00:00
_luaList . Insert ( indices [ i ] + 1 , file ) ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 00:44:18 +00:00
var newindices = indices . Select ( t = > t + 1 ) . ToList ( ) ;
LuaListView . SelectedIndices . Clear ( ) ;
2013-11-25 02:08:45 +00:00
foreach ( var newi in newindices )
2012-03-17 23:16:11 +00:00
{
2013-11-25 00:44:18 +00:00
LuaListView . SelectItem ( newi , true ) ;
2012-03-17 23:16:11 +00:00
}
2013-11-25 00:44:18 +00:00
UpdateDialog ( ) ;
2012-03-17 23:16:11 +00:00
}
2012-03-19 16:19:31 +00:00
2013-11-25 00:44:18 +00:00
private void SelectAllMenuItem_Click ( object sender , EventArgs e )
2012-03-19 16:19:31 +00:00
{
2013-11-25 02:08:45 +00:00
for ( var i = 0 ; i < _luaList . Count ; i + + )
2013-11-25 00:44:18 +00:00
{
2013-11-25 02:08:45 +00:00
LuaListView . SelectItem ( i , true ) ;
2013-11-25 00:44:18 +00:00
}
2012-03-19 16:19:31 +00:00
}
2012-03-19 16:49:47 +00:00
2013-11-25 00:44:18 +00:00
private void StopAllScriptsMenuItem_Click ( object sender , EventArgs e )
2012-03-19 16:49:47 +00:00
{
2013-11-25 21:01:38 +00:00
_luaList . StopAllScripts ( ) ;
2012-03-19 16:49:47 +00:00
}
2012-03-24 10:53:26 +00:00
2013-11-25 00:44:18 +00:00
private void RegisteredFunctionsMenuItem_Click ( object sender , EventArgs e )
2012-03-26 23:31:21 +00:00
{
2013-11-25 00:44:18 +00:00
if ( LuaImp . RegisteredFunctions . Any ( ) )
2012-03-26 23:31:21 +00:00
{
2013-11-25 02:08:45 +00:00
var alreadyOpen = false ;
2013-11-25 00:44:18 +00:00
foreach ( Form form in Application . OpenForms )
2012-03-26 23:31:21 +00:00
{
2013-11-25 00:44:18 +00:00
if ( form is LuaRegisteredFunctionsList )
{
alreadyOpen = true ;
form . Focus ( ) ;
}
}
if ( ! alreadyOpen )
{
var form = new LuaRegisteredFunctionsList { StartLocation = GetPromptPoint ( ) } ;
form . Show ( ) ;
2012-03-26 23:31:21 +00:00
}
}
}
2013-11-25 00:44:18 +00:00
#endregion
#region Options
private void OptionsSubMenu_DropDownOpened ( object sender , EventArgs e )
2012-03-26 23:31:21 +00:00
{
2013-11-25 00:44:18 +00:00
SaveWindowPositionMenuItem . Checked = Global . Config . LuaConsoleSaveWindowPosition ;
AutoloadConsoleMenuItem . Checked = Global . Config . AutoLoadLuaConsole ;
AutoloadSessionMenuItem . Checked = Global . Config . RecentLuaSession . AutoLoad ;
DisableScriptsOnLoadMenuItem . Checked = Global . Config . DisableLuaScriptsOnLoad ;
2012-03-26 23:31:21 +00:00
}
2013-11-25 00:44:18 +00:00
private void SaveWindowPositionMenuItem_Click ( object sender , EventArgs e )
2012-03-26 23:31:21 +00:00
{
2013-11-25 00:44:18 +00:00
Global . Config . LuaConsoleSaveWindowPosition ^ = true ;
2012-03-26 23:31:21 +00:00
}
2013-11-25 00:44:18 +00:00
private void AutoloadConsoleMenuItem_Click ( object sender , EventArgs e )
2012-03-26 23:31:21 +00:00
{
2013-11-25 00:44:18 +00:00
Global . Config . AutoLoadLuaConsole ^ = true ;
2012-03-26 23:31:21 +00:00
}
2012-03-28 20:49:58 +00:00
2013-11-25 00:44:18 +00:00
private void AutoloadSessionMenuItem_Click ( object sender , EventArgs e )
2012-03-28 20:49:58 +00:00
{
2013-11-25 00:44:18 +00:00
Global . Config . RecentLuaSession . AutoLoad ^ = true ;
2012-03-28 20:49:58 +00:00
}
2012-07-19 04:19:24 +00:00
2013-11-25 00:44:18 +00:00
private void DisableScriptsOnLoadMenuItem_Click ( object sender , EventArgs e )
2012-07-22 20:25:53 +00:00
{
2013-11-25 00:44:18 +00:00
Global . Config . DisableLuaScriptsOnLoad ^ = true ;
}
2012-07-22 20:25:53 +00:00
2013-11-25 00:44:18 +00:00
private void RestoreDefaultSettingsMenuItem_Click ( object sender , EventArgs e )
{
Size = new Size ( _defaultWidth , _defaultHeight ) ;
2012-07-22 20:25:53 +00:00
}
2013-11-25 00:44:18 +00:00
#endregion
#region Help
private void FunctionsListMenuItem_Click ( object sender , EventArgs e )
2012-07-19 04:19:24 +00:00
{
2013-11-25 00:44:18 +00:00
GlobalWin . Sound . StopSound ( ) ;
new LuaFunctionsForm ( ) . Show ( ) ;
GlobalWin . Sound . StartSound ( ) ;
2012-07-19 04:19:24 +00:00
}
2012-07-25 17:36:26 +00:00
2013-11-25 00:44:18 +00:00
private void OnlineDocsMenuItem_Click ( object sender , EventArgs e )
2012-07-25 17:36:26 +00:00
{
2013-11-25 00:44:18 +00:00
System . Diagnostics . Process . Start ( "http://tasvideos.org/BizHawk/LuaFunctions.html" ) ;
2012-07-25 17:36:26 +00:00
}
2013-11-25 00:44:18 +00:00
#endregion
#region Toolbar and Context Menu
private void EditToolbarItem_Click ( object sender , EventArgs e )
2012-07-25 17:36:26 +00:00
{
2013-11-25 00:44:18 +00:00
if ( VersionInfo . INTERIM )
{
2013-11-25 02:08:45 +00:00
SelectedFiles . ToList ( ) . ForEach ( x = > OpenLuaWriter ( x . Path ) ) ;
2013-11-25 00:44:18 +00:00
}
else
{
EditScriptMenuItem_Click ( sender , e ) ;
}
2012-07-25 17:36:26 +00:00
}
2013-11-25 00:44:18 +00:00
private void ScriptListContextMenu_Opening ( object sender , CancelEventArgs e )
2012-07-25 17:36:26 +00:00
{
2013-11-25 00:44:18 +00:00
ToggleScriptContextItem . Enabled =
PauseScriptContextItem . Enabled =
EditScriptContextItem . Enabled =
SelectedFiles . Any ( ) ;
StopAllScriptsContextItem . Visible =
ScriptContextSeparator . Visible =
_luaList . Any ( file = > file . Enabled ) ;
2012-07-25 17:36:26 +00:00
}
2013-08-05 00:26:19 +00:00
2013-11-25 00:44:18 +00:00
private void ConsoleContextMenu_Opening ( object sender , CancelEventArgs e )
2013-11-10 23:16:18 +00:00
{
2013-11-25 00:44:18 +00:00
RegisteredFunctionsContextItem . Enabled = LuaImp . RegisteredFunctions . Any ( ) ;
2013-11-10 23:16:18 +00:00
}
2013-11-25 00:44:18 +00:00
private void ClearConsoleContextItem_Click ( object sender , EventArgs e )
2013-08-05 00:26:19 +00:00
{
2013-11-25 21:01:38 +00:00
ClearOutputWindow ( ) ;
2013-11-25 00:44:18 +00:00
}
#endregion
#region Dialog , Listview , OutputBox
private void LuaConsole_DragDrop ( object sender , DragEventArgs e )
{
2013-11-25 02:08:45 +00:00
var filePaths = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
2013-11-25 00:44:18 +00:00
try
2013-08-05 00:26:19 +00:00
{
2013-11-25 02:08:45 +00:00
foreach ( var path in filePaths )
2013-11-10 22:05:03 +00:00
{
2013-11-25 00:44:18 +00:00
if ( Path . GetExtension ( path ) = = ( ".lua" ) | | Path . GetExtension ( path ) = = ( ".txt" ) )
2013-11-10 22:05:03 +00:00
{
2013-11-25 00:44:18 +00:00
LoadLuaFile ( path ) ;
UpdateDialog ( ) ;
}
else if ( Path . GetExtension ( path ) = = ( ".luases" ) )
{
2013-11-25 21:01:38 +00:00
_luaList . LoadLuaSession ( path ) ;
2013-11-25 00:44:18 +00:00
RunLuaScripts ( ) ;
2013-11-25 21:01:38 +00:00
UpdateDialog ( ) ;
_luaList . Changes = false ;
2013-11-25 00:44:18 +00:00
return ;
2013-11-10 22:05:03 +00:00
}
}
2013-11-25 00:44:18 +00:00
}
catch ( Exception ex )
{
if ( ex . ToString ( ) . Substring ( 0 , 32 ) = = "LuaInterface.LuaScriptException:" | | ex . ToString ( ) . Substring ( 0 , 26 ) = = "LuaInterface.LuaException:" )
2013-11-10 22:05:03 +00:00
{
2013-11-25 21:01:38 +00:00
ConsoleLog ( ex . Message ) ;
2013-11-10 22:05:03 +00:00
}
2013-11-25 00:44:18 +00:00
else
{
MessageBox . Show ( ex . Message ) ;
}
}
}
private void LuaConsole_DragEnter ( object sender , DragEventArgs e )
{
e . Effect = e . Data . GetDataPresent ( DataFormats . FileDrop ) ? DragDropEffects . Copy : DragDropEffects . None ;
}
private void LuaListView_KeyDown ( object sender , KeyEventArgs e )
{
if ( e . KeyCode = = Keys . Delete & & ! e . Control & & ! e . Alt & & ! e . Shift )
{
RemoveScriptMenuItem_Click ( null , null ) ;
}
else if ( e . KeyCode = = Keys . A & & e . Control & & ! e . Alt & & ! e . Shift ) //Select All
{
SelectAllMenuItem_Click ( null , null ) ;
}
else if ( e . KeyCode = = Keys . F12 & & ! e . Control & & ! e . Alt & & ! e . Shift ) //F12
{
RegisteredFunctionsMenuItem_Click ( null , null ) ;
2013-08-05 00:26:19 +00:00
}
}
2013-08-05 00:45:41 +00:00
2013-11-25 00:44:18 +00:00
private void LuaListView_ItemActivate ( object sender , EventArgs e )
2013-08-05 00:45:41 +00:00
{
2013-11-25 00:44:18 +00:00
ToggleScriptMenuItem_Click ( sender , e ) ;
2013-08-05 00:45:41 +00:00
}
2013-11-17 16:58:24 +00:00
private void OutputBox_KeyDown ( object sender , KeyEventArgs e )
{
if ( e . KeyCode = = Keys . F12 & & ! e . Control & & ! e . Alt & & ! e . Shift ) //F12
{
2013-11-25 00:44:18 +00:00
RegisteredFunctionsMenuItem_Click ( null , null ) ;
2013-11-17 16:58:24 +00:00
}
}
2013-11-25 00:44:18 +00:00
#endregion
#endregion
2011-06-16 02:39:35 +00:00
}
2011-05-06 01:37:28 +00:00
}