* Taseditor: cleaned up code a bit more, renamed identifiers to follow single convention

This commit is contained in:
ansstuff 2013-03-04 16:58:54 +00:00
parent 1a98c236af
commit 7007fc4805
58 changed files with 5232 additions and 5211 deletions

View File

@ -264,7 +264,7 @@ static void DoNamcoSoundHQ(void) {
lengo = LengthCache[P];
duff2 = FetchDuff(P, envelope);
for (V = CVBC << 1; V < SOUNDTS << 1; V++) {
for (V = CVBC << 1; V < (int)SOUNDTS << 1; V++) {
WaveHi[V >> 1] += duff2;
if (!vco) {
PlayIndex[P] += freq;

View File

@ -245,11 +245,11 @@ static INLINE void DoSQVHQ(int x) {
if (vpsg1[(x << 2) | 0x2] & 0x80) {
if (vpsg1[x << 2] & 0x80) {
for (V = cvbc[x]; V < SOUNDTS; V++)
for (V = cvbc[x]; V < (int)SOUNDTS; V++)
WaveHi[V] += amp;
} else {
int32 thresh = (vpsg1[x << 2] >> 4) & 7;
for (V = cvbc[x]; V < SOUNDTS; V++) {
for (V = cvbc[x]; V < (int)SOUNDTS; V++) {
if (dcount[x] > thresh)
WaveHi[V] += amp;
vcount[x]--;
@ -277,7 +277,7 @@ static void DoSawVHQ(void) {
int32 V;
if (vpsg2[2] & 0x80) {
for (V = cvbc[2]; V < SOUNDTS; V++) {
for (V = cvbc[2]; V < (int)SOUNDTS; V++) {
WaveHi[V] += (((phaseacc >> 3) & 0x1f) << 8) * 6 / 8;
vcount[2]--;
if (vcount[2] <= 0) {

View File

@ -402,10 +402,10 @@ static int JoedCharWidth(uint8 ch)
char target[64][256];
void DrawTextTransWH(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor, int max_w, int max_h, int border)
void DrawTextTransWH(uint8 *dest, int width, uint8 *textmsg, uint8 fgcolor, int max_w, int max_h, int border)
{
unsigned int beginx=2, x=beginx;
unsigned int y=2;
int beginx=2, x=beginx;
int y=2;
memset(target, 0, 64 * 256);

View File

@ -5,4 +5,4 @@ void DrawMessage(bool beforeMovie);
void FCEU_DrawRecordingStatus(uint8* XBuf);
void FCEU_DrawNumberRow(uint8 *XBuf, int *nstatus, int cur);
void DrawTextTrans(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor);
void DrawTextTransWH(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor, int max_w, int max_h, int border);
void DrawTextTransWH(uint8 *dest, int width, uint8 *textmsg, uint8 fgcolor, int max_w, int max_h, int border);

View File

@ -74,10 +74,10 @@ extern bool fullSaveStateLoads;
extern int frameSkipAmt;
extern int32 fps_scale_frameadvance;
extern TASEDITOR_CONFIG taseditor_config;
extern char* recent_projects[];
extern TASEDITOR_CONFIG taseditorConfig;
extern char* recentProjectsArray[];
// Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator
char* taseditor_config_last_author;
char* taseditorConfigLastAuthorName;
char* ResumeROM;
//window positions and sizes:
@ -158,16 +158,16 @@ static CFGSTRUCT fceuconfig[] =
ACS(ramWatchRecent[3]),
ACS(ramWatchRecent[4]),
ACS(recent_projects[0]),
ACS(recent_projects[1]),
ACS(recent_projects[2]),
ACS(recent_projects[3]),
ACS(recent_projects[4]),
ACS(recent_projects[5]),
ACS(recent_projects[6]),
ACS(recent_projects[7]),
ACS(recent_projects[8]),
ACS(recent_projects[9]),
ACS(recentProjectsArray[0]),
ACS(recentProjectsArray[1]),
ACS(recentProjectsArray[2]),
ACS(recentProjectsArray[3]),
ACS(recentProjectsArray[4]),
ACS(recentProjectsArray[5]),
ACS(recentProjectsArray[6]),
ACS(recentProjectsArray[7]),
ACS(recentProjectsArray[8]),
ACS(recentProjectsArray[9]),
AC(AutoResumePlay),
ACS(ResumeROM),
@ -321,68 +321,68 @@ static CFGSTRUCT fceuconfig[] =
AC(AFoff),
AC(AutoFireOffset),
AC(DesynchAutoFire),
AC(taseditor_config.wndx),
AC(taseditor_config.wndy),
AC(taseditor_config.wndwidth),
AC(taseditor_config.wndheight),
AC(taseditor_config.saved_wndx),
AC(taseditor_config.saved_wndy),
AC(taseditor_config.saved_wndwidth),
AC(taseditor_config.saved_wndheight),
AC(taseditor_config.wndmaximized),
AC(taseditor_config.findnote_wndx),
AC(taseditor_config.findnote_wndy),
AC(taseditor_config.follow_playback),
AC(taseditor_config.turbo_seek),
AC(taseditor_config.show_branch_screenshots),
AC(taseditor_config.show_branch_descr),
AC(taseditor_config.bind_markers),
AC(taseditor_config.empty_marker_notes),
AC(taseditor_config.combine_consecutive),
AC(taseditor_config.use_1p_rec),
AC(taseditor_config.columnset_by_keys),
AC(taseditor_config.branch_full_movie),
AC(taseditor_config.old_branching_controls),
AC(taseditor_config.view_branches_tree),
AC(taseditor_config.branch_scr_hud),
AC(taseditor_config.restore_position),
AC(taseditor_config.adjust_input_due_to_lag),
AC(taseditor_config.superimpose),
AC(taseditor_config.enable_auto_function),
AC(taseditor_config.enable_hot_changes),
AC(taseditor_config.greenzone_capacity),
AC(taseditor_config.undo_levels),
AC(taseditor_config.jump_to_undo),
AC(taseditor_config.follow_note_context),
AC(taseditor_config.last_export_type),
AC(taseditor_config.last_export_subtitles),
AC(taseditor_config.save_binary),
AC(taseditor_config.save_markers),
AC(taseditor_config.save_bookmarks),
AC(taseditor_config.save_history),
AC(taseditor_config.save_piano_roll),
AC(taseditor_config.save_selection),
AC(taseditor_config.save_greenzone),
AC(taseditor_config.savecompact_binary),
AC(taseditor_config.savecompact_markers),
AC(taseditor_config.savecompact_bookmarks),
AC(taseditor_config.savecompact_history),
AC(taseditor_config.savecompact_piano_roll),
AC(taseditor_config.savecompact_selection),
AC(taseditor_config.savecompact_greenzone),
AC(taseditor_config.findnote_matchcase),
AC(taseditor_config.findnote_search_up),
AC(taseditor_config.draw_input),
AC(taseditor_config.enable_greenzoning),
AC(taseditor_config.enable_autosave),
AC(taseditor_config.autosave_period),
AC(taseditor_config.silent_autosave),
AC(taseditor_config.autopause_at_finish),
AC(taseditor_config.tooltips),
AC(taseditor_config.current_pattern),
AC(taseditor_config.pattern_skips_lag),
AC(taseditor_config.pattern_recording),
ACS(taseditor_config_last_author),
AC(taseditorConfig.windowX),
AC(taseditorConfig.windowY),
AC(taseditorConfig.windowWidth),
AC(taseditorConfig.windowHeight),
AC(taseditorConfig.savedWindowX),
AC(taseditorConfig.savedWindowY),
AC(taseditorConfig.savedWindowWidth),
AC(taseditorConfig.savedWindowHeight),
AC(taseditorConfig.windowIsMaximized),
AC(taseditorConfig.findnoteWindowX),
AC(taseditorConfig.findnoteWindowY),
AC(taseditorConfig.findnoteMatchCase),
AC(taseditorConfig.findnoteSearchUp),
AC(taseditorConfig.followPlaybackCursor),
AC(taseditorConfig.turboSeek),
AC(taseditorConfig.autoRestoreLastPlaybackPosition),
AC(taseditorConfig.superimpose),
AC(taseditorConfig.recordingUsePattern),
AC(taseditorConfig.enableLuaAutoFunction),
AC(taseditorConfig.displayBranchesTree),
AC(taseditorConfig.displayBranchScreenshots),
AC(taseditorConfig.displayBranchDescriptions),
AC(taseditorConfig.enableHotChanges),
AC(taseditorConfig.followUndoContext),
AC(taseditorConfig.followMarkerNoteContext),
AC(taseditorConfig.greenzoneCapacity),
AC(taseditorConfig.maxUndoLevels),
AC(taseditorConfig.enableGreenzoning),
AC(taseditorConfig.autofirePatternSkipsLag),
AC(taseditorConfig.autoAdjustInputAccordingToLag),
AC(taseditorConfig.drawInputByDragging),
AC(taseditorConfig.combineConsecutiveRecordingsAndDraws),
AC(taseditorConfig.use1PKeysForAllSingleRecordings),
AC(taseditorConfig.useInputKeysForColumnSet),
AC(taseditorConfig.bindMarkersToInput),
AC(taseditorConfig.emptyNewMarkerNotes),
AC(taseditorConfig.oldControlSchemeForBranching),
AC(taseditorConfig.branchesRestoreEntireMovie),
AC(taseditorConfig.HUDInBranchScreenshots),
AC(taseditorConfig.autopauseAtTheEndOfMovie),
AC(taseditorConfig.lastExportedInputType),
AC(taseditorConfig.lastExportedSubtitlesStatus),
AC(taseditorConfig.projectSavingOptions_SaveInBinary),
AC(taseditorConfig.projectSavingOptions_SaveMarkers),
AC(taseditorConfig.projectSavingOptions_SaveBookmarks),
AC(taseditorConfig.projectSavingOptions_SaveHistory),
AC(taseditorConfig.projectSavingOptions_SavePianoRoll),
AC(taseditorConfig.projectSavingOptions_SaveSelection),
AC(taseditorConfig.projectSavingOptions_GreenzoneSavingMode),
AC(taseditorConfig.saveCompact_SaveInBinary),
AC(taseditorConfig.saveCompact_SaveMarkers),
AC(taseditorConfig.saveCompact_SaveBookmarks),
AC(taseditorConfig.saveCompact_SaveHistory),
AC(taseditorConfig.saveCompact_SavePianoRoll),
AC(taseditorConfig.saveCompact_SaveSelection),
AC(taseditorConfig.saveCompact_GreenzoneSavingMode),
AC(taseditorConfig.autosaveEnabled),
AC(taseditorConfig.autosavePeriod),
AC(taseditorConfig.autosaveSilent),
AC(taseditorConfig.tooltipsEnabled),
AC(taseditorConfig.currentPattern),
ACS(taseditorConfigLastAuthorName),
AC(lagCounterDisplay),
AC(oldInputDisplay),
AC(movieSubtitles),
@ -435,7 +435,7 @@ void SaveConfig(const char *filename)
ramWatchRecent[x] = rw_recent_files[x];
}
// Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator
taseditor_config_last_author = taseditor_config.last_author;
taseditorConfigLastAuthorName = taseditorConfig.lastAuthorName;
ResumeROM = rom_name_when_closing_emulator;
//-----------------------------------
@ -465,10 +465,10 @@ void LoadConfig(const char *filename)
}
}
// Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator
if (taseditor_config_last_author)
strncpy(taseditor_config.last_author, taseditor_config_last_author, AUTHOR_MAX_LEN-1);
if (taseditorConfigLastAuthorName)
strncpy(taseditorConfig.lastAuthorName, taseditorConfigLastAuthorName, AUTHOR_NAME_MAX_LEN-1);
else
taseditor_config.last_author[0] = 0;
taseditorConfig.lastAuthorName[0] = 0;
if (ResumeROM)
strncpy(rom_name_when_closing_emulator, ResumeROM, 128);
else

View File

@ -73,8 +73,8 @@
#include "taseditor.h"
#include "taseditor/taseditor_window.h"
extern TASEDITOR_WINDOW taseditor_window;
extern bool taseditor_accelerator_keys;
extern TASEDITOR_WINDOW taseditorWindow;
extern bool taseditorEnableAcceleratorKeys;
//---------------------------
//mbg merge 6/29/06 - new aboutbox
@ -345,15 +345,15 @@ int BlockingCheck()
}
}
if(!handled && taseditor_window.hwndTasEditor && taseditor_accelerator_keys)
if(!handled && taseditorWindow.hwndTASEditor && taseditorEnableAcceleratorKeys)
{
if(IsChild(taseditor_window.hwndTasEditor, msg.hwnd))
handled = TranslateAccelerator(taseditor_window.hwndTasEditor, fceu_hAccel, &msg);
if(IsChild(taseditorWindow.hwndTASEditor, msg.hwnd))
handled = TranslateAccelerator(taseditorWindow.hwndTASEditor, fceu_hAccel, &msg);
}
if(!handled && taseditor_window.hwndFindNote)
if(!handled && taseditorWindow.hwndFindNote)
{
if(IsChild(taseditor_window.hwndFindNote, msg.hwnd))
handled = IsDialogMessage(taseditor_window.hwndFindNote, &msg);
if(IsChild(taseditorWindow.hwndFindNote, msg.hwnd))
handled = IsDialogMessage(taseditorWindow.hwndFindNote, &msg);
}
/* //adelikat - Currently no accel keys are used in the main window. Uncomment this block to activate them.
if(!handled)
@ -419,8 +419,8 @@ void DoFCEUExit()
return;
// If user was asked to save changes in TAS Editor and chose cancel, don't close FCEUX
extern bool ExitTasEditor();
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && !ExitTasEditor())
extern bool exitTASEditor();
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && !exitTASEditor())
return;
if (CloseMemoryWatch() && AskSave()) //If user was asked to save changes in the memory watch dialog or ram watch, and chose cancel, don't close FCEUX!
@ -936,7 +936,7 @@ void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
//update debugging displays
_updateWindow();
// update TAS Editor
UpdateTasEditor();
updateTASEditor();
extern bool JustFrameAdvanced;

View File

@ -12,7 +12,7 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Neutral resources
// Íåéòðàëüíûé resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
@ -1476,10 +1476,10 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDCANCEL,94,55,50,14
ICON IDI_ICON4,IDC_STATIC,11,11,20,20
LTEXT "TAS Editor",IDC_TASEDITOR_NAME,43,8,83,13
LTEXT "Version 1.0",IDC_STATIC,63,25,37,8
LTEXT "Created by AnS",IDC_STATIC,138,12,52,8
LTEXT "Originated from TASEdit",IDC_STATIC,138,25,83,9,SS_NOPREFIX
LTEXT "TAS Editor",IDC_TASEDITOR_NAME,43,8,84,13
LTEXT "Version 1.01",IDC_STATIC,60,25,45,8
LTEXT "Created by AnS",IDC_STATIC,138,12,58,8
LTEXT "Originated from TASEdit",IDC_STATIC,138,25,85,9,SS_NOPREFIX
LTEXT "made by zeromus & adelikat",IDC_STATIC,138,35,96,9,SS_NOPREFIX
END
@ -2134,12 +2134,12 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
#endif // Neutral resources
#endif // Íåéòðàëüíûé resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Russian (Russia) resources
// Ðóññêèé (Ðîññèÿ) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
@ -2192,12 +2192,12 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
#endif // Russian (Russia) resources
#endif // Ðóññêèé (Ðîññèÿ) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
// Àíãëèéñêèé (ÑØÀ) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
@ -2431,7 +2431,7 @@ IDB_BITMAP_SELECTED17 BITMAP "res\\te_17_selected.bmp"
IDB_BITMAP_SELECTED18 BITMAP "res\\te_18_selected.bmp"
IDB_BITMAP_SELECTED19 BITMAP "res\\te_19_selected.bmp"
IDB_BRANCH_SPRITESHEET BITMAP "res\\branch_spritesheet.bmp"
#endif // English (United States) resources
#endif // Àíãëèéñêèé (ÑØÀ) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -728,6 +728,8 @@
#define ID_CHR2 1284
#define ID_CHR3 1285
#define ID_STATIC 1286
#define ID_CDL_OPTIONS 1287
#define ID_CDL_GENERATEROM 1288
#define MENU_NETWORK 40040
#define MENU_PALETTE 40041
#define MENU_SOUND 40042
@ -1182,7 +1184,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 290
#define _APS_NEXT_COMMAND_VALUE 40583
#define _APS_NEXT_CONTROL_VALUE 1287
#define _APS_NEXT_CONTROL_VALUE 1289
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -29,35 +29,36 @@ Main - Main gate between emulator and Taseditor
using namespace std;
// TAS Editor data
bool emulator_must_run_taseditor = false;
bool Taseditor_rewind_now = false;
bool must_call_manual_lua_function = false;
bool taseditor_accelerator_keys = false;
bool mustEngageTaseditor = false;
bool mustRewindNow = false;
bool mustCallManualLuaFunction = false;
bool taseditorEnableAcceleratorKeys = false;
// all Taseditor functional modules
TASEDITOR_CONFIG taseditor_config;
TASEDITOR_WINDOW taseditor_window;
TASEDITOR_CONFIG taseditorConfig;
TASEDITOR_WINDOW taseditorWindow;
TASEDITOR_PROJECT project;
HISTORY history;
PLAYBACK playback;
RECORDER recorder;
GREENZONE greenzone;
MARKERS_MANAGER markers_manager;
MARKERS_MANAGER markersManager;
BOOKMARKS bookmarks;
BRANCHES branches;
POPUP_DISPLAY popup_display;
PIANO_ROLL piano_roll;
POPUP_DISPLAY popupDisplay;
PIANO_ROLL pianoRoll;
TASEDITOR_LUA taseditor_lua;
SELECTION selection;
SPLICER splicer;
EDITOR editor;
extern int joysticks_per_frame[NUM_SUPPORTED_INPUT_TYPES];
extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
extern bool turbo;
extern int pal_emulation;
extern int newppu;
extern void PushCurrentVideoSettings();
extern void RefreshThrottleFPS();
extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader);
// temporarily saved FCEUX config
int saved_eoptions;
int saved_EnableAutosave;
@ -70,23 +71,23 @@ extern void TaseditorAutoFunction();
extern void TaseditorManualFunction();
// returns true if Taseditor is engaged at the end of the function
bool EnterTasEditor()
bool enterTASEditor()
{
if (taseditor_window.hwndTasEditor)
if (taseditorWindow.hwndTASEditor)
{
// TAS Editor is already engaged, just set focus to its window
if (!taseditor_config.wndmaximized)
ShowWindow(taseditor_window.hwndTasEditor, SW_SHOWNORMAL);
SetForegroundWindow(taseditor_window.hwndTasEditor);
if (!taseditorConfig.windowIsMaximized)
ShowWindow(taseditorWindow.hwndTASEditor, SW_SHOWNORMAL);
SetForegroundWindow(taseditorWindow.hwndTASEditor);
return true;
} else if (FCEU_IsValidUI(FCEUI_TASEDITOR))
{
// start TAS Editor
// create window
taseditor_window.init();
if (taseditor_window.hwndTasEditor)
taseditorWindow.init();
if (taseditorWindow.hwndTASEditor)
{
SetTaseditorInput();
enableGeneralKeyboardInput();
// save "eoptions"
saved_eoptions = eoptions;
// set "Run in background"
@ -104,17 +105,17 @@ bool EnterTasEditor()
// init modules
editor.init();
piano_roll.init();
pianoRoll.init();
selection.init();
splicer.init();
playback.init();
greenzone.init();
recorder.init();
markers_manager.init();
markersManager.init();
project.init();
bookmarks.init();
branches.init();
popup_display.init();
popupDisplay.init();
history.init();
taseditor_lua.init();
// either start new movie or use current movie
@ -126,7 +127,7 @@ bool EnterTasEditor()
FCEUI_StopMovie();
movieMode = MOVIEMODE_TASEDITOR;
FCEUMOV_CreateCleanMovie();
playback.StartFromZero();
playback.restartPlaybackFromZeroGround();
} else
{
// use current movie to create a new project
@ -137,21 +138,21 @@ bool EnterTasEditor()
if (((int)currMovieData.records.size() - 1) < currFrameCounter)
currMovieData.insertEmpty(-1, currFrameCounter - ((int)currMovieData.records.size() - 1));
// ensure that movie has correct set of ports/fourscore
SetInputType(currMovieData, GetInputType(currMovieData));
setInputType(currMovieData, getInputType(currMovieData));
// force the input configuration stored in the movie to apply to FCEUX config
ApplyMovieInputConfig();
applyMovieInputConfig();
// reset some modules that need MovieData info
piano_roll.reset();
pianoRoll.reset();
recorder.reset();
// create initial snapshot in history
history.reset();
// reset Taseditor variables
must_call_manual_lua_function = false;
mustCallManualLuaFunction = false;
SetFocus(history.hwndHistoryList); // set focus only once, to show blue selection cursor
SetFocus(piano_roll.hwndList);
SetFocus(pianoRoll.hwndList);
FCEU_DispMessage("TAS Editor engaged", 0);
taseditor_window.RedrawTaseditor();
taseditorWindow.redraw();
return true;
} else
{
@ -165,23 +166,23 @@ bool EnterTasEditor()
}
}
bool ExitTasEditor()
bool exitTASEditor()
{
if (!AskSaveProject()) return false;
if (!askToSaveProject()) return false;
// destroy window
taseditor_window.exit();
ClearTaseditorInput();
taseditorWindow.exit();
disableGeneralKeyboardInput();
// release memory
editor.free();
piano_roll.free();
markers_manager.free();
pianoRoll.free();
markersManager.free();
greenzone.free();
bookmarks.free();
branches.free();
popup_display.free();
popupDisplay.free();
history.free();
playback.SeekingStop();
playback.stopSeeking();
selection.free();
// restore "eoptions"
@ -200,69 +201,69 @@ bool ExitTasEditor()
}
// everyframe function
void UpdateTasEditor()
void updateTASEditor()
{
if (taseditor_window.hwndTasEditor)
if (taseditorWindow.hwndTASEditor)
{
// TAS Editor is engaged
// update all modules that need to be updated every frame
// the order is somewhat important, e.g. Greenzone must update before Bookmark Set, Piano Roll must update before Selection
taseditor_window.update();
taseditorWindow.update();
greenzone.update();
recorder.update();
piano_roll.update();
markers_manager.update();
pianoRoll.update();
markersManager.update();
playback.update();
bookmarks.update();
branches.update();
popup_display.update();
popupDisplay.update();
selection.update();
splicer.update();
history.update();
project.update();
// run Lua functions if needed
if (taseditor_config.enable_auto_function)
if (taseditorConfig.enableLuaAutoFunction)
TaseditorAutoFunction();
if (must_call_manual_lua_function)
if (mustCallManualLuaFunction)
{
TaseditorManualFunction();
must_call_manual_lua_function = false;
mustCallManualLuaFunction = false;
}
} else
{
// TAS Editor is not engaged
TaseditorAutoFunction(); // but we still should run Lua auto function
if (emulator_must_run_taseditor)
if (mustEngageTaseditor)
{
char fullname[512];
char fullname[1000];
strcpy(fullname, curMovieFilename);
if (EnterTasEditor())
LoadProject(fullname);
emulator_must_run_taseditor = false;
if (enterTASEditor())
loadProject(fullname);
mustEngageTaseditor = false;
}
}
}
BOOL CALLBACK NewProjectProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK newProjectProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static struct NewProjectParameters* p = NULL;
switch (message)
{
case WM_INITDIALOG:
p = (struct NewProjectParameters*)lParam;
p->input_type = GetInputType(currMovieData);
p->copy_current_input = p->copy_current_markers = false;
if (strlen(taseditor_config.last_author))
p->inputType = getInputType(currMovieData);
p->copyCurrentInput = p->copyCurrentMarkers = false;
if (strlen(taseditorConfig.lastAuthorName))
{
// convert UTF8 char* string to Unicode wstring
wchar_t saved_author_name[AUTHOR_MAX_LEN] = {0};
MultiByteToWideChar(CP_UTF8, 0, taseditor_config.last_author, -1, saved_author_name, AUTHOR_MAX_LEN);
p->author_name = saved_author_name;
wchar_t savedAuthorName[AUTHOR_NAME_MAX_LEN] = {0};
MultiByteToWideChar(CP_UTF8, 0, taseditorConfig.lastAuthorName, -1, savedAuthorName, AUTHOR_NAME_MAX_LEN);
p->authorName = savedAuthorName;
} else
{
p->author_name = L"";
p->authorName = L"";
}
switch (p->input_type)
switch (p->inputType)
{
case INPUT_TYPE_1P:
{
@ -281,39 +282,39 @@ BOOL CALLBACK NewProjectProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM l
}
}
SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_AUTHOR), CCM_SETUNICODEFORMAT, TRUE, 0);
SetDlgItemTextW(hwndDlg, IDC_EDIT_AUTHOR, (LPCWSTR)(p->author_name.c_str()));
SetDlgItemTextW(hwndDlg, IDC_EDIT_AUTHOR, (LPCWSTR)(p->authorName.c_str()));
return 0;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_RADIO_1PLAYER:
p->input_type = INPUT_TYPE_1P;
p->inputType = INPUT_TYPE_1P;
break;
case IDC_RADIO_2PLAYERS:
p->input_type = INPUT_TYPE_2P;
p->inputType = INPUT_TYPE_2P;
break;
case IDC_RADIO_FOURSCORE:
p->input_type = INPUT_TYPE_FOURSCORE;
p->inputType = INPUT_TYPE_FOURSCORE;
break;
case IDC_COPY_INPUT:
p->copy_current_input ^= 1;
CheckDlgButton(hwndDlg, IDC_COPY_INPUT, p->copy_current_input?MF_CHECKED : MF_UNCHECKED);
p->copyCurrentInput ^= 1;
CheckDlgButton(hwndDlg, IDC_COPY_INPUT, p->copyCurrentInput?MF_CHECKED : MF_UNCHECKED);
break;
case IDC_COPY_MARKERS:
p->copy_current_markers ^= 1;
CheckDlgButton(hwndDlg, IDC_COPY_MARKERS, p->copy_current_markers?MF_CHECKED : MF_UNCHECKED);
p->copyCurrentMarkers ^= 1;
CheckDlgButton(hwndDlg, IDC_COPY_MARKERS, p->copyCurrentMarkers?MF_CHECKED : MF_UNCHECKED);
break;
case IDOK:
{
// save author name in params and in taseditor_config (converted to multibyte char*)
wchar_t author_name[AUTHOR_MAX_LEN] = {0};
GetDlgItemTextW(hwndDlg, IDC_EDIT_AUTHOR, (LPWSTR)author_name, AUTHOR_MAX_LEN);
p->author_name = author_name;
if (p->author_name == L"")
taseditor_config.last_author[0] = 0;
wchar_t authorName[AUTHOR_NAME_MAX_LEN] = {0};
GetDlgItemTextW(hwndDlg, IDC_EDIT_AUTHOR, (LPWSTR)authorName, AUTHOR_NAME_MAX_LEN);
p->authorName = authorName;
if (p->authorName == L"")
taseditorConfig.lastAuthorName[0] = 0;
else
// convert Unicode wstring to UTF8 char* string
WideCharToMultiByte(CP_UTF8, 0, (p->author_name).c_str(), -1, taseditor_config.last_author, AUTHOR_MAX_LEN, 0, 0);
WideCharToMultiByte(CP_UTF8, 0, (p->authorName).c_str(), -1, taseditorConfig.lastAuthorName, AUTHOR_NAME_MAX_LEN, 0, 0);
EndDialog(hwndDlg, 1);
return TRUE;
}
@ -326,54 +327,54 @@ BOOL CALLBACK NewProjectProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM l
return FALSE;
}
void NewProject()
void createNewProject()
{
if (!AskSaveProject()) return;
if (!askToSaveProject()) return;
static struct NewProjectParameters params;
if (DialogBoxParam(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_NEWPROJECT), taseditor_window.hwndTasEditor, NewProjectProc, (LPARAM)&params) > 0)
if (DialogBoxParam(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_NEWPROJECT), taseditorWindow.hwndTASEditor, newProjectProc, (LPARAM)&params) > 0)
{
FCEUMOV_CreateCleanMovie();
// apply selected options
SetInputType(currMovieData, params.input_type);
ApplyMovieInputConfig();
if (params.copy_current_input)
setInputType(currMovieData, params.inputType);
applyMovieInputConfig();
if (params.copyCurrentInput)
// copy Input from current snapshot (from history)
history.GetCurrentSnapshot().inputlog.toMovie(currMovieData);
if (!params.copy_current_markers)
markers_manager.reset();
if (params.author_name != L"") currMovieData.comments.push_back(L"author " + params.author_name);
history.getCurrentSnapshot().inputlog.toMovie(currMovieData);
if (!params.copyCurrentMarkers)
markersManager.reset();
if (params.authorName != L"") currMovieData.comments.push_back(L"author " + params.authorName);
// reset Taseditor
project.init(); // new project has blank name
greenzone.reset();
if (params.copy_current_input)
if (params.copyCurrentInput)
// copy LagLog from current snapshot (from history)
greenzone.laglog = history.GetCurrentSnapshot().laglog;
greenzone.lagLog = history.getCurrentSnapshot().laglog;
playback.reset();
playback.StartFromZero();
playback.restartPlaybackFromZeroGround();
bookmarks.reset();
branches.reset();
history.reset();
piano_roll.reset();
pianoRoll.reset();
selection.reset();
editor.reset();
splicer.reset();
recorder.reset();
popup_display.reset();
taseditor_window.RedrawTaseditor();
taseditor_window.UpdateCaption();
popupDisplay.reset();
taseditorWindow.redraw();
taseditorWindow.updateCaption();
}
}
void OpenProject()
void openProject()
{
if (!AskSaveProject()) return;
if (!askToSaveProject()) return;
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = taseditor_window.hwndTasEditor;
ofn.hwndOwner = taseditorWindow.hwndTASEditor;
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Open TAS Editor Project";
const char filter[] = "TAS Editor Projects (*.fm3)\0*.fm3\0All Files (*.*)\0*.*\0\0";
@ -390,44 +391,44 @@ void OpenProject()
if (GetOpenFileName(&ofn)) // If it is a valid filename
{
LoadProject(nameo);
loadProject(nameo);
}
}
bool LoadProject(const char* fullname)
bool loadProject(const char* fullname)
{
// try to load project
if (project.load(fullname))
{
// loaded successfully
ApplyMovieInputConfig();
applyMovieInputConfig();
// add new file to Recent menu
taseditor_window.UpdateRecentProjectsArray(fullname);
taseditor_window.RedrawTaseditor();
taseditor_window.UpdateCaption();
taseditorWindow.updateRecentProjectsArray(fullname);
taseditorWindow.redraw();
taseditorWindow.updateCaption();
return true;
} else
{
// failed to load
taseditor_window.RedrawTaseditor();
taseditor_window.UpdateCaption();
taseditorWindow.redraw();
taseditorWindow.updateCaption();
return false;
}
}
// Saves current project
bool SaveProjectAs(bool save_compact)
bool saveProjectAs(bool save_compact)
{
const char filter[] = "TAS Editor Projects (*.fm3)\0*.fm3\0All Files (*.*)\0*.*\0\0";
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = taseditor_window.hwndTasEditor;
ofn.hwndOwner = taseditorWindow.hwndTASEditor;
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Save TAS Editor Project As...";
ofn.lpstrFilter = filter;
char nameo[2048];
if (project.GetProjectName().empty())
if (project.getProjectName().empty())
{
// suggest ROM name for this project
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); //convert | to . for archive filenames
@ -436,7 +437,7 @@ bool SaveProjectAs(bool save_compact)
} else
{
// suggest current name
strncpy(nameo, project.GetProjectName().c_str(), 2047);
strncpy(nameo, project.getProjectName().c_str(), 2047);
}
ofn.lpstrFile = nameo;
@ -448,59 +449,59 @@ bool SaveProjectAs(bool save_compact)
if (GetSaveFileName(&ofn)) // if it is a valid filename
{
project.RenameProject(nameo, true);
project.renameProject(nameo, true);
if (save_compact)
project.save(nameo, taseditor_config.savecompact_binary, taseditor_config.savecompact_markers, taseditor_config.savecompact_bookmarks, taseditor_config.savecompact_greenzone, taseditor_config.savecompact_history, taseditor_config.savecompact_piano_roll, taseditor_config.savecompact_selection);
project.save(nameo, taseditorConfig.saveCompact_SaveInBinary, taseditorConfig.saveCompact_SaveMarkers, taseditorConfig.saveCompact_SaveBookmarks, taseditorConfig.saveCompact_GreenzoneSavingMode, taseditorConfig.saveCompact_SaveHistory, taseditorConfig.saveCompact_SavePianoRoll, taseditorConfig.saveCompact_SaveSelection);
else
project.save(nameo, taseditor_config.save_binary, taseditor_config.save_markers, taseditor_config.save_bookmarks, taseditor_config.save_greenzone, taseditor_config.save_history, taseditor_config.save_piano_roll, taseditor_config.save_selection);
taseditor_window.UpdateRecentProjectsArray(nameo);
project.save(nameo, taseditorConfig.projectSavingOptions_SaveInBinary, taseditorConfig.projectSavingOptions_SaveMarkers, taseditorConfig.projectSavingOptions_SaveBookmarks, taseditorConfig.projectSavingOptions_GreenzoneSavingMode, taseditorConfig.projectSavingOptions_SaveHistory, taseditorConfig.projectSavingOptions_SavePianoRoll, taseditorConfig.projectSavingOptions_SaveSelection);
taseditorWindow.updateRecentProjectsArray(nameo);
// saved successfully - remove * mark from caption
taseditor_window.UpdateCaption();
taseditorWindow.updateCaption();
} else return false;
return true;
}
bool SaveProject(bool save_compact)
bool saveProject(bool save_compact)
{
if (project.GetProjectFile().empty())
if (project.getProjectFile().empty())
{
return SaveProjectAs(save_compact);
return saveProjectAs(save_compact);
} else
{
if (save_compact)
project.save(0, taseditor_config.savecompact_binary, taseditor_config.savecompact_markers, taseditor_config.savecompact_bookmarks, taseditor_config.savecompact_greenzone, taseditor_config.savecompact_history, taseditor_config.savecompact_piano_roll, taseditor_config.savecompact_selection);
project.save(0, taseditorConfig.saveCompact_SaveInBinary, taseditorConfig.saveCompact_SaveMarkers, taseditorConfig.saveCompact_SaveBookmarks, taseditorConfig.saveCompact_GreenzoneSavingMode, taseditorConfig.saveCompact_SaveHistory, taseditorConfig.saveCompact_SavePianoRoll, taseditorConfig.saveCompact_SaveSelection);
else
project.save(0, taseditor_config.save_binary, taseditor_config.save_markers, taseditor_config.save_bookmarks, taseditor_config.save_greenzone, taseditor_config.save_history, taseditor_config.save_piano_roll, taseditor_config.save_selection);
taseditor_window.UpdateCaption();
project.save(0, taseditorConfig.projectSavingOptions_SaveInBinary, taseditorConfig.projectSavingOptions_SaveMarkers, taseditorConfig.projectSavingOptions_SaveBookmarks, taseditorConfig.projectSavingOptions_GreenzoneSavingMode, taseditorConfig.projectSavingOptions_SaveHistory, taseditorConfig.projectSavingOptions_SavePianoRoll, taseditorConfig.projectSavingOptions_SaveSelection);
taseditorWindow.updateCaption();
}
return true;
}
// --------------------------------------------------
void SaveCompact_SetDialogItems(HWND hwndDlg)
{
CheckDlgButton(hwndDlg, IDC_CHECK_BINARY, taseditor_config.savecompact_binary?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_MARKERS, taseditor_config.savecompact_markers?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_BOOKMARKS, taseditor_config.savecompact_bookmarks?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_HISTORY, taseditor_config.savecompact_history?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_PIANO_ROLL, taseditor_config.savecompact_piano_roll?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_SELECTION, taseditor_config.savecompact_selection?BST_CHECKED : BST_UNCHECKED);
CheckRadioButton(hwndDlg, IDC_RADIO1, IDC_RADIO4, IDC_RADIO1 + (taseditor_config.savecompact_greenzone % SAVE_GREENZONE_TOTAL));
CheckDlgButton(hwndDlg, IDC_CHECK_BINARY, taseditorConfig.saveCompact_SaveInBinary?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_MARKERS, taseditorConfig.saveCompact_SaveMarkers?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_BOOKMARKS, taseditorConfig.saveCompact_SaveBookmarks?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_HISTORY, taseditorConfig.saveCompact_SaveHistory?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_PIANO_ROLL, taseditorConfig.saveCompact_SavePianoRoll?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_SELECTION, taseditorConfig.saveCompact_SaveSelection?BST_CHECKED : BST_UNCHECKED);
CheckRadioButton(hwndDlg, IDC_RADIO1, IDC_RADIO4, IDC_RADIO1 + (taseditorConfig.saveCompact_GreenzoneSavingMode % GREENZONE_SAVING_MODES_TOTAL));
}
void SaveCompact_GetDialogItems(HWND hwndDlg)
{
taseditor_config.savecompact_binary = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BINARY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.savecompact_markers = (SendDlgItemMessage(hwndDlg, IDC_CHECK_MARKERS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.savecompact_bookmarks = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BOOKMARKS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.savecompact_history = (SendDlgItemMessage(hwndDlg, IDC_CHECK_HISTORY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.savecompact_piano_roll = (SendDlgItemMessage(hwndDlg, IDC_CHECK_PIANO_ROLL, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.savecompact_selection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.saveCompact_SaveInBinary = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BINARY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.saveCompact_SaveMarkers = (SendDlgItemMessage(hwndDlg, IDC_CHECK_MARKERS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.saveCompact_SaveBookmarks = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BOOKMARKS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.saveCompact_SaveHistory = (SendDlgItemMessage(hwndDlg, IDC_CHECK_HISTORY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.saveCompact_SavePianoRoll = (SendDlgItemMessage(hwndDlg, IDC_CHECK_PIANO_ROLL, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.saveCompact_SaveSelection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED);
if (SendDlgItemMessage(hwndDlg, IDC_RADIO1, BM_GETCHECK, 0, 0) == BST_CHECKED)
taseditor_config.savecompact_greenzone = SAVE_GREENZONE_ALL;
taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_ALL;
else if (SendDlgItemMessage(hwndDlg, IDC_RADIO2, BM_GETCHECK, 0, 0) == BST_CHECKED)
taseditor_config.savecompact_greenzone = SAVE_GREENZONE_16TH;
taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_16TH;
else if (SendDlgItemMessage(hwndDlg, IDC_RADIO3, BM_GETCHECK, 0, 0) == BST_CHECKED)
taseditor_config.savecompact_greenzone = SAVE_GREENZONE_MARKED;
taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_MARKED;
else
taseditor_config.savecompact_greenzone = SAVE_GREENZONE_NO;
taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_NO;
}
BOOL CALLBACK SaveCompactProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
@ -508,7 +509,7 @@ BOOL CALLBACK SaveCompactProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
{
case WM_INITDIALOG:
{
SetWindowPos(hwndDlg, 0, taseditor_config.wndx + 100, taseditor_config.wndy + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
SetWindowPos(hwndDlg, 0, taseditorConfig.windowX + 100, taseditorConfig.windowY + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
SaveCompact_SetDialogItems(hwndDlg);
return TRUE;
}
@ -536,26 +537,26 @@ BOOL CALLBACK SaveCompactProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
}
return FALSE;
}
void SaveCompact()
void saveCompact()
{
if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_SAVECOMPACT), taseditor_window.hwndTasEditor, SaveCompactProc) > 0)
if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_SAVECOMPACT), taseditorWindow.hwndTASEditor, SaveCompactProc) > 0)
{
const char filter[] = "TAS Editor Projects (*.fm3)\0*.fm3\0All Files (*.*)\0*.*\0\0";
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = taseditor_window.hwndTasEditor;
ofn.hwndOwner = taseditorWindow.hwndTASEditor;
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Save Compact";
ofn.lpstrFilter = filter;
char nameo[2048];
if (project.GetProjectName().empty())
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());
strcpy(nameo, project.getProjectName().c_str());
// add "-compact" if there's no such suffix
if (!strstr(nameo, "-compact"))
strcat(nameo, "-compact");
@ -569,37 +570,37 @@ void SaveCompact()
if (GetSaveFileName(&ofn))
{
project.save(nameo, taseditor_config.savecompact_binary, taseditor_config.savecompact_markers, taseditor_config.savecompact_bookmarks, taseditor_config.savecompact_greenzone, taseditor_config.savecompact_history, taseditor_config.savecompact_piano_roll, taseditor_config.savecompact_selection);
taseditor_window.UpdateCaption();
project.save(nameo, taseditorConfig.saveCompact_SaveInBinary, taseditorConfig.saveCompact_SaveMarkers, taseditorConfig.saveCompact_SaveBookmarks, taseditorConfig.saveCompact_GreenzoneSavingMode, taseditorConfig.saveCompact_SaveHistory, taseditorConfig.saveCompact_SavePianoRoll, taseditorConfig.saveCompact_SaveSelection);
taseditorWindow.updateCaption();
}
}
}
// --------------------------------------------------
// returns false if user doesn't want to exit
bool AskSaveProject()
bool askToSaveProject()
{
bool changes_found = false;
if (project.GetProjectChanged()) changes_found = true;
bool changesFound = false;
if (project.getProjectChanged())
changesFound = true;
// ask saving project
if (changes_found)
if (changesFound)
{
int answer = MessageBox(taseditor_window.hwndTasEditor, "Save Project changes?", "TAS Editor", MB_YESNOCANCEL);
int answer = MessageBox(taseditorWindow.hwndTASEditor, "Save Project changes?", "TAS Editor", MB_YESNOCANCEL);
if (answer == IDYES)
return SaveProject();
return saveProject();
return (answer != IDCANCEL);
}
return true;
}
extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader);
void Import()
void importInputData()
{
const char filter[] = "FCEUX Movie Files (*.fm2), TAS Editor Projects (*.fm3)\0*.fm2;*.fm3\0All Files (*.*)\0*.*\0\0";
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = taseditor_window.hwndTasEditor;
ofn.hwndOwner = taseditorWindow.hwndTASEditor;
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Import";
ofn.lpstrFilter = filter;
@ -621,14 +622,14 @@ void Import()
char drv[512], dir[512], name[1024], ext[512];
splitpath(nameo, drv, dir, name, ext);
strcat(name, ext);
int result = history.RegisterImport(md, name);
int result = history.registerImport(md, name);
if (result >= 0)
{
greenzone.InvalidateAndCheck(result);
greenzone.laglog.InvalidateFrom(result);
greenzone.invalidateAndUpdatePlayback(result);
greenzone.lagLog.invalidateFromFrame(result);
} else
{
MessageBox(taseditor_window.hwndTasEditor, "Imported movie has the same Input.\nNo changes were made.", "TAS Editor", MB_OK);
MessageBox(taseditorWindow.hwndTASEditor, "Imported movie has the same Input.\nNo changes were made.", "TAS Editor", MB_OK);
}
} else
{
@ -637,13 +638,13 @@ void Import()
}
}
BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK aboutWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
SendMessage(GetDlgItem(hWnd, IDC_TASEDITOR_NAME), WM_SETFONT, (WPARAM)piano_roll.hTaseditorAboutFont, 0);
SendMessage(GetDlgItem(hWnd, IDC_TASEDITOR_NAME), WM_SETFONT, (WPARAM)pianoRoll.hTaseditorAboutFont, 0);
break;
}
case WM_COMMAND:
@ -660,24 +661,24 @@ BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK SavingOptionsProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK savingOptionsWndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
CheckDlgButton(hwndDlg, IDC_AUTOSAVE_PROJECT, taseditor_config.enable_autosave?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SILENT_AUTOSAVE, taseditor_config.silent_autosave?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTOSAVE_PROJECT, taseditorConfig.autosaveEnabled?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SILENT_AUTOSAVE, taseditorConfig.autosaveSilent?BST_CHECKED : BST_UNCHECKED);
char buf[16] = {0};
sprintf(buf, "%u", taseditor_config.autosave_period);
sprintf(buf, "%u", taseditorConfig.autosavePeriod);
SetDlgItemText(hwndDlg, IDC_AUTOSAVE_PERIOD, buf);
CheckDlgButton(hwndDlg, IDC_CHECK_BINARY, taseditor_config.save_binary?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_MARKERS, taseditor_config.save_markers?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_BOOKMARKS, taseditor_config.save_bookmarks?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_HISTORY, taseditor_config.save_history?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_PIANO_ROLL, taseditor_config.save_piano_roll?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_SELECTION, taseditor_config.save_selection?BST_CHECKED : BST_UNCHECKED);
CheckRadioButton(hwndDlg, IDC_RADIO1, IDC_RADIO4, IDC_RADIO1 + (taseditor_config.save_greenzone % SAVE_GREENZONE_TOTAL));
CheckDlgButton(hwndDlg, IDC_CHECK_BINARY, taseditorConfig.projectSavingOptions_SaveInBinary?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_MARKERS, taseditorConfig.projectSavingOptions_SaveMarkers?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_BOOKMARKS, taseditorConfig.projectSavingOptions_SaveBookmarks?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_HISTORY, taseditorConfig.projectSavingOptions_SaveHistory?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_PIANO_ROLL, taseditorConfig.projectSavingOptions_SavePianoRoll?BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_SELECTION, taseditorConfig.projectSavingOptions_SaveSelection?BST_CHECKED : BST_UNCHECKED);
CheckRadioButton(hwndDlg, IDC_RADIO1, IDC_RADIO4, IDC_RADIO1 + (taseditorConfig.projectSavingOptions_GreenzoneSavingMode % GREENZONE_SAVING_MODES_TOTAL));
return TRUE;
}
case WM_COMMAND:
@ -686,32 +687,32 @@ BOOL CALLBACK SavingOptionsProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARA
{
case IDOK:
{
taseditor_config.enable_autosave = (SendDlgItemMessage(hwndDlg, IDC_AUTOSAVE_PROJECT, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.silent_autosave = (SendDlgItemMessage(hwndDlg, IDC_SILENT_AUTOSAVE, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.autosaveEnabled = (SendDlgItemMessage(hwndDlg, IDC_AUTOSAVE_PROJECT, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.autosaveSilent = (SendDlgItemMessage(hwndDlg, IDC_SILENT_AUTOSAVE, BM_GETCHECK, 0, 0) == BST_CHECKED);
char buf[16] = {0};
GetDlgItemText(hwndDlg, IDC_AUTOSAVE_PERIOD, buf, 16 * sizeof(char));
int new_period = taseditor_config.autosave_period;
int new_period = taseditorConfig.autosavePeriod;
sscanf(buf, "%u", &new_period);
if (new_period < AUTOSAVE_PERIOD_MIN)
new_period = AUTOSAVE_PERIOD_MIN;
else if (new_period > AUTOSAVE_PERIOD_MAX)
new_period = AUTOSAVE_PERIOD_MAX;
taseditor_config.autosave_period = new_period;
project.SheduleNextAutosave();
taseditor_config.save_binary = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BINARY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.save_markers = (SendDlgItemMessage(hwndDlg, IDC_CHECK_MARKERS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.save_bookmarks = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BOOKMARKS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.save_history = (SendDlgItemMessage(hwndDlg, IDC_CHECK_HISTORY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.save_piano_roll = (SendDlgItemMessage(hwndDlg, IDC_CHECK_PIANO_ROLL, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditor_config.save_selection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.autosavePeriod = new_period;
project.sheduleNextAutosave();
taseditorConfig.projectSavingOptions_SaveInBinary = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BINARY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.projectSavingOptions_SaveMarkers = (SendDlgItemMessage(hwndDlg, IDC_CHECK_MARKERS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.projectSavingOptions_SaveBookmarks = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BOOKMARKS, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.projectSavingOptions_SaveHistory = (SendDlgItemMessage(hwndDlg, IDC_CHECK_HISTORY, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.projectSavingOptions_SavePianoRoll = (SendDlgItemMessage(hwndDlg, IDC_CHECK_PIANO_ROLL, BM_GETCHECK, 0, 0) == BST_CHECKED);
taseditorConfig.projectSavingOptions_SaveSelection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED);
if (SendDlgItemMessage(hwndDlg, IDC_RADIO1, BM_GETCHECK, 0, 0) == BST_CHECKED)
taseditor_config.save_greenzone = SAVE_GREENZONE_ALL;
taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_ALL;
else if (SendDlgItemMessage(hwndDlg, IDC_RADIO2, BM_GETCHECK, 0, 0) == BST_CHECKED)
taseditor_config.save_greenzone = SAVE_GREENZONE_16TH;
taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_16TH;
else if (SendDlgItemMessage(hwndDlg, IDC_RADIO3, BM_GETCHECK, 0, 0) == BST_CHECKED)
taseditor_config.save_greenzone = SAVE_GREENZONE_MARKED;
taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_MARKED;
else
taseditor_config.save_greenzone = SAVE_GREENZONE_NO;
taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_NO;
EndDialog(hwndDlg, 1);
return TRUE;
}
@ -730,8 +731,8 @@ BOOL CALLBACK ExportProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPara
switch (message)
{
case WM_INITDIALOG:
SetWindowPos(hwndDlg, 0, taseditor_config.wndx + 100, taseditor_config.wndy + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
switch (taseditor_config.last_export_type)
SetWindowPos(hwndDlg, 0, taseditorConfig.windowX + 100, taseditorConfig.windowY + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
switch (taseditorConfig.lastExportedInputType)
{
case INPUT_TYPE_1P:
{
@ -749,23 +750,23 @@ BOOL CALLBACK ExportProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPara
break;
}
}
CheckDlgButton(hwndDlg, IDC_NOTES_TO_SUBTITLES, taseditor_config.last_export_subtitles?MF_CHECKED : MF_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NOTES_TO_SUBTITLES, taseditorConfig.lastExportedSubtitlesStatus?MF_CHECKED : MF_UNCHECKED);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_RADIO_1PLAYER:
taseditor_config.last_export_type = INPUT_TYPE_1P;
taseditorConfig.lastExportedInputType = INPUT_TYPE_1P;
break;
case IDC_RADIO_2PLAYERS:
taseditor_config.last_export_type = INPUT_TYPE_2P;
taseditorConfig.lastExportedInputType = INPUT_TYPE_2P;
break;
case IDC_RADIO_FOURSCORE:
taseditor_config.last_export_type = INPUT_TYPE_FOURSCORE;
taseditorConfig.lastExportedInputType = INPUT_TYPE_FOURSCORE;
break;
case IDC_NOTES_TO_SUBTITLES:
taseditor_config.last_export_subtitles ^= 1;
CheckDlgButton(hwndDlg, IDC_NOTES_TO_SUBTITLES, taseditor_config.last_export_subtitles?MF_CHECKED : MF_UNCHECKED);
taseditorConfig.lastExportedSubtitlesStatus ^= 1;
CheckDlgButton(hwndDlg, IDC_NOTES_TO_SUBTITLES, taseditorConfig.lastExportedSubtitlesStatus?MF_CHECKED : MF_UNCHECKED);
break;
case IDOK:
EndDialog(hwndDlg, 1);
@ -779,17 +780,17 @@ BOOL CALLBACK ExportProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPara
return FALSE;
}
void Export()
void exportToFM2()
{
if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_EXPORT), taseditor_window.hwndTasEditor, ExportProc) > 0)
if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_EXPORT), taseditorWindow.hwndTASEditor, ExportProc) > 0)
{
const char filter[] = "FCEUX Movie File (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0";
char fname[2048];
strcpy(fname, project.GetFM2Name().c_str());
strcpy(fname, project.getFM2Name().c_str());
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = taseditor_window.hwndTasEditor;
ofn.hwndOwner = taseditorWindow.hwndTASEditor;
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Export to FM2";
ofn.lpstrFilter = filter;
@ -805,24 +806,24 @@ void Export()
// create copy of current movie data
MovieData temp_md = currMovieData;
// modify the copy according to selected type of export
SetInputType(temp_md, taseditor_config.last_export_type);
setInputType(temp_md, taseditorConfig.lastExportedInputType);
temp_md.loadFrameCount = -1;
// also add subtitles if needed
if (taseditor_config.last_export_subtitles)
if (taseditorConfig.lastExportedSubtitlesStatus)
{
// convert Marker Notes to Movie Subtitles
char framenum[11];
std::string subtitle;
int marker_id;
for (int i = 0; i < markers_manager.GetMarkersSize(); ++i)
int markerID;
for (int i = 0; i < markersManager.getMarkersArraySize(); ++i)
{
marker_id = markers_manager.GetMarker(i);
if (marker_id)
markerID = markersManager.getMarkerAtFrame(i);
if (markerID)
{
_itoa(i, framenum, 10);
strcat(framenum, " ");
subtitle = framenum;
subtitle.append(markers_manager.GetNote(marker_id));
subtitle.append(markersManager.getNoteCopy(markerID));
temp_md.subtitles.push_back(subtitle);
}
}
@ -835,7 +836,7 @@ void Export()
}
}
int GetInputType(MovieData& md)
int getInputType(MovieData& md)
{
if (md.fourscore)
return INPUT_TYPE_FOURSCORE;
@ -844,9 +845,9 @@ int GetInputType(MovieData& md)
else
return INPUT_TYPE_1P;
}
void SetInputType(MovieData& md, int new_input_type)
void setInputType(MovieData& md, int newInputType)
{
switch (new_input_type)
switch (newInputType)
{
case INPUT_TYPE_1P:
{
@ -872,7 +873,7 @@ void SetInputType(MovieData& md, int new_input_type)
}
}
void ApplyMovieInputConfig()
void applyMovieInputConfig()
{
// update FCEUX input config
FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]);
@ -885,23 +886,23 @@ void ApplyMovieInputConfig()
newppu = currMovieData.PPUflag;
SetMainWindowText();
// return focus to TAS Editor window
SetFocus(taseditor_window.hwndTasEditor);
SetFocus(taseditorWindow.hwndTASEditor);
}
// this getter contains formula to decide whether to record or replay movie
bool TaseditorIsRecording()
bool isTaseditorRecording()
{
if (movie_readonly || playback.GetPauseFrame() >= 0 || (taseditor_config.old_branching_controls && !recorder.state_was_loaded_in_readwrite_mode))
if (movie_readonly || playback.getPauseFrame() >= 0 || (taseditorConfig.oldControlSchemeForBranching && !recorder.stateWasLoadedInReadWriteMode))
return false; // replay
return true; // record
}
void Taseditor_RecordInput()
void recordInputByTaseditor()
{
recorder.InputChanged();
recorder.recordInput();
}
// this gate handles some FCEUX hotkeys (EMUCMD)
void Taseditor_EMUCMD(int command)
void handleEmuCmdByTaseditor(int command)
{
switch (command)
{
@ -916,7 +917,7 @@ void Taseditor_EMUCMD(int command)
case EMUCMD_SAVE_SLOT_8:
case EMUCMD_SAVE_SLOT_9:
{
if (taseditor_config.old_branching_controls)
if (taseditorConfig.oldControlSchemeForBranching)
bookmarks.command(COMMAND_SELECT, command - EMUCMD_SAVE_SLOT_0);
else
bookmarks.command(COMMAND_JUMP, command - EMUCMD_SAVE_SLOT_0);
@ -924,14 +925,14 @@ void Taseditor_EMUCMD(int command)
}
case EMUCMD_SAVE_SLOT_NEXT:
{
int slot = bookmarks.GetSelectedSlot() + 1;
int slot = bookmarks.getSelectedSlot() + 1;
if (slot >= TOTAL_BOOKMARKS) slot = 0;
bookmarks.command(COMMAND_SELECT, slot);
break;
}
case EMUCMD_SAVE_SLOT_PREV:
{
int slot = bookmarks.GetSelectedSlot() - 1;
int slot = bookmarks.getSelectedSlot() - 1;
if (slot < 0) slot = TOTAL_BOOKMARKS - 1;
bookmarks.command(COMMAND_SELECT, slot);
break;
@ -971,41 +972,41 @@ void Taseditor_EMUCMD(int command)
playback.jump(0);
break;
case EMUCMD_RELOAD:
taseditor_window.LoadRecentProject(0);
taseditorWindow.loadRecentProject(0);
break;
case EMUCMD_TASEDITOR_RESTORE_PLAYBACK:
playback.RestorePosition();
playback.restoreLastPosition();
break;
case EMUCMD_TASEDITOR_CANCEL_SEEKING:
playback.CancelSeeking();
playback.cancelSeeking();
break;
case EMUCMD_TASEDITOR_SWITCH_AUTORESTORING:
taseditor_config.restore_position ^= 1;
taseditor_window.UpdateCheckedItems();
taseditorConfig.autoRestoreLastPlaybackPosition ^= 1;
taseditorWindow.updateCheckedItems();
break;
case EMUCMD_TASEDITOR_SWITCH_MULTITRACKING:
recorder.multitrack_recording_joypad++;
if (recorder.multitrack_recording_joypad > joysticks_per_frame[GetInputType(currMovieData)])
recorder.multitrack_recording_joypad = 0;
recorder.multitrackRecordingJoypadNumber++;
if (recorder.multitrackRecordingJoypadNumber > joysticksPerFrame[getInputType(currMovieData)])
recorder.multitrackRecordingJoypadNumber = 0;
break;
case EMUCMD_TASEDITOR_RUN_MANUAL_LUA:
// the function will be called in next window update
must_call_manual_lua_function = true;
mustCallManualLuaFunction = true;
break;
}
}
// these functions allow/disallow some FCEUX hotkeys and TAS Editor accelerators
void SetTaseditorInput()
void enableGeneralKeyboardInput()
{
taseditor_accelerator_keys = true;
taseditorEnableAcceleratorKeys = true;
// set "Background TAS Editor input"
KeyboardSetBackgroundAccessBit(KEYBACKACCESS_TASEDITOR);
JoystickSetBackgroundAccessBit(JOYBACKACCESS_TASEDITOR);
}
void ClearTaseditorInput()
void disableGeneralKeyboardInput()
{
taseditor_accelerator_keys = false;
taseditorEnableAcceleratorKeys = false;
// clear "Background TAS Editor input"
KeyboardClearBackgroundAccessBit(KEYBACKACCESS_TASEDITOR);
JoystickClearBackgroundAccessBit(JOYBACKACCESS_TASEDITOR);

View File

@ -2,36 +2,37 @@
struct NewProjectParameters
{
int input_type;
bool copy_current_input;
bool copy_current_markers;
std::wstring author_name;
int inputType;
bool copyCurrentInput;
bool copyCurrentMarkers;
std::wstring authorName;
};
bool EnterTasEditor();
bool ExitTasEditor();
void UpdateTasEditor();
bool enterTASEditor();
bool exitTASEditor();
void updateTASEditor();
void NewProject();
void OpenProject();
bool LoadProject(const char* fullname);
bool SaveProject(bool save_compact = false);
bool SaveProjectAs(bool save_compact = false);
void SaveCompact();
bool AskSaveProject();
void createNewProject();
void openProject();
bool loadProject(const char* fullname);
bool saveProject(bool save_compact = false);
bool saveProjectAs(bool save_compact = false);
void saveCompact();
bool askToSaveProject();
void Import();
void Export();
void importInputData();
void exportToFM2();
int GetInputType(MovieData& md);
void SetInputType(MovieData& md, int new_input_type);
int getInputType(MovieData& md);
void setInputType(MovieData& md, int newInputType);
void ApplyMovieInputConfig();
void applyMovieInputConfig();
bool TaseditorIsRecording();
void Taseditor_RecordInput();
bool isTaseditorRecording();
void recordInputByTaseditor();
void Taseditor_EMUCMD(int command);
void SetTaseditorInput();
void ClearTaseditorInput();
void handleEmuCmdByTaseditor(int command);
void enableGeneralKeyboardInput();
void disableGeneralKeyboardInput();

View File

@ -18,7 +18,7 @@ Bookmark - Single Bookmark data
#include "taseditor_project.h"
#include "zlib.h"
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_CONFIG taseditorConfig;
extern GREENZONE greenzone;
extern HISTORY history;
@ -27,7 +27,7 @@ extern uint8 *XBackBuf;
BOOKMARK::BOOKMARK()
{
not_empty = false;
notEmpty = false;
}
void BOOKMARK::init()
@ -36,24 +36,24 @@ void BOOKMARK::init()
}
void BOOKMARK::free()
{
not_empty = false;
flash_type = flash_phase = floating_phase = 0;
notEmpty = false;
flashType = flashPhase = floatingPhase = 0;
SNAPSHOT tmp;
snapshot = tmp;
savestate.resize(0);
saved_screenshot.resize(0);
savedScreenshot.resize(0);
}
bool BOOKMARK::checkDiffFromCurrent()
bool BOOKMARK::isDifferentFromCurrentMovie()
{
// check if the Bookmark data differs from current project/MovieData/Markers/settings
if (not_empty && snapshot.keyframe == currFrameCounter)
if (notEmpty && snapshot.keyFrame == currFrameCounter)
{
if (snapshot.inputlog.size == currMovieData.getNumRecords() && snapshot.inputlog.findFirstChange(currMovieData) < 0)
{
if (!snapshot.MarkersDifferFromCurrent())
if (!snapshot.areMarkersDifferentFromCurrentMarkers())
{
if (snapshot.inputlog.has_hot_changes == taseditor_config.enable_hot_changes)
if (snapshot.inputlog.hasHotChanges == taseditorConfig.enableHotChanges)
{
return false;
}
@ -66,42 +66,42 @@ bool BOOKMARK::checkDiffFromCurrent()
void BOOKMARK::set()
{
// copy Input and Hotchanges
snapshot.init(currMovieData, taseditor_config.enable_hot_changes);
snapshot.keyframe = currFrameCounter;
if (taseditor_config.enable_hot_changes)
snapshot.inputlog.copyHotChanges(&history.GetCurrentSnapshot().inputlog);
snapshot.init(currMovieData, taseditorConfig.enableHotChanges);
snapshot.keyFrame = currFrameCounter;
if (taseditorConfig.enableHotChanges)
snapshot.inputlog.copyHotChanges(&history.getCurrentSnapshot().inputlog);
// copy savestate
savestate = greenzone.GetSavestate(currFrameCounter);
savestate = greenzone.getSavestateOfFrame(currFrameCounter);
// save screenshot
uLongf comprlen = (SCREENSHOT_SIZE>>9)+12 + SCREENSHOT_SIZE;
saved_screenshot.resize(comprlen);
savedScreenshot.resize(comprlen);
// compress screenshot data
if (taseditor_config.branch_scr_hud)
compress(&saved_screenshot[0], &comprlen, XBuf, SCREENSHOT_SIZE);
if (taseditorConfig.HUDInBranchScreenshots)
compress(&savedScreenshot[0], &comprlen, XBuf, SCREENSHOT_SIZE);
else
compress(&saved_screenshot[0], &comprlen, XBackBuf, SCREENSHOT_SIZE);
saved_screenshot.resize(comprlen);
compress(&savedScreenshot[0], &comprlen, XBackBuf, SCREENSHOT_SIZE);
savedScreenshot.resize(comprlen);
not_empty = true;
flash_phase = FLASH_PHASE_MAX;
flash_type = FLASH_TYPE_SET;
notEmpty = true;
flashPhase = FLASH_PHASE_MAX;
flashType = FLASH_TYPE_SET;
}
void BOOKMARK::jumped()
void BOOKMARK::handleJump()
{
flash_phase = FLASH_PHASE_MAX;
flash_type = FLASH_TYPE_JUMP;
flashPhase = FLASH_PHASE_MAX;
flashType = FLASH_TYPE_JUMP;
}
void BOOKMARK::deployed()
void BOOKMARK::handleDeploy()
{
flash_phase = FLASH_PHASE_MAX;
flash_type = FLASH_TYPE_DEPLOY;
flashPhase = FLASH_PHASE_MAX;
flashType = FLASH_TYPE_DEPLOY;
}
void BOOKMARK::save(EMUFILE *os)
{
if (not_empty)
if (notEmpty)
{
write8le(1, os);
// write snapshot
@ -111,9 +111,9 @@ void BOOKMARK::save(EMUFILE *os)
write32le(size, os);
os->fwrite(&savestate[0], size);
// write saved_screenshot
size = saved_screenshot.size();
size = savedScreenshot.size();
write32le(size, os);
os->fwrite(&saved_screenshot[0], size);
os->fwrite(&savedScreenshot[0], size);
} else write8le((uint8)0, os);
}
// returns true if couldn't load
@ -121,8 +121,8 @@ bool BOOKMARK::load(EMUFILE *is)
{
uint8 tmp;
if (!read8le(&tmp, is)) return true;
not_empty = (tmp != 0);
if (not_empty)
notEmpty = (tmp != 0);
if (notEmpty)
{
// read snapshot
if (snapshot.load(is)) return true;
@ -133,14 +133,14 @@ bool BOOKMARK::load(EMUFILE *is)
if ((int)is->fread(&savestate[0], size) < size) return true;
// read saved_screenshot
if (!read32le(&size, is)) return true;
saved_screenshot.resize(size);
if ((int)is->fread(&saved_screenshot[0], size) < size) return true;
savedScreenshot.resize(size);
if ((int)is->fread(&savedScreenshot[0], size) < size) return true;
} else
{
free();
}
// all ok - reset vars
flash_type = flash_phase = floating_phase = 0;
flashType = flashPhase = floatingPhase = 0;
return false;
}
bool BOOKMARK::skipLoad(EMUFILE *is)

View File

@ -3,7 +3,7 @@
#define FLASH_PHASE_MAX 11
#define FLASH_PHASE_BUTTONHELD 6
enum
enum FLASH_TYPES
{
FLASH_TYPE_SET = 0,
FLASH_TYPE_JUMP = 1,
@ -21,25 +21,26 @@ public:
void init();
void free();
bool checkDiffFromCurrent();
bool isDifferentFromCurrentMovie();
void set();
void jumped();
void deployed();
void handleJump();
void handleDeploy();
void save(EMUFILE *os);
bool load(EMUFILE *is);
bool skipLoad(EMUFILE *is);
// saved vars
bool not_empty;
bool notEmpty;
SNAPSHOT snapshot;
std::vector<uint8> savestate;
std::vector<uint8> saved_screenshot;
std::vector<uint8> savedScreenshot;
// not saved vars
int flash_phase;
int flash_type;
int floating_phase;
int flashPhase;
int flashType;
int floatingPhase;
private:

View File

@ -28,17 +28,17 @@ Bookmarks/Branches - Manager of Bookmarks
LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
WNDPROC hwndBookmarksList_oldWndProc;
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern POPUP_DISPLAY popup_display;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern POPUP_DISPLAY popupDisplay;
extern PLAYBACK playback;
extern RECORDER recorder;
extern SELECTION selection;
extern GREENZONE greenzone;
extern TASEDITOR_PROJECT project;
extern HISTORY history;
extern PIANO_ROLL piano_roll;
extern MARKERS_MANAGER markers_manager;
extern PIANO_ROLL pianoRoll;
extern MARKERS_MANAGER markersManager;
extern BRANCHES branches;
// resources
@ -46,7 +46,7 @@ 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[TOTAL_COMMANDS][FLASH_PHASE_MAX+1] = {
COLORREF bookmark_flash_colors[TOTAL_BOOKMARK_COMMANDS][FLASH_PHASE_MAX+1] = {
// set
//0x122330, 0x1b3541, 0x254753, 0x2e5964, 0x376b75, 0x417e87, 0x4a8f97, 0x53a1a8, 0x5db3b9, 0x66c5cb, 0x70d7dc, 0x79e9ed,
0x0d1241, 0x111853, 0x161e64, 0x1a2575, 0x1f2b87, 0x233197, 0x2837a8, 0x2c3db9, 0x3144cb, 0x354adc, 0x3a50ed, 0x3f57ff,
@ -61,145 +61,145 @@ BOOKMARKS::BOOKMARKS()
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = NULL;
list_tme.cbSize = sizeof(tme);
list_tme.dwFlags = TME_LEAVE;
list_tme.hwndTrack = NULL;
tmeList.cbSize = sizeof(tme);
tmeList.dwFlags = TME_LEAVE;
tmeList.hwndTrack = NULL;
}
void BOOKMARKS::init()
{
free();
hwndBookmarksList = GetDlgItem(taseditor_window.hwndTasEditor, IDC_BOOKMARKSLIST);
hwndBranchesBitmap = GetDlgItem(taseditor_window.hwndTasEditor, IDC_BRANCHES_BITMAP);
hwndBookmarks = GetDlgItem(taseditor_window.hwndTasEditor, IDC_BOOKMARKS_BOX);
hwndBookmarksList = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKSLIST);
hwndBranchesBitmap = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BRANCHES_BITMAP);
hwndBookmarks = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKS_BOX);
// prepare bookmarks listview
ListView_SetExtendedListViewStyleEx(hwndBookmarksList, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
// subclass the listview
hwndBookmarksList_oldWndProc = (WNDPROC)SetWindowLong(hwndBookmarksList, GWL_WNDPROC, (LONG)BookmarksListWndProc);
// setup images for the listview
himglist = ImageList_Create(11, 13, ILC_COLOR8 | ILC_MASK, 1, 1);
hImgList = ImageList_Create(11, 13, ILC_COLOR8 | ILC_MASK, 1, 1);
HBITMAP bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP0));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP2));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP3));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP4));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP5));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP6));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP7));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP8));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP9));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP10));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP11));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP12));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP13));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP14));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP15));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP16));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP17));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP18));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP19));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED0));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED1));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED2));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED3));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED4));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED5));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED6));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED7));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED8));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED9));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED10));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED11));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED12));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED13));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED14));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED15));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED16));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED17));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED18));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED19));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
DeleteObject(bmp);
ListView_SetImageList(hwndBookmarksList, himglist, LVSIL_SMALL);
ListView_SetImageList(hwndBookmarksList, hImgList, LVSIL_SMALL);
// setup columns
LVCOLUMN lvc;
// icons column
@ -212,47 +212,47 @@ void BOOKMARKS::init()
lvc.cx = BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH;
ListView_InsertColumn(hwndBookmarksList, 1, &lvc);
// time column
lvc.cx = BOOKMARKSLIST_COLUMN_TIME_WIDTH;
lvc.cx = BOOKMARKSLIST_COLUMN_TIMESTAMP_WIDTH;
ListView_InsertColumn(hwndBookmarksList, 2, &lvc);
// create 10 rows
ListView_SetItemCountEx(hwndBookmarksList, TOTAL_BOOKMARKS, LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL);
reset();
selected_slot = DEFAULT_SLOT;
selectedSlot = DEFAULT_SLOT;
// find the top/height of the "Time" cell of the 1st row (for mouseover hittest calculations)
RECT temp_rect, wrect;
if (ListView_GetSubItemRect(hwndBookmarksList, 0, 2, LVIR_BOUNDS, &temp_rect) && temp_rect.bottom != temp_rect.top)
{
list_row_top = temp_rect.top;
list_row_left = temp_rect.left;
list_row_height = temp_rect.bottom - temp_rect.top;
listTopMargin = temp_rect.top;
listRowLeft = temp_rect.left;
listRowHeight = temp_rect.bottom - temp_rect.top;
} else
{
// couldn't get rect, set default values
list_row_top = 0;
list_row_left = BOOKMARKSLIST_COLUMN_ICONS_WIDTH + BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH;
list_row_height = 14;
listTopMargin = 0;
listRowLeft = BOOKMARKSLIST_COLUMN_ICONS_WIDTH + BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH;
listRowHeight = 14;
}
// calculate the needed height of client area (so that all 10 rows fir the screen)
int total_list_height = list_row_top + list_row_height * TOTAL_BOOKMARKS;
int total_list_height = listTopMargin + listRowHeight * TOTAL_BOOKMARKS;
// find the difference between Bookmarks List window and Bookmarks List client area
GetWindowRect(hwndBookmarksList, &wrect);
GetClientRect(hwndBookmarksList, &temp_rect);
total_list_height += (wrect.bottom - wrect.top) - (temp_rect.bottom - temp_rect.top);
// change the height
taseditor_window.ChangeBookmarksListHeight(total_list_height);
taseditorWindow.changeBookmarksListHeight(total_list_height);
RedrawBookmarksCaption();
redrawBookmarksSectionCaption();
}
void BOOKMARKS::free()
{
bookmarks_array.resize(0);
if (himglist)
bookmarksArray.resize(0);
if (hImgList)
{
ImageList_Destroy(himglist);
himglist = 0;
ImageList_Destroy(hImgList);
hImgList = 0;
}
}
void BOOKMARKS::reset()
@ -260,20 +260,20 @@ void BOOKMARKS::reset()
// delete all commands if there are any
commands.resize(0);
// init bookmarks
bookmarks_array.resize(0);
bookmarks_array.resize(TOTAL_BOOKMARKS);
bookmarksArray.resize(0);
bookmarksArray.resize(TOTAL_BOOKMARKS);
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
bookmarks_array[i].init();
bookmarksArray[i].init();
reset_vars();
}
void BOOKMARKS::reset_vars()
{
mouse_x = mouse_y = -1;
item_under_mouse = ITEM_UNDER_MOUSE_NONE;
mouse_over_bitmap = false;
must_check_item_under_mouse = true;
bookmark_leftclicked = bookmark_rightclicked = ITEM_UNDER_MOUSE_NONE;
check_flash_shedule = clock() + BOOKMARKS_FLASH_TICK;
mouseX = mouseY = -1;
itemUnderMouse = ITEM_UNDER_MOUSE_NONE;
mouseOverBranchesBitmap = false;
mustCheckItemUnderMouse = true;
bookmarkLeftclicked = bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE;
nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK;
}
void BOOKMARKS::update()
@ -295,12 +295,12 @@ void BOOKMARKS::update()
deploy(slot);
break;
case COMMAND_SELECT:
if (selected_slot != slot)
if (selectedSlot != slot)
{
int old_selected_slot = selected_slot;
selected_slot = slot;
RedrawBookmark(old_selected_slot);
RedrawBookmark(selected_slot);
int old_selected_slot = selectedSlot;
selectedSlot = slot;
redrawBookmark(old_selected_slot);
redrawBookmark(selectedSlot);
}
break;
}
@ -308,41 +308,41 @@ void BOOKMARKS::update()
commands.resize(0);
// once per 100 milliseconds update bookmark flashes
if (clock() > check_flash_shedule)
if (clock() > nextFlashUpdateTime)
{
check_flash_shedule = clock() + BOOKMARKS_FLASH_TICK;
nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK;
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
{
if (bookmark_rightclicked == i || bookmark_leftclicked == i)
if (bookmarkRightclicked == i || bookmarkLeftclicked == i)
{
if (bookmarks_array[i].flash_phase != FLASH_PHASE_BUTTONHELD)
if (bookmarksArray[i].flashPhase != FLASH_PHASE_BUTTONHELD)
{
bookmarks_array[i].flash_phase = FLASH_PHASE_BUTTONHELD;
RedrawBookmark(i);
branches.must_redraw_branches_tree = true; // because border of branch digit has changed
bookmarksArray[i].flashPhase = FLASH_PHASE_BUTTONHELD;
redrawBookmark(i);
branches.mustRedrawBranchesBitmap = true; // because border of branch digit has changed
}
} else
{
if (bookmarks_array[i].flash_phase > 0)
if (bookmarksArray[i].flashPhase > 0)
{
bookmarks_array[i].flash_phase--;
RedrawBookmark(i);
branches.must_redraw_branches_tree = true; // because border of branch digit has changed
bookmarksArray[i].flashPhase--;
redrawBookmark(i);
branches.mustRedrawBranchesBitmap = true; // because border of branch digit has changed
}
}
}
}
// controls
if (must_check_item_under_mouse)
if (mustCheckItemUnderMouse)
{
if (edit_mode == EDIT_MODE_BRANCHES)
item_under_mouse = branches.FindItemUnderMouse(mouse_x, mouse_y);
else if (edit_mode == EDIT_MODE_BOTH)
item_under_mouse = FindItemUnderMouse();
if (editMode == EDIT_MODE_BRANCHES)
itemUnderMouse = branches.findItemUnderMouse(mouseX, mouseY);
else if (editMode == EDIT_MODE_BOTH)
itemUnderMouse = findItemUnderMouse();
else
item_under_mouse = ITEM_UNDER_MOUSE_NONE;
must_check_item_under_mouse = false;
itemUnderMouse = ITEM_UNDER_MOUSE_NONE;
mustCheckItemUnderMouse = false;
}
}
@ -350,7 +350,7 @@ void BOOKMARKS::update()
void BOOKMARKS::command(int command_id, int slot)
{
if (slot < 0)
slot = selected_slot;
slot = selectedSlot;
if (slot >= 0 && slot < TOTAL_BOOKMARKS)
{
commands.push_back(command_id);
@ -363,36 +363,36 @@ void BOOKMARKS::set(int slot)
if (slot < 0 || slot >= TOTAL_BOOKMARKS) return;
// First save changes in edited note (in case it's being currently edited)
markers_manager.UpdateMarkerNote();
markersManager.updateEditedMarkerNote();
int previous_frame = bookmarks_array[slot].snapshot.keyframe;
if (bookmarks_array[slot].checkDiffFromCurrent())
int previous_frame = bookmarksArray[slot].snapshot.keyFrame;
if (bookmarksArray[slot].isDifferentFromCurrentMovie())
{
BOOKMARK backup_copy(bookmarks_array[slot]);
bookmarks_array[slot].set();
BOOKMARK backup_copy(bookmarksArray[slot]);
bookmarksArray[slot].set();
// rebuild Branches Tree
int old_current_branch = branches.GetCurrentBranch();
branches.HandleBookmarkSet(slot);
int old_current_branch = branches.getCurrentBranch();
branches.handleBookmarkSet(slot);
if (slot != old_current_branch && old_current_branch != ITEM_UNDER_MOUSE_CLOUD)
{
// current_branch was switched to slot, redraw Bookmarks List to change the color of digits
piano_roll.RedrawRow(bookmarks_array[old_current_branch].snapshot.keyframe);
RedrawChangedBookmarks(bookmarks_array[old_current_branch].snapshot.keyframe);
pianoRoll.redrawRow(bookmarksArray[old_current_branch].snapshot.keyFrame);
redrawChangedBookmarks(bookmarksArray[old_current_branch].snapshot.keyFrame);
}
// also redraw List rows
if (previous_frame >= 0 && previous_frame != currFrameCounter)
{
piano_roll.RedrawRow(previous_frame);
RedrawChangedBookmarks(previous_frame);
pianoRoll.redrawRow(previous_frame);
redrawChangedBookmarks(previous_frame);
}
piano_roll.RedrawRow(currFrameCounter);
RedrawChangedBookmarks(currFrameCounter);
pianoRoll.redrawRow(currFrameCounter);
redrawChangedBookmarks(currFrameCounter);
// if screenshot of the slot is currently shown - reinit and redraw the picture
if (popup_display.screenshot_currently_shown == slot)
popup_display.screenshot_currently_shown = ITEM_UNDER_MOUSE_NONE;
if (popupDisplay.currentlyDisplayedBookmark == slot)
popupDisplay.currentlyDisplayedBookmark = ITEM_UNDER_MOUSE_NONE;
history.RegisterBookmarkSet(slot, backup_copy, old_current_branch);
must_check_item_under_mouse = true;
history.registerBookmarkSet(slot, backup_copy, old_current_branch);
mustCheckItemUnderMouse = true;
FCEU_DispMessage("Branch %d saved.", 0, slot);
}
}
@ -400,81 +400,81 @@ void BOOKMARKS::set(int slot)
void BOOKMARKS::jump(int slot)
{
if (slot < 0 || slot >= TOTAL_BOOKMARKS) return;
if (bookmarks_array[slot].not_empty)
if (bookmarksArray[slot].notEmpty)
{
int frame = bookmarks_array[slot].snapshot.keyframe;
int frame = bookmarksArray[slot].snapshot.keyFrame;
playback.jump(frame);
bookmarks_array[slot].jumped();
bookmarksArray[slot].handleJump();
}
}
void BOOKMARKS::deploy(int slot)
{
recorder.state_was_loaded_in_readwrite_mode = true;
if (taseditor_config.old_branching_controls && movie_readonly)
recorder.stateWasLoadedInReadWriteMode = true;
if (taseditorConfig.oldControlSchemeForBranching && movie_readonly)
{
jump(slot);
return;
}
if (slot < 0 || slot >= TOTAL_BOOKMARKS) return;
if (!bookmarks_array[slot].not_empty) return;
if (!bookmarksArray[slot].notEmpty) return;
int keyframe = bookmarks_array[slot].snapshot.keyframe;
int keyframe = bookmarksArray[slot].snapshot.keyFrame;
bool markers_changed = false;
// revert Markers to the Bookmarked state
if (bookmarks_array[slot].snapshot.MarkersDifferFromCurrent())
if (bookmarksArray[slot].snapshot.areMarkersDifferentFromCurrentMarkers())
{
bookmarks_array[slot].snapshot.copyToMarkers();
bookmarksArray[slot].snapshot.copyToCurrentMarkers();
markers_changed = true;
}
// revert current movie data to the Bookmarked state
if (taseditor_config.branch_full_movie)
if (taseditorConfig.branchesRestoreEntireMovie)
{
bookmarks_array[slot].snapshot.inputlog.toMovie(currMovieData);
bookmarksArray[slot].snapshot.inputlog.toMovie(currMovieData);
} else
{
// restore movie up to and not including bookmarked frame (simulating old TASing method)
if (keyframe)
bookmarks_array[slot].snapshot.inputlog.toMovie(currMovieData, 0, keyframe - 1);
bookmarksArray[slot].snapshot.inputlog.toMovie(currMovieData, 0, keyframe - 1);
else
currMovieData.truncateAt(0);
// add empty frame at the end (at keyframe)
currMovieData.insertEmpty(-1, 1);
}
int first_change = history.RegisterBranching(slot, markers_changed); // this also reverts Greenzone's LagLog if needed
int first_change = history.registerBranching(slot, markers_changed); // this also reverts Greenzone's LagLog if needed
if (first_change >= 0)
{
selection.must_find_current_marker = playback.must_find_current_marker = true;
piano_roll.UpdateItemCount();
greenzone.Invalidate(first_change);
bookmarks_array[slot].deployed();
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
pianoRoll.updateLinesCount();
greenzone.invalidate(first_change);
bookmarksArray[slot].handleDeploy();
} else if (markers_changed)
{
selection.must_find_current_marker = playback.must_find_current_marker = true;
bookmarks_array[slot].deployed();
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
bookmarksArray[slot].handleDeploy();
} else
{
// didn't change anything in current movie
bookmarks_array[slot].jumped();
bookmarksArray[slot].handleJump();
}
// jump to the target (bookmarked frame)
if (greenzone.SavestateIsEmpty(keyframe))
greenzone.WriteSavestate(keyframe, bookmarks_array[slot].savestate);
if (greenzone.isSavestateEmpty(keyframe))
greenzone.writeSavestateForFrame(keyframe, bookmarksArray[slot].savestate);
playback.jump(keyframe, true);
// switch current branch to this branch
int old_current_branch = branches.GetCurrentBranch();
branches.HandleBookmarkDeploy(slot);
int old_current_branch = branches.getCurrentBranch();
branches.handleBookmarkDeploy(slot);
if (slot != old_current_branch && old_current_branch != ITEM_UNDER_MOUSE_CLOUD)
{
piano_roll.RedrawRow(bookmarks_array[old_current_branch].snapshot.keyframe);
RedrawChangedBookmarks(bookmarks_array[old_current_branch].snapshot.keyframe);
piano_roll.RedrawRow(keyframe);
RedrawChangedBookmarks(keyframe);
pianoRoll.redrawRow(bookmarksArray[old_current_branch].snapshot.keyFrame);
redrawChangedBookmarks(bookmarksArray[old_current_branch].snapshot.keyFrame);
pianoRoll.redrawRow(keyframe);
redrawChangedBookmarks(keyframe);
}
FCEU_DispMessage("Branch %d loaded.", 0, slot);
piano_roll.RedrawList(); // even though the Greenzone invalidation most likely have already sent the command to redraw
pianoRoll.redraw(); // even though the Greenzone invalidation most likely have already sent the command to redraw
}
void BOOKMARKS::save(EMUFILE *os, bool really_save)
@ -485,7 +485,7 @@ void BOOKMARKS::save(EMUFILE *os, bool really_save)
os->fwrite(bookmarks_save_id, BOOKMARKS_ID_LEN);
// write all 10 bookmarks
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
bookmarks_array[i].save(os);
bookmarksArray[i].save(os);
// write branches
branches.save(os);
} else
@ -520,12 +520,12 @@ bool BOOKMARKS::load(EMUFILE *is, unsigned int offset)
if (strcmp(bookmarks_save_id, save_id)) goto error; // string is not valid
// read all 10 bookmarks
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
if (bookmarks_array[i].load(is)) goto error;
if (bookmarksArray[i].load(is)) goto error;
// read branches
if (branches.load(is)) goto error;
// all ok
reset_vars();
RedrawBookmarksCaption();
redrawBookmarksSectionCaption();
return false;
error:
FCEU_printf("Error loading Bookmarks\n");
@ -534,115 +534,115 @@ error:
return true;
}
// ----------------------------------------------------------
void BOOKMARKS::RedrawBookmarksCaption()
void BOOKMARKS::redrawBookmarksSectionCaption()
{
int prev_edit_mode = edit_mode;
if (taseditor_config.view_branches_tree)
int prev_edit_mode = editMode;
if (taseditorConfig.displayBranchesTree)
{
edit_mode = EDIT_MODE_BRANCHES;
editMode = EDIT_MODE_BRANCHES;
ShowWindow(hwndBookmarksList, SW_HIDE);
ShowWindow(hwndBranchesBitmap, SW_SHOW);
} else if (taseditor_config.old_branching_controls && movie_readonly)
} else if (taseditorConfig.oldControlSchemeForBranching && movie_readonly)
{
edit_mode = EDIT_MODE_BOOKMARKS;
editMode = EDIT_MODE_BOOKMARKS;
ShowWindow(hwndBranchesBitmap, SW_HIDE);
ShowWindow(hwndBookmarksList, SW_SHOW);
RedrawBookmarksList();
redrawBookmarksList();
} else
{
edit_mode = EDIT_MODE_BOTH;
editMode = EDIT_MODE_BOTH;
ShowWindow(hwndBranchesBitmap, SW_HIDE);
ShowWindow(hwndBookmarksList, SW_SHOW);
RedrawBookmarksList();
redrawBookmarksList();
}
if (prev_edit_mode != edit_mode)
must_check_item_under_mouse = true;
SetWindowText(hwndBookmarks, bookmarksCaption[edit_mode]);
if (prev_edit_mode != editMode)
mustCheckItemUnderMouse = true;
SetWindowText(hwndBookmarks, bookmarksCaption[editMode]);
}
void BOOKMARKS::RedrawBookmarksList(bool erase_bg)
void BOOKMARKS::redrawBookmarksList(bool eraseBG)
{
if (edit_mode != EDIT_MODE_BRANCHES)
InvalidateRect(hwndBookmarksList, 0, erase_bg);
if (editMode != EDIT_MODE_BRANCHES)
InvalidateRect(hwndBookmarksList, 0, eraseBG);
}
void BOOKMARKS::RedrawChangedBookmarks(int frame)
void BOOKMARKS::redrawChangedBookmarks(int frame)
{
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
{
if (bookmarks_array[i].snapshot.keyframe == frame)
RedrawBookmark(i);
if (bookmarksArray[i].snapshot.keyFrame == frame)
redrawBookmark(i);
}
}
void BOOKMARKS::RedrawBookmark(int bookmark_number)
void BOOKMARKS::redrawBookmark(int bookmarkNumber)
{
RedrawListRow((bookmark_number + TOTAL_BOOKMARKS - 1) % TOTAL_BOOKMARKS);
redrawBookmarksListRow((bookmarkNumber + TOTAL_BOOKMARKS - 1) % TOTAL_BOOKMARKS);
}
void BOOKMARKS::RedrawListRow(int row_index)
void BOOKMARKS::redrawBookmarksListRow(int rowIndex)
{
ListView_RedrawItems(hwndBookmarksList, row_index, row_index);
ListView_RedrawItems(hwndBookmarksList, rowIndex, rowIndex);
}
void BOOKMARKS::MouseMove(int new_x, int new_y)
void BOOKMARKS::handleMouseMove(int newX, int newY)
{
mouse_x = new_x;
mouse_y = new_y;
must_check_item_under_mouse = true;
mouseX = newX;
mouseY = newY;
mustCheckItemUnderMouse = true;
}
int BOOKMARKS::FindItemUnderMouse()
int BOOKMARKS::findItemUnderMouse()
{
int item = ITEM_UNDER_MOUSE_NONE;
RECT wrect;
GetClientRect(hwndBookmarksList, &wrect);
if (mouse_x >= list_row_left && mouse_x < wrect.right - wrect.left && mouse_y >= list_row_top && mouse_y < wrect.bottom - wrect.top)
if (mouseX >= listRowLeft && mouseX < wrect.right - wrect.left && mouseY >= listTopMargin && mouseY < wrect.bottom - wrect.top)
{
int row_under_mouse = (mouse_y - list_row_top) / list_row_height;
int row_under_mouse = (mouseY - listTopMargin) / listRowHeight;
if (row_under_mouse >= 0 && row_under_mouse < TOTAL_BOOKMARKS)
item = (row_under_mouse + 1) % TOTAL_BOOKMARKS;
}
return item;
}
int BOOKMARKS::GetSelectedSlot()
int BOOKMARKS::getSelectedSlot()
{
return selected_slot;
return selectedSlot;
}
// ----------------------------------------------------------------------------------------
void BOOKMARKS::GetDispInfo(NMLVDISPINFO* nmlvDispInfo)
void BOOKMARKS::getDispInfo(NMLVDISPINFO* nmlvDispInfo)
{
LVITEM& item = nmlvDispInfo->item;
if (item.mask & LVIF_TEXT)
{
switch(item.iSubItem)
{
case BOOKMARKS_COLUMN_ICON:
case BOOKMARKSLIST_COLUMN_ICON:
{
if ((item.iItem + 1) % TOTAL_BOOKMARKS == branches.GetCurrentBranch())
if ((item.iItem + 1) % TOTAL_BOOKMARKS == branches.getCurrentBranch())
item.iImage = ((item.iItem + 1) % TOTAL_BOOKMARKS) + TOTAL_BOOKMARKS;
else
item.iImage = (item.iItem + 1) % TOTAL_BOOKMARKS;
if (taseditor_config.old_branching_controls)
if (taseditorConfig.oldControlSchemeForBranching)
{
if ((item.iItem + 1) % TOTAL_BOOKMARKS == selected_slot)
item.iImage += BOOKMARKS_SELECTED;
if ((item.iItem + 1) % TOTAL_BOOKMARKS == selectedSlot)
item.iImage += BOOKMARKS_BITMAPS_SELECTED;
}
break;
}
case BOOKMARKS_COLUMN_FRAME:
case BOOKMARKSLIST_COLUMN_FRAME:
{
if (bookmarks_array[(item.iItem + 1) % TOTAL_BOOKMARKS].not_empty)
U32ToDecStr(item.pszText, bookmarks_array[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.keyframe, DIGITS_IN_FRAMENUM);
if (bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].notEmpty)
U32ToDecStr(item.pszText, bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.keyFrame, DIGITS_IN_FRAMENUM);
break;
}
case BOOKMARKS_COLUMN_TIME:
case BOOKMARKSLIST_COLUMN_TIME:
{
if (bookmarks_array[(item.iItem + 1) % TOTAL_BOOKMARKS].not_empty)
strcpy(item.pszText, bookmarks_array[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.description);
if (bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].notEmpty)
strcpy(item.pszText, bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.description);
}
break;
}
}
}
LONG BOOKMARKS::CustomDraw(NMLVCUSTOMDRAW* msg)
LONG BOOKMARKS::handleCustomDraw(NMLVCUSTOMDRAW* msg)
{
int cell_x, cell_y;
switch(msg->nmcd.dwDrawStage)
@ -656,65 +656,65 @@ LONG BOOKMARKS::CustomDraw(NMLVCUSTOMDRAW* msg)
cell_y = (msg->nmcd.dwItemSpec + 1) % TOTAL_BOOKMARKS;
// flash with text color when needed
if (bookmarks_array[cell_y].flash_phase)
msg->clrText = bookmark_flash_colors[bookmarks_array[cell_y].flash_type][bookmarks_array[cell_y].flash_phase];
if (bookmarksArray[cell_y].flashPhase)
msg->clrText = bookmark_flash_colors[bookmarksArray[cell_y].flashType][bookmarksArray[cell_y].flashPhase];
if (cell_x == BOOKMARKS_COLUMN_FRAME || (taseditor_config.old_branching_controls && movie_readonly && cell_x == BOOKMARKS_COLUMN_TIME))
if (cell_x == BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig.oldControlSchemeForBranching && movie_readonly && cell_x == BOOKMARKSLIST_COLUMN_TIME))
{
if (bookmarks_array[cell_y].not_empty)
if (bookmarksArray[cell_y].notEmpty)
{
// frame number
SelectObject(msg->nmcd.hdc, piano_roll.hMainListFont);
int frame = bookmarks_array[cell_y].snapshot.keyframe;
if (frame == currFrameCounter || frame == (playback.GetFlashingPauseFrame() - 1))
SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont);
int frame = bookmarksArray[cell_y].snapshot.keyFrame;
if (frame == currFrameCounter || frame == (playback.getFlashingPauseFrame() - 1))
{
// current frame
msg->clrTextBk = CUR_FRAMENUM_COLOR;
} else if (frame < greenzone.GetSize())
} else if (frame < greenzone.getSize())
{
if (!greenzone.SavestateIsEmpty(frame))
if (!greenzone.isSavestateEmpty(frame))
{
if (greenzone.laglog.GetLagInfoAtFrame(frame) == LAGGED_YES)
if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
msg->clrTextBk = LAG_FRAMENUM_COLOR;
else
msg->clrTextBk = GREENZONE_FRAMENUM_COLOR;
} else if (!greenzone.SavestateIsEmpty(cell_y & EVERY16TH)
|| !greenzone.SavestateIsEmpty(cell_y & EVERY8TH)
|| !greenzone.SavestateIsEmpty(cell_y & EVERY4TH)
|| !greenzone.SavestateIsEmpty(cell_y & EVERY2ND))
} else if (!greenzone.isSavestateEmpty(cell_y & EVERY16TH)
|| !greenzone.isSavestateEmpty(cell_y & EVERY8TH)
|| !greenzone.isSavestateEmpty(cell_y & EVERY4TH)
|| !greenzone.isSavestateEmpty(cell_y & EVERY2ND))
{
if (greenzone.laglog.GetLagInfoAtFrame(frame) == LAGGED_YES)
if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
msg->clrTextBk = PALE_LAG_FRAMENUM_COLOR;
else
msg->clrTextBk = PALE_GREENZONE_FRAMENUM_COLOR;
} else msg->clrTextBk = NORMAL_FRAMENUM_COLOR;
} else msg->clrTextBk = NORMAL_FRAMENUM_COLOR;
} else msg->clrTextBk = NORMAL_BACKGROUND_COLOR; // empty bookmark
} else if (cell_x == BOOKMARKS_COLUMN_TIME)
} else if (cell_x == BOOKMARKSLIST_COLUMN_TIME)
{
if (bookmarks_array[cell_y].not_empty)
if (bookmarksArray[cell_y].notEmpty)
{
// frame number
SelectObject(msg->nmcd.hdc, piano_roll.hMainListFont);
int frame = bookmarks_array[cell_y].snapshot.keyframe;
if (frame == currFrameCounter || frame == (playback.GetFlashingPauseFrame() - 1))
SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont);
int frame = bookmarksArray[cell_y].snapshot.keyFrame;
if (frame == currFrameCounter || frame == (playback.getFlashingPauseFrame() - 1))
{
// current frame
msg->clrTextBk = CUR_INPUT_COLOR1;
} else if (frame < greenzone.GetSize())
} else if (frame < greenzone.getSize())
{
if (!greenzone.SavestateIsEmpty(frame))
if (!greenzone.isSavestateEmpty(frame))
{
if (greenzone.laglog.GetLagInfoAtFrame(frame) == LAGGED_YES)
if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
msg->clrTextBk = LAG_INPUT_COLOR1;
else
msg->clrTextBk = GREENZONE_INPUT_COLOR1;
} else if (!greenzone.SavestateIsEmpty(cell_y & EVERY16TH)
|| !greenzone.SavestateIsEmpty(cell_y & EVERY8TH)
|| !greenzone.SavestateIsEmpty(cell_y & EVERY4TH)
|| !greenzone.SavestateIsEmpty(cell_y & EVERY2ND))
} else if (!greenzone.isSavestateEmpty(cell_y & EVERY16TH)
|| !greenzone.isSavestateEmpty(cell_y & EVERY8TH)
|| !greenzone.isSavestateEmpty(cell_y & EVERY4TH)
|| !greenzone.isSavestateEmpty(cell_y & EVERY2ND))
{
if (greenzone.laglog.GetLagInfoAtFrame(frame) == LAGGED_YES)
if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
msg->clrTextBk = PALE_LAG_INPUT_COLOR1;
else
msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR1;
@ -727,28 +727,28 @@ LONG BOOKMARKS::CustomDraw(NMLVCUSTOMDRAW* msg)
}
}
void BOOKMARKS::LeftClick()
void BOOKMARKS::handleLeftClick()
{
if (column_clicked <= BOOKMARKS_COLUMN_FRAME || (taseditor_config.old_branching_controls && movie_readonly))
command(COMMAND_JUMP, bookmark_leftclicked);
else if (column_clicked == BOOKMARKS_COLUMN_TIME && (!taseditor_config.old_branching_controls || !movie_readonly))
command(COMMAND_DEPLOY, bookmark_leftclicked);
if (columnClicked <= BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig.oldControlSchemeForBranching && movie_readonly))
command(COMMAND_JUMP, bookmarkLeftclicked);
else if (columnClicked == BOOKMARKSLIST_COLUMN_TIME && (!taseditorConfig.oldControlSchemeForBranching || !movie_readonly))
command(COMMAND_DEPLOY, bookmarkLeftclicked);
}
void BOOKMARKS::RightClick()
void BOOKMARKS::handleRightClick()
{
if (bookmark_rightclicked >= 0)
command(COMMAND_SET, bookmark_rightclicked);
if (bookmarkRightclicked >= 0)
command(COMMAND_SET, bookmarkRightclicked);
}
int BOOKMARKS::FindBookmarkAtFrame(int frame)
int BOOKMARKS::findBookmarkAtFrame(int frame)
{
int cur_bookmark = branches.GetCurrentBranch();
if (cur_bookmark != ITEM_UNDER_MOUSE_CLOUD && bookmarks_array[cur_bookmark].snapshot.keyframe == frame)
int cur_bookmark = branches.getCurrentBranch();
if (cur_bookmark != ITEM_UNDER_MOUSE_CLOUD && bookmarksArray[cur_bookmark].snapshot.keyFrame == frame)
return cur_bookmark + TOTAL_BOOKMARKS; // blue digit has highest priority when drawing
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
{
cur_bookmark = (i + 1) % TOTAL_BOOKMARKS;
if (bookmarks_array[cur_bookmark].not_empty && bookmarks_array[cur_bookmark].snapshot.keyframe == frame)
if (bookmarksArray[cur_bookmark].notEmpty && bookmarksArray[cur_bookmark].snapshot.keyFrame == frame)
return cur_bookmark; // green digit
}
return -1; // no Bookmarks at the frame
@ -767,19 +767,19 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
return 0;
case WM_MOUSEMOVE:
{
if (!bookmarks.mouse_over_bookmarkslist)
if (!bookmarks.mouseOverBookmarksList)
{
bookmarks.mouse_over_bookmarkslist = true;
bookmarks.list_tme.hwndTrack = hWnd;
TrackMouseEvent(&bookmarks.list_tme);
bookmarks.mouseOverBookmarksList = true;
bookmarks.tmeList.hwndTrack = hWnd;
TrackMouseEvent(&bookmarks.tmeList);
}
bookmarks.MouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
bookmarks.handleMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
}
case WM_MOUSELEAVE:
{
bookmarks.mouse_over_bookmarkslist = false;
bookmarks.MouseMove(-1, -1);
bookmarks.mouseOverBookmarksList = false;
bookmarks.handleMouseMove(-1, -1);
break;
}
case WM_LBUTTONDOWN:
@ -791,14 +791,14 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam);
ListView_SubItemHitTest(hWnd, (LPARAM)&info);
if (info.iItem >= 0 && bookmarks.bookmark_rightclicked < 0)
if (info.iItem >= 0 && bookmarks.bookmarkRightclicked < 0)
{
bookmarks.bookmark_leftclicked = (info.iItem + 1) % TOTAL_BOOKMARKS;
bookmarks.column_clicked = info.iSubItem;
if (bookmarks.column_clicked <= BOOKMARKS_COLUMN_FRAME || (taseditor_config.old_branching_controls && movie_readonly))
bookmarks.bookmarks_array[bookmarks.bookmark_leftclicked].flash_type = FLASH_TYPE_JUMP;
else if (bookmarks.column_clicked == BOOKMARKS_COLUMN_TIME && (!taseditor_config.old_branching_controls || !movie_readonly))
bookmarks.bookmarks_array[bookmarks.bookmark_leftclicked].flash_type = FLASH_TYPE_DEPLOY;
bookmarks.bookmarkLeftclicked = (info.iItem + 1) % TOTAL_BOOKMARKS;
bookmarks.columnClicked = info.iSubItem;
if (bookmarks.columnClicked <= BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig.oldControlSchemeForBranching && movie_readonly))
bookmarks.bookmarksArray[bookmarks.bookmarkLeftclicked].flashType = FLASH_TYPE_JUMP;
else if (bookmarks.columnClicked == BOOKMARKSLIST_COLUMN_TIME && (!taseditorConfig.oldControlSchemeForBranching || !movie_readonly))
bookmarks.bookmarksArray[bookmarks.bookmarkLeftclicked].flashType = FLASH_TYPE_DEPLOY;
SetCapture(hWnd);
}
return 0;
@ -813,11 +813,11 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
if (info.pt.x >= 0 && info.pt.x < wrect.right - wrect.left && info.pt.y >= 0 && info.pt.y < wrect.bottom - wrect.top)
{
ListView_SubItemHitTest(hWnd, (LPARAM)&info);
if (bookmarks.bookmark_leftclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.column_clicked == info.iSubItem)
bookmarks.LeftClick();
if (bookmarks.bookmarkLeftclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.columnClicked == info.iSubItem)
bookmarks.handleLeftClick();
}
ReleaseCapture();
bookmarks.bookmark_leftclicked = -1;
bookmarks.bookmarkLeftclicked = -1;
return 0;
}
case WM_RBUTTONDOWN:
@ -829,11 +829,11 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam);
ListView_SubItemHitTest(hWnd, (LPARAM)&info);
if (info.iItem >= 0 && bookmarks.bookmark_leftclicked < 0)
if (info.iItem >= 0 && bookmarks.bookmarkLeftclicked < 0)
{
bookmarks.bookmark_rightclicked = (info.iItem + 1) % TOTAL_BOOKMARKS;
bookmarks.column_clicked = info.iSubItem;
bookmarks.bookmarks_array[bookmarks.bookmark_rightclicked].flash_type = FLASH_TYPE_SET;
bookmarks.bookmarkRightclicked = (info.iItem + 1) % TOTAL_BOOKMARKS;
bookmarks.columnClicked = info.iSubItem;
bookmarks.bookmarksArray[bookmarks.bookmarkRightclicked].flashType = FLASH_TYPE_SET;
SetCapture(hWnd);
}
return 0;
@ -848,11 +848,11 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
if (info.pt.x >= 0 && info.pt.x < wrect.right - wrect.left && info.pt.y >= 0 && info.pt.y < wrect.bottom - wrect.top)
{
ListView_SubItemHitTest(hWnd, (LPARAM)&info);
if (bookmarks.bookmark_rightclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.column_clicked == info.iSubItem)
bookmarks.RightClick();
if (bookmarks.bookmarkRightclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.columnClicked == info.iSubItem)
bookmarks.handleRightClick();
}
ReleaseCapture();
bookmarks.bookmark_rightclicked = ITEM_UNDER_MOUSE_NONE;
bookmarks.bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE;
return 0;
}
case WM_MBUTTONDOWN:
@ -860,13 +860,13 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
{
if (GetFocus() != hWnd)
SetFocus(hWnd);
playback.MiddleButtonClick();
playback.handleMiddleButtonClick();
return 0;
}
case WM_MOUSEWHEEL:
{
bookmarks.bookmark_rightclicked = ITEM_UNDER_MOUSE_NONE; // ensure that accidental rightclick on BookmarksList won't set Bookmarks when user does rightbutton + wheel
return SendMessage(piano_roll.hwndList, msg, wParam, lParam);
bookmarks.bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE; // ensure that accidental rightclick on BookmarksList won't set Bookmarks when user does rightbutton + wheel
return SendMessage(pianoRoll.hwndList, msg, wParam, lParam);
}
}
return CallWindowProc(hwndBookmarksList_oldWndProc, hWnd, msg, wParam, lParam);

View File

@ -4,14 +4,14 @@
#define TOTAL_BOOKMARKS 10
enum
enum BOOKMARKS_EDIT_MODES
{
EDIT_MODE_BOOKMARKS = 0,
EDIT_MODE_BOTH = 1,
EDIT_MODE_BRANCHES = 2,
};
enum COMMANDS
enum BOOKMARK_COMMANDS
{
COMMAND_SET = 0,
COMMAND_JUMP = 1,
@ -19,30 +19,32 @@ enum COMMANDS
COMMAND_SELECT = 3,
COMMAND_DELETE = 4, // not implemented, probably useless
TOTAL_COMMANDS
// ...
TOTAL_BOOKMARK_COMMANDS
};
#define BOOKMARKSLIST_COLUMN_ICONS_WIDTH 15
#define BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH 74
#define BOOKMARKSLIST_COLUMN_TIME_WIDTH 80
#define BOOKMARKSLIST_COLUMN_TIMESTAMP_WIDTH 80
#define BOOKMARKS_SELECTED 20
#define BOOKMARKS_BITMAPS_SELECTED 20
#define ITEM_UNDER_MOUSE_NONE -2
#define ITEM_UNDER_MOUSE_CLOUD -1
#define ITEM_UNDER_MOUSE_NONE (-2)
#define ITEM_UNDER_MOUSE_CLOUD (-1)
#define ITEM_UNDER_MOUSE_FIREBALL (TOTAL_BOOKMARKS)
#define BOOKMARKS_FLASH_TICK 100 // in milliseconds
// listview columns
enum
{
BOOKMARKS_COLUMN_ICON = 0,
BOOKMARKS_COLUMN_FRAME = 1,
BOOKMARKS_COLUMN_TIME = 2,
BOOKMARKSLIST_COLUMN_ICON = 0,
BOOKMARKSLIST_COLUMN_FRAME = 1,
BOOKMARKSLIST_COLUMN_TIME = 2,
};
#define BOOKMARKS_ID_LEN 10
#define TIME_DESC_LENGTH 9 // "HH:MM:SS"
#define TIMESTAMP_LENGTH 9 // "HH:MM:SS"
#define DEFAULT_SLOT 1
@ -61,37 +63,37 @@ public:
void command(int command_id, int slot = -1);
void GetDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG CustomDraw(NMLVCUSTOMDRAW* msg);
void LeftClick();
void RightClick();
void getDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG handleCustomDraw(NMLVCUSTOMDRAW* msg);
void handleLeftClick();
void handleRightClick();
int FindBookmarkAtFrame(int frame);
int findBookmarkAtFrame(int frame);
void RedrawBookmarksCaption();
void RedrawBookmarksList(bool erase_bg = false);
void RedrawChangedBookmarks(int frame);
void RedrawBookmark(int bookmark_number);
void RedrawListRow(int row_index);
void redrawBookmarksSectionCaption();
void redrawBookmarksList(bool eraseBG = false);
void redrawChangedBookmarks(int frame);
void redrawBookmark(int bookmarkNumber);
void redrawBookmarksListRow(int rowIndex);
void MouseMove(int new_x, int new_y);
int FindItemUnderMouse();
void handleMouseMove(int newX, int newY);
int findItemUnderMouse();
int GetSelectedSlot();
int getSelectedSlot();
// saved vars
std::vector<BOOKMARK> bookmarks_array;
std::vector<BOOKMARK> bookmarksArray;
// not saved vars
int edit_mode;
bool must_check_item_under_mouse;
bool mouse_over_bitmap, mouse_over_bookmarkslist;
int item_under_mouse;
TRACKMOUSEEVENT tme, list_tme;
int bookmark_leftclicked, bookmark_rightclicked, column_clicked;
int list_row_top;
int list_row_left;
int list_row_height;
int editMode;
bool mustCheckItemUnderMouse;
bool mouseOverBranchesBitmap, mouseOverBookmarksList;
int itemUnderMouse;
TRACKMOUSEEVENT tme, tmeList;
int bookmarkLeftclicked, bookmarkRightclicked, columnClicked;
int listTopMargin;
int listRowLeft;
int listRowHeight;
HWND hwndBookmarksList, hwndBranchesBitmap, hwndBookmarks;
@ -102,12 +104,12 @@ private:
// not saved vars
std::vector<int> commands;
int selected_slot;
int check_flash_shedule;
int mouse_x, mouse_y;
int selectedSlot;
int nextFlashUpdateTime;
int mouseX, mouseY;
// GDI stuff
HFONT hBookmarksFont;
HIMAGELIST himglist;
HIMAGELIST hImgList;
};

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
#define CURSOR_MAX_DISTANCE 256.0
#define CURSOR_MIN_SPEED 1.0
// floating "empty" branches
// floating empty branches
#define MAX_FLOATING_PHASE 4
// branches bitmap
@ -100,84 +100,85 @@ public:
void init();
void free();
void reset();
void reset_vars();
void resetVars();
void update();
void save(EMUFILE *os);
bool load(EMUFILE *is);
int GetParentOf(int child);
int GetCurrentBranch();
bool GetChangesSinceCurrentBranch();
int getParentOf(int child);
int getCurrentBranch();
bool areThereChangesSinceCurrentBranch();
bool IsSafeToShowBranchesData();
bool isSafeToShowBranchesData();
void RedrawBranchesTree();
void PaintBranchesBitmap(HDC hdc);
void redrawBranchesBitmap();
void paintBranchesBitmap(HDC hdc);
void HandleBookmarkSet(int slot);
void HandleBookmarkDeploy(int slot);
void HandleHistoryJump(int new_current_branch, bool new_changes_since_current_branch);
void handleBookmarkSet(int slot);
void handleBookmarkDeploy(int slot);
void handleHistoryJump(int newCurrentBranch, bool newChangesSinceCurrentBranch);
void setChangesMadeSinceBranch();
void InvalidateBranchSlot(int slot);
int GetFirstDifference(int first_branch, int second_branch);
int FindFullTimelineForBranch(int branch_num);
void ChangesMadeSinceBranch();
void invalidateRelationsOfBranchSlot(int slot);
int findFullTimelineForBranch(int branchNumber);
int FindItemUnderMouse(int mouse_x, int mouse_y);
int findItemUnderMouse(int mouseX, int mouseY);
// not saved vars
bool must_redraw_branches_tree;
bool must_recalculate_branches_tree;
int branch_rightclicked;
bool mustRedrawBranchesBitmap;
bool mustRecalculateBranchesTree;
int branchRightclicked;
private:
void SetCurrentPosTime();
void setCurrentPosTimestamp();
void RecalculateParents();
void RecalculateBranchesTree();
void RecursiveAddHeight(int branch_num, int amount);
void RecursiveSetYPos(int parent, int parentY);
void recalculateParents();
void recalculateBranchesTree();
void recursiveAddHeight(int branchNumber, int amount);
void recursiveSetYPos(int parent, int parentY);
int getFirstDifferenceBetween(int firstBranch, int secondBranch);
// saved vars
std::vector<int> parents;
int current_branch;
bool changes_since_current_branch;
char cloud_time[TIME_DESC_LENGTH];
char current_pos_time[TIME_DESC_LENGTH];
std::vector<std::vector<int>> cached_first_difference;
std::vector<int8> cached_timelines; // stores id of the last branch on the timeline of every Branch. Sometimes it's the id of the Branch itself, but sometimes it's an id of its child/grandchild that shares the same Input
int currentBranch;
bool changesSinceCurrentBranch;
char cloudTimestamp[TIMESTAMP_LENGTH];
char currentPosTimestamp[TIMESTAMP_LENGTH];
std::vector<std::vector<int>> cachedFirstDifferences;
std::vector<int8> cachedTimelines; // stores id of the last branch on the timeline of every Branch. Sometimes it's the id of the Branch itself, but sometimes it's an id of its child/grandchild that shares the same Input
// not saved vars
int transition_phase;
int animation_frame;
int next_animation_time;
int playback_x, playback_y;
double cursor_x, cursor_y;
std::vector<int> BranchX; // in pixels
std::vector<int> BranchY;
std::vector<int> BranchPrevX;
std::vector<int> BranchPrevY;
std::vector<int> BranchCurrX;
std::vector<int> BranchCurrY;
int CloudX, CloudPrevX, cloud_x;
int fireball_size;
int latest_drawn_item_under_mouse;
int transitionPhase;
int currentAnimationFrame;
int nextAnimationTime;
int playbackCursorX, playbackCursorY;
double cornersCursorX, cornersCursorY;
std::vector<int> branchX; // in pixels
std::vector<int> branchY;
std::vector<int> branchPreviousX;
std::vector<int> branchPreviousY;
std::vector<int> branchCurrentX;
std::vector<int> branchCurrentY;
int cloudX, cloudPreviousX, cloudCurrentX;
int fireballSize;
int lastItemUnderMouse;
// GDI stuff
HBRUSH normal_brush, border_brush, selected_slot_brush;
RECT temp_rect;
HPEN normal_pen, timeline_pen, select_pen;
HBITMAP branches_hbitmap, hOldBitmap, buffer_hbitmap, hOldBitmap1, branchesSpritesheet, hOldBitmap2;
HBRUSH normalBrush, borderBrush, selectedSlotBrush;
RECT tempRect;
HPEN normalPen, timelinePen, selectPen;
HBITMAP hBranchesBitmap, hOldBitmap, hBufferBitmap, hOldBitmap1, hBranchesSpritesheet, hOldBitmap2;
HDC hBitmapDC, hBufferDC, hSpritesheetDC;
TRIVERTEX vertex[2];
GRADIENT_RECT gRect;
RECT branches_bitmap_rect;
RECT branchesBitmapRect;
// temps
std::vector<int> GridX; // in grid units
std::vector<int> GridY;
std::vector<int> GridHeight;
std::vector<std::vector<uint8>> Children;
std::vector<int> gridX; // measured in grid units, not in pixels
std::vector<int> gridY;
std::vector<int> gridHeight;
std::vector<std::vector<uint8>> children;
};

View File

@ -18,17 +18,17 @@ Editor - Interface for editing Input and Markers
#include "taseditor_project.h"
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditorWindow;
extern TASEDITOR_CONFIG taseditorConfig;
extern HISTORY history;
extern MARKERS_MANAGER markers_manager;
extern MARKERS_MANAGER markersManager;
extern PLAYBACK playback;
extern GREENZONE greenzone;
extern PIANO_ROLL piano_roll;
extern PIANO_ROLL pianoRoll;
extern SELECTION selection;
extern int joysticks_per_frame[NUM_SUPPORTED_INPUT_TYPES];
extern int GetInputType(MovieData& md);
extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
extern int getInputType(MovieData& md);
// resources
char patternsFilename[] = "\\taseditor_patterns.txt";
@ -50,22 +50,22 @@ void EDITOR::init()
if (!ifs.fail())
{
std::string tempstr1, tempstr2;
while (ReadString(&ifs, tempstr1))
while (readStringFromPatternsFile(&ifs, tempstr1))
{
if (ReadString(&ifs, tempstr2))
if (readStringFromPatternsFile(&ifs, tempstr2))
{
total_patterns++;
// save the name
autofire_patterns_names.push_back(tempstr1);
patternsNames.push_back(tempstr1);
// parse 2nd string to sequence of 1s and 0s
autofire_patterns.resize(total_patterns);
autofire_patterns[total_patterns - 1].resize(tempstr2.size());
patterns.resize(total_patterns);
patterns[total_patterns - 1].resize(tempstr2.size());
for (int i = tempstr2.size() - 1; i >= 0; i--)
{
if (tempstr2[i] == autofire_patterns_flagpress)
autofire_patterns[total_patterns - 1][i] = 1;
patterns[total_patterns - 1][i] = 1;
else
autofire_patterns[total_patterns - 1][i] = 0;
patterns[total_patterns - 1][i] = 0;
}
}
}
@ -73,49 +73,49 @@ void EDITOR::init()
{
FCEU_printf("Could not load tools\\taseditor_patterns.txt!\n");
}
if (autofire_patterns.size() == 0)
if (patterns.size() == 0)
{
FCEU_printf("Will be using default set of patterns...\n");
autofire_patterns.resize(4);
autofire_patterns_names.resize(4);
patterns.resize(4);
patternsNames.resize(4);
// Default Pattern 0: Alternating (1010...)
autofire_patterns_names[0] = "Alternating (1010...)";
autofire_patterns[0].resize(2);
autofire_patterns[0][0] = 1;
autofire_patterns[0][1] = 0;
patternsNames[0] = "Alternating (1010...)";
patterns[0].resize(2);
patterns[0][0] = 1;
patterns[0][1] = 0;
// Default Pattern 1: Alternating at 30FPS (11001100...)
autofire_patterns_names[1] = "Alternating at 30FPS (11001100...)";
autofire_patterns[1].resize(4);
autofire_patterns[1][0] = 1;
autofire_patterns[1][1] = 1;
autofire_patterns[1][2] = 0;
autofire_patterns[1][3] = 0;
patternsNames[1] = "Alternating at 30FPS (11001100...)";
patterns[1].resize(4);
patterns[1][0] = 1;
patterns[1][1] = 1;
patterns[1][2] = 0;
patterns[1][3] = 0;
// Default Pattern 2: One Quarter (10001000...)
autofire_patterns_names[2] = "One Quarter (10001000...)";
autofire_patterns[2].resize(4);
autofire_patterns[2][0] = 1;
autofire_patterns[2][1] = 0;
autofire_patterns[2][2] = 0;
autofire_patterns[2][3] = 0;
patternsNames[2] = "One Quarter (10001000...)";
patterns[2].resize(4);
patterns[2][0] = 1;
patterns[2][1] = 0;
patterns[2][2] = 0;
patterns[2][3] = 0;
// Default Pattern 3: Tap'n'Hold (1011111111111111111111111111111111111...)
autofire_patterns_names[3] = "Tap'n'Hold (101111111...)";
autofire_patterns[3].resize(1000);
autofire_patterns[3][0] = 1;
autofire_patterns[3][1] = 0;
patternsNames[3] = "Tap'n'Hold (101111111...)";
patterns[3].resize(1000);
patterns[3][0] = 1;
patterns[3][1] = 0;
for (int i = 2; i < 1000; ++i)
autofire_patterns[3][i] = 1;
patterns[3][i] = 1;
}
// reset current_pattern if it's outside the range
if (taseditor_config.current_pattern < 0 || taseditor_config.current_pattern >= (int)autofire_patterns.size())
taseditor_config.current_pattern = 0;
taseditor_window.UpdatePatternsMenu();
if (taseditorConfig.currentPattern < 0 || taseditorConfig.currentPattern >= (int)patterns.size())
taseditorConfig.currentPattern = 0;
taseditorWindow.updatePatternsMenu();
reset();
}
void EDITOR::free()
{
autofire_patterns.resize(0);
autofire_patterns_names.resize(0);
patterns.resize(0);
patternsNames.resize(0);
}
void EDITOR::reset()
{
@ -129,7 +129,7 @@ void EDITOR::update()
}
// ----------------------------------------------------------------------------------------------
// returns false if couldn't read a string containing at least one char
bool EDITOR::ReadString(EMUFILE *is, std::string& dest)
bool EDITOR::readStringFromPatternsFile(EMUFILE *is, std::string& dest)
{
dest.resize(0);
int charr;
@ -152,9 +152,9 @@ bool EDITOR::ReadString(EMUFILE *is, std::string& dest)
}
// ----------------------------------------------------------------------------------------------
// following functions use function parameters to determine range of frames
void EDITOR::InputToggle(int start, int end, int joy, int button, int consecutive_tag)
void EDITOR::toggleInput(int start, int end, int joy, int button, int consecutivenessTag)
{
if (joy < 0 || joy >= joysticks_per_frame[GetInputType(currMovieData)]) return;
if (joy < 0 || joy >= joysticksPerFrame[getInputType(currMovieData)]) return;
int check_frame = end;
if (start > end)
@ -173,18 +173,18 @@ void EDITOR::InputToggle(int start, int end, int joy, int button, int consecutiv
// clear range
for (int i = start; i <= end; ++i)
currMovieData.records[i].clearBit(joy, button);
greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_UNSET, start, end, 0, NULL, consecutive_tag));
greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_UNSET, start, end, 0, NULL, consecutivenessTag));
} else
{
// set range
for (int i = start; i <= end; ++i)
currMovieData.records[i].setBit(joy, button);
greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_SET, start, end, 0, NULL, consecutive_tag));
greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_SET, start, end, 0, NULL, consecutivenessTag));
}
}
void EDITOR::InputSetPattern(int start, int end, int joy, int button, int consecutive_tag)
void EDITOR::setInputUsingPattern(int start, int end, int joy, int button, int consecutivenessTag)
{
if (joy < 0 || joy >= joysticks_per_frame[GetInputType(currMovieData)]) return;
if (joy < 0 || joy >= joysticksPerFrame[getInputType(currMovieData)]) return;
if (start > end)
{
@ -197,42 +197,42 @@ void EDITOR::InputSetPattern(int start, int end, int joy, int button, int consec
if (end >= currMovieData.getNumRecords())
return;
int pattern_offset = 0, current_pattern = taseditor_config.current_pattern;
int pattern_offset = 0, current_pattern = taseditorConfig.currentPattern;
bool changes_made = false;
bool value;
for (int i = start; i <= end; ++i)
{
// skip lag frames
if (taseditor_config.pattern_skips_lag && greenzone.laglog.GetLagInfoAtFrame(i) == LAGGED_YES)
if (taseditorConfig.autofirePatternSkipsLag && greenzone.lagLog.getLagInfoAtFrame(i) == LAGGED_YES)
continue;
value = (autofire_patterns[current_pattern][pattern_offset] != 0);
value = (patterns[current_pattern][pattern_offset] != 0);
if (currMovieData.records[i].checkBit(joy, button) != value)
{
changes_made = true;
currMovieData.records[i].setBitValue(joy, button, value);
}
pattern_offset++;
if (pattern_offset >= (int)autofire_patterns[current_pattern].size())
pattern_offset -= autofire_patterns[current_pattern].size();
if (pattern_offset >= (int)patterns[current_pattern].size())
pattern_offset -= patterns[current_pattern].size();
}
if (changes_made)
greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_PATTERN, start, end, 0, autofire_patterns_names[current_pattern].c_str(), consecutive_tag));
greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_PATTERN, start, end, 0, patternsNames[current_pattern].c_str(), consecutivenessTag));
}
// following functions use current Selection to determine range of frames
bool EDITOR::FrameColumnSet()
bool EDITOR::handleColumnSet()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return false;
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
RowsSelection::iterator current_selection_begin(current_selection->begin());
RowsSelection::iterator current_selection_end(current_selection->end());
// inspect the selected frames, if they are all set, then unset all, else set all
bool unset_found = false, changes_made = false;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if (!markers_manager.GetMarker(*it))
if (!markersManager.getMarkerAtFrame(*it))
{
unset_found = true;
break;
@ -241,96 +241,96 @@ bool EDITOR::FrameColumnSet()
if (unset_found)
{
// set all
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if (!markers_manager.GetMarker(*it))
if (!markersManager.getMarkerAtFrame(*it))
{
if (markers_manager.SetMarker(*it))
if (markersManager.setMarkerAtFrame(*it))
{
changes_made = true;
piano_roll.RedrawRow(*it);
pianoRoll.redrawRow(*it);
}
}
}
if (changes_made)
history.RegisterMarkersChange(MODTYPE_MARKER_SET, *current_selection_begin, *current_selection->rbegin());
history.registerMarkersChange(MODTYPE_MARKER_SET, *current_selection_begin, *current_selection->rbegin());
} else
{
// unset all
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if (markers_manager.GetMarker(*it))
if (markersManager.getMarkerAtFrame(*it))
{
markers_manager.ClearMarker(*it);
markersManager.removeMarkerFromFrame(*it);
changes_made = true;
piano_roll.RedrawRow(*it);
pianoRoll.redrawRow(*it);
}
}
if (changes_made)
history.RegisterMarkersChange(MODTYPE_MARKER_REMOVE, *current_selection_begin, *current_selection->rbegin());
history.registerMarkersChange(MODTYPE_MARKER_REMOVE, *current_selection_begin, *current_selection->rbegin());
}
if (changes_made)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
return changes_made;
}
bool EDITOR::FrameColumnSetPattern()
bool EDITOR::handleColumnSetUsingPattern()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return false;
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
int pattern_offset = 0, current_pattern = taseditor_config.current_pattern;
RowsSelection::iterator current_selection_begin(current_selection->begin());
RowsSelection::iterator current_selection_end(current_selection->end());
int pattern_offset = 0, current_pattern = taseditorConfig.currentPattern;
bool changes_made = false;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
// skip lag frames
if (taseditor_config.pattern_skips_lag && greenzone.laglog.GetLagInfoAtFrame(*it) == LAGGED_YES)
if (taseditorConfig.autofirePatternSkipsLag && greenzone.lagLog.getLagInfoAtFrame(*it) == LAGGED_YES)
continue;
if (autofire_patterns[current_pattern][pattern_offset])
if (patterns[current_pattern][pattern_offset])
{
if (!markers_manager.GetMarker(*it))
if (!markersManager.getMarkerAtFrame(*it))
{
if (markers_manager.SetMarker(*it))
if (markersManager.setMarkerAtFrame(*it))
{
changes_made = true;
piano_roll.RedrawRow(*it);
pianoRoll.redrawRow(*it);
}
}
} else
{
if (markers_manager.GetMarker(*it))
if (markersManager.getMarkerAtFrame(*it))
{
markers_manager.ClearMarker(*it);
markersManager.removeMarkerFromFrame(*it);
changes_made = true;
piano_roll.RedrawRow(*it);
pianoRoll.redrawRow(*it);
}
}
pattern_offset++;
if (pattern_offset >= (int)autofire_patterns[current_pattern].size())
pattern_offset -= autofire_patterns[current_pattern].size();
if (pattern_offset >= (int)patterns[current_pattern].size())
pattern_offset -= patterns[current_pattern].size();
}
if (changes_made)
{
history.RegisterMarkersChange(MODTYPE_MARKER_PATTERN, *current_selection_begin, *current_selection->rbegin(), autofire_patterns_names[current_pattern].c_str());
selection.must_find_current_marker = playback.must_find_current_marker = true;
history.registerMarkersChange(MODTYPE_MARKER_PATTERN, *current_selection_begin, *current_selection->rbegin(), patternsNames[current_pattern].c_str());
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
return true;
} else
return false;
}
bool EDITOR::InputColumnSet(int joy, int button)
bool EDITOR::handleInputColumnSet(int joy, int button)
{
if (joy < 0 || joy >= joysticks_per_frame[GetInputType(currMovieData)]) return false;
if (joy < 0 || joy >= joysticksPerFrame[getInputType(currMovieData)]) return false;
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return false;
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
RowsSelection::iterator current_selection_begin(current_selection->begin());
RowsSelection::iterator current_selection_end(current_selection->end());
//inspect the selected frames, if they are all set, then unset all, else set all
bool newValue = false;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if (!(currMovieData.records[*it].checkBit(joy,button)))
{
@ -339,99 +339,99 @@ bool EDITOR::InputColumnSet(int joy, int button)
}
}
// apply newValue
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
currMovieData.records[*it].setBitValue(joy,button,newValue);
int first_changes;
if (newValue)
{
first_changes = history.RegisterChanges(MODTYPE_SET, *current_selection_begin, *current_selection->rbegin());
first_changes = history.registerChanges(MODTYPE_SET, *current_selection_begin, *current_selection->rbegin());
} else
{
first_changes = history.RegisterChanges(MODTYPE_UNSET, *current_selection_begin, *current_selection->rbegin());
first_changes = history.registerChanges(MODTYPE_UNSET, *current_selection_begin, *current_selection->rbegin());
}
if (first_changes >= 0)
{
greenzone.InvalidateAndCheck(first_changes);
greenzone.invalidateAndUpdatePlayback(first_changes);
return true;
} else
return false;
}
bool EDITOR::InputColumnSetPattern(int joy, int button)
bool EDITOR::handleInputColumnSetUsingPattern(int joy, int button)
{
if (joy < 0 || joy >= joysticks_per_frame[GetInputType(currMovieData)]) return false;
if (joy < 0 || joy >= joysticksPerFrame[getInputType(currMovieData)]) return false;
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return false;
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
int pattern_offset = 0, current_pattern = taseditor_config.current_pattern;
RowsSelection::iterator current_selection_begin(current_selection->begin());
RowsSelection::iterator current_selection_end(current_selection->end());
int pattern_offset = 0, current_pattern = taseditorConfig.currentPattern;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
// skip lag frames
if (taseditor_config.pattern_skips_lag && greenzone.laglog.GetLagInfoAtFrame(*it) == LAGGED_YES)
if (taseditorConfig.autofirePatternSkipsLag && greenzone.lagLog.getLagInfoAtFrame(*it) == LAGGED_YES)
continue;
currMovieData.records[*it].setBitValue(joy, button, autofire_patterns[current_pattern][pattern_offset] != 0);
currMovieData.records[*it].setBitValue(joy, button, patterns[current_pattern][pattern_offset] != 0);
pattern_offset++;
if (pattern_offset >= (int)autofire_patterns[current_pattern].size())
pattern_offset -= autofire_patterns[current_pattern].size();
if (pattern_offset >= (int)patterns[current_pattern].size())
pattern_offset -= patterns[current_pattern].size();
}
int first_changes = history.RegisterChanges(MODTYPE_PATTERN, *current_selection_begin, *current_selection->rbegin(), 0, autofire_patterns_names[current_pattern].c_str());
int first_changes = history.registerChanges(MODTYPE_PATTERN, *current_selection_begin, *current_selection->rbegin(), 0, patternsNames[current_pattern].c_str());
if (first_changes >= 0)
{
greenzone.InvalidateAndCheck(first_changes);
greenzone.invalidateAndUpdatePlayback(first_changes);
return true;
} else
return false;
}
void EDITOR::SetMarkers()
void EDITOR::setMarkers()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size())
{
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
RowsSelection::iterator current_selection_begin(current_selection->begin());
RowsSelection::iterator current_selection_end(current_selection->end());
bool changes_made = false;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if (!markers_manager.GetMarker(*it))
if (!markersManager.getMarkerAtFrame(*it))
{
if (markers_manager.SetMarker(*it))
if (markersManager.setMarkerAtFrame(*it))
{
changes_made = true;
piano_roll.RedrawRow(*it);
pianoRoll.redrawRow(*it);
}
}
}
if (changes_made)
{
selection.must_find_current_marker = playback.must_find_current_marker = true;
history.RegisterMarkersChange(MODTYPE_MARKER_SET, *current_selection_begin, *current_selection->rbegin());
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
history.registerMarkersChange(MODTYPE_MARKER_SET, *current_selection_begin, *current_selection->rbegin());
}
}
}
void EDITOR::RemoveMarkers()
void EDITOR::removeMarkers()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size())
{
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
RowsSelection::iterator current_selection_begin(current_selection->begin());
RowsSelection::iterator current_selection_end(current_selection->end());
bool changes_made = false;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if (markers_manager.GetMarker(*it))
if (markersManager.getMarkerAtFrame(*it))
{
markers_manager.ClearMarker(*it);
markersManager.removeMarkerFromFrame(*it);
changes_made = true;
piano_roll.RedrawRow(*it);
pianoRoll.redrawRow(*it);
}
}
if (changes_made)
{
selection.must_find_current_marker = playback.must_find_current_marker = true;
history.RegisterMarkersChange(MODTYPE_MARKER_REMOVE, *current_selection_begin, *current_selection->rbegin());
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
history.registerMarkersChange(MODTYPE_MARKER_REMOVE, *current_selection_begin, *current_selection->rbegin());
}
}
}

View File

@ -9,20 +9,20 @@ public:
void reset();
void update();
void InputToggle(int start, int end, int joy, int button, int consecutive_tag = 0);
void InputSetPattern(int start, int end, int joy, int button, int consecutive_tag = 0);
void toggleInput(int start, int end, int joy, int button, int consecutivenessTag = 0);
void setInputUsingPattern(int start, int end, int joy, int button, int consecutivenessTag = 0);
bool FrameColumnSet();
bool FrameColumnSetPattern();
bool InputColumnSet(int joy, int button);
bool InputColumnSetPattern(int joy, int button);
void SetMarkers();
void RemoveMarkers();
bool handleColumnSet();
bool handleColumnSetUsingPattern();
bool handleInputColumnSet(int joy, int button);
bool handleInputColumnSetUsingPattern(int joy, int button);
void setMarkers();
void removeMarkers();
std::vector<std::string> autofire_patterns_names;
std::vector<std::vector<uint8>> autofire_patterns;
std::vector<std::string> patternsNames;
std::vector<std::vector<uint8>> patterns;
private:
bool ReadString(EMUFILE *is, std::string& dest);
bool readStringFromPatternsFile(EMUFILE *is, std::string& dest);
};

View File

@ -24,13 +24,13 @@ Greenzone - Access zone
#include "state.h"
#include "zlib.h"
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_PROJECT project;
extern PLAYBACK playback;
extern HISTORY history;
extern BOOKMARKS bookmarks;
extern MARKERS_MANAGER markers_manager;
extern PIANO_ROLL piano_roll;
extern MARKERS_MANAGER markersManager;
extern PIANO_ROLL pianoRoll;
extern SELECTION selection;
extern char lagFlag;
@ -45,13 +45,13 @@ GREENZONE::GREENZONE()
void GREENZONE::init()
{
reset();
next_cleaning_time = clock() + TIME_BETWEEN_CLEANINGS;
nextCleaningTime = clock() + TIME_BETWEEN_CLEANINGS;
}
void GREENZONE::free()
{
savestates.resize(0);
greenZoneCount = 0;
laglog.reset();
greenzoneSize = 0;
lagLog.reset();
}
void GREENZONE::reset()
{
@ -60,48 +60,48 @@ void GREENZONE::reset()
void GREENZONE::update()
{
// keep collecting savestates, this code must be executed at the end of every frame
if (taseditor_config.enable_greenzoning)
if (taseditorConfig.enableGreenzoning)
{
CollectCurrentState();
collectCurrentState();
} else
{
// just update Greenzone upper limit
if (greenZoneCount <= currFrameCounter)
greenZoneCount = currFrameCounter + 1;
if (greenzoneSize <= currFrameCounter)
greenzoneSize = currFrameCounter + 1;
}
// run cleaning from time to time
if (clock() > next_cleaning_time)
RunGreenzoneCleaning();
if (clock() > nextCleaningTime)
runGreenzoneCleaning();
// also log lag frames
if (currFrameCounter > 0)
{
// lagFlag indicates that lag was in previous frame
int old_lagFlag = laglog.GetLagInfoAtFrame(currFrameCounter - 1);
int old_lagFlag = lagLog.getLagInfoAtFrame(currFrameCounter - 1);
// Auto-adjust Input according to lag
if (taseditor_config.adjust_input_due_to_lag && old_lagFlag != LAGGED_DONTKNOW)
if (taseditorConfig.autoAdjustInputAccordingToLag && old_lagFlag != LAGGED_UNKNOWN)
{
if ((old_lagFlag == LAGGED_YES) && !lagFlag)
{
// there's no more lag on previous frame - shift Input up 1 or more frames
AdjustUp();
adjustUp();
} else if ((old_lagFlag == LAGGED_NO) && lagFlag)
{
// there's new lag on previous frame - shift Input down 1 frame
AdjustDown();
adjustDown();
}
} else
{
if (lagFlag && (old_lagFlag != LAGGED_YES))
laglog.SetLagInfo(currFrameCounter - 1, true);
lagLog.setLagInfo(currFrameCounter - 1, true);
else if (!lagFlag && old_lagFlag != LAGGED_NO)
laglog.SetLagInfo(currFrameCounter - 1, false);
lagLog.setLagInfo(currFrameCounter - 1, false);
}
}
}
void GREENZONE::CollectCurrentState()
void GREENZONE::collectCurrentState()
{
if ((int)savestates.size() <= currFrameCounter)
savestates.resize(currFrameCounter + 1);
@ -112,11 +112,11 @@ void GREENZONE::CollectCurrentState()
FCEUSS_SaveMS(&ms, Z_DEFAULT_COMPRESSION);
ms.trim();
}
if (greenZoneCount <= currFrameCounter)
greenZoneCount = currFrameCounter + 1;
if (greenzoneSize <= currFrameCounter)
greenzoneSize = currFrameCounter + 1;
}
bool GREENZONE::LoadSavestate(unsigned int frame)
bool GREENZONE::loadSavestateOfFrame(unsigned int frame)
{
if (frame >= savestates.size() || !savestates[frame].size())
return false;
@ -124,68 +124,79 @@ bool GREENZONE::LoadSavestate(unsigned int frame)
return FCEUSS_LoadFP(&ms, SSLOADPARAM_NOBACKUP);
}
void GREENZONE::RunGreenzoneCleaning()
void GREENZONE::runGreenzoneCleaning()
{
bool changed = false;
int i = currFrameCounter - taseditor_config.greenzone_capacity;
int i = currFrameCounter - taseditorConfig.greenzoneCapacity;
if (i <= 0) goto finish; // zeroth frame should not be cleaned
int limit;
// 2x of 1/2
limit = i - 2 * taseditor_config.greenzone_capacity;
limit = i - 2 * taseditorConfig.greenzoneCapacity;
if (limit < 0) limit = 0;
for (; i > limit; i--)
{
if (i & 0x1)
changed = changed | ClearSavestateAndFreeMemory(i);
changed = changed | clearSavestateAndFreeMemory(i);
}
if (i < 0) goto finish;
// 4x of 1/4
limit = i - 4 * taseditor_config.greenzone_capacity;
limit = i - 4 * taseditorConfig.greenzoneCapacity;
if (limit < 0) limit = 0;
for (; i > limit; i--)
{
if (i & 0x3)
changed = changed | ClearSavestateAndFreeMemory(i);
changed = changed | clearSavestateAndFreeMemory(i);
}
if (i < 0) goto finish;
// 8x of 1/8
limit = i - 8 * taseditor_config.greenzone_capacity;
limit = i - 8 * taseditorConfig.greenzoneCapacity;
if (limit < 0) limit = 0;
for (; i > limit; i--)
{
if (i & 0x7)
changed = changed | ClearSavestateAndFreeMemory(i);
changed = changed | clearSavestateAndFreeMemory(i);
}
if (i < 0) goto finish;
// 16x of 1/16
limit = i - 16 * taseditor_config.greenzone_capacity;
limit = i - 16 * taseditorConfig.greenzoneCapacity;
if (limit < 0) limit = 0;
for (; i > limit; i--)
{
if (i & 0xF)
changed = changed | ClearSavestateAndFreeMemory(i);
changed = changed | clearSavestateAndFreeMemory(i);
}
// clear all remaining
for (; i > 0; i--)
{
changed = changed | ClearSavestateAndFreeMemory(i);
changed = changed | clearSavestateAndFreeMemory(i);
}
finish:
if (changed)
{
piano_roll.RedrawList();
bookmarks.RedrawBookmarksList();
pianoRoll.redraw();
bookmarks.redrawBookmarksList();
}
// shedule next cleaning
next_cleaning_time = clock() + TIME_BETWEEN_CLEANINGS;
nextCleaningTime = clock() + TIME_BETWEEN_CLEANINGS;
}
// returns true if actually cleared savestate data
bool GREENZONE::ClearSavestate(unsigned int index)
bool GREENZONE::clearSavestateOfFrame(unsigned int frame)
{
if (index < savestates.size() && savestates[index].size())
if (frame < savestates.size() && savestates[frame].size())
{
savestates[index].resize(0);
savestates[frame].resize(0);
return true;
} else
{
return false;
}
}
bool GREENZONE::clearSavestateAndFreeMemory(unsigned int frame)
{
if (frame < savestates.size() && savestates[frame].size())
{
savestates[frame].swap(std::vector<uint8>());
return true;
} else
{
@ -193,51 +204,39 @@ bool GREENZONE::ClearSavestate(unsigned int index)
}
}
bool GREENZONE::ClearSavestateAndFreeMemory(unsigned int index)
void GREENZONE::ungreenzoneSelectedFrames()
{
if (index < savestates.size() && savestates[index].size())
{
savestates[index].swap(std::vector<uint8>());
return true;
} else
{
return false;
}
}
void GREENZONE::UnGreenzoneSelectedFrames()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return;
bool changed = false;
int size = savestates.size();
int start_index = *current_selection->begin();
int end_index = *current_selection->rbegin();
SelectionFrames::reverse_iterator current_selection_rend = current_selection->rend();
RowsSelection::reverse_iterator current_selection_rend = current_selection->rend();
// degreenzone frames, going backwards
for (SelectionFrames::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
changed = changed | ClearSavestateAndFreeMemory(*it);
for (RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
changed = changed | clearSavestateAndFreeMemory(*it);
if (changed)
{
piano_roll.RedrawList();
bookmarks.RedrawBookmarksList();
pianoRoll.redraw();
bookmarks.redrawBookmarksList();
}
}
void GREENZONE::save(EMUFILE *os, int save_type)
{
if (save_type != SAVE_GREENZONE_NO)
if (save_type != GREENZONE_SAVING_MODE_NO)
{
CollectCurrentState(); // in case the project is being saved before the greenzone.update() was called within current frame
RunGreenzoneCleaning();
if (greenZoneCount > (int)savestates.size())
greenZoneCount = savestates.size();
collectCurrentState(); // in case the project is being saved before the greenzone.update() was called within current frame
runGreenzoneCleaning();
if (greenzoneSize > (int)savestates.size())
greenzoneSize = savestates.size();
// write "GREENZONE" string
os->fwrite(greenzone_save_id, GREENZONE_ID_LEN);
// write LagLog
laglog.save(os);
lagLog.save(os);
// write size
write32le(greenZoneCount, os);
write32le(greenzoneSize, os);
// write Playback cursor position
write32le(currFrameCounter, os);
}
@ -246,15 +245,15 @@ void GREENZONE::save(EMUFILE *os, int save_type)
switch (save_type)
{
case SAVE_GREENZONE_ALL:
case GREENZONE_SAVING_MODE_ALL:
{
// write savestates
for (frame = 0; frame < greenZoneCount; ++frame)
for (frame = 0; frame < greenzoneSize; ++frame)
{
// update TASEditor progressbar from time to time
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
{
playback.SetProgressbar(frame, greenZoneCount);
playback.setProgressbar(frame, greenzoneSize);
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
}
if (!savestates[frame].size()) continue;
@ -268,17 +267,17 @@ void GREENZONE::save(EMUFILE *os, int save_type)
write32le(-1, os);
break;
}
case SAVE_GREENZONE_16TH:
case GREENZONE_SAVING_MODE_16TH:
{
// write savestates
for (frame = 0; frame < greenZoneCount; ++frame)
for (frame = 0; frame < greenzoneSize; ++frame)
{
if (!(frame & 0xF) || frame == currFrameCounter)
{
// update TASEditor progressbar from time to time
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
{
playback.SetProgressbar(frame, greenZoneCount);
playback.setProgressbar(frame, greenzoneSize);
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
}
if (!savestates[frame].size()) continue;
@ -293,17 +292,17 @@ void GREENZONE::save(EMUFILE *os, int save_type)
write32le(-1, os);
break;
}
case SAVE_GREENZONE_MARKED:
case GREENZONE_SAVING_MODE_MARKED:
{
// write savestates
for (frame = 0; frame < greenZoneCount; ++frame)
for (frame = 0; frame < greenzoneSize; ++frame)
{
if (markers_manager.GetMarker(frame) || frame == currFrameCounter)
if (markersManager.getMarkerAtFrame(frame) || frame == currFrameCounter)
{
// update TASEditor progressbar from time to time
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
{
playback.SetProgressbar(frame, greenZoneCount);
playback.setProgressbar(frame, greenzoneSize);
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
}
if (!savestates[frame].size()) continue;
@ -318,18 +317,18 @@ void GREENZONE::save(EMUFILE *os, int save_type)
write32le(-1, os);
break;
}
case SAVE_GREENZONE_NO:
case GREENZONE_SAVING_MODE_NO:
{
// write "GREENZONX" string
os->fwrite(greenzone_skipsave_id, GREENZONE_ID_LEN);
// write LagLog
laglog.save(os);
lagLog.save(os);
// write Playback cursor position
write32le(currFrameCounter, os);
if (currFrameCounter > 0)
{
// write ONE savestate for currFrameCounter
CollectCurrentState();
collectCurrentState();
int size = savestates[currFrameCounter].size();
write32le(size, os);
os->fwrite(&savestates[currFrameCounter][0], size);
@ -348,7 +347,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
} else
{
reset();
playback.StartFromZero(); // reset Playback cursor to frame 0
playback.restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
return false;
}
int frame = 0, prev_frame = -1, size = 0;
@ -360,13 +359,13 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
{
// string says to skip loading Greenzone
// read LagLog
laglog.load(is);
lagLog.load(is);
// read Playback cursor position
if (read32le(&frame, is))
{
currFrameCounter = frame;
greenZoneCount = currFrameCounter + 1;
savestates.resize(greenZoneCount);
greenzoneSize = currFrameCounter + 1;
savestates.resize(greenzoneSize);
if (currFrameCounter)
{
// there must be one savestate in the file
@ -375,7 +374,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
savestates[frame].resize(size);
if (is->fread(&savestates[frame][0], size) == size)
{
if (LoadSavestate(currFrameCounter))
if (loadSavestateOfFrame(currFrameCounter))
{
FCEU_printf("No Greenzone in the file\n");
return false;
@ -386,7 +385,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
{
// literally no Greenzone in the file, but this is still not a error
reset();
playback.StartFromZero(); // reset Playback cursor to frame 0
playback.restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
FCEU_printf("No Greenzone in the file, Playback at frame 0\n");
return false;
}
@ -395,21 +394,21 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
}
if (strcmp(greenzone_save_id, save_id)) goto error; // string is not valid
// read LagLog
laglog.load(is);
lagLog.load(is);
// read size
if (read32le(&size, is) && size >= 0 && size <= currMovieData.getNumRecords())
{
greenZoneCount = size;
savestates.resize(greenZoneCount);
greenzoneSize = size;
savestates.resize(greenzoneSize);
// read Playback cursor position
if (read32le(&frame, is))
{
currFrameCounter = frame;
int greenzone_tail_frame = currFrameCounter - taseditor_config.greenzone_capacity;
int greenzone_tail_frame2 = greenzone_tail_frame - 2 * taseditor_config.greenzone_capacity;
int greenzone_tail_frame4 = greenzone_tail_frame - 4 * taseditor_config.greenzone_capacity;
int greenzone_tail_frame8 = greenzone_tail_frame - 8 * taseditor_config.greenzone_capacity;
int greenzone_tail_frame16 = greenzone_tail_frame - 16 * taseditor_config.greenzone_capacity;
int greenzone_tail_frame = currFrameCounter - taseditorConfig.greenzoneCapacity;
int greenzone_tail_frame2 = greenzone_tail_frame - 2 * taseditorConfig.greenzoneCapacity;
int greenzone_tail_frame4 = greenzone_tail_frame - 4 * taseditorConfig.greenzoneCapacity;
int greenzone_tail_frame8 = greenzone_tail_frame - 8 * taseditorConfig.greenzoneCapacity;
int greenzone_tail_frame16 = greenzone_tail_frame - 16 * taseditorConfig.greenzoneCapacity;
// read savestates
while(1)
{
@ -418,7 +417,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
// update TASEditor progressbar from time to time
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
{
playback.SetProgressbar(frame, greenZoneCount);
playback.setProgressbar(frame, greenzoneSize);
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
}
// read savestate
@ -442,27 +441,27 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
prev_frame = frame; // successfully read one Greenzone frame info
}
}
if (prev_frame+1 == greenZoneCount)
if (prev_frame+1 == greenzoneSize)
{
// everything went fine - load savestate at cursor position
if (LoadSavestate(currFrameCounter))
if (loadSavestateOfFrame(currFrameCounter))
return false;
}
// uh, okay, but maybe we managed to read at least something useful from the file
// first see if original position of currFrameCounter was read successfully
if (LoadSavestate(currFrameCounter))
if (loadSavestateOfFrame(currFrameCounter))
{
greenZoneCount = prev_frame+1; // cut greenZoneCount to last good frame
greenzoneSize = prev_frame+1; // cut greenZoneCount to last good frame
FCEU_printf("Greenzone loaded partially\n");
return false;
}
// then at least jump to some frame that was read successfully
for (; prev_frame >= 0; prev_frame--)
{
if (LoadSavestate(prev_frame))
if (loadSavestateOfFrame(prev_frame))
{
currFrameCounter = prev_frame;
greenZoneCount = prev_frame+1; // cut greenZoneCount to this good frame
greenzoneSize = prev_frame+1; // cut greenZoneCount to this good frame
FCEU_printf("Greenzone loaded partially, Playback moved to the end of greenzone\n");
return false;
}
@ -472,16 +471,16 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
error:
FCEU_printf("Error loading Greenzone\n");
reset();
playback.StartFromZero(); // reset Playback cursor to frame 0
playback.restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
return true;
}
// -------------------------------------------------------------------------------------------------
void GREENZONE::AdjustUp()
void GREENZONE::adjustUp()
{
int at = currFrameCounter - 1; // at = the frame above currFrameCounter
// find how many consequent lag frames there are
int num_frames_to_erase = 0;
while (laglog.GetLagInfoAtFrame(at++) == LAGGED_YES)
while (lagLog.getLagInfoAtFrame(at++) == LAGGED_YES)
num_frames_to_erase++;
if (num_frames_to_erase > 0)
@ -489,10 +488,10 @@ void GREENZONE::AdjustUp()
bool markers_changed = false;
// delete these frames of lag
currMovieData.eraseRecords(currFrameCounter - 1, num_frames_to_erase);
laglog.EraseFrame(currFrameCounter - 1, num_frames_to_erase);
if (taseditor_config.bind_markers)
lagLog.eraseFrame(currFrameCounter - 1, num_frames_to_erase);
if (taseditorConfig.bindMarkersToInput)
{
if (markers_manager.EraseMarker(currFrameCounter - 1, num_frames_to_erase))
if (markersManager.eraseMarker(currFrameCounter - 1, num_frames_to_erase))
markers_changed = true;
}
// update movie data size, because Playback cursor must always be inside the movie
@ -500,70 +499,70 @@ void GREENZONE::AdjustUp()
if (((int)currMovieData.records.size() - 1) <= currFrameCounter)
currMovieData.insertEmpty(-1, currFrameCounter - ((int)currMovieData.records.size() - 1));
// update Piano Roll (reduce it if needed)
piano_roll.UpdateItemCount();
pianoRoll.updateLinesCount();
// register changes
int first_input_changes = history.RegisterAdjustLag(currFrameCounter - 1, 0 - num_frames_to_erase);
int first_input_changes = history.registerAdjustLag(currFrameCounter - 1, 0 - num_frames_to_erase);
// if Input in the frame above currFrameCounter has changed then invalidate Greenzone (rewind 1 frame back)
// also if the frame above currFrameCounter is lag frame then rewind 1 frame (invalidate Greenzone), because maybe this frame also needs lag removal
if ((first_input_changes >= 0 && first_input_changes < currFrameCounter) || (laglog.GetLagInfoAtFrame(currFrameCounter - 1) != LAGGED_NO))
if ((first_input_changes >= 0 && first_input_changes < currFrameCounter) || (lagLog.getLagInfoAtFrame(currFrameCounter - 1) != LAGGED_NO))
{
// custom invalidation procedure, not retriggering LostPosition/PauseFrame
Invalidate(first_input_changes);
invalidate(first_input_changes);
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
int saved_pause_frame = playback.GetPauseFrame();
playback.EnsurePlaybackIsInsideGreenzone();
int saved_pause_frame = playback.getPauseFrame();
playback.ensurePlaybackIsInsideGreenzone();
if (saved_pause_frame >= 0)
playback.SeekingStart(saved_pause_frame);
playback.startSeekingToFrame(saved_pause_frame);
if (emu_was_paused)
playback.PauseEmulation();
playback.pauseEmulation();
} else
{
// just invalidate Greenzone after currFrameCounter (this is necessary in order to force user to re-emulate everything after the point, because the lag log data after the currFrameCounter is now in unknown state and it should be collected again)
Invalidate(currFrameCounter);
invalidate(currFrameCounter);
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
}
void GREENZONE::AdjustDown()
void GREENZONE::adjustDown()
{
int at = currFrameCounter - 1;
bool markers_changed = false;
// clone frame and insert lag
currMovieData.cloneRegion(at, 1);
laglog.InsertFrame(at, true, 1);
if (taseditor_config.bind_markers)
lagLog.insertFrame(at, true, 1);
if (taseditorConfig.bindMarkersToInput)
{
if (markers_manager.insertEmpty(at, 1))
if (markersManager.insertEmpty(at, 1))
markers_changed = true;
}
// register changes
int first_input_changes = history.RegisterAdjustLag(at, +1);
int first_input_changes = history.registerAdjustLag(at, +1);
// If Input in the frame above currFrameCounter has changed then invalidate Greenzone (rewind 1 frame back)
// This should never actually happen, because we clone the frame, so the Input doesn't change
// But the check should remain, in case we decide to insert blank frame instead of cloning
if (first_input_changes >= 0 && first_input_changes < currFrameCounter)
{
// custom invalidation procedure, not retriggering LostPosition/PauseFrame
Invalidate(first_input_changes);
invalidate(first_input_changes);
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
int saved_pause_frame = playback.GetPauseFrame();
playback.EnsurePlaybackIsInsideGreenzone();
int saved_pause_frame = playback.getPauseFrame();
playback.ensurePlaybackIsInsideGreenzone();
if (saved_pause_frame >= 0)
playback.SeekingStart(saved_pause_frame);
playback.startSeekingToFrame(saved_pause_frame);
if (emu_was_paused)
playback.PauseEmulation();
playback.pauseEmulation();
} else
{
// just invalidate Greenzone after currFrameCounter
Invalidate(currFrameCounter);
invalidate(currFrameCounter);
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
// -------------------------------------------------------------------------------------------------
// invalidate and restore playback
void GREENZONE::InvalidateAndCheck(int after)
// This version doesn't restore playback, may be used only by Branching, Recording and AdjustLag functions!
void GREENZONE::invalidate(int after)
{
if (after >= 0)
{
@ -571,86 +570,86 @@ void GREENZONE::InvalidateAndCheck(int after)
after = currMovieData.getNumRecords() - 1;
// clear all savestates that became irrelevant
for (int i = savestates.size() - 1; i > after; i--)
ClearSavestate(i);
if (greenZoneCount > after + 1 || currFrameCounter > after)
clearSavestateOfFrame(i);
if (greenzoneSize > after + 1)
{
greenZoneCount = after + 1;
greenzoneSize = after + 1;
currMovieData.rerecordCount++;
}
}
// redraw Piano Roll even if Greenzone didn't change
pianoRoll.redraw();
bookmarks.redrawBookmarksList();
}
// invalidate and restore playback
void GREENZONE::invalidateAndUpdatePlayback(int after)
{
if (after >= 0)
{
if (after >= currMovieData.getNumRecords())
after = currMovieData.getNumRecords() - 1;
// clear all savestates that became irrelevant
for (int i = savestates.size() - 1; i > after; i--)
clearSavestateOfFrame(i);
if (greenzoneSize > after + 1 || currFrameCounter > after)
{
greenzoneSize = after + 1;
currMovieData.rerecordCount++;
// either set Playback cursor to be inside the Greenzone or run seeking to restore Playback cursor position
if (currFrameCounter >= greenZoneCount)
if (currFrameCounter >= greenzoneSize)
{
if (playback.GetPauseFrame() >= 0 && !FCEUI_EmulationPaused())
if (playback.getPauseFrame() >= 0 && !FCEUI_EmulationPaused())
{
// emulator was running, so continue seeking, but don't follow the Playback cursor
playback.jump(playback.GetPauseFrame(), false, true, false);
playback.jump(playback.getPauseFrame(), false, true, false);
} else
{
playback.SetLostPosition(currFrameCounter);
if (taseditor_config.restore_position)
playback.setLastPosition(currFrameCounter);
if (taseditorConfig.autoRestoreLastPlaybackPosition)
// start seeking to the green arrow, but don't follow the Playback cursor
playback.jump(playback.GetLostPosition(), false, true, false);
playback.jump(playback.getLastPosition(), false, true, false);
else
playback.EnsurePlaybackIsInsideGreenzone();
playback.ensurePlaybackIsInsideGreenzone();
}
}
}
}
// redraw Piano Roll even if Greenzone didn't change
piano_roll.RedrawList();
bookmarks.RedrawBookmarksList();
}
// This version doesn't restore playback, may be used only by Branching, Recording and AdjustLag functions!
void GREENZONE::Invalidate(int after)
{
if (after >= 0)
{
if (after >= currMovieData.getNumRecords())
after = currMovieData.getNumRecords() - 1;
// clear all savestates that became irrelevant
for (int i = savestates.size() - 1; i > after; i--)
ClearSavestate(i);
if (greenZoneCount > after + 1)
{
greenZoneCount = after + 1;
currMovieData.rerecordCount++;
}
}
// redraw Piano Roll even if Greenzone didn't change
piano_roll.RedrawList();
bookmarks.RedrawBookmarksList();
pianoRoll.redraw();
bookmarks.redrawBookmarksList();
}
// -------------------------------------------------------------------------------------------------
int GREENZONE::FindBeginningOfGreenZone(int starting_index)
int GREENZONE::findFirstGreenzonedFrame(int starting_index)
{
for (int i = starting_index; i < greenZoneCount; ++i)
for (int i = starting_index; i < greenzoneSize; ++i)
if (savestates[i].size()) return i;
return -1; // error
}
// getters
int GREENZONE::GetSize()
int GREENZONE::getSize()
{
return greenZoneCount;
return greenzoneSize;
}
// this should only be used by Bookmark Set procedure
std::vector<uint8>& GREENZONE::GetSavestate(int frame)
std::vector<uint8>& GREENZONE::getSavestateOfFrame(int frame)
{
return savestates[frame];
}
// this function should only be used by Bookmark Deploy procedure
void GREENZONE::WriteSavestate(int frame, std::vector<uint8>& savestate)
void GREENZONE::writeSavestateForFrame(int frame, std::vector<uint8>& savestate)
{
if ((int)savestates.size() <= frame)
savestates.resize(frame + 1);
savestates[frame] = savestate;
if (greenZoneCount <= frame)
greenZoneCount = frame + 1;
if (greenzoneSize <= frame)
greenzoneSize = frame + 1;
}
bool GREENZONE::SavestateIsEmpty(unsigned int frame)
bool GREENZONE::isSavestateEmpty(unsigned int frame)
{
if ((int)frame < greenZoneCount && frame < savestates.size() && savestates[frame].size())
if ((int)frame < greenzoneSize && frame < savestates.size() && savestates[frame].size())
return false;
else
return true;

View File

@ -11,7 +11,7 @@
#define EVERY4TH 0xFFFFFFFC
#define EVERY2ND 0xFFFFFFFE
#define PROGRESSBAR_UPDATE_RATE 1000 // progressbar is updated after every 1000 savestates loaded from fm3
#define PROGRESSBAR_UPDATE_RATE 1000 // progressbar is updated after every 1000 savestates loaded from FM3 file
class GREENZONE
{
@ -22,41 +22,41 @@ public:
void free();
void update();
void save(EMUFILE *os, int save_type = SAVE_GREENZONE_ALL);
void save(EMUFILE *os, int save_type = GREENZONE_SAVING_MODE_ALL);
bool load(EMUFILE *is, unsigned int offset);
bool LoadSavestate(unsigned int frame);
bool loadSavestateOfFrame(unsigned int frame);
void RunGreenzoneCleaning();
void runGreenzoneCleaning();
void UnGreenzoneSelectedFrames();
void ungreenzoneSelectedFrames();
void InvalidateAndCheck(int after);
void Invalidate(int after);
void invalidate(int after);
void invalidateAndUpdatePlayback(int after);
int FindBeginningOfGreenZone(int starting_index = 0);
int findFirstGreenzonedFrame(int startingFrame = 0);
int GetSize();
std::vector<uint8>& GetSavestate(int frame);
void WriteSavestate(int frame, std::vector<uint8>& savestate);
bool SavestateIsEmpty(unsigned int frame);
int getSize();
std::vector<uint8>& getSavestateOfFrame(int frame);
void writeSavestateForFrame(int frame, std::vector<uint8>& savestate);
bool isSavestateEmpty(unsigned int frame);
// saved data
LAGLOG laglog;
LAGLOG lagLog;
private:
void CollectCurrentState();
bool ClearSavestate(unsigned int index);
bool ClearSavestateAndFreeMemory(unsigned int index);
void collectCurrentState();
bool clearSavestateOfFrame(unsigned int frame);
bool clearSavestateAndFreeMemory(unsigned int frame);
void AdjustUp();
void AdjustDown();
void adjustUp();
void adjustDown();
// saved data
int greenZoneCount;
int greenzoneSize;
std::vector<std::vector<uint8>> savestates;
// not saved data
int next_cleaning_time;
int nextCleaningTime;
};

File diff suppressed because it is too large Load Diff

View File

@ -97,64 +97,62 @@ public:
void reset();
void update(); // called every frame
void HistorySizeChanged();
void updateHistoryLogSize();
void save(EMUFILE *os, bool really_save = true);
void save(EMUFILE *os, bool reallySave = true);
bool load(EMUFILE *is, unsigned int offset);
void undo();
void redo();
int RegisterChanges(int mod_type, int start = 0, int end =-1, int size = 0, const char* comment = NULL, int consecutive_tag = 0, SelectionFrames* frameset = NULL);
int RegisterAdjustLag(int start, int size);
void RegisterMarkersChange(int mod_type, int start = 0, int end =-1, const char* comment = 0);
int registerChanges(int mod_type, int start = 0, int end =-1, int size = 0, const char* comment = NULL, int consecutivenessTag = 0, RowsSelection* frameset = NULL);
int registerAdjustLag(int start, int size);
void registerMarkersChange(int modificationType, int start = 0, int end =-1, const char* comment = 0);
void registerBookmarkSet(int slot, BOOKMARK& backupÑopy, int oldCurrentBranch);
int registerBranching(int slot, bool markersWereChanged);
void registerRecording(int frameOfChange, uint32 joypadDifferenceBits);
int registerImport(MovieData& md, char* filename);
int registerLuaChanges(const char* name, int start, bool insertionOrDeletionWasDone);
void RegisterBookmarkSet(int slot, BOOKMARK& backup_copy, int old_current_branch);
int RegisterBranching(int slot, bool markers_changed);
void RegisterRecording(int frame_of_change, uint32 joypad_diff_bits);
int RegisterImport(MovieData& md, char* filename);
int RegisterLuaChanges(const char* name, int start, bool InsertionDeletion_was_made);
int getCategoryOfOperation(int modificationType);
int GetCategoryOfOperation(int mod_type);
SNAPSHOT& getCurrentSnapshot();
SNAPSHOT& getNextToCurrentSnapshot();
int getUndoHint();
char* getItemDesc(int pos);
SNAPSHOT& GetCurrentSnapshot();
SNAPSHOT& GetNextToCurrentSnapshot();
char* GetItemDesc(int pos);
int GetUndoHint();
void getDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG handleCustomDraw(NMLVCUSTOMDRAW* msg);
void handleSingleClick(int rowIndex);
void GetDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG CustomDraw(NMLVCUSTOMDRAW* msg);
void Click(int row_index);
void redrawList();
void updateList();
void RedrawHistoryList();
void UpdateHistoryList();
bool CursorOverHistoryList();
bool isCursorOverHistoryList();
HWND hwndHistoryList;
private:
int JumpInTime(int new_pos);
int jumpInTime(int newPos);
void AddItemToHistory(SNAPSHOT &snap, int cur_branch = 0);
void AddItemToHistory(SNAPSHOT &snap, int cur_branch, BOOKMARK &bookm);
void addItemToHistoryLog(SNAPSHOT &snap, int currentBranch = 0);
void addItemToHistoryLog(SNAPSHOT &snap, int currentBranch, BOOKMARK &bookm);
// saved variables
std::vector<SNAPSHOT> snapshots;
std::vector<BOOKMARK> backup_bookmarks;
std::vector<int8> backup_current_branch;
int history_cursor_pos;
int history_total_items;
std::vector<BOOKMARK> bookmarkBackups;
std::vector<int8> currentBranchNumberBackups;
int historyCursorPos;
int historyTotalItems;
// not saved variables
int history_start_pos;
int history_size;
int historyStartPos;
int historySize;
int undo_hint_pos, old_undo_hint_pos;
int undo_hint_time;
bool old_show_undo_hint, show_undo_hint;
int next_autocompress_time;
int undoHintPos, oldUndoHintPos;
int undoHintTimer;
bool showUndoHint, oldShowUndoHint;
int nextAutocompressTime;
};

View File

@ -24,9 +24,9 @@ InputLog - Log of Input
#include "zlib.h"
extern SELECTION selection;
extern int GetInputType(MovieData& md);
extern int getInputType(MovieData& md);
int joysticks_per_frame[NUM_SUPPORTED_INPUT_TYPES] = {1, 2, 4};
int joysticksPerFrame[INPUT_TYPES_TOTAL] = {1, 2, 4};
INPUTLOG::INPUTLOG()
{
@ -34,18 +34,18 @@ INPUTLOG::INPUTLOG()
void INPUTLOG::init(MovieData& md, bool hotchanges, int force_input_type)
{
has_hot_changes = hotchanges;
hasHotChanges = hotchanges;
if (force_input_type < 0)
input_type = GetInputType(md);
inputType = getInputType(md);
else
input_type = force_input_type;
int num_joys = joysticks_per_frame[input_type];
inputType = force_input_type;
int num_joys = joysticksPerFrame[inputType];
// retrieve Input data from movie data
size = md.getNumRecords();
joysticks.resize(BYTES_PER_JOYSTICK * num_joys * size); // it's much faster to have this format than have [frame][joy] or other structures
commands.resize(size); // commands take 1 byte per frame
if (has_hot_changes)
Init_HotChanges();
if (hasHotChanges)
initHotChanges();
// fill Input vector
int joy;
@ -55,44 +55,44 @@ void INPUTLOG::init(MovieData& md, bool hotchanges, int force_input_type)
joysticks[frame * num_joys * BYTES_PER_JOYSTICK + joy * BYTES_PER_JOYSTICK] = md.records[frame].joysticks[joy];
commands[frame] = md.records[frame].commands;
}
already_compressed = false;
alreadyCompressed = false;
}
// this function only updates one frame of Input Log and Hot Changes data
// the function should only be used when combining consecutive Recordings
void INPUTLOG::reinit(MovieData& md, bool hotchanges, int frame_of_change)
{
has_hot_changes = hotchanges;
int num_joys = joysticks_per_frame[input_type];
hasHotChanges = hotchanges;
int num_joys = joysticksPerFrame[inputType];
int joy;
// retrieve Input data from movie data
size = md.getNumRecords();
joysticks.resize(BYTES_PER_JOYSTICK * num_joys * size, 0);
commands.resize(size);
if (has_hot_changes)
if (hasHotChanges)
{
// resize Hot Changes
Init_HotChanges();
initHotChanges();
// compare current movie data at the frame_of_change to current state of InputLog at the frame_of_change
uint8 my_joy, their_joy;
for (joy = num_joys - 1; joy >= 0; joy--)
{
my_joy = GetJoystickInfo(frame_of_change, joy);
my_joy = getJoystickData(frame_of_change, joy);
their_joy = md.records[frame_of_change].joysticks[joy];
if (my_joy != their_joy)
SetMaxHotChange_Bits(frame_of_change, joy, my_joy ^ their_joy);
setMaxHotChangeBits(frame_of_change, joy, my_joy ^ their_joy);
}
} else
{
// if user switches Hot Changes off inbetween two consecutive Recordings
hot_changes.resize(0);
hotChanges.resize(0);
}
// update Input vector
for (joy = num_joys - 1; joy >= 0; joy--)
joysticks[frame_of_change * num_joys * BYTES_PER_JOYSTICK + joy * BYTES_PER_JOYSTICK] = md.records[frame_of_change].joysticks[joy];
commands[frame_of_change] = md.records[frame_of_change].commands;
already_compressed = false;
alreadyCompressed = false;
}
void INPUTLOG::toMovie(MovieData& md, int start, int end)
@ -100,7 +100,7 @@ void INPUTLOG::toMovie(MovieData& md, int start, int end)
if (end < 0 || end >= size) end = size - 1;
// write Input data to movie data
md.records.resize(end + 1);
int num_joys = joysticks_per_frame[input_type];
int num_joys = joysticksPerFrame[inputType];
int joy;
for (int frame = start; frame <= end; ++frame)
{
@ -110,57 +110,57 @@ void INPUTLOG::toMovie(MovieData& md, int start, int end)
}
}
void INPUTLOG::compress_data()
void INPUTLOG::compressData()
{
// compress joysticks
int len = joysticks.size();
uLongf comprlen = (len>>9)+12 + len;
joysticks_compressed.resize(comprlen);
compress(&joysticks_compressed[0], &comprlen, &joysticks[0], len);
joysticks_compressed.resize(comprlen);
compressedJoysticks.resize(comprlen);
compress(&compressedJoysticks[0], &comprlen, &joysticks[0], len);
compressedJoysticks.resize(comprlen);
// compress commands
len = commands.size();
comprlen = (len>>9)+12 + len;
commands_compressed.resize(comprlen);
compress(&commands_compressed[0], &comprlen, &commands[0], len);
commands_compressed.resize(comprlen);
if (has_hot_changes)
compressedCommands.resize(comprlen);
compress(&compressedCommands[0], &comprlen, &commands[0], len);
compressedCommands.resize(comprlen);
if (hasHotChanges)
{
// compress hot_changes
len = hot_changes.size();
len = hotChanges.size();
comprlen = (len>>9)+12 + len;
hot_changes_compressed.resize(comprlen);
compress(&hot_changes_compressed[0], &comprlen, &hot_changes[0], len);
hot_changes_compressed.resize(comprlen);
compressedHotChanges.resize(comprlen);
compress(&compressedHotChanges[0], &comprlen, &hotChanges[0], len);
compressedHotChanges.resize(comprlen);
}
// don't recompress anymore
already_compressed = true;
alreadyCompressed = true;
}
bool INPUTLOG::Get_already_compressed()
bool INPUTLOG::isAlreadyCompressed()
{
return already_compressed;
return alreadyCompressed;
}
void INPUTLOG::save(EMUFILE *os)
{
// write vars
write32le(size, os);
write8le(input_type, os);
write8le(inputType, os);
// write data
if (!already_compressed)
compress_data();
if (!alreadyCompressed)
compressData();
// save joysticks data
write32le(joysticks_compressed.size(), os);
os->fwrite(&joysticks_compressed[0], joysticks_compressed.size());
write32le(compressedJoysticks.size(), os);
os->fwrite(&compressedJoysticks[0], compressedJoysticks.size());
// save commands data
write32le(commands_compressed.size(), os);
os->fwrite(&commands_compressed[0], commands_compressed.size());
if (has_hot_changes)
write32le(compressedCommands.size(), os);
os->fwrite(&compressedCommands[0], compressedCommands.size());
if (hasHotChanges)
{
write8le((uint8)1, os);
// save hot_changes data
write32le(hot_changes_compressed.size(), os);
os->fwrite(&hot_changes_compressed[0], hot_changes_compressed.size());
write32le(compressedHotChanges.size(), os);
os->fwrite(&compressedHotChanges[0], compressedHotChanges.size());
} else
{
write8le((uint8)0, os);
@ -173,20 +173,20 @@ bool INPUTLOG::load(EMUFILE *is)
// read vars
if (!read32le(&size, is)) return true;
if (!read8le(&tmp, is)) return true;
input_type = tmp;
inputType = tmp;
// read data
already_compressed = true;
alreadyCompressed = true;
int comprlen;
uLongf destlen;
// read and uncompress joysticks data
destlen = size * BYTES_PER_JOYSTICK * joysticks_per_frame[input_type];
destlen = size * BYTES_PER_JOYSTICK * joysticksPerFrame[inputType];
joysticks.resize(destlen);
// read size
if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true;
joysticks_compressed.resize(comprlen);
if (is->fread(&joysticks_compressed[0], comprlen) != comprlen) return true;
int e = uncompress(&joysticks[0], &destlen, &joysticks_compressed[0], comprlen);
compressedJoysticks.resize(comprlen);
if (is->fread(&compressedJoysticks[0], comprlen) != comprlen) return true;
int e = uncompress(&joysticks[0], &destlen, &compressedJoysticks[0], comprlen);
if (e != Z_OK && e != Z_BUF_ERROR) return true;
// read and uncompress commands data
destlen = size;
@ -194,24 +194,24 @@ bool INPUTLOG::load(EMUFILE *is)
// read size
if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true;
commands_compressed.resize(comprlen);
if (is->fread(&commands_compressed[0], comprlen) != comprlen) return true;
e = uncompress(&commands[0], &destlen, &commands_compressed[0], comprlen);
compressedCommands.resize(comprlen);
if (is->fread(&compressedCommands[0], comprlen) != comprlen) return true;
e = uncompress(&commands[0], &destlen, &compressedCommands[0], comprlen);
if (e != Z_OK && e != Z_BUF_ERROR) return true;
// read hotchanges
if (!read8le(&tmp, is)) return true;
has_hot_changes = (tmp != 0);
if (has_hot_changes)
hasHotChanges = (tmp != 0);
if (hasHotChanges)
{
// read and uncompress hot_changes data
destlen = size * joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
hot_changes.resize(destlen);
destlen = size * joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
hotChanges.resize(destlen);
// read size
if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true;
hot_changes_compressed.resize(comprlen);
if (is->fread(&hot_changes_compressed[0], comprlen) != comprlen) return true;
e = uncompress(&hot_changes[0], &destlen, &hot_changes_compressed[0], comprlen);
compressedHotChanges.resize(comprlen);
if (is->fread(&compressedHotChanges[0], comprlen) != comprlen) return true;
e = uncompress(&hotChanges[0], &destlen, &compressedHotChanges[0], comprlen);
if (e != Z_OK && e != Z_BUF_ERROR) return true;
}
return false;
@ -241,19 +241,19 @@ bool INPUTLOG::skipLoad(EMUFILE *is)
}
// --------------------------------------------------------------------------------------------
// return number of first frame of difference between two InputLogs
int INPUTLOG::findFirstChange(INPUTLOG& their_log, int start, int end)
int INPUTLOG::findFirstChange(INPUTLOG& theirLog, int start, int end)
{
// search for differences to the specified end (or to the end of this InputLog)
if (end < 0 || end >= size) end = size-1;
int their_log_end = their_log.size;
int their_log_end = theirLog.size;
int joy;
int num_joys = joysticks_per_frame[input_type];
int num_joys = joysticksPerFrame[inputType];
for (int frame = start; frame <= end; ++frame)
{
for (joy = num_joys - 1; joy >= 0; joy--)
if (GetJoystickInfo(frame, joy) != their_log.GetJoystickInfo(frame, joy)) return frame;
if (GetCommandsInfo(frame) != their_log.GetCommandsInfo(frame)) return frame;
if (getJoystickData(frame, joy) != theirLog.getJoystickData(frame, joy)) return frame;
if (getCommandsData(frame) != theirLog.getCommandsData(frame)) return frame;
}
// no difference was found
@ -270,12 +270,12 @@ int INPUTLOG::findFirstChange(MovieData& md, int start, int end)
if (end >= md.getNumRecords()) end = md.getNumRecords() - 1;
int joy;
int num_joys = joysticks_per_frame[input_type];
int num_joys = joysticksPerFrame[inputType];
for (int frame = start; frame <= end; ++frame)
{
for (joy = num_joys - 1; joy >= 0; joy--)
if (GetJoystickInfo(frame, joy) != md.records[frame].joysticks[joy]) return frame;
if (GetCommandsInfo(frame) != md.records[frame].commands) return frame;
if (getJoystickData(frame, joy) != md.records[frame].joysticks[joy]) return frame;
if (getCommandsData(frame) != md.records[frame].commands) return frame;
}
// no difference was found
@ -288,15 +288,15 @@ int INPUTLOG::findFirstChange(MovieData& md, int start, int end)
return -1;
}
int INPUTLOG::GetJoystickInfo(int frame, int joy)
int INPUTLOG::getJoystickData(int frame, int joy)
{
if (frame < 0 || frame >= size)
return 0;
if (joy > joysticks_per_frame[input_type])
if (joy > joysticksPerFrame[inputType])
return 0;
return joysticks[frame * BYTES_PER_JOYSTICK * joysticks_per_frame[input_type] + joy];
return joysticks[frame * BYTES_PER_JOYSTICK * joysticksPerFrame[inputType] + joy];
}
int INPUTLOG::GetCommandsInfo(int frame)
int INPUTLOG::getCommandsData(int frame)
{
if (frame < 0 || frame >= size)
return 0;
@ -310,14 +310,14 @@ void INPUTLOG::insertFrames(int at, int frames)
{
// append frames to the end
commands.resize(size);
joysticks.resize(BYTES_PER_JOYSTICK * joysticks_per_frame[input_type] * size);
if (has_hot_changes)
joysticks.resize(BYTES_PER_JOYSTICK * joysticksPerFrame[inputType] * size);
if (hasHotChanges)
{
hot_changes.resize(joysticks_per_frame[input_type] * size * HOTCHANGE_BYTES_PER_JOY);
hotChanges.resize(joysticksPerFrame[inputType] * size * HOTCHANGE_BYTES_PER_JOY);
// fill new hotchanges with max value
int lower_limit = joysticks_per_frame[input_type] * (size - frames) * HOTCHANGE_BYTES_PER_JOY;
for (int i = hot_changes.size() - 1; i >= lower_limit; i--)
hot_changes[i] = BYTE_VALUE_CONTAINING_MAX_HOTCHANGES;
int lower_limit = joysticksPerFrame[inputType] * (size - frames) * HOTCHANGE_BYTES_PER_JOY;
for (int i = hotChanges.size() - 1; i >= lower_limit; i--)
hotChanges[i] = BYTE_VALUE_CONTAINING_MAX_HOTCHANGES;
}
} else
{
@ -325,81 +325,81 @@ void INPUTLOG::insertFrames(int at, int frames)
// insert 1 byte of commands
commands.insert(commands.begin() + at, frames, 0);
// insert X bytes of joystics
int bytes = BYTES_PER_JOYSTICK * joysticks_per_frame[input_type];
int bytes = BYTES_PER_JOYSTICK * joysticksPerFrame[inputType];
joysticks.insert(joysticks.begin() + (at * bytes), frames * bytes, 0);
if (has_hot_changes)
if (hasHotChanges)
{
// insert X bytes of hot_changes
bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
hot_changes.insert(hot_changes.begin() + (at * bytes), frames * bytes, BYTE_VALUE_CONTAINING_MAX_HOTCHANGES);
bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
hotChanges.insert(hotChanges.begin() + (at * bytes), frames * bytes, BYTE_VALUE_CONTAINING_MAX_HOTCHANGES);
}
}
// data was changed
already_compressed = false;
alreadyCompressed = false;
}
void INPUTLOG::eraseFrame(int frame)
{
// erase 1 byte of commands
commands.erase(commands.begin() + frame);
// erase X bytes of joystics
int bytes = BYTES_PER_JOYSTICK * joysticks_per_frame[input_type];
int bytes = BYTES_PER_JOYSTICK * joysticksPerFrame[inputType];
joysticks.erase(joysticks.begin() + (frame * bytes), joysticks.begin() + ((frame + 1) * bytes));
if (has_hot_changes)
if (hasHotChanges)
{
// erase X bytes of hot_changes
bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
hot_changes.erase(hot_changes.begin() + (frame * bytes), hot_changes.begin() + ((frame + 1) * bytes));
bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
hotChanges.erase(hotChanges.begin() + (frame * bytes), hotChanges.begin() + ((frame + 1) * bytes));
}
size--;
// data was changed
already_compressed = false;
alreadyCompressed = false;
}
// -----------------------------------------------------------------------------------------------
void INPUTLOG::Init_HotChanges()
void INPUTLOG::initHotChanges()
{
hot_changes.resize(joysticks_per_frame[input_type] * size * HOTCHANGE_BYTES_PER_JOY);
hotChanges.resize(joysticksPerFrame[inputType] * size * HOTCHANGE_BYTES_PER_JOY);
}
void INPUTLOG::copyHotChanges(INPUTLOG* source_of_hotchanges, int limit_frame_of_source)
void INPUTLOG::copyHotChanges(INPUTLOG* sourceOfHotChanges, int limiterFrameOfSource)
{
// copy hot changes from source InputLog
if (source_of_hotchanges && source_of_hotchanges->has_hot_changes && source_of_hotchanges->input_type == input_type)
if (sourceOfHotChanges && sourceOfHotChanges->hasHotChanges && sourceOfHotChanges->inputType == inputType)
{
int frames_to_copy = source_of_hotchanges->size;
int frames_to_copy = sourceOfHotChanges->size;
if (frames_to_copy > size)
frames_to_copy = size;
// special case for Branches: if limit_frame if specified, then copy only hotchanges from 0 to limit_frame
if (limit_frame_of_source >= 0 && frames_to_copy > limit_frame_of_source)
frames_to_copy = limit_frame_of_source;
if (limiterFrameOfSource >= 0 && frames_to_copy > limiterFrameOfSource)
frames_to_copy = limiterFrameOfSource;
int bytes_to_copy = frames_to_copy * joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
memcpy(&hot_changes[0], &source_of_hotchanges->hot_changes[0], bytes_to_copy);
int bytes_to_copy = frames_to_copy * joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
memcpy(&hotChanges[0], &sourceOfHotChanges->hotChanges[0], bytes_to_copy);
}
}
void INPUTLOG::inheritHotChanges(INPUTLOG* source_of_hotchanges)
void INPUTLOG::inheritHotChanges(INPUTLOG* sourceOfHotChanges)
{
// copy hot changes from source InputLog and fade them
if (source_of_hotchanges && source_of_hotchanges->has_hot_changes && source_of_hotchanges->input_type == input_type)
if (sourceOfHotChanges && sourceOfHotChanges->hasHotChanges && sourceOfHotChanges->inputType == inputType)
{
int frames_to_copy = source_of_hotchanges->size;
int frames_to_copy = sourceOfHotChanges->size;
if (frames_to_copy > size)
frames_to_copy = size;
int bytes_to_copy = frames_to_copy * joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
memcpy(&hot_changes[0], &source_of_hotchanges->hot_changes[0], bytes_to_copy);
FadeHotChanges();
int bytes_to_copy = frames_to_copy * joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
memcpy(&hotChanges[0], &sourceOfHotChanges->hotChanges[0], bytes_to_copy);
fadeHotChanges();
}
}
void INPUTLOG::inheritHotChanges_DeleteSelection(INPUTLOG* source_of_hotchanges, SelectionFrames* frameset)
void INPUTLOG::inheritHotChanges_DeleteSelection(INPUTLOG* sourceOfHotChanges, RowsSelection* frameset)
{
// copy hot changes from source InputLog, but omit deleted frames (which are represented by the "frameset")
if (source_of_hotchanges && source_of_hotchanges->has_hot_changes && source_of_hotchanges->input_type == input_type)
if (sourceOfHotChanges && sourceOfHotChanges->hasHotChanges && sourceOfHotChanges->inputType == inputType)
{
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
int frame = 0, pos = 0, source_pos = 0;
int this_size = hot_changes.size(), source_size = source_of_hotchanges->hot_changes.size();
SelectionFrames::iterator it(frameset->begin());
SelectionFrames::iterator frameset_end(frameset->end());
int this_size = hotChanges.size(), source_size = sourceOfHotChanges->hotChanges.size();
RowsSelection::iterator it(frameset->begin());
RowsSelection::iterator frameset_end(frameset->end());
while (pos < this_size && source_pos < source_size)
{
if (it != frameset_end && frame == *it)
@ -410,25 +410,25 @@ void INPUTLOG::inheritHotChanges_DeleteSelection(INPUTLOG* source_of_hotchanges,
} else
{
// copy hotchanges of this frame
memcpy(&hot_changes[pos], &source_of_hotchanges->hot_changes[source_pos], bytes);
memcpy(&hotChanges[pos], &sourceOfHotChanges->hotChanges[source_pos], bytes);
pos += bytes;
source_pos += bytes;
}
frame++;
}
FadeHotChanges();
fadeHotChanges();
}
}
void INPUTLOG::inheritHotChanges_InsertSelection(INPUTLOG* source_of_hotchanges, SelectionFrames* frameset)
void INPUTLOG::inheritHotChanges_InsertSelection(INPUTLOG* sourceOfHotChanges, RowsSelection* frameset)
{
// copy hot changes from source InputLog, but insert filled lines for inserted frames (which are represented by the "frameset")
SelectionFrames::iterator it(frameset->begin());
SelectionFrames::iterator frameset_end(frameset->end());
if (source_of_hotchanges && source_of_hotchanges->has_hot_changes && source_of_hotchanges->input_type == input_type)
RowsSelection::iterator it(frameset->begin());
RowsSelection::iterator frameset_end(frameset->end());
if (sourceOfHotChanges && sourceOfHotChanges->hasHotChanges && sourceOfHotChanges->inputType == inputType)
{
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
int frame = 0, region_len = 0, pos = 0, source_pos = 0;
int this_size = hot_changes.size(), source_size = source_of_hotchanges->hot_changes.size();
int this_size = hotChanges.size(), source_size = sourceOfHotChanges->hotChanges.size();
while (pos < this_size)
{
if (it != frameset_end && frame == *it)
@ -437,15 +437,15 @@ void INPUTLOG::inheritHotChanges_InsertSelection(INPUTLOG* source_of_hotchanges,
it++;
region_len++;
// set filled line to the frame
memset(&hot_changes[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
memset(&hotChanges[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
} else if (source_pos < source_size)
{
// this frame should be copied
frame -= region_len;
region_len = 0;
// copy hotchanges of this frame
memcpy(&hot_changes[pos], &source_of_hotchanges->hot_changes[source_pos], bytes);
FadeHotChanges(pos, pos + bytes);
memcpy(&hotChanges[pos], &sourceOfHotChanges->hotChanges[source_pos], bytes);
fadeHotChanges(pos, pos + bytes);
source_pos += bytes;
}
pos += bytes;
@ -454,9 +454,9 @@ void INPUTLOG::inheritHotChanges_InsertSelection(INPUTLOG* source_of_hotchanges,
} else
{
// no old data, just fill "frameset" lines
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
int frame = 0, region_len = 0, pos = 0;
int this_size = hot_changes.size();
int this_size = hotChanges.size();
while (pos < this_size)
{
if (it != frameset_end && frame == *it)
@ -465,7 +465,7 @@ void INPUTLOG::inheritHotChanges_InsertSelection(INPUTLOG* source_of_hotchanges,
it++;
region_len++;
// set filled line to the frame
memset(&hot_changes[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
memset(&hotChanges[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
// exit loop when all frames in the Selection are handled
if (it == frameset_end) break;
} else
@ -480,65 +480,65 @@ void INPUTLOG::inheritHotChanges_InsertSelection(INPUTLOG* source_of_hotchanges,
}
}
}
void INPUTLOG::inheritHotChanges_DeleteNum(INPUTLOG* source_of_hotchanges, int start, int frames, bool fade_old)
void INPUTLOG::inheritHotChanges_DeleteNum(INPUTLOG* sourceOfHotChanges, int start, int frames, bool fadeOld)
{
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
// copy hot changes from source InputLog up to "start" and from "start+frames" to end
if (source_of_hotchanges && source_of_hotchanges->has_hot_changes && source_of_hotchanges->input_type == input_type)
if (sourceOfHotChanges && sourceOfHotChanges->hasHotChanges && sourceOfHotChanges->inputType == inputType)
{
int this_size = hot_changes.size(), source_size = source_of_hotchanges->hot_changes.size();
int this_size = hotChanges.size(), source_size = sourceOfHotChanges->hotChanges.size();
int bytes_to_copy = bytes * start;
int dest_pos = 0, source_pos = 0;
if (bytes_to_copy > source_size)
bytes_to_copy = source_size;
memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy);
memcpy(&hotChanges[dest_pos], &sourceOfHotChanges->hotChanges[source_pos], bytes_to_copy);
dest_pos += bytes_to_copy;
source_pos += bytes_to_copy + bytes * frames;
bytes_to_copy = this_size - dest_pos;
if (bytes_to_copy > source_size - source_pos)
bytes_to_copy = source_size - source_pos;
memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy);
if (fade_old)
FadeHotChanges();
memcpy(&hotChanges[dest_pos], &sourceOfHotChanges->hotChanges[source_pos], bytes_to_copy);
if (fadeOld)
fadeHotChanges();
}
}
void INPUTLOG::inheritHotChanges_InsertNum(INPUTLOG* source_of_hotchanges, int start, int frames, bool fade_old)
void INPUTLOG::inheritHotChanges_InsertNum(INPUTLOG* sourceOfHotChanges, int start, int frames, bool fadeOld)
{
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
// copy hot changes from source InputLog up to "start", then make a gap, then copy from "start+frames" to end
if (source_of_hotchanges && source_of_hotchanges->has_hot_changes && source_of_hotchanges->input_type == input_type)
if (sourceOfHotChanges && sourceOfHotChanges->hasHotChanges && sourceOfHotChanges->inputType == inputType)
{
int this_size = hot_changes.size(), source_size = source_of_hotchanges->hot_changes.size();
int this_size = hotChanges.size(), source_size = sourceOfHotChanges->hotChanges.size();
int bytes_to_copy = bytes * start;
int dest_pos = 0, source_pos = 0;
if (bytes_to_copy > source_size)
bytes_to_copy = source_size;
memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy);
memcpy(&hotChanges[dest_pos], &sourceOfHotChanges->hotChanges[source_pos], bytes_to_copy);
dest_pos += bytes_to_copy + bytes * frames;
source_pos += bytes_to_copy;
bytes_to_copy = this_size - dest_pos;
if (bytes_to_copy > source_size - source_pos)
bytes_to_copy = source_size - source_pos;
memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy);
if (fade_old)
FadeHotChanges();
memcpy(&hotChanges[dest_pos], &sourceOfHotChanges->hotChanges[source_pos], bytes_to_copy);
if (fadeOld)
fadeHotChanges();
}
// fill the gap with max_hot lines on frames from "start" to "start+frames"
memset(&hot_changes[bytes * start], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes * frames);
memset(&hotChanges[bytes * start], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes * frames);
}
void INPUTLOG::inheritHotChanges_PasteInsert(INPUTLOG* source_of_hotchanges, SelectionFrames* inserted_set)
void INPUTLOG::inheritHotChanges_PasteInsert(INPUTLOG* sourceOfHotChanges, RowsSelection* insertedSet)
{
// copy hot changes from source InputLog and insert filled lines for inserted frames (which are represented by "inserted_set")
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int bytes = joysticksPerFrame[inputType] * HOTCHANGE_BYTES_PER_JOY;
int frame = 0, pos = 0;
int this_size = hot_changes.size();
SelectionFrames::iterator it(inserted_set->begin());
SelectionFrames::iterator inserted_set_end(inserted_set->end());
int this_size = hotChanges.size();
RowsSelection::iterator it(insertedSet->begin());
RowsSelection::iterator inserted_set_end(insertedSet->end());
if (source_of_hotchanges && source_of_hotchanges->has_hot_changes && source_of_hotchanges->input_type == input_type)
if (sourceOfHotChanges && sourceOfHotChanges->hasHotChanges && sourceOfHotChanges->inputType == inputType)
{
int source_pos = 0;
int source_size = source_of_hotchanges->hot_changes.size();
int source_size = sourceOfHotChanges->hotChanges.size();
while (pos < this_size)
{
if (it != inserted_set_end && frame == *it)
@ -546,12 +546,12 @@ void INPUTLOG::inheritHotChanges_PasteInsert(INPUTLOG* source_of_hotchanges, Sel
// this frame was inserted
it++;
// set filled line to the frame
memset(&hot_changes[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
memset(&hotChanges[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
} else if (source_pos < source_size)
{
// copy hotchanges of this frame
memcpy(&hot_changes[pos], &source_of_hotchanges->hot_changes[source_pos], bytes);
FadeHotChanges(pos, pos + bytes);
memcpy(&hotChanges[pos], &sourceOfHotChanges->hotChanges[source_pos], bytes);
fadeHotChanges(pos, pos + bytes);
source_pos += bytes;
}
pos += bytes;
@ -567,7 +567,7 @@ void INPUTLOG::inheritHotChanges_PasteInsert(INPUTLOG* source_of_hotchanges, Sel
// this frame was inserted
it++;
// set filled line to the frame
memset(&hot_changes[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
memset(&hotChanges[pos], BYTE_VALUE_CONTAINING_MAX_HOTCHANGES, bytes);
pos += bytes;
// exit loop when all inserted_set frames are handled
if (it == inserted_set_end) break;
@ -580,70 +580,70 @@ void INPUTLOG::inheritHotChanges_PasteInsert(INPUTLOG* source_of_hotchanges, Sel
}
}
}
void INPUTLOG::fillHotChanges(INPUTLOG& their_log, int start, int end)
void INPUTLOG::fillHotChanges(INPUTLOG& theirLog, int start, int end)
{
// compare InputLogs to the specified end (or to the end of this InputLog)
if (end < 0 || end >= size) end = size-1;
uint8 my_joy, their_joy;
for (int joy = joysticks_per_frame[input_type] - 1; joy >= 0; joy--)
for (int joy = joysticksPerFrame[inputType] - 1; joy >= 0; joy--)
{
for (int frame = start; frame <= end; ++frame)
{
my_joy = GetJoystickInfo(frame, joy);
their_joy = their_log.GetJoystickInfo(frame, joy);
my_joy = getJoystickData(frame, joy);
their_joy = theirLog.getJoystickData(frame, joy);
if (my_joy != their_joy)
SetMaxHotChange_Bits(frame, joy, my_joy ^ their_joy);
setMaxHotChangeBits(frame, joy, my_joy ^ their_joy);
}
}
}
void INPUTLOG::SetMaxHotChange_Bits(int frame, int joypad, uint8 joy_bits)
void INPUTLOG::setMaxHotChangeBits(int frame, int joypad, uint8 joyBits)
{
uint8 mask = 1;
// check all 8 buttons and set max hot_changes for bits that are set
for (int i = 0; i < BUTTONS_PER_JOYSTICK; ++i)
{
if (joy_bits & mask)
SetMaxHotChange(frame, joypad * BUTTONS_PER_JOYSTICK + i);
if (joyBits & mask)
setMaxHotChanges(frame, joypad * BUTTONS_PER_JOYSTICK + i);
mask <<= 1;
}
}
void INPUTLOG::SetMaxHotChange(int frame, int absolute_button)
void INPUTLOG::setMaxHotChanges(int frame, int absoluteButtonNumber)
{
if (frame < 0 || frame >= size || !has_hot_changes) return;
if (frame < 0 || frame >= size || !hasHotChanges) return;
// set max value to the button hotness
if (absolute_button & 1)
hot_changes[frame * (HOTCHANGE_BYTES_PER_JOY * joysticks_per_frame[input_type]) + (absolute_button >> 1)] |= BYTE_VALUE_CONTAINING_MAX_HOTCHANGE_HI;
if (absoluteButtonNumber & 1)
hotChanges[frame * (HOTCHANGE_BYTES_PER_JOY * joysticksPerFrame[inputType]) + (absoluteButtonNumber >> 1)] |= BYTE_VALUE_CONTAINING_MAX_HOTCHANGE_HI;
else
hot_changes[frame * (HOTCHANGE_BYTES_PER_JOY * joysticks_per_frame[input_type]) + (absolute_button >> 1)] |= BYTE_VALUE_CONTAINING_MAX_HOTCHANGE_LO;
hotChanges[frame * (HOTCHANGE_BYTES_PER_JOY * joysticksPerFrame[inputType]) + (absoluteButtonNumber >> 1)] |= BYTE_VALUE_CONTAINING_MAX_HOTCHANGE_LO;
}
void INPUTLOG::FadeHotChanges(int start_byte, int end_byte)
void INPUTLOG::fadeHotChanges(int startByte, int endByte)
{
uint8 hi_half, low_half;
if (end_byte < 0)
end_byte = hot_changes.size();
for (int i = end_byte - 1; i >= start_byte; i--)
if (endByte < 0)
endByte = hotChanges.size();
for (int i = endByte - 1; i >= startByte; i--)
{
if (hot_changes[i])
if (hotChanges[i])
{
hi_half = hot_changes[i] >> HOTCHANGE_BITS_PER_VALUE;
low_half = hot_changes[i] & HOTCHANGE_BITMASK;
hi_half = hotChanges[i] >> HOTCHANGE_BITS_PER_VALUE;
low_half = hotChanges[i] & HOTCHANGE_BITMASK;
if (hi_half) hi_half--;
if (low_half) low_half--;
hot_changes[i] = (hi_half << HOTCHANGE_BITS_PER_VALUE) | low_half;
hotChanges[i] = (hi_half << HOTCHANGE_BITS_PER_VALUE) | low_half;
}
}
}
int INPUTLOG::GetHotChangeInfo(int frame, int absolute_button)
int INPUTLOG::getHotChangesInfo(int frame, int absoluteButtonNumber)
{
if (!has_hot_changes || frame < 0 || frame >= size || absolute_button < 0 || absolute_button >= NUM_JOYPAD_BUTTONS * joysticks_per_frame[input_type])
if (!hasHotChanges || frame < 0 || frame >= size || absoluteButtonNumber < 0 || absoluteButtonNumber >= NUM_JOYPAD_BUTTONS * joysticksPerFrame[inputType])
return 0;
uint8 val = hot_changes[frame * (HOTCHANGE_BYTES_PER_JOY * joysticks_per_frame[input_type]) + (absolute_button >> 1)];
uint8 val = hotChanges[frame * (HOTCHANGE_BYTES_PER_JOY * joysticksPerFrame[inputType]) + (absoluteButtonNumber >> 1)];
if (absolute_button & 1)
if (absoluteButtonNumber & 1)
// odd buttons (B, T, D, R) take upper 4 bits of the byte
return val >> HOTCHANGE_BITS_PER_VALUE;
else

View File

@ -1,12 +1,13 @@
// Specification file for InputLog class
enum Input_types
enum INPUT_TYPES
{
INPUT_TYPE_1P,
INPUT_TYPE_2P,
INPUT_TYPE_FOURSCORE,
NUM_SUPPORTED_INPUT_TYPES
// ...
INPUT_TYPES_TOTAL
};
#define BUTTONS_PER_JOYSTICK 8
@ -33,54 +34,52 @@ public:
bool load(EMUFILE *is);
bool skipLoad(EMUFILE *is);
void compress_data();
bool Get_already_compressed();
void compressData();
bool isAlreadyCompressed();
int findFirstChange(INPUTLOG& their_log, int start = 0, int end = -1);
int findFirstChange(INPUTLOG& theirLog, int start = 0, int end = -1);
int findFirstChange(MovieData& md, int start = 0, int end = -1);
int GetJoystickInfo(int frame, int joy);
int GetCommandsInfo(int frame);
int getJoystickData(int frame, int joy);
int getCommandsData(int frame);
void insertFrames(int at, int frames);
void eraseFrame(int frame);
void Init_HotChanges();
void initHotChanges();
void copyHotChanges(INPUTLOG* source_of_hotchanges, int limit_frame_of_source = -1);
void inheritHotChanges(INPUTLOG* source_of_hotchanges);
void inheritHotChanges_DeleteSelection(INPUTLOG* source_of_hotchanges, SelectionFrames* frameset);
void inheritHotChanges_InsertSelection(INPUTLOG* source_of_hotchanges, SelectionFrames* frameset);
void inheritHotChanges_DeleteNum(INPUTLOG* source_of_hotchanges, int start, int frames, bool fade_old);
void inheritHotChanges_InsertNum(INPUTLOG* source_of_hotchanges, int start, int frames, bool fade_old);
void inheritHotChanges_PasteInsert(INPUTLOG* source_of_hotchanges, SelectionFrames* inserted_set);
void fillHotChanges(INPUTLOG& their_log, int start = 0, int end = -1);
void copyHotChanges(INPUTLOG* sourceOfHotChanges, int limiterFrameOfSource = -1);
void inheritHotChanges(INPUTLOG* sourceOfHotChanges);
void inheritHotChanges_DeleteSelection(INPUTLOG* sourceOfHotChanges, RowsSelection* frameset);
void inheritHotChanges_InsertSelection(INPUTLOG* sourceOfHotChanges, RowsSelection* frameset);
void inheritHotChanges_DeleteNum(INPUTLOG* sourceOfHotChanges, int start, int frames, bool fadeOld);
void inheritHotChanges_InsertNum(INPUTLOG* sourceOfHotChanges, int start, int frames, bool fadeOld);
void inheritHotChanges_PasteInsert(INPUTLOG* sourceOfHotChanges, RowsSelection* insertedSet);
void fillHotChanges(INPUTLOG& theirLog, int start = 0, int end = -1);
void SetMaxHotChange_Bits(int frame, int joypad, uint8 joy_bits);
void SetMaxHotChange(int frame, int absolute_button);
void setMaxHotChangeBits(int frame, int joypad, uint8 joyBits);
void setMaxHotChanges(int frame, int absoluteButtonNumber);
void FadeHotChanges(int start_byte = 0, int end_byte = -1);
void fadeHotChanges(int startByte = 0, int endByte = -1);
int GetHotChangeInfo(int frame, int absolute_button);
int getHotChangesInfo(int frame, int absoluteButtonNumber);
// saved data
int size; // in frames
int input_type; // theoretically TAS Editor can support any other Input types
bool has_hot_changes;
// not saved data
std::vector<uint8> hot_changes; // Format: buttons01joy0-for-frame0, buttons23joy0-for-frame0, buttons45joy0-for-frame0, buttons67joy0-for-frame0, buttons01joy1-for-frame0, ...
std::vector<uint8> joysticks; // Format: joy0-for-frame0, joy1-for-frame0, joy2-for-frame0, joy3-for-frame0, joy0-for-frame1, joy1-for-frame1, ...
std::vector<uint8> commands; // Format: commands-for-frame0, commands-for-frame1, ...
int inputType; // theoretically TAS Editor can support any other Input types
bool hasHotChanges;
private:
// also saved data
std::vector<uint8> joysticks_compressed;
std::vector<uint8> commands_compressed;
std::vector<uint8> hot_changes_compressed;
std::vector<uint8> compressedJoysticks;
std::vector<uint8> compressedCommands;
std::vector<uint8> compressedHotChanges;
// not saved data
bool already_compressed; // to compress only once
std::vector<uint8> hotChanges; // Format: buttons01joy0-for-frame0, buttons23joy0-for-frame0, buttons45joy0-for-frame0, buttons67joy0-for-frame0, buttons01joy1-for-frame0, ...
std::vector<uint8> joysticks; // Format: joy0-for-frame0, joy1-for-frame0, joy2-for-frame0, joy3-for-frame0, joy0-for-frame1, joy1-for-frame1, ...
std::vector<uint8> commands; // Format: commands-for-frame0, commands-for-frame1, ...
bool alreadyCompressed; // to compress only once
};

View File

@ -20,52 +20,52 @@ LagLog - Log of Lag appearance
LAGLOG::LAGLOG()
{
already_compressed = false;
alreadyCompressed = false;
}
void LAGLOG::reset()
{
lag_log.resize(0);
already_compressed = false;
lagLog.resize(0);
alreadyCompressed = false;
}
void LAGLOG::compress_data()
void LAGLOG::compressData()
{
int len = lag_log.size() * sizeof(uint8);
int len = lagLog.size() * sizeof(uint8);
if (len)
{
uLongf comprlen = (len>>9)+12 + len;
lag_log_compressed.resize(comprlen, LAGGED_DONTKNOW);
compress(&lag_log_compressed[0], &comprlen, (uint8*)&lag_log[0], len);
lag_log_compressed.resize(comprlen);
compressedLagLog.resize(comprlen, LAGGED_UNKNOWN);
compress(&compressedLagLog[0], &comprlen, (uint8*)&lagLog[0], len);
compressedLagLog.resize(comprlen);
} else
{
// LagLog can be empty
lag_log_compressed.resize(0);
// LagLog can even be empty
compressedLagLog.resize(0);
}
already_compressed = true;
alreadyCompressed = true;
}
bool LAGLOG::Get_already_compressed()
bool LAGLOG::isAlreadyCompressed()
{
return already_compressed;
return alreadyCompressed;
}
void LAGLOG::Reset_already_compressed()
void LAGLOG::resetCompressedStatus()
{
already_compressed = false;
alreadyCompressed = false;
}
void LAGLOG::save(EMUFILE *os)
{
// write size
int size = lag_log.size();
int size = lagLog.size();
write32le(size, os);
if (size)
{
// write array
if (!already_compressed)
compress_data();
write32le(lag_log_compressed.size(), os);
os->fwrite(&lag_log_compressed[0], lag_log_compressed.size());
if (!alreadyCompressed)
compressData();
write32le(compressedLagLog.size(), os);
os->fwrite(&compressedLagLog[0], compressedLagLog.size());
}
}
// returns true if couldn't load
@ -74,8 +74,8 @@ bool LAGLOG::load(EMUFILE *is)
int size;
if (read32le(&size, is))
{
already_compressed = true;
lag_log.resize(size, LAGGED_DONTKNOW);
alreadyCompressed = true;
lagLog.resize(size, LAGGED_UNKNOWN);
if (size)
{
// read and uncompress array
@ -83,13 +83,13 @@ bool LAGLOG::load(EMUFILE *is)
uLongf destlen = size * sizeof(int);
if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true;
lag_log_compressed.resize(comprlen);
if (is->fread(&lag_log_compressed[0], comprlen) != comprlen) return true;
int e = uncompress((uint8*)&lag_log[0], &destlen, &lag_log_compressed[0], comprlen);
compressedLagLog.resize(comprlen);
if (is->fread(&compressedLagLog[0], comprlen) != comprlen) return true;
int e = uncompress((uint8*)&lagLog[0], &destlen, &compressedLagLog[0], comprlen);
if (e != Z_OK && e != Z_BUF_ERROR) return true;
} else
{
lag_log_compressed.resize(0);
compressedLagLog.resize(0);
}
// all ok
return false;
@ -113,82 +113,82 @@ bool LAGLOG::skipLoad(EMUFILE *is)
return true;
}
// -------------------------------------------------------------------------------------------------
void LAGLOG::InvalidateFrom(int frame)
void LAGLOG::invalidateFromFrame(int frame)
{
if (frame >= 0 && frame < (int)lag_log.size())
if (frame >= 0 && frame < (int)lagLog.size())
{
lag_log.resize(frame);
already_compressed = false;
lagLog.resize(frame);
alreadyCompressed = false;
}
}
void LAGLOG::SetLagInfo(int frame, bool lagFlag)
void LAGLOG::setLagInfo(int frame, bool lagFlag)
{
if ((int)lag_log.size() <= frame)
lag_log.resize(frame + 1, LAGGED_DONTKNOW);
if ((int)lagLog.size() <= frame)
lagLog.resize(frame + 1, LAGGED_UNKNOWN);
if (lagFlag)
lag_log[frame] = LAGGED_YES;
lagLog[frame] = LAGGED_YES;
else
lag_log[frame] = LAGGED_NO;
lagLog[frame] = LAGGED_NO;
already_compressed = false;
alreadyCompressed = false;
}
void LAGLOG::EraseFrame(int frame, int frames)
void LAGLOG::eraseFrame(int frame, int numFrames)
{
if (frame < (int)lag_log.size())
if (frame < (int)lagLog.size())
{
if (frames == 1)
if (numFrames == 1)
{
// erase 1 frame
lag_log.erase(lag_log.begin() + frame);
already_compressed = false;
} else if (frames > 1)
lagLog.erase(lagLog.begin() + frame);
alreadyCompressed = false;
} else if (numFrames > 1)
{
// erase many frames
if (frame + frames > (int)lag_log.size())
frames = (int)lag_log.size() - frame;
lag_log.erase(lag_log.begin() + frame, lag_log.begin() + (frame + frames));
already_compressed = false;
if (frame + numFrames > (int)lagLog.size())
numFrames = (int)lagLog.size() - frame;
lagLog.erase(lagLog.begin() + frame, lagLog.begin() + (frame + numFrames));
alreadyCompressed = false;
}
}
}
void LAGLOG::InsertFrame(int frame, bool lagFlag, int frames)
void LAGLOG::insertFrame(int frame, bool lagFlag, int numFrames)
{
if (frame < (int)lag_log.size())
if (frame < (int)lagLog.size())
{
// insert
lag_log.insert(lag_log.begin() + frame, frames, (lagFlag) ? LAGGED_YES : LAGGED_NO);
lagLog.insert(lagLog.begin() + frame, numFrames, (lagFlag) ? LAGGED_YES : LAGGED_NO);
} else
{
// append
lag_log.resize(frame + 1, LAGGED_DONTKNOW);
lagLog.resize(frame + 1, LAGGED_UNKNOWN);
if (lagFlag)
lag_log[frame] = LAGGED_YES;
lagLog[frame] = LAGGED_YES;
else
lag_log[frame] = LAGGED_NO;
lagLog[frame] = LAGGED_NO;
}
already_compressed = false;
alreadyCompressed = false;
}
// getters
int LAGLOG::GetSize()
int LAGLOG::getSize()
{
return lag_log.size();
return lagLog.size();
}
int LAGLOG::GetLagInfoAtFrame(int frame)
int LAGLOG::getLagInfoAtFrame(int frame)
{
if (frame < (int)lag_log.size())
return lag_log[frame];
if (frame < (int)lagLog.size())
return lagLog[frame];
else
return LAGGED_DONTKNOW;
return LAGGED_UNKNOWN;
}
int LAGLOG::findFirstChange(LAGLOG& their_log)
int LAGLOG::findFirstChange(LAGLOG& theirLog)
{
// search for differences to the end of this or their LagLog, whichever is less
int end = lag_log.size() - 1;
int their_log_end = their_log.GetSize() - 1;
int end = lagLog.size() - 1;
int their_log_end = theirLog.getSize() - 1;
if (end > their_log_end)
end = their_log_end;
@ -196,8 +196,8 @@ int LAGLOG::findFirstChange(LAGLOG& their_log)
for (int i = 0; i <= end; ++i)
{
// if old info != new info and both infos are known
my_lag_info = lag_log[i];
their_lag_info = their_log.GetLagInfoAtFrame(i);
my_lag_info = lagLog[i];
their_lag_info = theirLog.getLagInfoAtFrame(i);
if ((my_lag_info == LAGGED_YES && their_lag_info == LAGGED_NO) || (my_lag_info == LAGGED_NO && their_lag_info == LAGGED_YES))
return i;
}

View File

@ -1,8 +1,11 @@
// Specification file for LagLog class
#define LAGGED_NO 0
#define LAGGED_YES 1
#define LAGGED_DONTKNOW 2
enum LAG_FLAG_VALUES
{
LAGGED_NO = 0,
LAGGED_YES = 1,
LAGGED_UNKNOWN = 2
};
class LAGLOG
{
@ -10,30 +13,30 @@ public:
LAGLOG();
void reset();
void compress_data();
bool Get_already_compressed();
void Reset_already_compressed();
void compressData();
bool isAlreadyCompressed();
void resetCompressedStatus();
void save(EMUFILE *os);
bool load(EMUFILE *is);
bool skipLoad(EMUFILE *is);
void InvalidateFrom(int frame);
void invalidateFromFrame(int frame);
void SetLagInfo(int frame, bool lagFlag);
void EraseFrame(int frame, int frames = 1);
void InsertFrame(int frame, bool lagFlag, int frames = 1);
void setLagInfo(int frame, bool lagFlag);
void eraseFrame(int frame, int numFrames = 1);
void insertFrame(int frame, bool lagFlag, int numFrames = 1);
int GetSize();
int GetLagInfoAtFrame(int frame);
int getSize();
int getLagInfoAtFrame(int frame);
int findFirstChange(LAGLOG& their_log);
int findFirstChange(LAGLOG& theirLog);
private:
// saved data
std::vector<uint8> lag_log_compressed;
std::vector<uint8> compressedLagLog;
// not saved data
std::vector<uint8> lag_log;
bool already_compressed; // to compress only once
std::vector<uint8> lagLog;
bool alreadyCompressed; // to compress only once
};

View File

@ -21,20 +21,20 @@ Markers - Snapshot of Markers state
MARKERS::MARKERS()
{
already_compressed = false;
alreadyCompressed = false;
}
void MARKERS::save(EMUFILE *os)
{
// write size
int size = markers_array.size();
int size = markersArray.size();
int len;
write32le(size, os);
// write array
if (!already_compressed)
compress_data();
write32le(markers_array_compressed.size(), os);
os->fwrite(&markers_array_compressed[0], markers_array_compressed.size());
if (!alreadyCompressed)
compressData();
write32le(compressedMarkersArray.size(), os);
os->fwrite(&compressedMarkersArray[0], compressedMarkersArray.size());
// write notes
size = notes.size();
write32le(size, os);
@ -52,16 +52,16 @@ bool MARKERS::load(EMUFILE *is)
int size;
if (read32le(&size, is))
{
markers_array.resize(size);
markersArray.resize(size);
// read and uncompress array
already_compressed = true;
alreadyCompressed = true;
int comprlen, len;
uLongf destlen = size * sizeof(int);
if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true;
markers_array_compressed.resize(comprlen);
if (is->fread(&markers_array_compressed[0], comprlen) != comprlen) return true;
int e = uncompress((uint8*)&markers_array[0], &destlen, &markers_array_compressed[0], comprlen);
compressedMarkersArray.resize(comprlen);
if (is->fread(&compressedMarkersArray[0], comprlen) != comprlen) return true;
int e = uncompress((uint8*)&markersArray[0], &destlen, &compressedMarkersArray[0], comprlen);
if (e != Z_OK && e != Z_BUF_ERROR) return true;
// read notes
if (read32le(&size, is) && size >= 0)
@ -103,21 +103,21 @@ bool MARKERS::skipLoad(EMUFILE *is)
return true;
}
void MARKERS::compress_data()
void MARKERS::compressData()
{
int len = markers_array.size() * sizeof(int);
int len = markersArray.size() * sizeof(int);
uLongf comprlen = (len>>9)+12 + len;
markers_array_compressed.resize(comprlen);
compress(&markers_array_compressed[0], &comprlen, (uint8*)&markers_array[0], len);
markers_array_compressed.resize(comprlen);
already_compressed = true;
compressedMarkersArray.resize(comprlen);
compress(&compressedMarkersArray[0], &comprlen, (uint8*)&markersArray[0], len);
compressedMarkersArray.resize(comprlen);
alreadyCompressed = true;
}
bool MARKERS::Get_already_compressed()
bool MARKERS::isAalreadyCompressed()
{
return already_compressed;
return alreadyCompressed;
}
void MARKERS::Reset_already_compressed()
void MARKERS::resetCompressedStatus()
{
already_compressed = false;
alreadyCompressed = false;
}

View File

@ -11,18 +11,18 @@ public:
bool load(EMUFILE *is);
bool skipLoad(EMUFILE *is);
void compress_data();
bool Get_already_compressed();
void Reset_already_compressed();
void compressData();
bool isAalreadyCompressed();
void resetCompressedStatus();
// saved data
std::vector<std::string> notes; // Format: 0th - note for intro (Marker 0), 1st - note for Marker1, 2nd - note for Marker2, ...
// not saved data
std::vector<int> markers_array; // Format: 0th = Marker num (id) for frame 0, 1st = Marker num for frame 1, ...
std::vector<int> markersArray; // Format: 0th = Marker number (id) for frame 0, 1st = Marker number for frame 1, ...
private:
// also saved data
std::vector<uint8> markers_array_compressed;
std::vector<uint8> compressedMarkersArray;
bool already_compressed; // to compress only once
bool alreadyCompressed; // to compress only once
};

View File

@ -26,8 +26,8 @@ Markers_manager - Manager of Markers
#pragma comment(lib, "Shlwapi.lib")
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern PLAYBACK playback;
extern SELECTION selection;
extern HISTORY history;
@ -39,7 +39,7 @@ char keywordDelimiters[] = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
MARKERS_MANAGER::MARKERS_MANAGER()
{
memset(findnote_string, 0, MAX_NOTE_LEN);
memset(findNoteString, 0, MAX_NOTE_LEN);
}
void MARKERS_MANAGER::init()
@ -48,14 +48,14 @@ void MARKERS_MANAGER::init()
}
void MARKERS_MANAGER::free()
{
markers.markers_array.resize(0);
markers.markersArray.resize(0);
markers.notes.resize(0);
}
void MARKERS_MANAGER::reset()
{
free();
marker_note_edit = MARKER_NOTE_EDIT_NONE;
search_similar_marker = 0;
markerNoteEditMode = MARKER_NOTE_EDIT_NONE;
currentIterationOfFindSimilar = 0;
markers.notes.resize(1);
markers.notes[0] = "Power on";
update();
@ -63,8 +63,8 @@ void MARKERS_MANAGER::reset()
void MARKERS_MANAGER::update()
{
// the size of current markers_array must be no less then the size of Input
if ((int)markers.markers_array.size() < currMovieData.getNumRecords())
markers.markers_array.resize(currMovieData.getNumRecords());
if ((int)markers.markersArray.size() < currMovieData.getNumRecords())
markers.markersArray.resize(currMovieData.getNumRecords());
}
void MARKERS_MANAGER::save(EMUFILE *os, bool really_save)
@ -73,7 +73,7 @@ void MARKERS_MANAGER::save(EMUFILE *os, bool really_save)
{
// write "MARKERS" string
os->fwrite(markers_save_id, MARKERS_ID_LEN);
markers.Reset_already_compressed(); // must recompress data, because most likely it has changed since last compression
markers.resetCompressedStatus(); // must recompress data, because most likely it has changed since last compression
markers.save(os);
} else
{
@ -112,149 +112,149 @@ error:
return true;
}
// -----------------------------------------------------------------------------------------
int MARKERS_MANAGER::GetMarkersSize()
int MARKERS_MANAGER::getMarkersArraySize()
{
return markers.markers_array.size();
return markers.markersArray.size();
}
bool MARKERS_MANAGER::SetMarkersSize(int new_size)
bool MARKERS_MANAGER::setMarkersArraySize(int newSize)
{
// if we are truncating, clear Markers that are gonna be erased (so that obsolete notes will be erased too)
bool markers_changed = false;
for (int i = markers.markers_array.size() - 1; i >= new_size; i--)
for (int i = markers.markersArray.size() - 1; i >= newSize; i--)
{
if (markers.markers_array[i])
if (markers.markersArray[i])
{
ClearMarker(i);
removeMarkerFromFrame(i);
markers_changed = true;
}
}
markers.markers_array.resize(new_size);
markers.markersArray.resize(newSize);
return markers_changed;
}
int MARKERS_MANAGER::GetMarker(int frame)
int MARKERS_MANAGER::getMarkerAtFrame(int frame)
{
if (frame >= 0 && frame < (int)markers.markers_array.size())
return markers.markers_array[frame];
if (frame >= 0 && frame < (int)markers.markersArray.size())
return markers.markersArray[frame];
else
return 0;
}
// finds and returns # of Marker starting from start_frame and searching up
int MARKERS_MANAGER::GetMarkerUp(int start_frame)
int MARKERS_MANAGER::getMarkerAboveFrame(int startFrame)
{
if (start_frame >= (int)markers.markers_array.size())
start_frame = markers.markers_array.size() - 1;
for (; start_frame >= 0; start_frame--)
if (markers.markers_array[start_frame]) return markers.markers_array[start_frame];
if (startFrame >= (int)markers.markersArray.size())
startFrame = markers.markersArray.size() - 1;
for (; startFrame >= 0; startFrame--)
if (markers.markersArray[startFrame]) return markers.markersArray[startFrame];
return 0;
}
// special version of the function
int MARKERS_MANAGER::GetMarkerUp(MARKERS& target_markers, int start_frame)
int MARKERS_MANAGER::getMarkerAboveFrame(MARKERS& targetMarkers, int startFrame)
{
if (start_frame >= (int)target_markers.markers_array.size())
start_frame = target_markers.markers_array.size() - 1;
for (; start_frame >= 0; start_frame--)
if (target_markers.markers_array[start_frame]) return target_markers.markers_array[start_frame];
if (startFrame >= (int)targetMarkers.markersArray.size())
startFrame = targetMarkers.markersArray.size() - 1;
for (; startFrame >= 0; startFrame--)
if (targetMarkers.markersArray[startFrame]) return targetMarkers.markersArray[startFrame];
return 0;
}
// finds frame where the Marker is set
int MARKERS_MANAGER::GetMarkerFrame(int marker_id)
int MARKERS_MANAGER::getMarkerFrameNumber(int marker_id)
{
for (int i = markers.markers_array.size() - 1; i >= 0; i--)
if (markers.markers_array[i] == marker_id) return i;
for (int i = markers.markersArray.size() - 1; i >= 0; i--)
if (markers.markersArray[i] == marker_id) return i;
// didn't find
return -1;
}
// returns number of new Marker
int MARKERS_MANAGER::SetMarker(int frame)
int MARKERS_MANAGER::setMarkerAtFrame(int frame)
{
if (frame < 0)
return 0;
else if (frame >= (int)markers.markers_array.size())
markers.markers_array.resize(frame + 1);
else if (markers.markers_array[frame])
return markers.markers_array[frame];
else if (frame >= (int)markers.markersArray.size())
markers.markersArray.resize(frame + 1);
else if (markers.markersArray[frame])
return markers.markersArray[frame];
int marker_num = GetMarkerUp(frame) + 1;
markers.markers_array[frame] = marker_num;
if (taseditor_config.empty_marker_notes)
int marker_num = getMarkerAboveFrame(frame) + 1;
markers.markersArray[frame] = marker_num;
if (taseditorConfig.emptyNewMarkerNotes)
markers.notes.insert(markers.notes.begin() + marker_num, 1, "");
else
// copy previous Marker note
markers.notes.insert(markers.notes.begin() + marker_num, 1, markers.notes[marker_num - 1]);
// increase following Markers' ids
int size = markers.markers_array.size();
int size = markers.markersArray.size();
for (frame++; frame < size; ++frame)
if (markers.markers_array[frame])
markers.markers_array[frame]++;
if (markers.markersArray[frame])
markers.markersArray[frame]++;
return marker_num;
}
void MARKERS_MANAGER::ClearMarker(int frame)
void MARKERS_MANAGER::removeMarkerFromFrame(int frame)
{
if (markers.markers_array[frame])
if (markers.markersArray[frame])
{
// erase corresponding note
markers.notes.erase(markers.notes.begin() + markers.markers_array[frame]);
markers.notes.erase(markers.notes.begin() + markers.markersArray[frame]);
// clear Marker
markers.markers_array[frame] = 0;
markers.markersArray[frame] = 0;
// decrease following Markers' ids
int size = markers.markers_array.size();
int size = markers.markersArray.size();
for (frame++; frame < size; ++frame)
if (markers.markers_array[frame])
markers.markers_array[frame]--;
if (markers.markersArray[frame])
markers.markersArray[frame]--;
}
}
void MARKERS_MANAGER::ToggleMarker(int frame)
void MARKERS_MANAGER::toggleMarkerAtFrame(int frame)
{
if (frame >= 0 && frame < (int)markers.markers_array.size())
if (frame >= 0 && frame < (int)markers.markersArray.size())
{
if (markers.markers_array[frame])
ClearMarker(frame);
if (markers.markersArray[frame])
removeMarkerFromFrame(frame);
else
SetMarker(frame);
setMarkerAtFrame(frame);
}
}
bool MARKERS_MANAGER::EraseMarker(int frame, int frames)
bool MARKERS_MANAGER::eraseMarker(int frame, int numFrames)
{
bool markers_changed = false;
if (frame < (int)markers.markers_array.size())
if (frame < (int)markers.markersArray.size())
{
if (frames == 1)
if (numFrames == 1)
{
// erase 1 frame
// if there's a Marker, first clear it
if (markers.markers_array[frame])
if (markers.markersArray[frame])
{
ClearMarker(frame);
removeMarkerFromFrame(frame);
markers_changed = true;
}
// erase 1 frame
markers.markers_array.erase(markers.markers_array.begin() + frame);
markers.markersArray.erase(markers.markersArray.begin() + frame);
} else
{
// erase many frames
if (frame + frames > (int)markers.markers_array.size())
frames = (int)markers.markers_array.size() - frame;
if (frame + numFrames > (int)markers.markersArray.size())
numFrames = (int)markers.markersArray.size() - frame;
// if there are Markers at those frames, first clear them
for (int i = frame; i < (frame + frames); ++i)
for (int i = frame; i < (frame + numFrames); ++i)
{
if (markers.markers_array[i])
if (markers.markersArray[i])
{
ClearMarker(i);
removeMarkerFromFrame(i);
markers_changed = true;
}
}
// erase frames
markers.markers_array.erase(markers.markers_array.begin() + frame, markers.markers_array.begin() + (frame + frames));
markers.markersArray.erase(markers.markersArray.begin() + frame, markers.markersArray.begin() + (frame + numFrames));
}
// check if there were some Markers after this frame
// since these Markers were shifted, markers_changed should be set to true
if (!markers_changed)
{
for (int i = markers.markers_array.size() - 1; i >= frame; i--)
for (int i = markers.markersArray.size() - 1; i >= frame; i--)
{
if (markers.markers_array[i])
if (markers.markersArray[i])
{
markers_changed = true; // Markers moved
break;
@ -264,35 +264,35 @@ bool MARKERS_MANAGER::EraseMarker(int frame, int frames)
}
return markers_changed;
}
bool MARKERS_MANAGER::insertEmpty(int at, int frames)
bool MARKERS_MANAGER::insertEmpty(int at, int numFrames)
{
if (at == -1)
{
// append blank frames
markers.markers_array.resize(markers.markers_array.size() + frames);
markers.markersArray.resize(markers.markersArray.size() + numFrames);
return false;
} else
{
bool markers_changed = false;
// first check if there are Markers after the frame
for (int i = markers.markers_array.size() - 1; i >= at; i--)
for (int i = markers.markersArray.size() - 1; i >= at; i--)
{
if (markers.markers_array[i])
if (markers.markersArray[i])
{
markers_changed = true; // Markers moved
break;
}
}
markers.markers_array.insert(markers.markers_array.begin() + at, frames, 0);
markers.markersArray.insert(markers.markersArray.begin() + at, numFrames, 0);
return markers_changed;
}
}
int MARKERS_MANAGER::GetNotesSize()
int MARKERS_MANAGER::getNotesSize()
{
return markers.notes.size();
}
std::string MARKERS_MANAGER::GetNote(int index)
std::string MARKERS_MANAGER::getNoteCopy(int index)
{
if (index >= 0 && index < (int)markers.notes.size())
return markers.notes[index];
@ -300,62 +300,62 @@ std::string MARKERS_MANAGER::GetNote(int index)
return markers.notes[0];
}
// special version of the function
std::string MARKERS_MANAGER::GetNote(MARKERS& target_markers, int index)
std::string MARKERS_MANAGER::getNoteCopy(MARKERS& targetMarkers, int index)
{
if (index >= 0 && index < (int)target_markers.notes.size())
return target_markers.notes[index];
if (index >= 0 && index < (int)targetMarkers.notes.size())
return targetMarkers.notes[index];
else
return target_markers.notes[0];
return targetMarkers.notes[0];
}
void MARKERS_MANAGER::SetNote(int index, const char* new_text)
void MARKERS_MANAGER::setNote(int index, const char* newText)
{
if (index >= 0 && index < (int)markers.notes.size())
markers.notes[index] = new_text;
markers.notes[index] = newText;
}
// ---------------------------------------------------------------------------------------
void MARKERS_MANAGER::MakeCopyTo(MARKERS& destination)
void MARKERS_MANAGER::makeCopyOfCurrentMarkersTo(MARKERS& destination)
{
destination.markers_array = markers.markers_array;
destination.markersArray = markers.markersArray;
destination.notes = markers.notes;
destination.Reset_already_compressed();
destination.resetCompressedStatus();
}
void MARKERS_MANAGER::RestoreFromCopy(MARKERS& source)
void MARKERS_MANAGER::restoreMarkersFromCopy(MARKERS& source)
{
markers.markers_array = source.markers_array;
markers.markersArray = source.markersArray;
markers.notes = source.notes;
}
// return true only when difference is found before end frame (not including end frame)
bool MARKERS_MANAGER::checkMarkersDiff(MARKERS& their_markers)
bool MARKERS_MANAGER::checkMarkersDiff(MARKERS& theirMarkers)
{
int end_my = GetMarkersSize() - 1;
int end_their = their_markers.markers_array.size() - 1;
int end_my = getMarkersArraySize() - 1;
int end_their = theirMarkers.markersArray.size() - 1;
int min_end = end_my;
int i;
// 1 - check if there are any Markers after min_end
if (end_my < end_their)
{
for (i = end_their; i > min_end; i--)
if (their_markers.markers_array[i])
if (theirMarkers.markersArray[i])
return true;
} else if (end_my > end_their)
{
min_end = end_their;
for (i = end_my; i > min_end; i--)
if (markers.markers_array[i])
if (markers.markersArray[i])
return true;
}
// 2 - check if there's any difference before min_end
for (i = min_end; i >= 0; i--)
{
if (markers.markers_array[i] != their_markers.markers_array[i])
if (markers.markersArray[i] != theirMarkers.markersArray[i])
return true;
else if (markers.markers_array[i] && // not empty
markers.notes[markers.markers_array[i]].compare(their_markers.notes[their_markers.markers_array[i]])) // notes differ
else if (markers.markersArray[i] && // not empty
markers.notes[markers.markersArray[i]].compare(theirMarkers.notes[theirMarkers.markersArray[i]])) // notes differ
return true;
}
// 3 - check if there's difference between 0th Notes
if (markers.notes[0].compare(their_markers.notes[0]))
if (markers.notes[0].compare(theirMarkers.notes[0]))
return true;
// no difference found
return false;
@ -367,28 +367,28 @@ bool ordering(const std::pair<int, double>& d1, const std::pair<int, double>& d2
return d1.second < d2.second;
}
void MARKERS_MANAGER::FindSimilar()
void MARKERS_MANAGER::findSimilarNote()
{
search_similar_marker = 0;
FindNextSimilar();
currentIterationOfFindSimilar = 0;
findNextSimilarNote();
}
void MARKERS_MANAGER::FindNextSimilar()
void MARKERS_MANAGER::findNextSimilarNote()
{
int i, t;
int sourceMarker = playback.shown_marker;
int sourceMarker = playback.displayedMarkerNumber;
char sourceNote[MAX_NOTE_LEN];
strcpy(sourceNote, GetNote(sourceMarker).c_str());
strcpy(sourceNote, getNoteCopy(sourceMarker).c_str());
// check if playback_marker_text is empty
if (!sourceNote[0])
{
MessageBox(taseditor_window.hwndTasEditor, "Marker Note under Playback cursor is empty!", "Find Similar Note", MB_OK);
MessageBox(taseditorWindow.hwndTASEditor, "Marker Note under Playback cursor is empty!", "Find Similar Note", MB_OK);
return;
}
// check if there's at least one note (not counting zeroth note)
if (markers.notes.size() <= 0)
{
MessageBox(taseditor_window.hwndTasEditor, "This project doesn't have any Markers!", "Find Similar Note", MB_OK);
MessageBox(taseditorWindow.hwndTASEditor, "This project doesn't have any Markers!", "Find Similar Note", MB_OK);
return;
}
@ -427,7 +427,7 @@ void MARKERS_MANAGER::FindNextSimilar()
if (!totalSourceKeywords)
{
MessageBox(taseditor_window.hwndTasEditor, "Marker Note under Playback cursor doesn't have keywords!", "Find Similar Note", MB_OK);
MessageBox(taseditorWindow.hwndTASEditor, "Marker Note under Playback cursor doesn't have keywords!", "Find Similar Note", MB_OK);
return;
}
@ -561,83 +561,83 @@ void MARKERS_MANAGER::FindNextSimilar()
*/
// Send Selection to the Marker found
int index = notePriority.size()-1 - search_similar_marker;
int index = notePriority.size()-1 - currentIterationOfFindSimilar;
if (index >= 0 && notePriority[index].second >= MIN_PRIORITY_TRESHOLD)
{
int marker_id = notePriority[index].first;
int frame = GetMarkerFrame(marker_id);
int frame = getMarkerFrameNumber(marker_id);
if (frame >= 0)
selection.JumpToFrame(frame);
selection.jumpToFrame(frame);
} else
{
if (search_similar_marker)
MessageBox(taseditor_window.hwndTasEditor, "Could not find more Notes similar to Marker Note under Playback cursor!", "Find Similar Note", MB_OK);
if (currentIterationOfFindSimilar)
MessageBox(taseditorWindow.hwndTASEditor, "Could not find more Notes similar to Marker Note under Playback cursor!", "Find Similar Note", MB_OK);
else
MessageBox(taseditor_window.hwndTasEditor, "Could not find anything similar to Marker Note under Playback cursor!", "Find Similar Note", MB_OK);
MessageBox(taseditorWindow.hwndTASEditor, "Could not find anything similar to Marker Note under Playback cursor!", "Find Similar Note", MB_OK);
}
// increase search_similar_marker so that next time we'll find another note
search_similar_marker++;
// increase currentIterationOfFindSimilar so that next time we'll find another note
currentIterationOfFindSimilar++;
}
// ------------------------------------------------------------------------------------
void MARKERS_MANAGER::UpdateMarkerNote()
void MARKERS_MANAGER::updateEditedMarkerNote()
{
if (!marker_note_edit) return;
if (!markerNoteEditMode) return;
char new_text[MAX_NOTE_LEN];
if (marker_note_edit == MARKER_NOTE_EDIT_UPPER)
if (markerNoteEditMode == MARKER_NOTE_EDIT_UPPER)
{
int len = SendMessage(playback.hwndPlaybackMarkerEdit, WM_GETTEXT, MAX_NOTE_LEN, (LPARAM)new_text);
int len = SendMessage(playback.hwndPlaybackMarkerEditField, WM_GETTEXT, MAX_NOTE_LEN, (LPARAM)new_text);
new_text[len] = 0;
// check changes
if (strcmp(GetNote(playback.shown_marker).c_str(), new_text))
if (strcmp(getNoteCopy(playback.displayedMarkerNumber).c_str(), new_text))
{
SetNote(playback.shown_marker, new_text);
if (playback.shown_marker)
history.RegisterMarkersChange(MODTYPE_MARKER_RENAME, GetMarkerFrame(playback.shown_marker), -1, new_text);
setNote(playback.displayedMarkerNumber, new_text);
if (playback.displayedMarkerNumber)
history.registerMarkersChange(MODTYPE_MARKER_RENAME, getMarkerFrameNumber(playback.displayedMarkerNumber), -1, new_text);
else
// zeroth Marker - just assume it's set on frame 0
history.RegisterMarkersChange(MODTYPE_MARKER_RENAME, 0, -1, new_text);
history.registerMarkersChange(MODTYPE_MARKER_RENAME, 0, -1, new_text);
// notify Selection to change text in the lower Marker (in case both are showing same Marker)
selection.must_find_current_marker = true;
selection.mustFindCurrentMarker = true;
}
} else if (marker_note_edit == MARKER_NOTE_EDIT_LOWER)
} else if (markerNoteEditMode == MARKER_NOTE_EDIT_LOWER)
{
int len = SendMessage(selection.hwndSelectionMarkerEdit, WM_GETTEXT, MAX_NOTE_LEN, (LPARAM)new_text);
int len = SendMessage(selection.hwndSelectionMarkerEditField, WM_GETTEXT, MAX_NOTE_LEN, (LPARAM)new_text);
new_text[len] = 0;
// check changes
if (strcmp(GetNote(selection.shown_marker).c_str(), new_text))
if (strcmp(getNoteCopy(selection.displayedMarkerNumber).c_str(), new_text))
{
SetNote(selection.shown_marker, new_text);
if (selection.shown_marker)
history.RegisterMarkersChange(MODTYPE_MARKER_RENAME, GetMarkerFrame(selection.shown_marker), -1, new_text);
setNote(selection.displayedMarkerNumber, new_text);
if (selection.displayedMarkerNumber)
history.registerMarkersChange(MODTYPE_MARKER_RENAME, getMarkerFrameNumber(selection.displayedMarkerNumber), -1, new_text);
else
// zeroth Marker - just assume it's set on frame 0
history.RegisterMarkersChange(MODTYPE_MARKER_RENAME, 0, -1, new_text);
history.registerMarkersChange(MODTYPE_MARKER_RENAME, 0, -1, new_text);
// notify Playback to change text in upper Marker (in case both are showing same Marker)
playback.must_find_current_marker = true;
playback.mustFindCurrentMarker = true;
}
}
}
// ------------------------------------------------------------------------------------
BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK findNoteWndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
extern MARKERS_MANAGER markers_manager;
extern MARKERS_MANAGER markersManager;
switch (message)
{
case WM_INITDIALOG:
{
if (taseditor_config.findnote_wndx == -32000) taseditor_config.findnote_wndx = 0; //Just in case
if (taseditor_config.findnote_wndy == -32000) taseditor_config.findnote_wndy = 0;
SetWindowPos(hwndDlg, 0, taseditor_config.findnote_wndx, taseditor_config.findnote_wndy, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
if (taseditorConfig.findnoteWindowX == -32000) taseditorConfig.findnoteWindowX = 0; //Just in case
if (taseditorConfig.findnoteWindowY == -32000) taseditorConfig.findnoteWindowY = 0;
SetWindowPos(hwndDlg, 0, taseditorConfig.findnoteWindowX, taseditorConfig.findnoteWindowY, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
CheckDlgButton(hwndDlg, IDC_MATCH_CASE, taseditor_config.findnote_matchcase?MF_CHECKED : MF_UNCHECKED);
if (taseditor_config.findnote_search_up)
CheckDlgButton(hwndDlg, IDC_MATCH_CASE, taseditorConfig.findnoteMatchCase?MF_CHECKED : MF_UNCHECKED);
if (taseditorConfig.findnoteSearchUp)
Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_UP), BST_CHECKED);
else
Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_DOWN), BST_CHECKED);
HWND hwndEdit = GetDlgItem(hwndDlg, IDC_NOTE_TO_FIND);
SendMessage(hwndEdit, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
SetWindowText(hwndEdit, markers_manager.findnote_string);
SetWindowText(hwndEdit, markersManager.findNoteString);
if (GetDlgCtrlID((HWND)wParam) != IDC_NOTE_TO_FIND)
{
SetFocus(hwndEdit);
@ -651,9 +651,9 @@ BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
{
RECT wrect;
GetWindowRect(hwndDlg, &wrect);
taseditor_config.findnote_wndx = wrect.left;
taseditor_config.findnote_wndy = wrect.top;
WindowBoundsCheckNoResize(taseditor_config.findnote_wndx, taseditor_config.findnote_wndy, wrect.right);
taseditorConfig.findnoteWindowX = wrect.left;
taseditorConfig.findnoteWindowY = wrect.top;
WindowBoundsCheckNoResize(taseditorConfig.findnoteWindowX, taseditorConfig.findnoteWindowY, wrect.right);
}
break;
}
@ -673,35 +673,35 @@ BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
break;
}
case IDC_RADIO_UP:
taseditor_config.findnote_search_up = true;
taseditorConfig.findnoteSearchUp = true;
break;
case IDC_RADIO_DOWN:
taseditor_config.findnote_search_up = false;
taseditorConfig.findnoteSearchUp = false;
break;
case IDC_MATCH_CASE:
taseditor_config.findnote_matchcase ^= 1;
CheckDlgButton(hwndDlg, IDC_MATCH_CASE, taseditor_config.findnote_matchcase?MF_CHECKED : MF_UNCHECKED);
taseditorConfig.findnoteMatchCase ^= 1;
CheckDlgButton(hwndDlg, IDC_MATCH_CASE, taseditorConfig.findnoteMatchCase?MF_CHECKED : MF_UNCHECKED);
break;
case IDOK:
{
int len = SendMessage(GetDlgItem(hwndDlg, IDC_NOTE_TO_FIND), WM_GETTEXT, MAX_NOTE_LEN, (LPARAM)markers_manager.findnote_string);
markers_manager.findnote_string[len] = 0;
int len = SendMessage(GetDlgItem(hwndDlg, IDC_NOTE_TO_FIND), WM_GETTEXT, MAX_NOTE_LEN, (LPARAM)markersManager.findNoteString);
markersManager.findNoteString[len] = 0;
// scan frames from current Selection to the border
int cur_marker = 0;
bool result;
int movie_size = currMovieData.getNumRecords();
int current_frame = selection.GetCurrentSelectionBeginning();
if (current_frame < 0 && taseditor_config.findnote_search_up)
int current_frame = selection.getCurrentRowsSelectionBeginning();
if (current_frame < 0 && taseditorConfig.findnoteSearchUp)
current_frame = movie_size;
while (true)
{
// move forward
if (taseditor_config.findnote_search_up)
if (taseditorConfig.findnoteSearchUp)
{
current_frame--;
if (current_frame < 0)
{
MessageBox(taseditor_window.hwndFindNote, "Nothing was found.", "Find Note", MB_OK);
MessageBox(taseditorWindow.hwndFindNote, "Nothing was found.", "Find Note", MB_OK);
break;
}
} else
@ -709,22 +709,22 @@ BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
current_frame++;
if (current_frame >= movie_size)
{
MessageBox(taseditor_window.hwndFindNote, "Nothing was found!", "Find Note", MB_OK);
MessageBox(taseditorWindow.hwndFindNote, "Nothing was found!", "Find Note", MB_OK);
break;
}
}
// scan marked frames
cur_marker = markers_manager.GetMarker(current_frame);
cur_marker = markersManager.getMarkerAtFrame(current_frame);
if (cur_marker)
{
if (taseditor_config.findnote_matchcase)
result = (strstr(markers_manager.GetNote(cur_marker).c_str(), markers_manager.findnote_string) != 0);
if (taseditorConfig.findnoteMatchCase)
result = (strstr(markersManager.getNoteCopy(cur_marker).c_str(), markersManager.findNoteString) != 0);
else
result = (StrStrI(markers_manager.GetNote(cur_marker).c_str(), markers_manager.findnote_string) != 0);
result = (StrStrI(markersManager.getNoteCopy(cur_marker).c_str(), markersManager.findNoteString) != 0);
if (result)
{
// found note containing searched string - jump there
selection.JumpToFrame(current_frame);
selection.jumpToFrame(current_frame);
break;
}
}
@ -732,8 +732,8 @@ BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case IDCANCEL:
DestroyWindow(taseditor_window.hwndFindNote);
taseditor_window.hwndFindNote = 0;
DestroyWindow(taseditorWindow.hwndFindNote);
taseditorWindow.hwndFindNote = 0;
return TRUE;
}
break;
@ -741,8 +741,8 @@ BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
case WM_CLOSE:
case WM_QUIT:
{
DestroyWindow(taseditor_window.hwndFindNote);
taseditor_window.hwndFindNote = 0;
DestroyWindow(taseditorWindow.hwndFindNote);
taseditorWindow.hwndFindNote = 0;
break;
}
}

View File

@ -15,7 +15,7 @@
#define KEYWORDS_LINE_MIN_SEQUENCE 1
#define MIN_PRIORITY_TRESHOLD 5.0
enum
enum MARKER_NOTE_EDIT_MODES
{
MARKER_NOTE_EDIT_NONE,
MARKER_NOTE_EDIT_UPPER,
@ -34,40 +34,40 @@ public:
void save(EMUFILE *os, bool really_save = true);
bool load(EMUFILE *is, unsigned int offset);
int GetMarkersSize();
bool SetMarkersSize(int new_size);
int getMarkersArraySize();
bool setMarkersArraySize(int newSize);
int GetMarker(int frame);
int GetMarkerUp(int start_frame);
int GetMarkerUp(MARKERS& target_markers, int start_frame); // special version of the function
int GetMarkerFrame(int marker_id);
int getMarkerAtFrame(int frame);
int getMarkerAboveFrame(int startFrame);
int getMarkerAboveFrame(MARKERS& targetMarkers, int startFrame); // special version of the function
int getMarkerFrameNumber(int markerID);
int SetMarker(int frame);
void ClearMarker(int frame);
void ToggleMarker(int frame);
int setMarkerAtFrame(int frame);
void removeMarkerFromFrame(int frame);
void toggleMarkerAtFrame(int frame);
bool EraseMarker(int frame, int frames = 1);
bool insertEmpty(int at, int frames);
bool eraseMarker(int frame, int numFrames = 1);
bool insertEmpty(int at, int numFrames);
int GetNotesSize();
std::string GetNote(int index);
std::string GetNote(MARKERS& target_markers, int index); // special version of the function
void SetNote(int index, const char* new_text);
int getNotesSize();
std::string getNoteCopy(int index);
std::string getNoteCopy(MARKERS& targetMarkers, int index); // special version of the function
void setNote(int index, const char* newText);
void MakeCopyTo(MARKERS& destination);
void RestoreFromCopy(MARKERS& source);
void makeCopyOfCurrentMarkersTo(MARKERS& destination);
void restoreMarkersFromCopy(MARKERS& source);
bool checkMarkersDiff(MARKERS& their_markers);
bool checkMarkersDiff(MARKERS& theirMarkers);
void FindSimilar();
void FindNextSimilar();
void findSimilarNote();
void findNextSimilarNote();
void UpdateMarkerNote();
void updateEditedMarkerNote();
// not saved vars
int marker_note_edit;
char findnote_string[MAX_NOTE_LEN];
int search_similar_marker;
int markerNoteEditMode;
char findNoteString[MAX_NOTE_LEN];
int currentIterationOfFindSimilar;
private:
// saved vars

File diff suppressed because it is too large Load Diff

View File

@ -28,9 +28,9 @@
#define DRAG_SCROLLING_BORDER_SIZE 10 // in pixels
#define DOUBLETAP_COUNT 3 // 1:quick press, 2 - quick release, 3 - quick press
#define DOUBLETAP_COUNT 3 // 3 actions: 1 = quick press, 2 = quick release, 3 = quick press
enum
enum PIANO_ROLL_COLUMNS
{
COLUMN_ICONS,
COLUMN_FRAMENUM,
@ -86,8 +86,7 @@ enum DRAG_MODES
// when there's too many button columns, there's need for 2nd Frame# column at the end
#define NUM_COLUMNS_NEED_2ND_FRAMENUM COLUMN_JOYPAD4_R
#define DIGITS_IN_FRAMENUM 7
#define DIGITS_IN_FRAMENUM 7 // should be enough for any TAS movie
#define BOOKMARKS_WITH_BLUE_ARROW 20
#define BOOKMARKS_WITH_GREEN_ARROW 40
#define BLUE_ARROW_IMAGE_ID 60
@ -156,90 +155,90 @@ public:
void free();
void reset();
void update();
void redraw();
void save(EMUFILE *os, bool really_save = true);
bool load(EMUFILE *is, unsigned int offset);
void RedrawList();
void RedrawRow(int index);
void RedrawHeader();
void redrawRow(int index);
void redrawHeader();
void UpdateItemCount();
bool CheckItemVisible(int frame);
void updateLinesCount();
bool isLineVisible(int frame);
void FollowPlayback();
void FollowPlaybackIfNeeded(bool follow_pauseframe = true);
void FollowPauseframe();
void FollowUndo();
void FollowSelection();
void FollowMarker(int marker_id);
void EnsureVisible(int row_index);
void followPlaybackCursor();
void followPlaybackCursorIfNeeded(bool followPauseframe = true);
void followPauseframe();
void followUndoHint();
void followSelection();
void followMarker(int markerID);
void ensureTheLineIsVisible(int rowIndex);
void ColumnSet(int column, bool alt_pressed);
void handleColumnSet(int column, bool altPressed);
void SetHeaderColumnLight(int column, int level);
void setLightInHeaderColumn(int column, int level);
void StartDraggingPlaybackCursor();
void StartDraggingMarker(int mouse_x, int mouse_y, int row_index, int column_index);
void StartSelectingDrag(int start_frame);
void StartDeselectingDrag(int start_frame);
void startDraggingPlaybackCursor();
void startDraggingMarker(int mouseX, int mouseY, int rowIndex, int columnIndex);
void startSelectingDrag(int startFrame);
void startDeselectingDrag(int startFrame);
void GetDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG CustomDraw(NMLVCUSTOMDRAW* msg);
LONG HeaderCustomDraw(NMLVCUSTOMDRAW* msg);
void getDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG handleCustomDraw(NMLVCUSTOMDRAW* msg);
LONG handleHeaderCustomDraw(NMLVCUSTOMDRAW* msg);
void RightClick(LVHITTESTINFO& info);
void handleRightClick(LVHITTESTINFO& info);
bool CheckIfTheresAnyIconAtFrame(int frame);
void CrossGaps(int zDelta);
bool checkIfTheresAnIconAtFrame(int frame);
void crossGaps(int zDelta);
int header_item_under_mouse;
int headerItemUnderMouse;
HWND hwndList, hwndHeader;
TRACKMOUSEEVENT tme;
int list_row_top, list_row_height, list_header_height;
int listTopMargin, listRowHeight, listHeaderHeight;
bool must_check_item_under_mouse;
int row_under_mouse, real_row_under_mouse, column_under_mouse;
bool mustCheckItemUnderMouse;
unsigned int drag_mode;
bool rbutton_drag_mode;
int marker_drag_box_dx, marker_drag_box_dy;
int marker_drag_box_x, marker_drag_box_y;
int marker_drag_countdown;
int marker_drag_framenum;
int drawing_last_x, drawing_last_y;
int drawing_start_time;
int drag_selection_starting_frame;
int drag_selection_ending_frame;
int rowUnderMouse, realRowUnderMouse, columnUnderMouse;
unsigned int dragMode;
bool rightButtonDragMode;
int markerDragBoxDX, markerDragBoxDY;
int markerDragBoxX, markerDragBoxY;
int markerDragCountdown;
int markerDragFrameNumber;
int drawingLastX, drawingLastY;
int drawingStartTimestamp;
int dragSelectionStartingFrame;
int dragSelectionEndingFrame;
bool shift_held, ctrl_held, alt_held;
int shift_timer, ctrl_timer;
int shift_count, ctrl_count;
bool shiftHeld, ctrlHeld, altHeld;
int shiftTimer, ctrlTimer;
int shiftActionsÑount, ctrlActionsÑount;
HWND hwndMarkerDragBox, hwndMarkerDragBoxText;
// GDI stuff
HFONT hMainListFont, hMainListSelectFont, hMarkersFont, hMarkersEditFont, hTaseditorAboutFont;
HBRUSH bg_brush, marker_drag_box_brush, marker_drag_box_brush_bind;
HBRUSH bgBrush, markerDragBoxBrushNormal, markerDragBoxBrushBind;
private:
void CenterListAt(int frame);
void centerListAroundLine(int rowIndex);
void DragPlaybackCursor();
void FinishDrag();
void handlePlaybackCursorDragging();
void finishDrag();
std::vector<uint8> header_colors;
int num_columns;
int next_header_update_time;
std::vector<uint8> headerColors;
int numColumns;
int nextHeaderUpdateTime;
bool must_redraw_list;
bool mustRedrawList;
HMENU hrmenu;
HMENU hrMenu;
// GDI stuff
HIMAGELIST himglist;
HIMAGELIST hImgList;
WNDCLASSEX wincl;
WNDCLASSEX winCl;
BLENDFUNCTION blend;
};

View File

@ -28,15 +28,15 @@ Playback - Player of emulation states
extern void ForceExecuteLuaFrameFunctions();
#endif
extern bool Taseditor_rewind_now;
extern bool mustRewindNow;
extern bool turbo;
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern SELECTION selection;
extern MARKERS_MANAGER markers_manager;
extern MARKERS_MANAGER markersManager;
extern GREENZONE greenzone;
extern PIANO_ROLL piano_roll;
extern PIANO_ROLL pianoRoll;
extern BOOKMARKS bookmarks;
extern void Update_RAM_Search();
@ -53,240 +53,240 @@ PLAYBACK::PLAYBACK()
void PLAYBACK::init()
{
hwndProgressbar = GetDlgItem(taseditor_window.hwndTasEditor, IDC_PROGRESS1);
hwndProgressbar = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PROGRESS1);
SendMessage(hwndProgressbar, PBM_SETRANGE, 0, MAKELPARAM(0, PROGRESSBAR_WIDTH));
hwndRewind = GetDlgItem(taseditor_window.hwndTasEditor, TASEDITOR_REWIND);
hwndForward = GetDlgItem(taseditor_window.hwndTasEditor, TASEDITOR_FORWARD);
hwndRewindFull = GetDlgItem(taseditor_window.hwndTasEditor, TASEDITOR_REWIND_FULL);
hwndForwardFull = GetDlgItem(taseditor_window.hwndTasEditor, TASEDITOR_FORWARD_FULL);
hwndPlaybackMarker = GetDlgItem(taseditor_window.hwndTasEditor, IDC_PLAYBACK_MARKER);
SendMessage(hwndPlaybackMarker, WM_SETFONT, (WPARAM)piano_roll.hMarkersFont, 0);
hwndPlaybackMarkerEdit = GetDlgItem(taseditor_window.hwndTasEditor, IDC_PLAYBACK_MARKER_EDIT);
SendMessage(hwndPlaybackMarkerEdit, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
SendMessage(hwndPlaybackMarkerEdit, WM_SETFONT, (WPARAM)piano_roll.hMarkersEditFont, 0);
hwndRewind = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_REWIND);
hwndForward = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_FORWARD);
hwndRewindFull = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_REWIND_FULL);
hwndForwardFull = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_FORWARD_FULL);
hwndPlaybackMarkerNumber = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PLAYBACK_MARKER);
SendMessage(hwndPlaybackMarkerNumber, WM_SETFONT, (WPARAM)pianoRoll.hMarkersFont, 0);
hwndPlaybackMarkerEditField = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PLAYBACK_MARKER_EDIT);
SendMessage(hwndPlaybackMarkerEditField, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
SendMessage(hwndPlaybackMarkerEditField, WM_SETFONT, (WPARAM)pianoRoll.hMarkersEditFont, 0);
// subclass the edit control
playbackMarkerEdit_oldWndproc = (WNDPROC)SetWindowLong(hwndPlaybackMarkerEdit, GWL_WNDPROC, (LONG)UpperMarkerEditWndProc);
playbackMarkerEdit_oldWndproc = (WNDPROC)SetWindowLong(hwndPlaybackMarkerEditField, GWL_WNDPROC, (LONG)UpperMarkerEditWndProc);
reset();
}
void PLAYBACK::reset()
{
must_autopause_at_the_end = true;
must_find_current_marker = true;
shown_marker = 0;
lastCursor = currFrameCounter;
lost_position_frame = pause_frame = old_pauseframe = 0;
lost_position_is_stable = old_show_pauseframe = show_pauseframe = false;
old_rewind_button_state = rewind_button_state = false;
old_forward_button_state = forward_button_state = false;
old_rewind_full_button_state = rewind_full_button_state = false;
old_forward_full_button_state = forward_full_button_state = false;
old_emu_paused = emu_paused = true;
SeekingStop();
mustAutopauseAtTheEnd = true;
mustFindCurrentMarker = true;
displayedMarkerNumber = 0;
lastCursorPos = currFrameCounter;
lastPositionFrame = pauseFrame = oldPauseFrame = 0;
lastPositionIsStable = oldStateOfShowPauseFrame = showPauseFrame = false;
rewindButtonOldState = rewindButtonState = false;
forwardButtonOldState = forwardButtonState = false;
rewindFullButtonOldState = rewindFullButtonState = false;
forwardFullButtonOldState = forwardFullButtonState = false;
emuPausedOldState = emuPausedState = true;
stopSeeking();
}
void PLAYBACK::update()
{
// controls:
// update < and > buttons
old_rewind_button_state = rewind_button_state;
rewind_button_state = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || Taseditor_rewind_now);
if (rewind_button_state)
rewindButtonOldState = rewindButtonState;
rewindButtonState = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || mustRewindNow);
if (rewindButtonState)
{
if (!old_rewind_button_state)
if (!rewindButtonOldState)
{
button_hold_time = clock();
RewindFrame();
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
buttonHoldTimer = clock();
handleRewindFrame();
} else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock())
{
RewindFrame();
handleRewindFrame();
}
}
old_forward_button_state = forward_button_state;
forward_button_state = (Button_GetState(hwndForward) & BST_PUSHED) != 0;
if (forward_button_state && !rewind_button_state)
forwardButtonOldState = forwardButtonState;
forwardButtonState = (Button_GetState(hwndForward) & BST_PUSHED) != 0;
if (forwardButtonState && !rewindButtonState)
{
if (!old_forward_button_state)
if (!forwardButtonOldState)
{
button_hold_time = clock();
ForwardFrame();
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
buttonHoldTimer = clock();
handleForwardFrame();
} else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock())
{
ForwardFrame();
handleForwardFrame();
}
}
// update << and >> buttons
old_rewind_full_button_state = rewind_full_button_state;
rewind_full_button_state = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0);
if (rewind_full_button_state && !rewind_button_state && !forward_button_state)
rewindFullButtonOldState = rewindFullButtonState;
rewindFullButtonState = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0);
if (rewindFullButtonState && !rewindButtonState && !forwardButtonState)
{
if (!old_rewind_full_button_state)
if (!rewindFullButtonOldState)
{
button_hold_time = clock();
RewindFull();
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
buttonHoldTimer = clock();
handleRewindFull();
} else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock())
{
RewindFull();
handleRewindFull();
}
}
old_forward_full_button_state = forward_full_button_state;
forward_full_button_state = (Button_GetState(hwndForwardFull) & BST_PUSHED) != 0;
if (forward_full_button_state && !rewind_button_state && !forward_button_state && !rewind_full_button_state)
forwardFullButtonOldState = forwardFullButtonState;
forwardFullButtonState = (Button_GetState(hwndForwardFull) & BST_PUSHED) != 0;
if (forwardFullButtonState && !rewindButtonState && !forwardButtonState && !rewindFullButtonState)
{
if (!old_forward_full_button_state)
if (!forwardFullButtonOldState)
{
button_hold_time = clock();
ForwardFull();
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
buttonHoldTimer = clock();
handleForwardFull();
} else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock())
{
ForwardFull();
handleForwardFull();
}
}
// update the Playback cursor
if (currFrameCounter != lastCursor)
if (currFrameCounter != lastCursorPos)
{
// update gfx of the old and new rows
piano_roll.RedrawRow(lastCursor);
bookmarks.RedrawChangedBookmarks(lastCursor);
piano_roll.RedrawRow(currFrameCounter);
bookmarks.RedrawChangedBookmarks(currFrameCounter);
lastCursor = currFrameCounter;
pianoRoll.redrawRow(lastCursorPos);
bookmarks.redrawChangedBookmarks(lastCursorPos);
pianoRoll.redrawRow(currFrameCounter);
bookmarks.redrawChangedBookmarks(currFrameCounter);
lastCursorPos = currFrameCounter;
// follow the Playback cursor, but in case of seeking don't follow it
piano_roll.FollowPlaybackIfNeeded(false);
pianoRoll.followPlaybackCursorIfNeeded(false);
// enforce redrawing now
UpdateWindow(piano_roll.hwndList);
UpdateWindow(pianoRoll.hwndList);
// lazy update of "Playback's Marker text"
int current_marker = markers_manager.GetMarkerUp(currFrameCounter);
if (shown_marker != current_marker)
int current_marker = markersManager.getMarkerAboveFrame(currFrameCounter);
if (displayedMarkerNumber != current_marker)
{
markers_manager.UpdateMarkerNote();
shown_marker = current_marker;
RedrawMarker();
must_find_current_marker = false;
markersManager.updateEditedMarkerNote();
displayedMarkerNumber = current_marker;
redrawMarkerData();
mustFindCurrentMarker = false;
}
}
// [non-lazy] update "Playback's Marker text" if needed
if (must_find_current_marker)
if (mustFindCurrentMarker)
{
markers_manager.UpdateMarkerNote();
shown_marker = markers_manager.GetMarkerUp(currFrameCounter);
RedrawMarker();
must_find_current_marker = false;
markersManager.updateEditedMarkerNote();
displayedMarkerNumber = markersManager.getMarkerAboveFrame(currFrameCounter);
redrawMarkerData();
mustFindCurrentMarker = false;
}
// pause when seeking hits pause_frame
if (pause_frame && currFrameCounter + 1 >= pause_frame)
SeekingStop();
else if (currFrameCounter >= GetLostPosition() && currFrameCounter >= currMovieData.getNumRecords() - 1 && must_autopause_at_the_end && taseditor_config.autopause_at_finish && !TaseditorIsRecording())
if (pauseFrame && currFrameCounter + 1 >= pauseFrame)
stopSeeking();
else if (currFrameCounter >= getLastPosition() && currFrameCounter >= currMovieData.getNumRecords() - 1 && mustAutopauseAtTheEnd && taseditorConfig.autopauseAtTheEndOfMovie && !isTaseditorRecording())
// pause at the end of the movie
PauseEmulation();
pauseEmulation();
// update flashing pauseframe
if (old_pauseframe != pause_frame && old_pauseframe)
if (oldPauseFrame != pauseFrame && oldPauseFrame)
{
// pause_frame was changed, clear old_pauseframe gfx
piano_roll.RedrawRow(old_pauseframe-1);
bookmarks.RedrawChangedBookmarks(old_pauseframe-1);
pianoRoll.redrawRow(oldPauseFrame-1);
bookmarks.redrawChangedBookmarks(oldPauseFrame-1);
}
old_pauseframe = pause_frame;
old_show_pauseframe = show_pauseframe;
if (pause_frame)
oldPauseFrame = pauseFrame;
oldStateOfShowPauseFrame = showPauseFrame;
if (pauseFrame)
{
if (emu_paused)
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_PAUSED) & 1;
if (emuPausedState)
showPauseFrame = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_PAUSED) & 1;
else
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_SEEKING) & 1;
} else show_pauseframe = false;
if (old_show_pauseframe != show_pauseframe)
showPauseFrame = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_SEEKING) & 1;
} else showPauseFrame = false;
if (oldStateOfShowPauseFrame != showPauseFrame)
{
// update pauseframe gfx
piano_roll.RedrawRow(pause_frame - 1);
bookmarks.RedrawChangedBookmarks(pause_frame - 1);
pianoRoll.redrawRow(pauseFrame - 1);
bookmarks.redrawChangedBookmarks(pauseFrame - 1);
}
// update seeking progressbar
old_emu_paused = emu_paused;
emu_paused = (FCEUI_EmulationPaused() != 0);
if (pause_frame)
emuPausedOldState = emuPausedState;
emuPausedState = (FCEUI_EmulationPaused() != 0);
if (pauseFrame)
{
if (old_show_pauseframe != show_pauseframe) // update progressbar from time to time
if (oldStateOfShowPauseFrame != showPauseFrame) // update progressbar from time to time
// display seeking progress
SetProgressbar(currFrameCounter - seeking_start_frame, pause_frame - seeking_start_frame);
} else if (old_emu_paused != emu_paused)
setProgressbar(currFrameCounter - seekingBeginningFrame, pauseFrame - seekingBeginningFrame);
} else if (emuPausedOldState != emuPausedState)
{
// emulator got paused/unpaused externally
if (old_emu_paused && !emu_paused)
if (emuPausedOldState && !emuPausedState)
{
// externally unpaused - show empty progressbar
SetProgressbar(0, 1);
setProgressbar(0, 1);
} else
{
// externally paused - progressbar should be full
SetProgressbar(1, 1);
setProgressbar(1, 1);
}
}
// prepare to stop at the end of the movie in case user unpauses emulator
if (emu_paused)
if (emuPausedState)
{
if (currFrameCounter < currMovieData.getNumRecords() - 1)
must_autopause_at_the_end = true;
mustAutopauseAtTheEnd = true;
else
must_autopause_at_the_end = false;
mustAutopauseAtTheEnd = false;
}
// this little statement is very important for adequate work of the "green arrow" and "Restore last position"
if (!emu_paused)
if (!emuPausedState)
// when emulating, lost_position_frame becomes unstable (which means that it's probably not equal to the end of current segment anymore)
lost_position_is_stable = false;
lastPositionIsStable = false;
}
// called after saving the project, because saving uses the progressbar for itself
void PLAYBACK::UpdateProgressbar()
void PLAYBACK::updateProgressbar()
{
if (pause_frame)
if (pauseFrame)
{
SetProgressbar(currFrameCounter - seeking_start_frame, pause_frame - seeking_start_frame);
setProgressbar(currFrameCounter - seekingBeginningFrame, pauseFrame - seekingBeginningFrame);
} else
{
if (emu_paused)
if (emuPausedState)
// full progressbar
SetProgressbar(1, 1);
setProgressbar(1, 1);
else
// cleared progressbar
SetProgressbar(0, 1);
setProgressbar(0, 1);
}
RedrawWindow(hwndProgressbar, NULL, NULL, RDW_INVALIDATE);
}
void PLAYBACK::ToggleEmulationPause()
void PLAYBACK::toggleEmulationPause()
{
if (FCEUI_EmulationPaused())
UnpauseEmulation();
unpauseEmulation();
else
PauseEmulation();
pauseEmulation();
}
void PLAYBACK::PauseEmulation()
void PLAYBACK::pauseEmulation()
{
FCEUI_SetEmulationPaused(EMULATIONPAUSED_PAUSED);
}
void PLAYBACK::UnpauseEmulation()
void PLAYBACK::unpauseEmulation()
{
FCEUI_SetEmulationPaused(0);
}
void PLAYBACK::RestorePosition()
void PLAYBACK::restoreLastPosition()
{
if (GetLostPosition() > currFrameCounter)
if (getLastPosition() > currFrameCounter)
{
if (emu_paused)
SeekingStart(GetLostPosition());
if (emuPausedState)
startSeekingToFrame(getLastPosition());
else
PauseEmulation();
pauseEmulation();
}
}
void PLAYBACK::MiddleButtonClick()
void PLAYBACK::handleMiddleButtonClick()
{
if (emu_paused)
if (emuPausedState)
{
// Unpause or start seeking
// works only when right mouse button is released
@ -295,87 +295,87 @@ void PLAYBACK::MiddleButtonClick()
if (GetAsyncKeyState(VK_SHIFT) < 0)
{
// if Shift is held, seek to nearest Marker
int last_frame = markers_manager.GetMarkersSize() - 1; // the end of movie Markers
int last_frame = markersManager.getMarkersArraySize() - 1; // the end of movie Markers
int target_frame = currFrameCounter + 1;
for (; target_frame <= last_frame; ++target_frame)
if (markers_manager.GetMarker(target_frame)) break;
if (markersManager.getMarkerAtFrame(target_frame)) break;
if (target_frame <= last_frame)
SeekingStart(target_frame);
startSeekingToFrame(target_frame);
} else if (GetAsyncKeyState(VK_CONTROL) < 0)
{
// if Ctrl is held, seek to Selection cursor or replay from Selection cursor
int selection_beginning = selection.GetCurrentSelectionBeginning();
int selection_beginning = selection.getCurrentRowsSelectionBeginning();
if (selection_beginning > currFrameCounter)
{
SeekingStart(selection_beginning);
startSeekingToFrame(selection_beginning);
} else if (selection_beginning < currFrameCounter)
{
int saved_currFrameCounter = currFrameCounter;
if (selection_beginning < 0)
selection_beginning = 0;
jump(selection_beginning);
SeekingStart(saved_currFrameCounter);
startSeekingToFrame(saved_currFrameCounter);
}
} else if (GetPauseFrame() < 0 && GetLostPosition() >= greenzone.GetSize())
} else if (getPauseFrame() < 0 && getLastPosition() >= greenzone.getSize())
{
RestorePosition();
restoreLastPosition();
} else
{
UnpauseEmulation();
unpauseEmulation();
}
}
} else
{
PauseEmulation();
pauseEmulation();
}
}
void PLAYBACK::SeekingStart(int finish_frame)
void PLAYBACK::startSeekingToFrame(int frame)
{
if ((pause_frame - 1) != finish_frame)
if ((pauseFrame - 1) != frame)
{
seeking_start_frame = currFrameCounter;
pause_frame = finish_frame + 1;
seekingBeginningFrame = currFrameCounter;
pauseFrame = frame + 1;
}
if (taseditor_config.turbo_seek)
if (taseditorConfig.turboSeek)
turbo = true;
UnpauseEmulation();
unpauseEmulation();
}
void PLAYBACK::SeekingStop()
void PLAYBACK::stopSeeking()
{
pause_frame = 0;
pauseFrame = 0;
turbo = false;
PauseEmulation();
SetProgressbar(1, 1);
pauseEmulation();
setProgressbar(1, 1);
}
void PLAYBACK::RewindFrame()
void PLAYBACK::handleRewindFrame()
{
if (pause_frame && !emu_paused) return;
if (pauseFrame && !emuPausedState) return;
if (currFrameCounter > 0)
jump(currFrameCounter - 1);
else
// cursor is at frame 0 - can't rewind, but still must make cursor visible if needed
piano_roll.FollowPlaybackIfNeeded(true);
if (!pause_frame)
PauseEmulation();
pianoRoll.followPlaybackCursorIfNeeded(true);
if (!pauseFrame)
pauseEmulation();
}
void PLAYBACK::ForwardFrame()
void PLAYBACK::handleForwardFrame()
{
if (pause_frame && !emu_paused) return;
if (pauseFrame && !emuPausedState) return;
jump(currFrameCounter + 1);
if (!pause_frame)
PauseEmulation();
if (!pauseFrame)
pauseEmulation();
turbo = false;
}
void PLAYBACK::RewindFull(int speed)
void PLAYBACK::handleRewindFull(int speed)
{
int index = currFrameCounter - 1;
// jump trough "speed" amount of previous Markers
while (speed > 0)
{
for (; index >= 0; index--)
if (markers_manager.GetMarker(index)) break;
if (markersManager.getMarkerAtFrame(index)) break;
speed--;
}
if (index >= 0)
@ -383,15 +383,15 @@ void PLAYBACK::RewindFull(int speed)
else
jump(0); // jump to the beginning of Piano Roll
}
void PLAYBACK::ForwardFull(int speed)
void PLAYBACK::handleForwardFull(int speed)
{
int last_frame = markers_manager.GetMarkersSize() - 1; // the end of movie Markers
int last_frame = markersManager.getMarkersArraySize() - 1; // the end of movie Markers
int index = currFrameCounter + 1;
// jump trough "speed" amount of next Markers
while (speed > 0)
{
for (; index <= last_frame; ++index)
if (markers_manager.GetMarker(index)) break;
if (markersManager.getMarkerAtFrame(index)) break;
speed--;
}
if (index <= last_frame)
@ -400,25 +400,25 @@ void PLAYBACK::ForwardFull(int speed)
jump(currMovieData.getNumRecords() - 1); // jump to the end of Piano Roll
}
void PLAYBACK::RedrawMarker()
void PLAYBACK::redrawMarkerData()
{
// redraw Marker num
char new_text[MAX_NOTE_LEN] = {0};
if (shown_marker <= 9999) // if there's too many digits in the number then don't show the word "Marker" before the number
if (displayedMarkerNumber <= 9999) // if there's too many digits in the number then don't show the word "Marker" before the number
strcpy(new_text, upperMarkerText);
char num[11];
_itoa(shown_marker, num, 10);
_itoa(displayedMarkerNumber, num, 10);
strcat(new_text, num);
strcat(new_text, " ");
SetWindowText(hwndPlaybackMarker, new_text);
SetWindowText(hwndPlaybackMarkerNumber, new_text);
// change Marker Note
strcpy(new_text, markers_manager.GetNote(shown_marker).c_str());
SetWindowText(hwndPlaybackMarkerEdit, new_text);
strcpy(new_text, markersManager.getNoteCopy(displayedMarkerNumber).c_str());
SetWindowText(hwndPlaybackMarkerEditField, new_text);
// reset search_similar_marker, because source Marker changed
markers_manager.search_similar_marker = 0;
markersManager.currentIterationOfFindSimilar = 0;
}
void PLAYBACK::StartFromZero()
void PLAYBACK::restartPlaybackFromZeroGround()
{
poweron(true);
FCEUMOV_ClearCommands(); // clear POWER SWITCH command caused by poweron()
@ -428,32 +428,32 @@ void PLAYBACK::StartFromZero()
currMovieData.insertEmpty(-1, 1);
}
void PLAYBACK::EnsurePlaybackIsInsideGreenzone(bool execute_lua)
void PLAYBACK::ensurePlaybackIsInsideGreenzone(bool executeLua)
{
// set the Playback cursor to the frame or at least above the frame
if (SetPlaybackAboveOrToFrame(greenzone.GetSize() - 1))
if (setPlaybackAboveOrToFrame(greenzone.getSize() - 1))
{
// since the game state was changed by this jump, we must update possible Lua callbacks and other tools that would normally only update in FCEUI_Emulate
if (execute_lua)
if (executeLua)
ForceExecuteLuaFrameFunctions();
Update_RAM_Search(); // Update_RAM_Watch() is also called.
}
// follow the Playback cursor, but in case of seeking don't follow it
piano_roll.FollowPlaybackIfNeeded(false);
pianoRoll.followPlaybackCursorIfNeeded(false);
}
// an interface for sending Playback cursor to any frame
void PLAYBACK::jump(int frame, bool force_state_reload, bool execute_lua, bool follow_pauseframe)
void PLAYBACK::jump(int frame, bool forceStateReload, bool executeLua, bool followPauseframe)
{
if (frame < 0) return;
int lastCursor = currFrameCounter;
// 1 - set the Playback cursor to the frame or at least above the frame
if (SetPlaybackAboveOrToFrame(frame, force_state_reload))
if (setPlaybackAboveOrToFrame(frame, forceStateReload))
{
// since the game state was changed by this jump, we must update possible Lua callbacks and other tools that would normally only update in FCEUI_Emulate
if (execute_lua)
if (executeLua)
ForceExecuteLuaFrameFunctions();
Update_RAM_Search(); // Update_RAM_Watch() is also called.
}
@ -461,91 +461,91 @@ void PLAYBACK::jump(int frame, bool force_state_reload, bool execute_lua, bool f
// 2 - seek from the current frame if we still aren't at the needed frame
if (frame > currFrameCounter)
{
SeekingStart(frame);
startSeekingToFrame(frame);
} else
{
// the Playback is already at the needed frame
if (pause_frame) // if Playback was seeking, pause emulation right here
SeekingStop();
if (pauseFrame) // if Playback was seeking, pause emulation right here
stopSeeking();
}
// follow the Playback cursor, and optionally follow pauseframe (if seeking was launched)
piano_roll.FollowPlaybackIfNeeded(follow_pauseframe);
pianoRoll.followPlaybackCursorIfNeeded(followPauseframe);
// redraw respective Piano Roll lines if needed
if (lastCursor != currFrameCounter)
{
// redraw row where Playback cursor was (in case there's two or more drags before playback.update())
piano_roll.RedrawRow(lastCursor);
bookmarks.RedrawChangedBookmarks(lastCursor);
pianoRoll.redrawRow(lastCursor);
bookmarks.redrawChangedBookmarks(lastCursor);
}
}
// returns true if the game state was changed (loaded)
bool PLAYBACK::SetPlaybackAboveOrToFrame(int frame, bool force_state_reload)
bool PLAYBACK::setPlaybackAboveOrToFrame(int frame, bool forceStateReload)
{
bool state_changed = false;
// search backwards for an earlier frame with valid savestate
int i = greenzone.GetSize() - 1;
int i = greenzone.getSize() - 1;
if (i > frame)
i = frame;
for (; i >= 0; i--)
{
if (!force_state_reload && !state_changed && i == currFrameCounter)
if (!forceStateReload && !state_changed && i == currFrameCounter)
{
// we can remain at current game state
break;
} else if (!greenzone.SavestateIsEmpty(i))
} else if (!greenzone.isSavestateEmpty(i))
{
state_changed = true; // after we once tried loading a savestate, we cannot use currFrameCounter state anymore, because the game state might have been corrupted by this loading attempt
if (greenzone.LoadSavestate(i))
if (greenzone.loadSavestateOfFrame(i))
break;
}
}
if (i < 0)
{
// couldn't find a savestate
StartFromZero();
restartPlaybackFromZeroGround();
state_changed = true;
}
return state_changed;
}
void PLAYBACK::SetLostPosition(int frame)
void PLAYBACK::setLastPosition(int frame)
{
if ((lost_position_frame - 1 < frame) || (lost_position_frame - 1 >= frame && !lost_position_is_stable))
if ((lastPositionFrame - 1 < frame) || (lastPositionFrame - 1 >= frame && !lastPositionIsStable))
{
if (lost_position_frame)
piano_roll.RedrawRow(lost_position_frame - 1);
lost_position_frame = frame + 1;
lost_position_is_stable = true;
if (lastPositionFrame)
pianoRoll.redrawRow(lastPositionFrame - 1);
lastPositionFrame = frame + 1;
lastPositionIsStable = true;
}
}
int PLAYBACK::GetLostPosition()
int PLAYBACK::getLastPosition()
{
return lost_position_frame - 1;
return lastPositionFrame - 1;
}
int PLAYBACK::GetPauseFrame()
int PLAYBACK::getPauseFrame()
{
return pause_frame - 1;
return pauseFrame - 1;
}
int PLAYBACK::GetFlashingPauseFrame()
int PLAYBACK::getFlashingPauseFrame()
{
if (show_pauseframe)
return pause_frame;
if (showPauseFrame)
return pauseFrame;
else
return 0;
}
void PLAYBACK::SetProgressbar(int a, int b)
void PLAYBACK::setProgressbar(int a, int b)
{
SendMessage(hwndProgressbar, PBM_SETPOS, PROGRESSBAR_WIDTH * a / b, 0);
}
void PLAYBACK::CancelSeeking()
void PLAYBACK::cancelSeeking()
{
if (pause_frame)
SeekingStop();
if (pauseFrame)
stopSeeking();
}
// -------------------------------------------------------------------------
LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
@ -556,51 +556,51 @@ LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR
{
case WM_SETFOCUS:
{
markers_manager.marker_note_edit = MARKER_NOTE_EDIT_UPPER;
markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_UPPER;
// enable editing
SendMessage(playback.hwndPlaybackMarkerEdit, EM_SETREADONLY, false, 0);
SendMessage(playback.hwndPlaybackMarkerEditField, EM_SETREADONLY, false, 0);
// disable FCEUX keyboard
ClearTaseditorInput();
disableGeneralKeyboardInput();
break;
}
case WM_KILLFOCUS:
{
// if we were editing, save and finish editing
if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_UPPER)
if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_UPPER)
{
markers_manager.UpdateMarkerNote();
markers_manager.marker_note_edit = MARKER_NOTE_EDIT_NONE;
markersManager.updateEditedMarkerNote();
markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_NONE;
}
// disable editing (make the bg grayed)
SendMessage(playback.hwndPlaybackMarkerEdit, EM_SETREADONLY, true, 0);
SendMessage(playback.hwndPlaybackMarkerEditField, EM_SETREADONLY, true, 0);
// enable FCEUX keyboard
if (taseditor_window.TASEditor_focus)
SetTaseditorInput();
if (taseditorWindow.TASEditorIsInFocus)
enableGeneralKeyboardInput();
break;
}
case WM_CHAR:
case WM_KEYDOWN:
{
if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_UPPER)
if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_UPPER)
{
switch(wParam)
{
case VK_ESCAPE:
// revert text to original note text
SetWindowText(playback.hwndPlaybackMarkerEdit, markers_manager.GetNote(playback.shown_marker).c_str());
SetFocus(piano_roll.hwndList);
SetWindowText(playback.hwndPlaybackMarkerEditField, markersManager.getNoteCopy(playback.displayedMarkerNumber).c_str());
SetFocus(pianoRoll.hwndList);
return 0;
case VK_RETURN:
// exit and save text changes
SetFocus(piano_roll.hwndList);
SetFocus(pianoRoll.hwndList);
return 0;
case VK_TAB:
{
// switch to lower edit control (also exit and save text changes)
SetFocus(selection.hwndSelectionMarkerEdit);
SetFocus(selection.hwndSelectionMarkerEditField);
// scroll to the Marker
if (taseditor_config.follow_note_context)
piano_roll.FollowMarker(selection.shown_marker);
if (taseditorConfig.followMarkerNoteContext)
pianoRoll.followMarker(selection.displayedMarkerNumber);
return 0;
}
}
@ -610,15 +610,15 @@ LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
playback.MiddleButtonClick();
playback.handleMiddleButtonClick();
return 0;
}
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
{
// scroll to the Marker
if (taseditor_config.follow_note_context)
piano_roll.FollowMarker(playback.shown_marker);
if (taseditorConfig.followMarkerNoteContext)
pianoRoll.followMarker(playback.displayedMarkerNumber);
break;
}
}

View File

@ -5,7 +5,7 @@
#define PAUSEFRAME_BLINKING_PERIOD_WHEN_SEEKING 100
#define PAUSEFRAME_BLINKING_PERIOD_WHEN_PAUSED 250
#define HOLD_REPEAT_DELAY 250 // in milliseconds
#define BUTTON_HOLD_REPEAT_DELAY 250 // in milliseconds
class PLAYBACK
@ -16,63 +16,63 @@ public:
void reset();
void update();
void EnsurePlaybackIsInsideGreenzone(bool execute_lua = true);
void jump(int frame, bool force_state_reload = false, bool execute_lua = true, bool follow_pauseframe = true);
void ensurePlaybackIsInsideGreenzone(bool executeLua = true);
void jump(int frame, bool forceStateReload = false, bool executeLua = true, bool followPauseframe = true);
void UpdateProgressbar();
void updateProgressbar();
void SeekingStart(int finish_frame);
void SeekingStop();
void startSeekingToFrame(int frame);
void stopSeeking();
void cancelSeeking();
void ToggleEmulationPause();
void PauseEmulation();
void UnpauseEmulation();
void toggleEmulationPause();
void pauseEmulation();
void unpauseEmulation();
void RestorePosition();
void MiddleButtonClick();
void restoreLastPosition();
void handleMiddleButtonClick();
void RewindFrame();
void ForwardFrame();
void RewindFull(int speed = 1);
void ForwardFull(int speed = 1);
void handleRewindFrame();
void handleForwardFrame();
void handleRewindFull(int speed = 1);
void handleForwardFull(int speed = 1);
void RedrawMarker();
void redrawMarkerData();
void StartFromZero();
void restartPlaybackFromZeroGround();
void SetLostPosition(int frame);
int GetLostPosition(); // actually returns lost_position_frame-1
int getLastPosition(); // actually returns lost_position_frame-1
void setLastPosition(int frame);
int GetPauseFrame();
int GetFlashingPauseFrame();
int getPauseFrame();
int getFlashingPauseFrame();
void SetProgressbar(int a, int b);
void CancelSeeking();
void setProgressbar(int a, int b);
bool must_find_current_marker;
int shown_marker;
bool mustFindCurrentMarker;
int displayedMarkerNumber;
HWND hwndProgressbar, hwndRewind, hwndForward, hwndRewindFull, hwndForwardFull;
HWND hwndPlaybackMarker, hwndPlaybackMarkerEdit;
HWND hwndPlaybackMarkerNumber, hwndPlaybackMarkerEditField;
private:
bool SetPlaybackAboveOrToFrame(int frame, bool force_state_reload = false);
bool setPlaybackAboveOrToFrame(int frame, bool forceStateReload = false);
int pause_frame;
int lost_position_frame;
bool lost_position_is_stable; // for when Greenzone invalidates several times, but the end of current segment must remain the same
int pauseFrame;
int lastPositionFrame;
bool lastPositionIsStable; // for when Greenzone invalidates several times, but the end of current segment must remain the same
bool must_autopause_at_the_end;
bool old_emu_paused, emu_paused;
int old_pauseframe;
bool old_show_pauseframe, show_pauseframe;
int lastCursor; // but for currentCursor we use external variable currFrameCounter
bool mustAutopauseAtTheEnd;
bool emuPausedState, emuPausedOldState;
int oldPauseFrame;
bool showPauseFrame, oldStateOfShowPauseFrame;
int lastCursorPos; // but for currentCursor we use external variable currFrameCounter
bool old_rewind_button_state, rewind_button_state;
bool old_forward_button_state, forward_button_state;
bool old_rewind_full_button_state, rewind_full_button_state;
bool old_forward_full_button_state, forward_full_button_state;
int button_hold_time;
int seeking_start_frame;
bool rewindButtonState, rewindButtonOldState;
bool forwardButtonState, forwardButtonOldState;
bool rewindFullButtonState, rewindFullButtonOldState;
bool forwardFullButtonState, forwardFullButtonOldState;
int buttonHoldTimer;
int seekingBeginningFrame;
};

View File

@ -19,66 +19,66 @@ Popup display - Manager of popup windows
#include "taseditor_project.h"
#include "zlib.h"
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern BOOKMARKS bookmarks;
extern BRANCHES branches;
extern PIANO_ROLL piano_roll;
extern MARKERS_MANAGER markers_manager;
extern PIANO_ROLL pianoRoll;
extern MARKERS_MANAGER markersManager;
extern PLAYBACK playback;
LRESULT CALLBACK ScrBmpWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT APIENTRY MarkerNoteDescrWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK screenshotBitmapWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT APIENTRY noteDescriptionWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
// resources
char szClassName[] = "ScrBmp";
char szClassName2[] = "MarketNoteDescr";
char szClassName[] = "ScreenshotBitmap";
char szClassName2[] = "NoteDescription";
POPUP_DISPLAY::POPUP_DISPLAY()
{
hwndScrBmp = 0;
hwndMarkerNoteDescr = 0;
hwndScreenshotBitmap = 0;
hwndNoteDescription = 0;
// create BITMAPINFO
scr_bmi = (LPBITMAPINFO)malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); // 256 color in palette
scr_bmi->bmiHeader.biSize = sizeof(scr_bmi->bmiHeader);
scr_bmi->bmiHeader.biWidth = SCREENSHOT_WIDTH;
scr_bmi->bmiHeader.biHeight = -SCREENSHOT_HEIGHT; // negative value = top-down bmp
scr_bmi->bmiHeader.biPlanes = 1;
scr_bmi->bmiHeader.biBitCount = 8;
scr_bmi->bmiHeader.biCompression = BI_RGB;
scr_bmi->bmiHeader.biSizeImage = 0;
screenshotBmi = (LPBITMAPINFO)malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); // 256 color in palette
screenshotBmi->bmiHeader.biSize = sizeof(screenshotBmi->bmiHeader);
screenshotBmi->bmiHeader.biWidth = SCREENSHOT_WIDTH;
screenshotBmi->bmiHeader.biHeight = -SCREENSHOT_HEIGHT; // negative value = top-down bmp
screenshotBmi->bmiHeader.biPlanes = 1;
screenshotBmi->bmiHeader.biBitCount = 8;
screenshotBmi->bmiHeader.biCompression = BI_RGB;
screenshotBmi->bmiHeader.biSizeImage = 0;
// register SCREENSHOT_DISPLAY window class
wincl1.hInstance = fceu_hInstance;
wincl1.lpszClassName = szClassName;
wincl1.lpfnWndProc = ScrBmpWndProc;
wincl1.style = CS_DBLCLKS;
wincl1.cbSize = sizeof(WNDCLASSEX);
wincl1.hIcon = 0;
wincl1.hIconSm = 0;
wincl1.hCursor = 0;
wincl1.lpszMenuName = 0;
wincl1.cbClsExtra = 0;
wincl1.cbWndExtra = 0;
wincl1.hbrBackground = 0;
if (!RegisterClassEx(&wincl1))
winCl1.hInstance = fceu_hInstance;
winCl1.lpszClassName = szClassName;
winCl1.lpfnWndProc = screenshotBitmapWndProc;
winCl1.style = CS_DBLCLKS;
winCl1.cbSize = sizeof(WNDCLASSEX);
winCl1.hIcon = 0;
winCl1.hIconSm = 0;
winCl1.hCursor = 0;
winCl1.lpszMenuName = 0;
winCl1.cbClsExtra = 0;
winCl1.cbWndExtra = 0;
winCl1.hbrBackground = 0;
if (!RegisterClassEx(&winCl1))
FCEU_printf("Error registering SCREENSHOT_DISPLAY window class\n");
// register MARKER_NOTE_DESCRIPTION window class
wincl2.hInstance = fceu_hInstance;
wincl2.lpszClassName = szClassName2;
wincl2.lpfnWndProc = MarkerNoteDescrWndProc;
wincl2.style = CS_DBLCLKS;
wincl2.cbSize = sizeof(WNDCLASSEX);
wincl2.hIcon = 0;
wincl2.hIconSm = 0;
wincl2.hCursor = 0;
wincl2.lpszMenuName = 0;
wincl2.cbClsExtra = 0;
wincl2.cbWndExtra = 0;
wincl2.hbrBackground = 0;
if (!RegisterClassEx(&wincl2))
FCEU_printf("Error registering MARKER_NOTE_DESCRIPTION window class\n");
// register NOTE_DESCRIPTION window class
winCl2.hInstance = fceu_hInstance;
winCl2.lpszClassName = szClassName2;
winCl2.lpfnWndProc = noteDescriptionWndProc;
winCl2.style = CS_DBLCLKS;
winCl2.cbSize = sizeof(WNDCLASSEX);
winCl2.hIcon = 0;
winCl2.hIconSm = 0;
winCl2.hCursor = 0;
winCl2.lpszMenuName = 0;
winCl2.cbClsExtra = 0;
winCl2.cbWndExtra = 0;
winCl2.hbrBackground = 0;
if (!RegisterClassEx(&winCl2))
FCEU_printf("Error registering NOTE_DESCRIPTION window class\n");
// create blendfunction
blend.BlendOp = AC_SRC_OVER;
@ -94,210 +94,210 @@ void POPUP_DISPLAY::init()
extern PALETTEENTRY *color_palette;
for (int i = 0; i < 256; ++i)
{
scr_bmi->bmiColors[i].rgbRed = color_palette[i].peRed;
scr_bmi->bmiColors[i].rgbGreen = color_palette[i].peGreen;
scr_bmi->bmiColors[i].rgbBlue = color_palette[i].peBlue;
screenshotBmi->bmiColors[i].rgbRed = color_palette[i].peRed;
screenshotBmi->bmiColors[i].rgbGreen = color_palette[i].peGreen;
screenshotBmi->bmiColors[i].rgbBlue = color_palette[i].peBlue;
}
HDC win_hdc = GetWindowDC(piano_roll.hwndList);
scr_bmp = CreateDIBSection(win_hdc, scr_bmi, DIB_RGB_COLORS, (void**)&scr_ptr, 0, 0);
HDC win_hdc = GetWindowDC(pianoRoll.hwndList);
screenshotHBitmap = CreateDIBSection(win_hdc, screenshotBmi, DIB_RGB_COLORS, (void**)&screenshotRasterPointer, 0, 0);
// calculate coordinates of popup windows (relative to TAS Editor window)
ParentWindowMoved();
updateBecauseParentWindowMoved();
}
void POPUP_DISPLAY::free()
{
reset();
if (scr_bmp)
if (screenshotHBitmap)
{
DeleteObject(scr_bmp);
scr_bmp = 0;
DeleteObject(screenshotHBitmap);
screenshotHBitmap = 0;
}
}
void POPUP_DISPLAY::reset()
{
screenshot_currently_shown = ITEM_UNDER_MOUSE_NONE;
next_update_time = scr_bmp_phase = 0;
if (hwndScrBmp)
currentlyDisplayedBookmark = ITEM_UNDER_MOUSE_NONE;
nextUpdateTime = screenshotBitmapPhase = 0;
if (hwndScreenshotBitmap)
{
DestroyWindow(hwndScrBmp);
hwndScrBmp = 0;
DestroyWindow(hwndScreenshotBitmap);
hwndScreenshotBitmap = 0;
}
if (hwndMarkerNoteDescr)
if (hwndNoteDescription)
{
DestroyWindow(hwndMarkerNoteDescr);
hwndMarkerNoteDescr = 0;
DestroyWindow(hwndNoteDescription);
hwndNoteDescription = 0;
}
}
void POPUP_DISPLAY::update()
{
// once per 40 milliseconds update popup windows alpha
if (clock() > next_update_time)
if (clock() > nextUpdateTime)
{
next_update_time = clock() + DISPLAY_UPDATE_TICK;
if (branches.IsSafeToShowBranchesData() && bookmarks.item_under_mouse >= 0 && bookmarks.item_under_mouse < TOTAL_BOOKMARKS && bookmarks.bookmarks_array[bookmarks.item_under_mouse].not_empty)
nextUpdateTime = clock() + DISPLAY_UPDATE_TICK;
if (branches.isSafeToShowBranchesData() && bookmarks.itemUnderMouse >= 0 && bookmarks.itemUnderMouse < TOTAL_BOOKMARKS && bookmarks.bookmarksArray[bookmarks.itemUnderMouse].notEmpty)
{
if (taseditor_config.show_branch_screenshots && !hwndScrBmp)
if (taseditorConfig.displayBranchScreenshots && !hwndScreenshotBitmap)
{
// create window
hwndScrBmp = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, szClassName, szClassName, WS_POPUP, taseditor_config.wndx + scr_bmp_x, taseditor_config.wndy + scr_bmp_y, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT, taseditor_window.hwndTasEditor, NULL, fceu_hInstance, NULL);
RedrawScreenshotBitmap();
ShowWindow(hwndScrBmp, SW_SHOWNA);
hwndScreenshotBitmap = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, szClassName, szClassName, WS_POPUP, taseditorConfig.windowX + screenshotBitmapX, taseditorConfig.windowY + screenshotBitmapY, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT, taseditorWindow.hwndTASEditor, NULL, fceu_hInstance, NULL);
redrawScreenshotBitmap();
ShowWindow(hwndScreenshotBitmap, SW_SHOWNA);
}
if (taseditor_config.show_branch_descr && !hwndMarkerNoteDescr)
if (taseditorConfig.displayBranchDescriptions && !hwndNoteDescription)
{
RECT wrect;
GetWindowRect(playback.hwndPlaybackMarkerEdit, &wrect);
descr_x = scr_bmp_x + (SCREENSHOT_WIDTH - (wrect.right - wrect.left)) / 2;
hwndMarkerNoteDescr = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, szClassName2, szClassName2, WS_POPUP, taseditor_config.wndx + descr_x, taseditor_config.wndy + descr_y, wrect.right - wrect.left, wrect.bottom - wrect.top, taseditor_window.hwndTasEditor, NULL, fceu_hInstance, NULL);
ChangeDescrText();
ShowWindow(hwndMarkerNoteDescr, SW_SHOWNA);
GetWindowRect(playback.hwndPlaybackMarkerEditField, &wrect);
descriptionX = screenshotBitmapX + (SCREENSHOT_WIDTH - (wrect.right - wrect.left)) / 2;
hwndNoteDescription = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, szClassName2, szClassName2, WS_POPUP, taseditorConfig.windowX + descriptionX, taseditorConfig.windowY + descriptionY, wrect.right - wrect.left, wrect.bottom - wrect.top, taseditorWindow.hwndTASEditor, NULL, fceu_hInstance, NULL);
changeDescriptionText();
ShowWindow(hwndNoteDescription, SW_SHOWNA);
}
// change screenshot_bitmap pic and description text if needed
if (screenshot_currently_shown != bookmarks.item_under_mouse)
if (currentlyDisplayedBookmark != bookmarks.itemUnderMouse)
{
if (taseditor_config.show_branch_screenshots)
ChangeScreenshotBitmap();
if (taseditor_config.show_branch_descr)
ChangeDescrText();
screenshot_currently_shown = bookmarks.item_under_mouse;
if (taseditorConfig.displayBranchScreenshots)
changeScreenshotBitmap();
if (taseditorConfig.displayBranchDescriptions)
changeDescriptionText();
currentlyDisplayedBookmark = bookmarks.itemUnderMouse;
}
if (scr_bmp_phase < SCR_BMP_PHASE_MAX)
if (screenshotBitmapPhase < SCREENSHOT_BITMAP_PHASE_MAX)
{
scr_bmp_phase++;
screenshotBitmapPhase++;
// update alpha
int phase_alpha = scr_bmp_phase;
if (phase_alpha > SCR_BMP_PHASE_ALPHA_MAX) phase_alpha = SCR_BMP_PHASE_ALPHA_MAX;
if (hwndScrBmp)
int phase_alpha = screenshotBitmapPhase;
if (phase_alpha > SCREENSHOT_BITMAP_PHASE_ALPHA_MAX) phase_alpha = SCREENSHOT_BITMAP_PHASE_ALPHA_MAX;
if (hwndScreenshotBitmap)
{
SetLayeredWindowAttributes(hwndScrBmp, 0, (255 * phase_alpha) / SCR_BMP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndScrBmp, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
SetLayeredWindowAttributes(hwndScreenshotBitmap, 0, (255 * phase_alpha) / SCREENSHOT_BITMAP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndScreenshotBitmap, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
}
if (hwndMarkerNoteDescr)
if (hwndNoteDescription)
{
SetLayeredWindowAttributes(hwndMarkerNoteDescr, 0, (255 * phase_alpha) / SCR_BMP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndMarkerNoteDescr, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
SetLayeredWindowAttributes(hwndNoteDescription, 0, (255 * phase_alpha) / SCREENSHOT_BITMAP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndNoteDescription, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
}
}
} else
{
// fade and finally hide screenshot
if (scr_bmp_phase > 0)
scr_bmp_phase--;
if (scr_bmp_phase > 0)
if (screenshotBitmapPhase > 0)
screenshotBitmapPhase--;
if (screenshotBitmapPhase > 0)
{
// update alpha
int phase_alpha = scr_bmp_phase;
if (phase_alpha > SCR_BMP_PHASE_ALPHA_MAX)
phase_alpha = SCR_BMP_PHASE_ALPHA_MAX;
int phase_alpha = screenshotBitmapPhase;
if (phase_alpha > SCREENSHOT_BITMAP_PHASE_ALPHA_MAX)
phase_alpha = SCREENSHOT_BITMAP_PHASE_ALPHA_MAX;
else if (phase_alpha < 0)
phase_alpha = 0;
if (hwndScrBmp)
if (hwndScreenshotBitmap)
{
SetLayeredWindowAttributes(hwndScrBmp, 0, (255 * phase_alpha) / SCR_BMP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndScrBmp, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
SetLayeredWindowAttributes(hwndScreenshotBitmap, 0, (255 * phase_alpha) / SCREENSHOT_BITMAP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndScreenshotBitmap, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
}
if (hwndMarkerNoteDescr)
if (hwndNoteDescription)
{
SetLayeredWindowAttributes(hwndMarkerNoteDescr, 0, (255 * phase_alpha) / SCR_BMP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndMarkerNoteDescr, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
SetLayeredWindowAttributes(hwndNoteDescription, 0, (255 * phase_alpha) / SCREENSHOT_BITMAP_PHASE_ALPHA_MAX, LWA_ALPHA);
UpdateLayeredWindow(hwndNoteDescription, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA);
}
} else
{
// destroy popup windows
scr_bmp_phase = 0;
if (hwndScrBmp)
screenshotBitmapPhase = 0;
if (hwndScreenshotBitmap)
{
DestroyWindow(hwndScrBmp);
hwndScrBmp = 0;
DestroyWindow(hwndScreenshotBitmap);
hwndScreenshotBitmap = 0;
}
if (hwndMarkerNoteDescr)
if (hwndNoteDescription)
{
DestroyWindow(hwndMarkerNoteDescr);
hwndMarkerNoteDescr = 0;
DestroyWindow(hwndNoteDescription);
hwndNoteDescription = 0;
}
// immediately redraw the window below those
UpdateWindow(taseditor_window.hwndTasEditor);
UpdateWindow(taseditorWindow.hwndTASEditor);
}
}
}
}
void POPUP_DISPLAY::ChangeScreenshotBitmap()
void POPUP_DISPLAY::changeScreenshotBitmap()
{
// uncompress
uLongf destlen = SCREENSHOT_SIZE;
int e = uncompress(&scr_ptr[0], &destlen, &bookmarks.bookmarks_array[bookmarks.item_under_mouse].saved_screenshot[0], bookmarks.bookmarks_array[bookmarks.item_under_mouse].saved_screenshot.size());
int e = uncompress(&screenshotRasterPointer[0], &destlen, &bookmarks.bookmarksArray[bookmarks.itemUnderMouse].savedScreenshot[0], bookmarks.bookmarksArray[bookmarks.itemUnderMouse].savedScreenshot.size());
if (e != Z_OK && e != Z_BUF_ERROR)
{
// error decompressing
FCEU_printf("Error decompressing screenshot %d\n", bookmarks.item_under_mouse);
FCEU_printf("Error decompressing screenshot %d\n", bookmarks.itemUnderMouse);
// at least fill bitmap with zeros
memset(&scr_ptr[0], 0, SCREENSHOT_SIZE);
memset(&screenshotRasterPointer[0], 0, SCREENSHOT_SIZE);
}
RedrawScreenshotBitmap();
redrawScreenshotBitmap();
}
void POPUP_DISPLAY::RedrawScreenshotBitmap()
void POPUP_DISPLAY::redrawScreenshotBitmap()
{
HBITMAP temp_bmp = (HBITMAP)SendMessage(scr_bmp_pic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)scr_bmp);
if (temp_bmp && temp_bmp != scr_bmp)
HBITMAP temp_bmp = (HBITMAP)SendMessage(hwndScreenshotPicture, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)screenshotHBitmap);
if (temp_bmp && temp_bmp != screenshotHBitmap)
DeleteObject(temp_bmp);
}
void POPUP_DISPLAY::ChangeDescrText()
void POPUP_DISPLAY::changeDescriptionText()
{
// retrieve info from the pointed bookmark's Markers
int frame = bookmarks.bookmarks_array[bookmarks.item_under_mouse].snapshot.keyframe;
int marker_id = markers_manager.GetMarkerUp(bookmarks.bookmarks_array[bookmarks.item_under_mouse].snapshot.markers, frame);
int frame = bookmarks.bookmarksArray[bookmarks.itemUnderMouse].snapshot.keyFrame;
int markerID = markersManager.getMarkerAboveFrame(bookmarks.bookmarksArray[bookmarks.itemUnderMouse].snapshot.markers, frame);
char new_text[MAX_NOTE_LEN];
strcpy(new_text, markers_manager.GetNote(bookmarks.bookmarks_array[bookmarks.item_under_mouse].snapshot.markers, marker_id).c_str());
SetWindowText(marker_note_descr, new_text);
strcpy(new_text, markersManager.getNoteCopy(bookmarks.bookmarksArray[bookmarks.itemUnderMouse].snapshot.markers, markerID).c_str());
SetWindowText(hwndNoteText, new_text);
}
void POPUP_DISPLAY::ParentWindowMoved()
void POPUP_DISPLAY::updateBecauseParentWindowMoved()
{
// calculate new positions relative to IDC_BOOKMARKS_BOX
RECT temp_rect, parent_rect;
GetWindowRect(taseditor_window.hwndTasEditor, &parent_rect);
GetWindowRect(GetDlgItem(taseditor_window.hwndTasEditor, IDC_BOOKMARKS_BOX), &temp_rect);
scr_bmp_x = temp_rect.left - SCREENSHOT_WIDTH - SCR_BMP_DX - parent_rect.left;
scr_bmp_y = (temp_rect.bottom - SCREENSHOT_HEIGHT) - parent_rect.top;
GetWindowRect(taseditorWindow.hwndTASEditor, &parent_rect);
GetWindowRect(GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKS_BOX), &temp_rect);
screenshotBitmapX = temp_rect.left - SCREENSHOT_WIDTH - SCREENSHOT_BITMAP_DX - parent_rect.left;
screenshotBitmapY = (temp_rect.bottom - SCREENSHOT_HEIGHT) - parent_rect.top;
RECT wrect;
GetWindowRect(playback.hwndPlaybackMarkerEdit, &wrect);
descr_x = scr_bmp_x + (SCREENSHOT_WIDTH - (wrect.right - wrect.left)) / 2;
descr_y = scr_bmp_y + SCREENSHOT_HEIGHT + SCR_BMP_DESCR_GAP;
GetWindowRect(playback.hwndPlaybackMarkerEditField, &wrect);
descriptionX = screenshotBitmapX + (SCREENSHOT_WIDTH - (wrect.right - wrect.left)) / 2;
descriptionY = screenshotBitmapY + SCREENSHOT_HEIGHT + SCREENSHOT_BITMAP_DESCRIPTION_GAP;
// if popup windows are currently shown, update their positions
if (hwndScrBmp)
SetWindowPos(hwndScrBmp, 0, taseditor_config.wndx + scr_bmp_x, taseditor_config.wndy + scr_bmp_y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
if (hwndMarkerNoteDescr)
SetWindowPos(hwndMarkerNoteDescr, 0, taseditor_config.wndx + descr_x, taseditor_config.wndy + descr_y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
if (hwndScreenshotBitmap)
SetWindowPos(hwndScreenshotBitmap, 0, taseditorConfig.windowX + screenshotBitmapX, taseditorConfig.windowY + screenshotBitmapY, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
if (hwndNoteDescription)
SetWindowPos(hwndNoteDescription, 0, taseditorConfig.windowX + descriptionX, taseditorConfig.windowY + descriptionY, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
}
// ----------------------------------------------------------------------------------------
LRESULT APIENTRY ScrBmpWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT APIENTRY screenshotBitmapWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
extern POPUP_DISPLAY popup_display;
extern POPUP_DISPLAY popupDisplay;
switch(message)
{
case WM_CREATE:
{
// create static bitmap placeholder
popup_display.scr_bmp_pic = CreateWindow(WC_STATIC, NULL, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 255, 255, hwnd, NULL, NULL, NULL);
popupDisplay.hwndScreenshotPicture = CreateWindow(WC_STATIC, NULL, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 255, 255, hwnd, NULL, NULL, NULL);
return 0;
}
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
}
LRESULT APIENTRY MarkerNoteDescrWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT APIENTRY noteDescriptionWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
extern POPUP_DISPLAY popup_display;
extern POPUP_DISPLAY popupDisplay;
switch(message)
{
case WM_CREATE:
{
// create static text field
RECT wrect;
GetWindowRect(playback.hwndPlaybackMarkerEdit, &wrect);
popup_display.marker_note_descr = CreateWindow(WC_STATIC, NULL, WS_CHILD | WS_VISIBLE | SS_CENTER | SS_ENDELLIPSIS | SS_SUNKEN, 1, 1, wrect.right - wrect.left - 2, wrect.bottom - wrect.top - 2, hwnd, NULL, NULL, NULL);
SendMessage(popup_display.marker_note_descr, WM_SETFONT, (WPARAM)piano_roll.hMarkersEditFont, 0);
GetWindowRect(playback.hwndPlaybackMarkerEditField, &wrect);
popupDisplay.hwndNoteText = CreateWindow(WC_STATIC, NULL, WS_CHILD | WS_VISIBLE | SS_CENTER | SS_ENDELLIPSIS | SS_SUNKEN, 1, 1, wrect.right - wrect.left - 2, wrect.bottom - wrect.top - 2, hwnd, NULL, NULL, NULL);
SendMessage(popupDisplay.hwndNoteText, WM_SETFONT, (WPARAM)pianoRoll.hMarkersEditFont, 0);
return 0;
}
default:

View File

@ -1,11 +1,9 @@
// Specification file for POPUP_DISPLAY class
#define SCR_BMP_PHASE_MAX 10
#define SCR_BMP_PHASE_ALPHA_MAX 8
#define SCR_BMP_DX 7
#define SCR_BMP_DESCR_GAP 2
#define SCREENSHOT_BITMAP_PHASE_MAX 10
#define SCREENSHOT_BITMAP_PHASE_ALPHA_MAX 8
#define SCREENSHOT_BITMAP_DX 7
#define SCREENSHOT_BITMAP_DESCRIPTION_GAP 2
#define DISPLAY_UPDATE_TICK 40 // update at 25FPS
class POPUP_DISPLAY
@ -17,28 +15,28 @@ public:
void reset();
void update();
void ChangeScreenshotBitmap();
void RedrawScreenshotBitmap();
void ChangeDescrText();
void changeScreenshotBitmap();
void redrawScreenshotBitmap();
void changeDescriptionText();
void ParentWindowMoved();
void updateBecauseParentWindowMoved();
int screenshot_currently_shown;
HWND hwndScrBmp, scr_bmp_pic, hwndMarkerNoteDescr, marker_note_descr;
int currentlyDisplayedBookmark;
HWND hwndScreenshotBitmap, hwndScreenshotPicture, hwndNoteDescription, hwndNoteText;
private:
int scr_bmp_x;
int scr_bmp_y;
int scr_bmp_phase;
int next_update_time;
int screenshotBitmapX;
int screenshotBitmapY;
int screenshotBitmapPhase;
int nextUpdateTime;
int descr_x;
int descr_y;
int descriptionX;
int descriptionY;
WNDCLASSEX wincl1, wincl2;
WNDCLASSEX winCl1, winCl2;
BLENDFUNCTION blend;
LPBITMAPINFO scr_bmi;
HBITMAP scr_bmp;
uint8* scr_ptr;
LPBITMAPINFO screenshotBmi;
HBITMAP screenshotHBitmap;
uint8* screenshotRasterPointer;
};

View File

@ -18,19 +18,19 @@ Recorder - Tool for Input recording
#include "taseditor_project.h"
extern int joysticks_per_frame[NUM_SUPPORTED_INPUT_TYPES];
extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
extern uint32 GetGamepadPressedImmediate();
extern int GetInputType(MovieData& md);
extern int getInputType(MovieData& md);
extern char lagFlag;
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern BOOKMARKS bookmarks;
extern HISTORY history;
extern GREENZONE greenzone;
extern PIANO_ROLL piano_roll;
extern PIANO_ROLL pianoRoll;
extern EDITOR editor;
// resources
@ -53,58 +53,58 @@ RECORDER::RECORDER()
void RECORDER::init()
{
hwndRecCheckbox = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RECORDING);
hwndRB_RecAll = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RADIO_ALL);
hwndRB_Rec1P = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RADIO_1P);
hwndRB_Rec2P = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RADIO_2P);
hwndRB_Rec3P = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RADIO_3P);
hwndRB_Rec4P = GetDlgItem(taseditor_window.hwndTasEditor, IDC_RADIO_4P);
old_multitrack_recording_joypad = multitrack_recording_joypad;
old_current_pattern = old_pattern_offset = 0;
must_increase_pattern_offset = false;
old_movie_readonly = movie_readonly;
old_joy.resize(MAX_NUM_JOYPADS);
new_joy.resize(MAX_NUM_JOYPADS);
current_joy.resize(MAX_NUM_JOYPADS);
hwndRecordingCheckbox = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RECORDING);
hwndRadioButtonRecordAll = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_ALL);
hwndRadioButtonRecord1P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_1P);
hwndRadioButtonRecord2P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_2P);
hwndRadioButtonRecord3P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_3P);
hwndRadioButtonRecord4P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_4P);
oldMultitrackRecordingJoypadNumber = multitrackRecordingJoypadNumber;
oldCurrentPattern = oldPatternOffset = 0;
mustIncreasePatternOffset = false;
oldStateOfMovieReadonly = movie_readonly;
oldJoyData.resize(MAX_NUM_JOYPADS);
newJoyData.resize(MAX_NUM_JOYPADS);
currentJoypadData.resize(MAX_NUM_JOYPADS);
}
void RECORDER::reset()
{
movie_readonly = true;
state_was_loaded_in_readwrite_mode = false;
multitrack_recording_joypad = MULTITRACK_RECORDING_ALL;
pattern_offset = 0;
must_increase_pattern_offset = false;
UncheckRecordingRadioButtons();
RecheckRecordingRadioButtons();
switch (GetInputType(currMovieData))
stateWasLoadedInReadWriteMode = false;
multitrackRecordingJoypadNumber = MULTITRACK_RECORDING_ALL;
patternOffset = 0;
mustIncreasePatternOffset = false;
uncheckRecordingRadioButtons();
recheckRecordingRadioButtons();
switch (getInputType(currMovieData))
{
case INPUT_TYPE_FOURSCORE:
{
// enable all 4 radiobuttons
EnableWindow(hwndRB_Rec1P, true);
EnableWindow(hwndRB_Rec2P, true);
EnableWindow(hwndRB_Rec3P, true);
EnableWindow(hwndRB_Rec4P, true);
EnableWindow(hwndRadioButtonRecord1P, true);
EnableWindow(hwndRadioButtonRecord2P, true);
EnableWindow(hwndRadioButtonRecord3P, true);
EnableWindow(hwndRadioButtonRecord4P, true);
break;
}
case INPUT_TYPE_2P:
{
// enable radiobuttons 1 and 2
EnableWindow(hwndRB_Rec1P, true);
EnableWindow(hwndRB_Rec2P, true);
EnableWindow(hwndRadioButtonRecord1P, true);
EnableWindow(hwndRadioButtonRecord2P, true);
// disable radiobuttons 3 and 4
EnableWindow(hwndRB_Rec3P, false);
EnableWindow(hwndRB_Rec4P, false);
EnableWindow(hwndRadioButtonRecord3P, false);
EnableWindow(hwndRadioButtonRecord4P, false);
break;
}
case INPUT_TYPE_1P:
{
// enable radiobutton 1
EnableWindow(hwndRB_Rec1P, true);
EnableWindow(hwndRadioButtonRecord1P, true);
// disable radiobuttons 2, 3 and 4
EnableWindow(hwndRB_Rec2P, false);
EnableWindow(hwndRB_Rec3P, false);
EnableWindow(hwndRB_Rec4P, false);
EnableWindow(hwndRadioButtonRecord2P, false);
EnableWindow(hwndRadioButtonRecord3P, false);
EnableWindow(hwndRadioButtonRecord4P, false);
break;
}
}
@ -112,78 +112,78 @@ void RECORDER::reset()
void RECORDER::update()
{
// update window caption if needed
if (old_movie_readonly != movie_readonly || old_multitrack_recording_joypad != multitrack_recording_joypad)
taseditor_window.UpdateCaption();
if (oldStateOfMovieReadonly != movie_readonly || oldMultitrackRecordingJoypadNumber != multitrackRecordingJoypadNumber)
taseditorWindow.updateCaption();
// update Bookmarks/Branches groupbox caption if needed
if (taseditor_config.old_branching_controls && old_movie_readonly != movie_readonly)
bookmarks.RedrawBookmarksCaption();
if (taseditorConfig.oldControlSchemeForBranching && oldStateOfMovieReadonly != movie_readonly)
bookmarks.redrawBookmarksSectionCaption();
// update "Recording" checkbox state
if (old_movie_readonly != movie_readonly)
if (oldStateOfMovieReadonly != movie_readonly)
{
Button_SetCheck(hwndRecCheckbox, movie_readonly?BST_UNCHECKED : BST_CHECKED);
old_movie_readonly = movie_readonly;
Button_SetCheck(hwndRecordingCheckbox, movie_readonly?BST_UNCHECKED : BST_CHECKED);
oldStateOfMovieReadonly = movie_readonly;
if (movie_readonly)
state_was_loaded_in_readwrite_mode = false;
stateWasLoadedInReadWriteMode = false;
}
// reset pattern_offset if current_pattern has changed
if (old_current_pattern != taseditor_config.current_pattern)
pattern_offset = 0;
if (oldCurrentPattern != taseditorConfig.currentPattern)
patternOffset = 0;
// increase pattern_offset if needed
if (must_increase_pattern_offset)
if (mustIncreasePatternOffset)
{
must_increase_pattern_offset = false;
if (!taseditor_config.pattern_skips_lag || lagFlag == 0)
mustIncreasePatternOffset = false;
if (!taseditorConfig.autofirePatternSkipsLag || lagFlag == 0)
{
pattern_offset++;
if (pattern_offset >= (int)editor.autofire_patterns[old_current_pattern].size())
pattern_offset -= editor.autofire_patterns[old_current_pattern].size();
patternOffset++;
if (patternOffset >= (int)editor.patterns[oldCurrentPattern].size())
patternOffset -= editor.patterns[oldCurrentPattern].size();
}
}
// update "Recording" checkbox text if something changed in pattern
if (old_current_pattern != taseditor_config.current_pattern || old_pattern_offset != pattern_offset)
if (oldCurrentPattern != taseditorConfig.currentPattern || oldPatternOffset != patternOffset)
{
old_current_pattern = taseditor_config.current_pattern;
old_pattern_offset = pattern_offset;
if (!taseditor_config.pattern_recording || editor.autofire_patterns[old_current_pattern][pattern_offset])
oldCurrentPattern = taseditorConfig.currentPattern;
oldPatternOffset = patternOffset;
if (!taseditorConfig.recordingUsePattern || editor.patterns[oldCurrentPattern][patternOffset])
// either not using Patterns or current pattern has 1 in current offset
SetWindowText(hwndRecCheckbox, recordingCheckbox);
SetWindowText(hwndRecordingCheckbox, recordingCheckbox);
else
// current pattern has 0 in current offset, this means next recorded frame will be blank
SetWindowText(hwndRecCheckbox, recordingCheckboxBlankPattern);
SetWindowText(hwndRecordingCheckbox, recordingCheckboxBlankPattern);
}
// update recording radio buttons if user changed multitrack_recording_joypad
if (old_multitrack_recording_joypad != multitrack_recording_joypad)
if (oldMultitrackRecordingJoypadNumber != multitrackRecordingJoypadNumber)
{
UncheckRecordingRadioButtons();
RecheckRecordingRadioButtons();
uncheckRecordingRadioButtons();
recheckRecordingRadioButtons();
}
int num_joys = joysticks_per_frame[GetInputType(currMovieData)];
int num_joys = joysticksPerFrame[getInputType(currMovieData)];
// save previous state
old_joy[0] = current_joy[0];
old_joy[1] = current_joy[1];
old_joy[2] = current_joy[2];
old_joy[3] = current_joy[3];
oldJoyData[0] = currentJoypadData[0];
oldJoyData[1] = currentJoypadData[1];
oldJoyData[2] = currentJoypadData[2];
oldJoyData[3] = currentJoypadData[3];
// fill current_joy data for Piano Roll header lights
uint32 joypads = GetGamepadPressedImmediate();
current_joy[0] = (joypads & 0xFF);
current_joy[1] = ((joypads >> 8) & 0xFF);
current_joy[2] = ((joypads >> 16) & 0xFF);
current_joy[3] = ((joypads >> 24) & 0xFF);
currentJoypadData[0] = (joypads & 0xFF);
currentJoypadData[1] = ((joypads >> 8) & 0xFF);
currentJoypadData[2] = ((joypads >> 16) & 0xFF);
currentJoypadData[3] = ((joypads >> 24) & 0xFF);
// filter out joysticks that should not be recorded (according to multitrack_recording_joypad)
if (multitrack_recording_joypad != MULTITRACK_RECORDING_ALL)
if (multitrackRecordingJoypadNumber != MULTITRACK_RECORDING_ALL)
{
int joy = multitrack_recording_joypad - 1;
int joy = multitrackRecordingJoypadNumber - 1;
// substitute target joypad with 1p joypad
if (multitrack_recording_joypad > MULTITRACK_RECORDING_1P && taseditor_config.use_1p_rec)
current_joy[joy] = current_joy[0];
if (multitrackRecordingJoypadNumber > MULTITRACK_RECORDING_1P && taseditorConfig.use1PKeysForAllSingleRecordings)
currentJoypadData[joy] = currentJoypadData[0];
// clear all other joypads (pressing them does not count)
for (int i = 0; i < num_joys; ++i)
if (i != joy)
current_joy[i] = 0;
currentJoypadData[i] = 0;
}
// call ColumnSet if needed
if (taseditor_config.columnset_by_keys && movie_readonly && taseditor_window.TASEditor_focus)
if (taseditorConfig.useInputKeysForColumnSet && movie_readonly && taseditorWindow.TASEditorIsInFocus)
{
// if Ctrl or Shift is held, do not call ColumnSet, because maybe this is accelerator
if ((GetAsyncKeyState(VK_CONTROL) >= 0) && (GetAsyncKeyState(VK_SHIFT) >= 0))
@ -194,113 +194,113 @@ void RECORDER::update()
for (int button = 0; button < NUM_JOYPAD_BUTTONS; ++button)
{
// if the button was pressed right now
if ((current_joy[joy] & (1 << button)) && !(old_joy[joy] & (1 << button)))
piano_roll.ColumnSet(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, alt_pressed);
if ((currentJoypadData[joy] & (1 << button)) && !(oldJoyData[joy] & (1 << button)))
pianoRoll.handleColumnSet(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, alt_pressed);
}
}
}
}
}
// ------------------------------------------------------------------------------------
void RECORDER::UncheckRecordingRadioButtons()
void RECORDER::uncheckRecordingRadioButtons()
{
Button_SetCheck(hwndRB_RecAll, BST_UNCHECKED);
Button_SetCheck(hwndRB_Rec1P, BST_UNCHECKED);
Button_SetCheck(hwndRB_Rec2P, BST_UNCHECKED);
Button_SetCheck(hwndRB_Rec3P, BST_UNCHECKED);
Button_SetCheck(hwndRB_Rec4P, BST_UNCHECKED);
Button_SetCheck(hwndRadioButtonRecordAll, BST_UNCHECKED);
Button_SetCheck(hwndRadioButtonRecord1P, BST_UNCHECKED);
Button_SetCheck(hwndRadioButtonRecord2P, BST_UNCHECKED);
Button_SetCheck(hwndRadioButtonRecord3P, BST_UNCHECKED);
Button_SetCheck(hwndRadioButtonRecord4P, BST_UNCHECKED);
}
void RECORDER::RecheckRecordingRadioButtons()
void RECORDER::recheckRecordingRadioButtons()
{
old_multitrack_recording_joypad = multitrack_recording_joypad;
switch(multitrack_recording_joypad)
oldMultitrackRecordingJoypadNumber = multitrackRecordingJoypadNumber;
switch(multitrackRecordingJoypadNumber)
{
case MULTITRACK_RECORDING_ALL:
Button_SetCheck(hwndRB_RecAll, BST_CHECKED);
Button_SetCheck(hwndRadioButtonRecordAll, BST_CHECKED);
break;
case MULTITRACK_RECORDING_1P:
Button_SetCheck(hwndRB_Rec1P, BST_CHECKED);
Button_SetCheck(hwndRadioButtonRecord1P, BST_CHECKED);
break;
case MULTITRACK_RECORDING_2P:
Button_SetCheck(hwndRB_Rec2P, BST_CHECKED);
Button_SetCheck(hwndRadioButtonRecord2P, BST_CHECKED);
break;
case MULTITRACK_RECORDING_3P:
Button_SetCheck(hwndRB_Rec3P, BST_CHECKED);
Button_SetCheck(hwndRadioButtonRecord3P, BST_CHECKED);
break;
case MULTITRACK_RECORDING_4P:
Button_SetCheck(hwndRB_Rec4P, BST_CHECKED);
Button_SetCheck(hwndRadioButtonRecord4P, BST_CHECKED);
break;
default:
multitrack_recording_joypad = MULTITRACK_RECORDING_ALL;
Button_SetCheck(hwndRB_RecAll, BST_CHECKED);
multitrackRecordingJoypadNumber = MULTITRACK_RECORDING_ALL;
Button_SetCheck(hwndRadioButtonRecordAll, BST_CHECKED);
break;
}
}
void RECORDER::InputChanged()
void RECORDER::recordInput()
{
bool changes_made = false;
uint32 joypad_diff_bits = 0;
int num_joys = joysticks_per_frame[GetInputType(currMovieData)];
int num_joys = joysticksPerFrame[getInputType(currMovieData)];
// take previous values from current snapshot, new Input from current movie
for (int i = 0; i < num_joys; ++i)
{
old_joy[i] = history.GetCurrentSnapshot().inputlog.GetJoystickInfo(currFrameCounter, i);
if (!taseditor_config.pattern_recording || editor.autofire_patterns[old_current_pattern][pattern_offset])
new_joy[i] = currMovieData.records[currFrameCounter].joysticks[i];
oldJoyData[i] = history.getCurrentSnapshot().inputlog.getJoystickData(currFrameCounter, i);
if (!taseditorConfig.recordingUsePattern || editor.patterns[oldCurrentPattern][patternOffset])
newJoyData[i] = currMovieData.records[currFrameCounter].joysticks[i];
else
new_joy[i] = 0; // blank
newJoyData[i] = 0; // blank
}
if (taseditor_config.pattern_recording)
if (taseditorConfig.recordingUsePattern)
// postpone incrementing pattern_offset to the end of the frame (when lagFlag will be known)
must_increase_pattern_offset = true;
mustIncreasePatternOffset = true;
// combine old and new data (superimpose) and filter out joystics that should not be recorded
if (multitrack_recording_joypad == MULTITRACK_RECORDING_ALL)
if (multitrackRecordingJoypadNumber == MULTITRACK_RECORDING_ALL)
{
for (int i = num_joys-1; i >= 0; i--)
{
// superimpose (bitwise OR) if needed
if (taseditor_config.superimpose == SUPERIMPOSE_CHECKED || (taseditor_config.superimpose == SUPERIMPOSE_INDETERMINATE && new_joy[i] == 0))
new_joy[i] |= old_joy[i];
if (taseditorConfig.superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig.superimpose == SUPERIMPOSE_INDETERMINATE && newJoyData[i] == 0))
newJoyData[i] |= oldJoyData[i];
// change this joystick
currMovieData.records[currFrameCounter].joysticks[i] = new_joy[i];
if (new_joy[i] != old_joy[i])
currMovieData.records[currFrameCounter].joysticks[i] = newJoyData[i];
if (newJoyData[i] != oldJoyData[i])
{
changes_made = true;
joypad_diff_bits |= (1 << (i + 1)); // bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
// set lights for changed buttons
for (int button = 0; button < NUM_JOYPAD_BUTTONS; ++button)
if ((new_joy[i] & (1 << button)) && !(old_joy[i] & (1 << button)))
piano_roll.SetHeaderColumnLight(COLUMN_JOYPAD1_A + i * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
if ((newJoyData[i] & (1 << button)) && !(oldJoyData[i] & (1 << button)))
pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + i * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
}
}
} else
{
int joy = multitrack_recording_joypad - 1;
int joy = multitrackRecordingJoypadNumber - 1;
// substitute target joypad with 1p joypad
if (multitrack_recording_joypad > MULTITRACK_RECORDING_1P && taseditor_config.use_1p_rec)
new_joy[joy] = new_joy[0];
if (multitrackRecordingJoypadNumber > MULTITRACK_RECORDING_1P && taseditorConfig.use1PKeysForAllSingleRecordings)
newJoyData[joy] = newJoyData[0];
// superimpose (bitwise OR) if needed
if (taseditor_config.superimpose == SUPERIMPOSE_CHECKED || (taseditor_config.superimpose == SUPERIMPOSE_INDETERMINATE && new_joy[joy] == 0))
new_joy[joy] |= old_joy[joy];
if (taseditorConfig.superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig.superimpose == SUPERIMPOSE_INDETERMINATE && newJoyData[joy] == 0))
newJoyData[joy] |= oldJoyData[joy];
// other joysticks should not be changed
for (int i = num_joys-1; i >= 0; i--)
currMovieData.records[currFrameCounter].joysticks[i] = old_joy[i]; // revert to old
currMovieData.records[currFrameCounter].joysticks[i] = oldJoyData[i]; // revert to old
// change only this joystick
currMovieData.records[currFrameCounter].joysticks[joy] = new_joy[joy];
if (new_joy[joy] != old_joy[joy])
currMovieData.records[currFrameCounter].joysticks[joy] = newJoyData[joy];
if (newJoyData[joy] != oldJoyData[joy])
{
changes_made = true;
joypad_diff_bits |= (1 << (joy + 1)); // bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
// set lights for changed buttons
for (int button = 0; button < NUM_JOYPAD_BUTTONS; ++button)
if ((new_joy[joy] & (1 << button)) && !(old_joy[joy] & (1 << button)))
piano_roll.SetHeaderColumnLight(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
if ((newJoyData[joy] & (1 << button)) && !(oldJoyData[joy] & (1 << button)))
pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
}
}
// check if new commands were recorded
if (currMovieData.records[currFrameCounter].commands != history.GetCurrentSnapshot().inputlog.GetCommandsInfo(currFrameCounter))
if (currMovieData.records[currFrameCounter].commands != history.getCurrentSnapshot().inputlog.getCommandsData(currFrameCounter))
{
changes_made = true;
joypad_diff_bits |= 1; // bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
@ -309,18 +309,18 @@ void RECORDER::InputChanged()
// register changes
if (changes_made)
{
history.RegisterRecording(currFrameCounter, joypad_diff_bits);
greenzone.Invalidate(currFrameCounter);
history.registerRecording(currFrameCounter, joypad_diff_bits);
greenzone.invalidate(currFrameCounter);
}
}
// getters
const char* RECORDER::GetRecordingMode()
const char* RECORDER::getRecordingMode()
{
return recordingModes[multitrack_recording_joypad];
return recordingModes[multitrackRecordingJoypadNumber];
}
const char* RECORDER::GetRecordingCaption()
const char* RECORDER::getRecordingCaption()
{
return recordingCaptions[multitrack_recording_joypad];
return recordingCaptions[multitrackRecordingJoypadNumber];
}

View File

@ -1,6 +1,6 @@
// Specification file for RECORDER class
enum
enum MULTITRACK_RECORDING_MODES
{
MULTITRACK_RECORDING_ALL = 0,
MULTITRACK_RECORDING_1P = 1,
@ -9,7 +9,7 @@ enum
MULTITRACK_RECORDING_4P = 4,
};
enum
enum SUPERIMPOSE_OPTIONS
{
SUPERIMPOSE_UNCHECKED = 0,
SUPERIMPOSE_CHECKED = 1,
@ -24,28 +24,28 @@ public:
void reset();
void update();
void UncheckRecordingRadioButtons();
void RecheckRecordingRadioButtons();
void uncheckRecordingRadioButtons();
void recheckRecordingRadioButtons();
void InputChanged();
void recordInput();
const char* GetRecordingMode();
const char* GetRecordingCaption();
const char* getRecordingMode();
const char* getRecordingCaption();
int multitrack_recording_joypad;
int pattern_offset;
std::vector<uint8> current_joy;
bool state_was_loaded_in_readwrite_mode;
int multitrackRecordingJoypadNumber;
int patternOffset;
std::vector<uint8> currentJoypadData;
bool stateWasLoadedInReadWriteMode;
private:
int old_multitrack_recording_joypad;
int old_current_pattern, old_pattern_offset;
bool must_increase_pattern_offset;
bool old_movie_readonly;
int oldMultitrackRecordingJoypadNumber;
int oldCurrentPattern, oldPatternOffset;
bool oldStateOfMovieReadonly;
bool mustIncreasePatternOffset;
HWND hwndRecCheckbox, hwndRB_RecAll, hwndRB_Rec1P, hwndRB_Rec2P, hwndRB_Rec3P, hwndRB_Rec4P;
HWND hwndRecordingCheckbox, hwndRadioButtonRecordAll, hwndRadioButtonRecord1P, hwndRadioButtonRecord2P, hwndRadioButtonRecord3P, hwndRadioButtonRecord4P;
// temps
std::vector<uint8> old_joy;
std::vector<uint8> new_joy;
std::vector<uint8> oldJoyData;
std::vector<uint8> newJoyData;
};

View File

@ -25,15 +25,15 @@ Selection - Manager of selections
#include "taseditor_project.h"
#include "../taseditor.h"
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern MARKERS_MANAGER markers_manager;
extern PIANO_ROLL piano_roll;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern MARKERS_MANAGER markersManager;
extern PIANO_ROLL pianoRoll;
extern SPLICER splicer;
extern EDITOR editor;
extern GREENZONE greenzone;
extern int joysticks_per_frame[NUM_SUPPORTED_INPUT_TYPES];
extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
LRESULT APIENTRY LowerMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
WNDPROC selectionMarkerEdit_oldWndproc;
@ -49,199 +49,199 @@ SELECTION::SELECTION()
void SELECTION::init()
{
hwndPrevMarker = GetDlgItem(taseditor_window.hwndTasEditor, TASEDITOR_PREV_MARKER);
hwndNextMarker = GetDlgItem(taseditor_window.hwndTasEditor, TASEDITOR_NEXT_MARKER);
hwndSelectionMarker = GetDlgItem(taseditor_window.hwndTasEditor, IDC_SELECTION_MARKER);
SendMessage(hwndSelectionMarker, WM_SETFONT, (WPARAM)piano_roll.hMarkersFont, 0);
hwndSelectionMarkerEdit = GetDlgItem(taseditor_window.hwndTasEditor, IDC_SELECTION_MARKER_EDIT);
SendMessage(hwndSelectionMarkerEdit, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
SendMessage(hwndSelectionMarkerEdit, WM_SETFONT, (WPARAM)piano_roll.hMarkersEditFont, 0);
hwndPreviousMarkerButton = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_PREV_MARKER);
hwndNextMarkerButton = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_NEXT_MARKER);
hwndSelectionMarkerNumber = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_SELECTION_MARKER);
SendMessage(hwndSelectionMarkerNumber, WM_SETFONT, (WPARAM)pianoRoll.hMarkersFont, 0);
hwndSelectionMarkerEditField = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_SELECTION_MARKER_EDIT);
SendMessage(hwndSelectionMarkerEditField, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
SendMessage(hwndSelectionMarkerEditField, WM_SETFONT, (WPARAM)pianoRoll.hMarkersEditFont, 0);
// subclass the edit control
selectionMarkerEdit_oldWndproc = (WNDPROC)SetWindowLong(hwndSelectionMarkerEdit, GWL_WNDPROC, (LONG)LowerMarkerEditWndProc);
selectionMarkerEdit_oldWndproc = (WNDPROC)SetWindowLong(hwndSelectionMarkerEditField, GWL_WNDPROC, (LONG)LowerMarkerEditWndProc);
reset();
}
void SELECTION::free()
{
// clear history
selections_history.resize(0);
history_total_items = 0;
temp_selection.clear();
rowsSelectionHistory.resize(0);
historyTotalItems = 0;
tempRowsSelection.clear();
}
void SELECTION::reset()
{
free();
// init vars
shown_marker = 0;
last_selection_beginning = -1;
history_size = taseditor_config.undo_levels + 1;
selections_history.resize(history_size);
history_start_pos = 0;
history_cursor_pos = -1;
displayedMarkerNumber = 0;
lastSelectionBeginning = -1;
historySize = taseditorConfig.maxUndoLevels + 1;
rowsSelectionHistory.resize(historySize);
historyStartPos = 0;
historyCursorPos = -1;
// create initial selection
AddNewSelectionToHistory();
track_selection_changes = true;
addNewSelectionToHistory();
trackSelectionChanges = true;
reset_vars();
}
void SELECTION::reset_vars()
{
old_prev_marker_button_state = prev_marker_button_state = false;
old_next_marker_button_state = next_marker_button_state = false;
must_find_current_marker = true;
previousMarkerButtonOldState = previousMarkerButtonState = false;
nextMarkerButtonOldState = nextMarkerButtonState = false;
mustFindCurrentMarker = true;
}
void SELECTION::update()
{
UpdateSelectionSize();
updateSelectionSize();
// update << and >> buttons
old_prev_marker_button_state = prev_marker_button_state;
prev_marker_button_state = ((Button_GetState(hwndPrevMarker) & BST_PUSHED) != 0);
if (prev_marker_button_state)
previousMarkerButtonOldState = previousMarkerButtonState;
previousMarkerButtonState = ((Button_GetState(hwndPreviousMarkerButton) & BST_PUSHED) != 0);
if (previousMarkerButtonState)
{
if (!old_prev_marker_button_state)
if (!previousMarkerButtonOldState)
{
button_hold_time = clock();
JumpPrevMarker();
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
buttonHoldTimer = clock();
jumpToPreviousMarker();
} else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock())
{
JumpPrevMarker();
jumpToPreviousMarker();
}
}
old_next_marker_button_state = next_marker_button_state;
next_marker_button_state = (Button_GetState(hwndNextMarker) & BST_PUSHED) != 0;
if (next_marker_button_state)
nextMarkerButtonOldState = nextMarkerButtonState;
nextMarkerButtonState = (Button_GetState(hwndNextMarkerButton) & BST_PUSHED) != 0;
if (nextMarkerButtonState)
{
if (!old_next_marker_button_state)
if (!nextMarkerButtonOldState)
{
button_hold_time = clock();
JumpNextMarker();
} else if (button_hold_time + HOLD_REPEAT_DELAY < clock())
buttonHoldTimer = clock();
jumpToNextMarker();
} else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock())
{
JumpNextMarker();
jumpToNextMarker();
}
}
// track changes of Selection beginning (Selection cursor)
if (last_selection_beginning != GetCurrentSelectionBeginning())
if (lastSelectionBeginning != getCurrentRowsSelectionBeginning())
{
last_selection_beginning = GetCurrentSelectionBeginning();
must_find_current_marker = true;
lastSelectionBeginning = getCurrentRowsSelectionBeginning();
mustFindCurrentMarker = true;
}
// update "Selection's Marker text" if needed
if (must_find_current_marker)
if (mustFindCurrentMarker)
{
markers_manager.UpdateMarkerNote();
shown_marker = markers_manager.GetMarkerUp(last_selection_beginning);
RedrawMarker();
must_find_current_marker = false;
markersManager.updateEditedMarkerNote();
displayedMarkerNumber = markersManager.getMarkerAboveFrame(lastSelectionBeginning);
redrawMarkerData();
mustFindCurrentMarker = false;
}
}
void SELECTION::UpdateSelectionSize()
void SELECTION::updateSelectionSize()
{
// keep Selection within Piano Roll limits
if (CurrentSelection().size())
if (getCurrentRowsSelection().size())
{
int delete_index;
int movie_size = currMovieData.getNumRecords();
while (true)
{
delete_index = *CurrentSelection().rbegin();
delete_index = *getCurrentRowsSelection().rbegin();
if (delete_index < movie_size) break;
CurrentSelection().erase(delete_index);
if (!CurrentSelection().size()) break;
getCurrentRowsSelection().erase(delete_index);
if (!getCurrentRowsSelection().size()) break;
}
}
}
void SELECTION::HistorySizeChanged()
void SELECTION::updateHistoryLogSize()
{
int new_history_size = taseditor_config.undo_levels + 1;
std::vector<SelectionFrames> new_selections_history(new_history_size);
int pos = history_cursor_pos, source_pos = history_cursor_pos;
int new_history_size = taseditorConfig.maxUndoLevels + 1;
std::vector<RowsSelection> new_selections_history(new_history_size);
int pos = historyCursorPos, source_pos = historyCursorPos;
if (pos >= new_history_size)
pos = new_history_size - 1;
int new_history_cursor_pos = pos;
// copy old "undo" snapshots
while (pos >= 0)
{
new_selections_history[pos] = selections_history[(history_start_pos + source_pos) % history_size];
new_selections_history[pos] = rowsSelectionHistory[(historyStartPos + source_pos) % historySize];
pos--;
source_pos--;
}
// copy old "redo" snapshots
int num_redo_snapshots = history_total_items - (history_cursor_pos + 1);
int num_redo_snapshots = historyTotalItems - (historyCursorPos + 1);
int space_available = new_history_size - (new_history_cursor_pos + 1);
int i = (num_redo_snapshots <= space_available) ? num_redo_snapshots : space_available;
int new_history_total_items = new_history_cursor_pos + i + 1;
for (; i > 0; i--)
new_selections_history[new_history_cursor_pos + i] = selections_history[(history_start_pos + history_cursor_pos + i) % history_size];
new_selections_history[new_history_cursor_pos + i] = rowsSelectionHistory[(historyStartPos + historyCursorPos + i) % historySize];
// finish
selections_history = new_selections_history;
history_size = new_history_size;
history_start_pos = 0;
history_cursor_pos = new_history_cursor_pos;
history_total_items = new_history_total_items;
rowsSelectionHistory = new_selections_history;
historySize = new_history_size;
historyStartPos = 0;
historyCursorPos = new_history_cursor_pos;
historyTotalItems = new_history_total_items;
}
void SELECTION::RedrawMarker()
void SELECTION::redrawMarkerData()
{
// redraw Marker num
char new_text[MAX_NOTE_LEN] = {0};
if (shown_marker <= 9999) // if there's too many digits in the number then don't show the word "Marker" before the number
if (displayedMarkerNumber <= 9999) // if there's too many digits in the number then don't show the word "Marker" before the number
strcpy(new_text, lowerMarkerText);
char num[11];
_itoa(shown_marker, num, 10);
_itoa(displayedMarkerNumber, num, 10);
strcat(new_text, num);
strcat(new_text, " ");
SetWindowText(hwndSelectionMarker, new_text);
SetWindowText(hwndSelectionMarkerNumber, new_text);
// change Marker Note
strcpy(new_text, markers_manager.GetNote(shown_marker).c_str());
SetWindowText(hwndSelectionMarkerEdit, new_text);
strcpy(new_text, markersManager.getNoteCopy(displayedMarkerNumber).c_str());
SetWindowText(hwndSelectionMarkerEditField, new_text);
}
void SELECTION::JumpPrevMarker(int speed)
void SELECTION::jumpToPreviousMarker(int speed)
{
// if nothing is selected, consider Playback cursor as current selection
int index = GetCurrentSelectionBeginning();
int index = getCurrentRowsSelectionBeginning();
if (index < 0) index = currFrameCounter;
// jump trough "speed" amount of previous Markers
while (speed > 0)
{
for (index--; index >= 0; index--)
if (markers_manager.GetMarker(index)) break;
if (markersManager.getMarkerAtFrame(index)) break;
speed--;
}
if (index >= 0)
JumpToFrame(index); // jump to the Marker
jumpToFrame(index); // jump to the Marker
else
JumpToFrame(0); // jump to the beginning of Piano Roll
jumpToFrame(0); // jump to the beginning of Piano Roll
}
void SELECTION::JumpNextMarker(int speed)
void SELECTION::jumpToNextMarker(int speed)
{
// if nothing is selected, consider Playback cursor as current selection
int index = GetCurrentSelectionBeginning();
int index = getCurrentRowsSelectionBeginning();
if (index < 0) index = currFrameCounter;
int last_frame = currMovieData.getNumRecords() - 1; // the end of Piano Roll
// jump trough "speed" amount of previous Markers
while (speed > 0)
{
for (++index; index <= last_frame; ++index)
if (markers_manager.GetMarker(index)) break;
if (markersManager.getMarkerAtFrame(index)) break;
speed--;
}
if (index <= last_frame)
JumpToFrame(index); // jump to Marker
jumpToFrame(index); // jump to Marker
else
JumpToFrame(last_frame); // jump to the end of Piano Roll
jumpToFrame(last_frame); // jump to the end of Piano Roll
}
void SELECTION::JumpToFrame(int frame)
void SELECTION::jumpToFrame(int frame)
{
ClearSelection();
SetRowSelection(frame);
piano_roll.FollowSelection();
clearAllRowsSelection();
setRowSelection(frame);
pianoRoll.followSelection();
}
// ----------------------------------------------------------
void SELECTION::save(EMUFILE *os, bool really_save)
@ -251,15 +251,15 @@ void 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);
write32le(historyCursorPos, os);
write32le(historyTotalItems, os);
// write selections starting from history_start_pos
for (int i = 0; i < history_total_items; ++i)
for (int i = 0; i < historyTotalItems; ++i)
{
saveSelection(selections_history[(history_start_pos + i) % history_size], os);
saveSelection(rowsSelectionHistory[(historyStartPos + i) % historySize], os);
}
// write clipboard_selection
saveSelection(splicer.GetClipboardSelection(), os);
saveSelection(splicer.getClipboardSelection(), os);
} else
{
// write "SELECTIOX" string
@ -289,45 +289,45 @@ bool SELECTION::load(EMUFILE *is, unsigned int offset)
}
if (strcmp(selection_save_id, save_id)) goto error; // string is not valid
// read vars
if (!read32le(&history_cursor_pos, is)) goto error;
if (!read32le(&history_total_items, is)) goto error;
if (history_cursor_pos > history_total_items) goto error;
history_start_pos = 0;
if (!read32le(&historyCursorPos, is)) goto error;
if (!read32le(&historyTotalItems, is)) goto error;
if (historyCursorPos > historyTotalItems) goto error;
historyStartPos = 0;
// read selections
int i;
int total = history_total_items;
if (history_total_items > history_size)
int total = historyTotalItems;
if (historyTotalItems > historySize)
{
// user can't afford that much undo levels, skip some selections
int num_selections_to_skip = history_total_items - history_size;
int num_selections_to_skip = historyTotalItems - historySize;
// first try to skip selections over history_cursor_pos (future selections), because "redo" is less important than "undo"
int num_redo_selections = history_total_items-1 - history_cursor_pos;
int num_redo_selections = historyTotalItems-1 - historyCursorPos;
if (num_selections_to_skip >= num_redo_selections)
{
// skip all redo selections
history_total_items = history_cursor_pos+1;
historyTotalItems = historyCursorPos+1;
num_selections_to_skip -= num_redo_selections;
// and still need to skip some undo selections
for (i = 0; i < num_selections_to_skip; ++i)
if (skiploadSelection(is)) goto error;
if (skipLoadSelection(is)) goto error;
total -= num_selections_to_skip;
history_cursor_pos -= num_selections_to_skip;
historyCursorPos -= num_selections_to_skip;
}
history_total_items -= num_selections_to_skip;
historyTotalItems -= num_selections_to_skip;
}
// load selections
for (i = 0; i < history_total_items; ++i)
for (i = 0; i < historyTotalItems; ++i)
{
if (loadSelection(selections_history[i], is)) goto error;
if (loadSelection(rowsSelectionHistory[i], is)) goto error;
}
// skip redo selections if needed
for (; i < total; ++i)
if (skiploadSelection(is)) goto error;
if (skipLoadSelection(is)) goto error;
// read clipboard_selection
if (loadSelection(splicer.GetClipboardSelection(), is)) goto error;
if (loadSelection(splicer.getClipboardSelection(), is)) goto error;
// all ok
EnforceSelectionToList();
enforceRowsSelectionToList();
reset_vars();
return false;
error:
@ -336,16 +336,16 @@ error:
return true;
}
void SELECTION::saveSelection(SelectionFrames& selection, EMUFILE *os)
void SELECTION::saveSelection(RowsSelection& selection, EMUFILE *os)
{
write32le(selection.size(), os);
if (selection.size())
{
for(SelectionFrames::iterator it(selection.begin()); it != selection.end(); it++)
for(RowsSelection::iterator it(selection.begin()); it != selection.end(); it++)
write32le(*it, os);
}
}
bool SELECTION::loadSelection(SelectionFrames& selection, EMUFILE *is)
bool SELECTION::loadSelection(RowsSelection& selection, EMUFILE *is)
{
int temp_int, temp_size;
if (!read32le(&temp_size, is)) return true;
@ -357,7 +357,7 @@ bool SELECTION::loadSelection(SelectionFrames& selection, EMUFILE *is)
}
return false;
}
bool SELECTION::skiploadSelection(EMUFILE *is)
bool SELECTION::skipLoadSelection(EMUFILE *is)
{
int temp_size;
if (!read32le(&temp_size, is)) return true;
@ -366,21 +366,21 @@ bool SELECTION::skiploadSelection(EMUFILE *is)
}
// ----------------------------------------------------------
// used to track selection
void SELECTION::ItemRangeChanged(NMLVODSTATECHANGE* info)
void SELECTION::noteThatItemRangeChanged(NMLVODSTATECHANGE* info)
{
bool ON = !(info->uOldState & LVIS_SELECTED) && (info->uNewState & LVIS_SELECTED);
bool OFF = (info->uOldState & LVIS_SELECTED) && !(info->uNewState & LVIS_SELECTED);
if (ON)
for(int i = info->iFrom; i <= info->iTo; ++i)
CurrentSelection().insert(i);
getCurrentRowsSelection().insert(i);
else
for(int i = info->iFrom; i <= info->iTo; ++i)
CurrentSelection().erase(i);
getCurrentRowsSelection().erase(i);
splicer.must_redraw_selection_text = true;
splicer.mustRedrawInfoAboutSelection = true;
}
void SELECTION::ItemChanged(NMLISTVIEW* info)
void SELECTION::noteThatItemChanged(NMLISTVIEW* info)
{
int item = info->iItem;
@ -393,169 +393,174 @@ void SELECTION::ItemChanged(NMLISTVIEW* info)
if (OFF)
{
// clear all (actually add new empty Selection to history)
if (CurrentSelection().size() && track_selection_changes)
AddNewSelectionToHistory();
if (getCurrentRowsSelection().size() && trackSelectionChanges)
addNewSelectionToHistory();
} else if (ON)
{
// select all
for(int i = currMovieData.getNumRecords() - 1; i >= 0; i--)
CurrentSelection().insert(i);
getCurrentRowsSelection().insert(i);
}
} else
{
if (ON)
CurrentSelection().insert(item);
getCurrentRowsSelection().insert(item);
else if (OFF)
CurrentSelection().erase(item);
getCurrentRowsSelection().erase(item);
}
splicer.must_redraw_selection_text = true;
splicer.mustRedrawInfoAboutSelection = true;
}
// ----------------------------------------------------------
void SELECTION::AddNewSelectionToHistory()
void SELECTION::addNewSelectionToHistory()
{
// create new empty selection
SelectionFrames selectionFrames;
RowsSelection selectionFrames;
// increase current position
// history uses conveyor of selections (vector with fixed size) to avoid resizing
if (history_cursor_pos+1 >= history_size)
// history uses ring buffer (vector with fixed size) to avoid resizing
if (historyCursorPos+1 >= historySize)
{
// reached the end of available history_size - move history_start_pos (thus deleting oldest selection)
history_cursor_pos = history_size-1;
history_start_pos = (history_start_pos + 1) % history_size;
historyCursorPos = historySize-1;
historyStartPos = (historyStartPos + 1) % historySize;
} else
{
// didn't reach the end of history yet
history_cursor_pos++;
if (history_cursor_pos >= history_total_items)
history_total_items = history_cursor_pos+1;
historyCursorPos++;
if (historyCursorPos >= historyTotalItems)
historyTotalItems = historyCursorPos+1;
}
// add
selections_history[(history_start_pos + history_cursor_pos) % history_size] = selectionFrames;
rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize] = selectionFrames;
}
void SELECTION::AddCurrentSelectionToHistory()
void SELECTION::addCurrentSelectionToHistory()
{
// create the copy of current selection
SelectionFrames selectionFrames = selections_history[(history_start_pos + history_cursor_pos) % history_size];
RowsSelection selectionFrames = rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize];
// increase current position
// history uses conveyor of selections (vector with fixed size) to avoid resizing
if (history_cursor_pos+1 >= history_size)
// history uses ring buffer (vector with fixed size) to avoid resizing
if (historyCursorPos+1 >= historySize)
{
// reached the end of available history_size - move history_start_pos (thus deleting oldest selection)
history_cursor_pos = history_size-1;
history_start_pos = (history_start_pos + 1) % history_size;
historyCursorPos = historySize-1;
historyStartPos = (historyStartPos + 1) % historySize;
} else
{
// didn't reach the end of history yet
history_cursor_pos++;
if (history_cursor_pos >= history_total_items)
history_total_items = history_cursor_pos+1;
historyCursorPos++;
if (historyCursorPos >= historyTotalItems)
historyTotalItems = historyCursorPos+1;
}
// add
selections_history[(history_start_pos + history_cursor_pos) % history_size] = selectionFrames;
rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize] = selectionFrames;
}
void SELECTION::JumpInTime(int new_pos)
void SELECTION::jumpInTime(int new_pos)
{
if (new_pos < 0) new_pos = 0; else if (new_pos >= history_total_items) new_pos = history_total_items-1;
if (new_pos == history_cursor_pos) return;
if (new_pos < 0) new_pos = 0; else if (new_pos >= historyTotalItems) new_pos = historyTotalItems-1;
if (new_pos == historyCursorPos) return;
// make jump
history_cursor_pos = new_pos;
historyCursorPos = new_pos;
// update Piano Roll items
EnforceSelectionToList();
enforceRowsSelectionToList();
// also keep Selection within Piano Roll
UpdateSelectionSize();
updateSelectionSize();
}
void SELECTION::undo()
{
JumpInTime(history_cursor_pos - 1);
jumpInTime(historyCursorPos - 1);
}
void SELECTION::redo()
{
JumpInTime(history_cursor_pos + 1);
jumpInTime(historyCursorPos + 1);
}
// ----------------------------------------------------------
bool SELECTION::GetRowSelection(int index)
bool SELECTION::isRowSelected(int index)
{
return ListView_GetItemState(piano_roll.hwndList, index, LVIS_SELECTED) != 0;
/*
if (CurrentSelection().find(frame) == CurrentSelection().end())
return false;
return true;
*/
return ListView_GetItemState(pianoRoll.hwndList, index, LVIS_SELECTED) != 0;
}
void SELECTION::ClearSelection()
void SELECTION::clearAllRowsSelection()
{
ListView_SetItemState(piano_roll.hwndList, -1, 0, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, -1, 0, LVIS_SELECTED);
}
void SELECTION::ClearRowSelection(int index)
void SELECTION::clearSingleRowSelection(int index)
{
ListView_SetItemState(piano_roll.hwndList, index, 0, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, index, 0, LVIS_SELECTED);
}
void SELECTION::ClearRegionSelection(int start, int end)
void SELECTION::clearRegionOfRowsSelection(int start, int end)
{
for (int i = start; i < end; ++i)
ListView_SetItemState(piano_roll.hwndList, i, 0, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, 0, LVIS_SELECTED);
}
void SELECTION::SelectAll()
void SELECTION::selectAllRows()
{
ListView_SetItemState(piano_roll.hwndList, -1, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, -1, LVIS_SELECTED, LVIS_SELECTED);
}
void SELECTION::SetRowSelection(int index)
void SELECTION::setRowSelection(int index)
{
ListView_SetItemState(piano_roll.hwndList, index, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, index, LVIS_SELECTED, LVIS_SELECTED);
}
void SELECTION::SetRegionSelection(int start, int end)
void SELECTION::setRegionOfRowsSelection(int start, int end)
{
for (int i = start; i < end; ++i)
ListView_SetItemState(piano_roll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
}
void SELECTION::SetRegionSelectionPattern(int start, int end)
void SELECTION::setRegionOfRowsSelectionUsingPattern(int start, int end)
{
int pattern_offset = 0, current_pattern = taseditor_config.current_pattern;
int pattern_offset = 0, current_pattern = taseditorConfig.currentPattern;
for (int i = start; i <= end; ++i)
{
// skip lag frames
if (taseditor_config.pattern_skips_lag && greenzone.laglog.GetLagInfoAtFrame(i) == LAGGED_YES)
if (taseditorConfig.autofirePatternSkipsLag && greenzone.lagLog.getLagInfoAtFrame(i) == LAGGED_YES)
continue;
if (editor.autofire_patterns[current_pattern][pattern_offset])
if (editor.patterns[current_pattern][pattern_offset])
{
ListView_SetItemState(piano_roll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
} else
{
ListView_SetItemState(piano_roll.hwndList, i, 0, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, 0, LVIS_SELECTED);
}
pattern_offset++;
if (pattern_offset >= (int)editor.autofire_patterns[current_pattern].size())
pattern_offset -= editor.autofire_patterns[current_pattern].size();
if (pattern_offset >= (int)editor.patterns[current_pattern].size())
pattern_offset -= editor.patterns[current_pattern].size();
}
}
void SELECTION::SelectBetweenMarkers()
void SELECTION::selectAllRowsBetweenMarkers()
{
int center, upper_border, lower_border;
int upper_marker, lower_marker;
int movie_size = currMovieData.getNumRecords();
// if nothing is selected then Playback cursor serves as Selection cursor
if (CurrentSelection().size())
if (getCurrentRowsSelection().size())
{
upper_border = center = *CurrentSelection().begin();
lower_border = *CurrentSelection().rbegin();
upper_border = center = *getCurrentRowsSelection().begin();
lower_border = *getCurrentRowsSelection().rbegin();
} else lower_border = upper_border = center = currFrameCounter;
// find Markers
// searching up starting from center-0
for (upper_marker = center; upper_marker >= 0; upper_marker--)
if (markers_manager.GetMarker(upper_marker)) break;
if (markersManager.getMarkerAtFrame(upper_marker)) break;
// searching down starting from center+1
for (lower_marker = center+1; lower_marker < movie_size; ++lower_marker)
if (markers_manager.GetMarker(lower_marker)) break;
if (markersManager.getMarkerAtFrame(lower_marker)) break;
ClearSelection();
clearAllRowsSelection();
// special case
if (upper_marker == -1 && lower_marker == movie_size)
{
SelectAll();
selectAllRows();
return;
}
@ -566,14 +571,14 @@ void SELECTION::SelectBetweenMarkers()
if (upper_marker < 0) upper_marker = 0;
for (int i = upper_marker; i < lower_marker; ++i)
{
ListView_SetItemState(piano_roll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
}
} else if (upper_border == upper_marker && lower_border == lower_marker-1)
{
// 2 - selected all between Markers and upper Marker selected too: select all between Markers, not including Markers
for (int i = upper_marker+1; i < lower_marker; ++i)
{
ListView_SetItemState(piano_roll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
}
} else if (upper_border == upper_marker+1 && lower_border == lower_marker-1)
{
@ -581,7 +586,7 @@ void SELECTION::SelectBetweenMarkers()
if (lower_marker >= movie_size) lower_marker = movie_size - 1;
for (int i = upper_marker+1; i <= lower_marker; ++i)
{
ListView_SetItemState(piano_roll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
}
} else if (upper_border == upper_marker+1 && lower_border == lower_marker)
{
@ -590,7 +595,7 @@ void SELECTION::SelectBetweenMarkers()
if (lower_marker >= movie_size) lower_marker = movie_size - 1;
for (int i = upper_marker; i <= lower_marker; ++i)
{
ListView_SetItemState(piano_roll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
}
} else
{
@ -598,100 +603,94 @@ void SELECTION::SelectBetweenMarkers()
if (upper_marker < 0) upper_marker = 0;
for (int i = upper_marker; i < lower_marker; ++i)
{
ListView_SetItemState(piano_roll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
}
}
}
void SELECTION::ReselectClipboard()
void SELECTION::reselectClipboard()
{
SelectionFrames clipboard_selection = splicer.GetClipboardSelection();
RowsSelection clipboard_selection = splicer.getClipboardSelection();
if (clipboard_selection.size() == 0) return;
ClearSelection();
CurrentSelection() = clipboard_selection;
EnforceSelectionToList();
clearAllRowsSelection();
getCurrentRowsSelection() = clipboard_selection;
enforceRowsSelectionToList();
// also keep Selection within Piano Roll
UpdateSelectionSize();
updateSelectionSize();
}
void SELECTION::Transpose(int shift)
void SELECTION::transposeVertically(int shift)
{
if (!shift) return;
SelectionFrames* current_selection = MakeStrobe();
RowsSelection* current_selection = getCopyOfCurrentRowsSelection();
if (current_selection->size())
{
ClearSelection();
clearAllRowsSelection();
int pos;
if (shift > 0)
{
int movie_size = currMovieData.getNumRecords();
SelectionFrames::reverse_iterator current_selection_rend(current_selection->rend());
for(SelectionFrames::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
RowsSelection::reverse_iterator current_selection_rend(current_selection->rend());
for(RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
{
pos = (*it) + shift;
if (pos < movie_size)
ListView_SetItemState(piano_roll.hwndList, pos, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, pos, LVIS_SELECTED, LVIS_SELECTED);
}
} else
{
SelectionFrames::iterator current_selection_end(current_selection->end());
for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; it++)
RowsSelection::iterator current_selection_end(current_selection->end());
for(RowsSelection::iterator it(current_selection->begin()); it != current_selection_end; it++)
{
pos = (*it) + shift;
if (pos >= 0)
ListView_SetItemState(piano_roll.hwndList, pos, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, pos, LVIS_SELECTED, LVIS_SELECTED);
}
}
}
}
void SELECTION::EnforceSelectionToList()
void SELECTION::enforceRowsSelectionToList()
{
track_selection_changes = false;
ClearSelection();
for(SelectionFrames::reverse_iterator it(CurrentSelection().rbegin()); it != CurrentSelection().rend(); it++)
trackSelectionChanges = false;
clearAllRowsSelection();
for(RowsSelection::reverse_iterator it(getCurrentRowsSelection().rbegin()); it != getCurrentRowsSelection().rend(); it++)
{
ListView_SetItemState(piano_roll.hwndList, *it, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(pianoRoll.hwndList, *it, LVIS_SELECTED, LVIS_SELECTED);
}
track_selection_changes = true;
trackSelectionChanges = true;
}
// getters
int SELECTION::GetCurrentSelectionSize()
int SELECTION::getCurrentRowsSelectionSize()
{
return selections_history[(history_start_pos + history_cursor_pos) % history_size].size();
return rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize].size();
}
int SELECTION::GetCurrentSelectionBeginning()
int SELECTION::getCurrentRowsSelectionBeginning()
{
if (selections_history[(history_start_pos + history_cursor_pos) % history_size].size())
return *selections_history[(history_start_pos + history_cursor_pos) % history_size].begin();
if (rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize].size())
return *rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize].begin();
else
return -1;
}
int SELECTION::GetCurrentSelectionEnd()
int SELECTION::getCurrentRowsSelectionEnd()
{
if (selections_history[(history_start_pos + history_cursor_pos) % history_size].size())
return *selections_history[(history_start_pos + history_cursor_pos) % history_size].rbegin();
if (rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize].size())
return *rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize].rbegin();
else
return -1;
}
bool SELECTION::CheckFrameSelected(int frame)
{
if (CurrentSelection().find(frame) == CurrentSelection().end())
return false;
return true;
}
SelectionFrames* SELECTION::MakeStrobe()
RowsSelection* SELECTION::getCopyOfCurrentRowsSelection()
{
// copy current Selection to temp_selection
temp_selection = selections_history[(history_start_pos + history_cursor_pos) % history_size];
return &temp_selection;
tempRowsSelection = rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize];
return &tempRowsSelection;
}
// this getter is private
SelectionFrames& SELECTION::CurrentSelection()
RowsSelection& SELECTION::getCurrentRowsSelection()
{
return selections_history[(history_start_pos + history_cursor_pos) % history_size];
return rowsSelectionHistory[(historyStartPos + historyCursorPos) % historySize];
}
// -------------------------------------------------------------------------
LRESULT APIENTRY LowerMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
@ -702,50 +701,50 @@ LRESULT APIENTRY LowerMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR
{
case WM_SETFOCUS:
{
markers_manager.marker_note_edit = MARKER_NOTE_EDIT_LOWER;
markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_LOWER;
// enable editing
SendMessage(selection.hwndSelectionMarkerEdit, EM_SETREADONLY, false, 0);
SendMessage(selection.hwndSelectionMarkerEditField, EM_SETREADONLY, false, 0);
// disable FCEUX keyboard
ClearTaseditorInput();
disableGeneralKeyboardInput();
break;
}
case WM_KILLFOCUS:
{
if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_LOWER)
if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_LOWER)
{
markers_manager.UpdateMarkerNote();
markers_manager.marker_note_edit = MARKER_NOTE_EDIT_NONE;
markersManager.updateEditedMarkerNote();
markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_NONE;
}
// disable editing (make the bg grayed)
SendMessage(selection.hwndSelectionMarkerEdit, EM_SETREADONLY, true, 0);
SendMessage(selection.hwndSelectionMarkerEditField, EM_SETREADONLY, true, 0);
// enable FCEUX keyboard
if (taseditor_window.TASEditor_focus)
SetTaseditorInput();
if (taseditorWindow.TASEditorIsInFocus)
enableGeneralKeyboardInput();
break;
}
case WM_CHAR:
case WM_KEYDOWN:
{
if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_LOWER)
if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_LOWER)
{
switch(wParam)
{
case VK_ESCAPE:
// revert text to original note text
SetWindowText(selection.hwndSelectionMarkerEdit, markers_manager.GetNote(selection.shown_marker).c_str());
SetFocus(piano_roll.hwndList);
SetWindowText(selection.hwndSelectionMarkerEditField, markersManager.getNoteCopy(selection.displayedMarkerNumber).c_str());
SetFocus(pianoRoll.hwndList);
return 0;
case VK_RETURN:
// exit and save text changes
SetFocus(piano_roll.hwndList);
SetFocus(pianoRoll.hwndList);
return 0;
case VK_TAB:
{
// switch to upper edit control (also exit and save text changes)
SetFocus(playback.hwndPlaybackMarkerEdit);
SetFocus(playback.hwndPlaybackMarkerEditField);
// scroll to the Marker
if (taseditor_config.follow_note_context)
piano_roll.FollowMarker(playback.shown_marker);
if (taseditorConfig.followMarkerNoteContext)
pianoRoll.followMarker(playback.displayedMarkerNumber);
return 0;
}
}
@ -755,15 +754,15 @@ LRESULT APIENTRY LowerMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
playback.MiddleButtonClick();
playback.handleMiddleButtonClick();
return 0;
}
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
{
// scroll to the Marker
if (taseditor_config.follow_note_context)
piano_roll.FollowMarker(selection.shown_marker);
if (taseditorConfig.followMarkerNoteContext)
pianoRoll.followMarker(selection.displayedMarkerNumber);
break;
}
}

View File

@ -1,7 +1,7 @@
// Specification file for SELECTION class
#include <set>
typedef std::set<int> SelectionFrames;
typedef std::set<int> RowsSelection;
#define SELECTION_ID_LEN 10
@ -15,81 +15,82 @@ public:
void reset_vars();
void update();
void UpdateSelectionSize();
void updateSelectionSize();
void HistorySizeChanged();
void updateHistoryLogSize();
void RedrawMarker();
void redrawMarkerData();
void save(EMUFILE *os, bool really_save = true);
bool load(EMUFILE *is, unsigned int offset);
void saveSelection(SelectionFrames& selection, EMUFILE *os);
bool loadSelection(SelectionFrames& selection, EMUFILE *is);
bool skiploadSelection(EMUFILE *is);
void saveSelection(RowsSelection& selection, EMUFILE *os);
bool loadSelection(RowsSelection& selection, EMUFILE *is);
bool skipLoadSelection(EMUFILE *is);
void ItemRangeChanged(NMLVODSTATECHANGE* info);
void ItemChanged(NMLISTVIEW* info);
void noteThatItemRangeChanged(NMLVODSTATECHANGE* info);
void noteThatItemChanged(NMLISTVIEW* info);
void AddNewSelectionToHistory();
void AddCurrentSelectionToHistory();
void addNewSelectionToHistory();
void addCurrentSelectionToHistory();
void undo();
void redo();
bool GetRowSelection(int index);
bool isRowSelected(int index);
void ClearSelection();
void ClearRowSelection(int index);
void ClearRegionSelection(int start, int end);
void clearAllRowsSelection();
void clearSingleRowSelection(int index);
void clearRegionOfRowsSelection(int start, int end);
void SelectAll();
void SetRowSelection(int index);
void SetRegionSelection(int start, int end);
void selectAllRows();
void setRowSelection(int index);
void setRegionOfRowsSelection(int start, int end);
void SetRegionSelectionPattern(int start, int end);
void SelectBetweenMarkers();
void ReselectClipboard();
void setRegionOfRowsSelectionUsingPattern(int start, int end);
void selectAllRowsBetweenMarkers();
void Transpose(int shift);
void reselectClipboard();
void JumpPrevMarker(int speed = 1);
void JumpNextMarker(int speed = 1);
void JumpToFrame(int frame);
void transposeVertically(int shift);
void jumpToPreviousMarker(int speed = 1);
void jumpToNextMarker(int speed = 1);
void jumpToFrame(int frame);
// getters
int GetCurrentSelectionSize();
int GetCurrentSelectionBeginning();
int GetCurrentSelectionEnd();
bool CheckFrameSelected(int frame);
SelectionFrames* MakeStrobe();
int getCurrentRowsSelectionSize();
int getCurrentRowsSelectionBeginning();
int getCurrentRowsSelectionEnd();
RowsSelection* getCopyOfCurrentRowsSelection();
bool must_find_current_marker;
int shown_marker;
bool mustFindCurrentMarker;
int displayedMarkerNumber;
HWND hwndPrevMarker, hwndNextMarker;
HWND hwndSelectionMarker, hwndSelectionMarkerEdit;
HWND hwndPreviousMarkerButton, hwndNextMarkerButton;
HWND hwndSelectionMarkerNumber, hwndSelectionMarkerEditField;
private:
void JumpInTime(int new_pos);
void EnforceSelectionToList();
void jumpInTime(int new_pos);
void enforceRowsSelectionToList();
SelectionFrames& CurrentSelection();
RowsSelection& getCurrentRowsSelection();
bool track_selection_changes;
int last_selection_beginning;
bool trackSelectionChanges;
int lastSelectionBeginning;
bool old_prev_marker_button_state, prev_marker_button_state;
bool old_next_marker_button_state, next_marker_button_state;
int button_hold_time;
bool previousMarkerButtonState, previousMarkerButtonOldState;
bool nextMarkerButtonState, nextMarkerButtonOldState;
int buttonHoldTimer;
std::vector<SelectionFrames> selections_history;
std::vector<RowsSelection> rowsSelectionHistory;
int history_cursor_pos;
int history_start_pos;
int history_total_items;
int history_size;
int historyCursorPos;
int historyStartPos;
int historySize;
int historyTotalItems;
SelectionFrames temp_selection;
RowsSelection tempRowsSelection;
};

View File

@ -19,28 +19,28 @@ Snapshot - Snapshot of all edited data
#include "taseditor_project.h"
#include "zlib.h"
extern MARKERS_MANAGER markers_manager;
extern MARKERS_MANAGER markersManager;
extern SELECTION selection;
extern GREENZONE greenzone;
extern int GetInputType(MovieData& md);
extern int getInputType(MovieData& md);
SNAPSHOT::SNAPSHOT()
{
}
void SNAPSHOT::init(MovieData& md, bool hotchanges, int force_input_type)
void SNAPSHOT::init(MovieData& md, bool hotchanges, int enforceInputType)
{
inputlog.init(md, hotchanges, force_input_type);
inputlog.init(md, hotchanges, enforceInputType);
// take a copy from greenzone.laglog
laglog = greenzone.laglog;
laglog.Reset_already_compressed();
laglog = greenzone.lagLog;
laglog.resetCompressedStatus();
// take a copy of markers_manager.markers
markers_manager.MakeCopyTo(markers);
if ((int)markers.markers_array.size() < inputlog.size)
markers.markers_array.resize(inputlog.size);
markersManager.makeCopyOfCurrentMarkersTo(markers);
if ((int)markers.markersArray.size() < inputlog.size)
markers.markersArray.resize(inputlog.size);
// save current time to description
time_t raw_time;
@ -49,13 +49,13 @@ void SNAPSHOT::init(MovieData& md, bool hotchanges, int force_input_type)
strftime(description, 10, "%H:%M:%S", timeinfo);
}
void SNAPSHOT::reinit(MovieData& md, bool hotchanges, int frame_of_change)
void SNAPSHOT::reinit(MovieData& md, bool hotchanges, int frameOfChanges)
{
inputlog.reinit(md, hotchanges, frame_of_change);
inputlog.reinit(md, hotchanges, frameOfChanges);
// take a copy from greenzone.laglog
laglog = greenzone.laglog;
laglog.Reset_already_compressed();
laglog = greenzone.lagLog;
laglog.resetCompressedStatus();
// Markers are supposed to be the same, because this is consecutive Recording
@ -66,39 +66,39 @@ void SNAPSHOT::reinit(MovieData& md, bool hotchanges, int frame_of_change)
strftime(description, 10, "%H:%M:%S", timeinfo);
}
bool SNAPSHOT::MarkersDifferFromCurrent()
bool SNAPSHOT::areMarkersDifferentFromCurrentMarkers()
{
return markers_manager.checkMarkersDiff(markers);
return markersManager.checkMarkersDiff(markers);
}
void SNAPSHOT::copyToMarkers()
void SNAPSHOT::copyToCurrentMarkers()
{
markers_manager.RestoreFromCopy(markers);
markersManager.restoreMarkersFromCopy(markers);
}
// -----------------------------------------------------------------------------------------
void SNAPSHOT::compress_data()
void SNAPSHOT::compressData()
{
if (!inputlog.Get_already_compressed())
inputlog.compress_data();
if (!laglog.Get_already_compressed())
laglog.compress_data();
if (!markers.Get_already_compressed())
markers.compress_data();
if (!inputlog.isAlreadyCompressed())
inputlog.compressData();
if (!laglog.isAlreadyCompressed())
laglog.compressData();
if (!markers.isAalreadyCompressed())
markers.compressData();
}
bool SNAPSHOT::Get_already_compressed()
bool SNAPSHOT::isAlreadyCompressed()
{
// only consider this snapshot fully compressed when all of InputLog, LagLog and Markers are compressed
return (inputlog.Get_already_compressed() && laglog.Get_already_compressed() && markers.Get_already_compressed());
return (inputlog.isAlreadyCompressed() && laglog.isAlreadyCompressed() && markers.isAalreadyCompressed());
}
void SNAPSHOT::save(EMUFILE *os)
{
// write vars
write32le(keyframe, os);
write32le(start_frame, os);
write32le(end_frame, os);
write32le(consecutive_tag, os);
write32le(rec_joypad_diff_bits, os);
write32le(mod_type, os);
write32le(keyFrame, os);
write32le(startFrame, os);
write32le(endFrame, os);
write32le(consecutivenessTag, os);
write32le(recordedJoypadDifferenceBits, os);
write32le(modificationType, os);
// write description
int len = strlen(description);
write8le(len, os);
@ -115,15 +115,15 @@ bool SNAPSHOT::load(EMUFILE *is)
{
uint8 tmp;
// read vars
if (!read32le(&keyframe, is)) return true;
if (!read32le(&start_frame, is)) return true;
if (!read32le(&end_frame, is)) return true;
if (!read32le(&consecutive_tag, is)) return true;
if (!read32le(&rec_joypad_diff_bits, is)) return true;
if (!read32le(&mod_type, is)) return true;
if (!read32le(&keyFrame, is)) return true;
if (!read32le(&startFrame, is)) return true;
if (!read32le(&endFrame, is)) return true;
if (!read32le(&consecutivenessTag, is)) return true;
if (!read32le(&recordedJoypadDifferenceBits, is)) return true;
if (!read32le(&modificationType, is)) return true;
// read description
if (!read8le(&tmp, is)) return true;
if (tmp >= SNAPSHOT_DESC_MAX_LENGTH) return true;
if (tmp >= SNAPSHOT_DESCRIPTION_MAX_LEN) return true;
if (is->fread(&description[0], tmp) != tmp) return true;
description[tmp] = 0; // add '0' because it wasn't saved in the file
// load InputLog data
@ -141,13 +141,13 @@ bool SNAPSHOT::skipLoad(EMUFILE *is)
if (is->fseek(sizeof(int) + // keyframe
sizeof(int) + // start_frame
sizeof(int) + // end_frame
sizeof(int) + // consecutive_tag
sizeof(int) + // rec_joypad_diff_bits
sizeof(int) + // consecutivenessTag
sizeof(int) + // recordedJoypadDifferenceBits
sizeof(int) // mod_type
, SEEK_CUR)) return true;
// skip description
if (!read8le(&tmp1, is)) return true;
if (tmp1 >= SNAPSHOT_DESC_MAX_LENGTH) return true;
if (tmp1 >= SNAPSHOT_DESCRIPTION_MAX_LEN) return true;
if (is->fseek(tmp1, SEEK_CUR) != 0) return true;
// skip InputLog data
if (inputlog.skipLoad(is)) return true;

View File

@ -2,20 +2,20 @@
#include "inputlog.h"
#define SNAPSHOT_DESC_MAX_LENGTH 100
#define SNAPSHOT_DESCRIPTION_MAX_LEN 100
class SNAPSHOT
{
public:
SNAPSHOT();
void init(MovieData& md, bool hotchanges, int force_input_type = -1);
void reinit(MovieData& md, bool hotchanges, int frame_of_change); // used when combining consecutive Recordings
void init(MovieData& md, bool hotChanges, int enforceInputType = -1);
void reinit(MovieData& md, bool hotChanges, int frameOfChanges); // used when combining consecutive Recordings
bool MarkersDifferFromCurrent();
void copyToMarkers();
bool areMarkersDifferentFromCurrentMarkers();
void copyToCurrentMarkers();
void compress_data();
bool Get_already_compressed();
void compressData();
bool isAlreadyCompressed();
void save(EMUFILE *os);
bool load(EMUFILE *is);
@ -25,13 +25,13 @@ public:
INPUTLOG inputlog;
LAGLOG laglog;
MARKERS markers;
int keyframe; // for jumping when making undo
int start_frame; // for consecutive Draws and "Related items highlighting"
int end_frame; // for consecutive Draws and "Related items highlighting"
int consecutive_tag; // for consecutive Recordings and Draws
uint32 rec_joypad_diff_bits; // for consecutive Recordings: bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
int mod_type;
char description[SNAPSHOT_DESC_MAX_LENGTH];
int keyFrame; // for jumping when making undo
int startFrame; // for consecutive Draws and "Related items highlighting"
int endFrame; // for consecutive Draws and "Related items highlighting"
int consecutivenessTag; // for consecutive Recordings and Draws
uint32 recordedJoypadDifferenceBits; // for consecutive Recordings: bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
int modificationType;
char description[SNAPSHOT_DESCRIPTION_MAX_LEN];
private:

View File

@ -21,17 +21,17 @@ Splicer - Tool for montage
#include "taseditor_project.h"
#include "../Win32InputBox.h"
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditorWindow;
extern TASEDITOR_CONFIG taseditorConfig;
extern HISTORY history;
extern MARKERS_MANAGER markers_manager;
extern MARKERS_MANAGER markersManager;
extern PLAYBACK playback;
extern GREENZONE greenzone;
extern PIANO_ROLL piano_roll;
extern PIANO_ROLL pianoRoll;
extern SELECTION selection;
extern int joysticks_per_frame[NUM_SUPPORTED_INPUT_TYPES];
extern int GetInputType(MovieData& md);
extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
extern int getInputType(MovieData& md);
// resources
char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"};
@ -50,24 +50,24 @@ SPLICER::SPLICER()
void SPLICER::init()
{
hwndTextSelection = GetDlgItem(taseditor_window.hwndTasEditor, IDC_TEXT_SELECTION);
hwndTextClipboard = GetDlgItem(taseditor_window.hwndTasEditor, IDC_TEXT_CLIPBOARD);
hwndSelectionInfo = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_TEXT_SELECTION);
hwndClipboardInfo = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_TEXT_CLIPBOARD);
reset();
if (clipboard_selection.empty())
CheckClipboard();
RedrawTextClipboard();
if (clipboardSelection.empty())
checkClipboardContents();
redrawInfoAboutClipboard();
}
void SPLICER::reset()
{
must_redraw_selection_text = true;
mustRedrawInfoAboutSelection = true;
}
void SPLICER::update()
{
// redraw Selection info text of needed
if (must_redraw_selection_text)
if (mustRedrawInfoAboutSelection)
{
int size = selection.GetCurrentSelectionSize();
int size = selection.getCurrentRowsSelectionSize();
if (size)
{
char new_text[100];
@ -84,7 +84,7 @@ void SPLICER::update()
strcat(new_text, numTextRow);
}
// columns
int columns = NUM_JOYPAD_BUTTONS * joysticks_per_frame[GetInputType(currMovieData)]; // in future the number of columns will depend on selected columns
int columns = NUM_JOYPAD_BUTTONS * joysticksPerFrame[getInputType(currMovieData)]; // in future the number of columns will depend on selected columns
if (columns > 1)
{
_itoa(columns, num, 10);
@ -94,30 +94,30 @@ void SPLICER::update()
{
strcat(new_text, numTextColumn);
}
SetWindowText(hwndTextSelection, new_text);
SetWindowText(hwndSelectionInfo, new_text);
} else
{
SetWindowText(hwndTextSelection, selectionEmptyText);
SetWindowText(hwndSelectionInfo, selectionEmptyText);
}
must_redraw_selection_text = false;
mustRedrawInfoAboutSelection = false;
}
}
// ----------------------------------------------------------------------------------------------
void SPLICER::CloneFrames()
void SPLICER::cloneSelectedFrames()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
int frames = current_selection->size();
if (!frames) return;
selection.ClearSelection(); // Selection will be moved down, so that same frames are selected
selection.clearAllRowsSelection(); // Selection will be moved down, so that same frames are selected
bool markers_changed = false;
currMovieData.records.reserve(currMovieData.getNumRecords() + frames);
// insert frames before each selection, but consecutive Selection lines are accounted as single region
SelectionFrames::reverse_iterator next_it;
SelectionFrames::reverse_iterator current_selection_rend = current_selection->rend();
RowsSelection::reverse_iterator next_it;
RowsSelection::reverse_iterator current_selection_rend = current_selection->rend();
int shift = frames;
frames = 1;
for(SelectionFrames::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
for(RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
{
next_it = it;
next_it++;
@ -125,48 +125,48 @@ void SPLICER::CloneFrames()
{
// end of current region
currMovieData.cloneRegion(*it, frames);
greenzone.laglog.InsertFrame(*it, false, frames);
if (taseditor_config.bind_markers)
greenzone.lagLog.insertFrame(*it, false, frames);
if (taseditorConfig.bindMarkersToInput)
{
// Markers are not cloned
if (markers_manager.insertEmpty(*it,frames))
if (markersManager.insertEmpty(*it,frames))
markers_changed = true;
}
selection.SetRegionSelection((*it) + shift, (*it) + shift + frames);
selection.setRegionOfRowsSelection((*it) + shift, (*it) + shift + frames);
shift -= frames;
// start accumulating next region
frames = 1;
} else frames++;
}
// check and register changes
int first_changes = history.RegisterChanges(MODTYPE_CLONE, *current_selection->begin(), -1, 0, NULL, 0, current_selection);
int first_changes = history.registerChanges(MODTYPE_CLONE, *current_selection->begin(), -1, 0, NULL, 0, current_selection);
if (first_changes >= 0)
{
greenzone.InvalidateAndCheck(first_changes);
greenzone.invalidateAndUpdatePlayback(first_changes);
} else if (markers_changed)
{
history.RegisterMarkersChange(MODTYPE_MARKER_SHIFT, *current_selection->begin());
piano_roll.RedrawList();
history.registerMarkersChange(MODTYPE_MARKER_SHIFT, *current_selection->begin());
pianoRoll.redraw();
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
void SPLICER::InsertFrames()
void SPLICER::insertSelectedFrames()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
int frames = current_selection->size();
if (!frames) return;
selection.ClearSelection(); // Selection will be moved down, so that same frames are selected
selection.clearAllRowsSelection(); // Selection will be moved down, so that same frames are selected
bool markers_changed = false;
currMovieData.records.reserve(currMovieData.getNumRecords() + frames);
// insert frames before each selection, but consecutive Selection lines are accounted as single region
SelectionFrames::reverse_iterator next_it;
SelectionFrames::reverse_iterator current_selection_rend = current_selection->rend();
RowsSelection::reverse_iterator next_it;
RowsSelection::reverse_iterator current_selection_rend = current_selection->rend();
int shift = frames;
frames = 1;
for(SelectionFrames::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
for(RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
{
next_it = it;
next_it++;
@ -174,37 +174,37 @@ void SPLICER::InsertFrames()
{
// end of current region
currMovieData.insertEmpty(*it, frames);
greenzone.laglog.InsertFrame(*it, false, frames);
if (taseditor_config.bind_markers)
greenzone.lagLog.insertFrame(*it, false, frames);
if (taseditorConfig.bindMarkersToInput)
{
if (markers_manager.insertEmpty(*it, frames))
if (markersManager.insertEmpty(*it, frames))
markers_changed = true;
}
selection.SetRegionSelection((*it) + shift, (*it) + shift + frames);
selection.setRegionOfRowsSelection((*it) + shift, (*it) + shift + frames);
shift -= frames;
// start accumulating next region
frames = 1;
} else frames++;
}
// check and register changes
int first_changes = history.RegisterChanges(MODTYPE_INSERT, *current_selection->begin(), -1, 0, NULL, 0, current_selection);
int first_changes = history.registerChanges(MODTYPE_INSERT, *current_selection->begin(), -1, 0, NULL, 0, current_selection);
if (first_changes >= 0)
{
greenzone.InvalidateAndCheck(first_changes);
greenzone.invalidateAndUpdatePlayback(first_changes);
} else if (markers_changed)
{
history.RegisterMarkersChange(MODTYPE_MARKER_SHIFT, *current_selection->begin());
piano_roll.RedrawList();
history.registerMarkersChange(MODTYPE_MARKER_SHIFT, *current_selection->begin());
pianoRoll.redraw();
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
void SPLICER::InsertNumFrames()
void SPLICER::insertNumberOfFrames()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
int frames = current_selection->size();
if (CWin32InputBox::GetInteger("Insert number of Frames", "How many frames?", frames, taseditor_window.hwndTasEditor) == IDOK)
if (CWin32InputBox::GetInteger("Insert number of Frames", "How many frames?", frames, taseditorWindow.hwndTASEditor) == IDOK)
{
if (frames > 0)
{
@ -220,103 +220,103 @@ void SPLICER::InsertNumFrames()
index = currFrameCounter;
}
currMovieData.insertEmpty(index, frames);
greenzone.laglog.InsertFrame(index, false, frames);
if (taseditor_config.bind_markers)
greenzone.lagLog.insertFrame(index, false, frames);
if (taseditorConfig.bindMarkersToInput)
{
if (markers_manager.insertEmpty(index, frames))
if (markersManager.insertEmpty(index, frames))
markers_changed = true;
}
if (current_selection->size())
{
// shift Selection down, so that same frames are selected
piano_roll.UpdateItemCount();
selection.ClearSelection();
SelectionFrames::iterator current_selection_end = current_selection->end();
for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; it++)
selection.SetRowSelection((*it) + frames);
pianoRoll.updateLinesCount();
selection.clearAllRowsSelection();
RowsSelection::iterator current_selection_end = current_selection->end();
for(RowsSelection::iterator it(current_selection->begin()); it != current_selection_end; it++)
selection.setRowSelection((*it) + frames);
}
// check and register changes
int first_changes = history.RegisterChanges(MODTYPE_INSERTNUM, index, -1, frames);
int first_changes = history.registerChanges(MODTYPE_INSERTNUM, index, -1, frames);
if (first_changes >= 0)
{
greenzone.InvalidateAndCheck(first_changes);
greenzone.invalidateAndUpdatePlayback(first_changes);
} else if (markers_changed)
{
history.RegisterMarkersChange(MODTYPE_MARKER_SHIFT, index);
piano_roll.RedrawList();
history.registerMarkersChange(MODTYPE_MARKER_SHIFT, index);
pianoRoll.redraw();
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
}
}
void SPLICER::DeleteFrames()
void SPLICER::deleteSelectedFrames()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return;
bool markers_changed = false;
int start_index = *current_selection->begin();
int end_index = *current_selection->rbegin();
SelectionFrames::reverse_iterator current_selection_rend = current_selection->rend();
RowsSelection::reverse_iterator current_selection_rend = current_selection->rend();
// delete frames on each selection, going backwards
for(SelectionFrames::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
for(RowsSelection::reverse_iterator it(current_selection->rbegin()); it != current_selection_rend; it++)
{
currMovieData.eraseRecords(*it);
greenzone.laglog.EraseFrame(*it);
if (taseditor_config.bind_markers)
greenzone.lagLog.eraseFrame(*it);
if (taseditorConfig.bindMarkersToInput)
{
if (markers_manager.EraseMarker(*it))
if (markersManager.eraseMarker(*it))
markers_changed = true;
}
}
// check if user deleted all frames
if (!currMovieData.getNumRecords())
playback.StartFromZero();
playback.restartPlaybackFromZeroGround();
// reduce Piano Roll
piano_roll.UpdateItemCount();
pianoRoll.updateLinesCount();
// check and register changes
int result = history.RegisterChanges(MODTYPE_DELETE, start_index, -1, 0, NULL, 0, current_selection);
int result = history.registerChanges(MODTYPE_DELETE, start_index, -1, 0, NULL, 0, current_selection);
if (result >= 0)
{
greenzone.InvalidateAndCheck(result);
greenzone.invalidateAndUpdatePlayback(result);
} else
{
// check for special case: user deleted a bunch of empty frames the end of the movie
greenzone.InvalidateAndCheck(currMovieData.getNumRecords() - 1);
greenzone.invalidateAndUpdatePlayback(currMovieData.getNumRecords() - 1);
if (markers_changed)
history.RegisterMarkersChange(MODTYPE_MARKER_SHIFT, start_index);
history.registerMarkersChange(MODTYPE_MARKER_SHIFT, start_index);
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
void SPLICER::ClearFrames(SelectionFrames* current_selection)
void SPLICER::clearSelectedFrames(RowsSelection* currentSelectionOverride)
{
bool cut = true;
if (!current_selection)
if (!currentSelectionOverride)
{
cut = false;
current_selection = selection.MakeStrobe();
if (current_selection->size() == 0) return;
currentSelectionOverride = selection.getCopyOfCurrentRowsSelection();
if (currentSelectionOverride->size() == 0) return;
}
// clear Input on each selected frame
SelectionFrames::iterator current_selection_end(current_selection->end());
for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; it++)
RowsSelection::iterator current_selection_end(currentSelectionOverride->end());
for(RowsSelection::iterator it(currentSelectionOverride->begin()); it != current_selection_end; it++)
{
currMovieData.records[*it].clear();
}
if (cut)
greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_CUT, *current_selection->begin(), *current_selection->rbegin()));
greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_CUT, *currentSelectionOverride->begin(), *currentSelectionOverride->rbegin()));
else
greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_CLEAR, *current_selection->begin(), *current_selection->rbegin()));
greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_CLEAR, *currentSelectionOverride->begin(), *currentSelectionOverride->rbegin()));
}
void SPLICER::Truncate()
void SPLICER::truncateMovie()
{
int frame = selection.GetCurrentSelectionBeginning();
int frame = selection.getCurrentRowsSelectionBeginning();
if (frame < 0) frame = currFrameCounter;
if (currMovieData.getNumRecords() > frame+1)
@ -324,49 +324,49 @@ void SPLICER::Truncate()
int last_frame_was = currMovieData.getNumRecords() - 1;
currMovieData.truncateAt(frame+1);
bool markers_changed = false;
if (taseditor_config.bind_markers)
if (taseditorConfig.bindMarkersToInput)
{
if (markers_manager.SetMarkersSize(frame+1))
if (markersManager.setMarkersArraySize(frame+1))
{
markers_changed = true;
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
}
piano_roll.UpdateItemCount();
int result = history.RegisterChanges(MODTYPE_TRUNCATE, frame + 1);
pianoRoll.updateLinesCount();
int result = history.registerChanges(MODTYPE_TRUNCATE, frame + 1);
if (result >= 0)
{
greenzone.InvalidateAndCheck(result);
greenzone.invalidateAndUpdatePlayback(result);
} else
{
// check for special case: user truncated empty frames of the movie
greenzone.InvalidateAndCheck(currMovieData.getNumRecords() - 1);
greenzone.invalidateAndUpdatePlayback(currMovieData.getNumRecords() - 1);
if (markers_changed)
history.RegisterMarkersChange(MODTYPE_MARKER_REMOVE, frame+1, last_frame_was);
history.registerMarkersChange(MODTYPE_MARKER_REMOVE, frame+1, last_frame_was);
}
}
}
bool SPLICER::Copy(SelectionFrames* current_selection)
bool SPLICER::copySelectedInputToClipboard(RowsSelection* currentSelectionOverride)
{
if (!current_selection)
if (!currentSelectionOverride)
{
current_selection = selection.MakeStrobe();
if (current_selection->size() == 0) return false;
currentSelectionOverride = selection.getCopyOfCurrentRowsSelection();
if (currentSelectionOverride->size() == 0) return false;
}
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
int num_joypads = joysticks_per_frame[GetInputType(currMovieData)];
RowsSelection::iterator current_selection_begin(currentSelectionOverride->begin());
RowsSelection::iterator current_selection_end(currentSelectionOverride->end());
int num_joypads = joysticksPerFrame[getInputType(currMovieData)];
int cframe = (*current_selection_begin) - 1;
try
{
int range = (*current_selection->rbegin() - *current_selection_begin) + 1;
int range = (*currentSelectionOverride->rbegin() - *current_selection_begin) + 1;
std::stringstream clipString;
clipString << "TAS " << range << std::endl;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if (*it > cframe+1)
{
@ -393,7 +393,7 @@ bool SPLICER::Copy(SelectionFrames* current_selection)
clipString << std::endl;
}
// write data to clipboard
if (!OpenClipboard(taseditor_window.hwndTasEditor))
if (!OpenClipboard(taseditorWindow.hwndTASEditor))
return false;
EmptyClipboard();
@ -416,28 +416,28 @@ bool SPLICER::Copy(SelectionFrames* current_selection)
}
// copied successfully
// memorize currently strobed Selection data to clipboard_selection
clipboard_selection = *current_selection;
RedrawTextClipboard();
clipboardSelection = *currentSelectionOverride;
redrawInfoAboutClipboard();
return true;
}
void SPLICER::Cut()
void SPLICER::cutSelectedInputToClipboard()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return;
if (Copy(current_selection))
if (copySelectedInputToClipboard(current_selection))
{
ClearFrames(current_selection);
clearSelectedFrames(current_selection);
}
}
bool SPLICER::Paste()
bool SPLICER::pasteInputFromClipboard()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return false;
if (!OpenClipboard(taseditor_window.hwndTasEditor)) return false;
if (!OpenClipboard(taseditorWindow.hwndTASEditor)) return false;
int num_joypads = joysticks_per_frame[GetInputType(currMovieData)];
int num_joypads = joysticksPerFrame[getInputType(currMovieData)];
bool result = false;
int pos = *(current_selection->begin());
HANDLE hGlobal = GetClipboardData(CF_TEXT);
@ -454,7 +454,7 @@ bool SPLICER::Paste()
if (currMovieData.getNumRecords() < pos+range)
{
currMovieData.insertEmpty(currMovieData.getNumRecords(),pos+range-currMovieData.getNumRecords());
markers_manager.update();
markersManager.update();
}
pGlobal = strchr(pGlobal, '\n');
@ -478,7 +478,7 @@ bool SPLICER::Paste()
pos++;
}
if (taseditor_config.superimpose == SUPERIMPOSE_UNCHECKED)
if (taseditorConfig.superimpose == SUPERIMPOSE_UNCHECKED)
{
currMovieData.records[pos].joysticks[0] = 0;
currMovieData.records[pos].joysticks[1] = 0;
@ -494,7 +494,7 @@ bool SPLICER::Paste()
{
case '|': // Joystick mark
// flush buttons to movie data
if (taseditor_config.superimpose == SUPERIMPOSE_CHECKED || (taseditor_config.superimpose == SUPERIMPOSE_INDETERMINATE && new_buttons == 0))
if (taseditorConfig.superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig.superimpose == SUPERIMPOSE_INDETERMINATE && new_buttons == 0))
{
flash_joy[joy] |= (new_buttons & (~currMovieData.records[pos].joysticks[joy])); // highlight buttons that are new
currMovieData.records[pos].joysticks[joy] |= new_buttons;
@ -520,7 +520,7 @@ bool SPLICER::Paste()
frame++;
}
// before going to next frame, flush buttons to movie data
if (taseditor_config.superimpose == SUPERIMPOSE_CHECKED || (taseditor_config.superimpose == SUPERIMPOSE_INDETERMINATE && new_buttons == 0))
if (taseditorConfig.superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig.superimpose == SUPERIMPOSE_INDETERMINATE && new_buttons == 0))
{
flash_joy[joy] |= (new_buttons & (~currMovieData.records[pos].joysticks[joy])); // highlight buttons that are new
currMovieData.records[pos].joysticks[joy] |= new_buttons;
@ -533,35 +533,35 @@ bool SPLICER::Paste()
pGlobal = strchr(pGlobal, '\n');
}
greenzone.InvalidateAndCheck(history.RegisterChanges(MODTYPE_PASTE, *(current_selection->begin()), pos));
greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_PASTE, *(current_selection->begin()), pos));
// flash Piano Roll header columns that were changed during paste
for (int joy = 0; joy < num_joypads; ++joy)
{
for (int btn = 0; btn < NUM_JOYPAD_BUTTONS; ++btn)
{
if (flash_joy[joy] & (1 << btn))
piano_roll.SetHeaderColumnLight(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + btn, HEADER_LIGHT_MAX);
pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + btn, HEADER_LIGHT_MAX);
}
}
result = true;
} else
{
SetWindowText(hwndTextClipboard, clipboardEmptyText);
SetWindowText(hwndClipboardInfo, clipboardEmptyText);
}
GlobalUnlock(hGlobal);
}
CloseClipboard();
return result;
}
bool SPLICER::PasteInsert()
bool SPLICER::pasteInsertInputFromClipboard()
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
if (current_selection->size() == 0) return false;
if (!OpenClipboard(taseditor_window.hwndTasEditor)) return false;
if (!OpenClipboard(taseditorWindow.hwndTASEditor)) return false;
SelectionFrames::iterator current_selection_begin(current_selection->begin());
int num_joypads = joysticks_per_frame[GetInputType(currMovieData)];
RowsSelection::iterator current_selection_begin(current_selection->begin());
int num_joypads = joysticksPerFrame[getInputType(currMovieData)];
bool result = false;
bool markers_changed = false;
int pos = *current_selection_begin;
@ -574,9 +574,9 @@ bool SPLICER::PasteInsert()
if (pGlobal[0]=='T' && pGlobal[1]=='A' && pGlobal[2]=='S')
{
// make sure Markers have the same size as movie
markers_manager.update();
markersManager.update();
// create inserted_set (for Input history hot changes)
SelectionFrames inserted_set;
RowsSelection inserted_set;
// Extract number of frames
int range;
@ -597,7 +597,7 @@ bool SPLICER::PasteInsert()
if (currMovieData.getNumRecords() < pos)
{
currMovieData.insertEmpty(currMovieData.getNumRecords(), pos - currMovieData.getNumRecords());
markers_manager.update();
markersManager.update();
}
while (*frame && *frame != '\n' && *frame != '|')
++frame;
@ -609,10 +609,10 @@ bool SPLICER::PasteInsert()
// insert new frame
currMovieData.insertEmpty(pos, 1);
greenzone.laglog.InsertFrame(pos, false, 1);
if (taseditor_config.bind_markers)
greenzone.lagLog.insertFrame(pos, false, 1);
if (taseditorConfig.bindMarkersToInput)
{
if (markers_manager.insertEmpty(pos, 1))
if (markersManager.insertEmpty(pos, 1))
markers_changed = true;
}
inserted_set.insert(pos);
@ -643,31 +643,31 @@ bool SPLICER::PasteInsert()
pGlobal = strchr(pGlobal, '\n');
}
markers_manager.update();
int first_changes = history.RegisterChanges(MODTYPE_PASTEINSERT, *current_selection_begin, -1, 0, NULL, 0, &inserted_set);
markersManager.update();
int first_changes = history.registerChanges(MODTYPE_PASTEINSERT, *current_selection_begin, -1, 0, NULL, 0, &inserted_set);
if (first_changes >= 0)
{
greenzone.InvalidateAndCheck(first_changes);
greenzone.invalidateAndUpdatePlayback(first_changes);
} else if (markers_changed)
{
history.RegisterMarkersChange(MODTYPE_MARKER_SHIFT, *current_selection->begin());
piano_roll.RedrawList();
history.registerMarkersChange(MODTYPE_MARKER_SHIFT, *current_selection->begin());
pianoRoll.redraw();
}
if (markers_changed)
selection.must_find_current_marker = playback.must_find_current_marker = true;
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
// flash Piano Roll header columns that were changed during paste
for (int joy = 0; joy < num_joypads; ++joy)
{
for (int btn = 0; btn < NUM_JOYPAD_BUTTONS; ++btn)
{
if (flash_joy[joy] & (1 << btn))
piano_roll.SetHeaderColumnLight(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + btn, HEADER_LIGHT_MAX);
pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + btn, HEADER_LIGHT_MAX);
}
}
result = true;
} else
{
SetWindowText(hwndTextClipboard, clipboardEmptyText);
SetWindowText(hwndClipboardInfo, clipboardEmptyText);
}
GlobalUnlock(hGlobal);
}
@ -676,15 +676,15 @@ bool SPLICER::PasteInsert()
}
// ----------------------------------------------------------------------------------------------
// retrieves some information from clipboard to clipboard_selection
void SPLICER::CheckClipboard()
void SPLICER::checkClipboardContents()
{
if (OpenClipboard(taseditor_window.hwndTasEditor))
if (OpenClipboard(taseditorWindow.hwndTASEditor))
{
// check if clipboard contains TAS Editor Input data
HANDLE hGlobal = GetClipboardData(CF_TEXT);
if (hGlobal)
{
clipboard_selection.clear();
clipboardSelection.clear();
int current_pos = -1;
char *pGlobal = (char*)GlobalLock((HGLOBAL)hGlobal);
// TAS recording info starts with "TAS "
@ -707,7 +707,7 @@ void SPLICER::CheckClipboard()
if (*frame=='|') ++frame;
} else
current_pos++;
clipboard_selection.insert(current_pos);
clipboardSelection.insert(current_pos);
// skip Input
pGlobal = strchr(pGlobal, '\n');
}
@ -718,17 +718,17 @@ void SPLICER::CheckClipboard()
}
}
void SPLICER::RedrawTextClipboard()
void SPLICER::redrawInfoAboutClipboard()
{
if (clipboard_selection.size())
if (clipboardSelection.size())
{
char new_text[100];
strcpy(new_text, clipboardText);
char num[11];
// rows
if (clipboard_selection.size() > 1)
if (clipboardSelection.size() > 1)
{
_itoa(clipboard_selection.size(), num, 10);
_itoa(clipboardSelection.size(), num, 10);
strcat(new_text, num);
strcat(new_text, numTextRows);
} else
@ -736,7 +736,7 @@ void SPLICER::RedrawTextClipboard()
strcat(new_text, numTextRow);
}
// columns
int columns = NUM_JOYPAD_BUTTONS * joysticks_per_frame[GetInputType(currMovieData)]; // in future the number of columns will depend on selected columns
int columns = NUM_JOYPAD_BUTTONS * joysticksPerFrame[getInputType(currMovieData)]; // in future the number of columns will depend on selected columns
if (columns > 1)
{
_itoa(columns, num, 10);
@ -746,14 +746,14 @@ void SPLICER::RedrawTextClipboard()
{
strcat(new_text, numTextColumn);
}
SetWindowText(hwndTextClipboard, new_text);
SetWindowText(hwndClipboardInfo, new_text);
} else
SetWindowText(hwndTextClipboard, clipboardEmptyText);
SetWindowText(hwndClipboardInfo, clipboardEmptyText);
}
SelectionFrames& SPLICER::GetClipboardSelection()
RowsSelection& SPLICER::getClipboardSelection()
{
return clipboard_selection;
return clipboardSelection;
}

View File

@ -8,27 +8,27 @@ public:
void reset();
void update();
void CloneFrames();
void InsertFrames();
void InsertNumFrames();
void DeleteFrames();
void ClearFrames(SelectionFrames* current_selection = 0);
void Truncate();
bool Copy(SelectionFrames* current_selection = 0);
void Cut();
bool Paste();
bool PasteInsert();
void cloneSelectedFrames();
void insertSelectedFrames();
void insertNumberOfFrames();
void deleteSelectedFrames();
void clearSelectedFrames(RowsSelection* currentSelectionOverride = 0);
void truncateMovie();
bool copySelectedInputToClipboard(RowsSelection* currentSelectionOverride = 0);
void cutSelectedInputToClipboard();
bool pasteInputFromClipboard();
bool pasteInsertInputFromClipboard();
void RedrawTextClipboard();
void redrawInfoAboutClipboard();
SelectionFrames& GetClipboardSelection();
RowsSelection& getClipboardSelection();
bool must_redraw_selection_text;
bool mustRedrawInfoAboutSelection;
private:
void CheckClipboard();
void checkClipboardContents();
SelectionFrames clipboard_selection;
HWND hwndTextSelection, hwndTextClipboard;
RowsSelection clipboardSelection;
HWND hwndSelectionInfo, hwndClipboardInfo;
};

View File

@ -16,74 +16,83 @@ Config - Current settings
* stores resources: default values of all settings, min/max values of settings
------------------------------------------------------------------------------------ */
#include "../common.h"
#include "taseditor_config.h"
#include "taseditor_project.h"
TASEDITOR_CONFIG::TASEDITOR_CONFIG()
{
// set default values
wndx = 0;
wndy = 0;
wndwidth = 0;
wndheight = 0;
saved_wndx = 0;
saved_wndy = 0;
saved_wndwidth = 0;
saved_wndheight = 0;
wndmaximized = false;
findnote_wndx = 0;
findnote_wndy = 0;
follow_playback = true;
turbo_seek = false;
show_branch_screenshots = true;
show_branch_descr = true;
enable_hot_changes = true;
jump_to_undo = true;
follow_note_context = true;
bind_markers = true;
empty_marker_notes = true;
combine_consecutive = false;
use_1p_rec = true;
columnset_by_keys = false;
superimpose = 0; // SUPERIMPOSE_UNCHECKED
branch_full_movie = true;
old_branching_controls = false;
view_branches_tree = false;
branch_scr_hud = true;
restore_position = false;
adjust_input_due_to_lag = true;
greenzone_capacity = GREENZONE_CAPACITY_DEFAULT;
undo_levels = UNDO_LEVELS_DEFAULT;
last_export_type = 0; // INPUT_TYPE_1P
last_export_subtitles = false;
save_binary = true;
save_markers = true;
save_bookmarks = true;
save_history = true;
save_piano_roll = true;
save_selection = true;
save_greenzone = SAVE_GREENZONE_ALL;
savecompact_binary = true;
savecompact_markers = true;
savecompact_bookmarks = true;
savecompact_history = false;
savecompact_piano_roll = true;
savecompact_selection = false;
savecompact_greenzone = SAVE_GREENZONE_NO;
findnote_matchcase = false;
findnote_search_up = false;
enable_auto_function = true;
draw_input = true;
enable_greenzoning = true;
enable_autosave = true;
autosave_period = AUTOSAVE_PERIOD_DEFAULT;
silent_autosave = true;
autopause_at_finish = true;
tooltips = true;
current_pattern = 0;
pattern_skips_lag = true;
pattern_recording = false;
last_author[0] = 0; // empty name
windowX = 0;
windowY = 0;
windowWidth = 0;
windowHeight = 0;
savedWindowX = 0;
savedWindowY = 0;
savedWindowWidth = 0;
savedWindowHeight = 0;
windowIsMaximized = false;
findnoteWindowX = 0;
findnoteWindowY = 0;
findnoteMatchCase = false;
findnoteSearchUp = false;
followPlaybackCursor = true;
turboSeek = false;
autoRestoreLastPlaybackPosition = false;
superimpose = SUPERIMPOSE_UNCHECKED;
recordingUsePattern = false;
enableLuaAutoFunction = true;
displayBranchesTree = false;
displayBranchScreenshots = true;
displayBranchDescriptions = true;
enableHotChanges = true;
followUndoContext = true;
followMarkerNoteContext = true;
greenzoneCapacity = GREENZONE_CAPACITY_DEFAULT;
maxUndoLevels = UNDO_LEVELS_DEFAULT;
enableGreenzoning = true;
autofirePatternSkipsLag = true;
autoAdjustInputAccordingToLag = true;
drawInputByDragging = true;
combineConsecutiveRecordingsAndDraws = false;
use1PKeysForAllSingleRecordings = true;
useInputKeysForColumnSet = false;
bindMarkersToInput = true;
emptyNewMarkerNotes = true;
oldControlSchemeForBranching = false;
branchesRestoreEntireMovie = true;
HUDInBranchScreenshots = true;
autopauseAtTheEndOfMovie = true;
lastExportedInputType = INPUT_TYPE_1P;
lastExportedSubtitlesStatus = false;
projectSavingOptions_SaveInBinary = true;
projectSavingOptions_SaveMarkers = true;
projectSavingOptions_SaveBookmarks = true;
projectSavingOptions_SaveHistory = true;
projectSavingOptions_SavePianoRoll = true;
projectSavingOptions_SaveSelection = true;
projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_ALL;
saveCompact_SaveInBinary = true;
saveCompact_SaveMarkers = true;
saveCompact_SaveBookmarks = true;
saveCompact_SaveHistory = false;
saveCompact_SavePianoRoll = true;
saveCompact_SaveSelection = false;
saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_NO;
autosaveEnabled = true;
autosavePeriod = AUTOSAVE_PERIOD_DEFAULT;
autosaveSilent = true;
tooltipsEnabled = true;
currentPattern = 0;
lastAuthorName[0] = 0; // empty name
}

View File

@ -1,98 +1,110 @@
// Specification file for TASEDITOR_CONFIG class
#define GREENZONE_CAPACITY_MIN 1
#define GREENZONE_CAPACITY_MAX 50000
#define GREENZONE_CAPACITY_MAX 50000 // this limitation is here just because we're running in 32-bit OS, so there's 2GB limit of RAM
#define GREENZONE_CAPACITY_DEFAULT 10000
#define UNDO_LEVELS_MIN 1
#define UNDO_LEVELS_MAX 1000
#define UNDO_LEVELS_MAX 1000 // this limitation is here just because we're running in 32-bit OS, so there's 2GB limit of RAM
#define UNDO_LEVELS_DEFAULT 100
#define AUTOSAVE_PERIOD_MIN 0 // 0 = no autosave
#define AUTOSAVE_PERIOD_MIN 0 // 0 = auto-save immediately after every change in the project
#define AUTOSAVE_PERIOD_MAX 1440 // 24 hours
#define AUTOSAVE_PERIOD_DEFAULT 15 // in minutes
enum
enum GREENZONE_SAVING_MODES
{
SAVE_GREENZONE_ALL,
SAVE_GREENZONE_16TH,
SAVE_GREENZONE_MARKED,
SAVE_GREENZONE_NO,
GREENZONE_SAVING_MODE_ALL,
GREENZONE_SAVING_MODE_16TH,
GREENZONE_SAVING_MODE_MARKED,
GREENZONE_SAVING_MODE_NO,
// ...
SAVE_GREENZONE_TOTAL
GREENZONE_SAVING_MODES_TOTAL
};
#define AUTHOR_MAX_LEN 100
#define AUTHOR_NAME_MAX_LEN 100
class TASEDITOR_CONFIG
{
public:
TASEDITOR_CONFIG();
// vars saved in cfg file
int wndx;
int wndy;
int wndwidth;
int wndheight;
int saved_wndx;
int saved_wndy;
int saved_wndwidth;
int saved_wndheight;
bool wndmaximized;
int findnote_wndx;
int findnote_wndy;
bool follow_playback;
bool turbo_seek;
bool show_branch_screenshots;
bool show_branch_descr;
bool enable_hot_changes;
bool jump_to_undo;
bool follow_note_context;
bool bind_markers;
bool empty_marker_notes;
bool combine_consecutive;
bool use_1p_rec;
bool columnset_by_keys;
// vars saved in fceux.cfg file
int windowX;
int windowY;
int windowWidth;
int windowHeight;
int savedWindowX;
int savedWindowY;
int savedWindowWidth;
int savedWindowHeight;
bool windowIsMaximized;
int findnoteWindowX;
int findnoteWindowY;
bool findnoteMatchCase;
bool findnoteSearchUp;
bool followPlaybackCursor;
bool turboSeek;
bool autoRestoreLastPlaybackPosition;
int superimpose;
bool branch_full_movie;
bool old_branching_controls;
bool view_branches_tree;
bool branch_scr_hud;
bool restore_position;
bool adjust_input_due_to_lag;
int greenzone_capacity;
int undo_levels;
int last_export_type;
bool last_export_subtitles;
bool save_binary;
bool save_markers;
bool save_bookmarks;
bool save_history;
bool save_piano_roll;
bool save_selection;
int save_greenzone;
bool savecompact_binary;
bool savecompact_markers;
bool savecompact_bookmarks;
bool savecompact_history;
bool savecompact_piano_roll;
bool savecompact_selection;
int savecompact_greenzone;
bool findnote_matchcase;
bool findnote_search_up;
bool enable_auto_function;
bool draw_input;
bool enable_greenzoning;
bool enable_autosave;
int autosave_period;
bool silent_autosave;
bool autopause_at_finish;
bool tooltips;
int current_pattern;
bool pattern_skips_lag;
bool pattern_recording;
char last_author[AUTHOR_MAX_LEN];
bool recordingUsePattern;
bool enableLuaAutoFunction;
bool displayBranchesTree;
bool displayBranchScreenshots;
bool displayBranchDescriptions;
bool enableHotChanges;
bool followUndoContext;
bool followMarkerNoteContext;
int greenzoneCapacity;
int maxUndoLevels;
bool enableGreenzoning;
bool autofirePatternSkipsLag;
bool autoAdjustInputAccordingToLag;
bool drawInputByDragging;
bool combineConsecutiveRecordingsAndDraws;
bool use1PKeysForAllSingleRecordings;
bool useInputKeysForColumnSet;
bool bindMarkersToInput;
bool emptyNewMarkerNotes;
bool oldControlSchemeForBranching;
bool branchesRestoreEntireMovie;
bool HUDInBranchScreenshots;
bool autopauseAtTheEndOfMovie;
int lastExportedInputType;
bool lastExportedSubtitlesStatus;
bool projectSavingOptions_SaveInBinary;
bool projectSavingOptions_SaveMarkers;
bool projectSavingOptions_SaveBookmarks;
bool projectSavingOptions_SaveHistory;
bool projectSavingOptions_SavePianoRoll;
bool projectSavingOptions_SaveSelection;
int projectSavingOptions_GreenzoneSavingMode;
bool saveCompact_SaveInBinary;
bool saveCompact_SaveMarkers;
bool saveCompact_SaveBookmarks;
bool saveCompact_SaveHistory;
bool saveCompact_SavePianoRoll;
bool saveCompact_SaveSelection;
int saveCompact_GreenzoneSavingMode;
bool autosaveEnabled;
int autosavePeriod;
bool autosaveSilent;
bool tooltipsEnabled;
int currentPattern;
char lastAuthorName[AUTHOR_NAME_MAX_LEN];
private:

View File

@ -18,16 +18,16 @@ Lua - Manager of Lua features
#include "taseditor_project.h"
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern HISTORY history;
extern MARKERS_MANAGER markers_manager;
extern MARKERS_MANAGER markersManager;
extern BOOKMARKS bookmarks;
extern BRANCHES branches;
extern RECORDER recorder;
extern PLAYBACK playback;
extern GREENZONE greenzone;
extern PIANO_ROLL piano_roll;
extern PIANO_ROLL pianoRoll;
extern SELECTION selection;
extern void TaseditorDisableManualFunctionIfNeeded();
@ -41,7 +41,7 @@ TASEDITOR_LUA::TASEDITOR_LUA()
void TASEDITOR_LUA::init()
{
pending_changes.resize(0);
hwndRunFunction = GetDlgItem(taseditor_window.hwndTasEditor, TASEDITOR_RUN_MANUAL);
hwndRunFunctionButton = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_RUN_MANUAL);
reset();
}
void TASEDITOR_LUA::reset()
@ -53,21 +53,21 @@ void TASEDITOR_LUA::update()
}
void TASEDITOR_LUA::EnableRunFunction(const char* caption)
void TASEDITOR_LUA::enableRunFunction(const char* caption)
{
if (caption)
SetWindowText(hwndRunFunction, caption);
SetWindowText(hwndRunFunctionButton, caption);
else
SetWindowText(hwndRunFunction, defaultRunFunctionCaption);
EnableWindow(hwndRunFunction, true);
SetWindowText(hwndRunFunctionButton, defaultRunFunctionCaption);
EnableWindow(hwndRunFunctionButton, true);
}
void TASEDITOR_LUA::DisableRunFunction()
void TASEDITOR_LUA::disableRunFunction()
{
SetWindowText(hwndRunFunction, defaultRunFunctionCaption);
EnableWindow(hwndRunFunction, false);
SetWindowText(hwndRunFunctionButton, defaultRunFunctionCaption);
EnableWindow(hwndRunFunctionButton, false);
}
void TASEDITOR_LUA::InsertDelete_rows_to_Snaphot(SNAPSHOT& snapshot)
void TASEDITOR_LUA::insertAndDeleteRowsInSnaphot(SNAPSHOT& snapshot)
{
int size = pending_changes.size();
if (size)
@ -112,7 +112,7 @@ bool TASEDITOR_LUA::engaged()
bool TASEDITOR_LUA::markedframe(int frame)
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return markers_manager.GetMarker(frame) != 0;
return markersManager.getMarkerAtFrame(frame) != 0;
else
return false;
}
@ -121,7 +121,7 @@ bool TASEDITOR_LUA::markedframe(int frame)
int TASEDITOR_LUA::getmarker(int frame)
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return markers_manager.GetMarkerUp(frame);
return markersManager.getMarkerAboveFrame(frame);
else
return -1;
}
@ -131,17 +131,17 @@ int TASEDITOR_LUA::setmarker(int frame)
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
int marker_id = markers_manager.GetMarker(frame);
int marker_id = markersManager.getMarkerAtFrame(frame);
if (!marker_id)
{
marker_id = markers_manager.SetMarker(frame);
marker_id = markersManager.setMarkerAtFrame(frame);
if (marker_id)
{
// new Marker was created - register changes in TAS Editor
history.RegisterMarkersChange(MODTYPE_LUA_MARKER_SET, frame);
selection.must_find_current_marker = playback.must_find_current_marker = true;
piano_roll.RedrawRow(frame);
piano_roll.SetHeaderColumnLight(COLUMN_FRAMENUM, HEADER_LIGHT_MAX);
history.registerMarkersChange(MODTYPE_LUA_MARKER_SET, frame);
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
pianoRoll.redrawRow(frame);
pianoRoll.setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX);
}
}
return marker_id;
@ -154,14 +154,14 @@ void TASEDITOR_LUA::removemarker(int frame)
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
if (markers_manager.GetMarker(frame))
if (markersManager.getMarkerAtFrame(frame))
{
markers_manager.ClearMarker(frame);
markersManager.removeMarkerFromFrame(frame);
// Marker was deleted - register changes in TAS Editor
history.RegisterMarkersChange(MODTYPE_LUA_MARKER_REMOVE, frame);
selection.must_find_current_marker = playback.must_find_current_marker = true;
piano_roll.RedrawRow(frame);
piano_roll.SetHeaderColumnLight(COLUMN_FRAMENUM, HEADER_LIGHT_MAX);
history.registerMarkersChange(MODTYPE_LUA_MARKER_REMOVE, frame);
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
pianoRoll.redrawRow(frame);
pianoRoll.setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX);
}
}
}
@ -171,7 +171,7 @@ const char* TASEDITOR_LUA::getnote(int index)
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
return strdup(markers_manager.GetNote(index).c_str());
return strdup(markersManager.getNoteCopy(index).c_str());
} else
return NULL;
}
@ -184,12 +184,12 @@ void TASEDITOR_LUA::setnote(int index, const char* newtext)
// rename only if newtext is different from old text
char text[MAX_NOTE_LEN];
strncpy(text, newtext, MAX_NOTE_LEN - 1);
if (strcmp(markers_manager.GetNote(index).c_str(), text))
if (strcmp(markersManager.getNoteCopy(index).c_str(), text))
{
// text differs from old Note - rename
markers_manager.SetNote(index, text);
history.RegisterMarkersChange(MODTYPE_LUA_MARKER_RENAME, markers_manager.GetMarkerFrame(index), -1, text);
selection.must_find_current_marker = playback.must_find_current_marker = true;
markersManager.setNote(index, text);
history.registerMarkersChange(MODTYPE_LUA_MARKER_RENAME, markersManager.getMarkerFrameNumber(index), -1, text);
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
}
}
}
@ -198,7 +198,7 @@ void TASEDITOR_LUA::setnote(int index, const char* newtext)
int TASEDITOR_LUA::getcurrentbranch()
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return branches.GetCurrentBranch();
return branches.getCurrentBranch();
else
return -1;
}
@ -207,7 +207,7 @@ int TASEDITOR_LUA::getcurrentbranch()
const char* TASEDITOR_LUA::getrecordermode()
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return recorder.GetRecordingMode();
return recorder.getRecordingMode();
else
return NULL;
}
@ -216,7 +216,7 @@ const char* TASEDITOR_LUA::getrecordermode()
int TASEDITOR_LUA::getsuperimpose()
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return taseditor_config.superimpose;
return taseditorConfig.superimpose;
else
return -1;
}
@ -225,7 +225,7 @@ int TASEDITOR_LUA::getsuperimpose()
int TASEDITOR_LUA::getlostplayback()
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return playback.GetLostPosition();
return playback.getLastPosition();
else
return -1;
}
@ -234,7 +234,7 @@ int TASEDITOR_LUA::getlostplayback()
int TASEDITOR_LUA::getplaybacktarget()
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return playback.GetPauseFrame();
return playback.getPauseFrame();
else
return -1;
}
@ -252,7 +252,7 @@ void TASEDITOR_LUA::setplayback(int frame)
void TASEDITOR_LUA::stopseeking()
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
playback.SeekingStop();
playback.stopSeeking();
}
// table taseditor.getselection()
@ -260,14 +260,14 @@ void TASEDITOR_LUA::getselection(std::vector<int>& placeholder)
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
SelectionFrames* current_selection = selection.MakeStrobe();
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
int frames = current_selection->size();
if (!frames) return;
placeholder.resize(frames);
SelectionFrames::iterator current_selection_end(current_selection->end());
RowsSelection::iterator current_selection_end(current_selection->end());
int i = 0;
for(SelectionFrames::iterator it(current_selection->begin()); it != current_selection_end; ++it)
for(RowsSelection::iterator it(current_selection->begin()); it != current_selection_end; ++it)
placeholder[i++] = *it;
}
}
@ -277,9 +277,9 @@ void TASEDITOR_LUA::setselection(std::vector<int>& new_set)
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
selection.ClearSelection();
selection.clearAllRowsSelection();
for (int i = new_set.size() - 1; i >= 0; i--)
selection.SetRowSelection(new_set[i]);
selection.setRowSelection(new_set[i]);
}
}
@ -383,7 +383,7 @@ int TASEDITOR_LUA::applyinputchanges(const char* name)
{
// expand movie to fit the frame
currMovieData.insertEmpty(-1, 1 + pending_changes[i].frame - currMovieData.getNumRecords());
markers_manager.update();
markersManager.update();
InsertionDeletion_was_made = true;
}
switch (pending_changes[i].type)
@ -414,9 +414,9 @@ int TASEDITOR_LUA::applyinputchanges(const char* name)
{
InsertionDeletion_was_made = true;
currMovieData.insertEmpty(pending_changes[i].frame, pending_changes[i].data);
greenzone.laglog.InsertFrame(pending_changes[i].frame, false, pending_changes[i].data);
if (taseditor_config.bind_markers)
markers_manager.insertEmpty(pending_changes[i].frame, pending_changes[i].data);
greenzone.lagLog.insertFrame(pending_changes[i].frame, false, pending_changes[i].data);
if (taseditorConfig.bindMarkersToInput)
markersManager.insertEmpty(pending_changes[i].frame, pending_changes[i].data);
break;
}
case LUA_CHANGE_TYPE_DELETEFRAMES:
@ -426,28 +426,28 @@ int TASEDITOR_LUA::applyinputchanges(const char* name)
{
if (pending_changes[i].frame < (int)currMovieData.getNumRecords())
currMovieData.eraseRecords(pending_changes[i].frame);
greenzone.laglog.EraseFrame(pending_changes[i].frame);
if (taseditor_config.bind_markers)
markers_manager.EraseMarker(pending_changes[i].frame);
greenzone.lagLog.eraseFrame(pending_changes[i].frame);
if (taseditorConfig.bindMarkersToInput)
markersManager.eraseMarker(pending_changes[i].frame);
}
break;
}
}
}
if (taseditor_config.bind_markers)
selection.must_find_current_marker = playback.must_find_current_marker = true;
if (taseditorConfig.bindMarkersToInput)
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
// check if user deleted all frames
if (!currMovieData.getNumRecords())
playback.StartFromZero();
playback.restartPlaybackFromZeroGround();
// reduce Piano Roll
piano_roll.UpdateItemCount();
pianoRoll.updateLinesCount();
// check actual changes
int result = history.RegisterLuaChanges(name, start_index, InsertionDeletion_was_made);
int result = history.registerLuaChanges(name, start_index, InsertionDeletion_was_made);
if (result >= 0)
greenzone.InvalidateAndCheck(result);
greenzone.invalidateAndUpdatePlayback(result);
else
// check for special case: user deleted empty frames of the movie
greenzone.InvalidateAndCheck(currMovieData.getNumRecords() - 1);
greenzone.invalidateAndUpdatePlayback(currMovieData.getNumRecords() - 1);
pending_changes.resize(0);
return result;

View File

@ -10,7 +10,7 @@ struct PENDING_CHANGES
int data;
};
enum
enum LUA_CHANGE_TYPES
{
LUA_CHANGE_TYPE_INPUTCHANGE,
LUA_CHANGE_TYPE_INSERTFRAMES,
@ -34,10 +34,10 @@ public:
void reset();
void update();
void EnableRunFunction(const char* caption = NULL);
void DisableRunFunction();
void enableRunFunction(const char* caption = NULL);
void disableRunFunction();
void InsertDelete_rows_to_Snaphot(SNAPSHOT& snapshot);
void insertAndDeleteRowsInSnaphot(SNAPSHOT& snapshot);
// Taseditor Lua library
bool engaged();
@ -66,6 +66,6 @@ public:
private:
std::vector<PENDING_CHANGES> pending_changes;
HWND hwndRunFunction;
HWND hwndRunFunctionButton;
};

View File

@ -20,26 +20,26 @@ Project - Manager of working project
#include "utils/xstring.h"
#include "version.h"
extern TASEDITOR_CONFIG taseditor_config;
extern TASEDITOR_WINDOW taseditor_window;
extern MARKERS_MANAGER markers_manager;
extern TASEDITOR_CONFIG taseditorConfig;
extern TASEDITOR_WINDOW taseditorWindow;
extern MARKERS_MANAGER markersManager;
extern BOOKMARKS bookmarks;
extern POPUP_DISPLAY popup_display;
extern POPUP_DISPLAY popupDisplay;
extern GREENZONE greenzone;
extern PLAYBACK playback;
extern RECORDER recorder;
extern HISTORY history;
extern PIANO_ROLL piano_roll;
extern PIANO_ROLL pianoRoll;
extern SELECTION selection;
extern SPLICER splicer;
extern FCEUGI *GameInfo;
extern void FCEU_PrintError(char *format, ...);
extern bool SaveProject(bool save_compact = false);
extern bool SaveProjectAs(bool save_compact = false);
extern int GetInputType(MovieData& md);
extern void SetInputType(MovieData& md, int new_input_type);
extern bool saveProject(bool save_compact = false);
extern bool saveProjectAs(bool save_compact = false);
extern int getInputType(MovieData& md);
extern void setInputType(MovieData& md, int new_input_type);
TASEDITOR_PROJECT::TASEDITOR_PROJECT()
{
@ -60,34 +60,34 @@ void TASEDITOR_PROJECT::reset()
void TASEDITOR_PROJECT::update()
{
// if it's time to autosave - pop Save As dialog
if (changed && taseditor_window.TASEditor_focus && taseditor_config.enable_autosave && !projectFile.empty() && clock() >= next_save_shedule && piano_roll.drag_mode == DRAG_MODE_NONE)
if (changed && taseditorWindow.TASEditorIsInFocus && taseditorConfig.autosaveEnabled && !projectFile.empty() && clock() >= nextSaveShedule && pianoRoll.dragMode == DRAG_MODE_NONE)
{
if (taseditor_config.silent_autosave)
SaveProject();
if (taseditorConfig.autosaveSilent)
saveProject();
else
SaveProjectAs();
saveProjectAs();
// in case user pressed Cancel, postpone saving to next time
SheduleNextAutosave();
sheduleNextAutosave();
}
}
bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool save_markers, bool save_bookmarks, int save_greenzone, bool save_history, bool save_piano_roll, bool save_selection)
bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool saveMarkers, bool saveBookmarks, int saveGreenzone, bool saveHistory, bool savePianoRoll, bool saveSelection)
{
if (!different_name && GetProjectFile().empty())
if (!differentName && getProjectFile().empty())
// no different name specified, and there's no current filename of the project
return false;
// check MD5
char md5_movie[256];
char md5_rom[256];
strcpy(md5_movie, md5_asciistr(currMovieData.romChecksum));
strcpy(md5_rom, md5_asciistr(GameInfo->MD5));
if (strcmp(md5_movie, md5_rom))
char md5OfMovie[256];
char md5OfRom[256];
strcpy(md5OfMovie, md5_asciistr(currMovieData.romChecksum));
strcpy(md5OfRom, md5_asciistr(GameInfo->MD5));
if (strcmp(md5OfMovie, md5OfRom))
{
// checksums mismatch, check if they both aren't zero
unsigned int k, count1 = 0, count2 = 0;
for(k = 0; k < strlen(md5_movie); k++) count1 += md5_movie[k] - '0';
for(k = 0; k < strlen(md5_rom); k++) count2 += md5_rom[k] - '0';
for(k = 0; k < strlen(md5OfMovie); k++) count1 += md5OfMovie[k] - '0';
for(k = 0; k < strlen(md5OfRom); k++) count2 += md5OfRom[k] - '0';
if (count1 && count2)
{
// ask user if he wants to fix the checksum before saving
@ -95,13 +95,13 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool
strcpy(message, "Movie ROM:\n");
strncat(message, currMovieData.romFilename.c_str(), 2047 - strlen(message));
strncat(message, "\nMD5: ", 2047 - strlen(message));
strncat(message, md5_movie, 2047 - strlen(message));
strncat(message, md5OfMovie, 2047 - strlen(message));
strncat(message, "\n\nCurrent ROM:\n", 2047 - strlen(message));
strncat(message, GameInfo->filename, 2047 - strlen(message));
strncat(message, "\nMD5: ", 2047 - strlen(message));
strncat(message, md5_rom, 2047 - strlen(message));
strncat(message, md5OfRom, 2047 - strlen(message));
strncat(message, "\n\nFix the movie header before saving? ", 2047 - strlen(message));
int answer = MessageBox(taseditor_window.hwndTasEditor, message, "ROM Checksum Mismatch", MB_YESNOCANCEL);
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "ROM Checksum Mismatch", MB_YESNOCANCEL);
if (answer == IDCANCEL)
{
// cancel saving
@ -116,10 +116,10 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool
}
// open file for write
EMUFILE_FILE* ofs = 0;
if (different_name)
ofs = FCEUD_UTF8_fstream(different_name, "wb");
if (differentName)
ofs = FCEUD_UTF8_fstream(differentName, "wb");
else
ofs = FCEUD_UTF8_fstream(GetProjectFile().c_str(), "wb");
ofs = FCEUD_UTF8_fstream(getProjectFile().c_str(), "wb");
if (ofs)
{
// change cursor to hourglass
@ -127,67 +127,67 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool
// save fm2 data to the project file
currMovieData.loadFrameCount = currMovieData.records.size();
currMovieData.emuVersion = FCEU_VERSION_NUMERIC;
currMovieData.dump(ofs, save_binary);
unsigned int taseditor_data_offset = ofs->ftell();
currMovieData.dump(ofs, inputInBinary);
unsigned int taseditorDataOffset = ofs->ftell();
// save header: fm3 version + saved_stuff
write32le(PROJECT_FILE_CURRENT_VERSION, ofs);
unsigned int saved_stuff_map = 0;
if (save_markers) saved_stuff_map |= MARKERS_SAVED;
if (save_bookmarks) saved_stuff_map |= BOOKMARKS_SAVED;
if (save_greenzone != SAVE_GREENZONE_NO) saved_stuff_map |= GREENZONE_SAVED;
if (save_history) saved_stuff_map |= HISTORY_SAVED;
if (save_piano_roll) saved_stuff_map |= PIANO_ROLL_SAVED;
if (save_selection) saved_stuff_map |= SELECTION_SAVED;
write32le(saved_stuff_map, ofs);
unsigned int number_of_pointers = DEFAULT_NUMBER_OF_POINTERS;
write32le(number_of_pointers, ofs);
unsigned int savedStuffMap = 0;
if (saveMarkers) savedStuffMap |= MARKERS_SAVED;
if (saveBookmarks) savedStuffMap |= BOOKMARKS_SAVED;
if (saveGreenzone != GREENZONE_SAVING_MODE_NO) savedStuffMap |= GREENZONE_SAVED;
if (saveHistory) savedStuffMap |= HISTORY_SAVED;
if (savePianoRoll) savedStuffMap |= PIANO_ROLL_SAVED;
if (saveSelection) savedStuffMap |= SELECTION_SAVED;
write32le(savedStuffMap, ofs);
unsigned int numberOfPointers = DEFAULT_NUMBER_OF_POINTERS;
write32le(numberOfPointers, ofs);
// write dummy zeros to the file, where the offsets will be
for (unsigned int i = 0; i < number_of_pointers; ++i)
for (unsigned int i = 0; i < numberOfPointers; ++i)
write32le(0, ofs);
// save specified modules
unsigned int markers_offset = ofs->ftell();
markers_manager.save(ofs, save_markers);
unsigned int bookmarks_offset = ofs->ftell();
bookmarks.save(ofs, save_bookmarks);
unsigned int greenzone_offset = ofs->ftell();
greenzone.save(ofs, save_greenzone);
unsigned int history_offset = ofs->ftell();
history.save(ofs, save_history);
unsigned int piano_roll_offset = ofs->ftell();
piano_roll.save(ofs, save_piano_roll);
unsigned int selection_offset = ofs->ftell();
selection.save(ofs, save_selection);
unsigned int markersOffset = ofs->ftell();
markersManager.save(ofs, saveMarkers);
unsigned int bookmarksOffset = ofs->ftell();
bookmarks.save(ofs, saveBookmarks);
unsigned int greenzoneOffset = ofs->ftell();
greenzone.save(ofs, saveGreenzone);
unsigned int historyOffset = ofs->ftell();
history.save(ofs, saveHistory);
unsigned int pianoRollOffset = ofs->ftell();
pianoRoll.save(ofs, savePianoRoll);
unsigned int selectionOffset = ofs->ftell();
selection.save(ofs, saveSelection);
// now write offsets (pointers)
ofs->fseek(taseditor_data_offset + PROJECT_FILE_OFFSET_OF_POINTERS_DATA, SEEK_SET);
write32le(markers_offset, ofs);
write32le(bookmarks_offset, ofs);
write32le(greenzone_offset, ofs);
write32le(history_offset, ofs);
write32le(piano_roll_offset, ofs);
write32le(selection_offset, ofs);
ofs->fseek(taseditorDataOffset + PROJECT_FILE_OFFSET_OF_POINTERS_DATA, SEEK_SET);
write32le(markersOffset, ofs);
write32le(bookmarksOffset, ofs);
write32le(greenzoneOffset, ofs);
write32le(historyOffset, ofs);
write32le(pianoRollOffset, ofs);
write32le(selectionOffset, ofs);
// finish
delete ofs;
playback.UpdateProgressbar();
playback.updateProgressbar();
// also set project.changed to false, unless it was SaveCompact
if (!different_name)
if (!differentName)
reset();
// restore cursor
taseditor_window.must_update_mouse_cursor = true;
taseditorWindow.mustUpdateMouseCursor = true;
return true;
} else
{
return false;
}
}
bool TASEDITOR_PROJECT::load(const char* fullname)
bool TASEDITOR_PROJECT::load(const char* fullName)
{
bool load_all = true;
unsigned int taseditor_data_offset = 0;
EMUFILE_FILE ifs(fullname, "rb");
bool loadAll = true;
unsigned int taseditorDataOffset = 0;
EMUFILE_FILE ifs(fullName, "rb");
if (ifs.fail())
{
FCEU_PrintError("Error opening %s!", fullname);
FCEU_PrintError("Error opening %s!", fullName);
return false;
}
@ -199,16 +199,16 @@ bool TASEDITOR_PROJECT::load(const char* fullname)
if (LoadFM2(tempMovieData, &ifs, ifs.size(), false))
{
// check MD5
char md5_original[256];
char md5_current[256];
strcpy(md5_original, md5_asciistr(tempMovieData.romChecksum));
strcpy(md5_current, md5_asciistr(GameInfo->MD5));
if (strcmp(md5_original, md5_current))
char md5OfOriginal[256];
char md5OfCurrent[256];
strcpy(md5OfOriginal, md5_asciistr(tempMovieData.romChecksum));
strcpy(md5OfCurrent, md5_asciistr(GameInfo->MD5));
if (strcmp(md5OfOriginal, md5OfCurrent))
{
// checksums mismatch, check if they both aren't zero
unsigned int k, count1 = 0, count2 = 0;
for(k = 0; k < strlen(md5_original); k++) count1 += md5_original[k] - '0';
for(k = 0; k < strlen(md5_current); k++) count2 += md5_current[k] - '0';
for(k = 0; k < strlen(md5OfOriginal); k++) count1 += md5OfOriginal[k] - '0';
for(k = 0; k < strlen(md5OfCurrent); k++) count2 += md5OfCurrent[k] - '0';
if (count1 && count2)
{
// ask user if he really wants to load the project
@ -217,174 +217,174 @@ bool TASEDITOR_PROJECT::load(const char* fullname)
strcat(message, "Original ROM:\n");
strncat(message, tempMovieData.romFilename.c_str(), 2047 - strlen(message));
strncat(message, "\nMD5: ", 2047 - strlen(message));
strncat(message, md5_original, 2047 - strlen(message));
strncat(message, md5OfOriginal, 2047 - strlen(message));
strncat(message, "\n\nCurrent ROM:\n", 2047 - strlen(message));
strncat(message, GameInfo->filename, 2047 - strlen(message));
strncat(message, "\nMD5: ", 2047 - strlen(message));
strncat(message, md5_current, 2047 - strlen(message));
strncat(message, md5OfCurrent, 2047 - strlen(message));
strncat(message, "\n\nLoad the project anyway?", 2047 - strlen(message));
int answer = MessageBox(taseditor_window.hwndTasEditor, message, "ROM Checksum Mismatch", MB_YESNO);
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "ROM Checksum Mismatch", MB_YESNO);
if (answer == IDNO)
return false;
}
}
taseditor_data_offset = ifs.ftell();
taseditorDataOffset = ifs.ftell();
// load fm3 version from header and check it
unsigned int file_version;
if (read32le(&file_version, &ifs))
unsigned int projectFileVersion;
if (read32le(&projectFileVersion, &ifs))
{
if (file_version != PROJECT_FILE_CURRENT_VERSION)
if (projectFileVersion != PROJECT_FILE_CURRENT_VERSION)
{
char message[2048] = {0};
strcpy(message, "This project was saved using different version of TAS Editor!\n\n");
strcat(message, "Original version: ");
char version_num[11];
_itoa(file_version, version_num, 10);
strncat(message, version_num, 2047 - strlen(message));
char versionNum[11];
_itoa(projectFileVersion, versionNum, 10);
strncat(message, versionNum, 2047 - strlen(message));
strncat(message, "\nCurrent version: ", 2047 - strlen(message));
_itoa(PROJECT_FILE_CURRENT_VERSION, version_num, 10);
strncat(message, version_num, 2047 - strlen(message));
_itoa(PROJECT_FILE_CURRENT_VERSION, versionNum, 10);
strncat(message, versionNum, 2047 - strlen(message));
strncat(message, "\n\nClick Yes to try loading all data from the file (may crash).\n", 2047 - strlen(message));
strncat(message, "Click No to only load movie data.\n", 2047 - strlen(message));
strncat(message, "Click Cancel to abort loading.", 2047 - strlen(message));
int answer = MessageBox(taseditor_window.hwndTasEditor, message, "FM3 Version Mismatch", MB_YESNOCANCEL);
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "FM3 Version Mismatch", MB_YESNOCANCEL);
if (answer == IDCANCEL)
return false;
else if (answer == IDNO)
load_all = false;
loadAll = false;
}
} else
{
// couldn't even load header, this seems like an FM2
load_all = false;
loadAll = false;
char message[2048];
strcpy(message, "This file doesn't seem to be an FM3 project.\nIt only contains FM2 movie data. Load it anyway?");
int answer = MessageBox(taseditor_window.hwndTasEditor, message, "Opening FM2 file", MB_YESNO);
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "Opening FM2 file", MB_YESNO);
if (answer == IDNO)
return false;
}
// save data to currMovieData and continue loading
FCEU_printf("\nLoading TAS Editor project %s...\n", fullname);
FCEU_printf("\nLoading TAS Editor project %s...\n", fullName);
currMovieData = tempMovieData;
LoadSubtitles(currMovieData);
// ensure that movie has correct set of ports/fourscore
SetInputType(currMovieData, GetInputType(currMovieData));
setInputType(currMovieData, getInputType(currMovieData));
} else
{
FCEU_PrintError("Error loading movie data from %s!", fullname);
FCEU_PrintError("Error loading movie data from %s!", fullName);
// do not alter the project
return false;
}
unsigned int saved_stuff = 0;
unsigned int number_of_pointers = 0;
unsigned int data_offset = 0;
unsigned int pointer_offset = taseditor_data_offset + PROJECT_FILE_OFFSET_OF_POINTERS_DATA;
if (load_all)
unsigned int savedStuff = 0;
unsigned int numberOfPointers = 0;
unsigned int dataOffset = 0;
unsigned int pointerOffset = taseditorDataOffset + PROJECT_FILE_OFFSET_OF_POINTERS_DATA;
if (loadAll)
{
read32le(&saved_stuff, &ifs);
read32le(&number_of_pointers, &ifs);
read32le(&savedStuff, &ifs);
read32le(&numberOfPointers, &ifs);
// load modules
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
pointer_offset += sizeof(unsigned int);
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
pointerOffset += sizeof(unsigned int);
else
data_offset = 0;
markers_manager.load(&ifs, data_offset);
dataOffset = 0;
markersManager.load(&ifs, dataOffset);
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
pointer_offset += sizeof(unsigned int);
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
pointerOffset += sizeof(unsigned int);
else
data_offset = 0;
bookmarks.load(&ifs, data_offset);
dataOffset = 0;
bookmarks.load(&ifs, dataOffset);
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
pointer_offset += sizeof(unsigned int);
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
pointerOffset += sizeof(unsigned int);
else
data_offset = 0;
greenzone.load(&ifs, data_offset);
dataOffset = 0;
greenzone.load(&ifs, dataOffset);
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
pointer_offset += sizeof(unsigned int);
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
pointerOffset += sizeof(unsigned int);
else
data_offset = 0;
history.load(&ifs, data_offset);
dataOffset = 0;
history.load(&ifs, dataOffset);
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
pointer_offset += sizeof(unsigned int);
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
pointerOffset += sizeof(unsigned int);
else
data_offset = 0;
piano_roll.load(&ifs, data_offset);
dataOffset = 0;
pianoRoll.load(&ifs, dataOffset);
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
pointer_offset += sizeof(unsigned int);
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
pointerOffset += sizeof(unsigned int);
else
data_offset = 0;
selection.load(&ifs, data_offset);
dataOffset = 0;
selection.load(&ifs, dataOffset);
} else
{
// reset modules
markers_manager.load(&ifs, 0);
markersManager.load(&ifs, 0);
bookmarks.load(&ifs, 0);
greenzone.load(&ifs, 0);
history.load(&ifs, 0);
piano_roll.load(&ifs, 0);
pianoRoll.load(&ifs, 0);
selection.load(&ifs, 0);
}
// reset other modules
playback.reset();
recorder.reset();
splicer.reset();
popup_display.reset();
popupDisplay.reset();
reset();
RenameProject(fullname, load_all);
renameProject(fullName, loadAll);
// restore mouse cursor shape
taseditor_window.must_update_mouse_cursor = true;
taseditorWindow.mustUpdateMouseCursor = true;
return true;
}
void TASEDITOR_PROJECT::RenameProject(const char* new_fullname, bool filename_is_correct)
void TASEDITOR_PROJECT::renameProject(const char* newFullName, bool filenameIsCorrect)
{
projectFile = new_fullname;
projectFile = newFullName;
char drv[512], dir[512], name[512], ext[512]; // For getting the filename
splitpath(new_fullname, drv, dir, name, ext);
splitpath(newFullName, drv, dir, name, ext);
projectName = name;
std::string thisfm2name = name;
thisfm2name.append(".fm2");
fm2FileName = thisfm2name;
// if filename is not correct (for example, user opened a corrupted FM3) clear the filename, so on Ctrl+S user will be forwarded to SaveAs
if (!filename_is_correct)
if (!filenameIsCorrect)
projectFile.clear();
}
// -----------------------------------------------------------------
std::string TASEDITOR_PROJECT::GetProjectFile()
std::string TASEDITOR_PROJECT::getProjectFile()
{
return projectFile;
}
std::string TASEDITOR_PROJECT::GetProjectName()
std::string TASEDITOR_PROJECT::getProjectName()
{
return projectName;
}
std::string TASEDITOR_PROJECT::GetFM2Name()
std::string TASEDITOR_PROJECT::getFM2Name()
{
return fm2FileName;
}
void TASEDITOR_PROJECT::SetProjectChanged()
void TASEDITOR_PROJECT::setProjectChanged()
{
if (!changed)
{
changed = true;
taseditor_window.UpdateCaption();
SheduleNextAutosave();
taseditorWindow.updateCaption();
sheduleNextAutosave();
}
}
bool TASEDITOR_PROJECT::GetProjectChanged()
bool TASEDITOR_PROJECT::getProjectChanged()
{
return changed;
}
void TASEDITOR_PROJECT::SheduleNextAutosave()
void TASEDITOR_PROJECT::sheduleNextAutosave()
{
next_save_shedule = clock() + taseditor_config.autosave_period * AUTOSAVE_PERIOD_SCALE;
nextSaveShedule = clock() + taseditorConfig.autosavePeriod * AUTOSAVE_PERIOD_SCALE;
}

View File

@ -20,7 +20,6 @@
#include "editor.h"
#include "popup_display.h"
//not available unless we #define _WIN32_WINNT >= 0x501 (XP) and we're trying very hard to keep 2000 support.
#ifndef LVS_EX_DOUBLEBUFFER
#define LVS_EX_DOUBLEBUFFER 0x00010000
@ -51,23 +50,23 @@ public:
void reset();
void update();
bool save(const char* different_name = 0, bool save_binary = true, bool save_markers = true, bool save_bookmarks = true, int save_greenzone = SAVE_GREENZONE_ALL, bool save_history = true, bool save_piano_roll = true, bool save_selection = true);
bool load(const char* fullname);
bool save(const char* differentName = 0, bool inputInBinary = true, bool saveMarkers = true, bool saveBookmarks = true, int saveGreenzone = GREENZONE_SAVING_MODE_ALL, bool saveHistory = true, bool savePianoRoll = true, bool saveSelection = true);
bool load(const char* fullName);
void RenameProject(const char* new_fullname, bool filename_is_correct);
void renameProject(const char* newFullName, bool filenameIsCorrect);
std::string GetProjectFile();
std::string GetProjectName();
std::string GetFM2Name();
std::string getProjectFile();
std::string getProjectName();
std::string getFM2Name();
void SetProjectChanged();
bool GetProjectChanged();
void setProjectChanged();
bool getProjectChanged();
void SheduleNextAutosave();
void sheduleNextAutosave();
private:
bool changed;
int next_save_shedule;
int nextSaveShedule;
std::string projectFile; // full path
std::string projectName; // file name only

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
// Specification file for TASEDITOR_WINDOW class
enum Window_items_enum
enum TASEDITOR_WINDOW_ITEMS
{
WINDOWITEMS_PIANO_ROLL,
WINDOWITEMS_PLAYBACK_MARKER,
@ -54,7 +54,7 @@ enum Window_items_enum
#define PATTERNS_MENU_POS 5
#define PATTERNS_MAX_VISIBLE_NAME 50
struct Window_items_struct
struct WindowItemData
{
int number;
int id;
@ -62,11 +62,11 @@ struct Window_items_struct
int y;
int width;
int height;
char tooltip_text_base[TOOLTIP_TEXT_MAX_LEN];
char tooltip_text[TOOLTIP_TEXT_MAX_LEN];
bool static_rect;
int hotkey_emucmd;
HWND tooltip_hwnd;
char tooltipTextBase[TOOLTIP_TEXT_MAX_LEN];
char tooltipText[TOOLTIP_TEXT_MAX_LEN];
bool isStaticRect;
int hotkeyEmuCmd;
HWND tooltipHWND;
};
class TASEDITOR_WINDOW
@ -77,40 +77,36 @@ public:
void exit();
void reset();
void update();
void redraw();
void ResizeItems();
void WindowMovedOrResized();
void ChangeBookmarksListHeight(int new_height);
void resizeWindowItems();
void handleWindowMovingOrResizing();
void changeBookmarksListHeight(int newHeight);
void UpdateTooltips();
void updateTooltips();
void updateCaption();
void updateCheckedItems();
void UpdateCaption();
void RedrawTaseditor();
void updateRecentProjectsMenu();
void updateRecentProjectsArray(const char* addString);
void removeRecentProject(unsigned int which);
void loadRecentProject(int slot);
void UpdateCheckedItems();
void updatePatternsMenu();
void recheckPatternsMenu();
void UpdateRecentProjectsMenu();
void UpdateRecentProjectsArray(const char* addString);
void RemoveRecentProject(unsigned int which);
void LoadRecentProject(int slot);
HWND hwndTASEditor, hwndFindNote;
bool TASEditorIsInFocus;
bool isReadyForResizing;
int minWidth;
int minHeight;
void UpdatePatternsMenu();
void RecheckPatternsMenu();
HWND hwndTasEditor, hwndFindNote;
bool TASEditor_focus;
bool ready_for_resizing;
int min_width;
int min_height;
bool must_update_mouse_cursor;
bool mustUpdateMouseCursor;
private:
void CalculateItems();
void calculateItems();
HWND hToolTipWnd;
HMENU hmenu, patterns_menu;
HMENU hMainMenu, hPatternsMenu;
HICON hTaseditorIcon;
};

View File

@ -77,7 +77,7 @@
#include "taseditor/taseditor_window.h"
#include "taseditor/playback.h"
extern TASEDITOR_WINDOW taseditor_window;
extern TASEDITOR_WINDOW taseditorWindow;
extern PLAYBACK playback;
#include "Win32InputBox.h"
@ -1290,15 +1290,15 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
case WM_MOUSEWHEEL:
{
// send the message to TAS Editor
if (taseditor_window.hwndTasEditor)
SendMessage(taseditor_window.hwndTasEditor, msg, wParam, lParam);
if (taseditorWindow.hwndTASEditor)
SendMessage(taseditorWindow.hwndTASEditor, msg, wParam, lParam);
return 0;
}
case WM_MBUTTONDOWN:
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
playback.MiddleButtonClick();
playback.handleMiddleButtonClick();
return 0;
}
@ -1525,12 +1525,12 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
if (GameInfo && !(fileDropped.find(".fm3") == string::npos))
{
//.fm3 is at the end of the filename so that must be the extension
extern bool EnterTasEditor();
extern bool LoadProject(const char* fullname);
extern bool AskSaveProject();
if (EnterTasEditor()) //We are convinced it is a TAS Editor project file, attempt to load in TAS Editor
if (AskSaveProject()) // in case there's unsaved project
LoadProject(fileDropped.c_str());
extern bool enterTASEditor();
extern bool loadProject(const char* fullname);
extern bool askToSaveProject();
if (enterTASEditor()) //We are convinced it is a TAS Editor project file, attempt to load in TAS Editor
if (askToSaveProject()) // in case there's unsaved project
loadProject(fileDropped.c_str());
}
}
//-------------------------------------------------------
@ -2042,8 +2042,8 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
// break;
// Removing this tool since it is redundant to both
case MENU_TASEDITOR:
extern bool EnterTasEditor();
EnterTasEditor();
extern bool enterTASEditor();
enterTASEditor();
break;
case MENU_CONVERT_MOVIE:
ConvertFCM(hWnd);

View File

@ -58,7 +58,7 @@ extern void CDLoggerROMChanged();
extern void ResetDebugStatisticsCounters();
extern void SetMainWindowText();
extern void CDLoggerPPUChanged();
extern bool TaseditorIsRecording();
extern bool isTaseditorRecording();
extern int32 fps_scale;
extern int32 fps_scale_unpaused;
@ -1033,7 +1033,7 @@ bool FCEU_IsValidUI(EFCEUI ui) {
if (!GameInfo) return false;
if (FCEUMOV_Mode(MOVIEMODE_RECORD)) return true;
#ifdef WIN32
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && TaseditorIsRecording()) return true;
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && isTaseditorRecording()) return true;
#endif
if (!FCEUMOV_Mode(MOVIEMODE_INACTIVE)) return false;
break;

View File

@ -52,7 +52,7 @@
#include "drivers/win/window.h"
#include "drivers/win/ntview.h"
#include "drivers/win/taseditor.h"
extern bool Taseditor_rewind_now;
extern bool mustRewindNow;
#endif // WIN32
//it is easier to declare these input drivers extern here than include a bunch of files
@ -853,7 +853,7 @@ static void CommandSelectSaveSlot(void)
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
#ifdef WIN32
Taseditor_EMUCMD(execcmd);
handleEmuCmdByTaseditor(execcmd);
#endif
} else
{
@ -871,7 +871,7 @@ static void CommandStateSave(void)
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
#ifdef WIN32
Taseditor_EMUCMD(execcmd);
handleEmuCmdByTaseditor(execcmd);
#endif
} else
{
@ -892,7 +892,7 @@ static void CommandStateLoad(void)
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
#ifdef WIN32
Taseditor_EMUCMD(execcmd);
handleEmuCmdByTaseditor(execcmd);
#endif
} else
{
@ -955,8 +955,8 @@ void LagCounterToggle(void)
static void LaunchTasEditor(void)
{
#ifdef WIN32
extern bool EnterTasEditor();
EnterTasEditor();
extern bool enterTASEditor();
enterTASEditor();
#endif
}
@ -1131,7 +1131,7 @@ static void ReloadRom(void)
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
// load most recent project
Taseditor_EMUCMD(execcmd);
handleEmuCmdByTaseditor(execcmd);
} else
{
// load most recent ROM
@ -1180,13 +1180,13 @@ void ToggleFullscreen()
static void TaseditorRewindOn(void)
{
#ifdef WIN32
Taseditor_rewind_now = true;
mustRewindNow = true;
#endif
}
static void TaseditorRewindOff(void)
{
#ifdef WIN32
Taseditor_rewind_now = false;
mustRewindNow = false;
#endif
}
@ -1194,6 +1194,6 @@ static void TaseditorCommand(void)
{
#ifdef WIN32
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
Taseditor_EMUCMD(execcmd);
handleEmuCmdByTaseditor(execcmd);
#endif
}

View File

@ -1895,9 +1895,9 @@ void TaseditorDisableManualFunctionIfNeeded()
// check if LUACALL_TASEDITOR_MANUAL function is not nil
lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
if (!lua_isfunction(L, -1))
taseditor_lua.DisableRunFunction();
taseditor_lua.disableRunFunction();
lua_pop(L, 1);
} else taseditor_lua.DisableRunFunction();
} else taseditor_lua.disableRunFunction();
}
#endif
@ -4342,7 +4342,7 @@ static int taseditor_registermanual(lua_State *L)
lua_insert(L,1);
lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
#ifdef WIN32
taseditor_lua.EnableRunFunction(caption);
taseditor_lua.enableRunFunction(caption);
#endif
return 1;
}

View File

@ -41,7 +41,7 @@
extern void AddRecentMovieFile(const char *filename);
#include "./drivers/win/taseditor.h"
extern bool emulator_must_run_taseditor;
extern bool mustEngageTaseditor;
#endif
using namespace std;
@ -992,13 +992,13 @@ void FCEUMOV_AddInputState()
currMovieData.insertEmpty(-1, (currFrameCounter + 1) - ((int)currMovieData.records.size() - 1));
MovieRecord* mr = &currMovieData.records[currFrameCounter];
if (TaseditorIsRecording())
if (isTaseditorRecording())
{
// record commands and buttons
mr->commands |= _currCommand;
joyports[0].log(mr);
joyports[1].log(mr);
Taseditor_RecordInput();
recordInputByTaseditor();
}
// replay buttons
joyports[0].load(mr);
@ -1191,7 +1191,7 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size)
#ifdef WIN32
int result = MessageBox(hAppWnd, "This movie is a TAS Editor project file.\nIt can be modified in TAS Editor only.\n\nOpen it in TAS Editor now?", "Movie Replay", MB_YESNO);
if (result == IDYES)
emulator_must_run_taseditor = true;
mustEngageTaseditor = true;
#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
@ -1496,7 +1496,7 @@ void FCEUI_MoviePlayFromBeginning(void)
if (movieMode == MOVIEMODE_TASEDITOR)
{
#ifdef WIN32
Taseditor_EMUCMD(EMUCMD_MOVIE_PLAY_FROM_BEGINNING);
handleEmuCmdByTaseditor(EMUCMD_MOVIE_PLAY_FROM_BEGINNING);
#endif
} else if (movieMode != MOVIEMODE_INACTIVE)
{

View File

@ -215,7 +215,8 @@ static int CTRL(FCEUFILE *fp) {
GameInfo->input[1] = SI_ZAPPER;
} else {
FCEU_printf(" Incorrect Control Chunk Size (%d). Data is:", uchead.info);
for(i = 0; i < uchead.info; i++) {
for(i = 0; i < (int)uchead.info; i++)
{
t = FCEU_fgetc(fp);
FCEU_printf(" %02x", t);
}