* Taseditor: Fixed previous commit accuracy

* Better turbo off method in lua engine when quitting
This commit is contained in:
ansstuff 2012-02-25 20:54:13 +00:00
parent 704af09cc8
commit d659fab541
6 changed files with 41 additions and 45 deletions

View File

@ -700,13 +700,12 @@ LONG HISTORY::CustomDraw(NMLVCUSTOMDRAW* msg)
}
void HISTORY::Click(LPNMITEMACTIVATE info)
void HISTORY::Click(int row_index)
{
// jump to pointed snapshot
int item = info->iItem;
if (item >= 0)
if (row_index >= 0)
{
int result = jump(item);
int result = jump(row_index);
if (result >= 0)
{
piano_roll.update();
@ -758,6 +757,7 @@ int HISTORY::GetUndoHint()
// ---------------------------------------------------------------------------------
LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
extern HISTORY history;
switch(msg)
{
case WM_CHAR:
@ -765,6 +765,19 @@ LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
case WM_KEYUP:
case WM_KILLFOCUS:
return 0;
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
{
if (GetFocus() != hWnd)
SetFocus(hWnd);
// perform hit test
LVHITTESTINFO info;
info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam);
ListView_SubItemHitTest(hWnd, (LPARAM)&info);
history.Click(info.iItem);
return 0;
}
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
@ -773,6 +786,8 @@ LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
}
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
if (GetFocus() != hWnd)
SetFocus(hWnd);
return 0;
case WM_MOUSEWHEEL:
{
@ -781,6 +796,10 @@ LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
if (GET_KEYSTATE_WPARAM(wParam) & (MK_RBUTTON|MK_SHIFT|MK_CONTROL) || (GetKeyState(VK_MENU) < 0))
return SendMessage(piano_roll.hwndList, msg, wParam, lParam);
}
case WM_MOUSEACTIVATE:
if (GetFocus() != hWnd)
SetFocus(hWnd);
break;
}
return CallWindowProc(hwndHistoryList_oldWndProc, hWnd, msg, wParam, lParam);

View File

@ -86,7 +86,7 @@ public:
void GetDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG CustomDraw(NMLVCUSTOMDRAW* msg);
void Click(LPNMITEMACTIVATE info);
void Click(int row_index);
void RedrawHistoryList();
void UpdateHistoryList();

View File

@ -93,7 +93,7 @@ void PIANO_ROLL::init()
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);
ListView_SetExtendedListViewStyleEx(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
// subclass the header
hwndHeader = ListView_GetHeader(hwndList);
hwndHeader_oldWndproc = (WNDPROC)SetWindowLong(hwndHeader, GWL_WNDPROC, (LONG)HeaderWndProc);
@ -187,7 +187,6 @@ void PIANO_ROLL::init()
}
void PIANO_ROLL::free()
{
auto_mouseup_timer = 0;
if (hMainListFont)
{
DeleteObject(hMainListFont);
@ -222,7 +221,6 @@ void PIANO_ROLL::free()
}
void PIANO_ROLL::reset()
{
auto_mouseup_timer = 0;
next_header_update_time = header_item_under_mouse = 0;
// delete all columns except 0th
while (ListView_DeleteColumn(hwndList, 1)) {}
@ -1063,10 +1061,7 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
case WM_TIMER:
// very hacky way to force exit from modal message loop used by ListView's WM_LBUTTONDOWN handler
if (piano_roll.auto_mouseup_timer)
PostMessage(hWnd, WM_LBUTTONUP, 0, 0);
// also disable timer of entering edit mode (there's no edit mode anyway)
// disable timer of entering edit mode (there's no edit mode anyway)
return 0;
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
@ -1109,13 +1104,8 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
piano_roll.RedrawRow(row_index);
}
// also select the row by calling hwndList_oldWndProc
// WARNING: incredible hack incoming!
// This allows to intercept normal behaviour of ListView while still using it for setting selection
// very hacky way to force exit from modal message loop used by ListView's WM_LBUTTONDOWN handler
piano_roll.auto_mouseup_timer = SetTimer(0, 0, TIME_TO_GENERATE_AUTO_MOUSEUP, 0);
PostMessage(hWnd, WM_LBUTTONUP, 0, 0); // ensure that oldWndProc will exit its modal message loop immediately
CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam);
KillTimer(0, piano_roll.auto_mouseup_timer);
piano_roll.auto_mouseup_timer = 0;
}
} else if(column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R)
{
@ -1123,21 +1113,9 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// first call old wndproc to set selection on the row
if (alt_pressed)
wParam |= MK_SHIFT; // Alt should select region, just like Shift
// WARNING: incredible hack incoming!
// This allows to intercept normal behaviour of ListView while still using it for setting selection
if (msg == WM_LBUTTONDOWN)
{
// very hacky way to force exit from modal message loop used by ListView's WM_LBUTTONDOWN handler
piano_roll.auto_mouseup_timer = SetTimer(0, 0, TIME_TO_GENERATE_AUTO_MOUSEUP, 0);
CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam);
KillTimer(0, piano_roll.auto_mouseup_timer);
piano_roll.auto_mouseup_timer = 0;
// ehh... normally we should not even call oldWndProc with WM_LBUTTONDOWN, but we need it for setting selection
} else
{
// as for WM_LBUTTONDBLCLK, it won't freeze the window, so no need for hacks with SetTimer
CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam);
}
PostMessage(hWnd, WM_LBUTTONUP, 0, 0); // ensure that oldWndProc will exit its modal message loop immediately
CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam);
if (alt_pressed)
{
int joy = (column_index - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS;
@ -1199,10 +1177,9 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
case WM_RBUTTONDOWN:
if (GetFocus() != piano_roll.hwndList)
SetFocus(piano_roll.hwndList);
return 0;
case WM_RBUTTONDBLCLK:
if (GetFocus() != hWnd)
SetFocus(hWnd);
return 0;
case WM_RBUTTONUP:
{
@ -1211,11 +1188,16 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam);
ListView_SubItemHitTest(hWnd, (LPARAM)&info);
// show context menu
// show context menu if user right-clicked on Frame#
if(info.iSubItem <= COLUMN_FRAMENUM || info.iSubItem >= COLUMN_FRAMENUM2)
piano_roll.RightClick(info);
return 0;
}
case WM_MOUSEACTIVATE:
if (GetFocus() != hWnd)
SetFocus(hWnd);
break;
}
return CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam);
}

View File

@ -18,7 +18,6 @@
#define HEADER_DX_FIX 4
#define BOOST_WHEN_BOTH_RIGHTBUTTON_AND_ALT_PRESSED 2
#define TIME_TO_GENERATE_AUTO_MOUSEUP 20 // in milliseconds
enum
{
@ -163,9 +162,6 @@ public:
HFONT hMainListFont, hMainListSelectFont, hMarkersFont, hMarkersEditFont;
HBRUSH bg_brush;
// very hacky way to force exit from modal message loop used by ListView's WM_LBUTTONDOWN handler
UINT_PTR auto_mouseup_timer;
private:
void CenterListAt(int frame);

View File

@ -728,10 +728,6 @@ BOOL CALLBACK WndprocTasEditor(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
case LVN_GETDISPINFO:
history.GetDispInfo((NMLVDISPINFO*)lParam);
break;
case NM_CLICK:
case NM_DBLCLK:
history.Click((LPNMITEMACTIVATE)lParam);
break;
}
break;
case TASEDITOR_PLAYSTOP:

View File

@ -84,6 +84,8 @@ extern "C"
extern void AddRecentLuaFile(const char *filename);
#endif
extern bool turbo;
struct LuaSaveState {
std::string filename;
EMUFILE_MEMORY *data;
@ -238,7 +240,8 @@ static void FCEU_LuaOnStop() {
// FCEUI_ToggleEmulationPause();
FCEUD_SetEmulationSpeed(EMUSPEED_NORMAL); //TODO: Ideally lua returns the speed to the speed the user set before running the script
//rather than returning it to normal, and turbo off. Perhaps some flags and a FCEUD_GetEmulationSpeed function
FCEUD_TurboOff(); //Turn off turbo
turbo = false;
//FCEUD_TurboOff();
#ifdef WIN32
TaseditorUpdateManualFunctionStatus();
#endif