From 2b0fbdf61d14684e2e9fc6494bbe10f44c12c605 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Tue, 21 Feb 2012 17:54:40 +0000 Subject: [PATCH] * Taseditor: registering click at buttondown; Alt+click on input = set pattern * Taseditor: Alt + wheel = Right button + wheel * Taseditor: header lights on mouseover * Taseditor: different patterns format --- output/tools/taseditor_patterns.txt | 11 +- src/drivers/win/res.rc | 16 +- src/drivers/win/taseditor.cpp | 4 +- src/drivers/win/taseditor/history.cpp | 6 +- src/drivers/win/taseditor/recorder.cpp | 20 +- src/drivers/win/taseditor/recorder.h | 2 +- src/drivers/win/taseditor/taseditor_list.cpp | 254 ++++++++++-------- src/drivers/win/taseditor/taseditor_list.h | 22 +- .../win/taseditor/taseditor_window.cpp | 16 +- 9 files changed, 185 insertions(+), 166 deletions(-) diff --git a/output/tools/taseditor_patterns.txt b/output/tools/taseditor_patterns.txt index 7f038f70..a584bd4b 100644 --- a/output/tools/taseditor_patterns.txt +++ b/output/tools/taseditor_patterns.txt @@ -1,18 +1,15 @@ - Alternating (1010...) 10 Alternating at 30FPS (11001100...) 1100 One Quarter (10001000...) -+--- +1000 Tap'n'Hold (101111111...) -AaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - - +1011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 One-Two (1011010110...) -!0!!o +10110 -FORMAT OF THIS FILE: 2 lines per every Pattern - first line is the name, second line is looped sequence of chars: first char is considered to be the flag of "button pressed", any other char in the sequence will mean "button released". Thus, every Pattern starts from button press. +FORMAT OF THIS FILE: 2 lines per every Pattern - first line is the name, second line is looped sequence of presses: 1 = press button, 0 = don't press button. diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 1d046b96..2801f268 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -1407,17 +1407,17 @@ BEGIN PUSHBUTTON ">",TASEDITOR_FORWARD,269,9,23,14,NOT WS_TABSTOP PUSHBUTTON ">>",TASEDITOR_FORWARD_FULL,292,9,23,14,NOT WS_TABSTOP CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER,200,39,115,6 - CONTROL " Follow cursor",CHECK_FOLLOW_CURSOR,"Button",BS_AUTOCHECKBOX,258,25,56,12 + CONTROL " Follow cursor",CHECK_FOLLOW_CURSOR,"Button",BS_AUTOCHECKBOX,202,25,56,12 CONTROL " Auto-restore last position",CHECK_AUTORESTORE_PLAYBACK, "Button",BS_AUTOCHECKBOX,202,48,105,12 CONTROL "",IDC_BOOKMARKSLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | NOT WS_VISIBLE | WS_BORDER,201,178,113,89 CONTROL "",IDC_HISTORYLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOLABELWRAP | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER,201,282,113,42 - CONTROL " All",IDC_RADIO_ALL,"Button",BS_AUTORADIOBUTTON,289,71,24,10 + CONTROL " All",IDC_RADIO_ALL,"Button",BS_AUTORADIOBUTTON,290,71,24,10 CONTROL " 1P",IDC_RADIO_1P,"Button",BS_AUTORADIOBUTTON,202,83,25,10 - CONTROL " 2P",IDC_RADIO_2P,"Button",BS_AUTORADIOBUTTON,231,83,24,10 - CONTROL " 3P",IDC_RADIO_3P,"Button",BS_AUTORADIOBUTTON,260,83,25,10 - CONTROL " 4P",IDC_RADIO_4P,"Button",BS_AUTORADIOBUTTON,289,83,24,10 - CONTROL " Superimpose",IDC_SUPERIMPOSE,"Button",BS_AUTO3STATE,202,96,54,10 + CONTROL " 2P",IDC_RADIO_2P,"Button",BS_AUTORADIOBUTTON,231,83,25,10 + CONTROL " 3P",IDC_RADIO_3P,"Button",BS_AUTORADIOBUTTON,261,83,24,10 + CONTROL " 4P",IDC_RADIO_4P,"Button",BS_AUTORADIOBUTTON,290,83,24,10 + CONTROL " Superimpose",IDC_SUPERIMPOSE,"Button",BS_AUTO3STATE,202,96,55,10 PUSHBUTTON "<<",TASEDITOR_PREV_MARKER,201,332,23,14,NOT WS_TABSTOP PUSHBUTTON "Similar",TASEDITOR_FIND_BEST_SIMILAR_MARKER,224,332,34,14,NOT WS_TABSTOP PUSHBUTTON "More",TASEDITOR_FIND_NEXT_SIMILAR_MARKER,258,332,34,14,NOT WS_TABSTOP @@ -1429,13 +1429,13 @@ BEGIN EDITTEXT IDC_SELECTION_MARKER_EDIT,64,333,127,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP RTEXT "Marker 99999",IDC_SELECTION_MARKER,3,335,58,10,0,WS_EX_RIGHT CONTROL "",IDC_BRANCHES_BITMAP,"Static",SS_OWNERDRAW | SS_NOTIFY | SS_REALSIZEIMAGE | NOT WS_VISIBLE,201,178,113,89 - CONTROL " Turbo seek",CHECK_TURBO_SEEK,"Button",BS_AUTOCHECKBOX,202,25,50,12 + CONTROL " Turbo seek",CHECK_TURBO_SEEK,"Button",BS_AUTOCHECKBOX,262,25,50,12 LTEXT "Selection: 0 rows, 16 columns",IDC_TEXT_SELECTION,203,118,112,10 LTEXT "Clipboard: 0 rows, 16 columns",IDC_TEXT_CLIPBOARD,202,128,114,10 CONTROL " Recording",IDC_RECORDING,"Button",BS_AUTO3STATE,202,71,64,10 PUSHBUTTON "Run function",TASEDITOR_RUN_MANUAL,201,150,54,14,WS_DISABLED | NOT WS_TABSTOP CONTROL "Auto function",IDC_RUN_AUTO,"Button",BS_AUTOCHECKBOX,260,152,55,10 - CONTROL " Use pattern",IDC_USEPATTERN,"Button",BS_AUTOCHECKBOX,260,96,54,10 + CONTROL " Use pattern",IDC_USEPATTERN,"Button",BS_AUTOCHECKBOX,261,96,53,10 END IDD_TASEDITOR_ABOUT DIALOGEX 0, 0, 208, 70 diff --git a/src/drivers/win/taseditor.cpp b/src/drivers/win/taseditor.cpp index 3603761d..1fdedf05 100644 --- a/src/drivers/win/taseditor.cpp +++ b/src/drivers/win/taseditor.cpp @@ -44,6 +44,7 @@ extern void TaseditorManualFunction(); // resources char patternsFilename[] = "\\taseditor_patterns.txt"; +char autofire_patterns_flagpress = 49; // "1" // enterframe function void UpdateTasEditor() @@ -615,12 +616,11 @@ bool EnterTasEditor() // save the name autofire_patterns_names.push_back(tempstr1); // parse 2nd string to sequence of 1s and 0s - char flagpress = tempstr2[0]; autofire_patterns.resize(total_patterns); autofire_patterns[total_patterns - 1].resize(tempstr2.size()); for (int i = tempstr2.size() - 1; i >= 0; i--) { - if (tempstr2[i] == flagpress) + if (tempstr2[i] == autofire_patterns_flagpress) autofire_patterns[total_patterns - 1][i] = 1; else autofire_patterns[total_patterns - 1][i] = 0; diff --git a/src/drivers/win/taseditor/history.cpp b/src/drivers/win/taseditor/history.cpp index 4e37ff56..e847f797 100644 --- a/src/drivers/win/taseditor/history.cpp +++ b/src/drivers/win/taseditor/history.cpp @@ -755,14 +755,12 @@ LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l return 0; case WM_MOUSEWHEEL: { - // right button/Ctrl/Shift + wheel -> send the message to Piano Roll + // Right button/Ctrl/Shift/Alt + wheel -> send the message to Piano Roll // but if just wheel - use default scrolling here - if (GET_KEYSTATE_WPARAM(wParam) & (MK_RBUTTON|MK_SHIFT|MK_CONTROL)) + if (GET_KEYSTATE_WPARAM(wParam) & (MK_RBUTTON|MK_SHIFT|MK_CONTROL) || (GetKeyState(VK_MENU) < 0)) return SendMessage(list.hwndList, msg, wParam, lParam); - } - } return CallWindowProc(hwndHistoryList_oldWndProc, hWnd, msg, wParam, lParam); } diff --git a/src/drivers/win/taseditor/recorder.cpp b/src/drivers/win/taseditor/recorder.cpp index 5e3ffc3c..45e25548 100644 --- a/src/drivers/win/taseditor/recorder.cpp +++ b/src/drivers/win/taseditor/recorder.cpp @@ -43,7 +43,7 @@ void RECORDER::init() hwndRB_Rec3P = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RADIO_3P); hwndRB_Rec4P = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RADIO_4P); old_multitrack_recording_joypad = multitrack_recording_joypad; - old_pattern_offset = 0; + old_current_pattern = old_pattern_offset = 0; must_increase_pattern_offset = false; old_movie_readonly = movie_readonly; old_joy.resize(MAX_NUM_JOYPADS); @@ -105,6 +105,9 @@ void RECORDER::update() Button_SetCheck(hwndRecCheckbox, movie_readonly?BST_UNCHECKED : BST_CHECKED); old_movie_readonly = movie_readonly; } + // reset pattern_offset if current_pattern has changed + if (old_current_pattern != taseditor_config.current_pattern) + pattern_offset = 0; // increase pattern_offset if needed if (must_increase_pattern_offset) { @@ -112,20 +115,21 @@ void RECORDER::update() if (!taseditor_config.pattern_skips_lag || lagFlag == 0) { pattern_offset++; - if (pattern_offset >= (int)autofire_patterns[taseditor_config.current_pattern].size()) - pattern_offset -= autofire_patterns[taseditor_config.current_pattern].size(); + if (pattern_offset >= (int)autofire_patterns[old_current_pattern].size()) + pattern_offset -= autofire_patterns[old_current_pattern].size(); } } - // update "Recording" checkbox text - if (old_pattern_offset != pattern_offset) + // update "Recording" checkbox text if something changed in pattern + if (old_current_pattern != taseditor_config.current_pattern || old_pattern_offset != pattern_offset) { - if (!taseditor_config.pattern_recording || autofire_patterns[taseditor_config.current_pattern][pattern_offset]) + old_current_pattern = taseditor_config.current_pattern; + old_pattern_offset = pattern_offset; + if (!taseditor_config.pattern_recording || autofire_patterns[old_current_pattern][pattern_offset]) // either not using Patterns or current pattern has 1 in current offset SetWindowText(hwndRecCheckbox, recordingCheckbox); else // current pattern has 0 in current offset, this means next recorded frame will be blank SetWindowText(hwndRecCheckbox, recordingCheckboxBlankPattern); - old_pattern_offset = pattern_offset; } // update recording radio buttons if user changed multitrack_recording_joypad if (old_multitrack_recording_joypad != multitrack_recording_joypad) @@ -213,7 +217,7 @@ void RECORDER::InputChanged() for (int i = 0; i < num_joys; ++i) { old_joy[i] = history.GetCurrentSnapshot().GetJoystickInfo(currFrameCounter, i); - if (!taseditor_config.pattern_recording || autofire_patterns[taseditor_config.current_pattern][pattern_offset]) + if (!taseditor_config.pattern_recording || autofire_patterns[old_current_pattern][pattern_offset]) new_joy[i] = currMovieData.records[currFrameCounter].joysticks[i]; else new_joy[i] = 0; // blank diff --git a/src/drivers/win/taseditor/recorder.h b/src/drivers/win/taseditor/recorder.h index 233202d1..bb7ef83a 100644 --- a/src/drivers/win/taseditor/recorder.h +++ b/src/drivers/win/taseditor/recorder.h @@ -37,7 +37,7 @@ public: private: int old_multitrack_recording_joypad; - int old_pattern_offset; + int old_current_pattern, old_pattern_offset; bool must_increase_pattern_offset; bool old_movie_readonly; diff --git a/src/drivers/win/taseditor/taseditor_list.cpp b/src/drivers/win/taseditor/taseditor_list.cpp index 2f938fe2..972ec09b 100644 --- a/src/drivers/win/taseditor/taseditor_list.cpp +++ b/src/drivers/win/taseditor/taseditor_list.cpp @@ -32,7 +32,7 @@ char list_save_id[LIST_ID_LEN] = "LIST"; char list_skipsave_id[LIST_ID_LEN] = "LISX"; 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, 0x006311, 0x008500, 0x1dad00, 0x46d100, 0x6ee300, 0x97e800, 0xb8f000, 0xdaf700, 0xffff7e, 0xffffb7 }; +COLORREF header_lights_colors[11] = { 0x0, 0x007313, 0x009100, 0x1daf00, 0x42c700, 0x65d900, 0x91e500, 0xb0f000, 0xdaf700, 0xf0fc7c, 0xfcffba }; TASEDITOR_LIST::TASEDITOR_LIST() { @@ -69,8 +69,6 @@ void TASEDITOR_LIST::init() "Arial"); /*font name*/ bg_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); - header_colors.resize(TOTAL_COLUMNS); - hwndList = GetDlgItem(taseditor_window.hwndTasEditor, IDC_LIST1); // prepare the main listview ListView_SetExtendedListViewStyleEx(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_INFOTIP); @@ -158,6 +156,11 @@ void TASEDITOR_LIST::init() ListView_InsertColumn(hwndList, 0, &lvc); hrmenu = LoadMenu(fceu_hInstance,"TASEDITORCONTEXTMENUS"); + header_colors.resize(TOTAL_COLUMNS); + // fill TrackMouseEvent struct + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwndHeader; } void TASEDITOR_LIST::free() @@ -196,7 +199,7 @@ void TASEDITOR_LIST::free() } void TASEDITOR_LIST::reset() { - next_header_update_time = 0; + next_header_update_time = header_item_under_mouse = 0; // delete all columns except 0th while (ListView_DeleteColumn(hwndList, 1)) {} // setup columns @@ -241,62 +244,43 @@ void TASEDITOR_LIST::update() { next_header_update_time = clock() + HEADER_LIGHT_UPDATE_TICK; bool changes_made = false; + int light_value = 0; // 1 - update Frame# columns' heads - if (header_colors[COLUMN_FRAMENUM] > HEADER_LIGHT_HOLD) + if (GetAsyncKeyState(VK_MENU) & 0x8000) + light_value = HEADER_LIGHT_HOLD; + else if (header_item_under_mouse == COLUMN_FRAMENUM || header_item_under_mouse == COLUMN_FRAMENUM2) + light_value = (selection.GetCurrentSelectionSize() > 0) ? HEADER_LIGHT_MOUSEOVER_SEL : HEADER_LIGHT_MOUSEOVER; + if (header_colors[COLUMN_FRAMENUM] < light_value) + { + header_colors[COLUMN_FRAMENUM]++; + changes_made = true; + } else if (header_colors[COLUMN_FRAMENUM] > light_value) { header_colors[COLUMN_FRAMENUM]--; changes_made = true; - } else - { - if ((GetAsyncKeyState(VK_MENU) & 0x8000)) - { - // Alt key is held - if (header_colors[COLUMN_FRAMENUM] < HEADER_LIGHT_HOLD) - { - header_colors[COLUMN_FRAMENUM]++; - changes_made = true; - } - } else - { - // Alt key is released - if (header_colors[COLUMN_FRAMENUM]) - { - header_colors[COLUMN_FRAMENUM]--; - changes_made = true; - } - } } header_colors[COLUMN_FRAMENUM2] = header_colors[COLUMN_FRAMENUM]; - // update input columns' heads + // 2 - update input columns' heads int i = num_columns-1; if (i == COLUMN_FRAMENUM2) i--; for (; i >= COLUMN_JOYPAD1_A; i--) { - if (header_colors[i] > HEADER_LIGHT_HOLD) + light_value = 0; + if (recorder.current_joy[(i - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS] & (1 << ((i - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS))) + light_value = HEADER_LIGHT_HOLD; + else if (header_item_under_mouse == i) + light_value = (selection.GetCurrentSelectionSize() > 0) ? HEADER_LIGHT_MOUSEOVER_SEL : HEADER_LIGHT_MOUSEOVER; + if (header_colors[i] < light_value) + { + header_colors[i]++; + changes_made = true; + } else if (header_colors[i] > light_value) { header_colors[i]--; changes_made = true; - } else - { - if (recorder.current_joy[(i - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS] & (1 << ((i - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS))) - { - // the button is held - if (header_colors[i] < HEADER_LIGHT_HOLD) - { - header_colors[i]++; - changes_made = true; - } - } else - { - // the button is released - if (header_colors[i]) - { - header_colors[i]--; - changes_made = true; - } - } - } + } } + // 3 - redraw if (changes_made) RedrawHeader(); } @@ -693,79 +677,34 @@ LONG TASEDITOR_LIST::HeaderCustomDraw(NMLVCUSTOMDRAW* msg) } } -void TASEDITOR_LIST::SingleClick(LPNMITEMACTIVATE info) -{ - int row_index = info->iItem; - if(row_index == -1) return; - int column_index = info->iSubItem; - - if(column_index == COLUMN_ICONS) - { - // click on the "icons" column - jump to the frame - selection.ClearSelection(); - playback.jump(row_index); - } else if(column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2) - { - // click on the "frame number" column - set marker if clicked with Alt - if (info->uKeyFlags & LVKF_ALT) - { - // reverse MARKER_FLAG_BIT in pointed frame - markers_manager.ToggleMarker(row_index); - selection.must_find_current_marker = playback.must_find_current_marker = true; - if (markers_manager.GetMarker(row_index)) - history.RegisterMarkersChange(MODTYPE_MARKER_SET, row_index); - else - history.RegisterMarkersChange(MODTYPE_MARKER_UNSET, row_index); - RedrawRow(row_index); - } - } - else if(column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R) - { - ToggleJoypadBit(column_index, row_index, info->uKeyFlags); - } -} -void TASEDITOR_LIST::DoubleClick(LPNMITEMACTIVATE info) -{ - int row_index = info->iItem; - if(row_index == -1) return; - int column_index = info->iSubItem; - - if(column_index == COLUMN_ICONS || column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2) - { - // double click sends playback to the frame - selection.ClearSelection(); - playback.jump(row_index); - } else if(column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R) - { - ToggleJoypadBit(column_index, row_index, info->uKeyFlags); - } -} - void TASEDITOR_LIST::ToggleJoypadBit(int column_index, int row_index, UINT KeyFlags) { int joy = (column_index - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; int bit = (column_index - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - if (KeyFlags & (LVKF_SHIFT|LVKF_CONTROL)) + if (KeyFlags & (MK_SHIFT|MK_CONTROL)) { // update multiple rows, using last row index as a flag to decide operation SelectionFrames* current_selection = selection.MakeStrobe(); SelectionFrames::iterator current_selection_end(current_selection->end()); - if (currMovieData.records[row_index].checkBit(joy, bit)) + if (current_selection->size()) { - // clear range - for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; it++) + if (currMovieData.records[row_index].checkBit(joy, bit)) { - currMovieData.records[*it].clearBit(joy, bit); - } - greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_UNSET, *current_selection->begin(), *current_selection->rbegin())); - } else - { - // set range - for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; it++) + // clear range + for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; it++) + { + currMovieData.records[*it].clearBit(joy, bit); + } + greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_UNSET, *current_selection->begin(), *current_selection->rbegin())); + } else { - currMovieData.records[*it].setBit(joy, bit); + // set range + for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; it++) + { + currMovieData.records[*it].setBit(joy, bit); + } + greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_SET, *current_selection->begin(), *current_selection->rbegin())); } - greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_SET, *current_selection->begin(), *current_selection->rbegin())); } } else { @@ -1029,7 +968,26 @@ LRESULT APIENTRY HeaderWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam switch(msg) { case WM_SETCURSOR: - return true; // no column resizing + // no column resizing cursor, always show arrow + SetCursor(LoadCursor(0, IDC_ARROW)); + return true; + case WM_MOUSEMOVE: + { + // perform hit test + HD_HITTESTINFO info; + info.pt.x = GET_X_LPARAM(lParam) + HEADER_DX_FIX; + info.pt.y = GET_Y_LPARAM(lParam); + SendMessage(hWnd, HDM_HITTEST, 0, (LPARAM)&info); + list.header_item_under_mouse = info.iItem; + // ensure that WM_MOUSELEAVE will be catched + TrackMouseEvent(&list.tme); + break; + } + case WM_MOUSELEAVE: + { + list.header_item_under_mouse = -1; + break; + } case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: { @@ -1037,9 +995,9 @@ LRESULT APIENTRY HeaderWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam { // perform hit test HD_HITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam); + info.pt.x = GET_X_LPARAM(lParam) + HEADER_DX_FIX; info.pt.y = GET_Y_LPARAM(lParam); - SendMessage(hWnd,HDM_HITTEST,0,(LPARAM)&info); + SendMessage(hWnd, HDM_HITTEST, 0, (LPARAM)&info); if(info.iItem >= COLUMN_FRAMENUM && info.iItem <= COLUMN_FRAMENUM2) list.ColumnSet(info.iItem, (GetKeyState(VK_MENU) < 0)); } @@ -1080,6 +1038,69 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; break; } + case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + { + bool alt_pressed = (GetKeyState(VK_MENU) < 0); + int fwKeys = GET_KEYSTATE_WPARAM(wParam); + // perform hit test + LVHITTESTINFO info; + info.pt.x = GET_X_LPARAM(lParam); + info.pt.y = GET_Y_LPARAM(lParam); + ListView_SubItemHitTest(hWnd, (LPARAM)&info); + int row_index = info.iItem; + int column_index = info.iSubItem; + if(row_index >= 0) + { + if(column_index == COLUMN_ICONS) + { + // click on the "icons" column - jump to the frame + selection.ClearSelection(); + playback.jump(row_index); + } else if(column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2) + { + // clicked on the "Frame#" column + if (msg == WM_LBUTTONDBLCLK && !alt_pressed) + { + // doubleclick - jump to the frame + selection.ClearSelection(); + playback.jump(row_index); + } else + { + // set marker if clicked with Alt + if (alt_pressed) + { + markers_manager.ToggleMarker(row_index); + selection.must_find_current_marker = playback.must_find_current_marker = true; + if (markers_manager.GetMarker(row_index)) + history.RegisterMarkersChange(MODTYPE_MARKER_SET, row_index); + else + history.RegisterMarkersChange(MODTYPE_MARKER_UNSET, row_index); + list.RedrawRow(row_index); + } + // also select the row + CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam); + } + } else if(column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R) + { + // clicked on input + // first call old wndproc to set selection on the row + if (alt_pressed) + { + // Alt should select region, just like Shift + CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam|MK_SHIFT, lParam); + int joy = (column_index - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; + int button = (column_index - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; + list.InputColumnSetPattern(joy, button); + } else + { + CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam); + list.ToggleJoypadBit(column_index, row_index, GET_KEYSTATE_WPARAM(wParam)); + } + } + } + return 0; + } case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: { @@ -1088,11 +1109,12 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) } case WM_MOUSEWHEEL: { + bool alt_pressed = (GetKeyState(VK_MENU) < 0); int fwKeys = GET_KEYSTATE_WPARAM(wParam); int zDelta = GET_WHEEL_DELTA_WPARAM(wParam); if (fwKeys & MK_SHIFT) { - // Shift + scroll = Playback rewind full(speed)/forward full(speed) + // Shift + wheel = Playback rewind full(speed)/forward full(speed) if (zDelta < 0) playback.ForwardFull(-zDelta / 120); else if (zDelta > 0) @@ -1100,15 +1122,18 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } else if (fwKeys & MK_CONTROL) { - // Ctrl + scroll = Selection rewind full(speed)/forward full(speed) + // Ctrl + wheel = Selection rewind full(speed)/forward full(speed) if (zDelta < 0) selection.JumpNextMarker(-zDelta / 120); else if (zDelta > 0) selection.JumpPrevMarker(zDelta / 120); return 0; - } else if (fwKeys & MK_RBUTTON) + } else if (alt_pressed || fwKeys & MK_RBUTTON) { - // Right button + scroll = rewind/forward + // Right button + wheel = Alt + wheel = rewind/forward + // if both Right button and Alt are pressed, move 2x faster + if (alt_pressed && fwKeys & MK_RBUTTON) + zDelta *= BOOST_WHEN_BOTH_RIGHTBUTTON_AND_ALT_PRESSED; int destination_frame = currFrameCounter - (zDelta / 120); if (destination_frame < 0) destination_frame = 0; playback.jump(destination_frame); @@ -1134,7 +1159,6 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) list.RightClick(info); return 0; } - } return CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam); } diff --git a/src/drivers/win/taseditor/taseditor_list.h b/src/drivers/win/taseditor/taseditor_list.h index 6a41be04..64b56ab4 100644 --- a/src/drivers/win/taseditor/taseditor_list.h +++ b/src/drivers/win/taseditor/taseditor_list.h @@ -10,8 +10,13 @@ #define NUM_JOYPAD_BUTTONS 8 #define HEADER_LIGHT_MAX 10 -#define HEADER_LIGHT_HOLD 4 +#define HEADER_LIGHT_HOLD 5 +#define HEADER_LIGHT_MOUSEOVER 2 +#define HEADER_LIGHT_MOUSEOVER_SEL 3 #define HEADER_LIGHT_UPDATE_TICK 40 // 25FPS +#define HEADER_DX_FIX 4 + +#define BOOST_WHEN_BOTH_RIGHTBUTTON_AND_ALT_PRESSED 2 enum { @@ -137,18 +142,20 @@ public: LONG CustomDraw(NMLVCUSTOMDRAW* msg); LONG HeaderCustomDraw(NMLVCUSTOMDRAW* msg); - void SingleClick(LPNMITEMACTIVATE info); - void DoubleClick(LPNMITEMACTIVATE info); - void RightClick(LVHITTESTINFO& info); void StrayClickMenu(LVHITTESTINFO& info); void RightClickMenu(LVHITTESTINFO& info); void ToggleJoypadBit(int column_index, int row_index, UINT KeyFlags); void ColumnSet(int column, bool alt_pressed); + bool FrameColumnSetPattern(); + bool FrameColumnSet(); + bool InputColumnSetPattern(int joy, int button); + bool InputColumnSet(int joy, int button); + int header_item_under_mouse; HWND hwndList, hwndHeader; - + TRACKMOUSEEVENT tme; // GDI stuff HIMAGELIST himglist; HFONT hMainListFont, hMainListSelectFont, hMarkersFont, hMarkersEditFont; @@ -157,11 +164,6 @@ public: private: void CenterListAt(int frame); - bool FrameColumnSetPattern(); - bool FrameColumnSet(); - bool InputColumnSetPattern(int joy, int button); - bool InputColumnSet(int joy, int button); - std::vector header_colors; int num_columns; int next_header_update_time; diff --git a/src/drivers/win/taseditor/taseditor_window.cpp b/src/drivers/win/taseditor/taseditor_window.cpp index 91efb70a..0f531b95 100644 --- a/src/drivers/win/taseditor/taseditor_window.cpp +++ b/src/drivers/win/taseditor/taseditor_window.cpp @@ -71,12 +71,12 @@ static struct IDC_BOOKMARKS_BOX, -1, 0, 0, 0, "", "", false, 0, 0, IDC_HISTORY_BOX, -1, 0, 0, -1, "", "", false, 0, 0, TASEDITOR_REWIND_FULL, -1, 0, 0, 0, "Send Playback to previous Marker (mouse: Shift+Wheel up) (hotkey: Shift+PageUp)", "", false, 0, 0, - TASEDITOR_REWIND, -1, 0, 0, 0, "Rewind one frame (mouse: Right button+Wheel up)", "", false, EMUCMD_TASEDITOR_REWIND, 0, + TASEDITOR_REWIND, -1, 0, 0, 0, "Rewind one frame (mouse: Right button+Wheel up) (Alt+Wheel up)", "", false, EMUCMD_TASEDITOR_REWIND, 0, TASEDITOR_PLAYSTOP, -1, 0, 0, 0, "Pause/Unpause Emulation (mouse: Middle button)", "", false, EMUCMD_PAUSE, 0, - TASEDITOR_FORWARD, -1, 0, 0, 0, "Advance one frame (mouse: Right button+Wheel down)", "", false, EMUCMD_FRAME_ADVANCE, 0, + TASEDITOR_FORWARD, -1, 0, 0, 0, "Advance one frame (mouse: Right button+Wheel down) (Alt+Wheel down)", "", false, EMUCMD_FRAME_ADVANCE, 0, TASEDITOR_FORWARD_FULL, -1, 0, 0, 0, "Send Playback to next Marker (mouse: Shift+Wheel down) (hotkey: Shift+PageDown)", "", false, 0, 0, IDC_PROGRESS1, -1, 0, 0, 0, "", "", false, 0, 0, - CHECK_FOLLOW_CURSOR, -1, 0, 0, 0, "The List will follow Playback cursor movements", "", false, 0, 0, + CHECK_FOLLOW_CURSOR, -1, 0, 0, 0, "The Piano Roll will follow Playback cursor movements", "", false, 0, 0, CHECK_AUTORESTORE_PLAYBACK, -1, 0, 0, 0, "If you change input above Playback, cursor will run where it was before change", "", false, 0, 0, IDC_BOOKMARKSLIST, -1, 0, 0, 0, "Right click = set Bookmark, Left click = jump to Bookmark or load Branch", "", false, 0, 0, IDC_HISTORYLIST, -1, 0, 0, -1, "Click to revert movie back to that time", "", false, 0, 0, @@ -91,10 +91,10 @@ static struct TASEDITOR_FIND_BEST_SIMILAR_MARKER, -1, -1, 0, -1, "Auto-search for Marker Note", "", false, 0, 0, TASEDITOR_FIND_NEXT_SIMILAR_MARKER, -1, -1, 0, -1, "Continue Auto-search", "", false, 0, 0, TASEDITOR_NEXT_MARKER, -1, -1, 0, -1, "Send Selection to next Marker (mouse: Ctrl+Wheel up) (hotkey: Ctrl+PageDown)", "", false, 0, 0, - IDC_JUMP_PLAYBACK_BUTTON, 0, 0, 0, 0, "Click here to scroll the List to Playback cursor", "", false, 0, 0, + IDC_JUMP_PLAYBACK_BUTTON, 0, 0, 0, 0, "Click here to scroll the Piano Roll to Playback cursor", "", false, 0, 0, IDC_PLAYBACK_MARKER_EDIT, 0, 0, -1, 0, "Click to edit text", "", false, 0, 0, IDC_PLAYBACK_MARKER, 0, 0, 0, 0, "", "", false, 0, 0, - IDC_JUMP_SELECTION_BUTTON, 0, -1, 0, -1, "Click here to scroll the List to Selection", "", false, 0, 0, + IDC_JUMP_SELECTION_BUTTON, 0, -1, 0, -1, "Click here to scroll the Piano Roll to Selection", "", false, 0, 0, IDC_SELECTION_MARKER_EDIT, 0, -1, -1, -1, "Click to edit text", "", false, 0, 0, IDC_SELECTION_MARKER, 0, -1, 0, -1, "", "", false, 0, 0, IDC_BRANCHES_BITMAP, -1, 0, 0, 0, "This window visualizes the hierarchy of your Branches", "", false, 0, 0, @@ -673,12 +673,6 @@ BOOL CALLBACK WndprocTasEditor(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP case LVN_GETDISPINFO: list.GetDispInfo((NMLVDISPINFO*)lParam); break; - case NM_CLICK: - list.SingleClick((LPNMITEMACTIVATE)lParam); - break; - case NM_DBLCLK: - list.DoubleClick((LPNMITEMACTIVATE)lParam); - break; case LVN_ITEMCHANGED: selection.ItemChanged((LPNMLISTVIEW) lParam); break;