* Tasedit: accelerator table

* Tasedit: new menu item "Config"
* Tasedit: Config->"Set greenzone capacity", auto-clearing old savestates
* Tasedit: pauseframe is shown by flashing color
This commit is contained in:
ansstuff 2011-09-19 18:13:31 +00:00
parent feae56ad1d
commit d2a886ebb1
12 changed files with 204 additions and 132 deletions

View File

@ -13,6 +13,9 @@ History
- Lessened the complexity of the class, made it less generic (since its purpose is to be simple) - Lessened the complexity of the class, made it less generic (since its purpose is to be simple)
- Updated the dialog template and made OK button as default button - Updated the dialog template and made OK button as default button
18-Sept-2011
- AnS: added szResult initializing to GetInteger
*/ */
typedef struct _MSDN_DLGTEMPLATEEX typedef struct _MSDN_DLGTEMPLATEEX
@ -228,7 +231,8 @@ INT_PTR CWin32InputBox::GetInteger(
{ {
WIN32INPUTBOX_PARAM param; WIN32INPUTBOX_PARAM param;
char szResult[20] = {'0'}; char szResult[20];
itoa(result,szResult,10);
param.szTitle = szTitle; param.szTitle = szTitle;
param.szPrompt = szPrompt; param.szPrompt = szPrompt;
param.szResult = szResult; param.szResult = szResult;

View File

@ -71,6 +71,7 @@ extern bool TASEdit_follow_playback;
extern bool TASEdit_show_lag_frames; extern bool TASEdit_show_lag_frames;
extern bool TASEdit_show_tweak_count; extern bool TASEdit_show_tweak_count;
extern bool TASEdit_restore_position; extern bool TASEdit_restore_position;
extern int TASEdit_greenzone_capacity;
//window positions and sizes: //window positions and sizes:
extern int ChtPosX,ChtPosY; extern int ChtPosX,ChtPosY;
@ -290,6 +291,7 @@ static CFGSTRUCT fceuconfig[] = {
AC(TASEdit_show_lag_frames), AC(TASEdit_show_lag_frames),
AC(TASEdit_show_tweak_count), AC(TASEdit_show_tweak_count),
AC(TASEdit_restore_position), AC(TASEdit_restore_position),
AC(TASEdit_greenzone_capacity),
AC(lagCounterDisplay), AC(lagCounterDisplay),
AC(oldInputDisplay), AC(oldInputDisplay),
AC(movieSubtitles), AC(movieSubtitles),

View File

@ -233,21 +233,23 @@ BEGIN
MENUITEM "Cu&t\tCtrl+X", ID_TASEDIT_CUT MENUITEM "Cu&t\tCtrl+X", ID_TASEDIT_CUT
MENUITEM "&Copy\tCtrl+C", ID_TASEDIT_COPY MENUITEM "&Copy\tCtrl+C", ID_TASEDIT_COPY
MENUITEM "&Paste\tCtrl+V", ID_TASEDIT_PASTE MENUITEM "&Paste\tCtrl+V", ID_TASEDIT_PASTE
MENUITEM "Paste to &New\tCtrl+Shift+V", ID_TASEDIT_PASTETONEW, INACTIVE
MENUITEM "&Delete\tCtrl+Delete", ID_TASEDIT_DELETE MENUITEM "&Delete\tCtrl+Delete", ID_TASEDIT_DELETE
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "&Add Marker", ID_EDIT_ADDMARKER, INACTIVE MENUITEM "&Add Marker", ID_EDIT_ADDMARKER, INACTIVE
MENUITEM "&Remove Marker", ID_EDIT_REMOVEMARKER, INACTIVE MENUITEM "&Remove Marker", ID_EDIT_REMOVEMARKER, INACTIVE
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "&Truncate\tCtrl+T", ID_EDIT_TRUNCATE MENUITEM "&Truncate\tCtrl+T", ID_EDIT_TRUNCATE
MENUITEM "&Branch\tCtrl+B", ID_EDIT_BRANCH, INACTIVE
END END
POPUP "&View" POPUP "&View"
BEGIN BEGIN
MENUITEM "Highlight &lag frames", ID_VIEW_SHOW_LAG_FRAMES MENUITEM "Highlight &lag frames", ID_VIEW_SHOW_LAG_FRAMES
MENUITEM "Show T&weak count", ID_VIEW_SHOW_TWEAK_COUNT MENUITEM "Show T&weak count", ID_VIEW_SHOW_TWEAK_COUNT
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "&Follow playback", ID_VIEW_FOLLOW_PLAYBACK MENUITEM "&Follow playback\tCtrl+F", ID_VIEW_FOLLOW_PLAYBACK
END
POPUP "Config"
BEGIN
MENUITEM "Set greenzone capacity", ID_CONFIG_SETGREENZONECAPACITY
END END
POPUP "&Help" POPUP "&Help"
BEGIN BEGIN
@ -339,13 +341,10 @@ BEGIN
MENUITEM "Insert number of Frames", ID_CONTEXT_SELECTED_INSERTFRAMES2 MENUITEM "Insert number of Frames", ID_CONTEXT_SELECTED_INSERTFRAMES2
MENUITEM "Delete Frame(s)", ID_CONTEXT_SELECTED_DELETEFRAMES MENUITEM "Delete Frame(s)", ID_CONTEXT_SELECTED_DELETEFRAMES
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "Paste to New", ID_CONTEXT_SELECTED_PASTETONEW, INACTIVE
MENUITEM SEPARATOR
MENUITEM "Add Marker", ID_CONTEXT_SELECTED_ADDMARKER, INACTIVE MENUITEM "Add Marker", ID_CONTEXT_SELECTED_ADDMARKER, INACTIVE
MENUITEM "Remove Marker", ID_CONTEXT_SELECTED_REMOVEMARKER, INACTIVE MENUITEM "Remove Marker", ID_CONTEXT_SELECTED_REMOVEMARKER, INACTIVE
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "Truncate", ID_CONTEXT_SELECTED_TRUNCATE MENUITEM "Truncate", ID_CONTEXT_SELECTED_TRUNCATE
MENUITEM "Branch", ID_CONTEXT_SELECTED_BRANCH, INACTIVE
END END
END END
@ -1341,7 +1340,7 @@ CAPTION "TAS Editor"
MENU TASEDITMENU MENU TASEDITMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,5,324,370 CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER,7,5,324,370
PUSHBUTTON "<<",TASEDIT_REWIND_FULL,341,14,22,14 PUSHBUTTON "<<",TASEDIT_REWIND_FULL,341,14,22,14
PUSHBUTTON "<",TASEDIT_REWIND,363,14,22,14 PUSHBUTTON "<",TASEDIT_REWIND,363,14,22,14
PUSHBUTTON "||",TASEDIT_PLAYSTOP,385,14,22,14 PUSHBUTTON "||",TASEDIT_PLAYSTOP,385,14,22,14
@ -1349,7 +1348,7 @@ BEGIN
PUSHBUTTON ">>",TASEDIT_FOWARD_FULL,429,14,22,14 PUSHBUTTON ">>",TASEDIT_FOWARD_FULL,429,14,22,14
GROUPBOX "Playback control",IDC_STATIC,337,5,118,41,BS_CENTER,WS_EX_RIGHT GROUPBOX "Playback control",IDC_STATIC,337,5,118,41,BS_CENTER,WS_EX_RIGHT
GROUPBOX "Project Input Logs",IDC_STATIC,337,246,118,129,BS_CENTER,WS_EX_RIGHT GROUPBOX "Project Input Logs",IDC_STATIC,337,246,118,129,BS_CENTER,WS_EX_RIGHT
CONTROL "",IDC_LIST2,"SysListView32",LVS_LIST | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,342,257,109,114 CONTROL "",IDC_LIST2,"SysListView32",LVS_LIST | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,342,257,109,114,WS_EX_LEFTSCROLLBAR
LTEXT "Tweak Count",IDC_TWEAKCOUNT,344,113,84,8 LTEXT "Tweak Count",IDC_TWEAKCOUNT,344,113,84,8
GROUPBOX "Recording input",IDC_STATIC,337,47,118,62,BS_CENTER,WS_EX_RIGHT GROUPBOX "Recording input",IDC_STATIC,337,47,118,62,BS_CENTER,WS_EX_RIGHT
CONTROL " Auto-restore last position",CHECK_AUTORESTORE_PLAYBACK, CONTROL " Auto-restore last position",CHECK_AUTORESTORE_PLAYBACK,
@ -1989,16 +1988,14 @@ END
IDR_ACCELERATOR1 ACCELERATORS IDR_ACCELERATOR1 ACCELERATORS
BEGIN BEGIN
"B", ACCEL_CTRL_B, VIRTKEY, CONTROL, NOINVERT
VK_DELETE, ACCEL_CTRL_DELETE, VIRTKEY, CONTROL, NOINVERT VK_DELETE, ACCEL_CTRL_DELETE, VIRTKEY, CONTROL, NOINVERT
"E", ACCEL_CTRL_E, VIRTKEY, CONTROL, NOINVERT
"N", ACCEL_CTRL_N, VIRTKEY, CONTROL, NOINVERT
"O", ACCEL_CTRL_O, VIRTKEY, CONTROL, NOINVERT
"S", ACCEL_CTRL_S, VIRTKEY, CONTROL, NOINVERT "S", ACCEL_CTRL_S, VIRTKEY, CONTROL, NOINVERT
"S", ACCEL_CTRL_SHIFT_S, VIRTKEY, SHIFT, CONTROL, NOINVERT
"V", ACCEL_CTRL_SHIFT_V, VIRTKEY, SHIFT, CONTROL, NOINVERT
"T", ACCEL_CTRL_T, VIRTKEY, CONTROL, NOINVERT "T", ACCEL_CTRL_T, VIRTKEY, CONTROL, NOINVERT
"W", ACCEL_CTRL_W, VIRTKEY, CONTROL, NOINVERT "C", ACCEL_CTRL_C, VIRTKEY, CONTROL, NOINVERT
"V", ACCEL_CTRL_V, VIRTKEY, CONTROL, NOINVERT
"X", ACCEL_CTRL_X, VIRTKEY, CONTROL, NOINVERT
"F", ACCEL_CTRL_F, VIRTKEY, CONTROL, NOINVERT
"P", ACCEL_CTRL_P, VIRTKEY, CONTROL, NOINVERT
END END
IDR_RWACCELERATOR ACCELERATORS IDR_RWACCELERATOR ACCELERATORS

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -817,6 +817,9 @@
#define ID_CONTEXT_SELECTED_INSERTFRAME 40423 #define ID_CONTEXT_SELECTED_INSERTFRAME 40423
#define ID_SELECTED_INSERTFRAMES40424 40424 #define ID_SELECTED_INSERTFRAMES40424 40424
#define ID_CONTEXT_SELECTED_INSERTFRAMES2 40425 #define ID_CONTEXT_SELECTED_INSERTFRAMES2 40425
#define ACCEL_CTRL_F 40429
#define ACCEL_CTRL_P 40430
#define ID_CONFIG_SETGREENZONECAPACITY 40432
#define IDC_DEBUGGER_ICONTRAY 55535 #define IDC_DEBUGGER_ICONTRAY 55535
#define MW_ValueLabel2 65423 #define MW_ValueLabel2 65423
#define MW_ValueLabel1 65426 #define MW_ValueLabel1 65426
@ -826,7 +829,7 @@
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 160 #define _APS_NEXT_RESOURCE_VALUE 160
#define _APS_NEXT_COMMAND_VALUE 40426 #define _APS_NEXT_COMMAND_VALUE 40433
#define _APS_NEXT_CONTROL_VALUE 1262 #define _APS_NEXT_CONTROL_VALUE 1262
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif

View File

@ -1,6 +1,7 @@
#include <set> #include <set>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <time.h>
#include "common.h" #include "common.h"
#include "tasedit.h" #include "tasedit.h"
@ -22,6 +23,10 @@ using namespace std;
//http://forums.devx.com/archive/index.php/t-37234.html //http://forums.devx.com/archive/index.php/t-37234.html
int old_movie_readonly = -1; int old_movie_readonly = -1;
int lastCursor;
int old_pauseframe;
bool old_show_pauseframe;
bool show_pauseframe;
// vars saved in cfg file // vars saved in cfg file
int TasEdit_wndx, TasEdit_wndy; int TasEdit_wndx, TasEdit_wndy;
@ -29,6 +34,7 @@ bool TASEdit_follow_playback = true;
bool TASEdit_show_lag_frames = true; bool TASEdit_show_lag_frames = true;
bool TASEdit_show_tweak_count = false; bool TASEdit_show_tweak_count = false;
bool TASEdit_restore_position = false; bool TASEdit_restore_position = false;
int TASEdit_greenzone_capacity = GREENZONE_DEFAULT_CAPACITY;
string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page
char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"}; char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"};
@ -36,7 +42,6 @@ char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R
HWND hwndTasEdit = 0; HWND hwndTasEdit = 0;
static HMENU hmenu, hrmenu; static HMENU hmenu, hrmenu;
static int lastCursor;
static HWND hwndList, hwndHeader, hwndTweakCount; static HWND hwndList, hwndHeader, hwndTweakCount;
static RECT rectTweakCount; static RECT rectTweakCount;
static WNDPROC hwndHeader_oldWndproc, hwndList_oldWndProc; static WNDPROC hwndHeader_oldWndproc, hwndList_oldWndProc;
@ -114,7 +119,7 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg)
if(cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2) if(cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2)
{ {
// frame number // frame number
if (cell_y == currFrameCounter) if (cell_y == currFrameCounter || (cell_y == pauseframe-1 && show_pauseframe))
{ {
// current frame // current frame
msg->clrTextBk = CUR_FRAMENUM_COLOR; msg->clrTextBk = CUR_FRAMENUM_COLOR;
@ -133,7 +138,7 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg)
} else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2) } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2)
{ {
// pad 1 or 3 // pad 1 or 3
if (cell_y == currFrameCounter) if (cell_y == currFrameCounter || (cell_y == pauseframe-1 && show_pauseframe))
{ {
// current frame // current frame
msg->clrTextBk = CUR_INPUT_COLOR1; msg->clrTextBk = CUR_INPUT_COLOR1;
@ -152,7 +157,7 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg)
} else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3) } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3)
{ {
// pad 2 or 4 // pad 2 or 4
if (cell_y == currFrameCounter) if (cell_y == currFrameCounter || (cell_y == pauseframe-1 && show_pauseframe))
{ {
// current frame // current frame
msg->clrTextBk = CUR_INPUT_COLOR2; msg->clrTextBk = CUR_INPUT_COLOR2;
@ -176,13 +181,6 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg)
} }
} }
void ExitTasEdit()
{
movieMode = MOVIEMODE_INACTIVE;
FCEU_DispMessage("Tasedit disengaged",0);
CreateCleanMovie();
}
// called from the rest of the emulator when things happen and the tasedit should change to reflect it // called from the rest of the emulator when things happen and the tasedit should change to reflect it
void UpdateTasEdit() void UpdateTasEdit()
{ {
@ -209,11 +207,22 @@ void UpdateTasEdit()
{ {
FollowPlayback(); FollowPlayback();
//update the old and new rows //update the old and new rows
ListView_RedrawItems(hwndList,lastCursor,lastCursor); RedrawRow(lastCursor);
ListView_RedrawItems(hwndList,currFrameCounter,currFrameCounter); RedrawRow(currFrameCounter);
UpdateWindow(hwndList); UpdateWindow(hwndList);
lastCursor = currFrameCounter; lastCursor = currFrameCounter;
} }
// update flashing pauseframe
if (old_pauseframe != pauseframe && old_pauseframe > 0) RedrawRow(old_pauseframe-1);
old_pauseframe = pauseframe;
old_show_pauseframe = show_pauseframe;
if (pauseframe > 0)
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD) & 1;
else
show_pauseframe = false;
if (old_show_pauseframe != show_pauseframe) RedrawRow(pauseframe-1);
// update window caption // update window caption
if ((!old_movie_readonly) == movie_readonly) if ((!old_movie_readonly) == movie_readonly)
{ {
@ -228,13 +237,18 @@ void UpdateTasEdit()
} }
} }
void RedrawTasedit()
{
InvalidateRect(hwndTasEdit,0,FALSE);
}
void RedrawList() void RedrawList()
{ {
InvalidateRect(hwndList,0,FALSE); InvalidateRect(hwndList,0,FALSE);
} }
void RedrawTasedit() void RedrawRow(int index)
{ {
InvalidateRect(hwndTasEdit,0,FALSE); if (ListView_IsItemVisible(hwndList, index))
ListView_RedrawItems(hwndList,index,index);
} }
void RedrawTweakCount() void RedrawTweakCount()
{ {
@ -302,6 +316,9 @@ void InvalidateGreenZone(int after)
{ {
if (TASEdit_restore_position) if (TASEdit_restore_position)
{ {
if (pauseframe-1 > currFrameCounter)
JumpToFrame(pauseframe-1);
else
JumpToFrame(currFrameCounter); JumpToFrame(currFrameCounter);
turbo = true; turbo = true;
} else } else
@ -314,13 +331,9 @@ void InvalidateGreenZone(int after)
RedrawList(); RedrawList();
} }
/* A function that tries jumping to a given frame. If unsuccessful, it than tries to jump to
a previously good frame and fastforward to it.
Returns true if a jump to the frame is made, false if nothing done.
*/
bool JumpToFrame(int index) bool JumpToFrame(int index)
{ {
// Returns true if a jump to the frame is made, false if nothing's done.
if (index<0) return false; if (index<0) return false;
if (index >= currMovieData.greenZoneCount) if (index >= currMovieData.greenZoneCount)
@ -340,6 +353,13 @@ bool JumpToFrame(int index)
if (currMovieData.loadTasSavestate(index)) if (currMovieData.loadTasSavestate(index))
{ {
currFrameCounter = index; currFrameCounter = index;
// if playback was seeking, pause emulation right here
if (pauseframe > 0)
{
if (!FCEUI_EmulationPaused()) FCEUI_ToggleEmulationPause();
pauseframe = -1;
}
turbo = false;
return true; return true;
} }
//Search for an earlier frame with savestate //Search for an earlier frame with savestate
@ -373,11 +393,11 @@ void DoubleClick(LPNMITEMACTIVATE info)
//if the icon or frame columns were double clicked: //if the icon or frame columns were double clicked:
if(info->iSubItem == COLUMN_ARROW) if(info->iSubItem == COLUMN_ARROW)
{ {
// set bookmark (of current bookmark slot) here
} else if(info->iSubItem == COLUMN_FRAMENUM || info->iSubItem == COLUMN_FRAMENUM2) } else if(info->iSubItem == COLUMN_FRAMENUM || info->iSubItem == COLUMN_FRAMENUM2)
{ {
JumpToFrame(index); JumpToFrame(index);
ClearSelection();
} }
else if(info->iSubItem >= COLUMN_JOYPAD1_A && info->iSubItem <= COLUMN_JOYPAD4_R) else if(info->iSubItem >= COLUMN_JOYPAD1_A && info->iSubItem <= COLUMN_JOYPAD4_R)
{ {
@ -398,7 +418,6 @@ void DoubleClick(LPNMITEMACTIVATE info)
{ {
//update one row //update one row
currMovieData.records[index].toggleBit(joy,bit); currMovieData.records[index].toggleBit(joy,bit);
//ListView_RedrawItems(hwndList,index,index);
} }
InvalidateGreenZone(index); InvalidateGreenZone(index);
} }
@ -412,7 +431,6 @@ static void ClearSelection()
ListView_SetItemState(hwndList,-1,0, LVIS_SELECTED); ListView_SetItemState(hwndList,-1,0, LVIS_SELECTED);
selectionFrames.clear(); selectionFrames.clear();
lastCursor=-1;
} }
//insert frames at the currently selected positions. //insert frames at the currently selected positions.
@ -681,31 +699,19 @@ static bool Paste()
return result; return result;
} }
//pastes the current clipboard selection into a new inputlog
static void PastetoNew()
{
}
//removes the current selection (does not put in clipboard) //removes the current selection (does not put in clipboard)
static void Delete() static void Delete()
{ {
DeleteFrames(); DeleteFrames();
} }
//Adds a marker to left column at selected frame (if multiple frames selected, it is placed at end of selection)
void AddMarker() void AddMarker()
{ {
} }
//Removes marker from selected frame (if multiple frames selected, all markers in selection removed?
void RemoveMarker() void RemoveMarker()
{ {
} }
//Makes new branch (timeline), takes current frame and creates new input log of all frames before it, new input log will be in focus
void Branch()
{
}
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
//The subclass wndproc for the listview header //The subclass wndproc for the listview header
@ -723,7 +729,7 @@ static LRESULT APIENTRY HeaderWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lP
info.pt.x = GET_X_LPARAM(lParam); info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam); info.pt.y = GET_Y_LPARAM(lParam);
SendMessage(hWnd,HDM_HITTEST,0,(LPARAM)&info); SendMessage(hWnd,HDM_HITTEST,0,(LPARAM)&info);
if(info.iItem != -1) if(info.iItem >= COLUMN_JOYPAD1_A && info.iItem <= COLUMN_JOYPAD4_R)
ColumnSet(info.iItem); ColumnSet(info.iItem);
} }
} }
@ -769,9 +775,9 @@ static void InitDialog()
hwndList_oldWndProc = (WNDPROC)SetWindowLong(hwndList,GWL_WNDPROC,(LONG)ListWndProc); hwndList_oldWndProc = (WNDPROC)SetWindowLong(hwndList,GWL_WNDPROC,(LONG)ListWndProc);
//setup all images for the listview //setup all images for the listview
HIMAGELIST himglist = ImageList_Create(8,12,ILC_COLOR32 | ILC_MASK,1,1); HIMAGELIST himglist = ImageList_Create(8,12,ILC_COLOR8 | ILC_MASK,1,1);
HBITMAP bmp = LoadBitmap(fceu_hInstance,MAKEINTRESOURCE(IDB_TE_ARROW)); HBITMAP bmp = LoadBitmap(fceu_hInstance,MAKEINTRESOURCE(IDB_TE_ARROW));
ImageList_AddMasked(himglist, bmp, RGB(255,0,255)); ImageList_AddMasked(himglist, bmp, 0xFF00FF);
DeleteObject(bmp); DeleteObject(bmp);
ListView_SetImageList(hwndList,himglist,LVSIL_SMALL); ListView_SetImageList(hwndList,himglist,LVSIL_SMALL);
//doesnt work well?? //doesnt work well??
@ -782,10 +788,11 @@ static void InitDialog()
int colidx=0; int colidx=0;
// arrow column // arrow column
lvc.mask = LVCF_WIDTH; lvc.mask = LVCF_WIDTH;
lvc.cx = 14; lvc.cx = 12;
ListView_InsertColumn(hwndList, colidx++, &lvc); ListView_InsertColumn(hwndList, colidx++, &lvc);
// frame number column // frame number column
lvc.mask = LVCF_WIDTH | LVCF_TEXT; lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT;
lvc.fmt = LVCFMT_CENTER;
lvc.cx = 92; lvc.cx = 92;
lvc.pszText = "Frame#"; lvc.pszText = "Frame#";
ListView_InsertColumn(hwndList, colidx++, &lvc); ListView_InsertColumn(hwndList, colidx++, &lvc);
@ -809,7 +816,8 @@ static void InitDialog()
void AddFourscoreColumns() void AddFourscoreColumns()
{ {
LVCOLUMN lvc; LVCOLUMN lvc;
lvc.mask = LVCF_WIDTH | LVCF_TEXT; lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT;
lvc.fmt = LVCFMT_CENTER;
lvc.cx = 21; lvc.cx = 21;
int colidx = COLUMN_JOYPAD3_A; int colidx = COLUMN_JOYPAD3_A;
for (int joy = 0; joy < 2; ++joy) for (int joy = 0; joy < 2; ++joy)
@ -918,7 +926,9 @@ static void OpenProject()
RemoveFourscoreColumns(); RemoveFourscoreColumns();
else if (!last_fourscore && currMovieData.fourscore) else if (!last_fourscore && currMovieData.fourscore)
AddFourscoreColumns(); AddFourscoreColumns();
if (!FCEUI_EmulationPaused()) FCEUI_ToggleEmulationPause();
FollowPlayback(); FollowPlayback();
RedrawTasedit();
} }
} }
@ -1146,12 +1156,10 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_COMMAND: case WM_COMMAND:
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case ACCEL_CTRL_N:
case ID_FILE_NEWPROJECT: case ID_FILE_NEWPROJECT:
NewProject(); NewProject();
break; break;
case ACCEL_CTRL_O:
case ID_FILE_OPENPROJECT: case ID_FILE_OPENPROJECT:
OpenProject(); OpenProject();
break; break;
@ -1161,7 +1169,6 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
SaveProject(); SaveProject();
break; break;
case ACCEL_CTRL_SHIFT_S:
case ID_FILE_SAVEPROJECTAS: case ID_FILE_SAVEPROJECTAS:
SaveProjectAs(); SaveProjectAs();
break; break;
@ -1198,12 +1205,6 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
Paste(); Paste();
break; break;
case ACCEL_CTRL_SHIFT_V: //Takes selected frames and creates new inputlog files
case ID_TASEDIT_PASTETONEW:
case ID_CONTEXT_SELECTED_PASTETONEW:
PastetoNew();
break;
case ACCEL_CTRL_DELETE: case ACCEL_CTRL_DELETE:
case ID_TASEDIT_DELETE: case ID_TASEDIT_DELETE:
Delete(); Delete();
@ -1225,11 +1226,6 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case ID_CONTEXT_STRAY_TRUNCATE: case ID_CONTEXT_STRAY_TRUNCATE:
Truncate(); Truncate();
break; break;
case ACCEL_CTRL_B:
case ID_EDIT_BRANCH:
case ID_CONTEXT_SELECTED_BRANCH:
Branch();
break;
case ID_HELP_TASEDITHELP: case ID_HELP_TASEDITHELP:
OpenHelpWindow(tasedithelp); OpenHelpWindow(tasedithelp);
@ -1239,8 +1235,10 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case MENU_CONTEXT_STRAY_INSERTFRAMES: case MENU_CONTEXT_STRAY_INSERTFRAMES:
case ID_CONTEXT_SELECTED_INSERTFRAMES2: case ID_CONTEXT_SELECTED_INSERTFRAMES2:
{ {
int frames; int frames = 1;
if(CWin32InputBox::GetInteger("Insert Frames", "How many frames?", frames, hwndDlg) == IDOK) if(CWin32InputBox::GetInteger("Insert Frames", "How many frames?", frames, hwndDlg) == IDOK)
{
if (frames > 0)
{ {
if (selectionFrames.size()) if (selectionFrames.size())
{ {
@ -1256,6 +1254,7 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
} }
} }
} }
}
break; break;
case ID_CONTEXT_SELECTED_INSERTFRAMES: case ID_CONTEXT_SELECTED_INSERTFRAMES:
@ -1296,11 +1295,16 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
JumpToFrame(currMovieData.greenZoneCount-1); JumpToFrame(currMovieData.greenZoneCount-1);
FollowPlayback(); FollowPlayback();
break; break;
case ACCEL_CTRL_F:
case ID_VIEW_FOLLOW_PLAYBACK: case ID_VIEW_FOLLOW_PLAYBACK:
//switch "Follow playback" flag //switch "Follow playback" flag
TASEdit_follow_playback ^= 1; TASEdit_follow_playback ^= 1;
CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED);
// if switched off then jump to selection
if (TASEdit_follow_playback)
FollowPlayback(); FollowPlayback();
else if (selectionFrames.size())
ListView_EnsureVisible(hwndList,(int)*selectionFrames.begin(),FALSE);
break; break;
case ID_VIEW_SHOW_LAG_FRAMES: case ID_VIEW_SHOW_LAG_FRAMES:
//switch "Highlight lag frames" flag //switch "Highlight lag frames" flag
@ -1314,10 +1318,29 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
CheckMenuItem(hmenu, ID_VIEW_SHOW_TWEAK_COUNT, TASEdit_show_tweak_count?MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, ID_VIEW_SHOW_TWEAK_COUNT, TASEdit_show_tweak_count?MF_CHECKED : MF_UNCHECKED);
RedrawTweakCount(); RedrawTweakCount();
break; break;
case ACCEL_CTRL_P:
case CHECK_AUTORESTORE_PLAYBACK: case CHECK_AUTORESTORE_PLAYBACK:
//switch "Auto-restore last playback position" flag
TASEdit_restore_position ^= 1; TASEdit_restore_position ^= 1;
CheckDlgButton(hwndTasEdit,CHECK_AUTORESTORE_PLAYBACK,TASEdit_restore_position?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hwndTasEdit,CHECK_AUTORESTORE_PLAYBACK,TASEdit_restore_position?BST_CHECKED:BST_UNCHECKED);
break; break;
case ID_CONFIG_SETGREENZONECAPACITY:
//open input dialog
int new_capacity = TASEdit_greenzone_capacity;
if(CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?", new_capacity, hwndDlg) == IDOK)
{
if (new_capacity < GREENZONE_MIN_CAPACITY)
new_capacity = GREENZONE_MIN_CAPACITY;
else if (new_capacity > GREENZONE_MAX_CAPACITY)
new_capacity = GREENZONE_MAX_CAPACITY;
if (new_capacity < TASEdit_greenzone_capacity)
{
TASEdit_greenzone_capacity = new_capacity;
currMovieData.ClearGreenzoneTail();
RedrawList();
} else TASEdit_greenzone_capacity = new_capacity;
}
break;
} }
break; break;
@ -1343,7 +1366,9 @@ void EnterTasEdit()
{ {
if(!FCEU_IsValidUI(FCEUI_TASEDIT)) return; if(!FCEU_IsValidUI(FCEUI_TASEDIT)) return;
lastCursor = -1; // init variables
lastCursor = old_pauseframe = -1;
old_show_pauseframe = show_pauseframe = false;
// either start new project or use current movie // either start new project or use current movie
if (movieMode == MOVIEMODE_INACTIVE) if (movieMode == MOVIEMODE_INACTIVE)
@ -1381,3 +1406,10 @@ void EnterTasEdit()
SetWindowPos(hwndTasEdit,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); SetWindowPos(hwndTasEdit,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
} }
} }
void ExitTasEdit()
{
movieMode = MOVIEMODE_INACTIVE;
FCEU_DispMessage("Tasedit disengaged",0);
currMovieData.clearGreenzone();
CreateCleanMovie();
}

View File

@ -3,6 +3,10 @@
#define FRAMES_TOO_FAR 60 #define FRAMES_TOO_FAR 60
#define NUM_JOYPADS 4 #define NUM_JOYPADS 4
#define NUM_JOYPAD_BUTTONS 8 #define NUM_JOYPAD_BUTTONS 8
#define GREENZONE_DEFAULT_CAPACITY 50000
#define GREENZONE_MIN_CAPACITY 1
#define GREENZONE_MAX_CAPACITY 200000 // maybe even more
#define PAUSEFRAME_BLINKING_PERIOD 100
// listview column names // listview column names
#define COLUMN_ARROW 0 #define COLUMN_ARROW 0
#define COLUMN_FRAMENUM 1 #define COLUMN_FRAMENUM 1
@ -62,8 +66,10 @@ void InvalidateGreenZone(int after);
bool JumpToFrame(int index); bool JumpToFrame(int index);
int FindBeginningOfGreenZone(int starting_index); int FindBeginningOfGreenZone(int starting_index);
void FollowPlayback(); void FollowPlayback();
void ClearSelection();
void AddFourscoreColumns(); void AddFourscoreColumns();
void RemoveFourscoreColumns(); void RemoveFourscoreColumns();
void RedrawList();
void RedrawTasedit(); void RedrawTasedit();
void RedrawList();
void RedrawRow(int index);
void RedrawTweakCount(); void RedrawTweakCount();

View File

@ -63,7 +63,7 @@ bool TASEDIT_PROJECT::SaveProject()
currMovieData.dump(ofs, true); currMovieData.dump(ofs, true);
ofs->fputc('\0'); // TODO: Add main branch name. ofs->fputc('\0'); // TODO: Add main branch name.
currMovieData.dumpGreenzone(ofs, true); currMovieData.dumpGreenzone(ofs);
delete ofs; delete ofs;
@ -86,8 +86,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
char branchname; char branchname;
branchname = ifs.fgetc(); // TODO: Add main branch name. branchname = ifs.fgetc(); // TODO: Add main branch name.
currMovieData.clearGreenzone(); if (!currMovieData.loadGreenzone(&ifs))
if (!currMovieData.loadGreenzone(&ifs, true))
{ {
// there was some error while loading greenzone - reset playback to frame 0 // there was some error while loading greenzone - reset playback to frame 0
poweron(true); poweron(true);

View File

@ -1902,7 +1902,6 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
// DoByteMonitor(); // DoByteMonitor();
// break; // break;
// Removing this tool since it is redundant to both // Removing this tool since it is redundant to both
case ACCEL_CTRL_E:
case MENU_TASEDIT: case MENU_TASEDIT:
EnterTasEdit(); EnterTasEdit();
break; break;

View File

@ -1039,6 +1039,7 @@ bool FCEU_IsValidUI(EFCEUI ui)
case FCEUI_TASEDIT: case FCEUI_TASEDIT:
if(!GameInfo) return false; if(!GameInfo) return false;
if(FCEUMOV_Mode(MOVIEMODE_TASEDIT)) return false;
break; break;
case FCEUI_RESET: case FCEUI_RESET:

View File

@ -48,6 +48,7 @@ using namespace std;
extern char FileBase[]; extern char FileBase[];
extern bool AutoSS; //Declared in fceu.cpp, keeps track if a auto-savestate has been made extern bool AutoSS; //Declared in fceu.cpp, keeps track if a auto-savestate has been made
extern int TASEdit_greenzone_capacity;
std::vector<int> subtitleFrames; //Frame numbers for subtitle messages std::vector<int> subtitleFrames; //Frame numbers for subtitle messages
std::vector<string> subtitleMessages; //Messages of subtitles std::vector<string> subtitleMessages; //Messages of subtitles
@ -141,9 +142,28 @@ void MovieData::TryDumpIncremental()
// update greenzone upper limit // update greenzone upper limit
if (currMovieData.greenZoneCount <= currFrameCounter) if (currMovieData.greenZoneCount <= currFrameCounter)
currMovieData.greenZoneCount = currFrameCounter+1; currMovieData.greenZoneCount = currFrameCounter+1;
ClearGreenzoneTail();
} }
} }
void MovieData::ClearGreenzoneTail()
{
int tail_frame = currMovieData.greenZoneCount-1 - TASEdit_greenzone_capacity;
if (tail_frame >= currFrameCounter) tail_frame = currFrameCounter - 1;
for (;tail_frame >= 0; tail_frame--)
{
if (currMovieData.savestates[tail_frame].empty()) break;
ClearSavestate(tail_frame);
RedrawRow(tail_frame);
}
}
void MovieData::ClearSavestate(int index)
{
std::vector<uint8> tmp;
currMovieData.savestates[index].swap(tmp);
}
MovieRecord::MovieRecord() MovieRecord::MovieRecord()
{ {
joysticks.data[0] = 0; joysticks.data[0] = 0;
@ -510,9 +530,9 @@ int MovieData::dump(EMUFILE *os, bool binary)
void MovieData::clearGreenzone() void MovieData::clearGreenzone()
{ {
int size = currMovieData.savestates.size(); int size = currMovieData.savestates.size();
for (int i = 1; i < size; ++i) for (int i = 0; i < size; ++i)
{ {
currMovieData.savestates[i].clear(); ClearSavestate(i);
} }
greenZoneCount = 1; greenZoneCount = 1;
currMovieData.frames_flags.resize(1); currMovieData.frames_flags.resize(1);
@ -521,74 +541,81 @@ void MovieData::clearGreenzone()
} }
int MovieData::dumpGreenzone(EMUFILE *os, bool binary) int MovieData::dumpGreenzone(EMUFILE *os)
{ {
// save savestates
int start = os->ftell(); int start = os->ftell();
int frame, size; int frame, size;
write32le(greenZoneCount, os); write32le(greenZoneCount, os);
write32le(currFrameCounter, os);
// write savestates
for (frame = 0; frame < greenZoneCount; ++frame) for (frame = 0; frame < greenZoneCount; ++frame)
{ {
if (savestates[frame].empty()) continue; if (savestates[frame].empty()) continue;
write32le(frame, os); write32le(frame, os);
size = savestates[frame].size();
write32le(size, os);
// write savestate
os->fwrite(&savestates[frame][0], size);
// write frames_flags // write frames_flags
os->fwrite(&frames_flags[frame], 1); os->fwrite(&frames_flags[frame], 1);
// write lua_colorings // write lua_colorings
// write monitorings // write monitorings
// write savestate
size = savestates[frame].size();
write32le(size, os);
os->fwrite(&savestates[frame][0], size);
} }
// write -1 as eof for greenzone // write -1 as eof for greenzone
write32le(-1, os); write32le(-1, os);
// finally write playback cursor position
write32le(currFrameCounter, os);
int end = os->ftell(); int end = os->ftell();
return end-start; return end-start;
} }
bool MovieData::loadGreenzone(EMUFILE *is, bool binary) bool MovieData::loadGreenzone(EMUFILE *is)
{ {
clearGreenzone(); clearGreenzone();
int frame = 0, prev_frame = 0, size = 0; int frame = 0, prev_frame = 0, size = 0;
if (read32le((uint32 *)&size, is)) if (read32le((uint32 *)&size, is))
{ {
greenZoneCount = size; greenZoneCount = size;
frames_flags.resize(size); savestates.resize(greenZoneCount);
savestates.resize(size); frames_flags.resize(greenZoneCount);
savestates.resize(greenZoneCount);
int greenzone_tail_frame = greenZoneCount-1 - TASEdit_greenzone_capacity;
if (read32le((uint32 *)&frame, is))
{
currFrameCounter = frame;
while(1) while(1)
{ {
if (!read32le((uint32 *)&frame, is)) break; if (!read32le((uint32 *)&frame, is)) break;
if (frame == -1) break; if (frame == -1) break;
// read frames_flags
if ((int)is->fread(&frames_flags[frame],1) != 1) break;
// read lua_colorings
// read monitorings
// read savestate
if (!read32le((uint32 *)&size, is)) break; if (!read32le((uint32 *)&size, is)) break;
if (frame > greenzone_tail_frame || frame == currFrameCounter)
if ((int)savestates.size() <= frame) savestates.resize(frame+1); {
// load savestate // load savestate
savestates[frame].resize(size); savestates[frame].resize(size);
if ((int)is->fread((char*)&savestates[frame][0],size) < size) break; if ((int)is->fread((char*)&savestates[frame][0],size) < size) break;
// load frames_flags prev_frame = frame; // successfully read one greenzone frame info
if ((int)is->fread(&frames_flags[frame],1) != 1) break; } else
// load lua_colorings {
// load monitorings // skip loading this savestate
if (is->fseek(size,SEEK_CUR) != 0) break;
prev_frame = frame; }
} }
greenZoneCount = prev_frame+1; // cut greenZoneCount to last good frame greenZoneCount = prev_frame+1; // cut greenZoneCount to last good frame
if (frame == -1) if (frame == -1)
{ {
// everything went fine - load savestate at cursor position // everything went fine - load savestate at cursor position
if (read32le((uint32 *)&currFrameCounter, is) && currMovieData.loadTasSavestate(currFrameCounter)) if (currMovieData.loadTasSavestate(currFrameCounter))
{
return true; return true;
}
} else } else
{ {
// there was some error while reading greenzone // there was some error while reading greenzone
} }
} }
}
return false; return false;
} }

View File

@ -233,8 +233,8 @@ public:
void installValue(std::string& key, std::string& val); void installValue(std::string& key, std::string& val);
int dump(EMUFILE* os, bool binary); int dump(EMUFILE* os, bool binary);
void clearGreenzone(); void clearGreenzone();
int dumpGreenzone(EMUFILE *os, bool binary); int dumpGreenzone(EMUFILE *os);
bool loadGreenzone(EMUFILE *is, bool binary); bool loadGreenzone(EMUFILE *is);
void clearRecordRange(int start, int len); void clearRecordRange(int start, int len);
void insertEmpty(int at, int frames); void insertEmpty(int at, int frames);
@ -245,6 +245,8 @@ public:
bool loadTasSavestate(int frame); bool loadTasSavestate(int frame);
void storeTasSavestate(int frame, int compression_level); void storeTasSavestate(int frame, int compression_level);
void TryDumpIncremental(); void TryDumpIncremental();
void ClearGreenzoneTail();
void ClearSavestate(int index);
private: private:
void installInt(std::string& val, int& var) void installInt(std::string& val, int& var)