From 31e015bf95230c9fc9be6fe37544a35b4f7be2b8 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Thu, 3 May 2012 15:02:52 +0000 Subject: [PATCH] Taseditor: changed "lost_position" logic again --- src/drivers/win/taseditor/greenzone.cpp | 19 ++++-- src/drivers/win/taseditor/playback.cpp | 65 +++++++++++-------- src/drivers/win/taseditor/selection.cpp | 6 +- .../win/taseditor/taseditor_project.cpp | 2 +- 4 files changed, 57 insertions(+), 35 deletions(-) diff --git a/src/drivers/win/taseditor/greenzone.cpp b/src/drivers/win/taseditor/greenzone.cpp index 9d79d71e..55e915ce 100644 --- a/src/drivers/win/taseditor/greenzone.cpp +++ b/src/drivers/win/taseditor/greenzone.cpp @@ -403,14 +403,23 @@ void GREENZONE::InvalidateAndCheck(int after) if (currFrameCounter >= greenZoneCount) { // remember the lost position - if (playback.lost_position_frame && playback.lost_position_frame != currFrameCounter + 1) - piano_roll.RedrawRow(playback.lost_position_frame - 1); - playback.lost_position_frame = currFrameCounter + 1; + if (playback.lost_position_frame < currFrameCounter + 1) + { + if (playback.lost_position_frame) + piano_roll.RedrawRow(playback.lost_position_frame - 1); + playback.lost_position_frame = currFrameCounter + 1; + } // auto-restore position if needed if (taseditor_config.restore_position) - playback.RestorePosition(); - else + { + if (playback.pause_frame) + playback.jump(playback.pause_frame - 1); + else + playback.jump(currFrameCounter); + } else + { playback.jump(greenZoneCount-1); + } } } } diff --git a/src/drivers/win/taseditor/playback.cpp b/src/drivers/win/taseditor/playback.cpp index 8ce59f3e..2bdfe06a 100644 --- a/src/drivers/win/taseditor/playback.cpp +++ b/src/drivers/win/taseditor/playback.cpp @@ -264,45 +264,58 @@ void PLAYBACK::UnpauseEmulation() void PLAYBACK::RestorePosition() { if (pause_frame) - jump(pause_frame-1); - else - jump(lost_position_frame-1); + { + // continue seeking + if (taseditor_config.turbo_seek) + turbo = true; + UnpauseEmulation(); + } else if (lost_position_frame && lost_position_frame > currFrameCounter + 1) + { + // start seeking from here to lost_position_frame + pause_frame = lost_position_frame; + seeking_start_frame = currFrameCounter; + if (taseditor_config.turbo_seek) + turbo = true; + UnpauseEmulation(); + } } void PLAYBACK::MiddleButtonClick() { if (emu_paused) { - // check if right mouse button is released + // if right mouse button is released, either just unpause or start seeking if (GetAsyncKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON) >= 0) { if (GetAsyncKeyState(VK_SHIFT) < 0) { - // if Shift is held, set pause_frame to nearest Marker - int last_frame = markers_manager.GetMarkersSize() - 1; + // if Shift is held, seek to nearest Marker + int last_frame = markers_manager.GetMarkersSize() - 1; // the end of movie Markers int target_frame = currFrameCounter + 1; for (; target_frame <= last_frame; ++target_frame) if (markers_manager.GetMarker(target_frame)) break; if (target_frame <= last_frame) { + // start seeking to the Marker seeking_start_frame = currFrameCounter; - pause_frame = target_frame + 1; // stop at the Marker + pause_frame = target_frame + 1; + if (taseditor_config.turbo_seek) + turbo = true; } } else if (GetAsyncKeyState(VK_CONTROL) < 0) { - // if Ctrl is held, set pause_frame to Selection cursor + // if Ctrl is held, seek to Selection cursor int selection_beginning = selection.GetCurrentSelectionBeginning(); if (selection_beginning > currFrameCounter) { + // start seeking to selection_beginning seeking_start_frame = currFrameCounter; pause_frame = selection_beginning + 1; + if (taseditor_config.turbo_seek) + turbo = true; } } - if (!pause_frame && lost_position_frame) - { - seeking_start_frame = currFrameCounter; - pause_frame = lost_position_frame; - } - UnpauseEmulation(); + UnpauseEmulation(); // in case RestorePosition doesn't unpause it + RestorePosition(); } } else { @@ -371,7 +384,7 @@ void PLAYBACK::RewindFull(int speed) } void PLAYBACK::ForwardFull(int speed) { - int last_frame = markers_manager.GetMarkersSize() - 1; + int last_frame = markers_manager.GetMarkersSize() - 1; // the end of movie Markers int index = currFrameCounter + 1; // jump trough "speed" amount of next markers while (speed > 0) @@ -436,7 +449,7 @@ bool PLAYBACK::JumpToFrame(int index) if (index >= greenzone.greenZoneCount) { // handle jump outside greenzone - if (currFrameCounter == greenzone.greenZoneCount-1 || JumpToFrame(greenzone.greenZoneCount-1)) + if (currFrameCounter == greenzone.greenZoneCount - 1 || JumpToFrame(greenzone.greenZoneCount - 1)) // seek from the end of greenzone SeekingStart(index+1); return false; @@ -450,7 +463,7 @@ bool PLAYBACK::JumpToFrame(int index) return true; } // search for an earlier frame with savestate - int i = (index>0)? index-1 : 0; + int i = (index > 0)? index-1 : 0; for (; i > 0; i--) { if (greenzone.loadTasSavestate(i)) break; @@ -461,7 +474,7 @@ bool PLAYBACK::JumpToFrame(int index) currFrameCounter = i; // continue from the frame if (index != currFrameCounter) - SeekingStart(index+1); + SeekingStart(index + 1); return true; } @@ -479,16 +492,16 @@ void PLAYBACK::SetProgressbar(int a, int b) } void PLAYBACK::CancelSeeking() { - // delete lost_position pointer (green arrow) - if (lost_position_frame) - { - int temp = lost_position_frame - 1; - lost_position_frame = 0; - piano_roll.RedrawRow(temp); - } - // and stop seeking if (pause_frame) + { SeekingStop(); + // also invalidate lost_position_frame if user cancelled seeking to it + if (lost_position_frame == pause_frame) + { + piano_roll.RedrawRow(lost_position_frame - 1); + lost_position_frame = 0; + } + } } // ------------------------------------------------------------------------- LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) diff --git a/src/drivers/win/taseditor/selection.cpp b/src/drivers/win/taseditor/selection.cpp index 11f3dcff..629bc443 100644 --- a/src/drivers/win/taseditor/selection.cpp +++ b/src/drivers/win/taseditor/selection.cpp @@ -218,7 +218,7 @@ void SELECTION::JumpNextMarker(int speed) // if nothing is selected, consider playback cursor as current selection int index = GetCurrentSelectionBeginning(); if (index < 0) index = currFrameCounter; - int last_frame = markers_manager.GetMarkersSize() - 1; + int last_frame = currMovieData.getNumRecords() - 1; // the end of Piano Roll // jump trough "speed" amount of previous markers while (speed > 0) { @@ -227,9 +227,9 @@ void SELECTION::JumpNextMarker(int speed) speed--; } if (index <= last_frame) - JumpToFrame(index); // jump to Marker + JumpToFrame(index); // jump to Marker else - JumpToFrame(currMovieData.getNumRecords() - 1); // jump to the end of Piano Roll + JumpToFrame(last_frame); // jump to the end of Piano Roll } void SELECTION::JumpToFrame(int frame) { diff --git a/src/drivers/win/taseditor/taseditor_project.cpp b/src/drivers/win/taseditor/taseditor_project.cpp index 01b767f7..f913fea8 100644 --- a/src/drivers/win/taseditor/taseditor_project.cpp +++ b/src/drivers/win/taseditor/taseditor_project.cpp @@ -60,7 +60,7 @@ void TASEDITOR_PROJECT::reset() void TASEDITOR_PROJECT::update() { // if it's time to autosave - pop Save As dialog - if (changed && taseditor_config.autosave_period && clock() >= next_save_shedule && piano_roll.drag_mode == DRAG_MODE_NONE) + if (changed && taseditor_window.TASEditor_focus && taseditor_config.autosave_period && clock() >= next_save_shedule && piano_roll.drag_mode == DRAG_MODE_NONE) { if (taseditor_config.silent_autosave) SaveProject();