Taseditor: straighten out pause_frame logic; fixed AdjustLag

This commit is contained in:
ansstuff 2012-07-26 13:34:03 +00:00
parent 1b5c7797c4
commit 5cf9eebd58
5 changed files with 21 additions and 24 deletions

View File

@ -1,5 +1,6 @@
25-Jul-2012 - AnS - Taseditor: auto-starting Note editing when creating Marker by double-click
19-Jul-2012 - AnS - Taseditor: Lua registermanual allows changing the "Run function" button caption; Markers are always restored when deploying Bookmarks 19-Jul-2012 - AnS - Taseditor: Lua registermanual allows changing the "Run function" button caption; Markers are always restored when deploying Bookmarks
01-Jul-2012 - AnS - new hotkey "Run Manual Lua function" 01-Jul-2012 - AnS - new hotkey "Run Manual Lua function"
24-Jun-2012 - AnS - Taseditor: drawing selected_slot border in Branches Tree 24-Jun-2012 - AnS - Taseditor: drawing selected_slot border in Branches Tree

View File

@ -98,20 +98,26 @@ void GREENZONE::CollectCurrentState()
lag_history.erase(lag_history.begin() + (currFrameCounter - 1)); lag_history.erase(lag_history.begin() + (currFrameCounter - 1));
editor.AdjustUp(currFrameCounter - 1); editor.AdjustUp(currFrameCounter - 1);
// since AdjustUp didn't restore Playback cursor, we must rewind here // since AdjustUp didn't restore Playback cursor, we must rewind here
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
int saved_pause_frame = playback.GetPauseFrame(); int saved_pause_frame = playback.GetPauseFrame();
playback.jump(currFrameCounter - 1); // rewind playback.jump(currFrameCounter - 1); // rewind
if (saved_pause_frame >= 0) if (saved_pause_frame >= 0)
playback.SeekingStart(saved_pause_frame); playback.SeekingStart(saved_pause_frame);
if (emu_was_paused)
playback.PauseEmulation();
} else if (!old_lagFlag && lagFlag) } else if (!old_lagFlag && lagFlag)
{ {
// there's new lag on previous frame - shift Input down // there's new lag on previous frame - shift Input down
lag_history.insert(lag_history.begin() + (currFrameCounter - 1), 1); lag_history.insert(lag_history.begin() + (currFrameCounter - 1), 1);
editor.AdjustDown(currFrameCounter - 1); editor.AdjustDown(currFrameCounter - 1);
// since AdjustDown didn't restore Playback cursor, we must rewind here // since AdjustDown didn't restore Playback cursor, we must rewind here
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
int saved_pause_frame = playback.GetPauseFrame(); int saved_pause_frame = playback.GetPauseFrame();
playback.jump(currFrameCounter - 1); // rewind playback.jump(currFrameCounter - 1); // rewind
if (saved_pause_frame >= 0) if (saved_pause_frame >= 0)
playback.SeekingStart(saved_pause_frame); playback.SeekingStart(saved_pause_frame);
if (emu_was_paused)
playback.PauseEmulation();
} }
} else } else
{ {
@ -443,9 +449,9 @@ void GREENZONE::InvalidateAndCheck(int after)
// either set Playback cursor to the end of Greenzone or run seeking to restore Playback cursor position // either set Playback cursor to the end of Greenzone or run seeking to restore Playback cursor position
if (currFrameCounter >= greenZoneCount) if (currFrameCounter >= greenZoneCount)
{ {
if (playback.GetFixedPauseFrame()) if (playback.GetPauseFrame() >= 0 && !FCEUI_EmulationPaused())
{ {
// continue seeking // emulator was running, so continue seeking
playback.jump(playback.GetPauseFrame()); playback.jump(playback.GetPauseFrame());
} else } else
{ {

View File

@ -1132,11 +1132,15 @@ void PIANO_ROLL::FinishDrag()
if (row_under_mouse == marker_drag_framenum) if (row_under_mouse == marker_drag_framenum)
{ {
// it was just double-click and release // it was just double-click and release
// set focus to lower Note edit field // if Selection points at dragged Marker, set focus to lower Note edit field
int dragged_marker_id = markers_manager.GetMarker(marker_drag_framenum); int dragged_marker_id = markers_manager.GetMarker(marker_drag_framenum);
int selection_marker_id = markers_manager.GetMarkerUp(selection.GetCurrentSelectionBeginning()); int selection_marker_id = markers_manager.GetMarkerUp(selection.GetCurrentSelectionBeginning());
if (dragged_marker_id == selection_marker_id) if (dragged_marker_id == selection_marker_id)
{
SetFocus(selection.hwndSelectionMarkerEdit); SetFocus(selection.hwndSelectionMarkerEdit);
// select all text in case user wants to overwrite it
SendMessage(selection.hwndSelectionMarkerEdit, EM_SETSEL, 0, -1);
}
} else if (markers_manager.GetMarker(row_under_mouse)) } else if (markers_manager.GetMarker(row_under_mouse))
{ {
int dragged_marker_id = markers_manager.GetMarker(marker_drag_framenum); int dragged_marker_id = markers_manager.GetMarker(marker_drag_framenum);

View File

@ -73,7 +73,7 @@ void PLAYBACK::reset()
shown_marker = 0; shown_marker = 0;
lastCursor = currFrameCounter; lastCursor = currFrameCounter;
lost_position_frame = pause_frame = old_pauseframe = 0; lost_position_frame = pause_frame = old_pauseframe = 0;
lost_position_must_be_fixed = pause_frame_must_be_fixed = old_show_pauseframe = show_pauseframe = false; lost_position_is_stable = old_show_pauseframe = show_pauseframe = false;
old_rewind_button_state = rewind_button_state = false; old_rewind_button_state = rewind_button_state = false;
old_forward_button_state = forward_button_state = false; old_forward_button_state = forward_button_state = false;
old_rewind_full_button_state = rewind_full_button_state = false; old_rewind_full_button_state = rewind_full_button_state = false;
@ -228,12 +228,9 @@ void PLAYBACK::update()
} }
// This logic is very important for adequate "green arrow" and "Restore position" // This logic is very important for adequate "green arrow" and "Restore position"
if (emu_paused) if (!emu_paused)
// when paused, pause_frame becomes unfixed // when emulating, lost_position_frame becomes unstable
pause_frame_must_be_fixed = false; lost_position_is_stable = false;
else
// when emulating, lost_position_frame becomes unfixed
lost_position_must_be_fixed = false;
} }
void PLAYBACK::updateProgressbar() void PLAYBACK::updateProgressbar()
@ -330,7 +327,6 @@ void PLAYBACK::SeekingStart(int finish_frame)
seeking_start_frame = currFrameCounter; seeking_start_frame = currFrameCounter;
pause_frame = finish_frame + 1; pause_frame = finish_frame + 1;
} }
pause_frame_must_be_fixed = true;
if (taseditor_config.turbo_seek) if (taseditor_config.turbo_seek)
turbo = true; turbo = true;
UnpauseEmulation(); UnpauseEmulation();
@ -338,7 +334,6 @@ void PLAYBACK::SeekingStart(int finish_frame)
void PLAYBACK::SeekingStop() void PLAYBACK::SeekingStop()
{ {
pause_frame = 0; pause_frame = 0;
pause_frame_must_be_fixed = false;
turbo = false; turbo = false;
PauseEmulation(); PauseEmulation();
SetProgressbar(1, 1); SetProgressbar(1, 1);
@ -482,12 +477,12 @@ bool PLAYBACK::JumpToFrame(int index)
void PLAYBACK::SetLostPosition(int frame) void PLAYBACK::SetLostPosition(int frame)
{ {
if ((lost_position_frame - 1 < frame) || (lost_position_frame - 1 > frame && !lost_position_must_be_fixed)) if ((lost_position_frame - 1 < frame) || (lost_position_frame - 1 > frame && !lost_position_is_stable))
{ {
if (lost_position_frame) if (lost_position_frame)
piano_roll.RedrawRow(lost_position_frame - 1); piano_roll.RedrawRow(lost_position_frame - 1);
lost_position_frame = frame + 1; lost_position_frame = frame + 1;
lost_position_must_be_fixed = true; lost_position_is_stable = true;
} }
} }
int PLAYBACK::GetLostPosition() int PLAYBACK::GetLostPosition()
@ -506,13 +501,6 @@ int PLAYBACK::GetFlashingPauseFrame()
else else
return 0; return 0;
} }
int PLAYBACK::GetFixedPauseFrame()
{
if (pause_frame_must_be_fixed)
return pause_frame;
else
return 0;
}
void PLAYBACK::SetProgressbar(int a, int b) void PLAYBACK::SetProgressbar(int a, int b)
{ {

View File

@ -44,7 +44,6 @@ public:
int GetPauseFrame(); int GetPauseFrame();
int GetFlashingPauseFrame(); int GetFlashingPauseFrame();
int GetFixedPauseFrame();
void SetProgressbar(int a, int b); void SetProgressbar(int a, int b);
void CancelSeeking(); void CancelSeeking();
@ -59,9 +58,8 @@ private:
bool JumpToFrame(int index); bool JumpToFrame(int index);
int pause_frame; int pause_frame;
bool pause_frame_must_be_fixed; // for "Auto-restore last position"
int lost_position_frame; int lost_position_frame;
bool lost_position_must_be_fixed; // for when Greenzone invalidates several times, but the end of current segment must remain the same bool lost_position_is_stable; // for when Greenzone invalidates several times, but the end of current segment must remain the same
bool autopause_at_the_end; bool autopause_at_the_end;
bool old_emu_paused, emu_paused; bool old_emu_paused, emu_paused;