diff --git a/Authors.txt b/Authors.txt index 9daf9463..32cfa6a3 100644 --- a/Authors.txt +++ b/Authors.txt @@ -65,7 +65,7 @@ DWEdit Debugger additions AnS - ansstuff at yandex dot ru (sf:ansstuff) -TASEdit enhancements +Bugfixes and additions, TASEdit v1.0 ---------linux devvers--------- >= 2.0 - These guys concentrated on keeping fceux the premiere diff --git a/changelog.txt b/changelog.txt index b1655349..50e508eb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 -19-octo-2011 - prg318 - scons: "scons install" now installs auxlib and manpage -19-octo-2011 - prg318 - scons: added --prefix option to build system and improved "install" target -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 -18-octo-2011 - prg318 - gtk: new video option for double buffering and ClipSides -18-octo-2011 - prg318 - sdl: GTK3 support is now functional. Set GTK3 to 1 in the SConstruct to try it out. -18-octo-2011 - prg318 - no longer use depreciated gtk2 functions -18-octo-2011 - prg318 - getSDLKey tool added to assist in remapping hotkeys -17-octo-2011 - prg318 - some segfaults fixed, also fixed some build errors -17-octo-2011 - prg318 - sdl netplay fixed -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" -07-octo-2011 - prg318 - gtk: support mouseclicks (ie zapper) + +12-nov-2011 - AnS - Tasedit: project autosaving +10-nov-2011 - AnS - Tasedit: Branches show saved screenshot on mouseover (alpha-fade popup window) +7-nov-2011 - AnS - Tasedit: Drawing Branches Tree (using GDI), animations, transitions, mouseover +04-nov-2011 - prg318 - gtk: added option for frameskipping and made label case consistent in gui +1-nov-2011 - zeromus - debugger - fix mysterious out of bounds condition while editing breakpoints +31-oct-2011 - zeromus - add winapi lua library +31-oct-2011 - zeromus - fix newppu bug; chr ram was not getting initialized to anything +28-oct-2011 - AnS - Switching Tasedit Bg input on/off when Tasedit gets/loses focus (allows FCEUX control without "Bg input") +27-oct-2011 - AnS - "Toggle Rerecord Display" hotkey (M), "Play Movie From Beginning" hotkey also works in Tasedit +27-oct-2011 - AnS - Tasedit: Bookmarks/Branches +23-oct-2011 - prg318 - sdl: fix a bug where alt key would get "stuck" when alt tabbing to window +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 - 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 diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index cae5dd58..34811d2b 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -80,6 +80,7 @@ extern bool TASEdit_restore_position; extern bool TASEdit_show_dot; extern int TASEdit_greenzone_capacity; extern int TasEdit_undo_levels; +extern int TASEdit_autosave_period; extern bool TASEdit_jump_to_undo; //window positions and sizes: @@ -310,6 +311,7 @@ static CFGSTRUCT fceuconfig[] = { AC(TASEdit_show_dot), AC(TASEdit_greenzone_capacity), AC(TasEdit_undo_levels), + AC(TASEdit_autosave_period), AC(TASEdit_jump_to_undo), AC(lagCounterDisplay), AC(oldInputDisplay), diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index a129b2e8..9fbf0d21 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -261,6 +261,7 @@ BEGIN BEGIN MENUITEM "Set &greenzone capacity", ID_CONFIG_SETGREENZONECAPACITY MENUITEM "Set max &undo levels", ID_CONFIG_SETMAXUNDOLEVELS + MENUITEM "Set &autosave period", ID_CONFIG_SETAUTOSAVEPERIOD MENUITEM SEPARATOR MENUITEM "Branches restore entire &Movie", ID_CONFIG_BRANCHESRESTOREFULLMOVIE MENUITEM "Branches work only when &Recording", ID_CONFIG_BRANCHESWORKONLYWHENRECORDING diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index a8f55b93..46001981 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -892,6 +892,7 @@ #define ID_CONFIG_BRANCHESRESTOREFULLMOVIE 40473 #define ID_CONFIG_BRANCHESWORKONLYWHENRECORDING 40474 #define ID_CONFIG_HUDINBRANCHSCREENSHOTS 40475 +#define ID_CONFIG_SETAUTOSAVEPERIOD 40476 #define IDC_DEBUGGER_ICONTRAY 55535 #define MW_ValueLabel2 65423 #define MW_ValueLabel1 65426 @@ -901,7 +902,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #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_SYMED_VALUE 101 #endif diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 3b1e9d4d..49eeba39 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -26,7 +26,6 @@ bool old_movie_readonly; bool TASEdit_focus = false; bool Tasedit_rewind_now = false; int listItems; // number of items per list page -int list_row_height; // in pixels // saved FCEU config int saved_eoptions; int saved_EnableAutosave; @@ -44,9 +43,10 @@ bool TASEdit_view_branches_tree = false; bool TASEdit_branch_scr_hud = true; bool TASEdit_restore_position = false; int TASEdit_greenzone_capacity = GREENZONE_CAPACITY_DEFAULT; +int TasEdit_undo_levels = UNDO_LEVELS_DEFAULT; +int TASEdit_autosave_period = AUTOSAVE_PERIOD_DEFAULT; extern bool muteTurbo; bool TASEdit_show_dot = true; -int TasEdit_undo_levels = UNDO_LEVELS_DEFAULT; bool TASEdit_jump_to_undo = true; 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()) { // 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; else msg->clrTextBk = UNDOHINT_FRAMENUM_COLOR; } else if (cell_y == currFrameCounter || cell_y == playback.GetPauseFrame()) { // 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 msg->clrTextBk = CUR_MARKED_FRAMENUM_COLOR; else 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 msg->clrTextBk = MARKED_FRAMENUM_COLOR; @@ -283,11 +283,11 @@ void UpdateTasEdit() playback.update(); bookmarks.update(); history.update(); + project.update(); // 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(); - project.update(); // update Bookmarks/Branches groupbox caption if (TASEdit_branch_only_when_rec && old_movie_readonly != movie_readonly) @@ -343,7 +343,7 @@ void RedrawWindowCaption() strcat(windowCaption, projectname.c_str()); } // and * if project has unsaved changes - if (project.changed) + if (project.GetProjectChanged()) strcat(windowCaption, "*"); SetWindowText(hwndTasEdit, windowCaption); } @@ -469,7 +469,7 @@ void SingleClick(LPNMITEMACTIVATE info) history.RegisterChanges(MODTYPE_MARKER_SET, row_index); else history.RegisterChanges(MODTYPE_MARKER_UNSET, row_index); - project.changed = true; + project.SetProjectChanged(); // deselect this row, so that new marker will be seen immediately ListView_SetItemState(hwndList, row_index, 0, LVIS_SELECTED); ListView_SetItemState(hwndList, -1, LVIS_FOCUSED, LVIS_FOCUSED); @@ -646,7 +646,7 @@ void ColumnSet(int column) markers.markers_array[*it] &= ~MARKER_FLAG_BIT; history.RegisterChanges(MODTYPE_MARKER_UNSET, *selectionFrames.begin(), *selectionFrames.rbegin()); } - project.changed = true; + project.SetProjectChanged(); ClearSelection(); // no need to RedrawList(); } else @@ -986,7 +986,7 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM return 0; case WM_MOUSEMOVE: { - if (!bookmarks.mouse_over_bitmap) + if (!bookmarks.mouse_over_bookmarkslist) { bookmarks.mouse_over_bookmarkslist = true; bookmarks.list_tme.hwndTrack = hWnd; @@ -1151,9 +1151,6 @@ void RecheckRecordingRadioButtons() void OpenProject() { 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"; @@ -1164,10 +1161,8 @@ void OpenProject() ofn.lpstrTitle="Open TASEdit Project..."; ofn.lpstrFilter=TPfilter; - //TODO - this is a bug, as GetRomName() returns archive.7z|game.rom and that confuses GetOpenFileName() - //we need to use a different function to get a friendlier name (same as savestates and fm2 and the like) - char nameo[2048]; //File name - strcpy(nameo, GetRomName()); //For now, just use ROM name + char nameo[2048]; + strcpy(nameo, mass_replace(GetRomName(),"|",".").c_str()); //convert | to . for archive filenames ofn.lpstrFile=nameo; ofn.nMaxFile=256; @@ -1225,10 +1220,9 @@ bool SaveProjectAs() ofn.lpstrTitle="Save TASEdit Project As..."; ofn.lpstrFilter=TPfilter; - char nameo[2048]; //File name - strcpy(nameo, GetRomName()); //For now, just use ROM name - - ofn.lpstrFile=nameo; //More parameters + char nameo[2048]; + strcpy(nameo, mass_replace(GetRomName(),"|",".").c_str()); //convert | to . for archive filenames + ofn.lpstrFile = nameo; ofn.lpstrDefExt="tas"; ofn.nMaxFile=256; ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; @@ -1265,7 +1259,7 @@ bool SaveProject() bool AskSaveProject() { bool changes_found = false; - if (project.changed) changes_found = true; + if (project.GetProjectChanged()) changes_found = true; // ask saving project if (changes_found) @@ -1638,9 +1632,8 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar break; case ID_CONFIG_SETGREENZONECAPACITY: { - //open input dialog 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) new_capacity = GREENZONE_CAPACITY_MIN; @@ -1656,7 +1649,6 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } case ID_CONFIG_SETMAXUNDOLEVELS: { - //open input dialog int new_size = TasEdit_undo_levels; 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; } + 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: muteTurbo ^= 1; CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED); diff --git a/src/drivers/win/tasedit.h b/src/drivers/win/tasedit.h index 21c1f3d4..add457a4 100644 --- a/src/drivers/win/tasedit.h +++ b/src/drivers/win/tasedit.h @@ -11,6 +11,11 @@ #define GREENZONE_CAPACITY_MIN 1 #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_MAX 999 #define UNDO_LEVELS_DEFAULT 100 diff --git a/src/drivers/win/taseditlib/bookmark.cpp b/src/drivers/win/taseditlib/bookmark.cpp index d32b8037..f11f9ff1 100644 --- a/src/drivers/win/taseditlib/bookmark.cpp +++ b/src/drivers/win/taseditlib/bookmark.cpp @@ -31,15 +31,13 @@ void BOOKMARK::set() snapshot.jump_frame = currFrameCounter; savestate = greenzone.savestates[currFrameCounter]; // save screenshot - std::vector 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; 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); not_empty = true; diff --git a/src/drivers/win/taseditlib/bookmark.h b/src/drivers/win/taseditlib/bookmark.h index fc4fa7e6..126122da 100644 --- a/src/drivers/win/taseditlib/bookmark.h +++ b/src/drivers/win/taseditlib/bookmark.h @@ -9,6 +9,11 @@ #define SCREENSHOT_HEIGHT 240 #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 { public: @@ -29,6 +34,7 @@ public: std::vector savestate; std::vector saved_screenshot; int parent_branch; + int parent_relation; private: diff --git a/src/drivers/win/taseditlib/bookmarks.cpp b/src/drivers/win/taseditlib/bookmarks.cpp index 03dc7c1b..541375c4 100644 --- a/src/drivers/win/taseditlib/bookmarks.cpp +++ b/src/drivers/win/taseditlib/bookmarks.cpp @@ -47,8 +47,6 @@ extern bool TASEdit_branch_full_movie; extern bool TASEdit_branch_only_when_rec; extern bool TASEdit_view_branches_tree; -extern int list_row_height; - BOOKMARKS::BOOKMARKS() { // create font @@ -395,7 +393,7 @@ void BOOKMARKS::set(int slot) must_recalculate_branches_tree = true; current_branch = slot; changes_since_current_branch = false; - project.changed = true; + project.SetProjectChanged(); if (previous_frame >= 0 && previous_frame != currFrameCounter) RedrawRowAndBookmark(previous_frame); @@ -438,7 +436,7 @@ void BOOKMARKS::unleash(int slot) if (bookmarks_array[slot].snapshot.checkMarkersDiff()) { bookmarks_array[slot].snapshot.toMarkers(); - project.changed = true; + project.SetProjectChanged(); markers_changed = true; } } @@ -472,7 +470,7 @@ void BOOKMARKS::unleash(int slot) if (bookmarks_array[slot].snapshot.checkMarkersDiff(jump_frame)) { bookmarks_array[slot].snapshot.copyToMarkers(jump_frame-1); - project.changed = true; + project.SetProjectChanged(); markers_changed = true; } } @@ -1299,19 +1297,15 @@ LRESULT CALLBACK ScrBmpWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lP { switch(message) { - HWND logo; 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); - break; + return 0; } - case WM_DESTROY: - PostQuitMessage(0); - break; default: return DefWindowProc(hwnd, message, wParam, lParam); } - return 0; } diff --git a/src/drivers/win/taseditlib/greenzone.cpp b/src/drivers/win/taseditlib/greenzone.cpp index 9f23517e..0a3e6f15 100644 --- a/src/drivers/win/taseditlib/greenzone.cpp +++ b/src/drivers/win/taseditlib/greenzone.cpp @@ -322,7 +322,7 @@ void GREENZONE::InvalidateAndCheck(int after) { if (after >= 0) { - project.changed = true; + project.SetProjectChanged(); if (greenZoneCount > after+1) { greenZoneCount = after+1; @@ -345,7 +345,7 @@ void GREENZONE::Invalidate(int after) { if (after >= 0) { - project.changed = true; + project.SetProjectChanged(); if (greenZoneCount > after+1) { greenZoneCount = after+1; diff --git a/src/drivers/win/taseditlib/inputhistory.cpp b/src/drivers/win/taseditlib/inputhistory.cpp index a5a7d6cb..95d956b6 100644 --- a/src/drivers/win/taseditlib/inputhistory.cpp +++ b/src/drivers/win/taseditlib/inputhistory.cpp @@ -137,7 +137,7 @@ int INPUT_HISTORY::jump(int new_pos) if (input_snapshots[real_pos].checkMarkersDiff()) { input_snapshots[real_pos].toMarkers(); - project.changed = true; + project.SetProjectChanged(); markers_changed = true; } } diff --git a/src/drivers/win/taseditlib/taseditproj.cpp b/src/drivers/win/taseditlib/taseditproj.cpp index ed5b814c..1066fb8c 100644 --- a/src/drivers/win/taseditlib/taseditproj.cpp +++ b/src/drivers/win/taseditlib/taseditproj.cpp @@ -2,6 +2,7 @@ #include "../main.h" #include "taseditproj.h" +#include "../tasedit.h" extern MARKERS markers; extern BOOKMARKS bookmarks; @@ -10,6 +11,7 @@ extern PLAYBACK playback; extern INPUT_HISTORY history; extern void FCEU_printf(char *format, ...); +extern int TASEdit_autosave_period; TASEDIT_PROJECT::TASEDIT_PROJECT() //Non parameterized constructor, loads project with default values { @@ -28,14 +30,19 @@ void TASEDIT_PROJECT::init() } void TASEDIT_PROJECT::reset() { - old_changed = changed = false; + changed = false; } 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(); + } + } bool TASEDIT_PROJECT::saveProject() @@ -139,3 +146,22 @@ void TASEDIT_PROJECT::SetProjectFile(std::string 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; +} diff --git a/src/drivers/win/taseditlib/taseditproj.h b/src/drivers/win/taseditlib/taseditproj.h index eff9c796..68fc4131 100644 --- a/src/drivers/win/taseditlib/taseditproj.h +++ b/src/drivers/win/taseditlib/taseditproj.h @@ -28,10 +28,17 @@ public: std::string GetProjectFile(); void SetProjectFile(std::string e); + void SetProjectChanged(); + bool GetProjectChanged(); + + void SheduleNextAutosave(); + // public vars - bool changed, old_changed; private: + bool changed; + int next_save_shedule; + std::string projectName; //The TASEdit Project's name 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??!