* loading TAS Editor projects by drag-n-drop
* Tasedit: File->Save Compact dialog
This commit is contained in:
parent
840528d52a
commit
a5ee28a447
|
@ -68,6 +68,7 @@ extern bool SingleInstanceOnly;
|
|||
extern bool oldInputDisplay;
|
||||
extern bool fullSaveStateLoads;
|
||||
extern int frameSkipAmt;
|
||||
|
||||
extern bool TASEdit_follow_playback;
|
||||
extern bool TASEdit_turbo_seek;
|
||||
extern bool TASEdit_show_lag_frames;
|
||||
|
@ -89,6 +90,13 @@ extern int TasEdit_undo_levels;
|
|||
extern int TASEdit_autosave_period;
|
||||
extern bool TASEdit_jump_to_undo;
|
||||
extern int TASEdit_last_export_type;
|
||||
extern bool TASEdit_savecompact_binary;
|
||||
extern bool TASEdit_savecompact_markers;
|
||||
extern bool TASEdit_savecompact_bookmarks;
|
||||
extern bool TASEdit_savecompact_greenzone;
|
||||
extern bool TASEdit_savecompact_history;
|
||||
extern bool TASEdit_savecompact_selection;
|
||||
extern bool TASEdit_savecompact_list;
|
||||
extern char* recent_projects[];
|
||||
|
||||
//window positions and sizes:
|
||||
|
@ -339,6 +347,13 @@ static CFGSTRUCT fceuconfig[] = {
|
|||
AC(TASEdit_autosave_period),
|
||||
AC(TASEdit_jump_to_undo),
|
||||
AC(TASEdit_last_export_type),
|
||||
AC(TASEdit_savecompact_binary),
|
||||
AC(TASEdit_savecompact_markers),
|
||||
AC(TASEdit_savecompact_bookmarks),
|
||||
AC(TASEdit_savecompact_greenzone),
|
||||
AC(TASEdit_savecompact_history),
|
||||
AC(TASEdit_savecompact_selection),
|
||||
AC(TASEdit_savecompact_list),
|
||||
AC(lagCounterDisplay),
|
||||
AC(oldInputDisplay),
|
||||
AC(movieSubtitles),
|
||||
|
|
|
@ -222,7 +222,7 @@ BEGIN
|
|||
MENUITEM "&Open", ID_FILE_OPENPROJECT
|
||||
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVEPROJECT
|
||||
MENUITEM "S&ave As", ID_FILE_SAVEPROJECTAS
|
||||
MENUITEM "Save &Compact", ID_FILE_SAVECOMPACT, INACTIVE
|
||||
MENUITEM "Save &Compact", ID_FILE_SAVECOMPACT
|
||||
MENUITEM "&Recent", ID_TASEDIT_FILE_RECENT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Import", ID_FILE_IMPORT
|
||||
|
@ -1423,7 +1423,23 @@ BEGIN
|
|||
PUSHBUTTON "Cancel",IDCANCEL,65,52,50,14
|
||||
CONTROL " 1 player",IDC_RADIO_1PLAYER,"Button",BS_AUTORADIOBUTTON,36,8,49,10
|
||||
CONTROL " 2 players",IDC_RADIO_2PLAYERS,"Button",BS_AUTORADIOBUTTON,36,21,49,10
|
||||
CONTROL " Fourscore",IDC_RADIO_FOURSCORE,"Button",BS_AUTORADIOBUTTON,37,35,47,10
|
||||
CONTROL " Fourscore",IDC_RADIO_FOURSCORE,"Button",BS_AUTORADIOBUTTON,36,35,47,10
|
||||
END
|
||||
|
||||
IDD_TASEDIT_SAVECOMPACT DIALOGEX 0, 0, 122, 134
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dialog"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Save",IDOK,7,114,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,65,114,50,14
|
||||
CONTROL " Binary Format of Input",IDC_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,8,87,10
|
||||
CONTROL " Markers",IDC_CHECK_MARKERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,22,67,10
|
||||
CONTROL " Bookmarks",IDC_CHECK_BOOKMARKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,36,67,10
|
||||
CONTROL " Greenzone",IDC_CHECK_GREENZONE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,51,67,10
|
||||
CONTROL " History",IDC_CHECK_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,66,67,10
|
||||
CONTROL " Selection",IDC_CHECK_SELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,81,67,10
|
||||
CONTROL " List data",IDC_CHECK_LIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,96,67,10
|
||||
END
|
||||
|
||||
ASSEMBLER DIALOGEX 0, 0, 202, 135
|
||||
|
@ -1900,6 +1916,16 @@ BEGIN
|
|||
BEGIN
|
||||
END
|
||||
|
||||
IDD_TASEDIT_EXPORT, DIALOG
|
||||
BEGIN
|
||||
END
|
||||
|
||||
IDD_TASEDIT_SAVECOMPACT, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 121
|
||||
BOTTOMMARGIN, 131
|
||||
END
|
||||
|
||||
"ASSEMBLER", DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
|
|
|
@ -181,6 +181,7 @@
|
|||
#define IDB_BITMAP19 182
|
||||
#define IDB_BRANCH_SPRITESHEET 184
|
||||
#define IDD_TASEDIT_EXPORT 185
|
||||
#define IDD_TASEDIT_SAVECOMPACT 186
|
||||
#define MENU_RESET 200
|
||||
#define BUTTON_ROMS 200
|
||||
#define TXT_PAD1 200
|
||||
|
@ -464,13 +465,26 @@
|
|||
#define IDC_CHEAT_PAUSEWHENACTIVE 1203
|
||||
#define IDC_FULLSAVESTATES 1203
|
||||
#define IDC_SUPERIMPOSE 1203
|
||||
#define IDC_CHECK_BINARY 1203
|
||||
#define IDC_VOLUMEGROUP 1204
|
||||
#define IDC_OMITBLANK 1204
|
||||
#define IDC_CHECK3 1204
|
||||
#define IDC_CHECK_MARKERS 1204
|
||||
#define IDC_RAMLIST 1205
|
||||
#define IDC_CHECK4 1205
|
||||
#define IDC_CHECK_BOOKMARKS 1205
|
||||
#define IDC_C_SEARCH 1206
|
||||
#define IDC_CHECK5 1206
|
||||
#define IDC_CHECK_GREENZONE 1206
|
||||
#define IDC_C_ADDCHEAT 1207
|
||||
#define IDC_CHECK6 1207
|
||||
#define IDC_CHECK_HISTORY 1207
|
||||
#define IDC_C_WATCH 1208
|
||||
#define IDC_CHECK7 1208
|
||||
#define IDC_CHECK_SELECTION 1208
|
||||
#define IDC_C_RESET 1209
|
||||
#define IDC_CHECK8 1209
|
||||
#define IDC_CHECK_LIST 1209
|
||||
#define IDC_C_ELIMINATE 1210
|
||||
#define IDC_LESSTHAN 1211
|
||||
#define IDC_MORETHAN 1212
|
||||
|
@ -647,7 +661,7 @@
|
|||
#define ID_Menu40175 40175
|
||||
#define ID_Menu40176 40176
|
||||
#define ID_EDIT_TRUNCATE 40177
|
||||
#define ID_FILE_IMPORT 40178
|
||||
#define ID_FILE_IMPORT 40178
|
||||
#define ID_FILE_NEWPROJECT 40179
|
||||
#define ID_FILE_OPEN_PROJECT 40180
|
||||
#define ID_FILE_OPENPROJECT 40181
|
||||
|
@ -928,7 +942,7 @@
|
|||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 186
|
||||
#define _APS_NEXT_RESOURCE_VALUE 187
|
||||
#define _APS_NEXT_COMMAND_VALUE 40501
|
||||
#define _APS_NEXT_CONTROL_VALUE 1270
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
|
|
|
@ -61,6 +61,13 @@ extern bool muteTurbo;
|
|||
bool TASEdit_enable_hot_changes = true;
|
||||
bool TASEdit_jump_to_undo = true;
|
||||
int TASEdit_last_export_type = EXPORT_TYPE_1P;
|
||||
bool TASEdit_savecompact_binary = true;
|
||||
bool TASEdit_savecompact_markers = true;
|
||||
bool TASEdit_savecompact_bookmarks = true;
|
||||
bool TASEdit_savecompact_greenzone = false;
|
||||
bool TASEdit_savecompact_history = false;
|
||||
bool TASEdit_savecompact_selection = false;
|
||||
bool TASEdit_savecompact_list = true;
|
||||
|
||||
// Recent Menu
|
||||
HMENU recent_projects_menu;
|
||||
|
@ -778,7 +785,7 @@ void OpenProject()
|
|||
ofn.hwndOwner = hwndTasEdit;
|
||||
ofn.hInstance = fceu_hInstance;
|
||||
ofn.lpstrTitle = "Open TAS Editor Project";
|
||||
const char filter[] = "TAS Editor Project (*.tas)\0*.tas\0\0";
|
||||
const char filter[] = "TAS Editor Projects (*.tas)\0*.tas\0\0";
|
||||
ofn.lpstrFilter = filter;
|
||||
|
||||
char nameo[2048];
|
||||
|
@ -844,7 +851,7 @@ void LoadRecentProject(int slot)
|
|||
// Saves current project
|
||||
bool SaveProjectAs()
|
||||
{
|
||||
const char filter[] = "TAS Editor Project (*.tas)\0*.tas\0All Files (*.*)\0*.*\0\0";
|
||||
const char filter[] = "TAS Editor Projects (*.tas)\0*.tas\0All Files (*.*)\0*.*\0\0";
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
|
@ -887,6 +894,94 @@ bool SaveProject()
|
|||
return true;
|
||||
}
|
||||
|
||||
void SaveCompact_GetCheckboxes(HWND hwndDlg)
|
||||
{
|
||||
TASEdit_savecompact_binary = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BINARY, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
TASEdit_savecompact_markers = (SendDlgItemMessage(hwndDlg, IDC_CHECK_MARKERS, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
TASEdit_savecompact_bookmarks = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BOOKMARKS, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
TASEdit_savecompact_greenzone = (SendDlgItemMessage(hwndDlg, IDC_CHECK_GREENZONE, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
TASEdit_savecompact_history = (SendDlgItemMessage(hwndDlg, IDC_CHECK_HISTORY, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
TASEdit_savecompact_selection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
TASEdit_savecompact_list = (SendDlgItemMessage(hwndDlg, IDC_CHECK_LIST, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
}
|
||||
BOOL CALLBACK SaveCompactProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
SetWindowPos(hwndDlg, 0, TasEdit_wndx + 100, TasEdit_wndy + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_BINARY, TASEdit_savecompact_binary?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_MARKERS, TASEdit_savecompact_markers?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_BOOKMARKS, TASEdit_savecompact_bookmarks?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_GREENZONE, TASEdit_savecompact_greenzone?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_HISTORY, TASEdit_savecompact_history?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_SELECTION, TASEdit_savecompact_selection?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_LIST, TASEdit_savecompact_list?MF_CHECKED : MF_UNCHECKED);
|
||||
return TRUE;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
SaveCompact_GetCheckboxes(hwndDlg);
|
||||
EndDialog(hwndDlg, 1);
|
||||
return TRUE;
|
||||
case IDCANCEL:
|
||||
SaveCompact_GetCheckboxes(hwndDlg);
|
||||
EndDialog(hwndDlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
case WM_QUIT:
|
||||
{
|
||||
SaveCompact_GetCheckboxes(hwndDlg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void SaveCompact()
|
||||
{
|
||||
if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDIT_SAVECOMPACT), hwndTasEdit, SaveCompactProc) > 0)
|
||||
{
|
||||
const char filter[] = "TAS Editor Projects (*.tas)\0*.tas\0All Files (*.*)\0*.*\0\0";
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hwndTasEdit;
|
||||
ofn.hInstance = fceu_hInstance;
|
||||
ofn.lpstrTitle = "Save Compact";
|
||||
ofn.lpstrFilter = filter;
|
||||
|
||||
char nameo[2048];
|
||||
if (project.GetProjectName().empty())
|
||||
// suggest ROM name for this project
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); //convert | to . for archive filenames
|
||||
else
|
||||
// suggest current name
|
||||
strcpy(nameo, project.GetProjectName().c_str());
|
||||
// add "-compact"
|
||||
strcat(nameo, "-compact");
|
||||
|
||||
ofn.lpstrFile = nameo;
|
||||
ofn.lpstrDefExt = "tas";
|
||||
ofn.nMaxFile = 2048;
|
||||
ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
|
||||
string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory
|
||||
ofn.lpstrInitialDir = initdir.c_str();
|
||||
|
||||
if(GetSaveFileName(&ofn)) //If it is a valid filename
|
||||
{
|
||||
project.save_compact(nameo, TASEdit_savecompact_binary, TASEdit_savecompact_markers, TASEdit_savecompact_bookmarks, TASEdit_savecompact_greenzone, TASEdit_savecompact_history, TASEdit_savecompact_selection, TASEdit_savecompact_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns false if user doesn't want to exit
|
||||
bool AskSaveProject()
|
||||
{
|
||||
|
@ -907,7 +1002,7 @@ bool AskSaveProject()
|
|||
extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader);
|
||||
void Import()
|
||||
{
|
||||
const char filter[] = "FCEUX Movie Files, TAS Editor Projects\0*.fm2;*.tas\0All Files (*.*)\0*.*\0\0";
|
||||
const char filter[] = "FCEUX Movie Files (*.fm2), TAS Editor Projects (*.tas)\0*.fm2;*.tas\0All Files (*.*)\0*.*\0\0";
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
|
@ -985,6 +1080,7 @@ BOOL CALLBACK ExportProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPara
|
|||
EndDialog(hwndDlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1180,10 +1276,13 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
break;
|
||||
case ACCEL_CTRL_S:
|
||||
case ID_FILE_SAVEPROJECT:
|
||||
SaveProject();
|
||||
SaveProject();
|
||||
break;
|
||||
case ID_FILE_SAVEPROJECTAS:
|
||||
SaveProjectAs();
|
||||
SaveProjectAs();
|
||||
break;
|
||||
case ID_FILE_SAVECOMPACT:
|
||||
SaveCompact();
|
||||
break;
|
||||
case ID_FILE_IMPORT:
|
||||
Import();
|
||||
|
@ -1565,89 +1664,92 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
bool EnterTasEdit()
|
||||
{
|
||||
if(!FCEU_IsValidUI(FCEUI_TASEDIT)) return false;
|
||||
if(!hwndTasEdit) hwndTasEdit = CreateDialog(fceu_hInstance,"TASEDIT", hAppWnd, WndprocTasEdit);
|
||||
if(hwndTasEdit)
|
||||
if(!hwndTasEdit)
|
||||
{
|
||||
// save "eoptions"
|
||||
saved_eoptions = eoptions;
|
||||
// set "Run in background"
|
||||
eoptions |= EO_BGRUN;
|
||||
GotFocus();
|
||||
// "Set high-priority thread"
|
||||
eoptions |= EO_HIGHPRIO;
|
||||
DoPriority();
|
||||
// clear "Disable speed throttling"
|
||||
eoptions &= ~EO_NOTHROTTLE;
|
||||
// switch off autosaves
|
||||
saved_EnableAutosave = EnableAutosave;
|
||||
EnableAutosave = 0;
|
||||
UpdateCheckedMenuItems();
|
||||
|
||||
hmenu = GetMenu(hwndTasEdit);
|
||||
hrmenu = LoadMenu(fceu_hInstance,"TASEDITCONTEXTMENUS");
|
||||
recent_projects_menu = CreateMenu();
|
||||
UpdateRecentProjectsMenu();
|
||||
// check option ticks
|
||||
CheckDlgButton(hwndTasEdit, CHECK_FOLLOW_CURSOR, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndTasEdit, CHECK_TURBO_SEEK, TASEdit_turbo_seek?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_SHOW_LAG_FRAMES, TASEdit_show_lag_frames?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_SHOW_MARKERS, TASEdit_show_markers?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_SHOWBRANCHSCREENSHOTS, TASEdit_show_branch_screenshots?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_JUMPWHENMAKINGUNDO, TASEdit_jump_to_undo?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_ENABLEHOTCHANGES, TASEdit_enable_hot_changes?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_BRANCHESRESTOREFULLMOVIE, TASEdit_branch_full_movie?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_BRANCHESWORKONLYWHENRECORDING, TASEdit_branch_only_when_rec?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_HUDINBRANCHSCREENSHOTS, TASEdit_branch_scr_hud?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_BINDMARKERSTOINPUT, TASEdit_bind_markers?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_USE1PFORRECORDING, TASEdit_use_1p_rec?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_COMBINECONSECUTIVERECORDINGS, TASEdit_combine_consecutive_rec?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_SUPERIMPOSE_AFFECTS_PASTE, TASEdit_superimpose_affects_paste?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndTasEdit,CHECK_AUTORESTORE_PLAYBACK,TASEdit_restore_position?BST_CHECKED:BST_UNCHECKED);
|
||||
CheckDlgButton(hwndTasEdit, IDC_SUPERIMPOSE, TASEdit_superimpose);
|
||||
|
||||
SetWindowPos(hwndTasEdit, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
|
||||
// init modules
|
||||
greenzone.init();
|
||||
playback.init();
|
||||
// either start new movie or use current movie
|
||||
if (FCEUMOV_Mode(MOVIEMODE_INACTIVE))
|
||||
hwndTasEdit = CreateDialog(fceu_hInstance,"TASEDIT", hAppWnd, WndprocTasEdit);
|
||||
if(hwndTasEdit)
|
||||
{
|
||||
FCEUI_StopMovie();
|
||||
CreateCleanMovie();
|
||||
playback.StartFromZero();
|
||||
} else
|
||||
{
|
||||
// use current movie to create a new project
|
||||
if (currMovieData.savestate.size() != 0)
|
||||
// save "eoptions"
|
||||
saved_eoptions = eoptions;
|
||||
// set "Run in background"
|
||||
eoptions |= EO_BGRUN;
|
||||
GotFocus();
|
||||
// "Set high-priority thread"
|
||||
eoptions |= EO_HIGHPRIO;
|
||||
DoPriority();
|
||||
// clear "Disable speed throttling"
|
||||
eoptions &= ~EO_NOTHROTTLE;
|
||||
// switch off autosaves
|
||||
saved_EnableAutosave = EnableAutosave;
|
||||
EnableAutosave = 0;
|
||||
UpdateCheckedMenuItems();
|
||||
|
||||
hmenu = GetMenu(hwndTasEdit);
|
||||
hrmenu = LoadMenu(fceu_hInstance,"TASEDITCONTEXTMENUS");
|
||||
recent_projects_menu = CreateMenu();
|
||||
UpdateRecentProjectsMenu();
|
||||
// check option ticks
|
||||
CheckDlgButton(hwndTasEdit, CHECK_FOLLOW_CURSOR, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndTasEdit, CHECK_TURBO_SEEK, TASEdit_turbo_seek?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_SHOW_LAG_FRAMES, TASEdit_show_lag_frames?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_SHOW_MARKERS, TASEdit_show_markers?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_SHOWBRANCHSCREENSHOTS, TASEdit_show_branch_screenshots?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_JUMPWHENMAKINGUNDO, TASEdit_jump_to_undo?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_VIEW_ENABLEHOTCHANGES, TASEdit_enable_hot_changes?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_BRANCHESRESTOREFULLMOVIE, TASEdit_branch_full_movie?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_BRANCHESWORKONLYWHENRECORDING, TASEdit_branch_only_when_rec?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_HUDINBRANCHSCREENSHOTS, TASEdit_branch_scr_hud?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_BINDMARKERSTOINPUT, TASEdit_bind_markers?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_USE1PFORRECORDING, TASEdit_use_1p_rec?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_COMBINECONSECUTIVERECORDINGS, TASEdit_combine_consecutive_rec?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_SUPERIMPOSE_AFFECTS_PASTE, TASEdit_superimpose_affects_paste?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckDlgButton(hwndTasEdit,CHECK_AUTORESTORE_PLAYBACK,TASEdit_restore_position?BST_CHECKED:BST_UNCHECKED);
|
||||
CheckDlgButton(hwndTasEdit, IDC_SUPERIMPOSE, TASEdit_superimpose);
|
||||
|
||||
SetWindowPos(hwndTasEdit, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
|
||||
// init modules
|
||||
greenzone.init();
|
||||
playback.init();
|
||||
// either start new movie or use current movie
|
||||
if (FCEUMOV_Mode(MOVIEMODE_INACTIVE))
|
||||
{
|
||||
FCEUD_PrintError("This version of TAS Editor doesn't work with movies starting from savestate.");
|
||||
// delete savestate, but preserve input
|
||||
currMovieData.savestate.clear();
|
||||
FCEUI_StopMovie();
|
||||
CreateCleanMovie();
|
||||
playback.StartFromZero();
|
||||
} else
|
||||
{
|
||||
// use current movie to create a new project
|
||||
if (currMovieData.savestate.size() != 0)
|
||||
{
|
||||
FCEUD_PrintError("This version of TAS Editor doesn't work with movies starting from savestate.");
|
||||
// delete savestate, but preserve input
|
||||
currMovieData.savestate.clear();
|
||||
}
|
||||
FCEUI_StopMovie();
|
||||
greenzone.TryDumpIncremental(lagFlag != 0);
|
||||
}
|
||||
FCEUI_StopMovie();
|
||||
greenzone.TryDumpIncremental(lagFlag != 0);
|
||||
}
|
||||
// switch to taseditor 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();
|
||||
markers.init();
|
||||
project.init();
|
||||
bookmarks.init();
|
||||
screenshot_display.init();
|
||||
history.init();
|
||||
selection.init();
|
||||
SetFocus(history.hwndHistoryList); // set focus only once, to show selection cursor
|
||||
SetFocus(tasedit_list.hwndList);
|
||||
FCEU_DispMessage("TAS Editor engaged", 0);
|
||||
return true;
|
||||
} else return false;
|
||||
// switch to taseditor 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();
|
||||
markers.init();
|
||||
project.init();
|
||||
bookmarks.init();
|
||||
screenshot_display.init();
|
||||
history.init();
|
||||
selection.init();
|
||||
SetFocus(history.hwndHistoryList); // set focus only once, to show selection cursor
|
||||
SetFocus(tasedit_list.hwndList);
|
||||
FCEU_DispMessage("TAS Editor engaged", 0);
|
||||
return true;
|
||||
} else return false;
|
||||
} else return true;
|
||||
}
|
||||
|
||||
bool ExitTasEdit()
|
||||
|
|
|
@ -32,6 +32,7 @@ bool LoadProject(char* fullname);
|
|||
void LoadRecentProject(int slot);
|
||||
bool SaveProject();
|
||||
bool SaveProjectAs();
|
||||
void SaveCompact();
|
||||
bool AskSaveProject();
|
||||
void Import();
|
||||
void Export();
|
||||
|
|
|
@ -27,6 +27,7 @@ extern bool TASEdit_view_branches_tree;
|
|||
|
||||
// resources
|
||||
char bookmarks_save_id[BOOKMARKS_ID_LEN] = "BOOKMARKS";
|
||||
char bookmarks_skipsave_id[BOOKMARKS_ID_LEN] = "BOOKMARKX";
|
||||
char bookmarksCaption[3][23] = { " Bookmarks ", " Bookmarks / Branches ", " Branches " };
|
||||
// color tables for flashing when saving/loading bookmarks
|
||||
COLORREF bookmark_flash_colors[3][FLASH_PHASE_MAX+1] = {
|
||||
|
@ -524,24 +525,31 @@ void BOOKMARKS::unleash(int slot)
|
|||
FCEU_DispMessage("Branch %d loaded.", 0, slot);
|
||||
}
|
||||
|
||||
void BOOKMARKS::save(EMUFILE *os)
|
||||
void BOOKMARKS::save(EMUFILE *os, bool really_save)
|
||||
{
|
||||
// write "BOOKMARKS" string
|
||||
os->fwrite(bookmarks_save_id, BOOKMARKS_ID_LEN);
|
||||
// write cloud time
|
||||
os->fwrite(cloud_time, TIME_DESC_LENGTH);
|
||||
// write current branch and flag of changes since it
|
||||
write32le(current_branch, os);
|
||||
if (changes_since_current_branch)
|
||||
write8le((uint8)1, os);
|
||||
else
|
||||
write8le((uint8)0, os);
|
||||
// write current_position time
|
||||
os->fwrite(current_pos_time, TIME_DESC_LENGTH);
|
||||
// write all 10 bookmarks
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
if (really_save)
|
||||
{
|
||||
bookmarks_array[i].save(os);
|
||||
// write "BOOKMARKS" string
|
||||
os->fwrite(bookmarks_save_id, BOOKMARKS_ID_LEN);
|
||||
// write cloud time
|
||||
os->fwrite(cloud_time, TIME_DESC_LENGTH);
|
||||
// write current branch and flag of changes since it
|
||||
write32le(current_branch, os);
|
||||
if (changes_since_current_branch)
|
||||
write8le((uint8)1, os);
|
||||
else
|
||||
write8le((uint8)0, os);
|
||||
// write current_position time
|
||||
os->fwrite(current_pos_time, TIME_DESC_LENGTH);
|
||||
// write all 10 bookmarks
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
{
|
||||
bookmarks_array[i].save(os);
|
||||
}
|
||||
} else
|
||||
{
|
||||
// write "BOOKMARKX" string
|
||||
os->fwrite(bookmarks_skipsave_id, BOOKMARKS_ID_LEN);
|
||||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
|
@ -549,26 +557,37 @@ bool BOOKMARKS::load(EMUFILE *is)
|
|||
{
|
||||
// read "BOOKMARKS" string
|
||||
char save_id[BOOKMARKS_ID_LEN];
|
||||
if ((int)is->fread(save_id, BOOKMARKS_ID_LEN) < BOOKMARKS_ID_LEN) return true;
|
||||
if (strcmp(bookmarks_save_id, save_id)) return true; // string is not valid
|
||||
if ((int)is->fread(save_id, BOOKMARKS_ID_LEN) < BOOKMARKS_ID_LEN) goto error;
|
||||
if (!strcmp(bookmarks_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading Bookmarks
|
||||
FCEU_printf("No bookmarks in the file\n");
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
if (strcmp(bookmarks_save_id, save_id)) goto error; // string is not valid
|
||||
// read cloud time
|
||||
if ((int)is->fread(cloud_time, TIME_DESC_LENGTH) < TIME_DESC_LENGTH) return true;
|
||||
if ((int)is->fread(cloud_time, TIME_DESC_LENGTH) < TIME_DESC_LENGTH) goto error;
|
||||
// read current branch and flag of changes since it
|
||||
uint8 tmp;
|
||||
if (!read32le(¤t_branch, is)) return true;
|
||||
if (!read8le(&tmp, is)) return true;
|
||||
if (!read32le(¤t_branch, is)) goto error;
|
||||
if (!read8le(&tmp, is)) goto error;
|
||||
changes_since_current_branch = (tmp != 0);
|
||||
// read current_position time
|
||||
if ((int)is->fread(current_pos_time, TIME_DESC_LENGTH) < TIME_DESC_LENGTH) return true;
|
||||
if ((int)is->fread(current_pos_time, TIME_DESC_LENGTH) < TIME_DESC_LENGTH) goto error;
|
||||
// read all 10 bookmarks
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
{
|
||||
if (bookmarks_array[i].load(is)) return true;
|
||||
if (bookmarks_array[i].load(is)) goto error;
|
||||
}
|
||||
// all ok
|
||||
reset_vars();
|
||||
RedrawBookmarksCaption();
|
||||
return false;
|
||||
error:
|
||||
FCEU_printf("Error loading bookmarks\n");
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
void BOOKMARKS::RedrawBookmarksCaption()
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
void reset_vars();
|
||||
void update();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
void set(int slot);
|
||||
|
|
|
@ -16,6 +16,7 @@ extern bool TASEdit_restore_position;
|
|||
extern void FCEU_printf(char *format, ...);
|
||||
|
||||
char greenzone_save_id[GREENZONE_ID_LEN] = "GREENZONE";
|
||||
char greenzone_skipsave_id[GREENZONE_ID_LEN] = "GREENZONX";
|
||||
|
||||
GREENZONE::GREENZONE()
|
||||
{
|
||||
|
@ -182,44 +183,60 @@ void GREENZONE::ClearSavestate(int index)
|
|||
savestates[index].swap(tmp);
|
||||
}
|
||||
|
||||
void GREENZONE::save(EMUFILE *os)
|
||||
void GREENZONE::save(EMUFILE *os, bool really_save)
|
||||
{
|
||||
int frame, size;
|
||||
int last_tick = 0;
|
||||
// write "GREENZONE" string
|
||||
os->fwrite(greenzone_save_id, GREENZONE_ID_LEN);
|
||||
// write size
|
||||
write32le(greenZoneCount, os);
|
||||
// compress and write lag history
|
||||
int len = lag_history.size();
|
||||
uLongf comprlen = (len>>9)+12 + len;
|
||||
std::vector<uint8> cbuf(comprlen);
|
||||
compress(&cbuf[0], &comprlen, &lag_history[0], len);
|
||||
write32le(comprlen, os);
|
||||
os->fwrite(&cbuf[0], comprlen);
|
||||
// write playback position
|
||||
write32le(currFrameCounter, os);
|
||||
// write savestates
|
||||
GreenzoneCleaning();
|
||||
for (frame = 0; frame < greenZoneCount; ++frame)
|
||||
if (really_save)
|
||||
{
|
||||
// update TASEditor progressbar from time to time
|
||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||
// write "GREENZONE" string
|
||||
os->fwrite(greenzone_save_id, GREENZONE_ID_LEN);
|
||||
// write size
|
||||
write32le(greenZoneCount, os);
|
||||
// compress and write lag history
|
||||
int len = lag_history.size();
|
||||
uLongf comprlen = (len>>9)+12 + len;
|
||||
std::vector<uint8> cbuf(comprlen);
|
||||
compress(&cbuf[0], &comprlen, &lag_history[0], len);
|
||||
write32le(comprlen, os);
|
||||
os->fwrite(&cbuf[0], comprlen);
|
||||
// write playback position
|
||||
write32le(currFrameCounter, os);
|
||||
// write savestates
|
||||
int frame, size;
|
||||
int last_tick = 0;
|
||||
GreenzoneCleaning();
|
||||
for (frame = 0; frame < greenZoneCount; ++frame)
|
||||
{
|
||||
playback.SetProgressbar(frame, greenZoneCount);
|
||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||
// update TASEditor progressbar from time to time
|
||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||
{
|
||||
playback.SetProgressbar(frame, greenZoneCount);
|
||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||
}
|
||||
if (savestates[frame].empty()) continue;
|
||||
write32le(frame, os);
|
||||
// write lua_colorings
|
||||
// write monitorings
|
||||
// write savestate
|
||||
size = savestates[frame].size();
|
||||
write32le(size, os);
|
||||
os->fwrite(&savestates[frame][0], size);
|
||||
}
|
||||
// write -1 as eof for greenzone
|
||||
write32le(-1, os);
|
||||
} else
|
||||
{
|
||||
// write "GREENZONX" string
|
||||
os->fwrite(greenzone_skipsave_id, GREENZONE_ID_LEN);
|
||||
// write playback position
|
||||
write32le(currFrameCounter, os);
|
||||
if (currFrameCounter > 0)
|
||||
{
|
||||
// write ONE savestate for currFrameCounter
|
||||
int size = savestates[currFrameCounter].size();
|
||||
write32le(size, os);
|
||||
os->fwrite(&savestates[currFrameCounter][0], size);
|
||||
}
|
||||
if (savestates[frame].empty()) continue;
|
||||
write32le(frame, os);
|
||||
// write lua_colorings
|
||||
// write monitorings
|
||||
// write savestate
|
||||
size = savestates[frame].size();
|
||||
write32le(size, os);
|
||||
os->fwrite(&savestates[frame][0], size);
|
||||
}
|
||||
// write -1 as eof for greenzone
|
||||
write32le(-1, os);
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool GREENZONE::load(EMUFILE *is)
|
||||
|
@ -230,6 +247,41 @@ bool GREENZONE::load(EMUFILE *is)
|
|||
// read "GREENZONE" string
|
||||
char save_id[GREENZONE_ID_LEN];
|
||||
if ((int)is->fread(save_id, GREENZONE_ID_LEN) < GREENZONE_ID_LEN) goto error;
|
||||
if (!strcmp(greenzone_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading Greenzone
|
||||
// read playback position
|
||||
if (read32le(&frame, is))
|
||||
{
|
||||
currFrameCounter = frame;
|
||||
greenZoneCount = currFrameCounter + 1;
|
||||
savestates.resize(greenZoneCount);
|
||||
if (currFrameCounter)
|
||||
{
|
||||
// there must be one savestate in the file
|
||||
if (read32le(&size, is) && size >= 0)
|
||||
{
|
||||
savestates[frame].resize(size);
|
||||
if (is->fread(&savestates[frame][0], size) == size)
|
||||
{
|
||||
if (loadTasSavestate(currFrameCounter))
|
||||
{
|
||||
FCEU_printf("No greenzone in the file\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
// literally no greenzone in the file, but this is still not a error
|
||||
reset();
|
||||
playback.StartFromZero(); // reset playback to frame 0
|
||||
FCEU_printf("No greenzone in the file, playback at frame 0\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
if (strcmp(greenzone_save_id, save_id)) goto error; // string is not valid
|
||||
// read size
|
||||
if (read32le(&size, is) && size >= 0 && size <= currMovieData.getNumRecords())
|
||||
|
@ -315,6 +367,9 @@ bool GREENZONE::load(EMUFILE *is)
|
|||
}
|
||||
}
|
||||
error:
|
||||
FCEU_printf("Error loading greenzone\n");
|
||||
reset();
|
||||
playback.StartFromZero(); // reset playback to frame 0
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
void free();
|
||||
void update();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
void TryDumpIncremental(bool lagFlag = true);
|
||||
|
|
|
@ -20,6 +20,7 @@ extern TASEDIT_PROJECT project;
|
|||
extern TASEDIT_LIST tasedit_list;
|
||||
|
||||
char history_save_id[HISTORY_ID_LEN] = "HISTORY";
|
||||
char history_skipsave_id[HISTORY_ID_LEN] = "HISTORX";
|
||||
char modCaptions[36][20] = {" Init",
|
||||
" Change",
|
||||
" Set",
|
||||
|
@ -476,20 +477,27 @@ void INPUT_HISTORY::RegisterImport(MovieData& md, char* filename)
|
|||
}
|
||||
}
|
||||
|
||||
void INPUT_HISTORY::save(EMUFILE *os)
|
||||
void INPUT_HISTORY::save(EMUFILE *os, bool really_save)
|
||||
{
|
||||
int real_pos, last_tick = 0;
|
||||
// write "HISTORY" string
|
||||
os->fwrite(history_save_id, HISTORY_ID_LEN);
|
||||
// write vars
|
||||
write32le(history_cursor_pos, os);
|
||||
write32le(history_total_items, os);
|
||||
// write snapshots starting from history_start_pos
|
||||
for (int i = 0; i < history_total_items; ++i)
|
||||
if (really_save)
|
||||
{
|
||||
real_pos = (history_start_pos + i) % history_size;
|
||||
input_snapshots[real_pos].save(os);
|
||||
playback.SetProgressbar(i, history_total_items);
|
||||
int real_pos, last_tick = 0;
|
||||
// write "HISTORY" string
|
||||
os->fwrite(history_save_id, HISTORY_ID_LEN);
|
||||
// write vars
|
||||
write32le(history_cursor_pos, os);
|
||||
write32le(history_total_items, os);
|
||||
// write snapshots starting from history_start_pos
|
||||
for (int i = 0; i < history_total_items; ++i)
|
||||
{
|
||||
real_pos = (history_start_pos + i) % history_size;
|
||||
input_snapshots[real_pos].save(os);
|
||||
playback.SetProgressbar(i, history_total_items);
|
||||
}
|
||||
} else
|
||||
{
|
||||
// write "HISTORX" string
|
||||
os->fwrite(history_skipsave_id, HISTORY_ID_LEN);
|
||||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
|
@ -502,6 +510,13 @@ bool INPUT_HISTORY::load(EMUFILE *is)
|
|||
// read "HISTORY" string
|
||||
char save_id[HISTORY_ID_LEN];
|
||||
if ((int)is->fread(save_id, HISTORY_ID_LEN) < HISTORY_ID_LEN) goto error;
|
||||
if (!strcmp(history_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading History
|
||||
FCEU_printf("No history in the file\n");
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
if (strcmp(history_save_id, save_id)) goto error; // string is not valid
|
||||
// read vars
|
||||
if (!read32le(&history_cursor_pos, is)) goto error;
|
||||
|
@ -548,6 +563,8 @@ bool INPUT_HISTORY::load(EMUFILE *is)
|
|||
RedrawHistoryList();
|
||||
return false;
|
||||
error:
|
||||
FCEU_printf("Error loading history\n");
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
// ----------------------------
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
void reset();
|
||||
void update(); // called every frame
|
||||
|
||||
void save(EMUFILE *os);
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
int undo();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "zlib.h"
|
||||
|
||||
char markers_save_id[MARKERS_ID_LEN] = "MARKERS";
|
||||
char markers_skipsave_id[MARKERS_ID_LEN] = "MARKERX";
|
||||
|
||||
MARKERS::MARKERS()
|
||||
{
|
||||
|
@ -29,20 +30,27 @@ void MARKERS::update()
|
|||
markers_array.resize(currMovieData.getNumRecords());
|
||||
}
|
||||
|
||||
void MARKERS::save(EMUFILE *os)
|
||||
void MARKERS::save(EMUFILE *os, bool really_save)
|
||||
{
|
||||
// write "MARKERS" string
|
||||
os->fwrite(markers_save_id, MARKERS_ID_LEN);
|
||||
// write size
|
||||
int size = markers_array.size();
|
||||
write32le(size, os);
|
||||
// compress and write array
|
||||
int len = markers_array.size();
|
||||
uLongf comprlen = (len>>9)+12 + len;
|
||||
std::vector<uint8> cbuf(comprlen);
|
||||
compress(&cbuf[0], &comprlen, &markers_array[0], len);
|
||||
write32le(comprlen, os);
|
||||
os->fwrite(&cbuf[0], comprlen);
|
||||
if (really_save)
|
||||
{
|
||||
// write "MARKERS" string
|
||||
os->fwrite(markers_save_id, MARKERS_ID_LEN);
|
||||
// write size
|
||||
int size = markers_array.size();
|
||||
write32le(size, os);
|
||||
// compress and write array
|
||||
int len = markers_array.size();
|
||||
uLongf comprlen = (len>>9)+12 + len;
|
||||
std::vector<uint8> cbuf(comprlen);
|
||||
compress(&cbuf[0], &comprlen, &markers_array[0], len);
|
||||
write32le(comprlen, os);
|
||||
os->fwrite(&cbuf[0], comprlen);
|
||||
} else
|
||||
{
|
||||
// write "MARKERX" string
|
||||
os->fwrite(markers_skipsave_id, MARKERS_ID_LEN);
|
||||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool MARKERS::load(EMUFILE *is)
|
||||
|
@ -50,6 +58,13 @@ bool MARKERS::load(EMUFILE *is)
|
|||
// read "MARKERS" string
|
||||
char save_id[MARKERS_ID_LEN];
|
||||
if ((int)is->fread(save_id, MARKERS_ID_LEN) < MARKERS_ID_LEN) goto error;
|
||||
if (!strcmp(markers_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading Markers
|
||||
FCEU_printf("No markers in the file\n");
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
if (strcmp(markers_save_id, save_id)) goto error; // string is not valid
|
||||
int size;
|
||||
if (read32le((uint32 *)&size, is) && size >= currMovieData.getNumRecords())
|
||||
|
@ -67,6 +82,8 @@ bool MARKERS::load(EMUFILE *is)
|
|||
return false;
|
||||
}
|
||||
error:
|
||||
FCEU_printf("Error loading markers\n");
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
void free();
|
||||
void update();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
void MakeCopy(std::vector<uint8> &destination_array);
|
||||
|
|
|
@ -30,6 +30,7 @@ COLORREF hot_changes_colors[16] = { 0x0, 0x5c4c44, 0x854604, 0xab2500, 0xc20006,
|
|||
//COLORREF hot_changes_colors[16] = { 0x0, 0x661212, 0x842B4E, 0x652C73, 0x48247D, 0x383596, 0x2947AE, 0x1E53C1, 0x135DD2, 0x116EDA, 0x107EE3, 0x0F8EEB, 0x209FF4, 0x3DB1FD, 0x51C2FF, 0x4DCDFF };
|
||||
|
||||
char list_save_id[LIST_ID_LEN] = "LIST";
|
||||
char list_skipsave_id[LIST_ID_LEN] = "LISX";
|
||||
|
||||
TASEDIT_LIST::TASEDIT_LIST()
|
||||
{
|
||||
|
@ -184,15 +185,21 @@ void TASEDIT_LIST::update()
|
|||
|
||||
}
|
||||
|
||||
void TASEDIT_LIST::save(EMUFILE *os)
|
||||
void TASEDIT_LIST::save(EMUFILE *os, bool really_save)
|
||||
{
|
||||
update();
|
||||
// write "LIST" string
|
||||
os->fwrite(list_save_id, LIST_ID_LEN);
|
||||
// write current top item
|
||||
int top_item = ListView_GetTopIndex(hwndList);
|
||||
write32le(top_item, os);
|
||||
|
||||
if (really_save)
|
||||
{
|
||||
update();
|
||||
// write "LIST" string
|
||||
os->fwrite(list_save_id, LIST_ID_LEN);
|
||||
// write current top item
|
||||
int top_item = ListView_GetTopIndex(hwndList);
|
||||
write32le(top_item, os);
|
||||
} else
|
||||
{
|
||||
// write "LISX" string
|
||||
os->fwrite(list_skipsave_id, LIST_ID_LEN);
|
||||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool TASEDIT_LIST::load(EMUFILE *is)
|
||||
|
@ -201,15 +208,23 @@ bool TASEDIT_LIST::load(EMUFILE *is)
|
|||
// read "LIST" string
|
||||
char save_id[LIST_ID_LEN];
|
||||
if ((int)is->fread(save_id, LIST_ID_LEN) < LIST_ID_LEN) goto error;
|
||||
if (!strcmp(list_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading List
|
||||
FCEU_printf("No list data in the file\n");
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
if (strcmp(list_save_id, save_id)) goto error; // string is not valid
|
||||
// read current top item and scroll list there
|
||||
int top_item;
|
||||
if (!read32le(&top_item, is)) goto error;
|
||||
ListView_EnsureVisible(hwndList, currMovieData.getNumRecords() - 1, FALSE);
|
||||
ListView_EnsureVisible(hwndList, top_item, FALSE);
|
||||
|
||||
return false;
|
||||
error:
|
||||
FCEU_printf("Error loading list data\n");
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
void reset();
|
||||
void update();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
void AddFourscore();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "taseditproj.h"
|
||||
|
||||
char selection_save_id[SELECTION_ID_LEN] = "SELECTION";
|
||||
char selection_skipsave_id[SELECTION_ID_LEN] = "SELECTIOX";
|
||||
|
||||
extern HWND hwndTasEdit;
|
||||
extern int TasEdit_undo_levels;
|
||||
|
@ -55,7 +56,6 @@ void TASEDIT_SELECTION::reset()
|
|||
history_start_pos = 0;
|
||||
history_cursor_pos = -1;
|
||||
// create initial selection
|
||||
ClearSelection();
|
||||
AddNewSelectionToHistory();
|
||||
track_selection_changes = true;
|
||||
reset_vars();
|
||||
|
@ -213,20 +213,27 @@ void TASEDIT_SELECTION::JumpToFrame(int frame)
|
|||
tasedit_list.FollowSelection();
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
void TASEDIT_SELECTION::save(EMUFILE *os)
|
||||
void TASEDIT_SELECTION::save(EMUFILE *os, bool really_save)
|
||||
{
|
||||
// write "SELECTION" string
|
||||
os->fwrite(selection_save_id, SELECTION_ID_LEN);
|
||||
// write vars
|
||||
write32le(history_cursor_pos, os);
|
||||
write32le(history_total_items, os);
|
||||
// write selections starting from history_start_pos
|
||||
for (int i = 0; i < history_total_items; ++i)
|
||||
if (really_save)
|
||||
{
|
||||
saveSelection(selections_history[(history_start_pos + i) % history_size], os);
|
||||
// write "SELECTION" string
|
||||
os->fwrite(selection_save_id, SELECTION_ID_LEN);
|
||||
// write vars
|
||||
write32le(history_cursor_pos, os);
|
||||
write32le(history_total_items, os);
|
||||
// write selections starting from history_start_pos
|
||||
for (int i = 0; i < history_total_items; ++i)
|
||||
{
|
||||
saveSelection(selections_history[(history_start_pos + i) % history_size], os);
|
||||
}
|
||||
// write clipboard_selection
|
||||
saveSelection(clipboard_selection, os);
|
||||
} else
|
||||
{
|
||||
// write "SELECTIOX" string
|
||||
os->fwrite(selection_skipsave_id, SELECTION_ID_LEN);
|
||||
}
|
||||
// write clipboard_selection
|
||||
saveSelection(clipboard_selection, os);
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool TASEDIT_SELECTION::load(EMUFILE *is)
|
||||
|
@ -234,6 +241,13 @@ bool TASEDIT_SELECTION::load(EMUFILE *is)
|
|||
// read "SELECTION" string
|
||||
char save_id[SELECTION_ID_LEN];
|
||||
if ((int)is->fread(save_id, SELECTION_ID_LEN) < SELECTION_ID_LEN) goto error;
|
||||
if (!strcmp(selection_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading Selection
|
||||
FCEU_printf("No selection in the file\n");
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
if (strcmp(selection_save_id, save_id)) goto error; // string is not valid
|
||||
// read vars
|
||||
if (!read32le(&history_cursor_pos, is)) goto error;
|
||||
|
@ -278,6 +292,8 @@ bool TASEDIT_SELECTION::load(EMUFILE *is)
|
|||
reset_vars();
|
||||
return false;
|
||||
error:
|
||||
FCEU_printf("Error loading selection\n");
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
|
||||
void RedrawTextClipboard();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is);
|
||||
void saveSelection(SelectionFrames& selection, EMUFILE *os);
|
||||
bool loadSelection(SelectionFrames& selection, EMUFILE *is);
|
||||
|
|
|
@ -71,6 +71,24 @@ bool TASEDIT_PROJECT::save()
|
|||
this->reset();
|
||||
return true;
|
||||
}
|
||||
bool TASEDIT_PROJECT::save_compact(char* filename, bool save_binary, bool save_markers, bool save_bookmarks, bool save_greenzone, bool save_history, bool save_selection, bool save_list)
|
||||
{
|
||||
EMUFILE_FILE* ofs = FCEUD_UTF8_fstream(filename,"wb");
|
||||
|
||||
currMovieData.loadFrameCount = currMovieData.records.size();
|
||||
currMovieData.dump(ofs, save_binary);
|
||||
markers.save(ofs, save_markers);
|
||||
bookmarks.save(ofs, save_bookmarks);
|
||||
greenzone.save(ofs, save_greenzone);
|
||||
history.save(ofs, save_history);
|
||||
selection.save(ofs, save_selection);
|
||||
tasedit_list.save(ofs, save_list);
|
||||
|
||||
delete ofs;
|
||||
|
||||
playback.updateProgressbar();
|
||||
return true;
|
||||
}
|
||||
bool TASEDIT_PROJECT::load(char* fullname)
|
||||
{
|
||||
EMUFILE_FILE ifs(fullname, "rb");
|
||||
|
@ -83,74 +101,27 @@ bool TASEDIT_PROJECT::load(char* fullname)
|
|||
|
||||
FCEU_printf("\nLoading TAS Editor project %s...\n", fullname);
|
||||
|
||||
bool error;
|
||||
MovieData tempMovieData = MovieData();
|
||||
extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader);
|
||||
if (LoadFM2(currMovieData, &ifs, ifs.size(), false))
|
||||
if (LoadFM2(tempMovieData, &ifs, ifs.size(), false))
|
||||
{
|
||||
currMovieData = tempMovieData;
|
||||
LoadSubtitles(currMovieData);
|
||||
} else
|
||||
{
|
||||
FCEU_printf("Error loading movie data\n");
|
||||
error = true;
|
||||
}
|
||||
// try to load markers
|
||||
error = markers.load(&ifs);
|
||||
if (error)
|
||||
{
|
||||
FCEU_printf("Error loading markers\n");
|
||||
markers.reset();
|
||||
} else
|
||||
{
|
||||
// try to load bookmarks
|
||||
error = bookmarks.load(&ifs);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
FCEU_printf("Error loading bookmarks\n");
|
||||
bookmarks.reset();
|
||||
} else
|
||||
{
|
||||
// try to load greenzone
|
||||
error = greenzone.load(&ifs);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
FCEU_printf("Error loading greenzone\n");
|
||||
greenzone.reset();
|
||||
playback.StartFromZero(); // reset playback to frame 0
|
||||
} else
|
||||
{
|
||||
// try to load history
|
||||
error = history.load(&ifs);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
FCEU_printf("Error loading history\n");
|
||||
history.reset();
|
||||
} else
|
||||
{
|
||||
// try to load selection
|
||||
error = selection.load(&ifs);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
FCEU_printf("Error loading selection\n");
|
||||
selection.reset();
|
||||
} else
|
||||
{
|
||||
// update and try to load list
|
||||
error = tasedit_list.load(&ifs);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
FCEU_printf("Error loading list\n");
|
||||
tasedit_list.reset();
|
||||
FCEU_PrintError("Error loading movie data from %s!", fullname);
|
||||
return false;
|
||||
}
|
||||
markers.load(&ifs);
|
||||
bookmarks.load(&ifs);
|
||||
greenzone.load(&ifs);
|
||||
history.load(&ifs);
|
||||
selection.load(&ifs);
|
||||
tasedit_list.load(&ifs);
|
||||
|
||||
playback.reset();
|
||||
recorder.reset();
|
||||
screenshot_display.reset();
|
||||
|
||||
reset();
|
||||
RenameProject(fullname);
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
void update();
|
||||
|
||||
bool save();
|
||||
bool save_compact(char* filename, bool save_binary, bool save_markers, bool save_bookmarks, bool save_greenzone, bool save_history, bool save_selection, bool save_list);
|
||||
bool load(char* fullname);
|
||||
|
||||
void RenameProject(char* new_fullname);
|
||||
|
|
|
@ -1498,9 +1498,11 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
LoadNewGamey(hWnd, 0);
|
||||
if (GameInfo && !(fileDropped.find(".tas") == string::npos))
|
||||
{
|
||||
//.tas is at the end of the filename so that must be the extension
|
||||
FCEUI_LoadMovie(ftmp, 1, false); //We are convinced it is a TAS Editor project file, attempt to load and replay it
|
||||
FCEUX_LoadMovieExtras(ftmp);
|
||||
//.tas is at the end of the filename so that must be the extension
|
||||
extern bool EnterTasEdit();
|
||||
extern bool LoadProject(char* fullname);
|
||||
if (EnterTasEdit()) //We are convinced it is a TAS Editor project file, attempt to load in TAS Editor
|
||||
LoadProject(ftmp);
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------
|
||||
|
|
|
@ -593,9 +593,10 @@ static void LoadFM2_binarychunk(MovieData& movieData, EMUFILE* fp, int size)
|
|||
//yuck... another custom text parser.
|
||||
bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)
|
||||
{
|
||||
// if there's no "binary" tag in the movie header, consider it as a movie in text format
|
||||
movieData.binaryFlag = false;
|
||||
// Non-TASEditor projects consume until EOF
|
||||
std::string a("length"), b("-1");
|
||||
movieData.installValue(a, b);
|
||||
movieData.loadFrameCount = -1;
|
||||
|
||||
//first, look for an fcm signature
|
||||
char fcmbuf[3];
|
||||
|
@ -636,7 +637,9 @@ bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)
|
|||
{
|
||||
LoadFM2_binarychunk(movieData, fp, size);
|
||||
return true;
|
||||
}
|
||||
} else if (isnewline && movieData.loadFrameCount == movieData.records.size())
|
||||
// exit prematurely if loaded the specified amound of records
|
||||
return true;
|
||||
switch(state)
|
||||
{
|
||||
case NEWLINE:
|
||||
|
@ -1196,6 +1199,8 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size)
|
|||
if (EnterTasEdit())
|
||||
LoadProject(fullname);
|
||||
}
|
||||
#else
|
||||
FCEUI_printf("This movie is a TAS Editor project file! It can be modified in TAS Editor only.\nMovie is now Read-Only.\n");
|
||||
#endif
|
||||
movie_readonly = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue