From dd3dac580800be417880d47ea353438ecc82210d Mon Sep 17 00:00:00 2001 From: ansstuff Date: Fri, 30 Sep 2011 19:49:21 +0000 Subject: [PATCH] * logging all display messages into Message Log * Tasedit: special method of inserting frames * Tasedit: progressbar updating when loading/saving large projects * Tasedit: moved "Follow cursor" checkbox from View menu to main TASEdit window --- changelog.txt | 19 +++++ src/drivers/win/res.rc | 33 ++++----- src/drivers/win/resource.h | 2 +- src/drivers/win/tasedit.cpp | 86 +++++++++++++--------- src/drivers/win/tasedit.h | 1 + src/drivers/win/taseditlib/taseditproj.cpp | 1 - src/movie.cpp | 30 +++++++- src/movie.h | 3 + src/video.cpp | 5 ++ 9 files changed, 123 insertions(+), 57 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1a1ff51c..bf99be6b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,23 @@ +30-sept-2011 - AnS - logging all display messages to Message Log +30-sept-2011 - AnS - Tasedit: special method of inserting frames; progressbar updating when loading/saving large projects; moved "Follow cursor" checkbox from View menu to main TASEdit window +30-sept-2011 - AnS - Tasedit: View->Show dot in empty cells; ClearFrames (Del), Cut operation clears frames instead of deleting; checking unsaved project on Exit and Open project +28-sept-2011 - CaH4e3 - resetexstate crash fix +27-sept-2011 - AnS - Fixed old bug with "Play Movie From Beginning" +26-sept-2011 - AnS - added support for "Enable HUD recording" option to SDL version +25-sept-2011 - AnS - Tasedit: progressbar; holding "<" and ">" buttons; Ctrl-Delete bugfix +25-sept-2011 - zeromus - newppu-fix bug in scroll reg logic causing mis-scrolls in p'radikus conflict +24-sept-2011 - CaH4e3 - latest mapper changes; code/data logger now can log data access from the RAM code; the new button to save unused data to the code/data logger +24-sept-2011 - AnS - Tasedit: changed control scheme to single click instead of double click +23-sept-2011 - AnS - File->AVI/Wav->Enable HUD recording +23-sept-2011 - AnS - moved "Display movie status icon" from Config->Movie options to Config->Display +23-sept-2011 - AnS - Config->Display->Rerecord counter; no more TweakCount +23-sept-2011 - AnS - Config->Movie options->Always suggest Read-Only replay (for Replay dialog) +22-sept-2011 - AnS - deleted "Lag Counter Reset" hotkey; added "Open TAS Edit" hotkey +22-sept-2011 - AnS - fixed long "savestate" messages containing path +22-sept-2011 - AnS - Tasedit: auto clear "Disable speed throttling" and "Run in background", auto set "Set high-priority thread" when entering TASEdit; FCEUX runs in bg when TASEdit has focus; Config->"Mute Turbo" check (same as in Config->Sound) +19-sept-2011 - AnS - Tasedit: accelerator table; Config->"Set greenzone capacity"; pauseframe is shown by flashing color +18-sept-2011 - zeromus - datalatch mapper-fix bug where wramless games would be able to do something mysterious to unmapped host emulator memory 17-sept-2011 - AnS - Tasedit: forced read-only behaviour when seeking or holding turbo; "Auto-restore last position" checkbox in playback controls; also fixed item drawing method, no more flicker and slowdowns 12-sept-2011 - prg318 - sdl: rename InputType to CurInputType due to variable of same name in src/movie.h 12-sept-2011 - AnS - Tasedit: rewrote project save/load functions; various bugfixes; Added string "Tweak Count" to Replay loading dialog diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index cb397166..d9b7ae5f 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -245,8 +245,6 @@ BEGIN BEGIN MENUITEM "Highlight &lag frames", ID_VIEW_SHOW_LAG_FRAMES MENUITEM "Show &dot in empty cells", ID_VIEW_SHOWDOTINEMPTYCELLS - MENUITEM SEPARATOR - MENUITEM "&Follow playback\tCtrl+F", ID_VIEW_FOLLOW_PLAYBACK END POPUP "Config" BEGIN @@ -1339,31 +1337,32 @@ CAPTION "TAS Editor" MENU TASEDITMENU FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER,6,5,310,370 - GROUPBOX "Playback control",IDC_STATIC,322,5,118,49,BS_CENTER,WS_EX_RIGHT + CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER,7,5,310,370 + GROUPBOX "Playback control",IDC_STATIC,322,5,118,62,BS_CENTER,WS_EX_RIGHT PUSHBUTTON "<<",TASEDIT_REWIND_FULL,326,14,22,14,NOT WS_TABSTOP PUSHBUTTON "<",TASEDIT_REWIND,348,14,22,14,NOT WS_TABSTOP PUSHBUTTON "||",TASEDIT_PLAYSTOP,370,14,22,14,NOT WS_TABSTOP PUSHBUTTON ">",TASEDIT_FORWARD,392,14,22,14,NOT WS_TABSTOP PUSHBUTTON ">>",TASEDIT_FORWARD_FULL,414,14,22,14,NOT WS_TABSTOP + CONTROL "",IDC_PROGRESS_BUTTON,"Button",BS_OWNERDRAW | WS_TABSTOP,326,42,110,10 + CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER,326,44,110,6 + CONTROL " Follow cursor",CHECK_FOLLOW_CURSOR,"Button",BS_AUTOCHECKBOX,327,30,105,12 CONTROL " Auto-restore last position",CHECK_AUTORESTORE_PLAYBACK, - "Button",BS_AUTOCHECKBOX,328,31,105,12 - GROUPBOX "Recording input",IDC_STATIC,322,55,118,50,BS_CENTER,WS_EX_RIGHT - GROUPBOX "Editing",IDC_STATIC,322,106,118,41,BS_CENTER,WS_EX_RIGHT + "Button",BS_AUTOCHECKBOX,327,53,105,12 + GROUPBOX "Recording input",IDC_STATIC,322,68,118,48,BS_CENTER,WS_EX_RIGHT + GROUPBOX "Editing",IDC_STATIC,322,118,118,29,BS_CENTER,WS_EX_RIGHT GROUPBOX "Bookmarks",IDC_STATIC,322,148,118,103,BS_CENTER,WS_EX_RIGHT CONTROL "",IDC_LIST3,"SysListView32",LVS_LIST | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER,327,159,108,88 GROUPBOX "Project Input Logs",IDC_STATIC,322,252,118,123,BS_CENTER,WS_EX_RIGHT CONTROL "",IDC_LIST2,"SysListView32",LVS_LIST | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER,327,263,108,108,WS_EX_LEFTSCROLLBAR - CONTROL "",IDC_PROGRESS_BUTTON,"Button",BS_OWNERDRAW | WS_TABSTOP,326,41,110,12 - CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER,326,44,110,6 - CONTROL " OFF",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,328,65,29,10 - CONTROL " ON",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,328,79,29,10 - CONTROL " 1P",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,380,65,25,10 - CONTROL " 2P",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,409,65,23,10 - CONTROL " 3P",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,380,79,25,10 - CONTROL " 4P",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,409,79,23,10 - CONTROL " Superimpose",IDC_SUPERIMPOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,92,55,10 - CONTROL " Omit blank",IDC_OMITBLANK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,387,92,49,10 + CONTROL " OFF",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,328,78,29,10 + CONTROL " ON",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,328,91,29,10 + CONTROL " 1P",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,380,78,25,10 + CONTROL " 2P",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,409,78,23,10 + CONTROL " 3P",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,380,91,25,10 + CONTROL " 4P",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,409,91,23,10 + CONTROL " Superimpose",IDC_SUPERIMPOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,104,55,10 + CONTROL " Omit blank",IDC_OMITBLANK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,387,104,49,10 END ASSEMBLER DIALOGEX 0, 0, 202, 135 diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index af2c07ba..4cd9f2a4 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -498,6 +498,7 @@ #define IDC_C_WATCH_SEPARATE 1259 #define IDC_TWEAKCOUNT 1260 #define CHECK_AUTORESTORE_PLAYBACK 1261 +#define CHECK_FOLLOW_CURSOR 1263 #define IDC_PROGRESS1 1262 #define MENU_NETWORK 40040 #define MENU_PALETTE 40041 @@ -814,7 +815,6 @@ #define IDC_C_WATCH_Separa 40416 #define ID_GAME_USECONFIG 40417 #define FCEUX_CONTEXT_GUICONFIG 40418 -#define ID_VIEW_FOLLOW_PLAYBACK 40419 #define ID_VIEW_SHOW_LAG_FRAMES 40420 #define ID_VIEW_SHOW_TWEAK_COUNT 40421 #define ID_SELECTED_INSERTFRAMES 40422 diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 2054d82a..1dc55398 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -316,6 +316,11 @@ void UpdateList() } } +void UpdateProgressbar(int frame) +{ + SendMessage(hwndProgressbar, PBM_SETPOS, PROGRESSBAR_WIDTH * frame / currMovieData.greenZoneCount, 0); +} + void RedrawWindowCaption() { char windowCaption[300]; // 260 + 30 + 1 + ... @@ -604,10 +609,19 @@ static void InsertFrames() //to keep this from being even slower than it would otherwise be, go ahead and reserve records currMovieData.records.reserve(currMovieData.records.size()+frames); - //insert frames before each selection + //insert frames before each selection, but consecutive selection lines are accounted as single region + frames = 1; + TSelectionFrames::reverse_iterator next_it; for(TSelectionFrames::reverse_iterator it(selectionFrames.rbegin()); it != selectionFrames.rend(); it++) { - currMovieData.insertEmpty(*it,1); + next_it = it; + next_it++; + if (next_it == selectionFrames.rend() || (int)*next_it < ((int)*it - 1)) + { + // end of current region + currMovieData.insertEmpty(*it,frames); + frames = 1; + } else frames++; } UpdateList(); @@ -1110,17 +1124,17 @@ void OpenProject() if(tempstr.rfind(".tas") == std::string::npos) //If they haven't put ".tas" after it, stick it on ourselves tempstr.append(".tas"); splitpath(tempstr.c_str(), drv, dir, name, ext); //Split the path... + project.SetProjectName(name); std::string filename = name; //Get the filename filename.append(ext); //Shove the extension back onto it... project.SetProjectFile(filename); //And update the project's filename. - //Set the project's name to the ROM name - project.SetProjectName(GetRomName()); //Set the fm2 name - std::string thisfm2name = project.GetProjectName(); + std::string thisfm2name = name; thisfm2name.append(".fm2"); project.SetFM2Name(thisfm2name); // switch to read-only mode, but first must uncheck radiobuttons explicitly if (!movie_readonly) FCEUI_MovieToggleReadOnly(); + multitrack_recording_joypad = MULTITRACK_RECORDING_ALL; UncheckRecordingRadioButtons(); RecheckRecordingRadioButtons(); // remember to update fourscore status @@ -1170,12 +1184,11 @@ bool SaveProjectAs() char drv[512], dir[512], name[512], ext[512]; //For getting the filename! splitpath(tempstr.c_str(), drv, dir, name, ext); //Split it up... + project.SetProjectName(name); std::string filename = name; //Grab the name... filename.append(ext); //Stick extension back on... project.SetProjectFile(filename); //And update the project's filename. - - project.SetProjectName(GetRomName()); //Set the project's name to the ROM name - std::string thisfm2name = project.GetProjectName(); + std::string thisfm2name = name; thisfm2name.append(".fm2"); //Setup the fm2 name project.SetFM2Name(thisfm2name); //Set the project's fm2 name project.saveProject(); @@ -1200,14 +1213,14 @@ bool AskSaveProject() if (project.changed) changes_found = true; // ask saving project - if (changes_found) - { - int answer = MessageBox(hwndTasEdit, "Save Project changes?", "TAS Edit", MB_YESNOCANCEL); - if(answer == IDYES) - return SaveProject(); - return (answer != IDCANCEL); - } - return true; + if (changes_found) + { + int answer = MessageBox(hwndTasEdit, "Save Project changes?", "TAS Edit", MB_YESNOCANCEL); + if(answer == IDYES) + return SaveProject(); + return (answer != IDCANCEL); + } + return true; } //Takes a selected .fm2 file and adds it to the Project inputlog @@ -1457,8 +1470,9 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case MENU_CONTEXT_STRAY_INSERTFRAMES: case ID_CONTEXT_SELECTED_INSERTFRAMES2: { - int frames = 1; - if(CWin32InputBox::GetInteger("Insert Frames", "How many frames?", frames, hwndDlg) == IDOK) + int frames = selectionFrames.size(); + if (!frames) frames = 1; + if(CWin32InputBox::GetInteger("Insert number of Frames", "How many frames?", frames, hwndDlg) == IDOK) { if (frames > 0) { @@ -1502,10 +1516,10 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar FollowPlayback(); break; case ACCEL_CTRL_F: - case ID_VIEW_FOLLOW_PLAYBACK: + case CHECK_FOLLOW_CURSOR: //switch "Follow playback" flag TASEdit_follow_playback ^= 1; - CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); + CheckDlgButton(hwndTasEdit, CHECK_FOLLOW_CURSOR, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); // if switched off then jump to selection if (TASEdit_follow_playback) FollowPlayback(); @@ -1526,22 +1540,22 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar break; case ID_CONFIG_SETGREENZONECAPACITY: { - //open input dialog - int new_capacity = TASEdit_greenzone_capacity; - if(CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?", new_capacity, hwndDlg) == IDOK) - { - if (new_capacity < GREENZONE_MIN_CAPACITY) - new_capacity = GREENZONE_MIN_CAPACITY; - else if (new_capacity > GREENZONE_MAX_CAPACITY) - new_capacity = GREENZONE_MAX_CAPACITY; - if (new_capacity < TASEdit_greenzone_capacity) + //open input dialog + int new_capacity = TASEdit_greenzone_capacity; + if(CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?", new_capacity, hwndDlg) == IDOK) { - TASEdit_greenzone_capacity = new_capacity; - currMovieData.ClearGreenzoneTail(); - RedrawList(); - } else TASEdit_greenzone_capacity = new_capacity; - } - break; + if (new_capacity < GREENZONE_MIN_CAPACITY) + new_capacity = GREENZONE_MIN_CAPACITY; + else if (new_capacity > GREENZONE_MAX_CAPACITY) + new_capacity = GREENZONE_MAX_CAPACITY; + if (new_capacity < TASEdit_greenzone_capacity) + { + TASEdit_greenzone_capacity = new_capacity; + currMovieData.ClearGreenzoneTail(); + RedrawList(); + } else TASEdit_greenzone_capacity = new_capacity; + } + break; } case ID_CONFIG_MUTETURBO: muteTurbo ^= 1; @@ -1639,7 +1653,7 @@ void EnterTasEdit() hmenu = GetMenu(hwndTasEdit); hrmenu = LoadMenu(fceu_hInstance,"TASEDITCONTEXTMENUS"); // check option ticks - CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); + CheckDlgButton(hwndTasEdit, CHECK_FOLLOW_CURSOR, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, ID_VIEW_SHOW_LAG_FRAMES, TASEdit_show_lag_frames?MF_CHECKED : MF_UNCHECKED); CheckDlgButton(hwndTasEdit,CHECK_AUTORESTORE_PLAYBACK,TASEdit_restore_position?BST_CHECKED:BST_UNCHECKED); CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED); diff --git a/src/drivers/win/tasedit.h b/src/drivers/win/tasedit.h index c1001749..54c8f28c 100644 --- a/src/drivers/win/tasedit.h +++ b/src/drivers/win/tasedit.h @@ -71,6 +71,7 @@ void EnterTasEdit(); bool ExitTasEdit(); void UpdateTasEdit(); void UpdateList(); +void UpdateProgressbar(int frame); void InputChanged(); void InvalidateGreenZone(int after); bool JumpToFrame(int index); diff --git a/src/drivers/win/taseditlib/taseditproj.cpp b/src/drivers/win/taseditlib/taseditproj.cpp index 05172e4a..05448ed0 100644 --- a/src/drivers/win/taseditlib/taseditproj.cpp +++ b/src/drivers/win/taseditlib/taseditproj.cpp @@ -79,7 +79,6 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN) { const char* filename = PFN.c_str(); - SetProjectName(PFN); EMUFILE_FILE ifs(filename, "rb"); LoadFM2(currMovieData, &ifs, ifs.size(), false); diff --git a/src/movie.cpp b/src/movie.cpp index e51a36e4..495a9e01 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -40,6 +40,9 @@ #include "./drivers/win/tasedit.h" #include "./drivers/win/window.h" extern void AddRecentMovieFile(const char *filename); + +extern void UpdateProgressbar(int frame); + #endif using namespace std; @@ -155,7 +158,7 @@ void MovieData::ClearGreenzoneTail() #ifdef WIN32 int tail_frame = currMovieData.greenZoneCount-1 - TASEdit_greenzone_capacity; #else - int tail_frame = currMovieData.greenZoneCount-1; + int tail_frame = 0; #endif if (tail_frame >= currFrameCounter) tail_frame = currFrameCounter - 1; @@ -551,11 +554,21 @@ int MovieData::dumpGreenzone(EMUFILE *os) { int start = os->ftell(); int frame, size; + int last_tick = PROGRESSBAR_UPDATE_MIN; + // write size write32le(greenZoneCount, os); write32le(currFrameCounter, os); // write savestates for (frame = 0; frame < greenZoneCount; ++frame) { +#ifdef WIN32 + // update TASEditor progressbar from time to time + if (frame / PROGRESSBAR_UPDATE_RATE > last_tick) + { + UpdateProgressbar(frame); + last_tick = frame / PROGRESSBAR_UPDATE_RATE; + } +#endif if (savestates[frame].empty()) continue; write32le(frame, os); // write frames_flags @@ -566,6 +579,7 @@ int MovieData::dumpGreenzone(EMUFILE *os) size = savestates[frame].size(); write32le(size, os); os->fwrite(&savestates[frame][0], size); + } // write -1 as eof for greenzone write32le(-1, os); @@ -578,6 +592,8 @@ bool MovieData::loadGreenzone(EMUFILE *is) { clearGreenzone(); int frame = 0, prev_frame = 0, size = 0; + int last_tick = PROGRESSBAR_UPDATE_MIN; + // read size if (read32le((uint32 *)&size, is)) { greenZoneCount = size; @@ -587,7 +603,7 @@ bool MovieData::loadGreenzone(EMUFILE *is) #ifdef WIN32 int greenzone_tail_frame = greenZoneCount-1 - TASEdit_greenzone_capacity; #else - int greenzone_tail_frame = greenZoneCount-1; + int greenzone_tail_frame = 0; #endif if (read32le((uint32 *)&frame, is)) @@ -597,6 +613,14 @@ bool MovieData::loadGreenzone(EMUFILE *is) { if (!read32le((uint32 *)&frame, is)) break; if (frame == -1) break; +#ifdef WIN32 + // update TASEditor progressbar from time to time + if (frame / PROGRESSBAR_UPDATE_RATE > last_tick) + { + UpdateProgressbar(frame); + last_tick = frame / PROGRESSBAR_UPDATE_RATE; + } +#endif // read frames_flags if ((int)is->fread(&frames_flags[frame],1) != 1) break; // read lua_colorings @@ -1141,6 +1165,8 @@ void FCEUMOV_AddInputState() } else { + // TODO: check if input actually changed + InputChanged(); // record buttons if (currMovieData.greenZoneCount>currFrameCounter+1) { diff --git a/src/movie.h b/src/movie.h index e3ca3d00..3c308c68 100644 --- a/src/movie.h +++ b/src/movie.h @@ -3,6 +3,9 @@ #define LAG_FLAG_BIT 1 +#define PROGRESSBAR_UPDATE_RATE 3000 // in frames of greenzone +#define PROGRESSBAR_UPDATE_MIN 6000 / PROGRESSBAR_UPDATE_RATE + #include #include #include diff --git a/src/video.cpp b/src/video.cpp index 807686b7..aad6152e 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -454,6 +454,11 @@ void FCEU_DispMessage(char *format, int disppos=0, ...) va_start(ap,disppos); vsnprintf(guiMessage.errmsg,sizeof(guiMessage.errmsg),format,ap); + // also log messages + char temp[2048]; + vsnprintf(temp,sizeof(temp),format,ap); + strcat(temp, "\n"); + FCEU_printf(temp); va_end(ap); guiMessage.howlong = 180;