* Tasedit: more refactoring
* Tasedit: "<<" and ">>" buttons now jump from one Marker to another * Tasedit: clever FollowSelection
This commit is contained in:
parent
07dde626de
commit
0e48de6f98
|
@ -62,7 +62,7 @@ HWND hwndHistoryList;
|
|||
WNDPROC hwndHistoryList_oldWndProc;
|
||||
HWND hwndBookmarksList, hwndBookmarks;
|
||||
WNDPROC hwndBookmarksList_oldWndProc;
|
||||
HWND hwndProgressbar, hwndRewind, hwndForward;
|
||||
HWND hwndProgressbar, hwndRewind, hwndForward, hwndRewindFull, hwndForwardFull;
|
||||
HWND hwndRB_RecOff, hwndRB_RecAll, hwndRB_Rec1P, hwndRB_Rec2P, hwndRB_Rec3P, hwndRB_Rec4P;
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ TASEDIT_PROJECT project;
|
|||
INPUT_HISTORY history;
|
||||
PLAYBACK playback;
|
||||
GREENZONE greenzone;
|
||||
|
||||
MARKERS markers;
|
||||
|
||||
void GetDispInfo(NMLVDISPINFO* nmlvDispInfo)
|
||||
{
|
||||
|
@ -162,18 +162,18 @@ LONG CustomDraw(NMLVCUSTOMDRAW* msg)
|
|||
} else if (cell_y == currFrameCounter || cell_y == playback.GetPauseFrame())
|
||||
{
|
||||
// current frame
|
||||
if(TASEdit_show_markers && currMovieData.frames_flags[cell_y] & MARKER_FLAG_BIT)
|
||||
if(TASEdit_show_markers && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
|
||||
// this frame is also marked
|
||||
msg->clrTextBk = CUR_MARKED_FRAMENUM_COLOR;
|
||||
else
|
||||
msg->clrTextBk = CUR_FRAMENUM_COLOR;
|
||||
} else if(TASEdit_show_markers && currMovieData.frames_flags[cell_y] & MARKER_FLAG_BIT)
|
||||
} else if(TASEdit_show_markers && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
|
||||
{
|
||||
// marked frame
|
||||
msg->clrTextBk = MARKED_FRAMENUM_COLOR;
|
||||
} else if(cell_y < greenzone.greenZoneCount && !greenzone.savestates[cell_y].empty())
|
||||
{
|
||||
if (TASEdit_show_lag_frames && (currMovieData.frames_flags[cell_y] & LAG_FLAG_BIT))
|
||||
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
|
||||
{
|
||||
// lag frame
|
||||
msg->clrTextBk = LAG_FRAMENUM_COLOR;
|
||||
|
@ -196,7 +196,7 @@ LONG CustomDraw(NMLVCUSTOMDRAW* msg)
|
|||
msg->clrTextBk = CUR_INPUT_COLOR1;
|
||||
} else if(cell_y < greenzone.greenZoneCount && !greenzone.savestates[cell_y].empty())
|
||||
{
|
||||
if (TASEdit_show_lag_frames && (currMovieData.frames_flags[cell_y] & LAG_FLAG_BIT))
|
||||
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
|
||||
{
|
||||
// lag frame
|
||||
msg->clrTextBk = LAG_INPUT_COLOR1;
|
||||
|
@ -219,7 +219,7 @@ LONG CustomDraw(NMLVCUSTOMDRAW* msg)
|
|||
msg->clrTextBk = CUR_INPUT_COLOR2;
|
||||
} else if(cell_y < greenzone.greenZoneCount && !greenzone.savestates[cell_y].empty())
|
||||
{
|
||||
if (TASEdit_show_lag_frames && (currMovieData.frames_flags[cell_y] & LAG_FLAG_BIT))
|
||||
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
|
||||
{
|
||||
// lag frame
|
||||
msg->clrTextBk = LAG_INPUT_COLOR2;
|
||||
|
@ -288,6 +288,8 @@ void UpdateList()
|
|||
}
|
||||
}
|
||||
}
|
||||
// also update number of items in markers array
|
||||
markers.update();
|
||||
}
|
||||
|
||||
void RedrawWindowCaption()
|
||||
|
@ -426,13 +428,10 @@ void SingleClick(LPNMITEMACTIVATE info)
|
|||
if (info->uKeyFlags & LVKF_ALT)
|
||||
{
|
||||
// reverse MARKER_FLAG_BIT in pointed frame
|
||||
if (currMovieData.frames_flags[row_index] & MARKER_FLAG_BIT)
|
||||
currMovieData.frames_flags[row_index] &= ~MARKER_FLAG_BIT;
|
||||
else
|
||||
currMovieData.frames_flags[row_index] |= MARKER_FLAG_BIT;
|
||||
markers.ToggleMarker(row_index);
|
||||
MarkersChanged();
|
||||
ListView_SetItemState(hwndList,row_index,0,LVIS_SELECTED);
|
||||
//RedrawList();
|
||||
// deselect this row, so that new marker will be seen immediately
|
||||
ListView_SetItemState(hwndList, row_index, 0, LVIS_SELECTED);
|
||||
}
|
||||
}
|
||||
else if(column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R)
|
||||
|
@ -464,7 +463,6 @@ void CloneFrames()
|
|||
int frames = selectionFrames.size();
|
||||
|
||||
currMovieData.records.reserve(currMovieData.getNumRecords() + frames);
|
||||
currMovieData.frames_flags.reserve(currMovieData.getNumRecords() + frames);
|
||||
|
||||
//insert frames before each selection, but consecutive selection lines are accounted as single region
|
||||
frames = 1;
|
||||
|
@ -476,7 +474,9 @@ void CloneFrames()
|
|||
if (next_it == selectionFrames.rend() || (int)*next_it < ((int)*it - 1))
|
||||
{
|
||||
// end of current region
|
||||
currMovieData.cloneRegion(*it,frames);
|
||||
currMovieData.cloneRegion(*it, frames);
|
||||
if (TASEdit_bind_markers)
|
||||
markers.insertEmpty(*it, frames);
|
||||
frames = 1;
|
||||
} else frames++;
|
||||
}
|
||||
|
@ -488,11 +488,8 @@ void InsertFrames()
|
|||
{
|
||||
int frames = selectionFrames.size();
|
||||
|
||||
//this is going to be slow.
|
||||
|
||||
//to keep this from being even slower than it would otherwise be, go ahead and reserve records
|
||||
currMovieData.records.reserve(currMovieData.getNumRecords() + frames);
|
||||
currMovieData.frames_flags.reserve(currMovieData.getNumRecords() + frames);
|
||||
|
||||
//insert frames before each selection, but consecutive selection lines are accounted as single region
|
||||
frames = 1;
|
||||
|
@ -505,6 +502,8 @@ void InsertFrames()
|
|||
{
|
||||
// end of current region
|
||||
currMovieData.insertEmpty(*it,frames);
|
||||
if (TASEdit_bind_markers)
|
||||
markers.insertEmpty(*it,frames);
|
||||
frames = 1;
|
||||
} else frames++;
|
||||
}
|
||||
|
@ -521,7 +520,7 @@ void DeleteFrames()
|
|||
{
|
||||
currMovieData.records.erase(currMovieData.records.begin() + *it);
|
||||
if (TASEdit_bind_markers)
|
||||
currMovieData.frames_flags.erase(currMovieData.frames_flags.begin() + *it);
|
||||
markers.markers_array.erase(markers.markers_array.begin() + *it);
|
||||
}
|
||||
// check if user deleted all frames
|
||||
if (!currMovieData.getNumRecords())
|
||||
|
@ -529,7 +528,14 @@ void DeleteFrames()
|
|||
// reduce list
|
||||
UpdateList();
|
||||
|
||||
greenzone.InvalidateGreenZone(history.RegisterInputChanges(MODTYPE_DELETE, start_index));
|
||||
int result = history.RegisterInputChanges(MODTYPE_DELETE, start_index);
|
||||
if (result >= 0)
|
||||
{
|
||||
greenzone.InvalidateGreenZone(result);
|
||||
} else if (greenzone.greenZoneCount >= currMovieData.getNumRecords())
|
||||
{
|
||||
greenzone.InvalidateGreenZone(currMovieData.getNumRecords()-1);
|
||||
} else RedrawList();
|
||||
}
|
||||
|
||||
void ClearFrames(bool cut)
|
||||
|
@ -557,7 +563,14 @@ void Truncate()
|
|||
{
|
||||
currMovieData.truncateAt(frame+1);
|
||||
UpdateList();
|
||||
greenzone.InvalidateGreenZone(history.RegisterInputChanges(MODTYPE_TRUNCATE, frame+1));
|
||||
int result = history.RegisterInputChanges(MODTYPE_TRUNCATE, frame+1);
|
||||
if (result >= 0)
|
||||
{
|
||||
greenzone.InvalidateGreenZone(result);
|
||||
} else if (greenzone.greenZoneCount >= currMovieData.getNumRecords())
|
||||
{
|
||||
greenzone.InvalidateGreenZone(currMovieData.getNumRecords()-1);
|
||||
} else RedrawList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +584,7 @@ void ColumnSet(int column)
|
|||
bool unset_found = false;
|
||||
for(TSelectionFrames::iterator it(selectionFrames.begin()); it != selectionFrames.end(); it++)
|
||||
{
|
||||
if(!(currMovieData.frames_flags[*it] & MARKER_FLAG_BIT))
|
||||
if(!(markers.markers_array[*it] & MARKER_FLAG_BIT))
|
||||
{
|
||||
unset_found = true;
|
||||
break;
|
||||
|
@ -581,12 +594,12 @@ void ColumnSet(int column)
|
|||
{
|
||||
// set all
|
||||
for(TSelectionFrames::iterator it(selectionFrames.begin()); it != selectionFrames.end(); it++)
|
||||
currMovieData.frames_flags[*it] |= MARKER_FLAG_BIT;
|
||||
markers.markers_array[*it] |= MARKER_FLAG_BIT;
|
||||
} else
|
||||
{
|
||||
// unset all
|
||||
for(TSelectionFrames::iterator it(selectionFrames.begin()); it != selectionFrames.end(); it++)
|
||||
currMovieData.frames_flags[*it] &= ~MARKER_FLAG_BIT;
|
||||
markers.markers_array[*it] &= ~MARKER_FLAG_BIT;
|
||||
}
|
||||
MarkersChanged();
|
||||
ClearSelection();
|
||||
|
@ -647,10 +660,10 @@ void SelectMidMarkers()
|
|||
// find markers
|
||||
// searching up starting from center-0
|
||||
for (upper_marker = center; upper_marker >= 0; upper_marker--)
|
||||
if (currMovieData.frames_flags[upper_marker] & MARKER_FLAG_BIT) break;
|
||||
if (markers.markers_array[upper_marker] & MARKER_FLAG_BIT) break;
|
||||
// searching down starting from center+1
|
||||
for (lower_marker = center+1; lower_marker < movie_size; ++lower_marker)
|
||||
if (currMovieData.frames_flags[lower_marker] & MARKER_FLAG_BIT) break;
|
||||
if (markers.markers_array[lower_marker] & MARKER_FLAG_BIT) break;
|
||||
|
||||
if (upper_marker == -1 && lower_marker == movie_size)
|
||||
{
|
||||
|
@ -1230,6 +1243,8 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
SendMessage(hwndProgressbar, PBM_SETRANGE, 0, MAKELPARAM(0, PROGRESSBAR_WIDTH));
|
||||
hwndRewind = GetDlgItem(hwndDlg, TASEDIT_REWIND);
|
||||
hwndForward = GetDlgItem(hwndDlg, TASEDIT_FORWARD);
|
||||
hwndRewindFull = GetDlgItem(hwndDlg, TASEDIT_REWIND_FULL);
|
||||
hwndForwardFull = GetDlgItem(hwndDlg, TASEDIT_FORWARD_FULL);
|
||||
hwndRB_RecOff = GetDlgItem(hwndDlg, IDC_RADIO1);
|
||||
hwndRB_RecAll = GetDlgItem(hwndDlg, IDC_RADIO2);
|
||||
hwndRB_Rec1P = GetDlgItem(hwndDlg, IDC_RADIO3);
|
||||
|
@ -1399,12 +1414,16 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
{
|
||||
// insert at selection
|
||||
int index = *selectionFrames.begin();
|
||||
currMovieData.insertEmpty(index,frames);
|
||||
currMovieData.insertEmpty(index, frames);
|
||||
if (TASEdit_bind_markers)
|
||||
markers.insertEmpty(index, frames);
|
||||
greenzone.InvalidateGreenZone(history.RegisterInputChanges(MODTYPE_INSERT, index));
|
||||
} else
|
||||
{
|
||||
// insert at playback cursor
|
||||
currMovieData.insertEmpty(currFrameCounter,frames);
|
||||
currMovieData.insertEmpty(currFrameCounter, frames);
|
||||
if (TASEdit_bind_markers)
|
||||
markers.insertEmpty(currFrameCounter, frames);
|
||||
greenzone.InvalidateGreenZone(history.RegisterInputChanges(MODTYPE_INSERT, currFrameCounter));
|
||||
}
|
||||
}
|
||||
|
@ -1421,15 +1440,9 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
case ID_CONTEXT_SELECTED_CLEARFRAMES:
|
||||
if (selectionFrames.size()) ClearFrames();
|
||||
break;
|
||||
case TASEDIT_REWIND_FULL:
|
||||
playback.RewindFull();
|
||||
break;
|
||||
case TASEDIT_PLAYSTOP:
|
||||
playback.ToggleEmulationPause();
|
||||
break;
|
||||
case TASEDIT_FORWARD_FULL:
|
||||
playback.ForwardFull();
|
||||
break;
|
||||
case ACCEL_CTRL_F:
|
||||
case CHECK_FOLLOW_CURSOR:
|
||||
//switch "Follow playback" flag
|
||||
|
@ -1439,7 +1452,7 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
if (TASEdit_follow_playback)
|
||||
FollowPlayback();
|
||||
else if (selectionFrames.size())
|
||||
ListView_EnsureVisible(hwndList,(int)*selectionFrames.begin(),FALSE);
|
||||
FollowSelection();
|
||||
break;
|
||||
case ID_VIEW_SHOW_LAG_FRAMES:
|
||||
//switch "Highlight lag frames" flag
|
||||
|
@ -1619,6 +1632,43 @@ void FollowUndo()
|
|||
}
|
||||
}
|
||||
}
|
||||
void FollowSelection()
|
||||
{
|
||||
int list_items = listItems;
|
||||
if (currMovieData.fourscore) list_items--;
|
||||
int selection_start = *selectionFrames.begin();
|
||||
int selection_end = *selectionFrames.rbegin();
|
||||
int selection_items = 1 + selection_end - selection_start;
|
||||
|
||||
if (selection_items <= list_items)
|
||||
{
|
||||
// selected region can fit in screen
|
||||
int lower_border = (list_items - selection_items) / 2;
|
||||
int upper_border = (list_items - selection_items) - lower_border;
|
||||
int index = selection_end + lower_border;
|
||||
if (index >= currMovieData.getNumRecords())
|
||||
index = currMovieData.getNumRecords()-1;
|
||||
ListView_EnsureVisible(hwndList, index, false);
|
||||
index = selection_start - upper_border;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
ListView_EnsureVisible(hwndList, index, false);
|
||||
} else
|
||||
{
|
||||
// selected region is too big to fit in screen
|
||||
// just center at selection_start
|
||||
int lower_border = (list_items - 1) / 2;
|
||||
int upper_border = (list_items - 1) - lower_border;
|
||||
int index = selection_start + lower_border;
|
||||
if (index >= currMovieData.getNumRecords())
|
||||
index = currMovieData.getNumRecords()-1;
|
||||
ListView_EnsureVisible(hwndList, index, false);
|
||||
index = selection_start - upper_border;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
ListView_EnsureVisible(hwndList, index, false);
|
||||
}
|
||||
}
|
||||
|
||||
void EnterTasEdit()
|
||||
{
|
||||
|
@ -1661,7 +1711,6 @@ void EnterTasEdit()
|
|||
SetWindowPos(hwndTasEdit,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
|
||||
|
||||
playback.init();
|
||||
greenzone.init();
|
||||
// either start new movie or use current movie
|
||||
if (movieMode == MOVIEMODE_INACTIVE)
|
||||
{
|
||||
|
@ -1731,10 +1780,12 @@ void EnterTasEdit()
|
|||
ListView_InsertColumn(hwndHistoryList, 0, &lvc);
|
||||
|
||||
// init variables
|
||||
greenzone.init();
|
||||
greenzone.TryDumpIncremental(lagFlag != 0);
|
||||
markers.init();
|
||||
project.init();
|
||||
history.init(TasEdit_undo_levels);
|
||||
SetFocus(hwndHistoryList);
|
||||
greenzone.TryDumpIncremental(lagFlag != 0);
|
||||
FCEU_DispMessage("Tasedit engaged",0);
|
||||
}
|
||||
}
|
||||
|
@ -1757,6 +1808,7 @@ bool ExitTasEdit()
|
|||
KeyboardClearBackgroundAccessBit(KEYBACKACCESS_TASEDIT);
|
||||
JoystickClearBackgroundAccessBit(JOYBACKACCESS_TASEDIT);
|
||||
// release memory
|
||||
markers.free();
|
||||
greenzone.clearGreenzone();
|
||||
history.free();
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ void InputChangedRec();
|
|||
bool CheckItemVisible(int frame);
|
||||
void FollowPlayback();
|
||||
void FollowUndo();
|
||||
void FollowSelection();
|
||||
void ClearSelection();
|
||||
void ClearRowSelection(int index);
|
||||
void AddFourscore();
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
extern TASEDIT_PROJECT project;
|
||||
extern PLAYBACK playback;
|
||||
extern int TASEdit_greenzone_capacity;
|
||||
extern bool TASEdit_bind_markers;
|
||||
extern bool TASEdit_restore_position;
|
||||
|
||||
extern void FCEU_printf(char *format, ...);
|
||||
|
@ -24,11 +23,11 @@ void GREENZONE::init()
|
|||
{
|
||||
clearGreenzone();
|
||||
|
||||
currMovieData.frames_flags.resize(currMovieData.records.size());
|
||||
reset();
|
||||
}
|
||||
void GREENZONE::reset()
|
||||
{
|
||||
lag_history.resize(currMovieData.getNumRecords());
|
||||
|
||||
}
|
||||
void GREENZONE::update()
|
||||
|
@ -40,16 +39,16 @@ void GREENZONE::update()
|
|||
void GREENZONE::TryDumpIncremental(bool lagFlag)
|
||||
{
|
||||
// if movie length is less than currFrame, pad it with empty frames
|
||||
if((int)currMovieData.records.size() <= currFrameCounter)
|
||||
currMovieData.insertEmpty(-1, 1 + currFrameCounter - (int)currMovieData.records.size());
|
||||
if(currMovieData.getNumRecords() <= currFrameCounter)
|
||||
currMovieData.insertEmpty(-1, 1 + currFrameCounter - currMovieData.getNumRecords());
|
||||
|
||||
// update greenzone upper limit
|
||||
if (greenZoneCount <= currFrameCounter)
|
||||
greenZoneCount = currFrameCounter+1;
|
||||
if ((int)savestates.size() < greenZoneCount)
|
||||
savestates.resize(greenZoneCount);
|
||||
if ((int)currMovieData.frames_flags.size() < greenZoneCount)
|
||||
currMovieData.frames_flags.resize(greenZoneCount);
|
||||
if ((int)lag_history.size() < greenZoneCount)
|
||||
lag_history.resize(greenZoneCount);
|
||||
|
||||
// if frame changed - log savestate
|
||||
storeTasSavestate(currFrameCounter);
|
||||
|
@ -58,9 +57,9 @@ void GREENZONE::TryDumpIncremental(bool lagFlag)
|
|||
{
|
||||
// lagFlag indicates that lag was in previous frame
|
||||
if (lagFlag)
|
||||
currMovieData.frames_flags[currFrameCounter-1] |= LAG_FLAG_BIT;
|
||||
lag_history[currFrameCounter-1] = 1;
|
||||
else
|
||||
currMovieData.frames_flags[currFrameCounter-1] &= ~LAG_FLAG_BIT;
|
||||
lag_history[currFrameCounter-1] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +69,7 @@ void GREENZONE::TryDumpIncremental(bool lagFlag)
|
|||
|
||||
bool GREENZONE::loadTasSavestate(int frame)
|
||||
{
|
||||
if (frame < 0 || frame >= (int)currMovieData.records.size())
|
||||
if (frame < 0 || frame >= currMovieData.getNumRecords())
|
||||
return false;
|
||||
if ((int)savestates.size() <= frame || savestates[frame].empty())
|
||||
return false;
|
||||
|
@ -119,15 +118,14 @@ void GREENZONE::clearGreenzone()
|
|||
}
|
||||
savestates.resize(0);
|
||||
greenZoneCount = 0;
|
||||
currMovieData.frames_flags.resize(0);
|
||||
lag_history.resize(0);
|
||||
// reset lua_colorings
|
||||
// reset monitorings
|
||||
|
||||
}
|
||||
|
||||
int GREENZONE::dumpGreenzone(EMUFILE *os)
|
||||
void GREENZONE::save(EMUFILE *os)
|
||||
{
|
||||
int start = os->ftell();
|
||||
int frame, size;
|
||||
int last_tick = 0;
|
||||
// write size
|
||||
|
@ -144,8 +142,8 @@ int GREENZONE::dumpGreenzone(EMUFILE *os)
|
|||
}
|
||||
if (savestates[frame].empty()) continue;
|
||||
write32le(frame, os);
|
||||
// write frames_flags
|
||||
os->fwrite(&currMovieData.frames_flags[frame], 1);
|
||||
// write lag history
|
||||
write8le(lag_history[frame], os);
|
||||
// write lua_colorings
|
||||
// write monitorings
|
||||
// write savestate
|
||||
|
@ -156,19 +154,15 @@ int GREENZONE::dumpGreenzone(EMUFILE *os)
|
|||
}
|
||||
// write -1 as eof for greenzone
|
||||
write32le(-1, os);
|
||||
|
||||
int end = os->ftell();
|
||||
return end-start;
|
||||
}
|
||||
|
||||
bool GREENZONE::loadGreenzone(EMUFILE *is)
|
||||
bool GREENZONE::load(EMUFILE *is)
|
||||
{
|
||||
clearGreenzone();
|
||||
currMovieData.frames_flags.resize(currMovieData.records.size());
|
||||
lag_history.resize(currMovieData.getNumRecords());
|
||||
int frame = 0, prev_frame = 0, size = 0;
|
||||
int last_tick = 0;
|
||||
// read size
|
||||
if (read32le((uint32 *)&size, is) && size >= 0 && size <= (int)currMovieData.records.size())
|
||||
if (read32le((uint32 *)&size, is) && size >= 0 && size <= currMovieData.getNumRecords())
|
||||
{
|
||||
greenZoneCount = size;
|
||||
savestates.resize(greenZoneCount);
|
||||
|
@ -187,8 +181,8 @@ bool GREENZONE::loadGreenzone(EMUFILE *is)
|
|||
playback.SetProgressbar(frame, greenZoneCount);
|
||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||
}
|
||||
// read frames_flags
|
||||
if ((int)is->fread(&currMovieData.frames_flags[frame],1) != 1) break;
|
||||
// read lag history
|
||||
if (!read8le(&lag_history[frame], is)) break;
|
||||
// read lua_colorings
|
||||
// read monitorings
|
||||
// read savestate
|
||||
|
@ -223,7 +217,8 @@ error:
|
|||
|
||||
void GREENZONE::InvalidateGreenZone(int after)
|
||||
{
|
||||
if (after < 0) return;
|
||||
if (after >= 0)
|
||||
{
|
||||
project.changed = true;
|
||||
if (greenZoneCount > after+1)
|
||||
{
|
||||
|
@ -238,6 +233,7 @@ void GREENZONE::InvalidateGreenZone(int after)
|
|||
playback.jump(greenZoneCount-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// redraw list even if greenzone didn't change
|
||||
RedrawList();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//Specification file for Greenzone class
|
||||
|
||||
//#define LAG_FLAG_BIT 1
|
||||
|
||||
class GREENZONE
|
||||
{
|
||||
|
@ -9,11 +10,11 @@ public:
|
|||
void reset();
|
||||
void update();
|
||||
|
||||
void TryDumpIncremental(bool lagFlag = true);
|
||||
void save(EMUFILE *os);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
void clearGreenzone();
|
||||
int dumpGreenzone(EMUFILE *os);
|
||||
bool loadGreenzone(EMUFILE *is);
|
||||
void TryDumpIncremental(bool lagFlag = true);
|
||||
|
||||
bool loadTasSavestate(int frame);
|
||||
void storeTasSavestate(int frame);
|
||||
|
@ -27,6 +28,7 @@ public:
|
|||
// data
|
||||
int greenZoneCount;
|
||||
std::vector<std::vector<uint8>> savestates;
|
||||
std::vector<uint8> lag_history;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ void INPUT_SNAPSHOT::toMovie(MovieData& md, int start)
|
|||
{
|
||||
// write input data to movie data
|
||||
md.records.resize(size);
|
||||
md.frames_flags.resize(size);
|
||||
switch(input_type)
|
||||
{
|
||||
case FOURSCORE:
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
//Implementation file of Markers class
|
||||
|
||||
#include "movie.h"
|
||||
#include "../common.h"
|
||||
#include "taseditproj.h"
|
||||
//#include "../tasedit.h"
|
||||
|
||||
|
||||
MARKERS::MARKERS()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MARKERS::init()
|
||||
{
|
||||
free();
|
||||
update();
|
||||
}
|
||||
void MARKERS::free()
|
||||
{
|
||||
markers_array.resize(0);
|
||||
}
|
||||
|
||||
void MARKERS::update()
|
||||
{
|
||||
if (markers_array.size() < currMovieData.getNumRecords())
|
||||
markers_array.resize(currMovieData.getNumRecords());
|
||||
}
|
||||
|
||||
void MARKERS::save(EMUFILE *os)
|
||||
{
|
||||
// write size
|
||||
int size = markers_array.size();
|
||||
write32le(size, os);
|
||||
// write array
|
||||
os->fwrite(markers_array.data(), size);
|
||||
}
|
||||
bool MARKERS::load(EMUFILE *is)
|
||||
{
|
||||
markers_array.resize(currMovieData.getNumRecords());
|
||||
int size;
|
||||
if (read32le((uint32 *)&size, is) && size == currMovieData.getNumRecords())
|
||||
{
|
||||
// read array
|
||||
if ((int)is->fread(markers_array.data(), size) == size) return true;
|
||||
}
|
||||
error:
|
||||
FCEU_printf("Error loading markers\n");
|
||||
return false;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
void MARKERS::ToggleMarker(int frame)
|
||||
{
|
||||
if (markers_array[frame] & MARKER_FLAG_BIT)
|
||||
markers_array[frame] &= ~MARKER_FLAG_BIT;
|
||||
else
|
||||
markers_array[frame] |= MARKER_FLAG_BIT;
|
||||
}
|
||||
|
||||
void MARKERS::insertEmpty(int at, int frames)
|
||||
{
|
||||
if(at == -1)
|
||||
{
|
||||
markers_array.resize(markers_array.size() + frames);
|
||||
} else
|
||||
{
|
||||
markers_array.insert(markers_array.begin() + at, frames, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
//Specification file for Markers class
|
||||
|
||||
#define MARKER_FLAG_BIT 1
|
||||
|
||||
class MARKERS
|
||||
{
|
||||
public:
|
||||
MARKERS();
|
||||
void init();
|
||||
void free();
|
||||
void update();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
void ToggleMarker(int frame);
|
||||
void insertEmpty(int at, int frames);
|
||||
|
||||
std::vector<uint8> markers_array;
|
||||
|
||||
private:
|
||||
|
||||
};
|
|
@ -9,9 +9,10 @@
|
|||
extern void ForceExecuteLuaFrameFunctions();
|
||||
#endif
|
||||
|
||||
extern HWND hwndProgressbar, hwndList, hwndRewind, hwndForward;
|
||||
extern HWND hwndProgressbar, hwndList, hwndRewind, hwndForward, hwndRewindFull, hwndForwardFull;
|
||||
extern void FCEU_printf(char *format, ...);
|
||||
extern bool turbo;
|
||||
extern MARKERS markers;
|
||||
extern GREENZONE greenzone;
|
||||
extern bool Tasedit_rewind_now;
|
||||
|
||||
|
@ -32,6 +33,8 @@ void PLAYBACK::reset()
|
|||
old_show_pauseframe = show_pauseframe = false;
|
||||
old_rewind_button_state = rewind_button_state = false;
|
||||
old_forward_button_state = forward_button_state = false;
|
||||
old_rewind_full_button_state = rewind_full_button_state = false;
|
||||
old_forward_full_button_state = forward_full_button_state = false;
|
||||
old_emu_paused = emu_paused = true;
|
||||
SeekingStop();
|
||||
}
|
||||
|
@ -42,23 +45,6 @@ void PLAYBACK::update()
|
|||
if(pauseframe && pauseframe <= currFrameCounter + 1)
|
||||
SeekingStop();
|
||||
|
||||
// update seeking progressbar
|
||||
old_emu_paused = emu_paused;
|
||||
emu_paused = (FCEUI_EmulationPaused() != 0);
|
||||
if (pauseframe && !emu_paused)
|
||||
{
|
||||
SetProgressbar(currFrameCounter - seeking_start_frame, pauseframe-seeking_start_frame);
|
||||
} else if (old_emu_paused != emu_paused)
|
||||
{
|
||||
// emulator got paused/unpaused externally
|
||||
if (old_emu_paused && !emu_paused)
|
||||
// externally unpaused - progressbar should be empty
|
||||
SetProgressbar(0, 1);
|
||||
else
|
||||
// externally paused - progressbar should be full
|
||||
SetProgressbar(1, 1);
|
||||
}
|
||||
|
||||
// update flashing pauseframe
|
||||
if (old_pauseframe != pauseframe && old_pauseframe) RedrawRow(old_pauseframe-1);
|
||||
old_pauseframe = pauseframe;
|
||||
|
@ -72,6 +58,24 @@ void PLAYBACK::update()
|
|||
} else show_pauseframe = false;
|
||||
if (old_show_pauseframe != show_pauseframe) RedrawRow(pauseframe-1);
|
||||
|
||||
// update seeking progressbar
|
||||
old_emu_paused = emu_paused;
|
||||
emu_paused = (FCEUI_EmulationPaused() != 0);
|
||||
if (pauseframe)
|
||||
{
|
||||
if (old_show_pauseframe != show_pauseframe)
|
||||
SetProgressbar(currFrameCounter - seeking_start_frame, pauseframe-seeking_start_frame);
|
||||
} else if (old_emu_paused != emu_paused)
|
||||
{
|
||||
// emulator got paused/unpaused externally
|
||||
if (old_emu_paused && !emu_paused)
|
||||
// externally unpaused - progressbar should be empty
|
||||
SetProgressbar(0, 1);
|
||||
else
|
||||
// externally paused - progressbar should be full
|
||||
SetProgressbar(1, 1);
|
||||
}
|
||||
|
||||
//update the playback cursor
|
||||
if(currFrameCounter != lastCursor)
|
||||
{
|
||||
|
@ -113,6 +117,34 @@ void PLAYBACK::update()
|
|||
}
|
||||
}
|
||||
}
|
||||
// update << and >> buttons
|
||||
old_rewind_full_button_state = rewind_full_button_state;
|
||||
rewind_full_button_state = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0);
|
||||
if (rewind_full_button_state && !rewind_button_state && !forward_button_state)
|
||||
{
|
||||
if (!old_rewind_full_button_state)
|
||||
{
|
||||
button_hold_time = clock();
|
||||
RewindFull();
|
||||
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
|
||||
{
|
||||
RewindFull();
|
||||
}
|
||||
}
|
||||
old_forward_full_button_state = forward_full_button_state;
|
||||
forward_full_button_state = (Button_GetState(hwndForwardFull) & BST_PUSHED) != 0;
|
||||
if (forward_full_button_state && !rewind_button_state && !forward_button_state && !rewind_full_button_state)
|
||||
{
|
||||
if (!old_forward_full_button_state)
|
||||
{
|
||||
button_hold_time = clock();
|
||||
ForwardFull();
|
||||
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
|
||||
{
|
||||
ForwardFull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PLAYBACK::updateProgressbar()
|
||||
|
@ -176,14 +208,33 @@ void PLAYBACK::ForwardFrame()
|
|||
}
|
||||
void PLAYBACK::RewindFull()
|
||||
{
|
||||
// rewind to the beginning of greenzone
|
||||
jump(greenzone.FindBeginningOfGreenZone());
|
||||
// jump to previous marker
|
||||
if (currFrameCounter > 0)
|
||||
{
|
||||
int index = currFrameCounter - 1;
|
||||
for (; index >= 0; index--)
|
||||
if (markers.markers_array[index] & MARKER_FLAG_BIT) break;
|
||||
if (index >= 0)
|
||||
jump(index);
|
||||
else if (currFrameCounter > 0)
|
||||
jump(0);
|
||||
}
|
||||
FollowPlayback();
|
||||
}
|
||||
void PLAYBACK::ForwardFull()
|
||||
{
|
||||
// move to the end of greenzone
|
||||
jump(greenzone.greenZoneCount-1);
|
||||
// jump to next marker
|
||||
int last_frame = currMovieData.getNumRecords()-1;
|
||||
if (currFrameCounter < last_frame)
|
||||
{
|
||||
int index = currFrameCounter + 1;
|
||||
for (; index < last_frame; ++index)
|
||||
if (markers.markers_array[index] & MARKER_FLAG_BIT) break;
|
||||
if (index <= last_frame)
|
||||
jump(index);
|
||||
else if (currFrameCounter < last_frame)
|
||||
jump(last_frame);
|
||||
}
|
||||
FollowPlayback();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ private:
|
|||
bool old_show_pauseframe, show_pauseframe;
|
||||
bool old_rewind_button_state, rewind_button_state;
|
||||
bool old_forward_button_state, forward_button_state;
|
||||
bool old_rewind_full_button_state, rewind_full_button_state;
|
||||
bool old_forward_full_button_state, forward_full_button_state;
|
||||
int button_hold_time;
|
||||
int seeking_start_frame;
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
#include "../main.h"
|
||||
#include "taseditproj.h"
|
||||
|
||||
extern INPUT_HISTORY history;
|
||||
extern PLAYBACK playback;
|
||||
extern MARKERS markers;
|
||||
extern GREENZONE greenzone;
|
||||
extern PLAYBACK playback;
|
||||
extern INPUT_HISTORY history;
|
||||
|
||||
extern void FCEU_printf(char *format, ...);
|
||||
|
||||
|
@ -42,11 +43,10 @@ bool TASEDIT_PROJECT::saveProject()
|
|||
if (PFN.empty()) return false;
|
||||
const char* filename = PFN.c_str();
|
||||
EMUFILE_FILE* ofs = FCEUD_UTF8_fstream(filename,"wb");
|
||||
//ofs << GetProjectName() << std::endl;
|
||||
//ofs << GetFM2Name() << std::endl;
|
||||
|
||||
currMovieData.dump(ofs, true);
|
||||
greenzone.dumpGreenzone(ofs);
|
||||
markers.save(ofs);
|
||||
greenzone.save(ofs);
|
||||
history.save(ofs);
|
||||
|
||||
delete ofs;
|
||||
|
@ -65,13 +65,15 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
|
|||
|
||||
EMUFILE_FILE ifs(filename, "rb");
|
||||
|
||||
FCEU_printf("Loading project %s\n", filename);
|
||||
FCEU_printf("Loading TASEdit project %s\n", filename);
|
||||
|
||||
LoadFM2(currMovieData, &ifs, ifs.size(), false);
|
||||
LoadSubtitles(currMovieData);
|
||||
|
||||
// try to load markers
|
||||
if (markers.load(&ifs))
|
||||
{
|
||||
// try to load greenzone
|
||||
if (!greenzone.loadGreenzone(&ifs))
|
||||
if (greenzone.load(&ifs))
|
||||
{
|
||||
// there was some error while loading greenzone - reset playback to frame 0
|
||||
poweron(true);
|
||||
|
@ -79,8 +81,9 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
|
|||
// try to load history
|
||||
history.load(&ifs);
|
||||
}
|
||||
|
||||
}
|
||||
reset();
|
||||
playback.updateProgressbar();
|
||||
return true;
|
||||
}
|
||||
// -----------------------------------------------------------------
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "inputhistory.h"
|
||||
#include "playback.h"
|
||||
#include "greenzone.h"
|
||||
#include "markers.h"
|
||||
|
||||
class TASEDIT_PROJECT
|
||||
{
|
||||
|
|
|
@ -109,7 +109,6 @@ void MovieData::clearRecordRange(int start, int len)
|
|||
for(int i=0;i<len;i++)
|
||||
{
|
||||
records[i+start].clear();
|
||||
frames_flags[i+start] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,20 +117,11 @@ void MovieData::insertEmpty(int at, int frames)
|
|||
if(at == -1)
|
||||
{
|
||||
int currcount = records.size();
|
||||
records.resize(currcount+frames);
|
||||
#ifdef WIN32
|
||||
if (TASEdit_bind_markers)
|
||||
#endif
|
||||
frames_flags.resize(currcount+frames);
|
||||
clearRecordRange(currcount,frames);
|
||||
}
|
||||
else
|
||||
records.resize(currcount + frames);
|
||||
clearRecordRange(currcount, frames);
|
||||
} else
|
||||
{
|
||||
records.insert(records.begin()+at,frames,MovieRecord());
|
||||
#ifdef WIN32
|
||||
if (TASEdit_bind_markers)
|
||||
#endif
|
||||
frames_flags.insert(frames_flags.begin()+at,frames,0);
|
||||
records.insert(records.begin() + at, frames, MovieRecord());
|
||||
clearRecordRange(at,frames);
|
||||
}
|
||||
}
|
||||
|
@ -140,14 +130,10 @@ void MovieData::cloneRegion(int at, int frames)
|
|||
{
|
||||
if(at == -1) return;
|
||||
|
||||
records.insert(records.begin()+at,frames,MovieRecord());
|
||||
#ifdef WIN32
|
||||
if (TASEdit_bind_markers)
|
||||
#endif
|
||||
frames_flags.insert(frames_flags.begin()+at,frames,0);
|
||||
records.insert(records.begin() + at, frames, MovieRecord());
|
||||
|
||||
for(int i = 0; i < frames; i++)
|
||||
records[i+at].Clone(records[i+at+frames]);
|
||||
records[i+at].Clone(records[i + at + frames]);
|
||||
}
|
||||
|
||||
MovieRecord::MovieRecord()
|
||||
|
@ -601,7 +587,6 @@ static void LoadFM2_binarychunk(MovieData& movieData, EMUFILE* fp, int size)
|
|||
numRecords=movieData.loadFrameCount;
|
||||
|
||||
movieData.records.resize(numRecords);
|
||||
movieData.frames_flags.resize(numRecords);
|
||||
for(int i=0;i<numRecords;i++)
|
||||
{
|
||||
movieData.records[i].parseBinary(&movieData,fp);
|
||||
|
@ -673,7 +658,6 @@ bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)
|
|||
if (stopAfterHeader) return true;
|
||||
int currcount = movieData.records.size();
|
||||
movieData.records.resize(currcount+1);
|
||||
movieData.frames_flags.resize(currcount+1);
|
||||
int preparse = fp->ftell();
|
||||
movieData.records[currcount].parse(&movieData, fp);
|
||||
int postparse = fp->ftell();
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#ifndef __MOVIE_H_
|
||||
#define __MOVIE_H_
|
||||
|
||||
#define LAG_FLAG_BIT 1
|
||||
#define MARKER_FLAG_BIT 2
|
||||
|
||||
#define PROGRESSBAR_UPDATE_RATE 2000 // in frames of greenzone
|
||||
|
||||
#include <vector>
|
||||
|
@ -178,7 +175,6 @@ public:
|
|||
std::string romFilename;
|
||||
std::vector<uint8> savestate;
|
||||
std::vector<MovieRecord> records;
|
||||
std::vector<uint8> frames_flags;
|
||||
std::vector<std::wstring> comments;
|
||||
std::vector<std::string> subtitles;
|
||||
//this is the RERECORD COUNT. please rename variable.
|
||||
|
|
|
@ -421,6 +421,7 @@
|
|||
<ClCompile Include="..\src\drivers\win\taseditlib\greenzone.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\taseditlib\inputhistory.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\taseditlib\inputsnapshot.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\taseditlib\markers.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\taseditlib\playback.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\texthook.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\throttle.cpp" />
|
||||
|
|
|
@ -911,6 +911,7 @@
|
|||
<ClCompile Include="..\src\drivers\win\taseditlib\inputsnapshot.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\taseditlib\playback.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\taseditlib\greenzone.cpp" />
|
||||
<ClCompile Include="..\src\drivers\win\taseditlib\markers.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\cart.h">
|
||||
|
|
Loading…
Reference in New Issue