2011-05-08 11:29:34 +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-22 18:38:44 +00:00
namespace BizHawk.MultiClient
2011-05-08 11:29:34 +00:00
{
2011-06-11 22:32:12 +00:00
public partial class TAStudio : Form
{
2011-06-12 18:31:42 +00:00
//TODO:
2012-08-17 23:27:29 +00:00
//Slicer Section:
//View clipboard - opens a pop-up with a listview showing the input
//Save clipboard as macro - adds to the macro list (todo: macro list)
//click & drag on list view should highlight rows
//any event that changes highlighting of listview should update selection display
//caret column and caret
2012-08-17 02:18:25 +00:00
//When closing tastudio, don't write the movie file? AskSave() is acceptable however
2011-07-24 17:29:09 +00:00
//If null emulator do a base virtualpad so getmnemonic doesn't fail
2011-06-12 18:31:42 +00:00
//Right-click - Go to current frame
2012-08-18 00:09:00 +00:00
//Clicking a frame should go there (currently set to double click)
2011-06-12 20:33:42 +00:00
//Multiple timeline system
//Macro listview
// Double click brings up a macro editing window
2011-06-12 21:36:03 +00:00
//ensureVisible when recording
2012-06-01 05:49:26 +00:00
//Allow hotkeys when TAStudio has focus
//Reduce the memory footprint with compression and or dropping frames and rerunning them when requested.
2011-06-12 18:31:42 +00:00
2011-06-11 22:32:12 +00:00
int defaultWidth ; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight ;
2012-06-25 00:06:07 +00:00
2011-06-12 14:42:50 +00:00
public bool Engaged ; //When engaged the Client will listen to TAStudio for input
2011-07-24 17:29:09 +00:00
List < VirtualPad > Pads = new List < VirtualPad > ( ) ;
2011-06-11 22:32:12 +00:00
2011-06-12 20:33:42 +00:00
//Movie header object - to have the main project header data
//List<string> MacroFiles - list of .macro files (simply log files)
2012-03-31 00:38:39 +00:00
//List<string> TimeLines - list of movie files
2011-06-12 20:33:42 +00:00
//List<string> Bookmarks - list of savestate files
2011-06-11 22:32:12 +00:00
public TAStudio ( )
{
InitializeComponent ( ) ;
Closing + = ( o , e ) = > SaveConfigSettings ( ) ;
TASView . QueryItemText + = new QueryItemTextHandler ( TASView_QueryItemText ) ;
TASView . QueryItemBkColor + = new QueryItemBkColorHandler ( TASView_QueryItemBkColor ) ;
TASView . VirtualMode = true ;
}
2012-08-17 23:27:29 +00:00
//TODO: move me
public class ClipboardEntry
{
public int frame ;
public string inputstr ;
}
public List < ClipboardEntry > Clipboard = new List < ClipboardEntry > ( ) ;
2011-06-11 22:59:21 +00:00
public void UpdateValues ( )
2011-06-11 22:32:12 +00:00
{
2011-06-12 21:36:03 +00:00
if ( ! this . IsHandleCreated | | this . IsDisposed ) return ;
2011-08-27 14:56:17 +00:00
TASView . BlazingFast = true ;
2011-09-03 18:07:30 +00:00
if ( Global . MovieSession . Movie . Mode = = MOVIEMODE . INACTIVE )
2011-06-12 21:36:03 +00:00
TASView . ItemCount = 0 ;
else
DisplayList ( ) ;
2011-07-30 03:00:18 +00:00
2011-09-03 18:07:30 +00:00
if ( Global . MovieSession . Movie . Mode = = MOVIEMODE . PLAY )
2011-07-30 03:00:18 +00:00
{
2011-09-03 18:07:30 +00:00
string str = Global . MovieSession . Movie . GetInputFrame ( Global . Emulator . Frame ) ;
2012-03-27 07:48:05 +00:00
if ( Global . Config . TASUpdatePads = = true & & str ! = "" )
2011-07-30 03:00:18 +00:00
{
2011-07-30 17:59:18 +00:00
switch ( Global . Emulator . SystemId )
{
case "NES" :
Pads [ 0 ] . SetButtons ( str . Substring ( 3 , 8 ) ) ;
Pads [ 1 ] . SetButtons ( str . Substring ( 12 , 8 ) ) ;
Pads [ 2 ] . SetButtons ( str [ 1 ] . ToString ( ) ) ;
break ;
2012-06-30 01:23:02 +00:00
case "A26" :
Pads [ 0 ] . SetButtons ( str . Substring ( 4 , 5 ) ) ;
Pads [ 1 ] . SetButtons ( str . Substring ( 10 , 5 ) ) ;
Pads [ 2 ] . SetButtons ( str . Substring ( 1 , 2 ) ) ;
break ;
2011-07-30 17:59:18 +00:00
case "SMS" :
case "GG" :
case "SG" :
2012-06-18 01:36:38 +00:00
Pads [ 0 ] . SetButtons ( str . Substring ( 1 , 6 ) ) ;
Pads [ 1 ] . SetButtons ( str . Substring ( 8 , 6 ) ) ;
Pads [ 2 ] . SetButtons ( str . Substring ( 15 , 2 ) ) ;
2011-07-30 17:59:18 +00:00
break ;
case "PCE" :
case "SGX" :
Pads [ 0 ] . SetButtons ( str . Substring ( 3 , 8 ) ) ;
Pads [ 1 ] . SetButtons ( str . Substring ( 12 , 8 ) ) ;
Pads [ 2 ] . SetButtons ( str . Substring ( 21 , 8 ) ) ;
Pads [ 3 ] . SetButtons ( str . Substring ( 30 , 8 ) ) ;
break ;
default :
break ;
}
2011-07-30 03:00:18 +00:00
}
2011-08-04 02:28:25 +00:00
TASView . BlazingFast = false ;
2011-07-30 03:00:18 +00:00
}
2011-06-11 22:59:21 +00:00
}
2011-06-11 22:32:12 +00:00
2011-06-12 14:42:50 +00:00
public string GetMnemonic ( )
{
2011-07-24 19:31:58 +00:00
StringBuilder str = new StringBuilder ( "|" ) ; //TODO: Control Command virtual pad
2012-06-25 00:06:07 +00:00
2011-07-24 19:31:58 +00:00
//TODO: remove this hack with a nes controls pad
if ( Global . Emulator . SystemId = = "NES" )
str . Append ( "0|" ) ;
2011-07-24 17:29:09 +00:00
for ( int x = 0 ; x < Pads . Count ; x + + )
str . Append ( Pads [ x ] . GetMnemonic ( ) ) ;
2011-06-12 14:42:50 +00:00
return str . ToString ( ) ;
}
2011-06-11 22:59:21 +00:00
private void TASView_QueryItemBkColor ( int index , int column , ref Color color )
{
2012-06-18 01:36:38 +00:00
if ( 0 = = index & & 0 = = Global . MovieSession . Movie . StateFirstIndex ( ) )
color = Color . LightGreen ; //special case for frame 0. Normally we need to go back an extra frame, but for frame 0 we can reload the rom.
if ( index > Global . MovieSession . Movie . StateFirstIndex ( ) & & index < = Global . MovieSession . Movie . StateLastIndex ( ) )
2011-06-11 22:59:21 +00:00
color = Color . LightGreen ;
2012-06-18 01:36:38 +00:00
if ( "" ! = Global . MovieSession . Movie . GetInputFrame ( index ) & &
Global . COMMANDS [ Global . MovieInputSourceAdapter . Type . Name ] . ContainsKey ( "Lag" ) & &
Global . MovieSession . Movie . GetInputFrame ( index ) [ 1 ] = = Global . COMMANDS [ Global . MovieInputSourceAdapter . Type . Name ] [ "Lag" ] [ 0 ] )
2012-01-08 23:51:53 +00:00
color = Color . Pink ;
2012-06-01 05:49:26 +00:00
if ( index = = Global . Emulator . Frame )
{
color = Color . LightBlue ;
}
2011-06-11 22:32:12 +00:00
}
private void TASView_QueryItemText ( int index , int column , out string text )
{
text = "" ;
2012-06-07 04:47:54 +00:00
//If this is just for an actual frame and not just the list view cursor at the end
if ( Global . MovieSession . Movie . LogLength ( ) ! = index )
{
if ( column = = 0 )
text = String . Format ( "{0:#,##0}" , index ) ;
if ( column = = 1 )
text = Global . MovieSession . Movie . GetInputFrame ( index ) ;
}
2011-06-11 22:59:21 +00:00
}
private void DisplayList ( )
{
2012-06-07 04:47:54 +00:00
TASView . ItemCount = Global . MovieSession . Movie . LogLength ( ) ;
2012-06-18 01:36:38 +00:00
if ( Global . MovieSession . Movie . LogLength ( ) = = Global . Emulator . Frame & & Global . MovieSession . Movie . StateLastIndex ( ) = = Global . Emulator . Frame - 1 )
2012-06-07 04:47:54 +00:00
{
//If we're at the end of the movie add one to show the cursor as a blank frame
TASView . ItemCount + + ;
}
2012-06-25 00:06:07 +00:00
TASView . ensureVisible ( Global . Emulator . Frame - 1 ) ;
2011-06-11 22:32:12 +00:00
}
2011-08-30 00:26:14 +00:00
public void Restart ( )
{
if ( ! this . IsHandleCreated | | this . IsDisposed ) return ;
TASView . Items . Clear ( ) ;
ControllerBox . Controls . Clear ( ) ;
ClearPads ( ) ;
Pads . Clear ( ) ;
LoadTAStudio ( ) ;
}
2011-07-30 17:59:18 +00:00
public void LoadTAStudio ( )
2011-06-11 22:32:12 +00:00
{
2011-06-12 14:42:50 +00:00
//TODO: don't engage until new/open project
/ /
2012-08-17 02:26:47 +00:00
Global . MainForm . PauseEmulator ( ) ;
2011-06-12 14:42:50 +00:00
Engaged = true ;
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "TAStudio engaged" ) ;
2012-07-26 22:10:18 +00:00
if ( Global . MovieSession . Movie . Mode ! = MOVIEMODE . INACTIVE )
{
Global . MovieSession . Movie . TastudioOn = true ;
Global . MainForm . StopOnFrame = - 1 ;
ReadOnlyCheckBox . Checked = Global . MainForm . ReadOnly ;
}
else
{
ReadOnlyCheckBox . Checked = false ;
}
2011-06-11 22:32:12 +00:00
LoadConfigSettings ( ) ;
2012-07-26 22:10:18 +00:00
2011-06-11 22:59:21 +00:00
DisplayList ( ) ;
2012-07-26 22:10:18 +00:00
2011-07-24 17:29:09 +00:00
//Add virtual pads
switch ( Global . Emulator . SystemId )
{
case "NULL" :
default :
break ;
2012-04-01 18:53:06 +00:00
case "A26" :
VirtualPadA26 ataripad1 = new VirtualPadA26 ( ) ;
ataripad1 . Location = new Point ( 8 , 19 ) ;
ataripad1 . Controller = "P1" ;
VirtualPadA26 ataripad2 = new VirtualPadA26 ( ) ;
ataripad2 . Location = new Point ( 188 , 19 ) ;
ataripad2 . Controller = "P2" ;
Pads . Add ( ataripad1 ) ;
Pads . Add ( ataripad2 ) ;
ControllerBox . Controls . Add ( Pads [ 0 ] ) ;
ControllerBox . Controls . Add ( Pads [ 1 ] ) ;
VirtualPadA26Control ataricontrols = new VirtualPadA26Control ( ) ;
ataricontrols . Location = new Point ( 8 , 109 ) ;
Pads . Add ( ataricontrols ) ;
ControllerBox . Controls . Add ( Pads [ 2 ] ) ;
break ;
2011-07-24 17:29:09 +00:00
case "NES" :
2011-07-24 19:31:58 +00:00
VirtualPadNES nespad1 = new VirtualPadNES ( ) ;
nespad1 . Location = new Point ( 8 , 19 ) ;
2011-07-24 20:17:21 +00:00
nespad1 . Controller = "P1" ;
2011-07-24 19:31:58 +00:00
VirtualPadNES nespad2 = new VirtualPadNES ( ) ;
nespad2 . Location = new Point ( 188 , 19 ) ;
2011-07-24 20:17:21 +00:00
nespad2 . Controller = "P2" ;
2011-07-24 19:31:58 +00:00
Pads . Add ( nespad1 ) ;
Pads . Add ( nespad2 ) ;
ControllerBox . Controls . Add ( Pads [ 0 ] ) ;
ControllerBox . Controls . Add ( Pads [ 1 ] ) ;
2011-07-30 13:48:13 +00:00
VirtualPadNESControl controlpad1 = new VirtualPadNESControl ( ) ;
controlpad1 . Location = new Point ( 8 , 109 ) ;
Pads . Add ( controlpad1 ) ;
ControllerBox . Controls . Add ( Pads [ 2 ] ) ;
2011-07-24 19:31:58 +00:00
break ;
case "SMS" :
2012-04-29 14:18:10 +00:00
case "SG" :
2011-07-24 19:31:58 +00:00
case "GG" :
VirtualPadSMS smspad1 = new VirtualPadSMS ( ) ;
smspad1 . Location = new Point ( 8 , 19 ) ;
2011-07-26 02:47:21 +00:00
smspad1 . Controller = "P1" ;
2011-07-24 19:31:58 +00:00
VirtualPadSMS smspad2 = new VirtualPadSMS ( ) ;
smspad2 . Location = new Point ( 188 , 19 ) ;
2011-07-26 02:47:21 +00:00
smspad2 . Controller = "P2" ;
2011-07-24 19:31:58 +00:00
Pads . Add ( smspad1 ) ;
Pads . Add ( smspad2 ) ;
2011-07-24 17:29:09 +00:00
ControllerBox . Controls . Add ( Pads [ 0 ] ) ;
ControllerBox . Controls . Add ( Pads [ 1 ] ) ;
2011-07-30 13:48:13 +00:00
VirtualPadSMSControl controlpad2 = new VirtualPadSMSControl ( ) ;
controlpad2 . Location = new Point ( 8 , 109 ) ;
Pads . Add ( controlpad2 ) ;
ControllerBox . Controls . Add ( Pads [ 2 ] ) ;
2011-07-24 17:29:09 +00:00
break ;
2011-07-30 01:09:44 +00:00
case "PCE" :
VirtualPadPCE pcepad1 = new VirtualPadPCE ( ) ;
pcepad1 . Location = new Point ( 8 , 19 ) ;
pcepad1 . Controller = "P1" ;
VirtualPadPCE pcepad2 = new VirtualPadPCE ( ) ;
pcepad2 . Location = new Point ( 188 , 19 ) ;
pcepad2 . Controller = "P2" ;
VirtualPadPCE pcepad3 = new VirtualPadPCE ( ) ;
pcepad3 . Location = new Point ( 8 , 109 ) ;
pcepad3 . Controller = "P3" ;
VirtualPadPCE pcepad4 = new VirtualPadPCE ( ) ;
pcepad4 . Location = new Point ( 188 , 109 ) ;
pcepad4 . Controller = "P4" ;
Pads . Add ( pcepad1 ) ;
Pads . Add ( pcepad2 ) ;
Pads . Add ( pcepad3 ) ;
Pads . Add ( pcepad4 ) ;
ControllerBox . Controls . Add ( Pads [ 0 ] ) ;
ControllerBox . Controls . Add ( Pads [ 1 ] ) ;
ControllerBox . Controls . Add ( Pads [ 2 ] ) ;
ControllerBox . Controls . Add ( Pads [ 3 ] ) ;
break ;
2011-07-24 17:29:09 +00:00
}
2011-06-11 22:32:12 +00:00
}
2011-07-30 17:59:18 +00:00
private void TAStudio_Load ( object sender , EventArgs e )
{
2011-09-13 00:04:33 +00:00
if ( ! Global . MainForm . INTERIM )
{
newProjectToolStripMenuItem . Enabled = false ;
openProjectToolStripMenuItem . Enabled = false ;
saveProjectToolStripMenuItem . Enabled = false ;
saveProjectAsToolStripMenuItem . Enabled = false ;
recentToolStripMenuItem . Enabled = false ;
importTASFileToolStripMenuItem . Enabled = false ;
}
2011-07-30 17:59:18 +00:00
LoadTAStudio ( ) ;
}
2011-06-11 22:32:12 +00:00
private void LoadConfigSettings ( )
{
defaultWidth = Size . Width ; //Save these first so that the user can restore to its original size
defaultHeight = Size . Height ;
2011-07-30 01:26:13 +00:00
if ( Global . Config . TAStudioSaveWindowPosition & & Global . Config . TASWndx > = 0 & & Global . Config . TASWndy > = 0 )
this . Location = new Point ( Global . Config . TASWndx , Global . Config . TASWndy ) ;
if ( Global . Config . TASWidth > = 0 & & Global . Config . TASHeight > = 0 )
{
this . Size = new System . Drawing . Size ( Global . Config . TASWidth , Global . Config . TASHeight ) ;
}
2011-06-11 22:32:12 +00:00
}
private void SaveConfigSettings ( )
{
2011-06-12 18:31:42 +00:00
Engaged = false ;
2011-06-11 22:32:12 +00:00
Global . Config . TASWndx = this . Location . X ;
Global . Config . TASWndy = this . Location . Y ;
Global . Config . TASWidth = this . Right - this . Left ;
Global . Config . TASHeight = this . Bottom - this . Top ;
2011-07-26 00:26:05 +00:00
ClearPads ( ) ;
}
2011-07-24 20:17:21 +00:00
2011-07-26 00:26:05 +00:00
public void ClearPads ( )
{
2011-07-24 20:17:21 +00:00
for ( int x = 0 ; x < Pads . Count ; x + + )
Pads [ x ] . Clear ( ) ;
2011-06-11 22:32:12 +00:00
}
private void exitToolStripMenuItem_Click ( object sender , EventArgs e )
{
this . Close ( ) ;
}
private void settingsToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
saveWindowPositionToolStripMenuItem . Checked = Global . Config . TAStudioSaveWindowPosition ;
autoloadToolStripMenuItem . Checked = Global . Config . AutoloadTAStudio ;
2011-07-30 17:59:18 +00:00
updatePadsOnMovePlaybackToolStripMenuItem . Checked = Global . Config . TASUpdatePads ;
2011-06-11 22:32:12 +00:00
}
private void saveWindowPositionToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . TAStudioSaveWindowPosition ^ = true ;
}
private void restoreWindowToolStripMenuItem_Click ( object sender , EventArgs e )
{
this . Size = new System . Drawing . Size ( defaultWidth , defaultHeight ) ;
}
private void StopButton_Click ( object sender , EventArgs e )
{
2011-07-22 01:34:21 +00:00
Global . MainForm . StopMovie ( ) ;
2011-07-26 00:26:05 +00:00
Restart ( ) ;
2011-06-11 22:32:12 +00:00
}
private void FrameAdvanceButton_Click ( object sender , EventArgs e )
{
2011-06-11 19:39:34 +00:00
Global . MainForm . PressFrameAdvance = true ;
2011-06-11 22:32:12 +00:00
}
2011-05-22 18:38:44 +00:00
2011-06-11 22:32:12 +00:00
private void RewindButton_Click ( object sender , EventArgs e )
{
2012-06-01 05:49:26 +00:00
Global . MovieSession . Movie . RewindToFrame ( Global . Emulator . Frame - 1 ) ;
2012-08-18 00:04:12 +00:00
UpdateValues ( ) ;
2011-06-11 22:32:12 +00:00
}
private void PauseButton_Click ( object sender , EventArgs e )
{
Global . MainForm . TogglePause ( ) ;
}
private void autoloadToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . AutoloadTAStudio ^ = true ;
}
private void checkBox1_CheckedChanged ( object sender , EventArgs e )
{
if ( ReadOnlyCheckBox . Checked )
{
2012-08-17 01:26:00 +00:00
Global . MainForm . SetReadOnly ( true ) ;
2011-06-11 22:32:12 +00:00
ReadOnlyCheckBox . BackColor = System . Drawing . SystemColors . Control ;
2012-07-26 22:10:18 +00:00
if ( Global . MovieSession . Movie . Mode ! = MOVIEMODE . INACTIVE )
{
Global . MovieSession . Movie . Mode = MOVIEMODE . PLAY ;
toolTip1 . SetToolTip ( this . ReadOnlyCheckBox , "Currently Read-Only Mode" ) ;
}
2011-06-11 22:32:12 +00:00
}
else
{
2012-08-17 01:26:00 +00:00
Global . MainForm . SetReadOnly ( false ) ;
2012-06-25 00:06:07 +00:00
ReadOnlyCheckBox . BackColor = Color . LightCoral ;
2012-07-26 22:10:18 +00:00
if ( Global . MovieSession . Movie . Mode ! = MOVIEMODE . INACTIVE )
{
Global . MovieSession . Movie . Mode = MOVIEMODE . RECORD ;
toolTip1 . SetToolTip ( this . ReadOnlyCheckBox , "Currently Read+Write Mode" ) ;
}
2011-06-11 22:32:12 +00:00
}
2012-07-26 22:10:18 +00:00
}
2011-06-11 23:54:35 +00:00
private void RewindToBeginning_Click ( object sender , EventArgs e )
{
2011-06-12 00:14:19 +00:00
Global . MainForm . Rewind ( Global . Emulator . Frame ) ;
DisplayList ( ) ;
2011-06-11 23:54:35 +00:00
}
private void FastForwardToEnd_Click ( object sender , EventArgs e )
{
2012-06-03 04:04:13 +00:00
if ( true = = this . FastFowardToEnd . Checked )
{
2012-06-18 01:36:38 +00:00
Global . MainForm . StopOnFrame = - 1 ;
2012-06-03 04:04:13 +00:00
}
else
{
2012-06-18 01:36:38 +00:00
Global . MainForm . StopOnFrame = Global . MovieSession . Movie . LogLength ( ) ;
2012-06-03 04:04:13 +00:00
}
2012-06-25 00:06:07 +00:00
this . FastFowardToEnd . Checked ^ = true ;
Global . MainForm . FastForward = this . FastFowardToEnd . Checked ;
if ( true = = this . FastFowardToEnd . Checked )
{
this . FastForward . Checked = false ;
this . TurboFastForward . Checked = false ;
}
}
2011-06-11 23:54:35 +00:00
private void editToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
2012-08-17 02:18:25 +00:00
if ( ReadOnlyCheckBox . Checked )
2011-06-11 23:54:35 +00:00
{
2012-08-17 03:04:35 +00:00
clearToolStripMenuItem2 . Enabled = false ;
2012-08-17 02:18:25 +00:00
deleteFramesToolStripMenuItem . Enabled = false ;
cloneToolStripMenuItem . Enabled = false ;
2011-06-11 23:54:35 +00:00
insertFrameToolStripMenuItem . Enabled = false ;
2012-08-17 02:18:25 +00:00
insertNumFramesToolStripMenuItem . Enabled = false ;
2012-08-17 03:24:33 +00:00
truncateMovieToolStripMenuItem . Enabled = false ;
2012-08-17 02:18:25 +00:00
2011-06-11 23:54:35 +00:00
}
else
{
2012-08-17 03:04:35 +00:00
clearToolStripMenuItem2 . Enabled = true ;
2012-08-17 02:18:25 +00:00
deleteFramesToolStripMenuItem . Enabled = true ;
cloneToolStripMenuItem . Enabled = true ;
2011-06-11 23:54:35 +00:00
insertFrameToolStripMenuItem . Enabled = true ;
2012-08-17 02:18:25 +00:00
insertNumFramesToolStripMenuItem . Enabled = true ;
2012-08-17 03:24:33 +00:00
truncateMovieToolStripMenuItem . Enabled = true ;
2011-06-11 23:54:35 +00:00
}
}
private void insertFrameToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-08-17 01:26:00 +00:00
if ( ReadOnlyCheckBox . Checked )
{
2011-06-11 23:54:35 +00:00
return ;
2012-08-17 01:26:00 +00:00
}
else
{
2012-08-17 02:18:25 +00:00
InsertFrames ( ) ;
2012-08-17 01:26:00 +00:00
}
2011-06-11 23:54:35 +00:00
}
2011-07-30 17:59:18 +00:00
private void updatePadsOnMovePlaybackToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . TASUpdatePads ^ = true ;
}
2011-09-13 00:04:33 +00:00
private void newProjectToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-06-25 00:06:07 +00:00
Global . MainForm . RecordMovie ( ) ;
}
2011-09-13 00:04:33 +00:00
private void openProjectToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-06-25 00:06:07 +00:00
Global . MainForm . PlayMovie ( ) ;
}
2011-09-13 00:04:33 +00:00
private void saveProjectToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-06-25 00:06:07 +00:00
Global . MovieSession . Movie . WriteMovie ( ) ;
2011-09-13 00:04:33 +00:00
}
private void saveProjectAsToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-06-25 00:06:07 +00:00
string fileName = SaveRecordingAs ( ) ;
2011-09-13 00:04:33 +00:00
2012-06-25 00:06:07 +00:00
if ( "" ! = fileName )
{
Global . MovieSession . Movie . UpdateFileName ( fileName ) ;
Global . MovieSession . Movie . WriteMovie ( ) ;
}
2011-09-13 00:04:33 +00:00
}
2012-04-29 13:25:35 +00:00
private void ClearVirtualPadHolds ( )
{
foreach ( var controller in ControllerBox . Controls )
{
if ( controller is VirtualPad )
( ( VirtualPad ) controller ) . Clear ( ) ;
}
}
private void clearVirtualPadsToolStripMenuItem_Click ( object sender , EventArgs e )
{
ClearVirtualPadHolds ( ) ;
}
private void clearToolStripMenuItem1_Click ( object sender , EventArgs e )
{
ClearVirtualPadHolds ( ) ;
}
2012-05-28 00:44:27 +00:00
2012-06-25 00:06:07 +00:00
private void FastForward_Click ( object sender , EventArgs e )
{
this . FastForward . Checked ^ = true ;
Global . MainForm . FastForward = this . FastForward . Checked ;
if ( true = = this . FastForward . Checked )
{
this . TurboFastForward . Checked = false ;
this . FastFowardToEnd . Checked = false ;
}
}
private void TurboFastForward_Click ( object sender , EventArgs e )
{
Global . MainForm . TurboFastForward ^ = true ;
this . TurboFastForward . Checked ^ = true ;
if ( true = = this . TurboFastForward . Checked )
{
this . FastForward . Checked = false ;
this . FastFowardToEnd . Checked = false ;
}
}
2012-06-01 05:49:26 +00:00
private void TASView_SelectedIndexChanged ( object sender , EventArgs e )
{
2012-08-18 00:04:12 +00:00
UpdateSlicerDisplay ( ) ;
2012-06-01 05:49:26 +00:00
}
private void TASView_DoubleClick ( object sender , EventArgs e )
{
Global . MovieSession . Movie . RewindToFrame ( TASView . selectedItem ) ;
2012-08-18 00:04:12 +00:00
UpdateValues ( ) ;
2012-06-01 05:49:26 +00:00
}
2012-06-07 04:47:54 +00:00
private void Insert_Click ( object sender , EventArgs e )
2012-08-17 01:26:00 +00:00
{
2012-08-17 02:18:25 +00:00
InsertFrames ( ) ;
2012-06-01 05:49:26 +00:00
}
2012-06-07 04:47:54 +00:00
private void Delete_Click ( object sender , EventArgs e )
2012-08-17 01:26:00 +00:00
{
2012-08-17 02:18:25 +00:00
DeleteFrames ( ) ;
2012-06-01 05:49:26 +00:00
}
2012-06-25 00:06:07 +00:00
private static string SaveRecordingAs ( )
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . InitialDirectory = PathManager . MakeAbsolutePath ( Global . Config . MoviesPath , "" ) ;
sfd . DefaultExt = "." + Global . Config . MovieExtension ;
//sfd.FileName = RecordBox.Text;
sfd . FileName = Global . MovieSession . Movie . Filename ;
sfd . Filter = "Generic Movie Files (*." + Global . Config . MovieExtension + ")|*." + Global . Config . MovieExtension + "|" + Global . MainForm . GetMovieExtName ( ) + "|All Files (*.*)|*.*" ;
Global . Sound . StopSound ( ) ;
var result = sfd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
if ( result = = DialogResult . OK )
{
return sfd . FileName ;
}
return "" ;
}
2012-08-17 01:01:46 +00:00
private void TASView_MouseWheel ( object sender , MouseEventArgs e )
{
//if ((Control.MouseButtons & MouseButtons.Middle) > 0) //adelikat: TODO: right-click + mouse wheel won't work because in this dialog, right-click freezes emulation in the main window. Why? Hex Editor doesn't do this for instance
if ( ( Control . ModifierKeys & Keys . Control ) > 0 )
{
if ( e . Delta > 0 ) //Scroll up
{
Global . MovieSession . Movie . RewindToFrame ( Global . Emulator . Frame - 1 ) ;
}
else if ( e . Delta < 0 ) //Scroll down
{
Global . MainForm . PressFrameAdvance = true ;
}
2012-08-18 00:04:12 +00:00
UpdateValues ( ) ;
2012-08-17 01:01:46 +00:00
}
}
2012-08-17 01:26:00 +00:00
private void contextMenuStrip1_Opening ( object sender , CancelEventArgs e )
{
if ( ReadOnlyCheckBox . Checked )
{
2012-08-17 03:04:35 +00:00
clearToolStripMenuItem3 . Visible = false ;
ContextMenu_Delete . Visible = false ;
cloneToolStripMenuItem1 . Visible = false ;
ContextMenu_Insert . Visible = false ;
insertFramesToolStripMenuItem . Visible = false ;
toolStripSeparator5 . Visible = false ;
2012-08-17 03:24:33 +00:00
truncateMovieToolStripMenuItem1 . Visible = false ;
toolStripSeparator9 . Visible = false ;
2012-08-17 01:26:00 +00:00
}
else
{
2012-08-17 03:04:35 +00:00
clearToolStripMenuItem3 . Visible = true ;
ContextMenu_Delete . Visible = true ;
cloneToolStripMenuItem1 . Visible = true ;
ContextMenu_Insert . Visible = true ;
insertFramesToolStripMenuItem . Visible = true ;
toolStripSeparator5 . Visible = true ;
2012-08-17 03:24:33 +00:00
truncateMovieToolStripMenuItem1 . Visible = true ;
toolStripSeparator9 . Visible = true ;
2012-08-17 01:26:00 +00:00
}
}
2012-08-17 02:18:25 +00:00
private void cloneToolStripMenuItem_Click ( object sender , EventArgs e )
{
Clone ( ) ;
}
private void cloneToolStripMenuItem1_Click ( object sender , EventArgs e )
{
Clone ( ) ;
}
private void deleteFramesToolStripMenuItem_Click ( object sender , EventArgs e )
{
DeleteFrames ( ) ;
}
private void InsertFrames ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
for ( int index = 0 ; index < list . Count ; index + + )
{
Global . MovieSession . Movie . InsertBlankFrame ( list [ index ] ) ;
}
UpdateValues ( ) ;
}
private void DeleteFrames ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
for ( int index = 0 ; index < list . Count ; index + + )
{
2012-08-17 23:56:37 +00:00
Global . MovieSession . Movie . DeleteFrame ( list [ 0 ] ) ; //TODO: this doesn't allow of non-continuous deletion, instead it should iterate from last to first and remove the iterated value
2012-08-17 02:18:25 +00:00
}
UpdateValues ( ) ;
}
private void Clone ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
for ( int index = 0 ; index < list . Count ; index + + )
{
Global . MovieSession . Movie . InsertFrame ( Global . MovieSession . Movie . GetInputFrame ( list [ index ] ) , list [ index ] ) ;
}
UpdateValues ( ) ;
}
2012-08-17 02:26:47 +00:00
private void ClearFrames ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
for ( int index = 0 ; index < list . Count ; index + + )
{
Global . MovieSession . Movie . ClearFrame ( list [ index ] ) ;
}
UpdateValues ( ) ;
}
2012-08-17 03:04:35 +00:00
private void InsertNumFrames ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
if ( list . Count > 0 )
{
InputPrompt prompt = new InputPrompt ( ) ;
prompt . TextInputType = InputPrompt . InputType . UNSIGNED ;
prompt . SetMessage ( "How many frames?" ) ;
prompt . SetInitialValue ( "1" ) ;
prompt . SetTitle ( "Insert new frames" ) ;
prompt . ShowDialog ( ) ;
if ( prompt . UserOK )
{
int frames = int . Parse ( prompt . UserText ) ;
for ( int i = 0 ; i < frames ; i + + )
{
Global . MovieSession . Movie . InsertBlankFrame ( list [ 0 ] + i ) ;
}
}
}
UpdateValues ( ) ;
}
private void SelectAll ( )
{
for ( int i = 0 ; i < TASView . ItemCount ; i + + )
{
TASView . SelectItem ( i , true ) ;
}
}
2012-08-17 02:26:47 +00:00
private void clearToolStripMenuItem2_Click ( object sender , EventArgs e )
{
ClearFrames ( ) ;
}
2012-08-17 03:04:35 +00:00
private void insertNumFramesToolStripMenuItem_Click ( object sender , EventArgs e )
{
InsertNumFrames ( ) ;
}
private void insertFramesToolStripMenuItem_Click ( object sender , EventArgs e )
{
InsertNumFrames ( ) ;
}
private void selectAllToolStripMenuItem_Click ( object sender , EventArgs e )
{
SelectAll ( ) ;
}
private void SelectAll_Click ( object sender , EventArgs e )
{
SelectAll ( ) ;
}
2012-08-17 03:24:33 +00:00
private void TruncateMovie ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
if ( list . Count > 0 )
{
Global . MovieSession . Movie . TruncateMovie ( list [ 0 ] ) ;
UpdateValues ( ) ;
}
}
private void truncateMovieToolStripMenuItem_Click ( object sender , EventArgs e )
{
TruncateMovie ( ) ;
}
private void truncateMovieToolStripMenuItem1_Click ( object sender , EventArgs e )
{
TruncateMovie ( ) ;
}
2012-08-17 23:27:29 +00:00
private void CopySelectionToClipBoard ( )
{
Clipboard . Clear ( ) ;
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
for ( int i = 0 ; i < list . Count ; i + + )
{
ClipboardEntry entry = new ClipboardEntry ( ) ;
2012-08-17 23:56:37 +00:00
entry . frame = list [ i ] ;
entry . inputstr = Global . MovieSession . Movie . GetInputFrame ( list [ i ] ) ;
2012-08-17 23:27:29 +00:00
Clipboard . Add ( entry ) ;
}
UpdateSlicerDisplay ( ) ;
}
private void copyToolStripMenuItem_Click ( object sender , EventArgs e )
{
CopySelectionToClipBoard ( ) ;
}
private void UpdateSlicerDisplay ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
if ( list . Count > 0 )
{
SelectionDisplay . Text = list . Count . ToString ( ) + " row" ;
}
else
{
SelectionDisplay . Text = "none" ;
}
if ( Clipboard . Count > 0 )
{
ClipboardDisplay . Text = Clipboard . Count . ToString ( ) + " row" ;
}
else
{
ClipboardDisplay . Text = "none" ;
}
}
private void TASView_Click ( object sender , EventArgs e )
{
UpdateSlicerDisplay ( ) ;
}
2012-08-17 23:56:37 +00:00
private void PasteSelectionOnTop ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
if ( list . Count > 0 )
{
for ( int i = 0 ; i < Clipboard . Count ; i + + )
{
Global . MovieSession . Movie . ModifyFrame ( Clipboard [ i ] . inputstr , list [ 0 ] + i ) ;
}
}
UpdateValues ( ) ;
}
private void PasteSelectionInsert ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
if ( list . Count > 0 )
{
for ( int i = 0 ; i < Clipboard . Count ; i + + )
{
Global . MovieSession . Movie . InsertFrame ( Clipboard [ i ] . inputstr , list [ 0 ] + i ) ;
}
}
UpdateValues ( ) ;
}
private void pasteToolStripMenuItem_Click ( object sender , EventArgs e )
{
PasteSelectionOnTop ( ) ;
}
private void pasteInsertToolStripMenuItem_Click ( object sender , EventArgs e )
{
PasteSelectionInsert ( ) ;
}
private void CutSelection ( )
{
ListView . SelectedIndexCollection list = TASView . SelectedIndices ;
if ( list . Count > 0 )
{
Clipboard . Clear ( ) ;
for ( int i = 0 ; i < list . Count ; i + + )
{
ClipboardEntry entry = new ClipboardEntry ( ) ;
entry . frame = list [ i ] ;
entry . inputstr = Global . MovieSession . Movie . GetInputFrame ( list [ i ] ) ;
Clipboard . Add ( entry ) ;
Global . MovieSession . Movie . DeleteFrame ( list [ 0 ] ) ;
}
UpdateValues ( ) ;
}
}
private void cutToolStripMenuItem_Click ( object sender , EventArgs e )
{
CutSelection ( ) ;
}
2012-08-18 00:09:00 +00:00
private void TASView_KeyDown ( object sender , KeyEventArgs e )
{
switch ( e . KeyCode )
{
case Keys . Delete :
DeleteFrames ( ) ;
break ;
case Keys . Insert :
InsertFrames ( ) ;
break ;
}
}
2011-06-11 22:32:12 +00:00
}
2011-05-08 11:29:34 +00:00
}