Taseditor: changed "lost_position" logic again

This commit is contained in:
ansstuff 2012-05-03 15:02:52 +00:00
parent 18b9dd1c59
commit 31e015bf95
4 changed files with 57 additions and 35 deletions

View File

@ -403,17 +403,26 @@ void GREENZONE::InvalidateAndCheck(int after)
if (currFrameCounter >= greenZoneCount) if (currFrameCounter >= greenZoneCount)
{ {
// remember the lost position // remember the lost position
if (playback.lost_position_frame && 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); piano_roll.RedrawRow(playback.lost_position_frame - 1);
playback.lost_position_frame = currFrameCounter + 1; playback.lost_position_frame = currFrameCounter + 1;
}
// auto-restore position if needed // auto-restore position if needed
if (taseditor_config.restore_position) if (taseditor_config.restore_position)
playback.RestorePosition(); {
if (playback.pause_frame)
playback.jump(playback.pause_frame - 1);
else else
playback.jump(currFrameCounter);
} else
{
playback.jump(greenZoneCount-1); playback.jump(greenZoneCount-1);
} }
} }
} }
}
// redraw Piano Roll even if greenzone didn't change // redraw Piano Roll even if greenzone didn't change
piano_roll.RedrawList(); piano_roll.RedrawList();
bookmarks.RedrawBookmarksList(); bookmarks.RedrawBookmarksList();

View File

@ -264,45 +264,58 @@ void PLAYBACK::UnpauseEmulation()
void PLAYBACK::RestorePosition() void PLAYBACK::RestorePosition()
{ {
if (pause_frame) if (pause_frame)
jump(pause_frame-1); {
else // continue seeking
jump(lost_position_frame-1); 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() void PLAYBACK::MiddleButtonClick()
{ {
if (emu_paused) 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(GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON) >= 0)
{ {
if (GetAsyncKeyState(VK_SHIFT) < 0) if (GetAsyncKeyState(VK_SHIFT) < 0)
{ {
// if Shift is held, set pause_frame to nearest Marker // if Shift is held, seek to nearest Marker
int last_frame = markers_manager.GetMarkersSize() - 1; int last_frame = markers_manager.GetMarkersSize() - 1; // the end of movie Markers
int target_frame = currFrameCounter + 1; int target_frame = currFrameCounter + 1;
for (; target_frame <= last_frame; ++target_frame) for (; target_frame <= last_frame; ++target_frame)
if (markers_manager.GetMarker(target_frame)) break; if (markers_manager.GetMarker(target_frame)) break;
if (target_frame <= last_frame) if (target_frame <= last_frame)
{ {
// start seeking to the Marker
seeking_start_frame = currFrameCounter; 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) } 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(); int selection_beginning = selection.GetCurrentSelectionBeginning();
if (selection_beginning > currFrameCounter) if (selection_beginning > currFrameCounter)
{ {
// start seeking to selection_beginning
seeking_start_frame = currFrameCounter; seeking_start_frame = currFrameCounter;
pause_frame = selection_beginning + 1; pause_frame = selection_beginning + 1;
if (taseditor_config.turbo_seek)
turbo = true;
} }
} }
if (!pause_frame && lost_position_frame) UnpauseEmulation(); // in case RestorePosition doesn't unpause it
{ RestorePosition();
seeking_start_frame = currFrameCounter;
pause_frame = lost_position_frame;
}
UnpauseEmulation();
} }
} else } else
{ {
@ -371,7 +384,7 @@ void PLAYBACK::RewindFull(int speed)
} }
void PLAYBACK::ForwardFull(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; int index = currFrameCounter + 1;
// jump trough "speed" amount of next markers // jump trough "speed" amount of next markers
while (speed > 0) while (speed > 0)
@ -479,16 +492,16 @@ void PLAYBACK::SetProgressbar(int a, int b)
} }
void PLAYBACK::CancelSeeking() 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) if (pause_frame)
{
SeekingStop(); 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) LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)

View File

@ -218,7 +218,7 @@ void SELECTION::JumpNextMarker(int speed)
// if nothing is selected, consider playback cursor as current selection // if nothing is selected, consider playback cursor as current selection
int index = GetCurrentSelectionBeginning(); int index = GetCurrentSelectionBeginning();
if (index < 0) index = currFrameCounter; 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 // jump trough "speed" amount of previous markers
while (speed > 0) while (speed > 0)
{ {
@ -229,7 +229,7 @@ void SELECTION::JumpNextMarker(int speed)
if (index <= last_frame) if (index <= last_frame)
JumpToFrame(index); // jump to Marker JumpToFrame(index); // jump to Marker
else 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) void SELECTION::JumpToFrame(int frame)
{ {

View File

@ -60,7 +60,7 @@ void TASEDITOR_PROJECT::reset()
void TASEDITOR_PROJECT::update() void TASEDITOR_PROJECT::update()
{ {
// if it's time to autosave - pop Save As dialog // 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) if (taseditor_config.silent_autosave)
SaveProject(); SaveProject();