From 2a75b9b8e8ccf0a80ee4550aa7a18e1444e8668d Mon Sep 17 00:00:00 2001 From: ansstuff Date: Mon, 5 Sep 2011 13:12:24 +0000 Subject: [PATCH] * added "Follow playback" in View menu * "<<" button now jumps to the beginning of greenzone * changing currFrameCounter doesn't reset selection anymore * fixed "Select All" function --- src/drivers/win/config.cpp | 2 + src/drivers/win/res.rc | 5 +- src/drivers/win/resource.h | 3 +- src/drivers/win/tasedit.cpp | 137 +++++++++++++++++++----------------- src/drivers/win/tasedit.h | 1 + src/input.cpp | 4 +- 6 files changed, 83 insertions(+), 69 deletions(-) diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index db85361d..2b998988 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -67,6 +67,7 @@ extern bool SingleInstanceOnly; extern bool oldInputDisplay; extern bool fullSaveStateLoads; extern int frameSkipAmt; +extern bool TASEdit_follow_playback; //window positions and sizes: extern int ChtPosX,ChtPosY; @@ -282,6 +283,7 @@ static CFGSTRUCT fceuconfig[] = { AC(AFoff), AC(AutoFireOffset), AC(DesynchAutoFire), + AC(TASEdit_follow_playback), AC(lagCounterDisplay), AC(oldInputDisplay), AC(movieSubtitles), diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 4bd7d997..c46da283 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -244,7 +244,10 @@ BEGIN MENUITEM "&Truncate\tCtrl+T", ID_EDIT_TRUNCATE MENUITEM "&Branch\tCtrl+B", ID_EDIT_BRANCH, INACTIVE END - MENUITEM "&View", ID_VIEW, INACTIVE + POPUP "&View" + BEGIN + MENUITEM "&Follow playback", ID_VIEW_FOLLOW_PLAYBACK + END POPUP "&Help" BEGIN MENUITEM "&TASEdit Help...", ID_HELP_TASEDITHELP diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 01e2c84a..3b1a3ce4 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -807,6 +807,7 @@ #define IDC_C_WATCH_Separa 40416 #define ID_GAME_USECONFIG 40417 #define FCEUX_CONTEXT_GUICONFIG 40418 +#define ID_VIEW_FOLLOW_PLAYBACK 40419 #define IDC_DEBUGGER_ICONTRAY 55535 #define MW_ValueLabel2 65423 #define MW_ValueLabel1 65426 @@ -816,7 +817,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 160 -#define _APS_NEXT_COMMAND_VALUE 40419 +#define _APS_NEXT_COMMAND_VALUE 40420 #define _APS_NEXT_CONTROL_VALUE 1261 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 0f904956..722a52d3 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -15,6 +15,7 @@ #include "joystick.h" #include "help.h" #include "main.h" //For the GetRomName() function +//#include "config.h" using namespace std; @@ -22,6 +23,7 @@ using namespace std; //http://forums.devx.com/archive/index.php/t-37234.html int TasEdit_wndx, TasEdit_wndy; +bool TASEdit_follow_playback = false; string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page @@ -100,45 +102,48 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg) SelectObject(msg->nmcd.hdc,debugSystem->hFixedFont); cell_x = msg->iSubItem; cell_y = msg->nmcd.dwItemSpec; - if(cell_x == COLUMN_ARROW || cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2) + if(cell_x > COLUMN_ARROW) { - // frame number - if (cell_y == currFrameCounter) + if(cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2) { - // current frame - msg->clrTextBk = CUR_FRAMENUM_COLOR; - } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) + // frame number + if (cell_y == currFrameCounter) + { + // current frame + msg->clrTextBk = CUR_FRAMENUM_COLOR; + } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) + { + // TODO: redline for lag frames + // green zone frame + msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; + } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR; + } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2) { - // TODO: redline for lag frames - // green zone frame - msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; - } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR; - } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2) - { - // pad 1 or 3 - if (cell_y == currFrameCounter) + // pad 1 or 3 + if (cell_y == currFrameCounter) + { + // current frame + msg->clrTextBk = CUR_INPUT_COLOR1; + } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) + { + // TODO: redline for lag frames + // green zone frame + msg->clrTextBk = GREENZONE_INPUT_COLOR1; + } else msg->clrTextBk = NORMAL_INPUT_COLOR1; + } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3) { - // current frame - msg->clrTextBk = CUR_INPUT_COLOR1; - } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) - { - // TODO: redline for lag frames - // green zone frame - msg->clrTextBk = GREENZONE_INPUT_COLOR1; - } else msg->clrTextBk = NORMAL_INPUT_COLOR1; - } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3) - { - // pad 2 or 4 - if (cell_y == currFrameCounter) - { - // current frame - msg->clrTextBk = CUR_INPUT_COLOR2; - } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) - { - // TODO: redline for lag frames - // green zone frame - msg->clrTextBk = GREENZONE_INPUT_COLOR2; - } else msg->clrTextBk = NORMAL_INPUT_COLOR2; + // pad 2 or 4 + if (cell_y == currFrameCounter) + { + // current frame + msg->clrTextBk = CUR_INPUT_COLOR2; + } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) + { + // TODO: redline for lag frames + // green zone frame + msg->clrTextBk = GREENZONE_INPUT_COLOR2; + } else msg->clrTextBk = NORMAL_INPUT_COLOR2; + } } return CDRF_DODEFAULT; default: @@ -173,26 +178,19 @@ void UpdateTasEdit() ListView_SetItemCountEx(hwndList,currMovieData.getNumRecords(),LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL); } - //update the cursor + //update the cursor when playing int newCursor = currFrameCounter; if(newCursor != lastCursor) { - //unselect all prior rows - TSelectionFrames oldSelected = selectionFrames; - for(TSelectionFrames::iterator it(oldSelected.begin()); it != oldSelected.end(); it++) - ListView_SetItemState(hwndList,*it,0, LVIS_FOCUSED|LVIS_SELECTED); - + /* if (!FCEUI_EmulationPaused()) + //select the row + ListView_SetItemState(hwndList,newCursor,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); + */ //scroll to the row - ListView_EnsureVisible(hwndList,newCursor,FALSE); - //select the row - ListView_SetItemState(hwndList,newCursor,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); - + if (TASEdit_follow_playback) ListView_EnsureVisible(hwndList,newCursor,FALSE); //update the old and new rows ListView_Update(hwndList,newCursor); ListView_Update(hwndList,lastCursor); - for(TSelectionFrames::iterator it(oldSelected.begin()); it != oldSelected.end(); it++) - ListView_Update(hwndList,*it); - lastCursor = newCursor; } @@ -515,9 +513,10 @@ static void SelectAll() { ClearSelection(); for(unsigned int i=0;i0) JumpToFrame(currFrameCounter-1); break; - case TASEDIT_PLAYSTOP: //Pause/Unpses (Play/Stop) movie FCEUI_ToggleEmulationPause(); break; - case TASEDIT_REWIND_FULL: - //rewinds to beginning of movie - JumpToFrame(0); + //rewinds to beginning of greenzone + JumpToFrame(FindBeginningOfGreenZone(0)); break; case TASEDIT_FOWARD_FULL: //moves to the end of greenzone JumpToFrame(currMovieData.greenZoneCount-1); break; - + case ID_VIEW_FOLLOW_PLAYBACK: + //switch "Follow playback" flag + TASEdit_follow_playback ^= 1; + CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); + break; } break; } @@ -1270,21 +1271,27 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar return FALSE; } +int FindBeginningOfGreenZone(int starting_index) +{ + for (int i=starting_index; i