Taseditor bugfixes

This commit is contained in:
ansstuff 2011-12-06 12:23:42 +00:00
parent c0d73203db
commit 51c7544b13
19 changed files with 127 additions and 96 deletions

View File

@ -225,7 +225,7 @@ BEGIN
MENUITEM "Save &Compact", ID_FILE_SAVECOMPACT, INACTIVE
MENUITEM "&Recent", ID_TASEDIT_FILE_RECENT
MENUITEM SEPARATOR
MENUITEM "&Import", ID_FILE_IMPORTFM2
MENUITEM "&Import", ID_FILE_IMPORT
MENUITEM "&Export to FM2", ID_FILE_EXPORTFM2
MENUITEM SEPARATOR
MENUITEM "&Close\tAlt+F4", ID_TASEDIT_FILE_CLOSE

View File

@ -180,7 +180,6 @@
#define IDB_BITMAP18 181
#define IDB_BITMAP19 182
#define IDB_BRANCH_SPRITESHEET 184
#define IDD_DIALOG4 185
#define IDD_TASEDIT_EXPORT 185
#define MENU_RESET 200
#define BUTTON_ROMS 200
@ -648,7 +647,7 @@
#define ID_Menu40175 40175
#define ID_Menu40176 40176
#define ID_EDIT_TRUNCATE 40177
#define ID_FILE_IMPORTFM2 40178
#define ID_FILE_IMPORT 40178
#define ID_FILE_NEWPROJECT 40179
#define ID_FILE_OPEN_PROJECT 40180
#define ID_FILE_OPENPROJECT 40181

View File

@ -767,22 +767,22 @@ void OpenProject()
{
if (!AskSaveProject()) return;
const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0\0";
const char filter[] = "TASEdit Project (*.tas)\0*.tas\0\0";
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndTasEdit;
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Open TASEdit Project...";
ofn.lpstrFilter=TPfilter;
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Open TASEdit Project...";
ofn.lpstrFilter = filter;
char nameo[2048];
strcpy(nameo, mass_replace(GetRomName(),"|",".").c_str()); //convert | to . for archive filenames
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); //convert | to . for archive filenames
ofn.lpstrFile=nameo;
ofn.lpstrFile = nameo;
ofn.nMaxFile = 2048;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST;
ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST;
string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
ofn.lpstrInitialDir = initdir.c_str();
@ -805,9 +805,14 @@ void OpenProject()
project.LoadProject(project.GetProjectFile());
// update fourscore status
if (last_fourscore && !currMovieData.fourscore)
{
tasedit_list.RemoveFourscore();
else if (!last_fourscore && currMovieData.fourscore)
FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]);
} else if (!last_fourscore && currMovieData.fourscore)
{
tasedit_list.AddFourscore();
FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]);
}
RedrawTasedit();
RedrawWindowCaption();
}
@ -1009,6 +1014,7 @@ void Export()
break;
}
}
// dump to disk
temp_md.dump(osRecordingMovie, false);
delete osRecordingMovie;
osRecordingMovie = 0;
@ -1146,7 +1152,7 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case ID_FILE_SAVEPROJECTAS:
SaveProjectAs();
break;
case ID_FILE_IMPORTFM2:
case ID_FILE_IMPORT:
Import();
break;
case ID_FILE_EXPORTFM2:
@ -1291,8 +1297,8 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (new_size != TasEdit_undo_levels)
{
TasEdit_undo_levels = new_size;
history.init(TasEdit_undo_levels);
selection.init(TasEdit_undo_levels);
history.reset();
selection.reset();
// hot changes were cleared, so update list
tasedit_list.RedrawList();
}
@ -1591,6 +1597,10 @@ void EnterTasEdit()
}
// switch to tasedit mode
movieMode = MOVIEMODE_TASEDIT;
currMovieData.ports[0] = SI_GAMEPAD;
currMovieData.ports[1] = SI_GAMEPAD;
//force the input configuration stored in the movie to apply
FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]);
// init variables
recorder.init();
tasedit_list.init();
@ -1598,8 +1608,8 @@ void EnterTasEdit()
project.init();
bookmarks.init();
screenshot_display.init();
history.init(TasEdit_undo_levels);
selection.init(TasEdit_undo_levels);
history.init();
selection.init();
SetFocus(history.hwndHistoryList); // set focus only once, to show selection cursor
SetFocus(tasedit_list.hwndList);
FCEU_DispMessage("Tasedit engaged", 0);
@ -1625,7 +1635,7 @@ bool ExitTasEdit()
// release memory
tasedit_list.free();
markers.free();
greenzone.clearGreenzone();
greenzone.free();
bookmarks.free();
screenshot_display.free();
history.free();

View File

@ -21,7 +21,7 @@ void BOOKMARK::init()
not_empty = false;
flash_type = flash_phase = 0;
snapshot.jump_frame = -1;
parent_branch = -1; // -1 = root
parent_branch = -1; // -1 = root (cloud)
}
void BOOKMARK::set()

View File

@ -88,21 +88,8 @@ void BOOKMARKS::init()
BranchPrevY.resize(TOTAL_BOOKMARKS+1);
BranchCurrX.resize(TOTAL_BOOKMARKS+1);
BranchCurrY.resize(TOTAL_BOOKMARKS+1);
for (int i = TOTAL_BOOKMARKS; i >= 0; i--)
{
BranchX[i] = BranchPrevX[i] = BranchCurrX[i] = EMPTY_BRANCHES_X;
BranchY[i] = BranchPrevY[i] = BranchCurrY[i] = EMPTY_BRANCHES_Y_BASE + EMPTY_BRANCHES_Y_FACTOR * ((i + TOTAL_BOOKMARKS - 1) % TOTAL_BOOKMARKS);
}
CursorX = CursorPrevX = CloudX = CloudPrevX = BRANCHES_CLOUD_X;
CursorY = CursorPrevY = BRANCHES_CLOUD_Y;
reset();
current_branch = -1; // -1 = root
changes_since_current_branch = false;
fireball_size = 0;
// set cloud_time and current_pos_time
SetCurrentPosTime();
strcpy(cloud_time, current_pos_time);
reset();
// init bookmarks
bookmarks_array.resize(TOTAL_BOOKMARKS);
@ -145,6 +132,24 @@ void BOOKMARKS::init()
update();
}
void BOOKMARKS::reset()
{
for (int i = TOTAL_BOOKMARKS; i >= 0; i--)
{
BranchX[i] = BranchPrevX[i] = BranchCurrX[i] = EMPTY_BRANCHES_X;
BranchY[i] = BranchPrevY[i] = BranchCurrY[i] = EMPTY_BRANCHES_Y_BASE + EMPTY_BRANCHES_Y_FACTOR * ((i + TOTAL_BOOKMARKS - 1) % TOTAL_BOOKMARKS);
}
CursorX = CursorPrevX = CloudX = CloudPrevX = BRANCHES_CLOUD_X;
CursorY = CursorPrevY = BRANCHES_CLOUD_Y;
reset_vars();
current_branch = -1; // -1 = root
changes_since_current_branch = false;
fireball_size = 0;
// set cloud_time and current_pos_time
SetCurrentPosTime();
strcpy(cloud_time, current_pos_time);
}
void BOOKMARKS::reset_vars()
{
transition_phase = animation_frame = 0;
mouse_x = mouse_y = -1;
@ -561,7 +566,7 @@ bool BOOKMARKS::load(EMUFILE *is)
if (bookmarks_array[i].load(is)) return true;
}
// all ok
reset();
reset_vars();
RedrawBookmarksCaption();
return false;
}

View File

@ -89,8 +89,9 @@ class BOOKMARKS
public:
BOOKMARKS();
void init();
void reset();
void free();
void reset();
void reset_vars();
void update();
void save(EMUFILE *os);

View File

@ -23,14 +23,27 @@ GREENZONE::GREENZONE()
void GREENZONE::init()
{
clearGreenzone();
reset();
next_cleaning_time = clock() + TIME_BETWEEN_CLEANINGS;
}
void GREENZONE::free()
{
int size = savestates.size();
for (int i = 0; i < size; ++i)
{
ClearSavestate(i);
}
savestates.resize(0);
greenZoneCount = 0;
lag_history.resize(0);
// reset lua_colorings
// reset monitorings
}
void GREENZONE::reset()
{
free();
lag_history.resize(currMovieData.getNumRecords());
}
void GREENZONE::update()
{
@ -169,21 +182,6 @@ void GREENZONE::ClearSavestate(int index)
savestates[index].swap(tmp);
}
void GREENZONE::clearGreenzone()
{
int size = savestates.size();
for (int i = 0; i < size; ++i)
{
ClearSavestate(i);
}
savestates.resize(0);
greenZoneCount = 0;
lag_history.resize(0);
// reset lua_colorings
// reset monitorings
}
void GREENZONE::save(EMUFILE *os)
{
int frame, size;
@ -226,7 +224,7 @@ void GREENZONE::save(EMUFILE *os)
// returns true if couldn't load
bool GREENZONE::load(EMUFILE *is)
{
clearGreenzone();
free();
int frame = 0, prev_frame = -1, size = 0;
int last_tick = 0;
// read "GREENZONE" string

View File

@ -17,12 +17,12 @@ public:
GREENZONE();
void init();
void reset();
void free();
void update();
void save(EMUFILE *os);
bool load(EMUFILE *is);
void clearGreenzone();
void TryDumpIncremental(bool lagFlag = true);
bool loadTasSavestate(int frame);

View File

@ -7,6 +7,7 @@ extern bool TASEdit_bind_markers;
extern bool TASEdit_enable_hot_changes;
extern bool TASEdit_branch_full_movie;
extern bool TASEdit_combine_consecutive_rec;
extern int TasEdit_undo_levels;
LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
WNDPROC hwndHistoryList_oldWndProc;
@ -61,7 +62,7 @@ INPUT_HISTORY::INPUT_HISTORY()
{
}
void INPUT_HISTORY::init(int new_size)
void INPUT_HISTORY::init()
{
// prepare the history listview
hwndHistoryList = GetDlgItem(hwndTasEdit, IDC_HISTORYLIST);
@ -73,13 +74,21 @@ void INPUT_HISTORY::init(int new_size)
lvc.cx = 500;
lvc.fmt = LVCFMT_LEFT;
ListView_InsertColumn(hwndHistoryList, 0, &lvc);
reset();
}
void INPUT_HISTORY::free()
{
input_snapshots.resize(0);
history_total_items = 0;
}
void INPUT_HISTORY::reset()
{
free();
// init vars
if (new_size > 0)
history_size = new_size + 1;
history_size = TasEdit_undo_levels + 1;
undo_hint_pos = old_undo_hint_pos = undo_hint_time = -1;
old_show_undo_hint = show_undo_hint = false;
// clear snapshots history
free();
input_snapshots.resize(history_size);
history_start_pos = 0;
history_cursor_pos = -1;
@ -89,16 +98,9 @@ void INPUT_HISTORY::init(int new_size)
strcat(inp.description, modCaptions[0]);
inp.jump_frame = -1;
AddInputSnapshotToHistory(inp);
UpdateHistoryList();
RedrawHistoryList();
}
void INPUT_HISTORY::free()
{
input_snapshots.resize(0);
history_total_items = 0;
}
void INPUT_HISTORY::update()
{
// update undo_hint

View File

@ -48,9 +48,9 @@ class INPUT_HISTORY
{
public:
INPUT_HISTORY();
void init(int new_size = 0);
void init();
void free();
void reset();
void update(); // called every frame
void save(EMUFILE *os);

View File

@ -10,6 +10,10 @@ MARKERS::MARKERS()
}
void MARKERS::init()
{
reset();
}
void MARKERS::reset()
{
free();
update();

View File

@ -9,6 +9,7 @@ class MARKERS
public:
MARKERS();
void init();
void reset();
void free();
void update();

View File

@ -1,7 +1,7 @@
//Specification file for SCREENSHOT_DISPLAY class
#define SCR_BMP_PHASE_MAX 12
#define SCR_BMP_PHASE_ALPHA_MAX 10
#define SCR_BMP_PHASE_MAX 10
#define SCR_BMP_PHASE_ALPHA_MAX 8
#define SCR_BMP_DX 7
#define DISPLAY_UPDATE_TICK 40 // update at 25FPS

View File

@ -157,6 +157,7 @@ void TASEDIT_LIST::init()
listItems = ListView_GetCountPerPage(hwndList);
update();
reset();
}
void TASEDIT_LIST::free()
{
@ -167,7 +168,11 @@ void TASEDIT_LIST::free()
}
}
void TASEDIT_LIST::reset()
{
// scroll to the beginning
ListView_EnsureVisible(hwndList, 0, FALSE);
}
void TASEDIT_LIST::update()
{
//update the number of items in the list
@ -181,6 +186,7 @@ void TASEDIT_LIST::update()
void TASEDIT_LIST::save(EMUFILE *os)
{
update();
// write "LIST" string
os->fwrite(list_save_id, LIST_ID_LEN);
// write current top item
@ -204,8 +210,6 @@ bool TASEDIT_LIST::load(EMUFILE *is)
return false;
error:
// scroll to the beginning
ListView_EnsureVisible(hwndList, 0, FALSE);
return true;
}
// ----------------------------------------------------------------------

View File

@ -90,6 +90,7 @@ public:
TASEDIT_LIST();
void init();
void free();
void reset();
void update();
void save(EMUFILE *os);

View File

@ -5,6 +5,7 @@
char selection_save_id[SELECTION_ID_LEN] = "SELECTION";
extern HWND hwndTasEdit;
extern int TasEdit_undo_levels;
extern MARKERS markers;
extern TASEDIT_LIST tasedit_list;
@ -23,7 +24,7 @@ TASEDIT_SELECTION::TASEDIT_SELECTION()
{
}
void TASEDIT_SELECTION::init(int new_size)
void TASEDIT_SELECTION::init()
{
hwndPrevMarker = GetDlgItem(hwndTasEdit, TASEDIT_PREV_MARKER);
hwndNextMarker = GetDlgItem(hwndTasEdit, TASEDIT_NEXT_MARKER);
@ -31,17 +32,7 @@ void TASEDIT_SELECTION::init(int new_size)
hwndFindNextMarker = GetDlgItem(hwndTasEdit, TASEDIT_FIND_NEXT_MARKER);
hwndTextSelection = GetDlgItem(hwndTasEdit, IDC_TEXT_SELECTION);
hwndTextClipboard = GetDlgItem(hwndTasEdit, IDC_TEXT_CLIPBOARD);
// init vars
if (new_size > 0)
history_size = new_size + 1;
// clear selections history
free();
selections_history.resize(history_size);
history_start_pos = 0;
history_cursor_pos = -1;
// create initial selection
AddNewSelectionToHistory();
track_selection_changes = true;
reset();
if (clipboard_selection.empty())
@ -56,12 +47,25 @@ void TASEDIT_SELECTION::free()
temp_selection.clear();
}
void TASEDIT_SELECTION::reset()
{
free();
// init vars
history_size = TasEdit_undo_levels + 1;
selections_history.resize(history_size);
history_start_pos = 0;
history_cursor_pos = -1;
// create initial selection
ClearSelection();
AddNewSelectionToHistory();
track_selection_changes = true;
reset_vars();
}
void TASEDIT_SELECTION::reset_vars()
{
old_prev_marker_button_state = prev_marker_button_state = false;
old_next_marker_button_state = next_marker_button_state = false;
must_redraw_text = true;
}
void TASEDIT_SELECTION::update()
{
// keep selection within movie limits
@ -271,7 +275,7 @@ bool TASEDIT_SELECTION::load(EMUFILE *is)
if (loadSelection(clipboard_selection, is)) goto error;
// all ok
EnforceSelectionToList();
reset();
reset_vars();
return false;
error:
return true;

View File

@ -6,9 +6,10 @@ class TASEDIT_SELECTION
{
public:
TASEDIT_SELECTION();
void init(int new_size = 0);
void init();
void free();
void reset();
void reset_vars();
void update();
void RedrawTextClipboard();

View File

@ -92,7 +92,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
if (error)
{
FCEU_printf("Error loading markers\n");
markers.init();
markers.reset();
} else
{
// try to load bookmarks
@ -101,7 +101,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
if (error)
{
FCEU_printf("Error loading bookmarks\n");
bookmarks.init();
bookmarks.reset();
} else
{
// try to load greenzone
@ -110,7 +110,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
if (error)
{
FCEU_printf("Error loading greenzone\n");
greenzone.init();
greenzone.reset();
playback.StartFromZero(); // reset playback to frame 0
} else
{
@ -120,7 +120,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
if (error)
{
FCEU_printf("Error loading history\n");
history.init();
history.reset();
} else
{
// try to load selection
@ -129,7 +129,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
if (error)
{
FCEU_printf("Error loading selection\n");
selection.init();
selection.reset();
} else
{
// update and try to load list
@ -138,6 +138,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
if (error)
{
FCEU_printf("Error loading list\n");
tasedit_list.reset();
}
playback.reset();

View File

@ -884,7 +884,7 @@ bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _paus
FCEUI_SetVidSystem(0);
//force the input configuration stored in the movie to apply
FCEUD_SetInput(currMovieData.fourscore,currMovieData.microphone,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]);
FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]);
//stuff that should only happen when we're ready to positively commit to the replay
if(tasedit)