* Tasedit: refactoring, tasedit_list class

* Tasedit: selection strobe (improved stability)
* Tasedit: rewinding pauses emulation
* soft reset and power switch messages, messages when saving/loading Branches
This commit is contained in:
ansstuff 2011-11-18 22:24:54 +00:00
parent 514c80e416
commit 0fcdda6c8a
26 changed files with 1156 additions and 1037 deletions

View File

@ -66,7 +66,7 @@ void RedoText(void)
} }
SetDlgItemText(logwin, LBL_LOG_TEXT, textbuf); SetDlgItemText(logwin, LBL_LOG_TEXT, textbuf);
SendDlgItemMessage(logwin, LBL_LOG_TEXT, EM_LINESCROLL, 0, 200); SendDlgItemMessage(logwin, LBL_LOG_TEXT, EM_LINESCROLL, 0, MAXIMUM_NUMBER_OF_LOGS);
} }
/** /**

View File

@ -1,4 +1,4 @@
#define MAXIMUM_NUMBER_OF_LOGS 256 #define MAXIMUM_NUMBER_OF_LOGS 1024
#define DONT_ADD_NEWLINE 0 #define DONT_ADD_NEWLINE 0
#define DO_ADD_NEWLINE 1 #define DO_ADD_NEWLINE 1

View File

@ -60,7 +60,6 @@
#include "tracer.h" #include "tracer.h"
#include "cdlogger.h" #include "cdlogger.h"
#include "throttle.h" #include "throttle.h"
#include "tasedit.h"
#include "replay.h" #include "replay.h"
#include "palette.h" //For the SetPalette function #include "palette.h" //For the SetPalette function
#include "main.h" #include "main.h"
@ -857,6 +856,7 @@ void _updateWindow()
//UpdateLogWindow(); //adelikat: Moved to FCEUI_Emulate //UpdateLogWindow(); //adelikat: Moved to FCEUI_Emulate
UpdateMemWatch(); UpdateMemWatch();
NTViewDoBlit(0); NTViewDoBlit(0);
extern void UpdateTasEdit();
UpdateTasEdit(); UpdateTasEdit();
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,136 +1,41 @@
#define CDDS_SUBITEMPREPAINT (CDDS_SUBITEM | CDDS_ITEMPREPAINT)
#define CDDS_SUBITEMPOSTPAINT (CDDS_SUBITEM | CDDS_ITEMPOSTPAINT)
#define CDDS_SUBITEMPREERASE (CDDS_SUBITEM | CDDS_ITEMPREERASE)
#define CDDS_SUBITEMPOSTERASE (CDDS_SUBITEM | CDDS_ITEMPOSTERASE)
#define NUM_JOYPADS 4
#define NUM_JOYPAD_BUTTONS 8
#define PROGRESSBAR_WIDTH 200 #define PROGRESSBAR_WIDTH 200
#define GREENZONE_CAPACITY_DEFAULT 10000 #define GREENZONE_CAPACITY_DEFAULT 10000
#define GREENZONE_CAPACITY_MIN 1 #define GREENZONE_CAPACITY_MIN 1
#define GREENZONE_CAPACITY_MAX 50000 #define GREENZONE_CAPACITY_MAX 50000
#define UNDO_LEVELS_MIN 1
#define UNDO_LEVELS_MAX 999
#define UNDO_LEVELS_DEFAULT 100
#define AUTOSAVE_PERIOD_SCALE 60000 // = 1 minute in milliseconds #define AUTOSAVE_PERIOD_SCALE 60000 // = 1 minute in milliseconds
#define AUTOSAVE_PERIOD_DEFAULT 10 // in minutes #define AUTOSAVE_PERIOD_DEFAULT 10 // in minutes
#define AUTOSAVE_PERIOD_MIN 0 // 0 = no autosave #define AUTOSAVE_PERIOD_MIN 0 // 0 = no autosave
#define AUTOSAVE_PERIOD_MAX 60 // 1 hour #define AUTOSAVE_PERIOD_MAX 60 // 1 hour
#define UNDO_LEVELS_MIN 1 // multitracking
#define UNDO_LEVELS_MAX 999
#define UNDO_LEVELS_DEFAULT 100
// multitrack
#define MULTITRACK_RECORDING_ALL 0 #define MULTITRACK_RECORDING_ALL 0
#define MULTITRACK_RECORDING_1P 1 #define MULTITRACK_RECORDING_1P 1
#define MULTITRACK_RECORDING_2P 2 #define MULTITRACK_RECORDING_2P 2
#define MULTITRACK_RECORDING_3P 3 #define MULTITRACK_RECORDING_3P 3
#define MULTITRACK_RECORDING_4P 4 #define MULTITRACK_RECORDING_4P 4
// listview column names
#define COLUMN_ICONS 0
#define COLUMN_FRAMENUM 1
#define COLUMN_JOYPAD1_A 2
#define COLUMN_JOYPAD1_B 3
#define COLUMN_JOYPAD1_S 4
#define COLUMN_JOYPAD1_T 5
#define COLUMN_JOYPAD1_U 6
#define COLUMN_JOYPAD1_D 7
#define COLUMN_JOYPAD1_L 8
#define COLUMN_JOYPAD1_R 9
#define COLUMN_JOYPAD2_A 10
#define COLUMN_JOYPAD2_B 11
#define COLUMN_JOYPAD2_S 12
#define COLUMN_JOYPAD2_T 13
#define COLUMN_JOYPAD2_U 14
#define COLUMN_JOYPAD2_D 15
#define COLUMN_JOYPAD2_L 16
#define COLUMN_JOYPAD2_R 17
#define COLUMN_JOYPAD3_A 18
#define COLUMN_JOYPAD3_B 19
#define COLUMN_JOYPAD3_S 20
#define COLUMN_JOYPAD3_T 21
#define COLUMN_JOYPAD3_U 22
#define COLUMN_JOYPAD3_D 23
#define COLUMN_JOYPAD3_L 24
#define COLUMN_JOYPAD3_R 25
#define COLUMN_JOYPAD4_A 26
#define COLUMN_JOYPAD4_B 27
#define COLUMN_JOYPAD4_S 28
#define COLUMN_JOYPAD4_T 29
#define COLUMN_JOYPAD4_U 30
#define COLUMN_JOYPAD4_D 31
#define COLUMN_JOYPAD4_L 32
#define COLUMN_JOYPAD4_R 33
#define COLUMN_FRAMENUM2 34
#define DIGITS_IN_FRAMENUM 7
#define ARROW_IMAGE_ID 20
// listview colors
#define NORMAL_TEXT_COLOR 0x0
#define NORMAL_FRAMENUM_COLOR 0xFFFFFF
#define NORMAL_INPUT_COLOR1 0xEDEDED
#define NORMAL_INPUT_COLOR2 0xDEDEDE
#define GREENZONE_FRAMENUM_COLOR 0xDDFFDD
#define GREENZONE_INPUT_COLOR1 0xC8F7C4
#define GREENZONE_INPUT_COLOR2 0xAEE2AE
#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4FFE4
#define PALE_GREENZONE_INPUT_COLOR1 0xD5F9D4
#define PALE_GREENZONE_INPUT_COLOR2 0xBAE6BA
#define LAG_FRAMENUM_COLOR 0xDBDAFF
#define LAG_INPUT_COLOR1 0xCECBEF
#define LAG_INPUT_COLOR2 0xBEBAE4
#define PALE_LAG_FRAMENUM_COLOR 0xE1E1FF
#define PALE_LAG_INPUT_COLOR1 0xD6D3F1
#define PALE_LAG_INPUT_COLOR2 0xC7C4E8
#define CUR_FRAMENUM_COLOR 0xFCF1CE
#define CUR_INPUT_COLOR1 0xF7E9B2
#define CUR_INPUT_COLOR2 0xE4D8A8
#define UNDOHINT_FRAMENUM_COLOR 0xF9DDE6
#define UNDOHINT_INPUT_COLOR1 0xF6CCDD
#define UNDOHINT_INPUT_COLOR2 0xE5B7CC
#define MARKED_FRAMENUM_COLOR 0xC0FCFF
#define CUR_MARKED_FRAMENUM_COLOR 0xDEF7F3
#define MARKED_UNDOHINT_FRAMENUM_COLOR 0xE1E7EC
// greenzone cleaning masks
#define EVERY16TH 0xFFFFFFF0
#define EVERY8TH 0xFFFFFFF8
#define EVERY4TH 0xFFFFFFFC
#define EVERY2ND 0xFFFFFFFE
// -----------------------------
enum ECONTEXTMENU enum ECONTEXTMENU
{ {
CONTEXTMENU_STRAY = 0, CONTEXTMENU_STRAY = 0,
CONTEXTMENU_SELECTED = 1, CONTEXTMENU_SELECTED = 1,
}; };
void EnterTasEdit(); void EnterTasEdit();
void InitDialog(); void InitDialog();
bool ExitTasEdit(); bool ExitTasEdit();
void UpdateTasEdit(); void UpdateTasEdit();
void UpdateList();
void InputChangedRec();
bool CheckItemVisible(int frame);
void FollowPlayback();
void FollowUndo();
void FollowSelection();
void FollowPauseframe();
void AddFourscore();
void RemoveFourscore();
void RedrawWindowCaption(); void RedrawWindowCaption();
void RedrawTasedit(); void RedrawTasedit();
void RedrawList();
void RedrawListAndBookmarks(); void RedrawListAndBookmarks();
void RedrawRow(int index);
void RedrawRowAndBookmark(int index); void RedrawRowAndBookmark(int index);
void InputChangedRec();
void ToggleJoypadBit(int column_index, int row_index, UINT KeyFlags); void ToggleJoypadBit(int column_index, int row_index, UINT KeyFlags);
void SwitchToReadOnly();
void UncheckRecordingRadioButtons(); void UncheckRecordingRadioButtons();
void RecheckRecordingRadioButtons(); void RecheckRecordingRadioButtons();
void OpenProject(); void OpenProject();
@ -141,10 +46,10 @@ void CloneFrames();
void InsertFrames(); void InsertFrames();
void InsertNumFrames(); void InsertNumFrames();
void DeleteFrames(); void DeleteFrames();
void ClearFrames(bool cut = false); void ClearFrames(SelectionFrames* current_selection = 0);
void Truncate(); void Truncate();
void ColumnSet(int column); void ColumnSet(int column);
bool Copy(); bool Copy(SelectionFrames* current_selection = 0);
void Cut(); void Cut();
bool Paste(); bool Paste();
void GotFocus(); void GotFocus();

View File

@ -1,25 +1,24 @@
//Implementation file of Bookmarks class //Implementation file of Bookmarks class
#include "movie.h"
#include "../common.h"
#include "taseditproj.h" #include "taseditproj.h"
#include "../tasedit.h"
#include "zlib.h" #include "zlib.h"
#include "utils/xstring.h" #include "utils/xstring.h"
#pragma comment(lib, "msimg32.lib") #pragma comment(lib, "msimg32.lib")
LRESULT CALLBACK ScrBmpWndProc(HWND, UINT, WPARAM, LPARAM);
char szClassName[] = "BmpTestApp";
HWND hwndScrBmp, scr_bmp_pic;
WNDCLASSEX wincl;
BLENDFUNCTION blend;
extern HWND hwndTasEdit; extern HWND hwndTasEdit;
extern int TasEdit_wndx, TasEdit_wndy; extern int TasEdit_wndx, TasEdit_wndy;
extern void RedrawRowAndBookmark(int index);
LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT APIENTRY BranchesBitmapWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ScrBmpWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
WNDPROC hwndBookmarksList_oldWndProc, hwndBranchesBitmap_oldWndProc;
// resources
char szClassName[] = "ScrBmp";
char bookmarks_save_id[BOOKMARKS_ID_LEN] = "BOOKMARKS"; char bookmarks_save_id[BOOKMARKS_ID_LEN] = "BOOKMARKS";
char bookmarksCaption[3][23] = { " Bookmarks ", " Bookmarks / Branches ", " Branches " }; char bookmarksCaption[3][23] = { " Bookmarks ", " Bookmarks / Branches ", " Branches " };
// color tables for flashing when saving/loading bookmarks // color tables for flashing when saving/loading bookmarks
COLORREF bookmark_flash_colors[3][FLASH_PHASE_MAX+1] = { COLORREF bookmark_flash_colors[3][FLASH_PHASE_MAX+1] = {
// set // set
@ -36,10 +35,7 @@ extern GREENZONE greenzone;
extern TASEDIT_PROJECT project; extern TASEDIT_PROJECT project;
extern INPUT_HISTORY history; extern INPUT_HISTORY history;
extern MARKERS markers; extern MARKERS markers;
extern TASEDIT_LIST tasedit_list;
extern HWND hwndBookmarks;
extern HWND hwndBookmarksList;
extern HWND hwndBranchesBitmap;
extern bool TASEdit_show_lag_frames; extern bool TASEdit_show_lag_frames;
extern bool TASEdit_bind_markers; extern bool TASEdit_bind_markers;
@ -103,6 +99,34 @@ BOOKMARKS::BOOKMARKS()
void BOOKMARKS::init() void BOOKMARKS::init()
{ {
free(); free();
hwndBookmarksList = GetDlgItem(hwndTasEdit, IDC_BOOKMARKSLIST);
hwndBookmarks = GetDlgItem(hwndTasEdit, IDC_BOOKMARKS_BOX);
hwndBranchesBitmap = GetDlgItem(hwndTasEdit, IDC_BRANCHES_BITMAP);
// prepare bookmarks listview
ListView_SetExtendedListViewStyleEx(hwndBookmarksList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
// subclass the listview
hwndBookmarksList_oldWndProc = (WNDPROC)SetWindowLong(hwndBookmarksList, GWL_WNDPROC, (LONG)BookmarksListWndProc);
// setup same images for the listview
ListView_SetImageList(hwndBookmarksList, tasedit_list.himglist, LVSIL_SMALL);
// setup columns
LVCOLUMN lvc;
// icons column
lvc.mask = LVCF_WIDTH;
lvc.cx = 13;
ListView_InsertColumn(hwndBookmarksList, 0, &lvc);
// jump_frame column
lvc.mask = LVCF_WIDTH | LVCF_FMT;
lvc.fmt = LVCFMT_CENTER;
lvc.cx = 74;
ListView_InsertColumn(hwndBookmarksList, 1, &lvc);
// time column
lvc.cx = 80;
ListView_InsertColumn(hwndBookmarksList, 2, &lvc);
// subclass BranchesBitmap
hwndBranchesBitmap_oldWndProc = (WNDPROC)SetWindowLong(hwndBranchesBitmap, GWL_WNDPROC, (LONG)BranchesBitmapWndProc);
// init arrays // init arrays
BranchX.resize(TOTAL_BOOKMARKS+1); BranchX.resize(TOTAL_BOOKMARKS+1);
BranchY.resize(TOTAL_BOOKMARKS+1); BranchY.resize(TOTAL_BOOKMARKS+1);
@ -134,7 +158,7 @@ void BOOKMARKS::init()
// find rows top/height (for mouseover hittest calculations) // find rows top/height (for mouseover hittest calculations)
RECT temp_rect; RECT temp_rect;
if (ListView_GetSubItemRect(hwndBookmarksList, 0, 2, LVIR_BOUNDS, &temp_rect)) if (ListView_GetSubItemRect(hwndBookmarksList, 0, 2, LVIR_BOUNDS, &temp_rect) && temp_rect.bottom != temp_rect.top)
{ {
branch_row_top = temp_rect.top; branch_row_top = temp_rect.top;
branch_row_left = temp_rect.left; branch_row_left = temp_rect.left;
@ -405,6 +429,8 @@ void BOOKMARKS::set(int slot)
if (previous_frame >= 0 && previous_frame != currFrameCounter) if (previous_frame >= 0 && previous_frame != currFrameCounter)
RedrawRowAndBookmark(previous_frame); RedrawRowAndBookmark(previous_frame);
RedrawRowAndBookmark(currFrameCounter); RedrawRowAndBookmark(currFrameCounter);
FCEU_DispMessage("Branch %d saved.", 0, slot);
} }
void BOOKMARKS::jump(int slot) void BOOKMARKS::jump(int slot)
@ -414,10 +440,10 @@ void BOOKMARKS::jump(int slot)
{ {
int frame = bookmarks_array[slot].snapshot.jump_frame; int frame = bookmarks_array[slot].snapshot.jump_frame;
playback.jump(frame); playback.jump(frame);
if (playback.pauseframe) if (playback.GetPauseFrame())
FollowPauseframe(); tasedit_list.FollowPauseframe();
else else
FollowPlayback(); tasedit_list.FollowPlayback();
bookmarks_array[slot].jump(); bookmarks_array[slot].jump();
} }
} }
@ -454,14 +480,14 @@ void BOOKMARKS::unleash(int slot)
// restore entire movie // restore entire movie
currMovieData.records.resize(bookmarks_array[slot].snapshot.size); currMovieData.records.resize(bookmarks_array[slot].snapshot.size);
bookmarks_array[slot].snapshot.toMovie(currMovieData, first_change); bookmarks_array[slot].snapshot.toMovie(currMovieData, first_change);
UpdateList(); tasedit_list.update();
history.RegisterBranching(MODTYPE_BRANCH_0 + slot, first_change, slot); history.RegisterBranching(MODTYPE_BRANCH_0 + slot, first_change, slot);
greenzone.Invalidate(first_change); greenzone.Invalidate(first_change);
bookmarks_array[slot].unleashed(); bookmarks_array[slot].unleashed();
} else if (markers_changed) } else if (markers_changed)
{ {
history.RegisterBranching(MODTYPE_BRANCH_MARKERS_0 + slot, first_change, slot); history.RegisterBranching(MODTYPE_BRANCH_MARKERS_0 + slot, first_change, slot);
RedrawList(); tasedit_list.RedrawList();
bookmarks_array[slot].unleashed(); bookmarks_array[slot].unleashed();
} else } else
{ {
@ -487,14 +513,14 @@ void BOOKMARKS::unleash(int slot)
// restore movie up to and not including bookmarked frame (imitating old TASing method) // restore movie up to and not including bookmarked frame (imitating old TASing method)
if (currMovieData.getNumRecords() <= jump_frame) currMovieData.records.resize(jump_frame+1); // but if old movie is shorter, include last frame as blank frame if (currMovieData.getNumRecords() <= jump_frame) currMovieData.records.resize(jump_frame+1); // but if old movie is shorter, include last frame as blank frame
bookmarks_array[slot].snapshot.toMovie(currMovieData, first_change, jump_frame-1); bookmarks_array[slot].snapshot.toMovie(currMovieData, first_change, jump_frame-1);
UpdateList(); tasedit_list.update();
history.RegisterBranching(MODTYPE_BRANCH_0 + slot, first_change, slot); history.RegisterBranching(MODTYPE_BRANCH_0 + slot, first_change, slot);
greenzone.Invalidate(first_change); greenzone.Invalidate(first_change);
bookmarks_array[slot].unleashed(); bookmarks_array[slot].unleashed();
} else if (markers_changed) } else if (markers_changed)
{ {
history.RegisterBranching(MODTYPE_BRANCH_MARKERS_0 + slot, first_change, slot); history.RegisterBranching(MODTYPE_BRANCH_MARKERS_0 + slot, first_change, slot);
RedrawList(); tasedit_list.RedrawList();
bookmarks_array[slot].unleashed(); bookmarks_array[slot].unleashed();
} else } else
{ {
@ -532,6 +558,8 @@ void BOOKMARKS::unleash(int slot)
current_branch = slot; current_branch = slot;
changes_since_current_branch = false; changes_since_current_branch = false;
must_recalculate_branches_tree = true; must_recalculate_branches_tree = true;
FCEU_DispMessage("Branch %d loaded.", 0, slot);
} }
void BOOKMARKS::save(EMUFILE *os) void BOOKMARKS::save(EMUFILE *os)
@ -946,7 +974,7 @@ LONG BOOKMARKS::CustomDraw(NMLVCUSTOMDRAW* msg)
// frame number // frame number
SelectObject(msg->nmcd.hdc, hBookmarksFont); SelectObject(msg->nmcd.hdc, hBookmarksFont);
int frame = bookmarks_array[cell_y].snapshot.jump_frame; int frame = bookmarks_array[cell_y].snapshot.jump_frame;
if (frame == currFrameCounter || frame == playback.GetPauseFrame()) if (frame == currFrameCounter || frame == (playback.GetPauseFrame() - 1))
{ {
// current frame // current frame
msg->clrTextBk = CUR_FRAMENUM_COLOR; msg->clrTextBk = CUR_FRAMENUM_COLOR;
@ -977,7 +1005,7 @@ LONG BOOKMARKS::CustomDraw(NMLVCUSTOMDRAW* msg)
// frame number // frame number
SelectObject(msg->nmcd.hdc, hBookmarksFont); SelectObject(msg->nmcd.hdc, hBookmarksFont);
int frame = bookmarks_array[cell_y].snapshot.jump_frame; int frame = bookmarks_array[cell_y].snapshot.jump_frame;
if (frame == currFrameCounter || frame == playback.GetPauseFrame()) if (frame == currFrameCounter || frame == (playback.GetPauseFrame() - 1))
{ {
// current frame // current frame
msg->clrTextBk = CUR_INPUT_COLOR1; msg->clrTextBk = CUR_INPUT_COLOR1;
@ -1309,14 +1337,92 @@ void BOOKMARKS::RecursiveSetYPos(int parent, int parentY)
} }
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
LRESULT CALLBACK ScrBmpWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
extern BOOKMARKS bookmarks;
switch(msg)
{
case WM_CHAR:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SETFOCUS:
case WM_KILLFOCUS:
return 0;
case WM_MOUSEMOVE:
{
if (!bookmarks.mouse_over_bookmarkslist)
{
bookmarks.mouse_over_bookmarkslist = true;
bookmarks.list_tme.hwndTrack = hWnd;
TrackMouseEvent(&bookmarks.list_tme);
}
bookmarks.MouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
}
case WM_MOUSELEAVE:
{
bookmarks.mouse_over_bookmarkslist = false;
bookmarks.MouseMove(-1, -1);
break;
}
case WM_SYSKEYDOWN:
{
if (wParam == VK_F10)
return 0;
break;
}
}
return CallWindowProc(hwndBookmarksList_oldWndProc, hWnd, msg, wParam, lParam);
}
LRESULT APIENTRY BranchesBitmapWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
extern BOOKMARKS bookmarks;
switch(msg)
{
case WM_MOUSEMOVE:
{
if (!bookmarks.mouse_over_bitmap)
{
bookmarks.mouse_over_bitmap = true;
bookmarks.tme.hwndTrack = hWnd;
TrackMouseEvent(&bookmarks.tme);
}
bookmarks.MouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
}
case WM_MOUSELEAVE:
{
bookmarks.mouse_over_bitmap = false;
bookmarks.MouseMove(-1, -1);
break;
}
case WM_SYSKEYDOWN:
{
if (wParam == VK_F10)
return 0;
break;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
bookmarks.PaintBranchesBitmap(hdc);
EndPaint(hWnd, &ps);
return 0;
}
}
return CallWindowProc(hwndBranchesBitmap_oldWndProc, hWnd, msg, wParam, lParam);
}
// ----------------------------------------------------------------------------------------
LRESULT APIENTRY ScrBmpWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
extern BOOKMARKS bookmarks;
switch(message) switch(message)
{ {
case WM_CREATE: case WM_CREATE:
{ {
// create static bitmap placeholder // create static bitmap placeholder
scr_bmp_pic = CreateWindow(WC_STATIC, NULL, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 255, 255, hwnd, NULL, NULL, NULL); bookmarks.scr_bmp_pic = CreateWindow(WC_STATIC, NULL, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 255, 255, hwnd, NULL, NULL, NULL);
return 0; return 0;
} }
default: default:

View File

@ -135,11 +135,10 @@ public:
std::vector<BOOKMARK> bookmarks_array; std::vector<BOOKMARK> bookmarks_array;
// not saved vars // not saved vars
bool mouse_over_bitmap, mouse_over_bookmarkslist;
TRACKMOUSEEVENT tme, list_tme;
int branch_row_top; int branch_row_top;
int branch_row_left; int branch_row_left;
int branch_row_height; int branch_row_height;
bool mouse_over_bitmap, mouse_over_bookmarkslist;
// screenshot bmp stuff // screenshot bmp stuff
LPBITMAPINFO scr_bmi; LPBITMAPINFO scr_bmi;
HBITMAP scr_bmp; HBITMAP scr_bmp;
@ -148,6 +147,10 @@ public:
int scr_bmp_y; int scr_bmp_y;
int scr_bmp_phase; int scr_bmp_phase;
int screenshot_currently_shown; int screenshot_currently_shown;
HWND hwndScrBmp, scr_bmp_pic;
WNDCLASSEX wincl;
BLENDFUNCTION blend;
TRACKMOUSEEVENT tme, list_tme;
private: private:
void SetCurrentPosTime(); void SetCurrentPosTime();
@ -179,6 +182,9 @@ private:
int mouse_x, mouse_y; int mouse_x, mouse_y;
int item_under_mouse; int item_under_mouse;
HWND hwndBookmarksList, hwndBookmarks;
HWND hwndBranchesBitmap;
// GDI stuff // GDI stuff
HFONT hBookmarksFont; HFONT hBookmarksFont;
HBRUSH normal_brush; HBRUSH normal_brush;

View File

@ -1,11 +1,8 @@
//Implementation file of Greenzone class //Implementation file of Greenzone class
#include "movie.h"
#include "state.h"
#include "../common.h"
#include "zlib.h"
#include "taseditproj.h" #include "taseditproj.h"
#include "../tasedit.h" #include "../tasedit.h"
#include "state.h"
#include "zlib.h" #include "zlib.h"
extern TASEDIT_PROJECT project; extern TASEDIT_PROJECT project;

View File

@ -5,6 +5,12 @@
#define GREENZONE_ID_LEN 10 #define GREENZONE_ID_LEN 10
// greenzone cleaning masks
#define EVERY16TH 0xFFFFFFF0
#define EVERY8TH 0xFFFFFFF8
#define EVERY4TH 0xFFFFFFFC
#define EVERY2ND 0xFFFFFFFE
class GREENZONE class GREENZONE
{ {
public: public:

View File

@ -3,18 +3,20 @@
#include "taseditproj.h" #include "taseditproj.h"
#include "../tasedit.h" // just for mainlist functions, later this should be deleted #include "../tasedit.h" // just for mainlist functions, later this should be deleted
extern void FCEU_printf(char *format, ...); extern HWND hwndTasEdit;
extern HWND hwndHistoryList;
extern bool TASEdit_bind_markers; extern bool TASEdit_bind_markers;
extern bool TASEdit_enable_hot_changes; extern bool TASEdit_enable_hot_changes;
extern bool TASEdit_branch_full_movie; extern bool TASEdit_branch_full_movie;
LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
WNDPROC hwndHistoryList_oldWndProc;
extern MARKERS markers; extern MARKERS markers;
extern BOOKMARKS bookmarks; extern BOOKMARKS bookmarks;
extern PLAYBACK playback; extern PLAYBACK playback;
extern GREENZONE greenzone; extern GREENZONE greenzone;
extern TASEDIT_PROJECT project; extern TASEDIT_PROJECT project;
extern TASEDIT_LIST tasedit_list;
char history_save_id[HISTORY_ID_LEN] = "HISTORY"; char history_save_id[HISTORY_ID_LEN] = "HISTORY";
char modCaptions[36][20] = {" Init", char modCaptions[36][20] = {" Init",
@ -57,11 +59,20 @@ char joypadCaptions[4][5] = {"(1P)", "(2P)", "(3P)", "(4P)"};
INPUT_HISTORY::INPUT_HISTORY() INPUT_HISTORY::INPUT_HISTORY()
{ {
} }
void INPUT_HISTORY::init(int new_size) void INPUT_HISTORY::init(int new_size)
{ {
// prepare the history listview
hwndHistoryList = GetDlgItem(hwndTasEdit, IDC_HISTORYLIST);
ListView_SetExtendedListViewStyleEx(hwndHistoryList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
// subclass the listview
hwndHistoryList_oldWndProc = (WNDPROC)SetWindowLong(hwndHistoryList, GWL_WNDPROC, (LONG)HistoryListWndProc);
LVCOLUMN lvc;
lvc.mask = LVCF_WIDTH | LVCF_FMT;
lvc.cx = 200;
lvc.fmt = LVCFMT_LEFT;
ListView_InsertColumn(hwndHistoryList, 0, &lvc);
// init vars // init vars
if (new_size > 0) if (new_size > 0)
history_size = new_size + 1; history_size = new_size + 1;
@ -92,7 +103,7 @@ void INPUT_HISTORY::update()
{ {
// update undo_hint // update undo_hint
if (old_undo_hint_pos != undo_hint_pos && old_undo_hint_pos >= 0) if (old_undo_hint_pos != undo_hint_pos && old_undo_hint_pos >= 0)
RedrawRow(old_undo_hint_pos); // not changing bookmarks list tasedit_list.RedrawRow(old_undo_hint_pos); // not changing bookmarks list
old_undo_hint_pos = undo_hint_pos; old_undo_hint_pos = undo_hint_pos;
old_show_undo_hint = show_undo_hint; old_show_undo_hint = show_undo_hint;
show_undo_hint = false; show_undo_hint = false;
@ -104,7 +115,7 @@ void INPUT_HISTORY::update()
undo_hint_pos = -1; // finished hinting undo_hint_pos = -1; // finished hinting
} }
if (old_show_undo_hint != show_undo_hint) if (old_show_undo_hint != show_undo_hint)
RedrawRow(undo_hint_pos); // not changing bookmarks list tasedit_list.RedrawRow(undo_hint_pos); // not changing bookmarks list
@ -155,11 +166,11 @@ int INPUT_HISTORY::jump(int new_pos)
{ {
markers.update(); markers.update();
bookmarks.ChangesMadeSinceBranch(); bookmarks.ChangesMadeSinceBranch();
RedrawList(); tasedit_list.RedrawList();
} else if (TASEdit_enable_hot_changes) } else if (TASEdit_enable_hot_changes)
{ {
// when using Hot Changes, list should be always redrawn, because old changes become less hot // when using Hot Changes, list should be always redrawn, because old changes become less hot
RedrawList(); tasedit_list.RedrawList();
} }
return first_change; return first_change;
@ -484,8 +495,8 @@ void INPUT_HISTORY::Click(LPNMITEMACTIVATE info)
int result = jump(item); int result = jump(item);
if (result >= 0) if (result >= 0)
{ {
UpdateList(); tasedit_list.update();
FollowUndo(); tasedit_list.FollowUndo();
greenzone.InvalidateAndCheck(result); greenzone.InvalidateAndCheck(result);
return; return;
} }
@ -534,4 +545,24 @@ int INPUT_HISTORY::GetUndoHint()
else else
return -1; return -1;
} }
// ---------------------------------------------------------------------------------
LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CHAR:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_KILLFOCUS:
return 0;
case WM_SYSKEYDOWN:
{
if (wParam == VK_F10)
return 0;
break;
}
}
return CallWindowProc(hwndHistoryList_oldWndProc, hWnd, msg, wParam, lParam);
}

View File

@ -78,6 +78,8 @@ public:
void RedrawHistoryList(); void RedrawHistoryList();
void UpdateHistoryList(); void UpdateHistoryList();
HWND hwndHistoryList;
private: private:
std::vector<INPUT_SNAPSHOT> input_snapshots; std::vector<INPUT_SNAPSHOT> input_snapshots;

View File

@ -470,10 +470,10 @@ void INPUT_SNAPSHOT::inheritHotChanges_DeleteSelection(INPUT_SNAPSHOT* source_of
int bytes = bytes_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY; int bytes = bytes_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int frame = 0, pos = 0, source_pos = 0; int frame = 0, pos = 0, source_pos = 0;
int this_size = hot_changes.size(), source_size = source_of_hotchanges->hot_changes.size(); int this_size = hot_changes.size(), source_size = source_of_hotchanges->hot_changes.size();
SelectionFrames::iterator it(selection.CurrentSelection().begin()); SelectionFrames::iterator it(selection.GetStrobedSelection().begin());
while (pos < this_size && source_pos < source_size) while (pos < this_size && source_pos < source_size)
{ {
if (it != selection.CurrentSelection().end() && frame == *it) if (it != selection.GetStrobedSelection().end() && frame == *it)
{ {
// this frame is selected // this frame is selected
it++; it++;
@ -499,10 +499,11 @@ void INPUT_SNAPSHOT::inheritHotChanges_InsertSelection(INPUT_SNAPSHOT* source_of
int bytes = bytes_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY; int bytes = bytes_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int frame = 0, region_len = 0, pos = 0, source_pos = 0; 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 = hot_changes.size(), source_size = source_of_hotchanges->hot_changes.size();
SelectionFrames::iterator it(selection.CurrentSelection().begin()); SelectionFrames::iterator it(selection.GetStrobedSelection().begin());
SelectionFrames::iterator current_selection_end(selection.GetStrobedSelection().end());
while (pos < this_size && source_pos < source_size) while (pos < this_size && source_pos < source_size)
{ {
if (it != selection.CurrentSelection().end() && frame == *it) if (it != current_selection_end && frame == *it)
{ {
// this frame is selected // this frame is selected
it++; it++;
@ -529,10 +530,11 @@ void INPUT_SNAPSHOT::inheritHotChanges_InsertSelection(INPUT_SNAPSHOT* source_of
int bytes = bytes_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY; int bytes = bytes_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
int frame = 0, region_len = 0, pos = 0; int frame = 0, region_len = 0, pos = 0;
int this_size = hot_changes.size(); int this_size = hot_changes.size();
SelectionFrames::iterator it(selection.CurrentSelection().begin()); SelectionFrames::iterator it(selection.GetStrobedSelection().begin());
SelectionFrames::iterator current_selection_end(selection.GetStrobedSelection().end());
while (pos < this_size) while (pos < this_size)
{ {
if (it != selection.CurrentSelection().end() && frame == *it) if (it != current_selection_end && frame == *it)
{ {
// this frame is selected // this frame is selected
it++; it++;
@ -541,7 +543,7 @@ void INPUT_SNAPSHOT::inheritHotChanges_InsertSelection(INPUT_SNAPSHOT* source_of
memset(&hot_changes[pos], 0xFF, bytes); memset(&hot_changes[pos], 0xFF, bytes);
pos += bytes; pos += bytes;
// exit loop when all selection frames are handled // exit loop when all selection frames are handled
if (it == selection.CurrentSelection().end()) break; if (it == current_selection_end) break;
} else } else
{ {
// this frame is not selected // this frame is not selected

View File

@ -1,7 +1,5 @@
//Implementation file of Markers class //Implementation file of Markers class
#include "movie.h"
#include "../common.h"
#include "taseditproj.h" #include "taseditproj.h"
//#include "../tasedit.h" //#include "../tasedit.h"
#include "zlib.h" #include "zlib.h"

View File

@ -1,7 +1,5 @@
//Implementation file of Playback class //Implementation file of Playback class
#include "movie.h"
#include "../common.h"
#include "taseditproj.h" #include "taseditproj.h"
#include "../tasedit.h" #include "../tasedit.h"
@ -9,16 +7,18 @@
extern void ForceExecuteLuaFrameFunctions(); extern void ForceExecuteLuaFrameFunctions();
#endif #endif
extern HWND hwndProgressbar, hwndList, hwndRewind, hwndForward, hwndRewindFull, hwndForwardFull; extern HWND hwndProgressbar, hwndRewind, hwndForward, hwndRewindFull, hwndForwardFull;
extern void FCEU_printf(char *format, ...); extern void FCEU_printf(char *format, ...);
extern bool turbo; extern bool turbo;
extern MARKERS markers; extern MARKERS markers;
extern GREENZONE greenzone; extern GREENZONE greenzone;
extern TASEDIT_LIST tasedit_list;
extern bool Tasedit_rewind_now; extern bool Tasedit_rewind_now;
PLAYBACK::PLAYBACK() PLAYBACK::PLAYBACK()
{ {
} }
void PLAYBACK::init() void PLAYBACK::init()
@ -29,7 +29,7 @@ void PLAYBACK::init()
void PLAYBACK::reset() void PLAYBACK::reset()
{ {
lastCursor = -1; lastCursor = -1;
pauseframe = old_pauseframe = 0; pause_frame = old_pauseframe = 0;
old_show_pauseframe = show_pauseframe = false; old_show_pauseframe = show_pauseframe = false;
old_rewind_button_state = rewind_button_state = false; old_rewind_button_state = rewind_button_state = false;
old_forward_button_state = forward_button_state = false; old_forward_button_state = forward_button_state = false;
@ -40,31 +40,31 @@ void PLAYBACK::reset()
} }
void PLAYBACK::update() void PLAYBACK::update()
{ {
// pause when seeking hit pauseframe // pause when seeking hit pause_frame
if(!FCEUI_EmulationPaused()) if(!FCEUI_EmulationPaused())
if(pauseframe && pauseframe <= currFrameCounter + 1) if(pause_frame && pause_frame <= currFrameCounter + 1)
SeekingStop(); SeekingStop();
// update flashing pauseframe // update flashing pauseframe
if (old_pauseframe != pauseframe && old_pauseframe) RedrawRowAndBookmark(old_pauseframe-1); if (old_pauseframe != pause_frame && old_pauseframe) RedrawRowAndBookmark(old_pauseframe-1);
old_pauseframe = pauseframe; old_pauseframe = pause_frame;
old_show_pauseframe = show_pauseframe; old_show_pauseframe = show_pauseframe;
if (pauseframe) if (pause_frame)
{ {
if (emu_paused) if (emu_paused)
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_PAUSED) & 1; show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_PAUSED) & 1;
else else
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_SEEKING) & 1; show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_SEEKING) & 1;
} else show_pauseframe = false; } else show_pauseframe = false;
if (old_show_pauseframe != show_pauseframe) RedrawRowAndBookmark(pauseframe-1); if (old_show_pauseframe != show_pauseframe) RedrawRowAndBookmark(pause_frame-1);
// update seeking progressbar // update seeking progressbar
old_emu_paused = emu_paused; old_emu_paused = emu_paused;
emu_paused = (FCEUI_EmulationPaused() != 0); emu_paused = (FCEUI_EmulationPaused() != 0);
if (pauseframe) if (pause_frame)
{ {
if (old_show_pauseframe != show_pauseframe) if (old_show_pauseframe != show_pauseframe)
SetProgressbar(currFrameCounter - seeking_start_frame, pauseframe-seeking_start_frame); SetProgressbar(currFrameCounter - seeking_start_frame, pause_frame - seeking_start_frame);
} else if (old_emu_paused != emu_paused) } else if (old_emu_paused != emu_paused)
{ {
// emulator got paused/unpaused externally // emulator got paused/unpaused externally
@ -79,17 +79,15 @@ void PLAYBACK::update()
//update the playback cursor //update the playback cursor
if(currFrameCounter != lastCursor) if(currFrameCounter != lastCursor)
{ {
FollowPlayback(); tasedit_list.FollowPlayback();
//update the old and new rows //update the old and new rows
RedrawRowAndBookmark(lastCursor); RedrawRowAndBookmark(lastCursor);
RedrawRowAndBookmark(currFrameCounter); RedrawRowAndBookmark(currFrameCounter);
UpdateWindow(hwndList); UpdateWindow(tasedit_list.hwndList);
lastCursor = currFrameCounter; lastCursor = currFrameCounter;
} }
// update < and > buttons // update < and > buttons
if(emu_paused)
{
old_rewind_button_state = rewind_button_state; old_rewind_button_state = rewind_button_state;
rewind_button_state = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || Tasedit_rewind_now); rewind_button_state = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || Tasedit_rewind_now);
if (rewind_button_state) if (rewind_button_state)
@ -116,7 +114,6 @@ void PLAYBACK::update()
ForwardFrame(); ForwardFrame();
} }
} }
}
// update << and >> buttons // update << and >> buttons
old_rewind_full_button_state = rewind_full_button_state; old_rewind_full_button_state = rewind_full_button_state;
rewind_full_button_state = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0); rewind_full_button_state = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0);
@ -149,9 +146,9 @@ void PLAYBACK::update()
void PLAYBACK::updateProgressbar() void PLAYBACK::updateProgressbar()
{ {
if (pauseframe) if (pause_frame)
{ {
SetProgressbar(currFrameCounter - seeking_start_frame, pauseframe-seeking_start_frame); SetProgressbar(currFrameCounter - seeking_start_frame, pause_frame - seeking_start_frame);
} else } else
{ {
if (emu_paused) if (emu_paused)
@ -183,13 +180,13 @@ void PLAYBACK::UnpauseEmulation()
void PLAYBACK::SeekingStart(int finish_frame) void PLAYBACK::SeekingStart(int finish_frame)
{ {
seeking_start_frame = currFrameCounter; seeking_start_frame = currFrameCounter;
pauseframe = finish_frame; pause_frame = finish_frame;
turbo = true; turbo = true;
UnpauseEmulation(); UnpauseEmulation();
} }
void PLAYBACK::SeekingStop() void PLAYBACK::SeekingStop()
{ {
pauseframe = 0; pause_frame = 0;
turbo = false; turbo = false;
PauseEmulation(); PauseEmulation();
SetProgressbar(1, 1); SetProgressbar(1, 1);
@ -199,10 +196,12 @@ void PLAYBACK::SeekingStop()
void PLAYBACK::RewindFrame() void PLAYBACK::RewindFrame()
{ {
if (currFrameCounter > 0) jump(currFrameCounter-1); if (currFrameCounter > 0) jump(currFrameCounter-1);
if (!pause_frame) PauseEmulation();
} }
void PLAYBACK::ForwardFrame() void PLAYBACK::ForwardFrame()
{ {
jump(currFrameCounter+1); jump(currFrameCounter+1);
if (!pause_frame) PauseEmulation();
turbo = false; turbo = false;
} }
void PLAYBACK::RewindFull() void PLAYBACK::RewindFull()
@ -247,13 +246,13 @@ void PLAYBACK::jump(int frame)
if (JumpToFrame(frame)) if (JumpToFrame(frame))
{ {
ForceExecuteLuaFrameFunctions(); ForceExecuteLuaFrameFunctions();
FollowPlayback(); tasedit_list.FollowPlayback();
} }
} }
void PLAYBACK::restorePosition() void PLAYBACK::restorePosition()
{ {
if (pauseframe) if (pause_frame)
jump(pauseframe-1); jump(pause_frame-1);
else else
jump(currFrameCounter); jump(currFrameCounter);
} }
@ -276,7 +275,7 @@ bool PLAYBACK::JumpToFrame(int index)
{ {
turbo = false; turbo = false;
// if playback was seeking, pause emulation right here // if playback was seeking, pause emulation right here
if (pauseframe) SeekingStop(); if (pause_frame) SeekingStop();
return true; return true;
} }
//Search for an earlier frame with savestate //Search for an earlier frame with savestate
@ -298,9 +297,9 @@ bool PLAYBACK::JumpToFrame(int index)
int PLAYBACK::GetPauseFrame() int PLAYBACK::GetPauseFrame()
{ {
if (show_pauseframe) if (show_pauseframe)
return pauseframe-1; return pause_frame;
else else
return -1; return 0;
} }
void PLAYBACK::SetProgressbar(int a, int b) void PLAYBACK::SetProgressbar(int a, int b)

View File

@ -36,11 +36,12 @@ public:
int GetPauseFrame(); int GetPauseFrame();
void SetProgressbar(int a, int b); void SetProgressbar(int a, int b);
int pauseframe;
private: private:
bool JumpToFrame(int index); bool JumpToFrame(int index);
int pause_frame;
int lastCursor; // for currentCursor we use external variable currFrameCounter int lastCursor; // for currentCursor we use external variable currFrameCounter
bool old_emu_paused, emu_paused; bool old_emu_paused, emu_paused;
int old_pauseframe; int old_pauseframe;

View File

@ -0,0 +1,573 @@
//Implementation file of TASEDIT_LIST class
#include "taseditproj.h"
//#include "../tasedit.h"
#include "utils/xstring.h"
extern HWND hwndTasEdit, hwndRB_Rec3P, hwndRB_Rec4P;
extern char buttonNames[NUM_JOYPAD_BUTTONS][2];
extern void ColumnSet(int column);
extern BOOKMARKS bookmarks;
extern PLAYBACK playback;
extern GREENZONE greenzone;
extern INPUT_HISTORY history;
extern MARKERS markers;
extern TASEDIT_SELECTION selection;
extern bool TASEdit_enable_hot_changes;
extern bool TASEdit_show_markers;
extern bool TASEdit_show_lag_frames;
extern bool TASEdit_follow_playback;
extern bool TASEdit_jump_to_undo;
LRESULT APIENTRY HeaderWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
WNDPROC hwndList_oldWndProc, hwndHeader_oldWndproc;
// resources
COLORREF hot_changes_colors[16] = { 0x0, 0x661212, 0x842B4E, 0x652C73, 0x48247D, 0x383596, 0x2947AE, 0x1E53C1, 0x135DD2, 0x116EDA, 0x107EE3, 0x0F8EEB, 0x209FF4, 0x3DB1FD, 0x51C2FF, 0x4DCDFF };
TASEDIT_LIST::TASEDIT_LIST()
{
// create fonts for main listview
hMainListFont = CreateFont(15, 10, /*Height,Width*/
0, 0, /*escapement,orientation*/
FW_BOLD, FALSE, FALSE, FALSE, /*weight, italic, underline, strikeout*/
ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_MASK, /*charset, precision, clipping*/
DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/
"Courier"); /*font name*/
hMainListSelectFont = CreateFont(14, 7, /*Height,Width*/
0, 0, /*escapement,orientation*/
FW_BOLD, FALSE, FALSE, FALSE, /*weight, italic, underline, strikeout*/
ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_MASK, /*charset, precision, clipping*/
DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/
"Arial"); /*font name*/
}
void TASEDIT_LIST::init()
{
//free();
hwndList = GetDlgItem(hwndTasEdit, IDC_LIST1);
// prepare the main listview
ListView_SetExtendedListViewStyleEx(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
// subclass the header
hwndHeader = ListView_GetHeader(hwndList);
hwndHeader_oldWndproc = (WNDPROC)SetWindowLong(hwndHeader, GWL_WNDPROC, (LONG)HeaderWndProc);
// subclass the whole listview
hwndList_oldWndProc = (WNDPROC)SetWindowLong(hwndList, GWL_WNDPROC, (LONG)ListWndProc);
// setup images for the listview
himglist = ImageList_Create(9, 13, ILC_COLOR8 | ILC_MASK, 1, 1);
HBITMAP bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP0));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP2));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP3));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP4));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP5));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP6));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP7));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP8));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP9));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP10));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP11));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP12));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP13));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP14));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP15));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP16));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP17));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP18));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP19));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_TE_ARROW));
ImageList_AddMasked(himglist, bmp, 0xFFFFFF);
DeleteObject(bmp);
ListView_SetImageList(hwndList, himglist, LVSIL_SMALL);
// setup columns
LVCOLUMN lvc;
int colidx=0;
// icons column
lvc.mask = LVCF_WIDTH;
lvc.cx = 13;
ListView_InsertColumn(hwndList, colidx++, &lvc);
// frame number column
lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT;
lvc.fmt = LVCFMT_CENTER;
lvc.cx = 75;
lvc.pszText = "Frame#";
ListView_InsertColumn(hwndList, colidx++, &lvc);
// pads columns
lvc.cx = 21;
// add pads 1 and 2
for (int joy = 0; joy < 2; ++joy)
{
for (int btn = 0; btn < NUM_JOYPAD_BUTTONS; ++btn)
{
lvc.pszText = buttonNames[btn];
ListView_InsertColumn(hwndList, colidx++, &lvc);
}
}
// add pads 3 and 4 and frame_number2
if (currMovieData.fourscore) AddFourscore();
listItems = ListView_GetCountPerPage(hwndList);
// calculate scr_bmp coordinates (relative to the listview top-left corner
RECT temp_rect, parent_rect;
GetWindowRect(hwndTasEdit, &parent_rect);
GetWindowRect(hwndHeader, &temp_rect);
bookmarks.scr_bmp_x = temp_rect.left - parent_rect.left;
bookmarks.scr_bmp_y = temp_rect.bottom - parent_rect.top;
update();
}
void TASEDIT_LIST::free()
{
}
void TASEDIT_LIST::update()
{
//update the number of items in the list
int currLVItemCount = ListView_GetItemCount(hwndList);
int movie_size = currMovieData.getNumRecords();
if(currLVItemCount != movie_size)
ListView_SetItemCountEx(hwndList, movie_size, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL);
}
// ----------------------------------------------------------------------
void TASEDIT_LIST::AddFourscore()
{
// add list columns
LVCOLUMN lvc;
lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT;
lvc.fmt = LVCFMT_CENTER;
lvc.cx = 21;
int colidx = COLUMN_JOYPAD3_A;
for (int joy = 0; joy < 2; ++joy)
{
for (int btn = 0; btn < NUM_JOYPAD_BUTTONS; ++btn)
{
lvc.pszText = buttonNames[btn];
ListView_InsertColumn(hwndList, colidx++, &lvc);
}
}
// frame number column again
lvc.cx = 75;
lvc.pszText = "Frame#";
ListView_InsertColumn(hwndList, colidx++, &lvc);
// enable radiobuttons for 3P/4P multitracking
EnableWindow(hwndRB_Rec3P, true);
EnableWindow(hwndRB_Rec4P, true);
// change eoptions
FCEUI_SetInputFourscore(true);
}
void TASEDIT_LIST::RemoveFourscore()
{
// remove list columns
for (int i = COLUMN_FRAMENUM2; i >= COLUMN_JOYPAD3_A; --i)
{
ListView_DeleteColumn (hwndList, i);
}
// disable radiobuttons for 3P/4P multitracking
EnableWindow(hwndRB_Rec3P, false);
EnableWindow(hwndRB_Rec4P, false);
// change eoptions
FCEUI_SetInputFourscore(false);
}
void TASEDIT_LIST::RedrawList()
{
InvalidateRect(hwndList, 0, FALSE);
}
void TASEDIT_LIST::RedrawRow(int index)
{
ListView_RedrawItems(hwndList, index, index);
}
// -------------------------------------------------------------------------
bool TASEDIT_LIST::CheckItemVisible(int frame)
{
int top = ListView_GetTopIndex(hwndList);
// in fourscore there's horizontal scrollbar which takes one row for itself
if (frame >= top && frame < top + listItems - (currMovieData.fourscore)?1:0)
return true;
return false;
}
void TASEDIT_LIST::FollowPlayback()
{
if (TASEdit_follow_playback) ListView_EnsureVisible(hwndList,currFrameCounter,FALSE);
}
void TASEDIT_LIST::FollowUndo()
{
int jump_frame = history.GetUndoHint();
if (TASEdit_jump_to_undo && jump_frame >= 0)
{
if (!CheckItemVisible(jump_frame))
{
// center list at jump_frame
int list_items = listItems;
if (currMovieData.fourscore) list_items--;
int lower_border = (list_items - 1) / 2;
int upper_border = (list_items - 1) - lower_border;
int index = jump_frame + lower_border;
if (index >= currMovieData.getNumRecords())
index = currMovieData.getNumRecords()-1;
ListView_EnsureVisible(hwndList, index, false);
index = jump_frame - upper_border;
if (index < 0)
index = 0;
ListView_EnsureVisible(hwndList, index, false);
}
}
}
void TASEDIT_LIST::FollowSelection()
{
SelectionFrames* current_selection = selection.MakeStrobe();
if (current_selection->size() == 0) return;
int list_items = listItems;
if (currMovieData.fourscore) list_items--;
int selection_start = *current_selection->begin();
int selection_end = *current_selection->rbegin();
int selection_items = 1 + selection_end - selection_start;
if (selection_items <= list_items)
{
// selected region can fit in screen
int lower_border = (list_items - selection_items) / 2;
int upper_border = (list_items - selection_items) - lower_border;
int index = selection_end + lower_border;
if (index >= currMovieData.getNumRecords())
index = currMovieData.getNumRecords()-1;
ListView_EnsureVisible(hwndList, index, false);
index = selection_start - upper_border;
if (index < 0)
index = 0;
ListView_EnsureVisible(hwndList, index, false);
} else
{
// selected region is too big to fit in screen
// just center at selection_start
int lower_border = (list_items - 1) / 2;
int upper_border = (list_items - 1) - lower_border;
int index = selection_start + lower_border;
if (index >= currMovieData.getNumRecords())
index = currMovieData.getNumRecords()-1;
ListView_EnsureVisible(hwndList, index, false);
index = selection_start - upper_border;
if (index < 0)
index = 0;
ListView_EnsureVisible(hwndList, index, false);
}
}
void TASEDIT_LIST::FollowPauseframe()
{
int jump_frame = playback.GetPauseFrame();
if (jump_frame >= 0)
{
// center list at jump_frame
int list_items = listItems;
if (currMovieData.fourscore) list_items--;
int lower_border = (list_items - 1) / 2;
int upper_border = (list_items - 1) - lower_border;
int index = jump_frame + lower_border;
if (index >= currMovieData.getNumRecords())
index = currMovieData.getNumRecords()-1;
ListView_EnsureVisible(hwndList, index, false);
index = jump_frame - upper_border;
if (index < 0)
index = 0;
ListView_EnsureVisible(hwndList, index, false);
}
}
void TASEDIT_LIST::GetDispInfo(NMLVDISPINFO* nmlvDispInfo)
{
LVITEM& item = nmlvDispInfo->item;
if(item.mask & LVIF_TEXT)
{
switch(item.iSubItem)
{
case COLUMN_ICONS:
{
if(item.iImage == I_IMAGECALLBACK)
{
item.iImage = bookmarks.FindBookmarkAtFrame(item.iItem);
if (item.iImage < 0)
{
if (item.iItem == currFrameCounter)
item.iImage = ARROW_IMAGE_ID;
}
}
break;
}
case COLUMN_FRAMENUM:
case COLUMN_FRAMENUM2:
{
U32ToDecStr(item.pszText, item.iItem, DIGITS_IN_FRAMENUM);
break;
}
case COLUMN_JOYPAD1_A: case COLUMN_JOYPAD1_B: case COLUMN_JOYPAD1_S: case COLUMN_JOYPAD1_T:
case COLUMN_JOYPAD1_U: case COLUMN_JOYPAD1_D: case COLUMN_JOYPAD1_L: case COLUMN_JOYPAD1_R:
case COLUMN_JOYPAD2_A: case COLUMN_JOYPAD2_B: case COLUMN_JOYPAD2_S: case COLUMN_JOYPAD2_T:
case COLUMN_JOYPAD2_U: case COLUMN_JOYPAD2_D: case COLUMN_JOYPAD2_L: case COLUMN_JOYPAD2_R:
case COLUMN_JOYPAD3_A: case COLUMN_JOYPAD3_B: case COLUMN_JOYPAD3_S: case COLUMN_JOYPAD3_T:
case COLUMN_JOYPAD3_U: case COLUMN_JOYPAD3_D: case COLUMN_JOYPAD3_L: case COLUMN_JOYPAD3_R:
case COLUMN_JOYPAD4_A: case COLUMN_JOYPAD4_B: case COLUMN_JOYPAD4_S: case COLUMN_JOYPAD4_T:
case COLUMN_JOYPAD4_U: case COLUMN_JOYPAD4_D: case COLUMN_JOYPAD4_L: case COLUMN_JOYPAD4_R:
{
int joy = (item.iSubItem - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS;
int bit = (item.iSubItem - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS;
uint8 data = currMovieData.records[item.iItem].joysticks[joy];
if(data & (1<<bit))
{
item.pszText[0] = buttonNames[bit][0];
item.pszText[2] = 0;
} else
{
if (TASEdit_enable_hot_changes && history.GetCurrentSnapshot().GetHotChangeInfo(item.iItem, item.iSubItem - COLUMN_JOYPAD1_A))
{
item.pszText[0] = 45; // "-"
item.pszText[1] = 0;
} else item.pszText[0] = 0;
}
}
break;
}
}
}
LONG TASEDIT_LIST::CustomDraw(NMLVCUSTOMDRAW* msg)
{
int cell_x, cell_y;
switch(msg->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
return CDRF_NOTIFYSUBITEMDRAW;
case CDDS_SUBITEMPREPAINT:
cell_x = msg->iSubItem;
cell_y = msg->nmcd.dwItemSpec;
if(cell_x > COLUMN_ICONS)
{
SelectObject(msg->nmcd.hdc, hMainListFont);
// text color
if(TASEdit_enable_hot_changes && cell_x >= COLUMN_JOYPAD1_A && cell_x <= COLUMN_JOYPAD4_R)
{
msg->clrText = hot_changes_colors[history.GetCurrentSnapshot().GetHotChangeInfo(cell_y, cell_x - COLUMN_JOYPAD1_A)];
} else msg->clrText = NORMAL_TEXT_COLOR;
// bg color
if(cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2)
{
// frame number
if (cell_y == history.GetUndoHint())
{
// undo hint here
if(TASEdit_show_markers && (int)markers.markers_array.size() > cell_y && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
msg->clrTextBk = MARKED_UNDOHINT_FRAMENUM_COLOR;
else
msg->clrTextBk = UNDOHINT_FRAMENUM_COLOR;
} else if (cell_y == currFrameCounter || cell_y == (playback.GetPauseFrame() - 1))
{
// current frame
if(TASEdit_show_markers && (int)markers.markers_array.size() > cell_y && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
// this frame is also marked
msg->clrTextBk = CUR_MARKED_FRAMENUM_COLOR;
else
msg->clrTextBk = CUR_FRAMENUM_COLOR;
} else if(TASEdit_show_markers && (int)markers.markers_array.size() > cell_y && (markers.markers_array[cell_y] & MARKER_FLAG_BIT))
{
// marked frame
msg->clrTextBk = MARKED_FRAMENUM_COLOR;
} else if(cell_y < greenzone.greenZoneCount)
{
if (!greenzone.savestates[cell_y].empty())
{
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
msg->clrTextBk = LAG_FRAMENUM_COLOR;
else
msg->clrTextBk = GREENZONE_FRAMENUM_COLOR;
} else if ((!greenzone.savestates[cell_y & EVERY16TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0xF) + 1 && !greenzone.savestates[(cell_y | 0xF) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY8TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0x7) + 1 && !greenzone.savestates[(cell_y | 0x7) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY4TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0x3) + 1 && !greenzone.savestates[(cell_y | 0x3) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY2ND].empty() && !greenzone.savestates[(cell_y | 0x1) + 1].empty()))
{
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
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 if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2)
{
// pad 1 or 3
if (cell_y == history.GetUndoHint())
{
// undo hint here
msg->clrTextBk = UNDOHINT_INPUT_COLOR1;
} else if (cell_y == currFrameCounter || cell_y == (playback.GetPauseFrame() - 1))
{
// current frame
msg->clrTextBk = CUR_INPUT_COLOR1;
} else if(cell_y < greenzone.greenZoneCount)
{
if (!greenzone.savestates[cell_y].empty())
{
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
msg->clrTextBk = LAG_INPUT_COLOR1;
else
msg->clrTextBk = GREENZONE_INPUT_COLOR1;
} else if ((!greenzone.savestates[cell_y & EVERY16TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0xF) + 1 && !greenzone.savestates[(cell_y | 0xF) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY8TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0x7) + 1 && !greenzone.savestates[(cell_y | 0x7) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY4TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0x3) + 1 && !greenzone.savestates[(cell_y | 0x3) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY2ND].empty() && !greenzone.savestates[(cell_y | 0x1) + 1].empty()))
{
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
msg->clrTextBk = PALE_LAG_INPUT_COLOR1;
else
msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR1;
} else msg->clrTextBk = NORMAL_INPUT_COLOR1;
} else msg->clrTextBk = NORMAL_INPUT_COLOR1;
} else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3)
{
// pad 2 or 4
if (cell_y == history.GetUndoHint())
{
// undo hint here
msg->clrTextBk = UNDOHINT_INPUT_COLOR2;
} else if (cell_y == currFrameCounter || cell_y == (playback.GetPauseFrame() - 1))
{
// current frame
msg->clrTextBk = CUR_INPUT_COLOR2;
} else if(cell_y < greenzone.greenZoneCount)
{
if (!greenzone.savestates[cell_y].empty())
{
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
msg->clrTextBk = LAG_INPUT_COLOR2;
else
msg->clrTextBk = GREENZONE_INPUT_COLOR2;
} else if ((!greenzone.savestates[cell_y & EVERY16TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0xF) + 1 && !greenzone.savestates[(cell_y | 0xF) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY8TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0x7) + 1 && !greenzone.savestates[(cell_y | 0x7) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY4TH].empty() && (int)greenzone.savestates.size() > (cell_y | 0x3) + 1 && !greenzone.savestates[(cell_y | 0x3) + 1].empty())
|| (!greenzone.savestates[cell_y & EVERY2ND].empty() && !greenzone.savestates[(cell_y | 0x1) + 1].empty()))
{
if (TASEdit_show_lag_frames && greenzone.lag_history[cell_y])
msg->clrTextBk = PALE_LAG_INPUT_COLOR2;
else
msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR2;
} else msg->clrTextBk = NORMAL_INPUT_COLOR2;
} else msg->clrTextBk = NORMAL_INPUT_COLOR2;
}
}
default:
return CDRF_DODEFAULT;
}
}
// -------------------------------------------------------------------------
LRESULT APIENTRY HeaderWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_SETCURSOR:
return true; // no column resizing
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
{
if (selection.GetCurrentSelectionSize())
{
//perform hit test
HD_HITTESTINFO info;
info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam);
SendMessage(hWnd,HDM_HITTEST,0,(LPARAM)&info);
if(info.iItem >= COLUMN_FRAMENUM && info.iItem <= COLUMN_FRAMENUM2)
ColumnSet(info.iItem);
}
}
return true;
}
return CallWindowProc(hwndHeader_oldWndproc, hWnd, msg, wParam, lParam);
}
//The subclass wndproc for the listview
LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CHAR:
case WM_KILLFOCUS:
return 0;
case WM_NOTIFY:
{
switch (((LPNMHDR)lParam)->code)
{
case HDN_BEGINTRACKW:
case HDN_BEGINTRACKA:
case HDN_TRACK:
return true; // no column resizing
}
break;
}
case WM_SYSKEYDOWN:
{
if (wParam == VK_F10)
return 0;
break;
}
}
return CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam);
}

View File

@ -0,0 +1,121 @@
//Specification file for TASEDIT_LIST class
#define CDDS_SUBITEMPREPAINT (CDDS_SUBITEM | CDDS_ITEMPREPAINT)
#define CDDS_SUBITEMPOSTPAINT (CDDS_SUBITEM | CDDS_ITEMPOSTPAINT)
#define CDDS_SUBITEMPREERASE (CDDS_SUBITEM | CDDS_ITEMPREERASE)
#define CDDS_SUBITEMPOSTERASE (CDDS_SUBITEM | CDDS_ITEMPOSTERASE)
#define NUM_JOYPADS 4
#define NUM_JOYPAD_BUTTONS 8
#define COLUMN_ICONS 0
#define COLUMN_FRAMENUM 1
#define COLUMN_JOYPAD1_A 2
#define COLUMN_JOYPAD1_B 3
#define COLUMN_JOYPAD1_S 4
#define COLUMN_JOYPAD1_T 5
#define COLUMN_JOYPAD1_U 6
#define COLUMN_JOYPAD1_D 7
#define COLUMN_JOYPAD1_L 8
#define COLUMN_JOYPAD1_R 9
#define COLUMN_JOYPAD2_A 10
#define COLUMN_JOYPAD2_B 11
#define COLUMN_JOYPAD2_S 12
#define COLUMN_JOYPAD2_T 13
#define COLUMN_JOYPAD2_U 14
#define COLUMN_JOYPAD2_D 15
#define COLUMN_JOYPAD2_L 16
#define COLUMN_JOYPAD2_R 17
#define COLUMN_JOYPAD3_A 18
#define COLUMN_JOYPAD3_B 19
#define COLUMN_JOYPAD3_S 20
#define COLUMN_JOYPAD3_T 21
#define COLUMN_JOYPAD3_U 22
#define COLUMN_JOYPAD3_D 23
#define COLUMN_JOYPAD3_L 24
#define COLUMN_JOYPAD3_R 25
#define COLUMN_JOYPAD4_A 26
#define COLUMN_JOYPAD4_B 27
#define COLUMN_JOYPAD4_S 28
#define COLUMN_JOYPAD4_T 29
#define COLUMN_JOYPAD4_U 30
#define COLUMN_JOYPAD4_D 31
#define COLUMN_JOYPAD4_L 32
#define COLUMN_JOYPAD4_R 33
#define COLUMN_FRAMENUM2 34
#define DIGITS_IN_FRAMENUM 7
#define ARROW_IMAGE_ID 20
// listview colors
#define NORMAL_TEXT_COLOR 0x0
#define NORMAL_FRAMENUM_COLOR 0xFFFFFF
#define NORMAL_INPUT_COLOR1 0xEDEDED
#define NORMAL_INPUT_COLOR2 0xDEDEDE
#define GREENZONE_FRAMENUM_COLOR 0xDDFFDD
#define GREENZONE_INPUT_COLOR1 0xC8F7C4
#define GREENZONE_INPUT_COLOR2 0xAEE2AE
#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4FFE4
#define PALE_GREENZONE_INPUT_COLOR1 0xD5F9D4
#define PALE_GREENZONE_INPUT_COLOR2 0xBAE6BA
#define LAG_FRAMENUM_COLOR 0xDBDAFF
#define LAG_INPUT_COLOR1 0xCECBEF
#define LAG_INPUT_COLOR2 0xBEBAE4
#define PALE_LAG_FRAMENUM_COLOR 0xE1E1FF
#define PALE_LAG_INPUT_COLOR1 0xD6D3F1
#define PALE_LAG_INPUT_COLOR2 0xC7C4E8
#define CUR_FRAMENUM_COLOR 0xFCF1CE
#define CUR_INPUT_COLOR1 0xF7E9B2
#define CUR_INPUT_COLOR2 0xE4D8A8
#define UNDOHINT_FRAMENUM_COLOR 0xF9DDE6
#define UNDOHINT_INPUT_COLOR1 0xF6CCDD
#define UNDOHINT_INPUT_COLOR2 0xE5B7CC
#define MARKED_FRAMENUM_COLOR 0xC0FCFF
#define CUR_MARKED_FRAMENUM_COLOR 0xDEF7F3
#define MARKED_UNDOHINT_FRAMENUM_COLOR 0xE1E7EC
class TASEDIT_LIST
{
public:
TASEDIT_LIST();
void init();
void free();
void update();
void AddFourscore();
void RemoveFourscore();
void RedrawList();
void RedrawRow(int index);
bool CheckItemVisible(int frame);
void FollowPlayback();
void FollowUndo();
void FollowSelection();
void FollowPauseframe();
void GetDispInfo(NMLVDISPINFO* nmlvDispInfo);
LONG CustomDraw(NMLVCUSTOMDRAW* msg);
HWND hwndList, hwndHeader;
HIMAGELIST himglist;
private:
int listItems; // number of items per list page
// GDI stuff
HFONT hMainListFont, hMainListSelectFont;
};

View File

@ -7,9 +7,7 @@
char selection_save_id[SELECTION_ID_LEN] = "SELECTION"; char selection_save_id[SELECTION_ID_LEN] = "SELECTION";
extern MARKERS markers; extern MARKERS markers;
extern TASEDIT_LIST tasedit_list;
extern HWND hwndList;
extern void RedrawList();
TASEDIT_SELECTION::TASEDIT_SELECTION() TASEDIT_SELECTION::TASEDIT_SELECTION()
{ {
@ -40,7 +38,7 @@ void TASEDIT_SELECTION::free()
void TASEDIT_SELECTION::update() void TASEDIT_SELECTION::update()
{ {
// keep selection within list limits // keep selection within movie limits
if (CurrentSelection().size()) if (CurrentSelection().size())
{ {
int delete_index; int delete_index;
@ -56,13 +54,6 @@ void TASEDIT_SELECTION::update()
} }
bool TASEDIT_SELECTION::CheckFrameSelected(int frame)
{
if(CurrentSelection().find(frame) == CurrentSelection().end())
return false;
return true;
}
void TASEDIT_SELECTION::save(EMUFILE *os) void TASEDIT_SELECTION::save(EMUFILE *os)
{ {
// write "SELECTION" string // write "SELECTION" string
@ -228,11 +219,6 @@ void TASEDIT_SELECTION::AddNewSelectionToHistory()
selections_history[(history_start_pos + history_cursor_pos) % history_size] = selectionFrames; selections_history[(history_start_pos + history_cursor_pos) % history_size] = selectionFrames;
} }
SelectionFrames& TASEDIT_SELECTION::CurrentSelection()
{
return selections_history[(history_start_pos + history_cursor_pos) % history_size];
}
void TASEDIT_SELECTION::jump(int new_pos) void TASEDIT_SELECTION::jump(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 < 0) new_pos = 0; else if (new_pos >= history_total_items) new_pos = history_total_items-1;
@ -256,8 +242,8 @@ void TASEDIT_SELECTION::redo()
void TASEDIT_SELECTION::MemorizeClipboardSelection() void TASEDIT_SELECTION::MemorizeClipboardSelection()
{ {
// copy current selection data to clipboard_selection // copy currently strobed selection data to clipboard_selection
clipboard_selection = CurrentSelection(); clipboard_selection = temp_selection;
} }
void TASEDIT_SELECTION::ReselectClipboard() void TASEDIT_SELECTION::ReselectClipboard()
{ {
@ -272,11 +258,11 @@ void TASEDIT_SELECTION::ReselectClipboard()
// ---------------------------------------------------------- // ----------------------------------------------------------
void TASEDIT_SELECTION::ClearSelection() void TASEDIT_SELECTION::ClearSelection()
{ {
ListView_SetItemState(hwndList, -1, 0, LVIS_FOCUSED|LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, -1, 0, LVIS_FOCUSED|LVIS_SELECTED);
} }
void TASEDIT_SELECTION::ClearRowSelection(int index) void TASEDIT_SELECTION::ClearRowSelection(int index)
{ {
ListView_SetItemState(hwndList, index, 0, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, index, 0, LVIS_SELECTED);
} }
void TASEDIT_SELECTION::EnforceSelectionToList() void TASEDIT_SELECTION::EnforceSelectionToList()
@ -285,24 +271,24 @@ void TASEDIT_SELECTION::EnforceSelectionToList()
ClearSelection(); ClearSelection();
for(SelectionFrames::reverse_iterator it(CurrentSelection().rbegin()); it != CurrentSelection().rend(); it++) for(SelectionFrames::reverse_iterator it(CurrentSelection().rbegin()); it != CurrentSelection().rend(); it++)
{ {
ListView_SetItemState(hwndList, *it, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, *it, LVIS_SELECTED, LVIS_SELECTED);
} }
track_selection_changes = true; track_selection_changes = true;
} }
void TASEDIT_SELECTION::SelectAll() void TASEDIT_SELECTION::SelectAll()
{ {
ListView_SetItemState(hwndList, -1, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, -1, LVIS_SELECTED, LVIS_SELECTED);
//RedrawList(); //RedrawList();
} }
void TASEDIT_SELECTION::SetRowSelection(int index) void TASEDIT_SELECTION::SetRowSelection(int index)
{ {
ListView_SetItemState(hwndList, index, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, index, LVIS_SELECTED, LVIS_SELECTED);
} }
void TASEDIT_SELECTION::SetRegionSelection(int start, int end) void TASEDIT_SELECTION::SetRegionSelection(int start, int end)
{ {
for (int i = start; i <= end; ++i) for (int i = start; i <= end; ++i)
ListView_SetItemState(hwndList, i, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
} }
void TASEDIT_SELECTION::SelectMidMarkers() void TASEDIT_SELECTION::SelectMidMarkers()
{ {
@ -326,7 +312,7 @@ void TASEDIT_SELECTION::SelectMidMarkers()
if (markers.markers_array[lower_marker] & MARKER_FLAG_BIT) break; if (markers.markers_array[lower_marker] & MARKER_FLAG_BIT) break;
// clear selection without clearing focused, because otherwise there's strange bug when quickly pressing Ctrl+A right after clicking on already selected row // clear selection without clearing focused, because otherwise there's strange bug when quickly pressing Ctrl+A right after clicking on already selected row
ListView_SetItemState(hwndList, -1, 0, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, -1, 0, LVIS_SELECTED);
// special case // special case
if (upper_marker == -1 && lower_marker == movie_size) if (upper_marker == -1 && lower_marker == movie_size)
@ -341,7 +327,7 @@ void TASEDIT_SELECTION::SelectMidMarkers()
// default: select all between markers // default: select all between markers
for (int i = upper_marker+1; i < lower_marker; ++i) for (int i = upper_marker+1; i < lower_marker; ++i)
{ {
ListView_SetItemState(hwndList, i, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
} }
} else if (upper_border == upper_marker+1 && lower_border == lower_marker-1) } else if (upper_border == upper_marker+1 && lower_border == lower_marker-1)
{ {
@ -350,14 +336,14 @@ void TASEDIT_SELECTION::SelectMidMarkers()
if (lower_marker >= movie_size) lower_marker = movie_size - 1; if (lower_marker >= movie_size) lower_marker = movie_size - 1;
for (int i = upper_marker; i <= lower_marker; ++i) for (int i = upper_marker; i <= lower_marker; ++i)
{ {
ListView_SetItemState(hwndList, i, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
} }
} else if (upper_border <= upper_marker && lower_border >= lower_marker) } else if (upper_border <= upper_marker && lower_border >= lower_marker)
{ {
// selected all between markers and both markers selected too - now deselect lower marker // selected all between markers and both markers selected too - now deselect lower marker
for (int i = upper_marker; i < lower_marker; ++i) for (int i = upper_marker; i < lower_marker; ++i)
{ {
ListView_SetItemState(hwndList, i, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
} }
} else if (upper_border == upper_marker && lower_border == lower_marker-1) } else if (upper_border == upper_marker && lower_border == lower_marker-1)
{ {
@ -365,22 +351,48 @@ void TASEDIT_SELECTION::SelectMidMarkers()
if (lower_marker >= movie_size) lower_marker = movie_size - 1; if (lower_marker >= movie_size) lower_marker = movie_size - 1;
for (int i = upper_marker+1; i <= lower_marker; ++i) for (int i = upper_marker+1; i <= lower_marker; ++i)
{ {
ListView_SetItemState(hwndList, i, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
} }
} else if (upper_border == upper_marker+1 && lower_border == lower_marker) } else if (upper_border == upper_marker+1 && lower_border == lower_marker)
{ {
// selected all between markers and lower marker selected too - now deselect lower marker (return to "selected all between markers") // selected all between markers and lower marker selected too - now deselect lower marker (return to "selected all between markers")
for (int i = upper_marker + 1; i < lower_marker; ++i) for (int i = upper_marker + 1; i < lower_marker; ++i)
{ {
ListView_SetItemState(hwndList, i, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(tasedit_list.hwndList, i, LVIS_SELECTED, LVIS_SELECTED);
} }
} }
} }
// getters
int TASEDIT_SELECTION::GetCurrentSelectionSize()
{
return selections_history[(history_start_pos + history_cursor_pos) % history_size].size();
}
int TASEDIT_SELECTION::GetCurrentSelectionBeginning()
{
if (selections_history[(history_start_pos + history_cursor_pos) % history_size].size())
return *selections_history[(history_start_pos + history_cursor_pos) % history_size].begin();
else
return -1;
}
bool TASEDIT_SELECTION::CheckFrameSelected(int frame)
{
if(CurrentSelection().find(frame) == CurrentSelection().end())
return false;
return true;
}
SelectionFrames* TASEDIT_SELECTION::MakeStrobe()
{
// copy current selection to temp_selection
temp_selection = selections_history[(history_start_pos + history_cursor_pos) % history_size];
return &temp_selection;
}
SelectionFrames& TASEDIT_SELECTION::GetStrobedSelection()
{
return temp_selection;
}
// this getter is only for inside-class use
SelectionFrames& TASEDIT_SELECTION::CurrentSelection()
{
return selections_history[(history_start_pos + history_cursor_pos) % history_size];
}

View File

@ -20,7 +20,6 @@ public:
void ItemChanged(NMLISTVIEW* info); void ItemChanged(NMLISTVIEW* info);
void AddNewSelectionToHistory(); void AddNewSelectionToHistory();
SelectionFrames& CurrentSelection();
void undo(); void undo();
void redo(); void redo();
@ -39,10 +38,16 @@ public:
void SetRegionSelection(int start, int end); void SetRegionSelection(int start, int end);
void SelectMidMarkers(); void SelectMidMarkers();
// getters
int GetCurrentSelectionSize();
int GetCurrentSelectionBeginning();
bool CheckFrameSelected(int frame); bool CheckFrameSelected(int frame);
SelectionFrames* MakeStrobe();
SelectionFrames& GetStrobedSelection();
private: private:
SelectionFrames& CurrentSelection();
bool track_selection_changes; bool track_selection_changes;
std::vector<SelectionFrames> selections_history; std::vector<SelectionFrames> selections_history;
@ -53,5 +58,6 @@ private:
int history_total_items; int history_total_items;
int history_size; int history_size;
SelectionFrames temp_selection;
}; };

View File

@ -9,6 +9,7 @@ extern BOOKMARKS bookmarks;
extern GREENZONE greenzone; extern GREENZONE greenzone;
extern PLAYBACK playback; extern PLAYBACK playback;
extern INPUT_HISTORY history; extern INPUT_HISTORY history;
extern TASEDIT_LIST tasedit_list;
extern TASEDIT_SELECTION selection; extern TASEDIT_SELECTION selection;
extern void FCEU_printf(char *format, ...); extern void FCEU_printf(char *format, ...);
@ -81,7 +82,7 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
bool error; bool error;
LoadFM2(currMovieData, &ifs, ifs.size(), false); LoadFM2(currMovieData, &ifs, ifs.size(), false);
LoadSubtitles(currMovieData); LoadSubtitles(currMovieData);
UpdateList(); tasedit_list.update();
// try to load markers // try to load markers
error = markers.load(&ifs); error = markers.load(&ifs);
if (error) if (error)

View File

@ -11,6 +11,7 @@ typedef std::set<int> SelectionFrames;
#include "greenzone.h" #include "greenzone.h"
#include "markers.h" #include "markers.h"
#include "bookmarks.h" #include "bookmarks.h"
#include "tasedit_list.h"
#include "tasedit_sel.h" #include "tasedit_sel.h"
class TASEDIT_PROJECT class TASEDIT_PROJECT

View File

@ -50,7 +50,6 @@
#include "cdlogger.h" #include "cdlogger.h"
#include "throttle.h" #include "throttle.h"
#include "monitor.h" #include "monitor.h"
#include "tasedit.h"
#include "keyboard.h" #include "keyboard.h"
#include "joystick.h" #include "joystick.h"
#include "oldmovie.h" #include "oldmovie.h"
@ -1923,6 +1922,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
// break; // break;
// Removing this tool since it is redundant to both // Removing this tool since it is redundant to both
case MENU_TASEDIT: case MENU_TASEDIT:
extern void EnterTasEdit();
EnterTasEdit(); EnterTasEdit();
break; break;
case MENU_CONVERT_MOVIE: case MENU_CONVERT_MOVIE:

View File

@ -589,6 +589,7 @@ void FCEUI_ResetNES(void)
return; return;
FCEU_QSimpleCommand(FCEUNPCMD_RESET); FCEU_QSimpleCommand(FCEUNPCMD_RESET);
ResetFrameCounter(); ResetFrameCounter();
FCEU_DispMessage("Soft reset", 0);
} }
//Powers off the NES //Powers off the NES
@ -598,6 +599,7 @@ void FCEUI_PowerNES(void)
return; return;
FCEU_QSimpleCommand(FCEUNPCMD_POWER); FCEU_QSimpleCommand(FCEUNPCMD_POWER);
ResetFrameCounter(); ResetFrameCounter();
FCEU_DispMessage("Power switch", 0);
} }
const char* FCEUI_CommandTypeNames[]= const char* FCEUI_CommandTypeNames[]=

View File

@ -252,7 +252,6 @@ extern bool subtitlesOnAVI;
extern bool freshMovie; extern bool freshMovie;
extern bool movie_readonly; extern bool movie_readonly;
extern bool autoMovieBackup; extern bool autoMovieBackup;
extern int pauseframe;
extern bool fullSaveStateLoads; extern bool fullSaveStateLoads;
//-------------------------------------------------- //--------------------------------------------------
void FCEUI_MakeBackupMovie(bool dispMessage); void FCEUI_MakeBackupMovie(bool dispMessage);

View File

@ -426,6 +426,7 @@
<ClCompile Include="..\src\drivers\win\taseditlib\inputsnapshot.cpp" /> <ClCompile Include="..\src\drivers\win\taseditlib\inputsnapshot.cpp" />
<ClCompile Include="..\src\drivers\win\taseditlib\markers.cpp" /> <ClCompile Include="..\src\drivers\win\taseditlib\markers.cpp" />
<ClCompile Include="..\src\drivers\win\taseditlib\playback.cpp" /> <ClCompile Include="..\src\drivers\win\taseditlib\playback.cpp" />
<ClCompile Include="..\src\drivers\win\taseditlib\tasedit_list.cpp" />
<ClCompile Include="..\src\drivers\win\taseditlib\tasedit_sel.cpp" /> <ClCompile Include="..\src\drivers\win\taseditlib\tasedit_sel.cpp" />
<ClCompile Include="..\src\drivers\win\texthook.cpp" /> <ClCompile Include="..\src\drivers\win\texthook.cpp" />
<ClCompile Include="..\src\drivers\win\throttle.cpp" /> <ClCompile Include="..\src\drivers\win\throttle.cpp" />
@ -739,6 +740,7 @@
<ClInclude Include="..\src\drivers\win\state.h" /> <ClInclude Include="..\src\drivers\win\state.h" />
<ClInclude Include="..\src\drivers\win\tasedit.h" /> <ClInclude Include="..\src\drivers\win\tasedit.h" />
<ClInclude Include="..\src\drivers\win\taseditlib\inputhistory.h" /> <ClInclude Include="..\src\drivers\win\taseditlib\inputhistory.h" />
<ClInclude Include="..\src\drivers\win\taseditlib\tasedit_list.h" />
<ClInclude Include="..\src\drivers\win\taseditlib\tasedit_sel.h" /> <ClInclude Include="..\src\drivers\win\taseditlib\tasedit_sel.h" />
<ClInclude Include="..\src\drivers\win\texthook.h" /> <ClInclude Include="..\src\drivers\win\texthook.h" />
<ClInclude Include="..\src\drivers\win\throttle.h" /> <ClInclude Include="..\src\drivers\win\throttle.h" />

View File

@ -929,6 +929,7 @@
<Filter>drivers\win\taseditlib</Filter> <Filter>drivers\win\taseditlib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\drivers\win\taseditlib\tasedit_sel.cpp" /> <ClCompile Include="..\src\drivers\win\taseditlib\tasedit_sel.cpp" />
<ClCompile Include="..\src\drivers\win\taseditlib\tasedit_list.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\cart.h"> <ClInclude Include="..\src\cart.h">
@ -1377,6 +1378,7 @@
<Filter>drivers\win\taseditlib</Filter> <Filter>drivers\win\taseditlib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\drivers\win\taseditlib\tasedit_sel.h" /> <ClInclude Include="..\src\drivers\win\taseditlib\tasedit_sel.h" />
<ClInclude Include="..\src\drivers\win\taseditlib\tasedit_list.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\src\drivers\win\res.rc"> <ResourceCompile Include="..\src\drivers\win\res.rc">