diff --git a/Authors.txt b/Authors.txt index 32cfa6a3..216aa50d 100644 --- a/Authors.txt +++ b/Authors.txt @@ -65,7 +65,7 @@ DWEdit Debugger additions AnS - ansstuff at yandex dot ru (sf:ansstuff) -Bugfixes and additions, TASEdit v1.0 +Bugfixes and additions, TAS Editor v1.0 ---------linux devvers--------- >= 2.0 - These guys concentrated on keeping fceux the premiere diff --git a/changelog.txt b/changelog.txt index c0ce33b4..fbe2bb45 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ +26-dec-2011 - AnS - Tasedit: Find Note dialog (Ctrl-F) +26-dec-2011 - AnS - new Lua functions (TAS Editor library) +19-dec-2011 - AnS - Tasedit: listview header lights +19-dec-2011 - AnS - Tasedit: Recording checkbox instead of radiobutton; Config->Use Input keys for ColumnSet +19-dec-2011 - AnS - Tasedit: Export dialog: "Convert Marker Notes to Movie Subtitles" 16-dec-2011 - AnS - Tasedit: new accelerators: Ctrl-PgUp/Ctrl-PgDn/Shift-PgUp/Shift-PgDn; Config->Allow keyboard controls in Listview 16-dec-2011 - AnS - Tasedit: View->Display Branch Tooltips 16-dec-2011 - AnS - Tasedit: Markers notes; View->Follow Marker Note context diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index d0b12ce1..bad1ca82 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -77,6 +77,7 @@ extern bool TASEdit_show_branch_screenshots; extern bool TASEdit_show_branch_tooltips; extern bool TASEdit_bind_markers; extern bool TASEdit_empty_marker_notes; +extern bool TASEdit_findnote_reappear; extern bool TASEdit_combine_consecutive_rec; extern bool TASEdit_use_1p_rec; extern bool TASEdit_columnset_by_keys; @@ -103,6 +104,8 @@ extern bool TASEdit_savecompact_greenzone; extern bool TASEdit_savecompact_history; extern bool TASEdit_savecompact_list; extern bool TASEdit_savecompact_selection; +extern bool TASEdit_findnote_matchcase; +extern bool TASEdit_findnote_search_up; extern char* recent_projects[]; //window positions and sizes: @@ -340,6 +343,7 @@ static CFGSTRUCT fceuconfig[] = { AC(TASEdit_show_branch_tooltips), AC(TASEdit_bind_markers), AC(TASEdit_empty_marker_notes), + AC(TASEdit_findnote_reappear), AC(TASEdit_combine_consecutive_rec), AC(TASEdit_use_1p_rec), AC(TASEdit_columnset_by_keys), @@ -366,6 +370,8 @@ static CFGSTRUCT fceuconfig[] = { AC(TASEdit_savecompact_history), AC(TASEdit_savecompact_list), AC(TASEdit_savecompact_selection), + AC(TASEdit_findnote_matchcase), + AC(TASEdit_findnote_search_up), AC(lagCounterDisplay), AC(oldInputDisplay), AC(movieSubtitles), diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 685398d5..4ac83152 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -254,6 +254,8 @@ BEGIN MENUITEM "Insert # of Frames\tIns", ID_EDIT_INSERT MENUITEM SEPARATOR MENUITEM "Truncate\tCtrl+T", ID_EDIT_TRUNCATE + MENUITEM SEPARATOR + MENUITEM "&Find Note...\tCtrl+F", ID_EDIT_FINDNOTE END POPUP "&View" BEGIN @@ -278,6 +280,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "&Bind Markers to Input", ID_CONFIG_BINDMARKERSTOINPUT MENUITEM "&Empty new Marker Notes", ID_CONFIG_EMPTYNEWMARKERNOTES + MENUITEM "Reappearing &Find Note dialog", ID_CONFIG_REAPPEARINGFINDNOTEDIALOG MENUITEM SEPARATOR MENUITEM "&Combine consecutive Recordings", ID_CONFIG_COMBINECONSECUTIVERECORDINGS MENUITEM "&Use 1P keys for all single Recordings", ID_CONFIG_USE1PFORRECORDING @@ -1405,14 +1408,14 @@ BEGIN CONTROL " 4P",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,402,98,24,10 CONTROL " Superimpose",IDC_SUPERIMPOSE,"Button",BS_AUTO3STATE,372,74,55,10 GROUPBOX " History ",IDC_STATIC,310,255,123,116,BS_CENTER,WS_EX_RIGHT - EDITTEXT IDC_SELECTION_MARKER_EDIT,65,377,240,13,ES_READONLY | NOT WS_TABSTOP + EDITTEXT IDC_SELECTION_MARKER_EDIT,65,377,240,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP PUSHBUTTON "<<",TASEDIT_PREV_MARKER,315,376,23,14,NOT WS_TABSTOP - PUSHBUTTON "Find",TASEDIT_FIND_BEST_MARKER,338,376,34,14,WS_DISABLED | NOT WS_TABSTOP - PUSHBUTTON "Next",TASEDIT_FIND_NEXT_MARKER,372,376,34,14,WS_DISABLED | NOT WS_TABSTOP + PUSHBUTTON "Similar",TASEDIT_FIND_BEST_SIMILAR_MARKER,338,376,34,14,NOT WS_TABSTOP + PUSHBUTTON "More",TASEDIT_FIND_NEXT_SIMILAR_MARKER,372,376,34,14,NOT WS_TABSTOP PUSHBUTTON ">>",TASEDIT_NEXT_MARKER,405,376,23,14,NOT WS_TABSTOP RTEXT "Marker 0",IDC_PLAYBACK_MARKER,3,3,60,10,0,WS_EX_RIGHT RTEXT "Marker 99999",IDC_SELECTION_MARKER,3,379,60,10,0,WS_EX_RIGHT - EDITTEXT IDC_PLAYBACK_MARKER_EDIT,65,1,240,13,ES_READONLY | NOT WS_TABSTOP + EDITTEXT IDC_PLAYBACK_MARKER_EDIT,65,1,240,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP CONTROL "",IDC_BRANCHES_BITMAP,"Static",SS_OWNERDRAW | SS_NOTIFY | SS_REALSIZEIMAGE | NOT WS_VISIBLE,315,160,113,89 CONTROL " Turbo seek",CHECK_TURBO_SEEK,"Button",BS_AUTOCHECKBOX,379,26,50,12 CONTROL "",IDC_TEXT_SELECTION_BUTTON,"Button",BS_OWNERDRAW,315,121,113,12 @@ -1422,33 +1425,47 @@ BEGIN END IDD_TASEDIT_EXPORT DIALOGEX 0, 0, 158, 86 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Export to FM2" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Export",IDOK,7,66,50,14 PUSHBUTTON "Cancel",IDCANCEL,100,66,50,14 - CONTROL " 1 player",IDC_RADIO_1PLAYER,"Button",BS_AUTORADIOBUTTON,8,8,47,10 + CONTROL " 1 player",IDC_RADIO_1PLAYER,"Button",BS_AUTORADIOBUTTON | WS_GROUP,8,8,47,10 CONTROL " 2 players",IDC_RADIO_2PLAYERS,"Button",BS_AUTORADIOBUTTON,8,21,47,10 CONTROL " Fourscore",IDC_RADIO_FOURSCORE,"Button",BS_AUTORADIOBUTTON,8,35,47,10 CONTROL " Convert Marker Notes to Movie Subtitles",IDC_NOTES_TO_SUBTITLES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,50,141,10 END +IDD_TASEDIT_FINDNOTE DIALOGEX 0, 0, 228, 52 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Find Note" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Find next",IDOK,171,6,51,14 + PUSHBUTTON "Cancel",IDCANCEL,171,24,51,14 + EDITTEXT IDC_NOTE_TO_FIND,6,7,160,12,ES_AUTOHSCROLL + CONTROL " Match case",IDC_MATCH_CASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,25,53,10 + GROUPBOX "Direction",IDC_STATIC,82,21,83,26 + CONTROL " Up",IDC_RADIO_UP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,90,32,29,10 + CONTROL " Down",IDC_RADIO_DOWN,"Button",BS_AUTORADIOBUTTON,125,32,32,10 +END + IDD_TASEDIT_SAVECOMPACT DIALOGEX 0, 0, 122, 134 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Save",IDOK,7,114,50,14 PUSHBUTTON "Cancel",IDCANCEL,65,114,50,14 - CONTROL " Binary Format of Input",IDC_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,8,87,10 + CONTROL " Binary Format of Input",IDC_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,7,87,10 CONTROL " Markers",IDC_CHECK_MARKERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,22,67,10 - CONTROL " Bookmarks",IDC_CHECK_BOOKMARKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,36,67,10 - CONTROL " Greenzone",IDC_CHECK_GREENZONE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,51,67,10 - CONTROL " History",IDC_CHECK_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,66,67,10 - CONTROL " List data",IDC_CHECK_LIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,96,67,10 - CONTROL " Selection",IDC_CHECK_SELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,81,67,10 + CONTROL " Bookmarks",IDC_CHECK_BOOKMARKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,37,67,10 + CONTROL " Greenzone",IDC_CHECK_GREENZONE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,52,67,10 + CONTROL " History",IDC_CHECK_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,67,67,10 + CONTROL " List data",IDC_CHECK_LIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,82,67,10 + CONTROL " Selection",IDC_CHECK_SELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,97,67,10 END ASSEMBLER DIALOGEX 0, 0, 202, 135 @@ -1891,6 +1908,10 @@ BEGIN BOTTOMMARGIN, 121 END + "NTVIEW", DIALOG + BEGIN + END + "ROMPATCHER", DIALOG BEGIN END @@ -1934,10 +1955,12 @@ BEGIN BEGIN END + IDD_TASEDIT_FINDNOTE, DIALOG + BEGIN + END + IDD_TASEDIT_SAVECOMPACT, DIALOG BEGIN - RIGHTMARGIN, 121 - BOTTOMMARGIN, 131 END "ASSEMBLER", DIALOG @@ -2090,6 +2113,8 @@ BEGIN "F", ACCEL_CTRL_F, VIRTKEY, CONTROL, NOINVERT VK_INSERT, ACCEL_CTRL_INSERT, VIRTKEY, CONTROL, NOINVERT "P", ACCEL_CTRL_P, VIRTKEY, CONTROL, NOINVERT + VK_NEXT, ACCEL_CTRL_PGDN, VIRTKEY, CONTROL, NOINVERT + VK_PRIOR, ACCEL_CTRL_PGUP, VIRTKEY, CONTROL, NOINVERT "Q", ACCEL_CTRL_Q, VIRTKEY, CONTROL, NOINVERT "S", ACCEL_CTRL_S, VIRTKEY, CONTROL, NOINVERT "T", ACCEL_CTRL_T, VIRTKEY, CONTROL, NOINVERT @@ -2101,11 +2126,9 @@ BEGIN VK_DELETE, ACCEL_DEL, VIRTKEY, NOINVERT VK_INSERT, ACCEL_INS, VIRTKEY, NOINVERT VK_INSERT, ACCEL_SHIFT_INS, VIRTKEY, SHIFT, NOINVERT - "V", ACCEL_SHIFT_V, VIRTKEY, SHIFT, NOINVERT - VK_PRIOR, ACCEL_CTRL_PGUP, VIRTKEY, CONTROL, NOINVERT - VK_NEXT, ACCEL_CTRL_PGDN, VIRTKEY, CONTROL, NOINVERT - VK_PRIOR, ACCEL_SHIFT_PGUP, VIRTKEY, SHIFT, NOINVERT VK_NEXT, ACCEL_SHIFT_PGDN, VIRTKEY, SHIFT, NOINVERT + VK_PRIOR, ACCEL_SHIFT_PGUP, VIRTKEY, SHIFT, NOINVERT + "V", ACCEL_SHIFT_V, VIRTKEY, SHIFT, NOINVERT END IDR_RWACCELERATOR ACCELERATORS diff --git a/src/drivers/win/res/tasedit-icon.ico b/src/drivers/win/res/tasedit-icon.ico index f6b55810..b3c9b65a 100644 Binary files a/src/drivers/win/res/tasedit-icon.ico and b/src/drivers/win/res/tasedit-icon.ico differ diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index f5a7b0f5..1f11e323 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -184,6 +184,7 @@ #define IDD_TASEDIT_SAVECOMPACT 186 #define IDD_TASEDIT_BRANCH_NOTE 188 #define IDI_ICON3 197 +#define IDD_TASEDIT_FINDNOTE 198 #define MENU_RESET 200 #define BUTTON_ROMS 200 #define TXT_PAD1 200 @@ -407,6 +408,7 @@ #define TASEDIT_REWIND2 1137 #define TASEDIT_PLAYSTOP 1137 #define IDC_RADIO1 1138 +#define IDC_RADIO_UP 1138 #define IDC_RADIO2 1139 #define IDC_RADIO3 1140 #define IDC_RADIO4 1141 @@ -421,10 +423,13 @@ #define TASEDIT_PREV_MARKER 1145 #define IDC_BUTTON8 1146 #define TASEDIT_FIND_BEST_MARKER 1146 +#define TASEDIT_FIND_BEST_SIMILAR_MARKER 1146 #define IDC_EDIT1 1147 #define IDC_SELECTION_MARKER_EDIT 1147 +#define IDC_NOTE_TO_FIND 1147 #define IDC_BUTTON9 1148 #define TASEDIT_FIND_NEXT_MARKER 1148 +#define TASEDIT_FIND_NEXT_SIMILAR_MARKER 1148 #define IDC_HISTORYLIST 1149 #define IDC_BOOKMARKSLIST 1150 #define TASEDIT_NEXT_MARKER 1151 @@ -471,6 +476,7 @@ #define IDC_SUPERIMPOSE 1203 #define IDC_CHECK_BINARY 1203 #define IDC_NOTES_TO_SUBTITLES 1203 +#define IDC_MATCH_CASE 1203 #define IDC_VOLUMEGROUP 1204 #define IDC_OMITBLANK 1204 #define IDC_CHECK3 1204 @@ -562,6 +568,7 @@ #define IDC_RADIO_FOURSCORE 1271 #define IDC_SELECTION_MARKER 1271 #define IDC_NOTE_TOOLTIP_EDIT 1272 +#define IDC_RADIO_DOWN 1273 #define MENU_NETWORK 40040 #define MENU_PALETTE 40041 #define MENU_SOUND 40042 @@ -953,6 +960,8 @@ #define ID_VIEW_SHOWBRANCHTOOLTIPS 40508 #define ID_CONFIG_USEINPUTKEYSFORCOLUMNSET 40509 #define ID_CONFIG_EMPTYNEWMARKERNOTES 40510 +#define ID_EDIT_FINDNOTE 40513 +#define ID_CONFIG_REAPPEARINGFINDNOTEDIALOG 40514 #define IDC_DEBUGGER_ICONTRAY 55535 #define MW_ValueLabel2 65423 #define MW_ValueLabel1 65426 @@ -961,9 +970,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 198 -#define _APS_NEXT_COMMAND_VALUE 40511 -#define _APS_NEXT_CONTROL_VALUE 1273 +#define _APS_NEXT_RESOURCE_VALUE 199 +#define _APS_NEXT_COMMAND_VALUE 40515 +#define _APS_NEXT_CONTROL_VALUE 1274 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index c5ed90e1..3bddd08d 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -9,6 +9,9 @@ #include "main.h" #include "tasedit.h" #include "version.h" +#include // for StrStrI + +#pragma comment(lib, "Shlwapi.lib") using namespace std; @@ -19,6 +22,7 @@ bool TASEdit_focus = false; bool Tasedit_rewind_now = false; int marker_note_edit = MARKER_NOTE_EDIT_NONE; +char findnote_string[MAX_NOTE_LEN] = {0}; // all Taseditor functional modules TASEDIT_PROJECT project; @@ -77,6 +81,9 @@ bool TASEdit_savecompact_greenzone = false; bool TASEdit_savecompact_history = false; bool TASEdit_savecompact_list = true; bool TASEdit_savecompact_selection = false; +bool TASEdit_findnote_matchcase = false; +bool TASEdit_findnote_search_up = false; +bool TASEdit_findnote_reappear = true; // Recent Menu HMENU recent_projects_menu; @@ -88,7 +95,6 @@ const unsigned int MAX_NUMBER_OF_RECENT_PROJECTS = sizeof(recent_projects)/sizeo string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TAS Editor Help page char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"}; char windowCaptioBase[] = "TAS Editor"; -extern char recordingCaptions[5][30]; HICON hTaseditorIcon = 0; // enterframe function @@ -113,7 +119,7 @@ void RedrawWindowCaption() char new_caption[300]; strcpy(new_caption, windowCaptioBase); if (!movie_readonly) - strcat(new_caption, recordingCaptions[recorder.multitrack_recording_joypad]); + strcat(new_caption, recorder.GetRecordingCaption()); // add project name std::string projectname = project.GetProjectName(); if (!projectname.empty()) @@ -466,9 +472,11 @@ void FrameColumnSet() { if(!current_markers.GetMarker(*it)) { - changes_made = true; - current_markers.SetMarker(*it); - tasedit_list.RedrawRow(*it); + if (current_markers.SetMarker(*it)) + { + changes_made = true; + tasedit_list.RedrawRow(*it); + } } } if (changes_made) @@ -480,8 +488,8 @@ void FrameColumnSet() { if(current_markers.GetMarker(*it)) { - changes_made = true; current_markers.ClearMarker(*it); + changes_made = true; tasedit_list.RedrawRow(*it); } } @@ -640,6 +648,7 @@ bool Paste() pGlobal = strchr(pGlobal, '\n'); int joy = 0; uint8 new_buttons = 0; + std::vector flash_joy(NUM_JOYPADS); char* frame; --pos; while (pGlobal++ && *pGlobal!='\0') @@ -674,14 +683,19 @@ bool Paste() case '|': // Joystick mark // flush buttons to movie data if (TASEdit_superimpose_affects_paste && (TASEdit_superimpose == BST_CHECKED || (TASEdit_superimpose == BST_INDETERMINATE && new_buttons == 0))) + { + flash_joy[joy] |= (new_buttons & (~currMovieData.records[pos].joysticks[joy])); // highlight buttons that are new currMovieData.records[pos].joysticks[joy] |= new_buttons; - else + } else + { + flash_joy[joy] |= new_buttons; // highlight buttons that were added currMovieData.records[pos].joysticks[joy] = new_buttons; + } ++joy; new_buttons = 0; break; default: - for (int bit=0; bit flash_joy(NUM_JOYPADS); --pos; while (pGlobal++ && *pGlobal!='\0') { @@ -783,6 +811,7 @@ bool PasteInsert() if (*frame == buttonNames[bit][0]) { currMovieData.records[pos].joysticks[joy] |= (1< 0 && strlen(findnote_string)) + { + current_frame = selection.GetCurrentSelectionBeginning(); + if (TASEdit_findnote_search_up) + if (current_frame < 0) + current_frame = movie_size; + while (true) + { + // move forward + if (TASEdit_findnote_search_up) + { + current_frame--; + if (current_frame < 0) + { + if (entries_found) + MessageBox(hwndTasEdit, "No more entries found.", "Find Note", MB_OK); + else + MessageBox(hwndTasEdit, "Nothing was found!", "Find Note", MB_OK); + break; + } + } else + { + current_frame++; + if (current_frame >= movie_size) + { + if (entries_found) + MessageBox(hwndTasEdit, "No more entries found.", "Find Note", MB_OK); + else + MessageBox(hwndTasEdit, "Nothing was found!", "Find Note", MB_OK); + break; + } + } + // scan marked frames + cur_marker = current_markers.GetMarker(current_frame); + if (cur_marker) + { + if (TASEdit_findnote_matchcase) + result = (strstr(current_markers.GetNote(cur_marker).c_str(), findnote_string) != 0); + else + result = (StrStrI(current_markers.GetNote(cur_marker).c_str(), findnote_string) != 0); + if (result) + { + // found note containing searched string - jump there + entries_found++; + selection.JumpToFrame(current_frame); + selection.update(); + break; + } + } + } + } else break; + } while (TASEdit_findnote_reappear); +} + +void FindSimilarMarker() +{ + char playback_marker_text[MAX_NOTE_LEN]; + strcpy(playback_marker_text, current_markers.GetNote(playback.shown_marker).c_str()); + + // check if playback_marker_text is empty + if (!playback_marker_text[0]) + { + MessageBox(hwndTasEdit, "Marker Note under Playback cursor is empty!", "Find Similar Note", MB_OK); + return; + } + + + + + + } // -------------------------------------------------------------------------------------------- void UpdateRecentProjectsMenu() diff --git a/src/drivers/win/tasedit.h b/src/drivers/win/tasedit.h index 1b7b77db..c017873b 100644 --- a/src/drivers/win/tasedit.h +++ b/src/drivers/win/tasedit.h @@ -58,6 +58,8 @@ void SetTaseditInput(); void ClearTaseditInput(); void UpdateMarkerNote(); +void FindNote(); +void FindSimilarMarker(); void UpdateRecentProjectsMenu(); void UpdateRecentProjectsArray(const char* addString); diff --git a/src/drivers/win/taseditlib/bookmarks.cpp b/src/drivers/win/taseditlib/bookmarks.cpp index 54a09a1d..81b9cdce 100644 --- a/src/drivers/win/taseditlib/bookmarks.cpp +++ b/src/drivers/win/taseditlib/bookmarks.cpp @@ -519,9 +519,6 @@ void BOOKMARKS::unleash(int slot) } greenzone.update(); - // jump to the target (bookmarked frame) - playback.jump(jump_frame); - // switch current branch to this branch if (slot != current_branch && current_branch >= 0) { @@ -534,6 +531,9 @@ void BOOKMARKS::unleash(int slot) changes_since_current_branch = false; must_recalculate_branches_tree = true; + // jump to the target (bookmarked frame) + playback.jump(jump_frame); + FCEU_DispMessage("Branch %d loaded.", 0, slot); } @@ -1038,6 +1038,10 @@ int BOOKMARKS::FindBookmarkAtFrame(int frame) } return -1; } +int BOOKMARKS::GetCurrentBranch() +{ + return current_branch; +} void BOOKMARKS::ChangesMadeSinceBranch() { diff --git a/src/drivers/win/taseditlib/bookmarks.h b/src/drivers/win/taseditlib/bookmarks.h index 40928591..68da0425 100644 --- a/src/drivers/win/taseditlib/bookmarks.h +++ b/src/drivers/win/taseditlib/bookmarks.h @@ -107,6 +107,7 @@ public: void RightClick(LPNMITEMACTIVATE info); int FindBookmarkAtFrame(int frame); + int GetCurrentBranch(); void RedrawBookmarksCaption(); void RedrawBookmarksList(); diff --git a/src/drivers/win/taseditlib/inputhistory.cpp b/src/drivers/win/taseditlib/inputhistory.cpp index 3580a470..8f39e44e 100644 --- a/src/drivers/win/taseditlib/inputhistory.cpp +++ b/src/drivers/win/taseditlib/inputhistory.cpp @@ -22,7 +22,7 @@ extern TASEDIT_LIST tasedit_list; char history_save_id[HISTORY_ID_LEN] = "HISTORY"; char history_skipsave_id[HISTORY_ID_LEN] = "HISTORX"; -char modCaptions[37][20] = {" Init", +char modCaptions[40][20] = {" Init", " Change", " Set", " Unset", @@ -58,7 +58,10 @@ char modCaptions[37][20] = {" Init", " Marker Branch9 to ", " Marker Set", " Marker Unset", - " Marker Rename"}; + " Marker Rename", + " LUA Marker Set", + " LUA Marker Unset", + " LUA Marker Rename" }; char joypadCaptions[4][5] = {"(1P)", "(2P)", "(3P)", "(4P)"}; INPUT_HISTORY::INPUT_HISTORY() @@ -164,6 +167,7 @@ int INPUT_HISTORY::jump(int new_pos) if (first_change >= 0) { input_snapshots[real_pos].toMovie(currMovieData, first_change); + selection.must_find_current_marker = playback.must_find_current_marker = true; bookmarks.ChangesMadeSinceBranch(); // list will be redrawn by greenzone invalidation } else if (markers_changed) @@ -172,6 +176,7 @@ int INPUT_HISTORY::jump(int new_pos) selection.must_find_current_marker = playback.must_find_current_marker = true; bookmarks.ChangesMadeSinceBranch(); tasedit_list.RedrawList(); + tasedit_list.FollowUndo(); } else if (TASEdit_enable_hot_changes) { // when using Hot Changes, list should be always redrawn, because old changes become less hot diff --git a/src/drivers/win/taseditlib/inputhistory.h b/src/drivers/win/taseditlib/inputhistory.h index c8c956b7..84e66813 100644 --- a/src/drivers/win/taseditlib/inputhistory.h +++ b/src/drivers/win/taseditlib/inputhistory.h @@ -39,6 +39,9 @@ #define MODTYPE_MARKER_SET 34 #define MODTYPE_MARKER_UNSET 35 #define MODTYPE_MARKER_RENAME 36 +#define MODTYPE_LUA_MARKER_SET 37 +#define MODTYPE_LUA_MARKER_UNSET 38 +#define MODTYPE_LUA_MARKER_RENAME 39 #define HISTORY_NORMAL_COLOR 0x000000 #define HISTORY_INCOHERENT_COLOR 0x999999 diff --git a/src/drivers/win/taseditlib/markers.cpp b/src/drivers/win/taseditlib/markers.cpp index 1f6065e2..4be4ee53 100644 --- a/src/drivers/win/taseditlib/markers.cpp +++ b/src/drivers/win/taseditlib/markers.cpp @@ -242,6 +242,8 @@ int MARKERS::GetMarker(int frame) // finds and returns # of Marker starting from start_frame and searching up int MARKERS::GetMarkerUp(int start_frame) { + if (start_frame >= (int)markers_array.size()) + start_frame = markers_array.size() - 1; for (; start_frame >= 0; start_frame--) if (markers_array[start_frame]) return markers_array[start_frame]; return 0; @@ -254,9 +256,16 @@ int MARKERS::GetMarkerFrame(int marker_id) // didn't find return -1; } - -void MARKERS::SetMarker(int frame) +// returns number of new marker +int MARKERS::SetMarker(int frame) { + if (frame < 0) + return 0; + else if (frame >= (int)markers_array.size()) + markers_array.resize(frame + 1); + else if (markers_array[frame]) + return markers_array[frame]; + int marker_num = GetMarkerUp(frame) + 1; markers_array[frame] = marker_num; if (TASEdit_empty_marker_notes) @@ -269,18 +278,22 @@ void MARKERS::SetMarker(int frame) for (frame++; frame < size; ++frame) if (markers_array[frame]) markers_array[frame]++; + return marker_num; } void MARKERS::ClearMarker(int frame) { - // erase corresponding note - notes.erase(notes.begin() + markers_array[frame]); - // erase marker - markers_array[frame] = 0; - // decrease following markers' ids - int size = markers_array.size(); - for (frame++; frame < size; ++frame) - if (markers_array[frame]) - markers_array[frame]--; + if (markers_array[frame]) + { + // erase corresponding note + notes.erase(notes.begin() + markers_array[frame]); + // erase marker + markers_array[frame] = 0; + // decrease following markers' ids + int size = markers_array.size(); + for (frame++; frame < size; ++frame) + if (markers_array[frame]) + markers_array[frame]--; + } } void MARKERS::ToggleMarker(int frame) { @@ -321,7 +334,7 @@ std::string MARKERS::GetNote(int index) return notes[index]; else return notes[0]; } -void MARKERS::SetNote(int index, char* new_text) +void MARKERS::SetNote(int index, const char* new_text) { if (index >= 0 && index < (int)notes.size()) notes[index] = new_text; diff --git a/src/drivers/win/taseditlib/markers.h b/src/drivers/win/taseditlib/markers.h index 438374f9..7e7c5ead 100644 --- a/src/drivers/win/taseditlib/markers.h +++ b/src/drivers/win/taseditlib/markers.h @@ -1,6 +1,6 @@ //Specification file for Markers class #define MARKERS_ID_LEN 8 -#define MAX_NOTE_LEN 100 +#define MAX_NOTE_LEN 80 class MARKERS { @@ -26,7 +26,7 @@ public: int GetMarkerUp(int start_frame); int GetMarkerFrame(int marker_id); - void SetMarker(int frame); + int SetMarker(int frame); void ClearMarker(int frame); void ToggleMarker(int frame); @@ -35,7 +35,7 @@ public: int GetNotesSize(); std::string GetNote(int index); - void SetNote(int index, char* new_text); + void SetNote(int index, const char* new_text); bool checkMarkersDiff(MARKERS& their_markers); bool checkMarkersDiff(MARKERS& their_markers, int end); diff --git a/src/drivers/win/taseditlib/recorder.cpp b/src/drivers/win/taseditlib/recorder.cpp index 77ebfa75..92887bfa 100644 --- a/src/drivers/win/taseditlib/recorder.cpp +++ b/src/drivers/win/taseditlib/recorder.cpp @@ -17,13 +17,19 @@ extern bool TASEdit_branch_only_when_rec; extern bool TASEdit_use_1p_rec; extern int TASEdit_superimpose; extern bool TASEdit_columnset_by_keys; +extern bool TASEdit_focus; // resources -char recordingCaptions[5][30] = { " (Recording All)", - " (Recording 1P)", - " (Recording 2P)", - " (Recording 3P)", - " (Recording 4P)"}; +const char recordingModes[5][4] = { "All", + "1P", + "2P", + "3P", + "4P"}; +const char recordingCaptions[5][17] = { " (Recording All)", + " (Recording 1P)", + " (Recording 2P)", + " (Recording 3P)", + " (Recording 4P)"}; RECORDER::RECORDER() { } @@ -98,7 +104,7 @@ void RECORDER::update() current_joy[i] = 0; } // call ColumnSet if needed - if (TASEdit_columnset_by_keys && movie_readonly) + if (TASEdit_columnset_by_keys && movie_readonly && TASEdit_focus) { int num_joys; if (currMovieData.fourscore) @@ -220,4 +226,12 @@ void RECORDER::InputChanged() } } +const char* RECORDER::GetRecordingMode() +{ + return recordingModes[multitrack_recording_joypad]; +} +const char* RECORDER::GetRecordingCaption() +{ + return recordingCaptions[multitrack_recording_joypad]; +} diff --git a/src/drivers/win/taseditlib/recorder.h b/src/drivers/win/taseditlib/recorder.h index 41832c58..28de1050 100644 --- a/src/drivers/win/taseditlib/recorder.h +++ b/src/drivers/win/taseditlib/recorder.h @@ -18,6 +18,9 @@ public: void RecheckRecordingRadioButtons(); void InputChanged(); + + const char* GetRecordingMode(); + const char* GetRecordingCaption(); int multitrack_recording_joypad; std::vector current_joy; diff --git a/src/drivers/win/taseditlib/tasedit_list.cpp b/src/drivers/win/taseditlib/tasedit_list.cpp index bd922117..f74ae536 100644 --- a/src/drivers/win/taseditlib/tasedit_list.cpp +++ b/src/drivers/win/taseditlib/tasedit_list.cpp @@ -31,7 +31,7 @@ WNDPROC hwndList_oldWndProc = 0, hwndHeader_oldWndproc = 0; // resources COLORREF hot_changes_colors[16] = { 0x0, 0x5c4c44, 0x854604, 0xab2500, 0xc20006, 0xd6006f, 0xd40091, 0xba00a4, 0x9500ba, 0x7a00cc, 0x5800d4, 0x0045e2, 0x0063ea, 0x0079f4, 0x0092fa, 0x00aaff }; //COLORREF hot_changes_colors[16] = { 0x0, 0x661212, 0x842B4E, 0x652C73, 0x48247D, 0x383596, 0x2947AE, 0x1E53C1, 0x135DD2, 0x116EDA, 0x107EE3, 0x0F8EEB, 0x209FF4, 0x3DB1FD, 0x51C2FF, 0x4DCDFF }; -COLORREF header_lights_colors[11] = { 0x0, 0x00661f, 0x008a15, 0x00a800, 0x24c700, 0x4bd600, 0x79e300, 0x97e800, 0xb4f000, 0xd6f700, 0xffff00 }; +COLORREF header_lights_colors[11] = { 0x0, 0x006311, 0x008500, 0x1dad00, 0x46d100, 0x6ee300, 0x97e800, 0xb8f000, 0xdaf700, 0xffff7e, 0xffffb7 }; char list_save_id[LIST_ID_LEN] = "LIST"; char list_skipsave_id[LIST_ID_LEN] = "LISX"; diff --git a/src/drivers/win/taseditlib/tasedit_list.h b/src/drivers/win/taseditlib/tasedit_list.h index 9223d29c..46ebbc6d 100644 --- a/src/drivers/win/taseditlib/tasedit_list.h +++ b/src/drivers/win/taseditlib/tasedit_list.h @@ -10,7 +10,7 @@ #define NUM_JOYPAD_BUTTONS 8 #define HEADER_LIGHT_MAX 10 -#define HEADER_LIGHT_HOLD 5 +#define HEADER_LIGHT_HOLD 4 #define HEADER_LIGHT_UPDATE_TICK 40 // 25FPS #define MAX_NUM_COLUMNS 35 diff --git a/src/drivers/win/taseditlib/tasedit_sel.cpp b/src/drivers/win/taseditlib/tasedit_sel.cpp index f4236039..dfbc4fad 100644 --- a/src/drivers/win/taseditlib/tasedit_sel.cpp +++ b/src/drivers/win/taseditlib/tasedit_sel.cpp @@ -65,7 +65,6 @@ void TASEDIT_SELECTION::reset() { free(); // init vars - must_find_current_marker = true; shown_marker = 0; last_selection_beginning = -1; history_size = TasEdit_undo_levels + 1; @@ -82,6 +81,7 @@ void TASEDIT_SELECTION::reset_vars() old_prev_marker_button_state = prev_marker_button_state = false; old_next_marker_button_state = next_marker_button_state = false; must_redraw_text = true; + must_find_current_marker = true; } void TASEDIT_SELECTION::update() { @@ -553,12 +553,12 @@ void TASEDIT_SELECTION::SelectAll() } void TASEDIT_SELECTION::SetRowSelection(int index) { - ListView_SetItemState(tasedit_list.hwndList, index, LVIS_SELECTED, LVIS_SELECTED); + ListView_SetItemState(tasedit_list.hwndList, index, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED); } void TASEDIT_SELECTION::SetRegionSelection(int start, int end) { for (int i = start; i <= end; ++i) - ListView_SetItemState(tasedit_list.hwndList, i, LVIS_SELECTED, LVIS_SELECTED); + ListView_SetItemState(tasedit_list.hwndList, i, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED); } void TASEDIT_SELECTION::SelectMidMarkers() { diff --git a/src/drivers/win/taseditlib/taseditproj.cpp b/src/drivers/win/taseditlib/taseditproj.cpp index 1ff6a02e..abe69589 100644 --- a/src/drivers/win/taseditlib/taseditproj.cpp +++ b/src/drivers/win/taseditlib/taseditproj.cpp @@ -134,6 +134,7 @@ bool TASEDIT_PROJECT::load(char* fullname) } else { FCEU_PrintError("Error loading movie data from %s!", fullname); + // do not load the project return false; } diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 6ba9ac93..2432ad58 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -39,7 +39,14 @@ #include "fceulua.h" #ifdef WIN32 -#include "drivers/win/common.h" +#include "drivers/win/taseditlib/taseditproj.h" +extern INPUT_HISTORY history; +extern MARKERS current_markers; +extern BOOKMARKS bookmarks; +extern RECORDER recorder; +extern PLAYBACK playback; +extern TASEDIT_LIST tasedit_list; +extern TASEDIT_SELECTION selection; #endif extern "C" @@ -2603,12 +2610,15 @@ int emu_emulating(lua_State *L) { // string movie.mode() // -// "record", "playback", "finished", or nil -int movie_mode(lua_State *L) { - if (FCEUMOV_IsRecording()) +// Returns "taseditor", "record", "playback", "finished" or nil +int movie_mode(lua_State *L) +{ + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + lua_pushstring(L, "taseditor"); + else if (FCEUMOV_IsRecording()) lua_pushstring(L, "record"); else if (FCEUMOV_IsFinished()) - lua_pushstring(L, "finished"); //Note: this comes before plaback since playback checks for finished as well + lua_pushstring(L, "finished"); //Note: this comes before playback since playback checks for finished as well else if (FCEUMOV_IsPlaying()) lua_pushstring(L, "playback"); else @@ -4249,6 +4259,177 @@ static int sound_get(lua_State *L) return 1; } +// TAS Editor functions library + +// bool taseditor.engaged() +static int taseditor_engaged(lua_State *L) +{ + lua_pushboolean(L, FCEUMOV_Mode(MOVIEMODE_TASEDIT)); + return 1; +} + +// bool taseditor.markedframe(int frame) +static int taseditor_markedframe(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + int frame = luaL_checkinteger(L, 1); + lua_pushboolean(L, current_markers.GetMarker(frame) != 0); + } else +#endif + { + lua_pushboolean(L, false); + } + return 1; +} + +// int taseditor.getmarker(int frame) +static int taseditor_getmarker(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + int frame = luaL_checkinteger(L, 1); + lua_pushinteger(L, current_markers.GetMarkerUp(frame)); + } else +#endif + { + lua_pushinteger(L, -1); + } + return 1; +} + +// int taseditor.setmarker(int frame) +static int taseditor_setmarker(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + int frame = luaL_checkinteger(L, 1); + int marker_id = current_markers.GetMarker(frame); + if(!marker_id) + { + marker_id = current_markers.SetMarker(frame); + if (marker_id) + { + // new marker was created - register changes in TAS Editor + history.RegisterMarkersChange(MODTYPE_LUA_MARKER_SET, frame); + selection.must_find_current_marker = playback.must_find_current_marker = true; + tasedit_list.SetHeaderColumnLight(COLUMN_FRAMENUM, HEADER_LIGHT_MAX); + } + } + lua_pushinteger(L, marker_id); + } else +#endif + { + lua_pushinteger(L, -1); + } + return 1; +} + +// taseditor.clearmarker(int frame) +static int taseditor_clearmarker(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + int frame = luaL_checkinteger(L, 1); + if (current_markers.GetMarker(frame)) + { + current_markers.ClearMarker(frame); + // marker was deleted - register changes in TAS Editor + history.RegisterMarkersChange(MODTYPE_LUA_MARKER_UNSET, frame); + selection.must_find_current_marker = playback.must_find_current_marker = true; + tasedit_list.SetHeaderColumnLight(COLUMN_FRAMENUM, HEADER_LIGHT_MAX); + } + } +#endif + return 0; +} + +// string taseditor.getnote(int index) +static int taseditor_getnote(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + int index = luaL_checkinteger(L, 1); + lua_pushstring(L, current_markers.GetNote(index).c_str()); + } else +#endif + { + lua_pushnil(L); + } + return 1; +} + +// taseditor.setnote(int index, string newtext) +static int taseditor_setnote(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + int index = luaL_checkinteger(L, 1); + char newtext[MAX_NOTE_LEN]; + strncpy(newtext, luaL_checkstring(L, 2), MAX_NOTE_LEN - 1); + if (strcmp(current_markers.GetNote(index).c_str(), newtext)) + { + // text differs from old note - rename + current_markers.SetNote(index, newtext); + history.RegisterMarkersChange(MODTYPE_LUA_MARKER_RENAME, current_markers.GetMarkerFrame(index)); + selection.must_find_current_marker = playback.must_find_current_marker = true; + } + } +#endif + return 0; +} + +// int taseditor.getcurrentbranch() +static int taseditor_getcurrentbranch(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + lua_pushinteger(L, bookmarks.GetCurrentBranch()); + } else +#endif + { + lua_pushinteger(L, -1); + } + return 1; +} + +// string taseditor.getrecordermode() +static int taseditor_getrecordermode(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + lua_pushstring(L, recorder.GetRecordingMode()); + } else +#endif + { + lua_pushnil(L); + } + return 1; +} + +// int taseditor.getplaybacktarget() +static int taseditor_getplaybacktarget(lua_State *L) +{ +#ifdef WIN32 + if (FCEUMOV_Mode(MOVIEMODE_TASEDIT)) + { + lua_pushinteger(L, playback.pause_frame - 1); + } else +#endif + { + lua_pushinteger(L, -1); + } + return 1; +} + static int doPopup(lua_State *L, const char* deftype, const char* deficon) { const char *str = luaL_checkstring(L, 1); const char* type = lua_type(L,2) == LUA_TSTRING ? lua_tostring(L,2) : deftype; @@ -5005,6 +5186,21 @@ static const struct luaL_reg soundlib[] = { {NULL,NULL} }; +static const struct luaL_reg taseditorlib[] = { + + {"engaged", taseditor_engaged}, + {"markedframe", taseditor_markedframe}, + {"getmarker", taseditor_getmarker}, + {"setmarker", taseditor_setmarker}, + {"clearmarker", taseditor_clearmarker}, + {"getnote", taseditor_getnote}, + {"setnote", taseditor_setnote}, + {"getcurrentbranch", taseditor_getcurrentbranch}, + {"getrecordermode", taseditor_getrecordermode}, + {"getplaybacktarget", taseditor_getplaybacktarget}, + {NULL,NULL} +}; + void CallExitFunction() { if (!L) return; @@ -5132,6 +5328,7 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) { luaL_register(L, "movie", movielib); luaL_register(L, "gui", guilib); luaL_register(L, "sound", soundlib); + luaL_register(L, "taseditor", taseditorlib); luaL_register(L, "bit", bit_funcs); // LuaBitOp library lua_settop(L, 0); // clean the stack, because each call to luaL_register leaves a table on top diff --git a/src/movie.cpp b/src/movie.cpp index d81e6e88..879fad24 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -1574,6 +1574,8 @@ bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount) //This function creates an array of frame numbers and corresponding strings for displaying subtitles void LoadSubtitles(MovieData &moviedata) { + subtitleFrames.resize(0); + subtitleMessages.resize(0); extern std::vector subtitles; for(uint32 i=0; i < moviedata.subtitles.size() ; i++) { @@ -1583,17 +1585,16 @@ void LoadSubtitles(MovieData &moviedata) //If we can't split them, then don't process this one if(splitat == std::string::npos) - { - } + { + } //Else split the subtitle into the int and string arrays else - { - key = subtitle.substr(0,splitat); - value = subtitle.substr(splitat+1); - - subtitleFrames.push_back(atoi(key.c_str())); - subtitleMessages.push_back(value); - } + { + key = subtitle.substr(0,splitat); + value = subtitle.substr(splitat+1); + subtitleFrames.push_back(atoi(key.c_str())); + subtitleMessages.push_back(value); + } } } @@ -1618,7 +1619,7 @@ void FCEU_DisplaySubtitles(char *format, ...) vsnprintf(subtitleMessage.errmsg,sizeof(subtitleMessage.errmsg),format,ap); va_end(ap); - subtitleMessage.howlong = 300; + subtitleMessage.howlong = 400; subtitleMessage.isMovieMessage = subtitlesOnAVI; subtitleMessage.linesFromBottom = 0; }