* Tasedit: Config->Set autosave period

* Tasedit: bugfixes
This commit is contained in:
ansstuff 2011-11-12 18:08:09 +00:00
parent 724616f718
commit 398eb98b93
14 changed files with 131 additions and 67 deletions

View File

@ -65,7 +65,7 @@ DWEdit
Debugger additions Debugger additions
AnS - ansstuff at yandex dot ru (sf:ansstuff) AnS - ansstuff at yandex dot ru (sf:ansstuff)
TASEdit enhancements Bugfixes and additions, TASEdit v1.0
---------linux devvers--------- ---------linux devvers---------
>= 2.0 - These guys concentrated on keeping fceux the premiere >= 2.0 - These guys concentrated on keeping fceux the premiere

View File

@ -1,16 +1,34 @@
04-novm-2011 - prg318 - gtk: added option for frameskipping and made label case consistent in gui
23-octo-2011 - prg318 - sdl: fix a bug where alt key would get "stuck" when alt tabbing to window 12-nov-2011 - AnS - Tasedit: project autosaving
19-octo-2011 - prg318 - scons: "scons install" now installs auxlib and manpage 10-nov-2011 - AnS - Tasedit: Branches show saved screenshot on mouseover (alpha-fade popup window)
19-octo-2011 - prg318 - scons: added --prefix option to build system and improved "install" target 7-nov-2011 - AnS - Tasedit: Drawing Branches Tree (using GDI), animations, transitions, mouseover
18-octo-2011 - prg318 - sdl: new hotkeys added - statestatenext savestateprev - useful for scrolling through savestates on a gamepad. mapped to pgup and pgdown by default 04-nov-2011 - prg318 - gtk: added option for frameskipping and made label case consistent in gui
18-octo-2011 - prg318 - gtk: new video option for double buffering and ClipSides 1-nov-2011 - zeromus - debugger - fix mysterious out of bounds condition while editing breakpoints
18-octo-2011 - prg318 - sdl: GTK3 support is now functional. Set GTK3 to 1 in the SConstruct to try it out. 31-oct-2011 - zeromus - add winapi lua library
18-octo-2011 - prg318 - no longer use depreciated gtk2 functions 31-oct-2011 - zeromus - fix newppu bug; chr ram was not getting initialized to anything
18-octo-2011 - prg318 - getSDLKey tool added to assist in remapping hotkeys 28-oct-2011 - AnS - Switching Tasedit Bg input on/off when Tasedit gets/loses focus (allows FCEUX control without "Bg input")
17-octo-2011 - prg318 - some segfaults fixed, also fixed some build errors 27-oct-2011 - AnS - "Toggle Rerecord Display" hotkey (M), "Play Movie From Beginning" hotkey also works in Tasedit
17-octo-2011 - prg318 - sdl netplay fixed 27-oct-2011 - AnS - Tasedit: Bookmarks/Branches
07-octo-2011 - prg318 - sdl: fixed some issues with --nogui . "--nogui" no longer requires an argument and can be used like this "$ fceux --nogui rom.nes" 23-oct-2011 - prg318 - sdl: fix a bug where alt key would get "stuck" when alt tabbing to window
07-octo-2011 - prg318 - gtk: support mouseclicks (ie zapper) 21-oct-2011 - AnS - Tasedit: gradual greenzone cleaning
19-oct-2011 - prg318 - scons: "scons install" now installs auxlib and manpage
19-oct-2011 - prg318 - scons: added --prefix option to build system and improved "install" target
18-oct-2011 - prg318 - sdl: new hotkeys added - statestatenext savestateprev - useful for scrolling through savestates on a gamepad. mapped to pgup and pgdown by default
18-oct-2011 - prg318 - gtk: new video option for double buffering and ClipSides
18-oct-2011 - prg318 - sdl: GTK3 support is now functional. Set GTK3 to 1 in the SConstruct to try it out.
18-oct-2011 - prg318 - no longer use depreciated gtk2 functions
18-oct-2011 - prg318 - getSDLKey tool added to assist in remapping hotkeys
17-oct-2011 - prg318 - some segfaults fixed, also fixed some build errors
17-oct-2011 - prg318 - sdl netplay fixed
15-oct-2011 - zeromus - don't lose cheat compare value when toggle cheat enables through UI
14-oct-2011 - AnS - added rewind hotkey (~), works only in Taseditor
14-oct-2011 - AnS - Tasedit: execute lua functions when jumping inside greenzone
13-oct-2011 - AnS - Tasedit: major refactoring
9-oct-2011 - AnS - Tasedit: input history, undo, redo; greenzone reduces only from the point where actual differences were found
07-oct-2011 - prg318 - sdl: fixed some issues with --nogui . "--nogui" no longer requires an argument and can be used like this "$ fceux --nogui rom.nes"
07-oct-2011 - prg318 - gtk: support mouseclicks (ie zapper)
03-oct-2011 - AnS - Tasedit: Clone Frame(s)
02-oct-2011 - AnS - Tasedit: Markers
30-sept-2011 - AnS - logging all display messages to Message Log 30-sept-2011 - AnS - logging all display messages to Message Log
30-sept-2011 - AnS - Tasedit: special method of inserting frames; progressbar updating when loading/saving large projects; moved "Follow cursor" checkbox from View menu to main TASEdit window 30-sept-2011 - AnS - Tasedit: special method of inserting frames; progressbar updating when loading/saving large projects; moved "Follow cursor" checkbox from View menu to main TASEdit window
30-sept-2011 - AnS - Tasedit: View->Show dot in empty cells; ClearFrames (Del), Cut operation clears frames instead of deleting; checking unsaved project on Exit and Open project 30-sept-2011 - AnS - Tasedit: View->Show dot in empty cells; ClearFrames (Del), Cut operation clears frames instead of deleting; checking unsaved project on Exit and Open project

View File

@ -80,6 +80,7 @@ extern bool TASEdit_restore_position;
extern bool TASEdit_show_dot; extern bool TASEdit_show_dot;
extern int TASEdit_greenzone_capacity; extern int TASEdit_greenzone_capacity;
extern int TasEdit_undo_levels; extern int TasEdit_undo_levels;
extern int TASEdit_autosave_period;
extern bool TASEdit_jump_to_undo; extern bool TASEdit_jump_to_undo;
//window positions and sizes: //window positions and sizes:
@ -310,6 +311,7 @@ static CFGSTRUCT fceuconfig[] = {
AC(TASEdit_show_dot), AC(TASEdit_show_dot),
AC(TASEdit_greenzone_capacity), AC(TASEdit_greenzone_capacity),
AC(TasEdit_undo_levels), AC(TasEdit_undo_levels),
AC(TASEdit_autosave_period),
AC(TASEdit_jump_to_undo), AC(TASEdit_jump_to_undo),
AC(lagCounterDisplay), AC(lagCounterDisplay),
AC(oldInputDisplay), AC(oldInputDisplay),

View File

@ -261,6 +261,7 @@ BEGIN
BEGIN BEGIN
MENUITEM "Set &greenzone capacity", ID_CONFIG_SETGREENZONECAPACITY MENUITEM "Set &greenzone capacity", ID_CONFIG_SETGREENZONECAPACITY
MENUITEM "Set max &undo levels", ID_CONFIG_SETMAXUNDOLEVELS MENUITEM "Set max &undo levels", ID_CONFIG_SETMAXUNDOLEVELS
MENUITEM "Set &autosave period", ID_CONFIG_SETAUTOSAVEPERIOD
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "Branches restore entire &Movie", ID_CONFIG_BRANCHESRESTOREFULLMOVIE MENUITEM "Branches restore entire &Movie", ID_CONFIG_BRANCHESRESTOREFULLMOVIE
MENUITEM "Branches work only when &Recording", ID_CONFIG_BRANCHESWORKONLYWHENRECORDING MENUITEM "Branches work only when &Recording", ID_CONFIG_BRANCHESWORKONLYWHENRECORDING

View File

@ -892,6 +892,7 @@
#define ID_CONFIG_BRANCHESRESTOREFULLMOVIE 40473 #define ID_CONFIG_BRANCHESRESTOREFULLMOVIE 40473
#define ID_CONFIG_BRANCHESWORKONLYWHENRECORDING 40474 #define ID_CONFIG_BRANCHESWORKONLYWHENRECORDING 40474
#define ID_CONFIG_HUDINBRANCHSCREENSHOTS 40475 #define ID_CONFIG_HUDINBRANCHSCREENSHOTS 40475
#define ID_CONFIG_SETAUTOSAVEPERIOD 40476
#define IDC_DEBUGGER_ICONTRAY 55535 #define IDC_DEBUGGER_ICONTRAY 55535
#define MW_ValueLabel2 65423 #define MW_ValueLabel2 65423
#define MW_ValueLabel1 65426 #define MW_ValueLabel1 65426
@ -901,7 +902,7 @@
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 185 #define _APS_NEXT_RESOURCE_VALUE 185
#define _APS_NEXT_COMMAND_VALUE 40476 #define _APS_NEXT_COMMAND_VALUE 40477
#define _APS_NEXT_CONTROL_VALUE 1267 #define _APS_NEXT_CONTROL_VALUE 1267
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif

View File

@ -26,7 +26,6 @@ bool old_movie_readonly;
bool TASEdit_focus = false; bool TASEdit_focus = false;
bool Tasedit_rewind_now = false; bool Tasedit_rewind_now = false;
int listItems; // number of items per list page int listItems; // number of items per list page
int list_row_height; // in pixels
// saved FCEU config // saved FCEU config
int saved_eoptions; int saved_eoptions;
int saved_EnableAutosave; int saved_EnableAutosave;
@ -44,9 +43,10 @@ bool TASEdit_view_branches_tree = false;
bool TASEdit_branch_scr_hud = true; bool TASEdit_branch_scr_hud = true;
bool TASEdit_restore_position = false; bool TASEdit_restore_position = false;
int TASEdit_greenzone_capacity = GREENZONE_CAPACITY_DEFAULT; int TASEdit_greenzone_capacity = GREENZONE_CAPACITY_DEFAULT;
int TasEdit_undo_levels = UNDO_LEVELS_DEFAULT;
int TASEdit_autosave_period = AUTOSAVE_PERIOD_DEFAULT;
extern bool muteTurbo; extern bool muteTurbo;
bool TASEdit_show_dot = true; bool TASEdit_show_dot = true;
int TasEdit_undo_levels = UNDO_LEVELS_DEFAULT;
bool TASEdit_jump_to_undo = true; bool TASEdit_jump_to_undo = true;
string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page
@ -170,19 +170,19 @@ LONG CustomDraw(NMLVCUSTOMDRAW* msg)
if (cell_y == history.GetUndoHint()) if (cell_y == history.GetUndoHint())
{ {
// undo hint here // undo hint here
if(TASEdit_show_markers && (markers.markers_array[cell_y] & MARKER_FLAG_BIT)) if(TASEdit_show_markers && (int)markers.markers_array.size() > cell_y && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
msg->clrTextBk = MARKED_UNDOHINT_FRAMENUM_COLOR; msg->clrTextBk = MARKED_UNDOHINT_FRAMENUM_COLOR;
else else
msg->clrTextBk = UNDOHINT_FRAMENUM_COLOR; msg->clrTextBk = UNDOHINT_FRAMENUM_COLOR;
} else if (cell_y == currFrameCounter || cell_y == playback.GetPauseFrame()) } else if (cell_y == currFrameCounter || cell_y == playback.GetPauseFrame())
{ {
// current frame // current frame
if(TASEdit_show_markers && (markers.markers_array[cell_y] & MARKER_FLAG_BIT)) if(TASEdit_show_markers && (int)markers.markers_array.size() > cell_y && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
// this frame is also marked // this frame is also marked
msg->clrTextBk = CUR_MARKED_FRAMENUM_COLOR; msg->clrTextBk = CUR_MARKED_FRAMENUM_COLOR;
else else
msg->clrTextBk = CUR_FRAMENUM_COLOR; msg->clrTextBk = CUR_FRAMENUM_COLOR;
} else if(TASEdit_show_markers && (markers.markers_array[cell_y] & MARKER_FLAG_BIT)) } else if(TASEdit_show_markers && (int)markers.markers_array.size() > cell_y && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
{ {
// marked frame // marked frame
msg->clrTextBk = MARKED_FRAMENUM_COLOR; msg->clrTextBk = MARKED_FRAMENUM_COLOR;
@ -283,11 +283,11 @@ void UpdateTasEdit()
playback.update(); playback.update();
bookmarks.update(); bookmarks.update();
history.update(); history.update();
project.update();
// update window caption // update window caption
if (project.old_changed != project.changed || old_movie_readonly != movie_readonly || old_multitrack_recording_joypad != multitrack_recording_joypad) if (old_movie_readonly != movie_readonly || old_multitrack_recording_joypad != multitrack_recording_joypad)
RedrawWindowCaption(); RedrawWindowCaption();
project.update();
// update Bookmarks/Branches groupbox caption // update Bookmarks/Branches groupbox caption
if (TASEdit_branch_only_when_rec && old_movie_readonly != movie_readonly) if (TASEdit_branch_only_when_rec && old_movie_readonly != movie_readonly)
@ -343,7 +343,7 @@ void RedrawWindowCaption()
strcat(windowCaption, projectname.c_str()); strcat(windowCaption, projectname.c_str());
} }
// and * if project has unsaved changes // and * if project has unsaved changes
if (project.changed) if (project.GetProjectChanged())
strcat(windowCaption, "*"); strcat(windowCaption, "*");
SetWindowText(hwndTasEdit, windowCaption); SetWindowText(hwndTasEdit, windowCaption);
} }
@ -469,7 +469,7 @@ void SingleClick(LPNMITEMACTIVATE info)
history.RegisterChanges(MODTYPE_MARKER_SET, row_index); history.RegisterChanges(MODTYPE_MARKER_SET, row_index);
else else
history.RegisterChanges(MODTYPE_MARKER_UNSET, row_index); history.RegisterChanges(MODTYPE_MARKER_UNSET, row_index);
project.changed = true; project.SetProjectChanged();
// deselect this row, so that new marker will be seen immediately // deselect this row, so that new marker will be seen immediately
ListView_SetItemState(hwndList, row_index, 0, LVIS_SELECTED); ListView_SetItemState(hwndList, row_index, 0, LVIS_SELECTED);
ListView_SetItemState(hwndList, -1, LVIS_FOCUSED, LVIS_FOCUSED); ListView_SetItemState(hwndList, -1, LVIS_FOCUSED, LVIS_FOCUSED);
@ -646,7 +646,7 @@ void ColumnSet(int column)
markers.markers_array[*it] &= ~MARKER_FLAG_BIT; markers.markers_array[*it] &= ~MARKER_FLAG_BIT;
history.RegisterChanges(MODTYPE_MARKER_UNSET, *selectionFrames.begin(), *selectionFrames.rbegin()); history.RegisterChanges(MODTYPE_MARKER_UNSET, *selectionFrames.begin(), *selectionFrames.rbegin());
} }
project.changed = true; project.SetProjectChanged();
ClearSelection(); ClearSelection();
// no need to RedrawList(); // no need to RedrawList();
} else } else
@ -986,7 +986,7 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
return 0; return 0;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
if (!bookmarks.mouse_over_bitmap) if (!bookmarks.mouse_over_bookmarkslist)
{ {
bookmarks.mouse_over_bookmarkslist = true; bookmarks.mouse_over_bookmarkslist = true;
bookmarks.list_tme.hwndTrack = hWnd; bookmarks.list_tme.hwndTrack = hWnd;
@ -1152,9 +1152,6 @@ void OpenProject()
{ {
if (!AskSaveProject()) return; if (!AskSaveProject()) return;
//If OPENFILENAME dialog successful, open up a completely new project instance and scrap the old one
//Run the project Load() function to pull all info from the .tas file into this new project instance
const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0\0"; const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0\0";
OPENFILENAME ofn; OPENFILENAME ofn;
@ -1164,10 +1161,8 @@ void OpenProject()
ofn.lpstrTitle="Open TASEdit Project..."; ofn.lpstrTitle="Open TASEdit Project...";
ofn.lpstrFilter=TPfilter; ofn.lpstrFilter=TPfilter;
//TODO - this is a bug, as GetRomName() returns archive.7z|game.rom and that confuses GetOpenFileName() char nameo[2048];
//we need to use a different function to get a friendlier name (same as savestates and fm2 and the like) strcpy(nameo, mass_replace(GetRomName(),"|",".").c_str()); //convert | to . for archive filenames
char nameo[2048]; //File name
strcpy(nameo, GetRomName()); //For now, just use ROM name
ofn.lpstrFile=nameo; ofn.lpstrFile=nameo;
ofn.nMaxFile=256; ofn.nMaxFile=256;
@ -1225,10 +1220,9 @@ bool SaveProjectAs()
ofn.lpstrTitle="Save TASEdit Project As..."; ofn.lpstrTitle="Save TASEdit Project As...";
ofn.lpstrFilter=TPfilter; ofn.lpstrFilter=TPfilter;
char nameo[2048]; //File name char nameo[2048];
strcpy(nameo, GetRomName()); //For now, just use ROM name strcpy(nameo, mass_replace(GetRomName(),"|",".").c_str()); //convert | to . for archive filenames
ofn.lpstrFile = nameo;
ofn.lpstrFile=nameo; //More parameters
ofn.lpstrDefExt="tas"; ofn.lpstrDefExt="tas";
ofn.nMaxFile=256; ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
@ -1265,7 +1259,7 @@ bool SaveProject()
bool AskSaveProject() bool AskSaveProject()
{ {
bool changes_found = false; bool changes_found = false;
if (project.changed) changes_found = true; if (project.GetProjectChanged()) changes_found = true;
// ask saving project // ask saving project
if (changes_found) if (changes_found)
@ -1638,9 +1632,8 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
case ID_CONFIG_SETGREENZONECAPACITY: case ID_CONFIG_SETGREENZONECAPACITY:
{ {
//open input dialog
int new_capacity = TASEdit_greenzone_capacity; int new_capacity = TASEdit_greenzone_capacity;
if(CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?", new_capacity, hwndDlg) == IDOK) if(CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?\n(actual limit of savestates can be 5 times more than the number provided)", new_capacity, hwndDlg) == IDOK)
{ {
if (new_capacity < GREENZONE_CAPACITY_MIN) if (new_capacity < GREENZONE_CAPACITY_MIN)
new_capacity = GREENZONE_CAPACITY_MIN; new_capacity = GREENZONE_CAPACITY_MIN;
@ -1656,7 +1649,6 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
} }
case ID_CONFIG_SETMAXUNDOLEVELS: case ID_CONFIG_SETMAXUNDOLEVELS:
{ {
//open input dialog
int new_size = TasEdit_undo_levels; int new_size = TasEdit_undo_levels;
if(CWin32InputBox::GetInteger("Max undo levels", "Keep history of how many changes?", new_size, hwndDlg) == IDOK) if(CWin32InputBox::GetInteger("Max undo levels", "Keep history of how many changes?", new_size, hwndDlg) == IDOK)
{ {
@ -1674,6 +1666,20 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
} }
break; break;
} }
case ID_CONFIG_SETAUTOSAVEPERIOD:
{
int new_period = TASEdit_autosave_period;
if(CWin32InputBox::GetInteger("Autosave period", "How many minutes may the project stay not saved after being changed?\n(0 = no autosaves)", new_period, hwndDlg) == IDOK)
{
if (new_period < AUTOSAVE_PERIOD_MIN)
new_period = AUTOSAVE_PERIOD_MIN;
else if (new_period > AUTOSAVE_PERIOD_MAX)
new_period = AUTOSAVE_PERIOD_MAX;
TASEdit_autosave_period = new_period;
project.SheduleNextAutosave();
}
break;
}
case ID_CONFIG_MUTETURBO: case ID_CONFIG_MUTETURBO:
muteTurbo ^= 1; muteTurbo ^= 1;
CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED);

View File

@ -11,6 +11,11 @@
#define GREENZONE_CAPACITY_MIN 1 #define GREENZONE_CAPACITY_MIN 1
#define GREENZONE_CAPACITY_MAX 50000 #define GREENZONE_CAPACITY_MAX 50000
#define AUTOSAVE_PERIOD_SCALE 60000 // = 1 minute in milliseconds
#define AUTOSAVE_PERIOD_DEFAULT 10 // in minutes
#define AUTOSAVE_PERIOD_MIN 0 // 0 = no autosave
#define AUTOSAVE_PERIOD_MAX 60 // 1 hour
#define UNDO_LEVELS_MIN 1 #define UNDO_LEVELS_MIN 1
#define UNDO_LEVELS_MAX 999 #define UNDO_LEVELS_MAX 999
#define UNDO_LEVELS_DEFAULT 100 #define UNDO_LEVELS_DEFAULT 100

View File

@ -31,15 +31,13 @@ void BOOKMARK::set()
snapshot.jump_frame = currFrameCounter; snapshot.jump_frame = currFrameCounter;
savestate = greenzone.savestates[currFrameCounter]; savestate = greenzone.savestates[currFrameCounter];
// save screenshot // save screenshot
std::vector<uint8> temp_screenshot(SCREENSHOT_SIZE);
if (TASEdit_branch_scr_hud)
memcpy(&temp_screenshot[0], &XBuf[0], SCREENSHOT_SIZE);
else
memcpy(&temp_screenshot[0], &XBackBuf[0], SCREENSHOT_SIZE);
// compress the screenshot
uLongf comprlen = (SCREENSHOT_SIZE>>9)+12 + SCREENSHOT_SIZE; uLongf comprlen = (SCREENSHOT_SIZE>>9)+12 + SCREENSHOT_SIZE;
saved_screenshot.resize(comprlen); saved_screenshot.resize(comprlen);
compress(&saved_screenshot[0], &comprlen, &temp_screenshot[0], SCREENSHOT_SIZE); // compress screenshot data
if (TASEdit_branch_scr_hud)
compress(&saved_screenshot[0], &comprlen, XBuf, SCREENSHOT_SIZE);
else
compress(&saved_screenshot[0], &comprlen, XBackBuf, SCREENSHOT_SIZE);
saved_screenshot.resize(comprlen); saved_screenshot.resize(comprlen);
not_empty = true; not_empty = true;

View File

@ -9,6 +9,11 @@
#define SCREENSHOT_HEIGHT 240 #define SCREENSHOT_HEIGHT 240
#define SCREENSHOT_SIZE SCREENSHOT_WIDTH * SCREENSHOT_HEIGHT #define SCREENSHOT_SIZE SCREENSHOT_WIDTH * SCREENSHOT_HEIGHT
#define PARENT_RELATION_SAME 0 // Yellow-blue: this child has absolutely the same input as its parent, although maybe different jump_frame. Input sizes must be equal too.
#define PARENT_RELATION_DIRECT 1 // Green-blue: the child has the same input at least until parent's jump_frame. Child's jump_frame can be higher or lower than parent's jump_frame (doesn't matter), but if child's input is shorter than parent's input, it is considered different if parent has non-null input after child's input ends.
#define PARENT_RELATION_ORPHAN 2 // Red-blue: child has different input before parent's jump_frame, so their inheritance may be illogical.
#define PARENT_RELATION_ATTACHED 3 // Blue: normal parent was lost due to different input before its jump_frame, so new parent was found. Essentially this is the same as PARENT_RELATION_DIRECT, but this also adds small notification that parent was inherited by autofinding system rather that by normal chain of user-made events (this notification may be useful for something).
class BOOKMARK class BOOKMARK
{ {
public: public:
@ -29,6 +34,7 @@ public:
std::vector<uint8> savestate; std::vector<uint8> savestate;
std::vector<uint8> saved_screenshot; std::vector<uint8> saved_screenshot;
int parent_branch; int parent_branch;
int parent_relation;
private: private:

View File

@ -47,8 +47,6 @@ extern bool TASEdit_branch_full_movie;
extern bool TASEdit_branch_only_when_rec; extern bool TASEdit_branch_only_when_rec;
extern bool TASEdit_view_branches_tree; extern bool TASEdit_view_branches_tree;
extern int list_row_height;
BOOKMARKS::BOOKMARKS() BOOKMARKS::BOOKMARKS()
{ {
// create font // create font
@ -395,7 +393,7 @@ void BOOKMARKS::set(int slot)
must_recalculate_branches_tree = true; must_recalculate_branches_tree = true;
current_branch = slot; current_branch = slot;
changes_since_current_branch = false; changes_since_current_branch = false;
project.changed = true; project.SetProjectChanged();
if (previous_frame >= 0 && previous_frame != currFrameCounter) if (previous_frame >= 0 && previous_frame != currFrameCounter)
RedrawRowAndBookmark(previous_frame); RedrawRowAndBookmark(previous_frame);
@ -438,7 +436,7 @@ void BOOKMARKS::unleash(int slot)
if (bookmarks_array[slot].snapshot.checkMarkersDiff()) if (bookmarks_array[slot].snapshot.checkMarkersDiff())
{ {
bookmarks_array[slot].snapshot.toMarkers(); bookmarks_array[slot].snapshot.toMarkers();
project.changed = true; project.SetProjectChanged();
markers_changed = true; markers_changed = true;
} }
} }
@ -472,7 +470,7 @@ void BOOKMARKS::unleash(int slot)
if (bookmarks_array[slot].snapshot.checkMarkersDiff(jump_frame)) if (bookmarks_array[slot].snapshot.checkMarkersDiff(jump_frame))
{ {
bookmarks_array[slot].snapshot.copyToMarkers(jump_frame-1); bookmarks_array[slot].snapshot.copyToMarkers(jump_frame-1);
project.changed = true; project.SetProjectChanged();
markers_changed = true; markers_changed = true;
} }
} }
@ -1299,19 +1297,15 @@ LRESULT CALLBACK ScrBmpWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lP
{ {
switch(message) switch(message)
{ {
HWND logo;
case WM_CREATE: case WM_CREATE:
{ {
// create static bitmap placeholder
scr_bmp_pic = CreateWindow(WC_STATIC, NULL, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 255, 255, hwnd, NULL, NULL, NULL); scr_bmp_pic = CreateWindow(WC_STATIC, NULL, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 255, 255, hwnd, NULL, NULL, NULL);
break; return 0;
} }
case WM_DESTROY:
PostQuitMessage(0);
break;
default: default:
return DefWindowProc(hwnd, message, wParam, lParam); return DefWindowProc(hwnd, message, wParam, lParam);
} }
return 0;
} }

View File

@ -322,7 +322,7 @@ void GREENZONE::InvalidateAndCheck(int after)
{ {
if (after >= 0) if (after >= 0)
{ {
project.changed = true; project.SetProjectChanged();
if (greenZoneCount > after+1) if (greenZoneCount > after+1)
{ {
greenZoneCount = after+1; greenZoneCount = after+1;
@ -345,7 +345,7 @@ void GREENZONE::Invalidate(int after)
{ {
if (after >= 0) if (after >= 0)
{ {
project.changed = true; project.SetProjectChanged();
if (greenZoneCount > after+1) if (greenZoneCount > after+1)
{ {
greenZoneCount = after+1; greenZoneCount = after+1;

View File

@ -137,7 +137,7 @@ int INPUT_HISTORY::jump(int new_pos)
if (input_snapshots[real_pos].checkMarkersDiff()) if (input_snapshots[real_pos].checkMarkersDiff())
{ {
input_snapshots[real_pos].toMarkers(); input_snapshots[real_pos].toMarkers();
project.changed = true; project.SetProjectChanged();
markers_changed = true; markers_changed = true;
} }
} }

View File

@ -2,6 +2,7 @@
#include "../main.h" #include "../main.h"
#include "taseditproj.h" #include "taseditproj.h"
#include "../tasedit.h"
extern MARKERS markers; extern MARKERS markers;
extern BOOKMARKS bookmarks; extern BOOKMARKS bookmarks;
@ -10,6 +11,7 @@ extern PLAYBACK playback;
extern INPUT_HISTORY history; extern INPUT_HISTORY history;
extern void FCEU_printf(char *format, ...); extern void FCEU_printf(char *format, ...);
extern int TASEdit_autosave_period;
TASEDIT_PROJECT::TASEDIT_PROJECT() //Non parameterized constructor, loads project with default values TASEDIT_PROJECT::TASEDIT_PROJECT() //Non parameterized constructor, loads project with default values
{ {
@ -28,13 +30,18 @@ void TASEDIT_PROJECT::init()
} }
void TASEDIT_PROJECT::reset() void TASEDIT_PROJECT::reset()
{ {
old_changed = changed = false; changed = false;
} }
void TASEDIT_PROJECT::update() void TASEDIT_PROJECT::update()
{ {
old_changed = changed; // if it's time to autosave - save
if (changed && TASEdit_autosave_period && clock() >= next_save_shedule)
{
SaveProject();
// in case user pressed Cancel, postpone saving to next time
SheduleNextAutosave();
}
} }
@ -139,3 +146,22 @@ void TASEDIT_PROJECT::SetProjectFile(std::string e)
projectFile = e; projectFile = e;
} }
void TASEDIT_PROJECT::SetProjectChanged()
{
if (!changed)
{
changed = true;
RedrawWindowCaption();
SheduleNextAutosave();
}
}
bool TASEDIT_PROJECT::GetProjectChanged()
{
return changed;
}
void TASEDIT_PROJECT::SheduleNextAutosave()
{
if (TASEdit_autosave_period)
next_save_shedule = clock() + TASEdit_autosave_period * AUTOSAVE_PERIOD_SCALE;
}

View File

@ -28,10 +28,17 @@ public:
std::string GetProjectFile(); std::string GetProjectFile();
void SetProjectFile(std::string e); void SetProjectFile(std::string e);
void SetProjectChanged();
bool GetProjectChanged();
void SheduleNextAutosave();
// public vars // public vars
bool changed, old_changed;
private: private:
bool changed;
int next_save_shedule;
std::string projectName; //The TASEdit Project's name std::string projectName; //The TASEdit Project's name
std::string fm2FileName; //The main branch ilog file (todo rename more appropriately) std::string fm2FileName; //The main branch ilog file (todo rename more appropriately)
std::string projectFile; //The TASEdit Project's filename (For saving purposes) //adelikat: TODO: why the hell is this different from project name??! std::string projectFile; //The TASEdit Project's filename (For saving purposes) //adelikat: TODO: why the hell is this different from project name??!