* Tasedit: searching Markers with similar Notes

* "About" window
This commit is contained in:
ansstuff 2011-12-27 21:06:43 +00:00
parent 4c8af77326
commit 7449bff36b
13 changed files with 348 additions and 44 deletions

View File

@ -1,4 +1,6 @@
27-dec-2011 - AnS - Tasedit: "About" window
27-dec-2011 - AnS - Tasedit: searching Markers with similar Notes ("Similar" and "More" buttons)
26-dec-2011 - AnS - Tasedit: Find Note dialog (Ctrl-F) 26-dec-2011 - AnS - Tasedit: Find Note dialog (Ctrl-F)
26-dec-2011 - AnS - new Lua functions (TAS Editor library) 26-dec-2011 - AnS - new Lua functions (TAS Editor library)
19-dec-2011 - AnS - Tasedit: listview header lights 19-dec-2011 - AnS - Tasedit: listview header lights

View File

@ -294,6 +294,7 @@ BEGIN
POPUP "&Help" POPUP "&Help"
BEGIN BEGIN
MENUITEM "&TAS Editor Help", ID_HELP_TASEDITHELP MENUITEM "&TAS Editor Help", ID_HELP_TASEDITHELP
MENUITEM SEPARATOR
MENUITEM "&About", ID_HELP_ABOUT MENUITEM "&About", ID_HELP_ABOUT
END END
END END
@ -1409,22 +1410,36 @@ BEGIN
CONTROL " 4P",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,402,98,24,10 CONTROL " 4P",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,402,98,24,10
CONTROL " Superimpose",IDC_SUPERIMPOSE,"Button",BS_AUTO3STATE,372,74,55,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 GROUPBOX " History ",IDC_STATIC,310,255,123,116,BS_CENTER,WS_EX_RIGHT
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 "<<",TASEDIT_PREV_MARKER,315,376,23,14,NOT WS_TABSTOP
PUSHBUTTON "Similar",TASEDIT_FIND_BEST_SIMILAR_MARKER,338,376,34,14,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 "More",TASEDIT_FIND_NEXT_SIMILAR_MARKER,372,376,34,14,NOT WS_TABSTOP
PUSHBUTTON ">>",TASEDIT_NEXT_MARKER,405,376,23,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 CONTROL "",IDC_JUMP_PLAYBACK_BUTTON,"Button",BS_OWNERDRAW,5,1,59,13
RTEXT "Marker 99999",IDC_SELECTION_MARKER,3,379,60,10,0,WS_EX_RIGHT
EDITTEXT IDC_PLAYBACK_MARKER_EDIT,65,1,240,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP EDITTEXT IDC_PLAYBACK_MARKER_EDIT,65,1,240,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
RTEXT "Marker 0",IDC_PLAYBACK_MARKER,3,3,60,10,0,WS_EX_RIGHT
CONTROL "",IDC_JUMP_SELECTION_BUTTON,"Button",BS_OWNERDRAW,5,377,59,13
EDITTEXT IDC_SELECTION_MARKER_EDIT,65,377,240,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
RTEXT "Marker 99999",IDC_SELECTION_MARKER,3,379,60,10,0,WS_EX_RIGHT
CONTROL "",IDC_BRANCHES_BITMAP,"Static",SS_OWNERDRAW | SS_NOTIFY | SS_REALSIZEIMAGE | NOT WS_VISIBLE,315,160,113,89 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 " Turbo seek",CHECK_TURBO_SEEK,"Button",BS_AUTOCHECKBOX,379,26,50,12
CONTROL "",IDC_TEXT_SELECTION_BUTTON,"Button",BS_OWNERDRAW,315,121,113,12
LTEXT "Selection: 0 rows, 16 columns",IDC_TEXT_SELECTION,316,123,114,10 LTEXT "Selection: 0 rows, 16 columns",IDC_TEXT_SELECTION,316,123,114,10
LTEXT "Clipboard: 0 rows, 16 columns",IDC_TEXT_CLIPBOARD,316,134,114,10 LTEXT "Clipboard: 0 rows, 16 columns",IDC_TEXT_CLIPBOARD,316,134,114,10
CONTROL " Recording",IDC_RECORDING,"Button",BS_AUTO3STATE,316,74,49,10 CONTROL " Recording",IDC_RECORDING,"Button",BS_AUTO3STATE,316,74,49,10
END END
IDD_TASEDIT_ABOUT DIALOGEX 0, 0, 210, 71
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDCANCEL,79,49,50,14
ICON IDI_ICON4,IDC_STATIC,11,10,20,20
LTEXT "TAS Editor",IDC_STATIC,48,10,49,11
LTEXT "Version 1.0",IDC_STATIC,47,23,37,8
LTEXT "Created by AnS in 2011",IDC_STATIC,111,10,77,8
LTEXT "Based on TASEdit v0.1 made by zeromus & adelikat",IDC_STATIC,111,23,91,19,SS_NOPREFIX
END
IDD_TASEDIT_EXPORT DIALOGEX 0, 0, 158, 86 IDD_TASEDIT_EXPORT DIALOGEX 0, 0, 158, 86
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Export to FM2" CAPTION "Export to FM2"
@ -1439,18 +1454,18 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,50,141,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,50,141,10
END END
IDD_TASEDIT_FINDNOTE DIALOGEX 0, 0, 228, 52 IDD_TASEDIT_FINDNOTE DIALOGEX 0, 0, 228, 49
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Find Note" CAPTION "Find Note"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Find next",IDOK,171,6,51,14 DEFPUSHBUTTON "Find next",IDOK,171,5,51,14
PUSHBUTTON "Cancel",IDCANCEL,171,24,51,14 PUSHBUTTON "Close",IDCANCEL,171,23,51,14
EDITTEXT IDC_NOTE_TO_FIND,6,7,160,12,ES_AUTOHSCROLL EDITTEXT IDC_NOTE_TO_FIND,6,6,160,12,ES_AUTOHSCROLL
CONTROL " Match case",IDC_MATCH_CASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,25,53,10 CONTROL " Match case",IDC_MATCH_CASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,23,53,10
GROUPBOX "Direction",IDC_STATIC,82,21,83,26 GROUPBOX "Direction",IDC_STATIC,82,20,83,24,BS_CENTER
CONTROL " Up",IDC_RADIO_UP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,90,32,29,10 CONTROL " Up",IDC_RADIO_UP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,90,30,29,10
CONTROL " Down",IDC_RADIO_DOWN,"Button",BS_AUTORADIOBUTTON,125,32,32,10 CONTROL " Down",IDC_RADIO_DOWN,"Button",BS_AUTORADIOBUTTON,125,30,32,10
END END
IDD_TASEDIT_SAVECOMPACT DIALOGEX 0, 0, 122, 134 IDD_TASEDIT_SAVECOMPACT DIALOGEX 0, 0, 122, 134
@ -2035,6 +2050,47 @@ END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Ðóññêèé (Ðîññèÿ) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON4 ICON "res\\tasedit-icon32.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_TASEDIT_ABOUT, DIALOG
BEGIN
END
END
#endif // APSTUDIO_INVOKED
#endif // Ðóññêèé (Ðîññèÿ) resources
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Àíãëèéñêèé (ÑØÀ) resources // Àíãëèéñêèé (ÑØÀ) resources

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -185,6 +185,7 @@
#define IDD_TASEDIT_BRANCH_NOTE 188 #define IDD_TASEDIT_BRANCH_NOTE 188
#define IDI_ICON3 197 #define IDI_ICON3 197
#define IDD_TASEDIT_FINDNOTE 198 #define IDD_TASEDIT_FINDNOTE 198
#define IDD_TASEDIT_ABOUT 199
#define MENU_RESET 200 #define MENU_RESET 200
#define BUTTON_ROMS 200 #define BUTTON_ROMS 200
#define TXT_PAD1 200 #define TXT_PAD1 200
@ -212,6 +213,7 @@
#define IDC_ADDBP_ADDR_END 201 #define IDC_ADDBP_ADDR_END 201
#define IDC_NTVIEW_REFRESH_TRACKBAR 201 #define IDC_NTVIEW_REFRESH_TRACKBAR 201
#define IDC_ASSEMBLER_APPLY 201 #define IDC_ASSEMBLER_APPLY 201
#define IDI_ICON4 201
#define MENU_EJECT_DISK 202 #define MENU_EJECT_DISK 202
#define TXT_FAM 202 #define TXT_FAM 202
#define MENU_MV_EDIT_PASTE 202 #define MENU_MV_EDIT_PASTE 202
@ -428,16 +430,15 @@
#define IDC_SELECTION_MARKER_EDIT 1147 #define IDC_SELECTION_MARKER_EDIT 1147
#define IDC_NOTE_TO_FIND 1147 #define IDC_NOTE_TO_FIND 1147
#define IDC_BUTTON9 1148 #define IDC_BUTTON9 1148
#define TASEDIT_FIND_NEXT_MARKER 1148
#define TASEDIT_FIND_NEXT_SIMILAR_MARKER 1148 #define TASEDIT_FIND_NEXT_SIMILAR_MARKER 1148
#define IDC_HISTORYLIST 1149 #define IDC_HISTORYLIST 1149
#define IDC_BOOKMARKSLIST 1150 #define IDC_BOOKMARKSLIST 1150
#define TASEDIT_NEXT_MARKER 1151 #define TASEDIT_NEXT_MARKER 1151
#define IDC_BRANCHES_BUTTON 1152 #define IDC_BRANCHES_BUTTON 1152
#define IDC_BRANCHES_BUTTON2 1153 #define IDC_JUMP_PLAYBACK_BUTTON 1153
#define IDC_TEXT_SELECTION_BUTTON 1153
#define IDC_EDIT2 1154 #define IDC_EDIT2 1154
#define IDC_PLAYBACK_MARKER_EDIT 1154 #define IDC_PLAYBACK_MARKER_EDIT 1154
#define IDC_JUMP_SELECTION_BUTTON 1155
#define CHECK_SOUND_MUTETURBO 1179 #define CHECK_SOUND_MUTETURBO 1179
#define IDC_EDIT_AUTHOR 1180 #define IDC_EDIT_AUTHOR 1180
#define MEMW_STATIC 1181 #define MEMW_STATIC 1181
@ -568,6 +569,7 @@
#define IDC_RADIO_FOURSCORE 1271 #define IDC_RADIO_FOURSCORE 1271
#define IDC_SELECTION_MARKER 1271 #define IDC_SELECTION_MARKER 1271
#define IDC_NOTE_TOOLTIP_EDIT 1272 #define IDC_NOTE_TOOLTIP_EDIT 1272
#define IDC_SELECTION_MARKER2 1272
#define IDC_RADIO_DOWN 1273 #define IDC_RADIO_DOWN 1273
#define MENU_NETWORK 40040 #define MENU_NETWORK 40040
#define MENU_PALETTE 40041 #define MENU_PALETTE 40041
@ -971,9 +973,9 @@
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 199 #define _APS_NEXT_RESOURCE_VALUE 202
#define _APS_NEXT_COMMAND_VALUE 40516 #define _APS_NEXT_COMMAND_VALUE 40516
#define _APS_NEXT_CONTROL_VALUE 1274 #define _APS_NEXT_CONTROL_VALUE 1275
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif

View File

@ -23,6 +23,7 @@ bool Tasedit_rewind_now = false;
int marker_note_edit = MARKER_NOTE_EDIT_NONE; int marker_note_edit = MARKER_NOTE_EDIT_NONE;
char findnote_string[MAX_NOTE_LEN] = {0}; char findnote_string[MAX_NOTE_LEN] = {0};
int search_similar_marker = 0;
// all Taseditor functional modules // all Taseditor functional modules
TASEDIT_PROJECT project; TASEDIT_PROJECT project;
@ -893,12 +894,14 @@ bool LoadProject(char* fullname)
UpdateRecentProjectsArray(fullname); UpdateRecentProjectsArray(fullname);
RedrawTasedit(); RedrawTasedit();
RedrawWindowCaption(); RedrawWindowCaption();
search_similar_marker = 0;
return true; return true;
} else } else
{ {
// failed to load // failed to load
RedrawTasedit(); RedrawTasedit();
RedrawWindowCaption(); RedrawWindowCaption();
search_similar_marker = 0;
return false; return false;
} }
} }
@ -972,6 +975,25 @@ void SaveCompact_GetCheckboxes(HWND hwndDlg)
TASEdit_savecompact_list = (SendDlgItemMessage(hwndDlg, IDC_CHECK_LIST, BM_GETCHECK, 0, 0) == BST_CHECKED); TASEdit_savecompact_list = (SendDlgItemMessage(hwndDlg, IDC_CHECK_LIST, BM_GETCHECK, 0, 0) == BST_CHECKED);
TASEdit_savecompact_selection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED); TASEdit_savecompact_selection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED);
} }
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
break;
}
}
return FALSE;
}
BOOL CALLBACK SaveCompactProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) BOOL CALLBACK SaveCompactProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
@ -1842,7 +1864,12 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
tasedit_list.FollowSelection(); tasedit_list.FollowSelection();
break; break;
} }
case IDC_TEXT_SELECTION_BUTTON: case IDC_JUMP_PLAYBACK_BUTTON:
{
tasedit_list.FollowPlayback();
break;
}
case IDC_JUMP_SELECTION_BUTTON:
{ {
tasedit_list.FollowSelection(); tasedit_list.FollowSelection();
break; break;
@ -1923,11 +1950,16 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
case TASEDIT_FIND_BEST_SIMILAR_MARKER: case TASEDIT_FIND_BEST_SIMILAR_MARKER:
FindSimilarMarker(); search_similar_marker = 0;
current_markers.FindSimilar(search_similar_marker);
search_similar_marker++;
break; break;
case TASEDIT_FIND_NEXT_SIMILAR_MARKER: case TASEDIT_FIND_NEXT_SIMILAR_MARKER:
// reset search_offset to 0 current_markers.FindSimilar(search_similar_marker);
FindSimilarMarker(); search_similar_marker++;
break;
case ID_HELP_ABOUT:
DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDIT_ABOUT), hwndTasEdit, AboutProc);
break; break;
@ -2038,6 +2070,8 @@ bool EnterTasEdit()
selection.init(); selection.init();
marker_note_edit = MARKER_NOTE_EDIT_NONE; marker_note_edit = MARKER_NOTE_EDIT_NONE;
search_similar_marker = 0;
SetFocus(history.hwndHistoryList); // set focus only once, to show selection cursor SetFocus(history.hwndHistoryList); // set focus only once, to show selection cursor
SetFocus(tasedit_list.hwndList); SetFocus(tasedit_list.hwndList);
FCEU_DispMessage("TAS Editor engaged", 0); FCEU_DispMessage("TAS Editor engaged", 0);
@ -2264,24 +2298,6 @@ BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
return FALSE; return FALSE;
} }
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() void UpdateRecentProjectsMenu()
{ {

View File

@ -58,7 +58,6 @@ void SetTaseditInput();
void ClearTaseditInput(); void ClearTaseditInput();
void UpdateMarkerNote(); void UpdateMarkerNote();
void FindSimilarMarker();
void UpdateRecentProjectsMenu(); void UpdateRecentProjectsMenu();
void UpdateRecentProjectsArray(const char* addString); void UpdateRecentProjectsArray(const char* addString);

View File

@ -1,12 +1,18 @@
//Implementation file of Markers class //Implementation file of Markers class
#include "taseditproj.h" #include "taseditproj.h"
#include "zlib.h" #include "zlib.h"
#include <Shlwapi.h> // for StrStrI
extern bool TASEdit_empty_marker_notes; extern bool TASEdit_empty_marker_notes;
extern HWND hwndTasEdit;
extern PLAYBACK playback;
extern TASEDIT_SELECTION selection;
// resources // resources
char markers_save_id[MARKERS_ID_LEN] = "MARKERS"; char markers_save_id[MARKERS_ID_LEN] = "MARKERS";
char markers_skipsave_id[MARKERS_ID_LEN] = "MARKERX"; char markers_skipsave_id[MARKERS_ID_LEN] = "MARKERX";
char keywordDelimiters[] = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
MARKERS::MARKERS() MARKERS::MARKERS()
{ {
@ -371,4 +377,206 @@ bool MARKERS::checkMarkersDiff(MARKERS& their_markers, int end)
} }
return false; return false;
} }
// ------------------------------------------------------------------------------------
bool ordering(const std::pair<int, double>& d1, const std::pair<int, double>& d2)
{
return d1.second < d2.second;
}
void MARKERS::FindSimilar(int offset)
{
int i, t;
int sourceMarker = playback.shown_marker;
char sourceNote[MAX_NOTE_LEN];
strcpy(sourceNote, GetNote(sourceMarker).c_str());
// check if playback_marker_text is empty
if (!sourceNote[0])
{
MessageBox(hwndTasEdit, "Marker Note under Playback cursor is empty!", "Find Similar Note", MB_OK);
return;
}
// 0 - divide source string into keywords
int totalSourceKeywords = 0;
char sourceKeywords[MAX_NUM_KEYWORDS][MAX_NOTE_LEN] = {0};
int current_line_pos = 0;
char sourceKeywordsLine[MAX_NUM_KEYWORDS] = {0};
char* pch;
// divide into tokens
pch = strtok(sourceNote, keywordDelimiters);
while (pch != NULL)
{
if (strlen(pch) >= KEYWORD_MIN_LEN)
{
// check if same keyword already appeared in the string
for (t = totalSourceKeywords - 1; t >= 0; t--)
if (!_stricmp(sourceKeywords[t], pch)) break;
if (t < 0)
{
// save new keyword
strcpy(sourceKeywords[totalSourceKeywords], pch);
// also set its id into the line
sourceKeywordsLine[current_line_pos++] = totalSourceKeywords + 1;
totalSourceKeywords++;
} else
{
// same keyword found
sourceKeywordsLine[current_line_pos++] = t + 1;
}
}
pch = strtok(NULL, keywordDelimiters);
}
// we found the line (sequence) of keywords
sourceKeywordsLine[current_line_pos] = 0;
if (!totalSourceKeywords)
{
MessageBox(hwndTasEdit, "Marker Note under Playback cursor doesn't have keywords!", "Find Similar Note", MB_OK);
return;
}
// 1 - find how frequently each keyword appears in notes
std::vector<int> keywordFound(totalSourceKeywords);
char checkedNote[MAX_NOTE_LEN];
for (i = notes.size() - 1; i > 0; i--)
{
if (i != sourceMarker)
{
strcpy(checkedNote, notes[i].c_str());
for (t = totalSourceKeywords - 1; t >= 0; t--)
if (StrStrI(checkedNote, sourceKeywords[t]))
keywordFound[t]++;
}
}
// findmax
int maxFound = 0;
for (t = totalSourceKeywords - 1; t >= 0; t--)
if (maxFound < keywordFound[t])
maxFound = keywordFound[t];
// and then calculate weight of each keyword: the more often it appears in markers, the less weight it has
std::vector<double> keywordWeight(totalSourceKeywords);
for (t = totalSourceKeywords - 1; t >= 0; t--)
keywordWeight[t] = KEYWORD_WEIGHT_BASE + KEYWORD_WEIGHT_FACTOR * (keywordFound[t] / (double)maxFound);
// start accumulating priorities
std::vector<std::pair<int, double>> notePriority(notes.size());
// 2 - find keywords in notes (including cases when keyword appears inside another word)
for (i = notePriority.size() - 1; i > 0; i--)
{
notePriority[i].first = i;
if (i != sourceMarker)
{
strcpy(checkedNote, notes[i].c_str());
for (t = totalSourceKeywords - 1; t >= 0; t--)
{
if (StrStrI(checkedNote, sourceKeywords[t]))
notePriority[i].second += KEYWORD_CASEINSENTITIVE_BONUS_PER_CHAR * keywordWeight[t] * strlen(sourceKeywords[t]);
if (strstr(checkedNote, sourceKeywords[t]))
notePriority[i].second += KEYWORD_CASESENTITIVE_BONUS_PER_CHAR * keywordWeight[t] * strlen(sourceKeywords[t]);
}
}
}
// 3 - search sequences of keywords from all other notes
current_line_pos = 0;
char checkedKeywordsLine[MAX_NUM_KEYWORDS] = {0};
int keyword_id;
for (i = notes.size() - 1; i > 0; i--)
{
if (i != sourceMarker)
{
strcpy(checkedNote, notes[i].c_str());
// divide into tokens
pch = strtok(checkedNote, keywordDelimiters);
while (pch != NULL)
{
if (strlen(pch) >= KEYWORD_MIN_LEN)
{
// check if the keyword is one of sourceKeywords
for (t = totalSourceKeywords - 1; t >= 0; t--)
if (!_stricmp(sourceKeywords[t], pch)) break;
if (t >= 0)
{
// the keyword is one of sourceKeywords - set its id into the line
checkedKeywordsLine[current_line_pos++] = t + 1;
} else
{
// found keyword that doesn't appear in sourceNote, give penalty
notePriority[i].second -= KEYWORD_PENALTY_FOR_STRANGERS * strlen(pch);
// since the keyword breaks our sequence of coincident keywords, check if that sequence is similar to sourceKeywordsLine
if (current_line_pos >= KEYWORDS_LINE_MIN_SEQUENCE)
{
checkedKeywordsLine[current_line_pos] = 0;
// search checkedKeywordsLine in sourceKeywordsLine
if (strstr(sourceKeywordsLine, checkedKeywordsLine))
{
// found same sequence of keywords! add priority to this checkedNote
for (t = current_line_pos - 1; t >= 0; t--)
{
// add bonus for every keyword in the sequence
keyword_id = checkedKeywordsLine[t] - 1;
notePriority[i].second += current_line_pos * KEYWORD_SEQUENCE_BONUS_PER_CHAR * keywordWeight[keyword_id] * strlen(sourceKeywords[keyword_id]);
}
}
}
// clear checkedKeywordsLine
memset(checkedKeywordsLine, 0, MAX_NUM_KEYWORDS);
current_line_pos = 0;
}
}
pch = strtok(NULL, keywordDelimiters);
}
// finished dividing into tokens
if (current_line_pos >= KEYWORDS_LINE_MIN_SEQUENCE)
{
checkedKeywordsLine[current_line_pos] = 0;
// search checkedKeywordsLine in sourceKeywordsLine
if (strstr(sourceKeywordsLine, checkedKeywordsLine))
{
// found same sequence of keywords! add priority to this checkedNote
for (t = current_line_pos - 1; t >= 0; t--)
{
// add bonus for every keyword in the sequence
keyword_id = checkedKeywordsLine[t] - 1;
notePriority[i].second += current_line_pos * KEYWORD_SEQUENCE_BONUS_PER_CHAR * keywordWeight[keyword_id] * strlen(sourceKeywords[keyword_id]);
}
}
}
// clear checkedKeywordsLine
memset(checkedKeywordsLine, 0, MAX_NUM_KEYWORDS);
current_line_pos = 0;
}
}
// 4 - sort notePriority by second member of the pair
std::sort(notePriority.begin(), notePriority.end(), ordering);
/*
// debug trace
FCEU_printf("\n\n\n\n\n\n\n\n\n\n");
for (t = totalSourceKeywords - 1; t >= 0; t--)
FCEU_printf("Keyword: %s, %d, %f\n", sourceKeywords[t], keywordFound[t], keywordWeight[t]);
for (i = notePriority.size() - 1; i > 0; i--)
{
int marker_id = notePriority[i].first;
FCEU_printf("Result: %s, %d, %f\n", notes[marker_id].c_str(), marker_id, notePriority[i].second);
}
*/
// Send selection to the marker found
if (notePriority[notePriority.size()-1 - offset].second >= MIN_PRIORITY_TRESHOLD)
{
int marker_id = notePriority[notePriority.size()-1 - offset].first;
int frame = GetMarkerFrame(marker_id);
if (frame >= 0)
selection.JumpToFrame(frame);
} else
{
if (offset)
MessageBox(hwndTasEdit, "Could not find more Notes similar to Marker Note under Playback cursor!", "Find Similar Note", MB_OK);
else
MessageBox(hwndTasEdit, "Could not find anything similar to Marker Note under Playback cursor!", "Find Similar Note", MB_OK);
}
}

View File

@ -2,6 +2,20 @@
#define MARKERS_ID_LEN 8 #define MARKERS_ID_LEN 8
#define MAX_NOTE_LEN 80 #define MAX_NOTE_LEN 80
// constants for "Find Similar Note" algorithm (may need finetuning)
#define KEYWORD_MIN_LEN 2
#define MAX_NUM_KEYWORDS (MAX_NOTE_LEN / (KEYWORD_MIN_LEN+1)) + 1
#define KEYWORD_WEIGHT_BASE 2.0
#define KEYWORD_WEIGHT_FACTOR -1.0
#define KEYWORD_CASEINSENTITIVE_BONUS_PER_CHAR 1.0 // these two should be small, because they also work when keyword is inside another keyword, giving irrelevant results
#define KEYWORD_CASESENTITIVE_BONUS_PER_CHAR 1.0
#define KEYWORD_SEQUENCE_BONUS_PER_CHAR 5.0
#define KEYWORD_PENALTY_FOR_STRANGERS 0.2
#define KEYWORDS_LINE_MIN_SEQUENCE 1
#define MIN_PRIORITY_TRESHOLD 5.0
class MARKERS class MARKERS
{ {
public: public:
@ -40,6 +54,8 @@ public:
bool checkMarkersDiff(MARKERS& their_markers); bool checkMarkersDiff(MARKERS& their_markers);
bool checkMarkersDiff(MARKERS& their_markers, int end); bool checkMarkersDiff(MARKERS& their_markers, int end);
void FindSimilar(int offset);
private: private:
std::vector<int> markers_array; // Format: 0th = marker num (id) for frame 0, 1st = marker num for frame 1, ... std::vector<int> markers_array; // Format: 0th = marker num (id) for frame 0, 1st = marker num for frame 1, ...
std::vector<std::string> notes; // Format: 0th - note for intro (Marker 0), 1st - note for Marker1, 2nd - note for Marker2, ... std::vector<std::string> notes; // Format: 0th - note for intro (Marker 0), 1st - note for Marker1, 2nd - note for Marker2, ...

View File

@ -11,6 +11,7 @@ extern bool Tasedit_rewind_now;
extern bool turbo; extern bool turbo;
extern bool TASEdit_turbo_seek; extern bool TASEdit_turbo_seek;
extern int marker_note_edit; extern int marker_note_edit;
extern int search_similar_marker;
extern MARKERS current_markers; extern MARKERS current_markers;
extern GREENZONE greenzone; extern GREENZONE greenzone;
@ -301,6 +302,8 @@ void PLAYBACK::RedrawMarker()
// change marker note // change marker note
strcpy(new_text, current_markers.GetNote(shown_marker).c_str()); strcpy(new_text, current_markers.GetNote(shown_marker).c_str());
SetWindowText(hwndPlaybackMarkerEdit, new_text); SetWindowText(hwndPlaybackMarkerEdit, new_text);
// reset search_similar_marker
search_similar_marker = 0;
} }
void PLAYBACK::StartFromZero() void PLAYBACK::StartFromZero()

View File

@ -36,8 +36,6 @@ void TASEDIT_SELECTION::init()
{ {
hwndPrevMarker = GetDlgItem(hwndTasEdit, TASEDIT_PREV_MARKER); hwndPrevMarker = GetDlgItem(hwndTasEdit, TASEDIT_PREV_MARKER);
hwndNextMarker = GetDlgItem(hwndTasEdit, TASEDIT_NEXT_MARKER); hwndNextMarker = GetDlgItem(hwndTasEdit, TASEDIT_NEXT_MARKER);
hwndFindBestMarker = GetDlgItem(hwndTasEdit, TASEDIT_FIND_BEST_MARKER);
hwndFindNextMarker = GetDlgItem(hwndTasEdit, TASEDIT_FIND_NEXT_MARKER);
hwndTextSelection = GetDlgItem(hwndTasEdit, IDC_TEXT_SELECTION); hwndTextSelection = GetDlgItem(hwndTasEdit, IDC_TEXT_SELECTION);
hwndTextClipboard = GetDlgItem(hwndTasEdit, IDC_TEXT_CLIPBOARD); hwndTextClipboard = GetDlgItem(hwndTasEdit, IDC_TEXT_CLIPBOARD);
hwndSelectionMarker = GetDlgItem(hwndTasEdit, IDC_SELECTION_MARKER); hwndSelectionMarker = GetDlgItem(hwndTasEdit, IDC_SELECTION_MARKER);

View File

@ -59,7 +59,7 @@ public:
bool must_find_current_marker; bool must_find_current_marker;
int shown_marker; int shown_marker;
HWND hwndPrevMarker, hwndNextMarker, hwndFindBestMarker, hwndFindNextMarker; HWND hwndPrevMarker, hwndNextMarker;
HWND hwndTextSelection, hwndTextClipboard; HWND hwndTextSelection, hwndTextClipboard;
HWND hwndSelectionMarker, hwndSelectionMarkerEdit; HWND hwndSelectionMarker, hwndSelectionMarkerEdit;

View File

@ -863,6 +863,7 @@
<None Include="..\src\drivers\win\res\ICON_1.ico" /> <None Include="..\src\drivers\win\res\ICON_1.ico" />
<None Include="..\src\drivers\win\res\ICON_2.ico" /> <None Include="..\src\drivers\win\res\ICON_2.ico" />
<None Include="..\src\drivers\win\res\tasedit-icon.ico" /> <None Include="..\src\drivers\win\res\tasedit-icon.ico" />
<None Include="..\src\drivers\win\res\tasedit-icon32.ico" />
<None Include="..\src\drivers\win\res\te_0.bmp" /> <None Include="..\src\drivers\win\res\te_0.bmp" />
<None Include="..\src\drivers\win\res\te_1.bmp" /> <None Include="..\src\drivers\win\res\te_1.bmp" />
<None Include="..\src\drivers\win\res\te_10.bmp" /> <None Include="..\src\drivers\win\res\te_10.bmp" />
@ -901,6 +902,7 @@
<None Include="..\src\pputile.inc" /> <None Include="..\src\pputile.inc" />
<None Include="ClassDiagram1.cd" /> <None Include="ClassDiagram1.cd" />
<None Include="res\tasedit-icon.ico" /> <None Include="res\tasedit-icon.ico" />
<None Include="res\tasedit-icon32.ico" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -1502,6 +1502,8 @@
<None Include="..\src\drivers\win\res\icon4.ico" /> <None Include="..\src\drivers\win\res\icon4.ico" />
<None Include="res\tasedit-icon.ico" /> <None Include="res\tasedit-icon.ico" />
<None Include="..\src\drivers\win\res\tasedit-icon.ico" /> <None Include="..\src\drivers\win\res\tasedit-icon.ico" />
<None Include="res\tasedit-icon32.ico" />
<None Include="..\src\drivers\win\res\tasedit-icon32.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="..\src\auxlib.lua" /> <CustomBuild Include="..\src\auxlib.lua" />