Ported over TAS modules to Qt. They compile but need to be integrated.
This commit is contained in:
parent
f00613007b
commit
801bd77639
|
@ -534,12 +534,22 @@ set(SRC_DRIVERS_SDL
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/avi/fileio.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/avi/gwavi.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/TasEditorWindow.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/taseditor_project.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/taseditor_config.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/taseditor_lua.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/markers_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/greenzone.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/selection.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/playback.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/recorder.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/history.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/splicer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/inputlog.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/laglog.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/branches.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/bookmarks.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/bookmark.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/snapshot.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TasEditor/markers.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -37,8 +37,17 @@
|
|||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
TasEditorWindow *tasWin = NULL;
|
||||
TASEDITOR_PROJECT *project = NULL;
|
||||
TASEDITOR_CONFIG *taseditorConfig = NULL;
|
||||
TASEDITOR_LUA *taseditor_lua = NULL;
|
||||
MARKERS_MANAGER *markersManager = NULL;
|
||||
SELECTION *selection = NULL;
|
||||
GREENZONE *greenzone = NULL;
|
||||
BOOKMARKS *bookmarks = NULL;
|
||||
BRANCHES *branches = NULL;
|
||||
PLAYBACK *playback = NULL;
|
||||
RECORDER *recorder = NULL;
|
||||
HISTORY *history = NULL;
|
||||
SPLICER *splicer = NULL;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -80,8 +89,17 @@ TasEditorWindow::TasEditorWindow(QWidget *parent)
|
|||
QMenuBar *menuBar;
|
||||
|
||||
tasWin = this;
|
||||
::project = &this->project;
|
||||
::taseditorConfig = &this->taseditorConfig;
|
||||
::taseditor_lua = &this->taseditor_lua;
|
||||
::markersManager = &this->markersManager;
|
||||
::selection = &this->selection;
|
||||
::greenzone = &this->greenzone;
|
||||
::bookmarks = &this->bookmarks;
|
||||
::playback = &this->playback;
|
||||
::recorder = &this->recorder;
|
||||
::history = &this->history;
|
||||
::branches = &this->branches;
|
||||
::splicer = &this->splicer;
|
||||
|
||||
setWindowTitle("TAS Editor");
|
||||
|
|
|
@ -31,16 +31,17 @@
|
|||
#include <QFont>
|
||||
|
||||
#include "Qt/TasEditor/taseditor_config.h"
|
||||
//#include "Qt/TasEditor/greenzone.h"
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/greenzone.h"
|
||||
#include "Qt/TasEditor/selection.h"
|
||||
#include "Qt/TasEditor/markers_manager.h"
|
||||
//#include "Qt/TasEditor/snapshot.h"
|
||||
//#include "Qt/TasEditor/bookmarks.h"
|
||||
//#include "Qt/TasEditor/branches.h"
|
||||
//#include "Qt/TasEditor/history.h"
|
||||
//#include "Qt/TasEditor/playback.h"
|
||||
#include "Qt/TasEditor/snapshot.h"
|
||||
#include "Qt/TasEditor/bookmarks.h"
|
||||
#include "Qt/TasEditor/branches.h"
|
||||
#include "Qt/TasEditor/history.h"
|
||||
#include "Qt/TasEditor/playback.h"
|
||||
#include "Qt/TasEditor/recorder.h"
|
||||
//#include "Qt/TasEditor/taseditor_lua.h"
|
||||
#include "Qt/TasEditor/taseditor_lua.h"
|
||||
#include "Qt/TasEditor/splicer.h"
|
||||
//#include "Qt/TasEditor/editor.h"
|
||||
//#include "Qt/TasEditor/popup_display.h"
|
||||
|
@ -89,12 +90,20 @@ class TasEditorWindow : public QDialog
|
|||
|
||||
QPianoRoll *pianoRoll;
|
||||
|
||||
TASEDITOR_PROJECT project;
|
||||
TASEDITOR_CONFIG taseditorConfig;
|
||||
TASEDITOR_LUA taseditor_lua;
|
||||
MARKERS_MANAGER markersManager;
|
||||
BOOKMARKS bookmarks;
|
||||
//PIANO_ROLL pianoRoll;
|
||||
SPLICER splicer;
|
||||
//EDITOR editor;
|
||||
//GREENZONE greenzone;
|
||||
GREENZONE greenzone;
|
||||
SELECTION selection;
|
||||
PLAYBACK playback;
|
||||
RECORDER recorder;
|
||||
HISTORY history;
|
||||
BRANCHES branches;
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
|
@ -162,9 +171,18 @@ class TasEditorWindow : public QDialog
|
|||
private slots:
|
||||
};
|
||||
|
||||
extern TASEDITOR_PROJECT *project;
|
||||
extern TASEDITOR_CONFIG *taseditorConfig;
|
||||
extern TASEDITOR_LUA *taseditor_lua;
|
||||
extern MARKERS_MANAGER *markersManager;
|
||||
extern BOOKMARKS *bookmarks;
|
||||
extern GREENZONE *greenzone;
|
||||
extern PLAYBACK *playback;
|
||||
extern RECORDER *recorder;
|
||||
extern SPLICER *splicer;
|
||||
extern HISTORY *history;
|
||||
extern SELECTION *selection;
|
||||
extern BRANCHES *branches;
|
||||
|
||||
bool tasWindowIsOpen(void);
|
||||
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
/* ---------------------------------------------------------------------------------
|
||||
Implementation file of Bookmark class
|
||||
Copyright (c) 2011-2013 AnS
|
||||
|
||||
(The MIT License)
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------------
|
||||
Bookmark - Single Bookmark data
|
||||
|
||||
* stores all info of one specific Bookmark: movie snapshot, a savestate of 1 frame, a screenshot of the frame, a state of flashing for this Bookmark's row
|
||||
* saves and loads the data from a project file. On error: sends warning to caller
|
||||
* implements procedure of "Bookmark set": creating movie snapshot, setting key frame on current Playback position, copying savestate from Greenzone, making and compressing screenshot, launching flashing animation
|
||||
* launches respective flashings for "Bookmark jump" and "Branch deploy"
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
//extern TASEDITOR_CONFIG taseditorConfig;
|
||||
//extern GREENZONE greenzone;
|
||||
//extern HISTORY history;
|
||||
|
||||
extern uint8 *XBuf;
|
||||
extern uint8 *XBackBuf;
|
||||
|
||||
BOOKMARK::BOOKMARK()
|
||||
{
|
||||
notEmpty = false;
|
||||
}
|
||||
|
||||
void BOOKMARK::init()
|
||||
{
|
||||
free();
|
||||
}
|
||||
void BOOKMARK::free()
|
||||
{
|
||||
notEmpty = false;
|
||||
flashType = flashPhase = floatingPhase = 0;
|
||||
SNAPSHOT tmp;
|
||||
snapshot = tmp;
|
||||
savestate.resize(0);
|
||||
savedScreenshot.resize(0);
|
||||
}
|
||||
|
||||
bool BOOKMARK::isDifferentFromCurrentMovie()
|
||||
{
|
||||
// check if the Bookmark data differs from current project/MovieData/Markers/settings
|
||||
if (notEmpty && snapshot.keyFrame == currFrameCounter)
|
||||
{
|
||||
if (snapshot.inputlog.size == currMovieData.getNumRecords() && snapshot.inputlog.findFirstChange(currMovieData) < 0)
|
||||
{
|
||||
if (!snapshot.areMarkersDifferentFromCurrentMarkers())
|
||||
{
|
||||
if (snapshot.inputlog.hasHotChanges == taseditorConfig->enableHotChanges)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BOOKMARK::set()
|
||||
{
|
||||
// copy Input and Hotchanges
|
||||
snapshot.init(currMovieData, greenzone->lagLog, taseditorConfig->enableHotChanges);
|
||||
snapshot.keyFrame = currFrameCounter;
|
||||
if (taseditorConfig->enableHotChanges)
|
||||
snapshot.inputlog.copyHotChanges(&history->getCurrentSnapshot().inputlog);
|
||||
// copy savestate
|
||||
savestate = greenzone->getSavestateOfFrame(currFrameCounter);
|
||||
// save screenshot
|
||||
uLongf comprlen = (SCREENSHOT_SIZE>>9)+12 + SCREENSHOT_SIZE;
|
||||
savedScreenshot.resize(comprlen);
|
||||
// compress screenshot data
|
||||
if (taseditorConfig->HUDInBranchScreenshots)
|
||||
compress(&savedScreenshot[0], &comprlen, XBuf, SCREENSHOT_SIZE);
|
||||
else
|
||||
compress(&savedScreenshot[0], &comprlen, XBackBuf, SCREENSHOT_SIZE);
|
||||
savedScreenshot.resize(comprlen);
|
||||
|
||||
notEmpty = true;
|
||||
flashPhase = FLASH_PHASE_MAX;
|
||||
flashType = FLASH_TYPE_SET;
|
||||
}
|
||||
|
||||
void BOOKMARK::handleJump()
|
||||
{
|
||||
flashPhase = FLASH_PHASE_MAX;
|
||||
flashType = FLASH_TYPE_JUMP;
|
||||
}
|
||||
|
||||
void BOOKMARK::handleDeploy()
|
||||
{
|
||||
flashPhase = FLASH_PHASE_MAX;
|
||||
flashType = FLASH_TYPE_DEPLOY;
|
||||
}
|
||||
|
||||
void BOOKMARK::save(EMUFILE *os)
|
||||
{
|
||||
if (notEmpty)
|
||||
{
|
||||
write8le(1, os);
|
||||
// write snapshot
|
||||
snapshot.save(os);
|
||||
// write savestate
|
||||
int size = savestate.size();
|
||||
write32le(size, os);
|
||||
os->fwrite(&savestate[0], size);
|
||||
// write saved_screenshot
|
||||
size = savedScreenshot.size();
|
||||
write32le(size, os);
|
||||
os->fwrite(&savedScreenshot[0], size);
|
||||
} else write8le((uint8)0, os);
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool BOOKMARK::load(EMUFILE *is)
|
||||
{
|
||||
uint8 tmp;
|
||||
if (!read8le(&tmp, is)) return true;
|
||||
notEmpty = (tmp != 0);
|
||||
if (notEmpty)
|
||||
{
|
||||
// read snapshot
|
||||
if (snapshot.load(is)) return true;
|
||||
// read savestate
|
||||
int size;
|
||||
if (!read32le(&size, is)) return true;
|
||||
savestate.resize(size);
|
||||
if ((int)is->fread(&savestate[0], size) < size) return true;
|
||||
// read saved_screenshot
|
||||
if (!read32le(&size, is)) return true;
|
||||
savedScreenshot.resize(size);
|
||||
if ((int)is->fread(&savedScreenshot[0], size) < size) return true;
|
||||
} else
|
||||
{
|
||||
free();
|
||||
}
|
||||
// all ok - reset vars
|
||||
flashType = flashPhase = floatingPhase = 0;
|
||||
return false;
|
||||
}
|
||||
bool BOOKMARK::skipLoad(EMUFILE *is)
|
||||
{
|
||||
uint8 tmp;
|
||||
if (!read8le(&tmp, is)) return true;
|
||||
if (tmp != 0)
|
||||
{
|
||||
// read snapshot
|
||||
if (snapshot.skipLoad(is)) return true;
|
||||
// read savestate
|
||||
int size;
|
||||
if (!read32le(&size, is)) return true;
|
||||
if (is->fseek(size, SEEK_CUR)) return true;
|
||||
// read saved_screenshot
|
||||
if (!read32le(&size, is)) return true;
|
||||
if (is->fseek(size, SEEK_CUR)) return true;
|
||||
}
|
||||
// all ok
|
||||
return false;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
// Specification file for Bookmark class
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include "Qt/TasEditor/snapshot.h"
|
||||
|
||||
#define FLASH_PHASE_MAX 11
|
||||
#define FLASH_PHASE_BUTTONHELD 6
|
||||
|
||||
enum FLASH_TYPES
|
||||
{
|
||||
FLASH_TYPE_SET = 0,
|
||||
FLASH_TYPE_JUMP = 1,
|
||||
FLASH_TYPE_DEPLOY = 2,
|
||||
};
|
||||
|
||||
#define SCREENSHOT_WIDTH 256
|
||||
#define SCREENSHOT_HEIGHT 240
|
||||
#define SCREENSHOT_SIZE SCREENSHOT_WIDTH * SCREENSHOT_HEIGHT
|
||||
|
||||
class BOOKMARK
|
||||
{
|
||||
public:
|
||||
BOOKMARK();
|
||||
void init();
|
||||
void free();
|
||||
|
||||
bool isDifferentFromCurrentMovie();
|
||||
|
||||
void set();
|
||||
void handleJump();
|
||||
void handleDeploy();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
bool load(EMUFILE *is);
|
||||
bool skipLoad(EMUFILE *is);
|
||||
|
||||
// saved vars
|
||||
bool notEmpty;
|
||||
SNAPSHOT snapshot;
|
||||
std::vector<uint8_t> savestate;
|
||||
std::vector<uint8_t> savedScreenshot;
|
||||
|
||||
// not saved vars
|
||||
int flashPhase;
|
||||
int flashType;
|
||||
int floatingPhase;
|
||||
|
||||
private:
|
||||
|
||||
};
|
|
@ -0,0 +1,885 @@
|
|||
/* ---------------------------------------------------------------------------------
|
||||
Implementation file of Bookmarks class
|
||||
Copyright (c) 2011-2013 AnS
|
||||
|
||||
(The MIT License)
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------------
|
||||
Bookmarks/Branches - Manager of Bookmarks
|
||||
[Single instance]
|
||||
|
||||
* stores 10 Bookmarks
|
||||
* implements all operations with Bookmarks: initialization, setting Bookmarks, jumping to Bookmarks, deploying Branches
|
||||
* saves and loads the data from a project file. On error: resets all Bookmarks and Branches
|
||||
* implements the working of Bookmarks List: creating, redrawing, mouseover, clicks
|
||||
* regularly updates flashings in Bookmarks List
|
||||
* on demand: updates colors of rows in Bookmarks List, reflecting conditions of respective Piano Roll rows
|
||||
* stores resources: save id, ids of commands, captions for panel, gradients for flashings, id of default slot
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include <zlib.h>
|
||||
#include "utils/xstring.h"
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
//#pragma comment(lib, "msimg32.lib")
|
||||
|
||||
//LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
//WNDPROC hwndBookmarksList_oldWndProc;
|
||||
|
||||
//extern TASEDITOR_CONFIG taseditorConfig;
|
||||
//extern TASEDITOR_WINDOW taseditorWindow;
|
||||
//extern POPUP_DISPLAY popupDisplay;
|
||||
//extern PLAYBACK playback;
|
||||
//extern RECORDER recorder;
|
||||
//extern SELECTION selection;
|
||||
//extern GREENZONE greenzone;
|
||||
//extern TASEDITOR_PROJECT project;
|
||||
//extern HISTORY history;
|
||||
//extern PIANO_ROLL pianoRoll;
|
||||
//extern MARKERS_MANAGER markersManager;
|
||||
//extern BRANCHES branches;
|
||||
|
||||
// resources
|
||||
char bookmarks_save_id[BOOKMARKS_ID_LEN] = "BOOKMARKS";
|
||||
char bookmarks_skipsave_id[BOOKMARKS_ID_LEN] = "BOOKMARKX";
|
||||
char bookmarksCaption[3][23] = { " Bookmarks ", " Bookmarks / Branches ", " Branches " };
|
||||
// color tables for flashing when saving/loading bookmarks
|
||||
//COLORREF bookmark_flash_colors[TOTAL_BOOKMARK_COMMANDS][FLASH_PHASE_MAX+1] = {
|
||||
// // set
|
||||
// //0x122330, 0x1b3541, 0x254753, 0x2e5964, 0x376b75, 0x417e87, 0x4a8f97, 0x53a1a8, 0x5db3b9, 0x66c5cb, 0x70d7dc, 0x79e9ed,
|
||||
// 0x0d1241, 0x111853, 0x161e64, 0x1a2575, 0x1f2b87, 0x233197, 0x2837a8, 0x2c3db9, 0x3144cb, 0x354adc, 0x3a50ed, 0x3f57ff,
|
||||
// // jump
|
||||
// 0x14350f, 0x1c480f, 0x235a0f, 0x2a6c0f, 0x317f10, 0x38910f, 0x3fa30f, 0x46b50f, 0x4dc80f, 0x54da0f, 0x5bec0f, 0x63ff10,
|
||||
// // deploy
|
||||
// 0x43171d, 0x541d21, 0x652325, 0x762929, 0x872f2c, 0x983530, 0xa93b34, 0xba4137, 0xcb463b, 0xdc4c3f, 0xed5243, 0xff5947 };
|
||||
|
||||
BOOKMARKS::BOOKMARKS()
|
||||
{
|
||||
// fill TrackMouseEvent struct
|
||||
//tme.cbSize = sizeof(tme);
|
||||
//tme.dwFlags = TME_LEAVE;
|
||||
//tme.hwndTrack = NULL;
|
||||
//tmeList.cbSize = sizeof(tme);
|
||||
//tmeList.dwFlags = TME_LEAVE;
|
||||
//tmeList.hwndTrack = NULL;
|
||||
}
|
||||
|
||||
void BOOKMARKS::init()
|
||||
{
|
||||
free();
|
||||
// hwndBookmarksList = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKSLIST);
|
||||
// hwndBranchesBitmap = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BRANCHES_BITMAP);
|
||||
// hwndBookmarks = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKS_BOX);
|
||||
//
|
||||
// // set a font which is overridden elsewhere and so really only used to calculate the row size
|
||||
// SendMessage(hwndBookmarksList, WM_SETFONT, (WPARAM)pianoRoll.hItemMeasurementFont, 0);
|
||||
// // prepare bookmarks listview
|
||||
// ListView_SetExtendedListViewStyleEx(hwndBookmarksList, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
|
||||
// // subclass the listview
|
||||
// hwndBookmarksList_oldWndProc = (WNDPROC)SetWindowLongPtr(hwndBookmarksList, GWLP_WNDPROC, (LONG_PTR)BookmarksListWndProc);
|
||||
// // setup images for the listview
|
||||
// hImgList = ImageList_Create(11, 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_BITMAP_SELECTED0));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED1));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED2));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED3));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED4));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED5));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED6));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED7));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED8));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED9));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED10));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED11));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED12));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED13));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED14));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED15));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED16));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED17));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED18));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED19));
|
||||
// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF);
|
||||
// DeleteObject(bmp);
|
||||
// ListView_SetImageList(hwndBookmarksList, hImgList, LVSIL_SMALL);
|
||||
// // setup columns
|
||||
// LVCOLUMN lvc;
|
||||
// // icons column
|
||||
// lvc.mask = LVCF_WIDTH;
|
||||
// lvc.cx = BOOKMARKSLIST_COLUMN_ICONS_WIDTH;
|
||||
// ListView_InsertColumn(hwndBookmarksList, 0, &lvc);
|
||||
// // keyframe column
|
||||
// lvc.mask = LVCF_WIDTH | LVCF_FMT;
|
||||
// lvc.fmt = LVCFMT_CENTER;
|
||||
// lvc.cx = BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH;
|
||||
// ListView_InsertColumn(hwndBookmarksList, 1, &lvc);
|
||||
// // time column
|
||||
// lvc.cx = BOOKMARKSLIST_COLUMN_TIMESTAMP_WIDTH;
|
||||
// ListView_InsertColumn(hwndBookmarksList, 2, &lvc);
|
||||
// // create 10 rows
|
||||
// ListView_SetItemCountEx(hwndBookmarksList, TOTAL_BOOKMARKS, LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL);
|
||||
|
||||
reset();
|
||||
selectedSlot = DEFAULT_SLOT;
|
||||
// find the top/height of the "Time" cell of the 1st row (for mouseover hittest calculations)
|
||||
//RECT temp_rect, wrect;
|
||||
//if (ListView_GetSubItemRect(hwndBookmarksList, 0, 2, LVIR_BOUNDS, &temp_rect) && temp_rect.bottom != temp_rect.top)
|
||||
//{
|
||||
// listTopMargin = temp_rect.top;
|
||||
// listRowLeft = temp_rect.left;
|
||||
// listRowHeight = temp_rect.bottom - temp_rect.top;
|
||||
//} else
|
||||
//{
|
||||
// // couldn't get rect, set default values
|
||||
// listTopMargin = 0;
|
||||
// listRowLeft = BOOKMARKSLIST_COLUMN_ICONS_WIDTH + BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH;
|
||||
// listRowHeight = 14;
|
||||
//}
|
||||
// calculate the needed height of client area (so that all 10 rows fir the screen)
|
||||
//int total_list_height = listTopMargin + listRowHeight * TOTAL_BOOKMARKS;
|
||||
// find the difference between Bookmarks List window and Bookmarks List client area
|
||||
//GetWindowRect(hwndBookmarksList, &wrect);
|
||||
//GetClientRect(hwndBookmarksList, &temp_rect);
|
||||
//total_list_height += (wrect.bottom - wrect.top) - (temp_rect.bottom - temp_rect.top);
|
||||
// change the height
|
||||
//taseditorWindow.changeBookmarksListHeight(total_list_height);
|
||||
|
||||
redrawBookmarksSectionCaption();
|
||||
}
|
||||
void BOOKMARKS::free()
|
||||
{
|
||||
bookmarksArray.resize(0);
|
||||
//if (hImgList)
|
||||
//{
|
||||
// ImageList_Destroy(hImgList);
|
||||
// hImgList = 0;
|
||||
//}
|
||||
}
|
||||
void BOOKMARKS::reset()
|
||||
{
|
||||
// delete all commands if there are any
|
||||
commands.resize(0);
|
||||
// init bookmarks
|
||||
bookmarksArray.resize(0);
|
||||
bookmarksArray.resize(TOTAL_BOOKMARKS);
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
{
|
||||
bookmarksArray[i].init();
|
||||
}
|
||||
reset_vars();
|
||||
}
|
||||
void BOOKMARKS::reset_vars()
|
||||
{
|
||||
mouseX = mouseY = -1;
|
||||
itemUnderMouse = ITEM_UNDER_MOUSE_NONE;
|
||||
mouseOverBranchesBitmap = false;
|
||||
mustCheckItemUnderMouse = true;
|
||||
bookmarkLeftclicked = bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE;
|
||||
nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK;
|
||||
}
|
||||
|
||||
void BOOKMARKS::update()
|
||||
{
|
||||
// execute all commands accumulated during last frame
|
||||
for (int i = 0; (i + 1) < (int)commands.size(); ) // FIFO
|
||||
{
|
||||
int command_id = commands[i++];
|
||||
int slot = commands[i++];
|
||||
switch (command_id)
|
||||
{
|
||||
case COMMAND_SET:
|
||||
set(slot);
|
||||
break;
|
||||
case COMMAND_JUMP:
|
||||
jump(slot);
|
||||
break;
|
||||
case COMMAND_DEPLOY:
|
||||
deploy(slot);
|
||||
break;
|
||||
case COMMAND_SELECT:
|
||||
if (selectedSlot != slot)
|
||||
{
|
||||
int old_selected_slot = selectedSlot;
|
||||
selectedSlot = slot;
|
||||
redrawBookmark(old_selected_slot);
|
||||
redrawBookmark(selectedSlot);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
commands.resize(0);
|
||||
|
||||
// once per 100 milliseconds update bookmark flashes
|
||||
if (clock() > nextFlashUpdateTime)
|
||||
{
|
||||
nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK;
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
{
|
||||
if (bookmarkRightclicked == i || bookmarkLeftclicked == i)
|
||||
{
|
||||
if (bookmarksArray[i].flashPhase != FLASH_PHASE_BUTTONHELD)
|
||||
{
|
||||
bookmarksArray[i].flashPhase = FLASH_PHASE_BUTTONHELD;
|
||||
redrawBookmark(i);
|
||||
branches->mustRedrawBranchesBitmap = true; // because border of branch digit has changed
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (bookmarksArray[i].flashPhase > 0)
|
||||
{
|
||||
bookmarksArray[i].flashPhase--;
|
||||
redrawBookmark(i);
|
||||
branches->mustRedrawBranchesBitmap = true; // because border of branch digit has changed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// controls
|
||||
if (mustCheckItemUnderMouse)
|
||||
{
|
||||
if (editMode == EDIT_MODE_BRANCHES)
|
||||
itemUnderMouse = branches->findItemUnderMouse(mouseX, mouseY);
|
||||
else if (editMode == EDIT_MODE_BOTH)
|
||||
itemUnderMouse = findItemUnderMouse();
|
||||
else
|
||||
itemUnderMouse = ITEM_UNDER_MOUSE_NONE;
|
||||
mustCheckItemUnderMouse = false;
|
||||
}
|
||||
}
|
||||
|
||||
// stores commands in array for update() function
|
||||
void BOOKMARKS::command(int command_id, int slot)
|
||||
{
|
||||
if (slot < 0)
|
||||
slot = selectedSlot;
|
||||
if (slot >= 0 && slot < TOTAL_BOOKMARKS)
|
||||
{
|
||||
commands.push_back(command_id);
|
||||
commands.push_back(slot);
|
||||
}
|
||||
}
|
||||
|
||||
void BOOKMARKS::set(int slot)
|
||||
{
|
||||
if (slot < 0 || slot >= TOTAL_BOOKMARKS) return;
|
||||
|
||||
// First save changes in edited note (in case it's being currently edited)
|
||||
markersManager->updateEditedMarkerNote();
|
||||
|
||||
int previous_frame = bookmarksArray[slot].snapshot.keyFrame;
|
||||
if (bookmarksArray[slot].isDifferentFromCurrentMovie())
|
||||
{
|
||||
BOOKMARK backup_copy(bookmarksArray[slot]);
|
||||
bookmarksArray[slot].set();
|
||||
// rebuild Branches Tree
|
||||
int old_current_branch = branches->getCurrentBranch();
|
||||
branches->handleBookmarkSet(slot);
|
||||
if (slot != old_current_branch && old_current_branch != ITEM_UNDER_MOUSE_CLOUD)
|
||||
{
|
||||
// current_branch was switched to slot, redraw Bookmarks List to change the color of digits
|
||||
//pianoRoll.redrawRow(bookmarksArray[old_current_branch].snapshot.keyFrame);
|
||||
redrawChangedBookmarks(bookmarksArray[old_current_branch].snapshot.keyFrame);
|
||||
}
|
||||
// also redraw List rows
|
||||
if (previous_frame >= 0 && previous_frame != currFrameCounter)
|
||||
{
|
||||
//pianoRoll.redrawRow(previous_frame);
|
||||
redrawChangedBookmarks(previous_frame);
|
||||
}
|
||||
//pianoRoll.redrawRow(currFrameCounter);
|
||||
redrawChangedBookmarks(currFrameCounter);
|
||||
// if screenshot of the slot is currently shown - reinit and redraw the picture
|
||||
//if (popupDisplay.currentlyDisplayedBookmark == slot)
|
||||
//{
|
||||
// popupDisplay.currentlyDisplayedBookmark = ITEM_UNDER_MOUSE_NONE;
|
||||
//}
|
||||
|
||||
history->registerBookmarkSet(slot, backup_copy, old_current_branch);
|
||||
mustCheckItemUnderMouse = true;
|
||||
FCEU_DispMessage("Branch %d saved.", 0, slot);
|
||||
}
|
||||
}
|
||||
|
||||
void BOOKMARKS::jump(int slot)
|
||||
{
|
||||
if (slot < 0 || slot >= TOTAL_BOOKMARKS) return;
|
||||
if (bookmarksArray[slot].notEmpty)
|
||||
{
|
||||
int frame = bookmarksArray[slot].snapshot.keyFrame;
|
||||
playback->jump(frame);
|
||||
bookmarksArray[slot].handleJump();
|
||||
}
|
||||
}
|
||||
|
||||
void BOOKMARKS::deploy(int slot)
|
||||
{
|
||||
recorder->stateWasLoadedInReadWriteMode = true;
|
||||
if (taseditorConfig->oldControlSchemeForBranching && movie_readonly)
|
||||
{
|
||||
jump(slot);
|
||||
return;
|
||||
}
|
||||
if (slot < 0 || slot >= TOTAL_BOOKMARKS) return;
|
||||
if (!bookmarksArray[slot].notEmpty) return;
|
||||
|
||||
int keyframe = bookmarksArray[slot].snapshot.keyFrame;
|
||||
bool markers_changed = false;
|
||||
// revert Markers to the Bookmarked state
|
||||
if (bookmarksArray[slot].snapshot.areMarkersDifferentFromCurrentMarkers())
|
||||
{
|
||||
bookmarksArray[slot].snapshot.copyToCurrentMarkers();
|
||||
markers_changed = true;
|
||||
}
|
||||
// revert current movie data to the Bookmarked state
|
||||
if (taseditorConfig->branchesRestoreEntireMovie)
|
||||
{
|
||||
bookmarksArray[slot].snapshot.inputlog.toMovie(currMovieData);
|
||||
} else
|
||||
{
|
||||
// restore movie up to and not including bookmarked frame (simulating old TASing method)
|
||||
if (keyframe)
|
||||
bookmarksArray[slot].snapshot.inputlog.toMovie(currMovieData, 0, keyframe - 1);
|
||||
else
|
||||
currMovieData.truncateAt(0);
|
||||
// add empty frame at the end (at keyframe)
|
||||
currMovieData.insertEmpty(-1, 1);
|
||||
}
|
||||
|
||||
int first_change = history->registerBranching(slot, markers_changed); // this also reverts Greenzone's LagLog if needed
|
||||
if (first_change >= 0)
|
||||
{
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
//pianoRoll.updateLinesCount();
|
||||
greenzone->invalidate(first_change);
|
||||
bookmarksArray[slot].handleDeploy();
|
||||
} else if (markers_changed)
|
||||
{
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
bookmarksArray[slot].handleDeploy();
|
||||
} else
|
||||
{
|
||||
// didn't change anything in current movie
|
||||
bookmarksArray[slot].handleJump();
|
||||
}
|
||||
|
||||
// jump to the target (bookmarked frame)
|
||||
if (greenzone->isSavestateEmpty(keyframe))
|
||||
{
|
||||
greenzone->writeSavestateForFrame(keyframe, bookmarksArray[slot].savestate);
|
||||
}
|
||||
playback->jump(keyframe, true);
|
||||
// switch current branch to this branch
|
||||
int old_current_branch = branches->getCurrentBranch();
|
||||
branches->handleBookmarkDeploy(slot);
|
||||
if (slot != old_current_branch && old_current_branch != ITEM_UNDER_MOUSE_CLOUD)
|
||||
{
|
||||
//pianoRoll.redrawRow(bookmarksArray[old_current_branch].snapshot.keyFrame);
|
||||
redrawChangedBookmarks(bookmarksArray[old_current_branch].snapshot.keyFrame);
|
||||
//pianoRoll.redrawRow(keyframe);
|
||||
redrawChangedBookmarks(keyframe);
|
||||
}
|
||||
FCEU_DispMessage("Branch %d loaded.", 0, slot);
|
||||
//pianoRoll.redraw(); // even though the Greenzone invalidation most likely have already sent the command to redraw
|
||||
}
|
||||
|
||||
void BOOKMARKS::save(EMUFILE *os, bool really_save)
|
||||
{
|
||||
if (really_save)
|
||||
{
|
||||
// write "BOOKMARKS" string
|
||||
os->fwrite(bookmarks_save_id, BOOKMARKS_ID_LEN);
|
||||
// write all 10 bookmarks
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
bookmarksArray[i].save(os);
|
||||
// write branches
|
||||
branches->save(os);
|
||||
} else
|
||||
{
|
||||
// write "BOOKMARKX" string
|
||||
os->fwrite(bookmarks_skipsave_id, BOOKMARKS_ID_LEN);
|
||||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool BOOKMARKS::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
if (offset)
|
||||
{
|
||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||
} else
|
||||
{
|
||||
reset();
|
||||
branches->reset();
|
||||
return false;
|
||||
}
|
||||
// read "BOOKMARKS" string
|
||||
char save_id[BOOKMARKS_ID_LEN];
|
||||
if ((int)is->fread(save_id, BOOKMARKS_ID_LEN) < BOOKMARKS_ID_LEN) goto error;
|
||||
if (!strcmp(bookmarks_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading Bookmarks
|
||||
FCEU_printf("No Bookmarks in the file\n");
|
||||
reset();
|
||||
branches->reset();
|
||||
return false;
|
||||
}
|
||||
if (strcmp(bookmarks_save_id, save_id)) goto error; // string is not valid
|
||||
// read all 10 bookmarks
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
if (bookmarksArray[i].load(is)) goto error;
|
||||
// read branches
|
||||
if (branches->load(is)) goto error;
|
||||
// all ok
|
||||
reset_vars();
|
||||
redrawBookmarksSectionCaption();
|
||||
return false;
|
||||
error:
|
||||
FCEU_printf("Error loading Bookmarks\n");
|
||||
reset();
|
||||
branches->reset();
|
||||
return true;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
void BOOKMARKS::redrawBookmarksSectionCaption()
|
||||
{
|
||||
int prev_edit_mode = editMode;
|
||||
if (taseditorConfig->displayBranchesTree)
|
||||
{
|
||||
editMode = EDIT_MODE_BRANCHES;
|
||||
//ShowWindow(hwndBookmarksList, SW_HIDE);
|
||||
//ShowWindow(hwndBranchesBitmap, SW_SHOW);
|
||||
} else if (taseditorConfig->oldControlSchemeForBranching && movie_readonly)
|
||||
{
|
||||
editMode = EDIT_MODE_BOOKMARKS;
|
||||
//ShowWindow(hwndBranchesBitmap, SW_HIDE);
|
||||
//ShowWindow(hwndBookmarksList, SW_SHOW);
|
||||
redrawBookmarksList();
|
||||
} else
|
||||
{
|
||||
editMode = EDIT_MODE_BOTH;
|
||||
//ShowWindow(hwndBranchesBitmap, SW_HIDE);
|
||||
//ShowWindow(hwndBookmarksList, SW_SHOW);
|
||||
redrawBookmarksList();
|
||||
}
|
||||
if (prev_edit_mode != editMode)
|
||||
mustCheckItemUnderMouse = true;
|
||||
//SetWindowText(hwndBookmarks, bookmarksCaption[editMode]);
|
||||
}
|
||||
void BOOKMARKS::redrawBookmarksList(bool eraseBG)
|
||||
{
|
||||
if (editMode != EDIT_MODE_BRANCHES)
|
||||
{
|
||||
//InvalidateRect(hwndBookmarksList, 0, eraseBG);
|
||||
}
|
||||
}
|
||||
void BOOKMARKS::redrawChangedBookmarks(int frame)
|
||||
{
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
{
|
||||
if (bookmarksArray[i].snapshot.keyFrame == frame)
|
||||
{
|
||||
redrawBookmark(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
void BOOKMARKS::redrawBookmark(int bookmarkNumber)
|
||||
{
|
||||
//redrawBookmarksListRow((bookmarkNumber + TOTAL_BOOKMARKS - 1) % TOTAL_BOOKMARKS);
|
||||
}
|
||||
void BOOKMARKS::redrawBookmarksListRow(int rowIndex)
|
||||
{
|
||||
//ListView_RedrawItems(hwndBookmarksList, rowIndex, rowIndex);
|
||||
}
|
||||
|
||||
void BOOKMARKS::handleMouseMove(int newX, int newY)
|
||||
{
|
||||
mouseX = newX;
|
||||
mouseY = newY;
|
||||
mustCheckItemUnderMouse = true;
|
||||
}
|
||||
int BOOKMARKS::findItemUnderMouse()
|
||||
{
|
||||
int item = ITEM_UNDER_MOUSE_NONE;
|
||||
// RECT wrect;
|
||||
// GetClientRect(hwndBookmarksList, &wrect);
|
||||
// if (mouseX >= listRowLeft && mouseX < wrect.right - wrect.left && mouseY >= listTopMargin && mouseY < wrect.bottom - wrect.top)
|
||||
// {
|
||||
// int row_under_mouse = (mouseY - listTopMargin) / listRowHeight;
|
||||
// if (row_under_mouse >= 0 && row_under_mouse < TOTAL_BOOKMARKS)
|
||||
// item = (row_under_mouse + 1) % TOTAL_BOOKMARKS;
|
||||
// }
|
||||
return item;
|
||||
}
|
||||
|
||||
int BOOKMARKS::getSelectedSlot()
|
||||
{
|
||||
return selectedSlot;
|
||||
}
|
||||
// ----------------------------------------------------------------------------------------
|
||||
//void BOOKMARKS::getDispInfo(NMLVDISPINFO* nmlvDispInfo)
|
||||
//{
|
||||
// LVITEM& item = nmlvDispInfo->item;
|
||||
// if (item.mask & LVIF_TEXT)
|
||||
// {
|
||||
// switch(item.iSubItem)
|
||||
// {
|
||||
// case BOOKMARKSLIST_COLUMN_ICON:
|
||||
// {
|
||||
// if ((item.iItem + 1) % TOTAL_BOOKMARKS == branches->getCurrentBranch())
|
||||
// item.iImage = ((item.iItem + 1) % TOTAL_BOOKMARKS) + TOTAL_BOOKMARKS;
|
||||
// else
|
||||
// item.iImage = (item.iItem + 1) % TOTAL_BOOKMARKS;
|
||||
// if (taseditorConfig->oldControlSchemeForBranching)
|
||||
// {
|
||||
// if ((item.iItem + 1) % TOTAL_BOOKMARKS == selectedSlot)
|
||||
// item.iImage += BOOKMARKS_BITMAPS_SELECTED;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case BOOKMARKSLIST_COLUMN_FRAME:
|
||||
// {
|
||||
// if (bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].notEmpty)
|
||||
// U32ToDecStr(item.pszText, bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.keyFrame, DIGITS_IN_FRAMENUM);
|
||||
// break;
|
||||
// }
|
||||
// case BOOKMARKSLIST_COLUMN_TIME:
|
||||
// {
|
||||
// if (bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].notEmpty)
|
||||
// strcpy(item.pszText, bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.description);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//LONG BOOKMARKS::handleCustomDraw(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 + 1) % TOTAL_BOOKMARKS;
|
||||
//
|
||||
// // flash with text color when needed
|
||||
// if (bookmarksArray[cell_y].flashPhase)
|
||||
// msg->clrText = bookmark_flash_colors[bookmarksArray[cell_y].flashType][bookmarksArray[cell_y].flashPhase];
|
||||
//
|
||||
// if (cell_x == BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig->oldControlSchemeForBranching && movie_readonly && cell_x == BOOKMARKSLIST_COLUMN_TIME))
|
||||
// {
|
||||
// if (bookmarksArray[cell_y].notEmpty)
|
||||
// {
|
||||
// // frame number
|
||||
// SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont);
|
||||
// int frame = bookmarksArray[cell_y].snapshot.keyFrame;
|
||||
// if (frame == currFrameCounter || frame == (playback->getFlashingPauseFrame() - 1))
|
||||
// {
|
||||
// // current frame
|
||||
// msg->clrTextBk = CUR_FRAMENUM_COLOR;
|
||||
// } else if (frame < greenzone->getSize())
|
||||
// {
|
||||
// if (!greenzone->isSavestateEmpty(frame))
|
||||
// {
|
||||
// if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
|
||||
// msg->clrTextBk = LAG_FRAMENUM_COLOR;
|
||||
// else
|
||||
// msg->clrTextBk = GREENZONE_FRAMENUM_COLOR;
|
||||
// } else if (!greenzone->isSavestateEmpty(cell_y & EVERY16TH)
|
||||
// || !greenzone->isSavestateEmpty(cell_y & EVERY8TH)
|
||||
// || !greenzone->isSavestateEmpty(cell_y & EVERY4TH)
|
||||
// || !greenzone->isSavestateEmpty(cell_y & EVERY2ND))
|
||||
// {
|
||||
// if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
|
||||
// msg->clrTextBk = PALE_LAG_FRAMENUM_COLOR;
|
||||
// else
|
||||
// msg->clrTextBk = PALE_GREENZONE_FRAMENUM_COLOR;
|
||||
// } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR;
|
||||
// } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR;
|
||||
// } else msg->clrTextBk = NORMAL_BACKGROUND_COLOR; // empty bookmark
|
||||
// } else if (cell_x == BOOKMARKSLIST_COLUMN_TIME)
|
||||
// {
|
||||
// if (bookmarksArray[cell_y].notEmpty)
|
||||
// {
|
||||
// // frame number
|
||||
// SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont);
|
||||
// int frame = bookmarksArray[cell_y].snapshot.keyFrame;
|
||||
// if (frame == currFrameCounter || frame == (playback->getFlashingPauseFrame() - 1))
|
||||
// {
|
||||
// // current frame
|
||||
// msg->clrTextBk = CUR_INPUT_COLOR1;
|
||||
// } else if (frame < greenzone->getSize())
|
||||
// {
|
||||
// if (!greenzone->isSavestateEmpty(frame))
|
||||
// {
|
||||
// if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
|
||||
// msg->clrTextBk = LAG_INPUT_COLOR1;
|
||||
// else
|
||||
// msg->clrTextBk = GREENZONE_INPUT_COLOR1;
|
||||
// } else if (!greenzone->isSavestateEmpty(cell_y & EVERY16TH)
|
||||
// || !greenzone->isSavestateEmpty(cell_y & EVERY8TH)
|
||||
// || !greenzone->isSavestateEmpty(cell_y & EVERY4TH)
|
||||
// || !greenzone->isSavestateEmpty(cell_y & EVERY2ND))
|
||||
// {
|
||||
// if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
|
||||
// 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 msg->clrTextBk = NORMAL_BACKGROUND_COLOR; // empty bookmark
|
||||
// }
|
||||
// default:
|
||||
// return CDRF_DODEFAULT;
|
||||
// }
|
||||
//}
|
||||
|
||||
void BOOKMARKS::handleLeftClick()
|
||||
{
|
||||
if (columnClicked <= BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig->oldControlSchemeForBranching && movie_readonly))
|
||||
command(COMMAND_JUMP, bookmarkLeftclicked);
|
||||
else if (columnClicked == BOOKMARKSLIST_COLUMN_TIME && (!taseditorConfig->oldControlSchemeForBranching || !movie_readonly))
|
||||
command(COMMAND_DEPLOY, bookmarkLeftclicked);
|
||||
}
|
||||
void BOOKMARKS::handleRightClick()
|
||||
{
|
||||
if (bookmarkRightclicked >= 0)
|
||||
command(COMMAND_SET, bookmarkRightclicked);
|
||||
}
|
||||
|
||||
int BOOKMARKS::findBookmarkAtFrame(int frame)
|
||||
{
|
||||
int cur_bookmark = branches->getCurrentBranch();
|
||||
if (cur_bookmark != ITEM_UNDER_MOUSE_CLOUD && bookmarksArray[cur_bookmark].snapshot.keyFrame == frame)
|
||||
return cur_bookmark + TOTAL_BOOKMARKS; // blue digit has highest priority when drawing
|
||||
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
|
||||
{
|
||||
cur_bookmark = (i + 1) % TOTAL_BOOKMARKS;
|
||||
if (bookmarksArray[cur_bookmark].notEmpty && bookmarksArray[cur_bookmark].snapshot.keyFrame == frame)
|
||||
return cur_bookmark; // green digit
|
||||
}
|
||||
return -1; // no Bookmarks at the frame
|
||||
}
|
||||
// ----------------------------------------------------------------------------------------
|
||||
//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.mouseOverBookmarksList)
|
||||
// {
|
||||
// bookmarks.mouseOverBookmarksList = true;
|
||||
// bookmarks.tmeList.hwndTrack = hWnd;
|
||||
// TrackMouseEvent(&bookmarks.tmeList);
|
||||
// }
|
||||
// bookmarks.handleMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
// break;
|
||||
// }
|
||||
// case WM_MOUSELEAVE:
|
||||
// {
|
||||
// bookmarks.mouseOverBookmarksList = false;
|
||||
// bookmarks.handleMouseMove(-1, -1);
|
||||
// break;
|
||||
// }
|
||||
// case WM_LBUTTONDOWN:
|
||||
// case WM_LBUTTONDBLCLK:
|
||||
// {
|
||||
// if (GetFocus() != hWnd)
|
||||
// SetFocus(hWnd);
|
||||
// LVHITTESTINFO info;
|
||||
// info.pt.x = GET_X_LPARAM(lParam);
|
||||
// info.pt.y = GET_Y_LPARAM(lParam);
|
||||
// ListView_SubItemHitTest(hWnd, (LPARAM)&info);
|
||||
// if (info.iItem >= 0 && bookmarks.bookmarkRightclicked < 0)
|
||||
// {
|
||||
// bookmarks.bookmarkLeftclicked = (info.iItem + 1) % TOTAL_BOOKMARKS;
|
||||
// bookmarks.columnClicked = info.iSubItem;
|
||||
// if (bookmarks.columnClicked <= BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig->oldControlSchemeForBranching && movie_readonly))
|
||||
// bookmarks.bookmarksArray[bookmarks.bookmarkLeftclicked].flashType = FLASH_TYPE_JUMP;
|
||||
// else if (bookmarks.columnClicked == BOOKMARKSLIST_COLUMN_TIME && (!taseditorConfig->oldControlSchemeForBranching || !movie_readonly))
|
||||
// bookmarks.bookmarksArray[bookmarks.bookmarkLeftclicked].flashType = FLASH_TYPE_DEPLOY;
|
||||
// SetCapture(hWnd);
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
// case WM_LBUTTONUP:
|
||||
// {
|
||||
// LVHITTESTINFO info;
|
||||
// info.pt.x = GET_X_LPARAM(lParam);
|
||||
// info.pt.y = GET_Y_LPARAM(lParam);
|
||||
// RECT wrect;
|
||||
// GetClientRect(hWnd, &wrect);
|
||||
// if (info.pt.x >= 0 && info.pt.x < wrect.right - wrect.left && info.pt.y >= 0 && info.pt.y < wrect.bottom - wrect.top)
|
||||
// {
|
||||
// ListView_SubItemHitTest(hWnd, (LPARAM)&info);
|
||||
// if (bookmarks.bookmarkLeftclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.columnClicked == info.iSubItem)
|
||||
// bookmarks.handleLeftClick();
|
||||
// }
|
||||
// ReleaseCapture();
|
||||
// bookmarks.bookmarkLeftclicked = -1;
|
||||
// return 0;
|
||||
// }
|
||||
// case WM_RBUTTONDOWN:
|
||||
// case WM_RBUTTONDBLCLK:
|
||||
// {
|
||||
// if (GetFocus() != hWnd)
|
||||
// SetFocus(hWnd);
|
||||
// LVHITTESTINFO info;
|
||||
// info.pt.x = GET_X_LPARAM(lParam);
|
||||
// info.pt.y = GET_Y_LPARAM(lParam);
|
||||
// ListView_SubItemHitTest(hWnd, (LPARAM)&info);
|
||||
// if (info.iItem >= 0 && bookmarks.bookmarkLeftclicked < 0)
|
||||
// {
|
||||
// bookmarks.bookmarkRightclicked = (info.iItem + 1) % TOTAL_BOOKMARKS;
|
||||
// bookmarks.columnClicked = info.iSubItem;
|
||||
// bookmarks.bookmarksArray[bookmarks.bookmarkRightclicked].flashType = FLASH_TYPE_SET;
|
||||
// SetCapture(hWnd);
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
// case WM_RBUTTONUP:
|
||||
// {
|
||||
// LVHITTESTINFO info;
|
||||
// info.pt.x = GET_X_LPARAM(lParam);
|
||||
// info.pt.y = GET_Y_LPARAM(lParam);
|
||||
// RECT wrect;
|
||||
// GetClientRect(hWnd, &wrect);
|
||||
// if (info.pt.x >= 0 && info.pt.x < wrect.right - wrect.left && info.pt.y >= 0 && info.pt.y < wrect.bottom - wrect.top)
|
||||
// {
|
||||
// ListView_SubItemHitTest(hWnd, (LPARAM)&info);
|
||||
// if (bookmarks.bookmarkRightclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.columnClicked == info.iSubItem)
|
||||
// bookmarks.handleRightClick();
|
||||
// }
|
||||
// ReleaseCapture();
|
||||
// bookmarks.bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE;
|
||||
// return 0;
|
||||
// }
|
||||
// case WM_MBUTTONDOWN:
|
||||
// case WM_MBUTTONDBLCLK:
|
||||
// {
|
||||
// if (GetFocus() != hWnd)
|
||||
// SetFocus(hWnd);
|
||||
// playback->handleMiddleButtonClick();
|
||||
// return 0;
|
||||
// }
|
||||
// case WM_MOUSEWHEEL:
|
||||
// {
|
||||
// bookmarks.bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE; // ensure that accidental rightclick on BookmarksList won't set Bookmarks when user does rightbutton + wheel
|
||||
// return SendMessage(pianoRoll.hwndList, msg, wParam, lParam);
|
||||
// }
|
||||
// }
|
||||
// return CallWindowProc(hwndBookmarksList_oldWndProc, hWnd, msg, wParam, lParam);
|
||||
//}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
// Specification file for Bookmarks class
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#include "fceu.h"
|
||||
#include "Qt/TasEditor/bookmark.h"
|
||||
|
||||
#define TOTAL_BOOKMARKS 10
|
||||
|
||||
enum BOOKMARKS_EDIT_MODES
|
||||
{
|
||||
EDIT_MODE_BOOKMARKS = 0,
|
||||
EDIT_MODE_BOTH = 1,
|
||||
EDIT_MODE_BRANCHES = 2,
|
||||
};
|
||||
|
||||
enum BOOKMARK_COMMANDS
|
||||
{
|
||||
COMMAND_SET = 0,
|
||||
COMMAND_JUMP = 1,
|
||||
COMMAND_DEPLOY = 2,
|
||||
COMMAND_SELECT = 3,
|
||||
COMMAND_DELETE = 4, // not implemented, probably useless
|
||||
|
||||
// ...
|
||||
TOTAL_BOOKMARK_COMMANDS
|
||||
};
|
||||
|
||||
#define BOOKMARKSLIST_COLUMN_ICONS_WIDTH 15
|
||||
#define BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH 74
|
||||
#define BOOKMARKSLIST_COLUMN_TIMESTAMP_WIDTH 80
|
||||
|
||||
#define BOOKMARKS_BITMAPS_SELECTED 20
|
||||
|
||||
#define ITEM_UNDER_MOUSE_NONE (-2)
|
||||
#define ITEM_UNDER_MOUSE_CLOUD (-1)
|
||||
#define ITEM_UNDER_MOUSE_FIREBALL (TOTAL_BOOKMARKS)
|
||||
|
||||
#define BOOKMARKS_FLASH_TICK 100 // in milliseconds
|
||||
|
||||
// listview columns
|
||||
enum
|
||||
{
|
||||
BOOKMARKSLIST_COLUMN_ICON = 0,
|
||||
BOOKMARKSLIST_COLUMN_FRAME = 1,
|
||||
BOOKMARKSLIST_COLUMN_TIME = 2,
|
||||
};
|
||||
|
||||
#define BOOKMARKS_ID_LEN 10
|
||||
#define TIMESTAMP_LENGTH 9 // "HH:MM:SS"
|
||||
|
||||
#define DEFAULT_SLOT 1
|
||||
|
||||
class BOOKMARKS
|
||||
{
|
||||
public:
|
||||
BOOKMARKS();
|
||||
void init();
|
||||
void free();
|
||||
void reset();
|
||||
void reset_vars();
|
||||
void update();
|
||||
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
|
||||
void command(int command_id, int slot = -1);
|
||||
|
||||
//void getDispInfo(NMLVDISPINFO* nmlvDispInfo);
|
||||
//LONG handleCustomDraw(NMLVCUSTOMDRAW* msg);
|
||||
void handleLeftClick();
|
||||
void handleRightClick();
|
||||
|
||||
int findBookmarkAtFrame(int frame);
|
||||
|
||||
void redrawBookmarksSectionCaption();
|
||||
void redrawBookmarksList(bool eraseBG = false);
|
||||
void redrawChangedBookmarks(int frame);
|
||||
void redrawBookmark(int bookmarkNumber);
|
||||
void redrawBookmarksListRow(int rowIndex);
|
||||
|
||||
void handleMouseMove(int newX, int newY);
|
||||
int findItemUnderMouse();
|
||||
|
||||
int getSelectedSlot();
|
||||
|
||||
// saved vars
|
||||
std::vector<BOOKMARK> bookmarksArray;
|
||||
|
||||
// not saved vars
|
||||
int editMode;
|
||||
bool mustCheckItemUnderMouse;
|
||||
bool mouseOverBranchesBitmap, mouseOverBookmarksList;
|
||||
int itemUnderMouse;
|
||||
//TRACKMOUSEEVENT tme, tmeList;
|
||||
int bookmarkLeftclicked, bookmarkRightclicked, columnClicked;
|
||||
int listTopMargin;
|
||||
int listRowLeft;
|
||||
int listRowHeight;
|
||||
|
||||
//HWND hwndBookmarksList, hwndBranchesBitmap, hwndBookmarks;
|
||||
|
||||
private:
|
||||
void set(int slot);
|
||||
void jump(int slot);
|
||||
void deploy(int slot);
|
||||
|
||||
// not saved vars
|
||||
std::vector<int> commands;
|
||||
int selectedSlot;
|
||||
int nextFlashUpdateTime;
|
||||
int mouseX, mouseY;
|
||||
|
||||
// GDI stuff
|
||||
//HFONT hBookmarksFont;
|
||||
//HIMAGELIST hImgList;
|
||||
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,187 @@
|
|||
// Specification file for Branches class
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#define BRANCHES_ANIMATION_TICK 40 // animate at 25FPS
|
||||
#define BRANCHES_TRANSITION_MAX 12
|
||||
#define CURSOR_MIN_DISTANCE 1.0
|
||||
#define CURSOR_MAX_DISTANCE 256.0
|
||||
#define CURSOR_MIN_SPEED 1.0
|
||||
|
||||
// floating empty branches
|
||||
#define MAX_FLOATING_PHASE 4
|
||||
|
||||
// branches bitmap
|
||||
#define BRANCHES_BITMAP_WIDTH 170
|
||||
#define BRANCHES_BITMAP_HEIGHT 145
|
||||
#define BRANCHES_ANIMATION_FRAMES 12
|
||||
#define BRANCHES_BITMAP_FRAMENUM_X 2
|
||||
#define BRANCHES_BITMAP_FRAMENUM_Y 1
|
||||
#define BRANCHES_BITMAP_TIME_X 2
|
||||
#define BRANCHES_BITMAP_TIME_Y BRANCHES_BITMAP_HEIGHT - 17
|
||||
#define BRANCHES_TEXT_SHADOW_COLOR 0xFFFFFF
|
||||
#define BRANCHES_TEXT_COLOR 0x7F0000
|
||||
// constants for drawing branches tree
|
||||
#define BRANCHES_CANVAS_WIDTH 140
|
||||
#define BRANCHES_CANVAS_HEIGHT 130
|
||||
#define BRANCHES_CLOUD_X 14
|
||||
#define BRANCHES_CLOUD_Y 72
|
||||
#define BRANCHES_GRID_MIN_WIDTH 14
|
||||
#define BRANCHES_GRID_MAX_WIDTH 30
|
||||
#define MIN_CLOUD_LINE_LENGTH 19
|
||||
#define MIN_CLOUD_X 12
|
||||
#define BASE_HORIZONTAL_SHIFT 10
|
||||
#define BRANCHES_GRID_MIN_HALFHEIGHT 8
|
||||
#define BRANCHES_GRID_MAX_HALFHEIGHT 12
|
||||
#define EMPTY_BRANCHES_X_BASE 4
|
||||
#define EMPTY_BRANCHES_Y_BASE 9
|
||||
#define EMPTY_BRANCHES_Y_FACTOR 14
|
||||
#define MAX_NUM_CHILDREN_ON_CANVAS_HEIGHT 9
|
||||
#define MAX_CHAIN_LEN 10
|
||||
#define MAX_GRID_Y_POS 8
|
||||
// spritesheet
|
||||
#define DIGIT_BITMAP_WIDTH 9
|
||||
#define DIGIT_BITMAP_HALFWIDTH DIGIT_BITMAP_WIDTH/2
|
||||
#define DIGIT_BITMAP_HEIGHT 13
|
||||
#define DIGIT_BITMAP_HALFHEIGHT DIGIT_BITMAP_HEIGHT/2
|
||||
#define BLUE_DIGITS_SPRITESHEET_DX DIGIT_BITMAP_WIDTH*TOTAL_BOOKMARKS
|
||||
#define MOUSEOVER_DIGITS_SPRITESHEET_DY DIGIT_BITMAP_HEIGHT
|
||||
#define DIGIT_RECT_WIDTH 11
|
||||
#define DIGIT_RECT_WIDTH_COLLISION (DIGIT_RECT_WIDTH + 2)
|
||||
#define DIGIT_RECT_HALFWIDTH DIGIT_RECT_WIDTH/2
|
||||
#define DIGIT_RECT_HALFWIDTH_COLLISION (DIGIT_RECT_HALFWIDTH + 1)
|
||||
#define DIGIT_RECT_HEIGHT 15
|
||||
#define DIGIT_RECT_HEIGHT_COLLISION (DIGIT_RECT_HEIGHT + 2)
|
||||
#define DIGIT_RECT_HALFHEIGHT DIGIT_RECT_HEIGHT/2
|
||||
#define DIGIT_RECT_HALFHEIGHT_COLLISION (DIGIT_RECT_HALFHEIGHT + 1)
|
||||
#define BRANCHES_CLOUD_WIDTH 26
|
||||
#define BRANCHES_CLOUD_HALFWIDTH BRANCHES_CLOUD_WIDTH/2
|
||||
#define BRANCHES_CLOUD_HEIGHT 15
|
||||
#define BRANCHES_CLOUD_HALFHEIGHT BRANCHES_CLOUD_HEIGHT/2
|
||||
#define BRANCHES_CLOUD_SPRITESHEET_X 180
|
||||
#define BRANCHES_CLOUD_SPRITESHEET_Y 0
|
||||
#define BRANCHES_FIREBALL_WIDTH 10
|
||||
#define BRANCHES_FIREBALL_HALFWIDTH BRANCHES_FIREBALL_WIDTH/2
|
||||
#define BRANCHES_FIREBALL_HEIGHT 10
|
||||
#define BRANCHES_FIREBALL_HALFHEIGHT BRANCHES_FIREBALL_HEIGHT/2
|
||||
#define BRANCHES_FIREBALL_SPRITESHEET_X 0
|
||||
#define BRANCHES_FIREBALL_SPRITESHEET_Y 26
|
||||
#define BRANCHES_FIREBALL_MAX_SIZE 5
|
||||
#define BRANCHES_FIREBALL_SPRITESHEET_END_X 160
|
||||
#define BRANCHES_CORNER_WIDTH 6
|
||||
#define BRANCHES_CORNER_HALFWIDTH BRANCHES_CORNER_WIDTH/2
|
||||
#define BRANCHES_CORNER_HEIGHT 6
|
||||
#define BRANCHES_CORNER_HALFHEIGHT BRANCHES_CORNER_HEIGHT/2
|
||||
#define BRANCHES_CORNER1_SPRITESHEET_X 206
|
||||
#define BRANCHES_CORNER1_SPRITESHEET_Y 0
|
||||
#define BRANCHES_CORNER2_SPRITESHEET_X 212
|
||||
#define BRANCHES_CORNER2_SPRITESHEET_Y 0
|
||||
#define BRANCHES_CORNER3_SPRITESHEET_X 206
|
||||
#define BRANCHES_CORNER3_SPRITESHEET_Y 6
|
||||
#define BRANCHES_CORNER4_SPRITESHEET_X 212
|
||||
#define BRANCHES_CORNER4_SPRITESHEET_Y 6
|
||||
#define BRANCHES_CORNER_BASE_SHIFT 7
|
||||
#define BRANCHES_MINIARROW_SPRITESHEET_X 180
|
||||
#define BRANCHES_MINIARROW_SPRITESHEET_Y 15
|
||||
#define BRANCHES_MINIARROW_WIDTH 3
|
||||
#define BRANCHES_MINIARROW_HALFWIDTH BRANCHES_MINIARROW_WIDTH/2
|
||||
#define BRANCHES_MINIARROW_HEIGHT 5
|
||||
#define BRANCHES_MINIARROW_HALFHEIGHT BRANCHES_MINIARROW_HEIGHT/2
|
||||
|
||||
#define BRANCHES_SELECTED_SLOT_DX -6
|
||||
#define BRANCHES_SELECTED_SLOT_DY -6
|
||||
#define BRANCHES_SELECTED_SLOT_WIDTH 13
|
||||
#define BRANCHES_SELECTED_SLOT_HEIGHT 13
|
||||
|
||||
#define FIRST_DIFFERENCE_UNKNOWN -2
|
||||
|
||||
class BRANCHES
|
||||
{
|
||||
public:
|
||||
BRANCHES();
|
||||
void init();
|
||||
void free();
|
||||
void reset();
|
||||
void resetVars();
|
||||
void update();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
bool load(EMUFILE *is);
|
||||
|
||||
int getParentOf(int child);
|
||||
int getCurrentBranch();
|
||||
bool areThereChangesSinceCurrentBranch();
|
||||
|
||||
bool isSafeToShowBranchesData();
|
||||
|
||||
void redrawBranchesBitmap();
|
||||
//void paintBranchesBitmap(HDC hdc);
|
||||
|
||||
void handleBookmarkSet(int slot);
|
||||
void handleBookmarkDeploy(int slot);
|
||||
void handleHistoryJump(int newCurrentBranch, bool newChangesSinceCurrentBranch);
|
||||
void setChangesMadeSinceBranch();
|
||||
|
||||
void invalidateRelationsOfBranchSlot(int slot);
|
||||
int findFullTimelineForBranch(int branchNumber);
|
||||
|
||||
int findItemUnderMouse(int mouseX, int mouseY);
|
||||
|
||||
// not saved vars
|
||||
bool mustRedrawBranchesBitmap;
|
||||
bool mustRecalculateBranchesTree;
|
||||
int branchRightclicked;
|
||||
|
||||
private:
|
||||
void setCurrentPosTimestamp();
|
||||
|
||||
void recalculateParents();
|
||||
void recalculateBranchesTree();
|
||||
void recursiveAddHeight(int branchNumber, int amount);
|
||||
void recursiveSetYPos(int parent, int parentY);
|
||||
|
||||
int getFirstDifferenceBetween(int firstBranch, int secondBranch);
|
||||
|
||||
// saved vars
|
||||
std::vector<int> parents;
|
||||
int currentBranch;
|
||||
bool changesSinceCurrentBranch;
|
||||
char cloudTimestamp[TIMESTAMP_LENGTH];
|
||||
char currentPosTimestamp[TIMESTAMP_LENGTH];
|
||||
std::vector<std::vector<int>> cachedFirstDifferences;
|
||||
std::vector<int8_t> cachedTimelines; // stores id of the last branch on the timeline of every Branch. Sometimes it's the id of the Branch itself, but sometimes it's an id of its child/grandchild that shares the same Input
|
||||
|
||||
// not saved vars
|
||||
int transitionPhase;
|
||||
int currentAnimationFrame;
|
||||
int nextAnimationTime;
|
||||
int playbackCursorX, playbackCursorY;
|
||||
double cornersCursorX, cornersCursorY;
|
||||
std::vector<int> branchX; // in pixels
|
||||
std::vector<int> branchY;
|
||||
std::vector<int> branchPreviousX;
|
||||
std::vector<int> branchPreviousY;
|
||||
std::vector<int> branchCurrentX;
|
||||
std::vector<int> branchCurrentY;
|
||||
int cloudX, cloudPreviousX, cloudCurrentX;
|
||||
int fireballSize;
|
||||
int lastItemUnderMouse;
|
||||
|
||||
// GDI stuff
|
||||
//HBRUSH normalBrush, borderBrush, selectedSlotBrush;
|
||||
//RECT tempRect;
|
||||
//HPEN normalPen, timelinePen, selectPen;
|
||||
//HBITMAP hBranchesBitmap, hOldBitmap, hBufferBitmap, hOldBitmap1, hBranchesSpritesheet, hOldBitmap2;
|
||||
//HDC hBitmapDC, hBufferDC, hSpritesheetDC;
|
||||
//TRIVERTEX vertex[2];
|
||||
//GRADIENT_RECT gRect;
|
||||
//RECT branchesBitmapRect;
|
||||
|
||||
// temps
|
||||
std::vector<int> gridX; // measured in grid units, not in pixels
|
||||
std::vector<int> gridY;
|
||||
std::vector<int> gridHeight;
|
||||
std::vector<std::vector<uint8_t>> children;
|
||||
|
||||
};
|
|
@ -20,18 +20,22 @@ Greenzone - Access zone
|
|||
* stores resources: save id, properties of gradual cleaning, timing of cleaning
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include "taseditor_project.h"
|
||||
#include "state.h"
|
||||
#include "zlib.h"
|
||||
#include <zlib.h>
|
||||
|
||||
extern TASEDITOR_CONFIG taseditorConfig;
|
||||
extern TASEDITOR_PROJECT project;
|
||||
extern PLAYBACK playback;
|
||||
extern HISTORY history;
|
||||
extern BOOKMARKS bookmarks;
|
||||
extern MARKERS_MANAGER markersManager;
|
||||
extern PIANO_ROLL pianoRoll;
|
||||
extern SELECTION selection;
|
||||
#include "fceu.h"
|
||||
#include "state.h"
|
||||
#include "driver.h"
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
//extern TASEDITOR_CONFIG taseditorConfig;
|
||||
//extern TASEDITOR_PROJECT project;
|
||||
//extern PLAYBACK playback;
|
||||
//extern HISTORY history;
|
||||
//extern BOOKMARKS bookmarks;
|
||||
//extern MARKERS_MANAGER markersManager;
|
||||
//extern PIANO_ROLL pianoRoll;
|
||||
//extern SELECTION selection;
|
||||
|
||||
extern char lagFlag;
|
||||
|
||||
|
@ -60,7 +64,7 @@ void GREENZONE::reset()
|
|||
void GREENZONE::update()
|
||||
{
|
||||
// keep collecting savestates, this code must be executed at the end of every frame
|
||||
if (taseditorConfig.enableGreenzoning)
|
||||
if (taseditorConfig->enableGreenzoning)
|
||||
{
|
||||
collectCurrentState();
|
||||
} else
|
||||
|
@ -80,7 +84,7 @@ void GREENZONE::update()
|
|||
// lagFlag indicates that lag was in previous frame
|
||||
int old_lagFlag = lagLog.getLagInfoAtFrame(currFrameCounter - 1);
|
||||
// Auto-adjust Input according to lag
|
||||
if (taseditorConfig.autoAdjustInputAccordingToLag && old_lagFlag != LAGGED_UNKNOWN)
|
||||
if (taseditorConfig->autoAdjustInputAccordingToLag && old_lagFlag != LAGGED_UNKNOWN)
|
||||
{
|
||||
if ((old_lagFlag == LAGGED_YES) && !lagFlag)
|
||||
{
|
||||
|
@ -97,12 +101,12 @@ void GREENZONE::update()
|
|||
{
|
||||
lagLog.setLagInfo(currFrameCounter - 1, true);
|
||||
// keep current snapshot laglog in touch
|
||||
history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, true);
|
||||
history->getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, true);
|
||||
} else if (!lagFlag && old_lagFlag != LAGGED_NO)
|
||||
{
|
||||
lagLog.setLagInfo(currFrameCounter - 1, false);
|
||||
// keep current snapshot laglog in touch
|
||||
history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, false);
|
||||
history->getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,11 +138,11 @@ bool GREENZONE::loadSavestateOfFrame(unsigned int frame)
|
|||
void GREENZONE::runGreenzoneCleaning()
|
||||
{
|
||||
bool changed = false;
|
||||
int i = currFrameCounter - taseditorConfig.greenzoneCapacity;
|
||||
int i = currFrameCounter - taseditorConfig->greenzoneCapacity;
|
||||
if (i <= 0) goto finish; // zeroth frame should not be cleaned
|
||||
int limit;
|
||||
// 2x of 1/2
|
||||
limit = i - 2 * taseditorConfig.greenzoneCapacity;
|
||||
limit = i - 2 * taseditorConfig->greenzoneCapacity;
|
||||
if (limit < 0) limit = 0;
|
||||
for (; i > limit; i--)
|
||||
{
|
||||
|
@ -147,7 +151,7 @@ void GREENZONE::runGreenzoneCleaning()
|
|||
}
|
||||
if (i < 0) goto finish;
|
||||
// 4x of 1/4
|
||||
limit = i - 4 * taseditorConfig.greenzoneCapacity;
|
||||
limit = i - 4 * taseditorConfig->greenzoneCapacity;
|
||||
if (limit < 0) limit = 0;
|
||||
for (; i > limit; i--)
|
||||
{
|
||||
|
@ -156,7 +160,7 @@ void GREENZONE::runGreenzoneCleaning()
|
|||
}
|
||||
if (i < 0) goto finish;
|
||||
// 8x of 1/8
|
||||
limit = i - 8 * taseditorConfig.greenzoneCapacity;
|
||||
limit = i - 8 * taseditorConfig->greenzoneCapacity;
|
||||
if (limit < 0) limit = 0;
|
||||
for (; i > limit; i--)
|
||||
{
|
||||
|
@ -165,7 +169,7 @@ void GREENZONE::runGreenzoneCleaning()
|
|||
}
|
||||
if (i < 0) goto finish;
|
||||
// 16x of 1/16
|
||||
limit = i - 16 * taseditorConfig.greenzoneCapacity;
|
||||
limit = i - 16 * taseditorConfig->greenzoneCapacity;
|
||||
if (limit < 0) limit = 0;
|
||||
for (; i > limit; i--)
|
||||
{
|
||||
|
@ -180,8 +184,8 @@ void GREENZONE::runGreenzoneCleaning()
|
|||
finish:
|
||||
if (changed)
|
||||
{
|
||||
pianoRoll.redraw();
|
||||
bookmarks.redrawBookmarksList();
|
||||
//pianoRoll.redraw();
|
||||
bookmarks->redrawBookmarksList();
|
||||
}
|
||||
// shedule next cleaning
|
||||
nextCleaningTime = clock() + TIME_BETWEEN_CLEANINGS;
|
||||
|
@ -203,7 +207,7 @@ bool GREENZONE::clearSavestateAndFreeMemory(unsigned int frame)
|
|||
{
|
||||
if (frame < savestates.size() && savestates[frame].size())
|
||||
{
|
||||
savestates[frame].swap(std::vector<uint8>());
|
||||
//savestates[frame].swap(std::vector<uint8_t>()); FIXME
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
|
@ -213,7 +217,7 @@ bool GREENZONE::clearSavestateAndFreeMemory(unsigned int frame)
|
|||
|
||||
void GREENZONE::ungreenzoneSelectedFrames()
|
||||
{
|
||||
RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
|
||||
RowsSelection* current_selection = selection->getCopyOfCurrentRowsSelection();
|
||||
if (current_selection->size() == 0) return;
|
||||
bool changed = false;
|
||||
int size = savestates.size();
|
||||
|
@ -225,8 +229,8 @@ void GREENZONE::ungreenzoneSelectedFrames()
|
|||
changed = changed | clearSavestateAndFreeMemory(*it);
|
||||
if (changed)
|
||||
{
|
||||
pianoRoll.redraw();
|
||||
bookmarks.redrawBookmarksList();
|
||||
//pianoRoll.redraw();
|
||||
bookmarks->redrawBookmarksList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +264,7 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
|||
// update TASEditor progressbar from time to time
|
||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||
{
|
||||
playback.setProgressbar(frame, greenzoneSize);
|
||||
playback->setProgressbar(frame, greenzoneSize);
|
||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||
}
|
||||
if (!savestates[frame].size()) continue;
|
||||
|
@ -284,7 +288,7 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
|||
// update TASEditor progressbar from time to time
|
||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||
{
|
||||
playback.setProgressbar(frame, greenzoneSize);
|
||||
playback->setProgressbar(frame, greenzoneSize);
|
||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||
}
|
||||
if (!savestates[frame].size()) continue;
|
||||
|
@ -304,12 +308,12 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
|||
// write savestates
|
||||
for (frame = 0; frame < greenzoneSize; ++frame)
|
||||
{
|
||||
if (markersManager.getMarkerAtFrame(frame) || frame == currFrameCounter)
|
||||
if (markersManager->getMarkerAtFrame(frame) || frame == currFrameCounter)
|
||||
{
|
||||
// update TASEditor progressbar from time to time
|
||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||
{
|
||||
playback.setProgressbar(frame, greenzoneSize);
|
||||
playback->setProgressbar(frame, greenzoneSize);
|
||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||
}
|
||||
if (!savestates[frame].size()) continue;
|
||||
|
@ -347,6 +351,10 @@ void GREENZONE::save(EMUFILE *os, int save_type)
|
|||
// returns true if couldn't load
|
||||
bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
int frame = 0, prev_frame = -1, size = 0;
|
||||
int last_tick = 0;
|
||||
char save_id[GREENZONE_ID_LEN];
|
||||
|
||||
free();
|
||||
if (offset)
|
||||
{
|
||||
|
@ -354,13 +362,10 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
|||
} else
|
||||
{
|
||||
reset();
|
||||
playback.restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
||||
playback->restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
||||
return false;
|
||||
}
|
||||
int frame = 0, prev_frame = -1, size = 0;
|
||||
int last_tick = 0;
|
||||
// read "GREENZONE" string
|
||||
char save_id[GREENZONE_ID_LEN];
|
||||
if ((int)is->fread(save_id, GREENZONE_ID_LEN) < GREENZONE_ID_LEN) goto error;
|
||||
if (!strcmp(greenzone_skipsave_id, save_id))
|
||||
{
|
||||
|
@ -392,7 +397,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
|||
{
|
||||
// literally no Greenzone in the file, but this is still not a error
|
||||
reset();
|
||||
playback.restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
||||
playback->restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
||||
FCEU_printf("No Greenzone in the file, Playback at frame 0\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -411,11 +416,11 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
|||
if (read32le(&frame, is))
|
||||
{
|
||||
currFrameCounter = frame;
|
||||
int greenzone_tail_frame = currFrameCounter - taseditorConfig.greenzoneCapacity;
|
||||
int greenzone_tail_frame2 = greenzone_tail_frame - 2 * taseditorConfig.greenzoneCapacity;
|
||||
int greenzone_tail_frame4 = greenzone_tail_frame - 4 * taseditorConfig.greenzoneCapacity;
|
||||
int greenzone_tail_frame8 = greenzone_tail_frame - 8 * taseditorConfig.greenzoneCapacity;
|
||||
int greenzone_tail_frame16 = greenzone_tail_frame - 16 * taseditorConfig.greenzoneCapacity;
|
||||
int greenzone_tail_frame = currFrameCounter - taseditorConfig->greenzoneCapacity;
|
||||
int greenzone_tail_frame2 = greenzone_tail_frame - 2 * taseditorConfig->greenzoneCapacity;
|
||||
int greenzone_tail_frame4 = greenzone_tail_frame - 4 * taseditorConfig->greenzoneCapacity;
|
||||
int greenzone_tail_frame8 = greenzone_tail_frame - 8 * taseditorConfig->greenzoneCapacity;
|
||||
int greenzone_tail_frame16 = greenzone_tail_frame - 16 * taseditorConfig->greenzoneCapacity;
|
||||
// read savestates
|
||||
while(1)
|
||||
{
|
||||
|
@ -424,7 +429,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
|||
// update TASEditor progressbar from time to time
|
||||
if (frame / PROGRESSBAR_UPDATE_RATE > last_tick)
|
||||
{
|
||||
playback.setProgressbar(frame, greenzoneSize);
|
||||
playback->setProgressbar(frame, greenzoneSize);
|
||||
last_tick = frame / PROGRESSBAR_UPDATE_RATE;
|
||||
}
|
||||
// read savestate
|
||||
|
@ -478,7 +483,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
|||
error:
|
||||
FCEU_printf("Error loading Greenzone\n");
|
||||
reset();
|
||||
playback.restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
||||
playback->restartPlaybackFromZeroGround(); // reset Playback cursor to frame 0
|
||||
return true;
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
@ -496,9 +501,9 @@ void GREENZONE::adjustUp()
|
|||
// delete these frames of lag
|
||||
currMovieData.eraseRecords(currFrameCounter - 1, num_frames_to_erase);
|
||||
lagLog.eraseFrame(currFrameCounter - 1, num_frames_to_erase);
|
||||
if (taseditorConfig.bindMarkersToInput)
|
||||
if (taseditorConfig->bindMarkersToInput)
|
||||
{
|
||||
if (markersManager.eraseMarker(currFrameCounter - 1, num_frames_to_erase))
|
||||
if (markersManager->eraseMarker(currFrameCounter - 1, num_frames_to_erase))
|
||||
markers_changed = true;
|
||||
}
|
||||
// update movie data size, because Playback cursor must always be inside the movie
|
||||
|
@ -506,9 +511,9 @@ void GREENZONE::adjustUp()
|
|||
if (((int)currMovieData.records.size() - 1) <= currFrameCounter)
|
||||
currMovieData.insertEmpty(-1, currFrameCounter - ((int)currMovieData.records.size() - 1));
|
||||
// update Piano Roll (reduce it if needed)
|
||||
pianoRoll.updateLinesCount();
|
||||
//pianoRoll.updateLinesCount();
|
||||
// register changes
|
||||
int first_input_changes = history.registerAdjustLag(currFrameCounter - 1, 0 - num_frames_to_erase);
|
||||
int first_input_changes = history->registerAdjustLag(currFrameCounter - 1, 0 - num_frames_to_erase);
|
||||
// if Input in the frame above currFrameCounter has changed then invalidate Greenzone (rewind 1 frame back)
|
||||
// also if the frame above currFrameCounter is lag frame then rewind 1 frame (invalidate Greenzone), because maybe this frame also needs lag removal
|
||||
if ((first_input_changes >= 0 && first_input_changes < currFrameCounter) || (lagLog.getLagInfoAtFrame(currFrameCounter - 1) != LAGGED_NO))
|
||||
|
@ -516,19 +521,21 @@ void GREENZONE::adjustUp()
|
|||
// custom invalidation procedure, not retriggering LostPosition/PauseFrame
|
||||
invalidate(first_input_changes);
|
||||
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
|
||||
int saved_pause_frame = playback.getPauseFrame();
|
||||
playback.ensurePlaybackIsInsideGreenzone();
|
||||
int saved_pause_frame = playback->getPauseFrame();
|
||||
playback->ensurePlaybackIsInsideGreenzone();
|
||||
if (saved_pause_frame >= 0)
|
||||
playback.startSeekingToFrame(saved_pause_frame);
|
||||
playback->startSeekingToFrame(saved_pause_frame);
|
||||
if (emu_was_paused)
|
||||
playback.pauseEmulation();
|
||||
playback->pauseEmulation();
|
||||
} else
|
||||
{
|
||||
// just invalidate Greenzone after currFrameCounter (this is necessary in order to force user to re-emulate everything after the point, because the lag log data after the currFrameCounter is now in unknown state and it should be collected again)
|
||||
invalidate(currFrameCounter);
|
||||
}
|
||||
if (markers_changed)
|
||||
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
|
||||
{
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
void GREENZONE::adjustDown()
|
||||
|
@ -538,13 +545,13 @@ void GREENZONE::adjustDown()
|
|||
// clone frame and insert lag
|
||||
currMovieData.cloneRegion(at, 1);
|
||||
lagLog.insertFrame(at, true, 1);
|
||||
if (taseditorConfig.bindMarkersToInput)
|
||||
if (taseditorConfig->bindMarkersToInput)
|
||||
{
|
||||
if (markersManager.insertEmpty(at, 1))
|
||||
if (markersManager->insertEmpty(at, 1))
|
||||
markers_changed = true;
|
||||
}
|
||||
// register changes
|
||||
int first_input_changes = history.registerAdjustLag(at, +1);
|
||||
int first_input_changes = history->registerAdjustLag(at, +1);
|
||||
// If Input in the frame above currFrameCounter has changed then invalidate Greenzone (rewind 1 frame back)
|
||||
// This should never actually happen, because we clone the frame, so the Input doesn't change
|
||||
// But the check should remain, in case we decide to insert blank frame instead of cloning
|
||||
|
@ -553,19 +560,21 @@ void GREENZONE::adjustDown()
|
|||
// custom invalidation procedure, not retriggering LostPosition/PauseFrame
|
||||
invalidate(first_input_changes);
|
||||
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
|
||||
int saved_pause_frame = playback.getPauseFrame();
|
||||
playback.ensurePlaybackIsInsideGreenzone();
|
||||
int saved_pause_frame = playback->getPauseFrame();
|
||||
playback->ensurePlaybackIsInsideGreenzone();
|
||||
if (saved_pause_frame >= 0)
|
||||
playback.startSeekingToFrame(saved_pause_frame);
|
||||
playback->startSeekingToFrame(saved_pause_frame);
|
||||
if (emu_was_paused)
|
||||
playback.pauseEmulation();
|
||||
playback->pauseEmulation();
|
||||
} else
|
||||
{
|
||||
// just invalidate Greenzone after currFrameCounter
|
||||
invalidate(currFrameCounter);
|
||||
}
|
||||
if (markers_changed)
|
||||
selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
|
||||
{
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// This version doesn't restore playback, may be used only by Branching, Recording and AdjustLag functions!
|
||||
|
@ -585,8 +594,8 @@ void GREENZONE::invalidate(int after)
|
|||
}
|
||||
}
|
||||
// redraw Piano Roll even if Greenzone didn't change
|
||||
pianoRoll.redraw();
|
||||
bookmarks.redrawBookmarksList();
|
||||
//pianoRoll.redraw();
|
||||
bookmarks->redrawBookmarksList();
|
||||
}
|
||||
// invalidate and restore playback
|
||||
void GREENZONE::invalidateAndUpdatePlayback(int after)
|
||||
|
@ -605,25 +614,25 @@ void GREENZONE::invalidateAndUpdatePlayback(int after)
|
|||
// either set Playback cursor to be inside the Greenzone or run seeking to restore Playback cursor position
|
||||
if (currFrameCounter >= greenzoneSize)
|
||||
{
|
||||
if (playback.getPauseFrame() >= 0 && !FCEUI_EmulationPaused())
|
||||
if (playback->getPauseFrame() >= 0 && !FCEUI_EmulationPaused())
|
||||
{
|
||||
// emulator was running, so continue seeking, but don't follow the Playback cursor
|
||||
playback.jump(playback.getPauseFrame(), false, true, false);
|
||||
playback->jump(playback->getPauseFrame(), false, true, false);
|
||||
} else
|
||||
{
|
||||
playback.setLastPosition(currFrameCounter);
|
||||
if (taseditorConfig.autoRestoreLastPlaybackPosition)
|
||||
playback->setLastPosition(currFrameCounter);
|
||||
if (taseditorConfig->autoRestoreLastPlaybackPosition)
|
||||
// start seeking to the green arrow, but don't follow the Playback cursor
|
||||
playback.jump(playback.getLastPosition(), false, true, false);
|
||||
playback->jump(playback->getLastPosition(), false, true, false);
|
||||
else
|
||||
playback.ensurePlaybackIsInsideGreenzone();
|
||||
playback->ensurePlaybackIsInsideGreenzone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// redraw Piano Roll even if Greenzone didn't change
|
||||
pianoRoll.redraw();
|
||||
bookmarks.redrawBookmarksList();
|
||||
//pianoRoll.redraw();
|
||||
bookmarks->redrawBookmarksList();
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
int GREENZONE::findFirstGreenzonedFrame(int starting_index)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,165 @@
|
|||
// Specification file for History class
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include "fceu.h"
|
||||
#include "Qt/TasEditor/bookmark.h"
|
||||
#include "Qt/TasEditor/snapshot.h"
|
||||
|
||||
#define UNDO_HINT_TIME 200 // in milliseconds
|
||||
|
||||
#define SAVING_HISTORY_PROGRESSBAR_UPDATE_RATE 10
|
||||
#define TIME_BETWEEN_AUTOCOMPRESSIONS 500 // in milliseconds
|
||||
|
||||
#define HISTORY_LIST_WIDTH 500
|
||||
|
||||
enum MOD_TYPES
|
||||
{
|
||||
MODTYPE_INIT,
|
||||
MODTYPE_UNDEFINED,
|
||||
MODTYPE_SET,
|
||||
MODTYPE_UNSET,
|
||||
MODTYPE_PATTERN,
|
||||
MODTYPE_INSERT,
|
||||
MODTYPE_INSERTNUM,
|
||||
MODTYPE_DELETE,
|
||||
MODTYPE_TRUNCATE,
|
||||
MODTYPE_CLEAR,
|
||||
MODTYPE_CUT,
|
||||
MODTYPE_PASTE,
|
||||
MODTYPE_PASTEINSERT,
|
||||
MODTYPE_CLONE,
|
||||
MODTYPE_RECORD,
|
||||
MODTYPE_IMPORT,
|
||||
MODTYPE_BOOKMARK_0,
|
||||
MODTYPE_BOOKMARK_1,
|
||||
MODTYPE_BOOKMARK_2,
|
||||
MODTYPE_BOOKMARK_3,
|
||||
MODTYPE_BOOKMARK_4,
|
||||
MODTYPE_BOOKMARK_5,
|
||||
MODTYPE_BOOKMARK_6,
|
||||
MODTYPE_BOOKMARK_7,
|
||||
MODTYPE_BOOKMARK_8,
|
||||
MODTYPE_BOOKMARK_9,
|
||||
MODTYPE_BRANCH_0,
|
||||
MODTYPE_BRANCH_1,
|
||||
MODTYPE_BRANCH_2,
|
||||
MODTYPE_BRANCH_3,
|
||||
MODTYPE_BRANCH_4,
|
||||
MODTYPE_BRANCH_5,
|
||||
MODTYPE_BRANCH_6,
|
||||
MODTYPE_BRANCH_7,
|
||||
MODTYPE_BRANCH_8,
|
||||
MODTYPE_BRANCH_9,
|
||||
MODTYPE_BRANCH_MARKERS_0,
|
||||
MODTYPE_BRANCH_MARKERS_1,
|
||||
MODTYPE_BRANCH_MARKERS_2,
|
||||
MODTYPE_BRANCH_MARKERS_3,
|
||||
MODTYPE_BRANCH_MARKERS_4,
|
||||
MODTYPE_BRANCH_MARKERS_5,
|
||||
MODTYPE_BRANCH_MARKERS_6,
|
||||
MODTYPE_BRANCH_MARKERS_7,
|
||||
MODTYPE_BRANCH_MARKERS_8,
|
||||
MODTYPE_BRANCH_MARKERS_9,
|
||||
MODTYPE_MARKER_SET,
|
||||
MODTYPE_MARKER_REMOVE,
|
||||
MODTYPE_MARKER_PATTERN,
|
||||
MODTYPE_MARKER_RENAME,
|
||||
MODTYPE_MARKER_DRAG,
|
||||
MODTYPE_MARKER_SWAP,
|
||||
MODTYPE_MARKER_SHIFT,
|
||||
MODTYPE_LUA_MARKER_SET,
|
||||
MODTYPE_LUA_MARKER_REMOVE,
|
||||
MODTYPE_LUA_MARKER_RENAME,
|
||||
MODTYPE_LUA_CHANGE,
|
||||
|
||||
MODTYPES_TOTAL
|
||||
};
|
||||
|
||||
enum CATEGORIES_OF_OPERATIONS
|
||||
{
|
||||
CATEGORY_OTHER,
|
||||
CATEGORY_INPUT_CHANGE,
|
||||
CATEGORY_MARKERS_CHANGE,
|
||||
CATEGORY_INPUT_MARKERS_CHANGE,
|
||||
|
||||
CATEGORIES_OF_OPERATIONS_TOTAL
|
||||
};
|
||||
|
||||
#define HISTORY_NORMAL_COLOR 0x000000
|
||||
#define HISTORY_NORMAL_BG_COLOR 0xFFFFFF
|
||||
#define HISTORY_RELATED_BG_COLOR 0xF9DDE6
|
||||
|
||||
#define WM_MOUSEWHEEL_RESENT WM_APP+123
|
||||
|
||||
#define HISTORY_ID_LEN 8
|
||||
|
||||
class HISTORY
|
||||
{
|
||||
public:
|
||||
HISTORY();
|
||||
void init();
|
||||
void free();
|
||||
void reset();
|
||||
void update(); // called every frame
|
||||
|
||||
void updateHistoryLogSize();
|
||||
|
||||
void save(EMUFILE *os, bool reallySave = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
int registerChanges(int mod_type, int start = 0, int end =-1, int size = 0, const char* comment = NULL, int consecutivenessTag = 0, RowsSelection* frameset = NULL);
|
||||
int registerAdjustLag(int start, int size);
|
||||
void registerMarkersChange(int modificationType, int start = 0, int end =-1, const char* comment = 0);
|
||||
void registerBookmarkSet(int slot, BOOKMARK& backupCopy, int oldCurrentBranch);
|
||||
int registerBranching(int slot, bool markersWereChanged);
|
||||
void registerRecording(int frameOfChange, uint32 joypadDifferenceBits);
|
||||
int registerImport(MovieData& md, char* filename);
|
||||
int registerLuaChanges(const char* name, int start, bool insertionOrDeletionWasDone);
|
||||
|
||||
int getCategoryOfOperation(int modificationType);
|
||||
|
||||
SNAPSHOT& getCurrentSnapshot();
|
||||
SNAPSHOT& getNextToCurrentSnapshot();
|
||||
int getUndoHint();
|
||||
char* getItemDesc(int pos);
|
||||
|
||||
//void getDispInfo(NMLVDISPINFO* nmlvDispInfo);
|
||||
//LONG handleCustomDraw(NMLVCUSTOMDRAW* msg);
|
||||
void handleSingleClick(int rowIndex);
|
||||
|
||||
void redrawList();
|
||||
void updateList();
|
||||
|
||||
bool isCursorOverHistoryList();
|
||||
|
||||
//HWND hwndHistoryList;
|
||||
|
||||
private:
|
||||
int jumpInTime(int newPos);
|
||||
|
||||
void addItemToHistoryLog(SNAPSHOT &snap, int currentBranch = 0);
|
||||
void addItemToHistoryLog(SNAPSHOT &snap, int currentBranch, BOOKMARK &bookm);
|
||||
|
||||
// saved variables
|
||||
std::vector<SNAPSHOT> snapshots;
|
||||
std::vector<BOOKMARK> bookmarkBackups;
|
||||
std::vector<int8_t> currentBranchNumberBackups;
|
||||
int historyCursorPos;
|
||||
int historyTotalItems;
|
||||
|
||||
// not saved variables
|
||||
int historyStartPos;
|
||||
int historySize;
|
||||
|
||||
int undoHintPos, oldUndoHintPos;
|
||||
int undoHintTimer;
|
||||
bool showUndoHint, oldShowUndoHint;
|
||||
int nextAutocompressTime;
|
||||
|
||||
};
|
||||
|
|
@ -25,7 +25,6 @@ InputLog - Log of Input
|
|||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
|
||||
extern SELECTION selection;
|
||||
//extern int getInputType(MovieData& md);
|
||||
|
||||
int joysticksPerFrame[INPUT_TYPES_TOTAL] = {1, 2, 4};
|
||||
|
||||
|
@ -36,9 +35,9 @@ INPUTLOG::INPUTLOG()
|
|||
void INPUTLOG::init(MovieData& md, bool hotchanges, int force_input_type)
|
||||
{
|
||||
hasHotChanges = hotchanges;
|
||||
//if (force_input_type < 0)
|
||||
// inputType = getInputType(md);
|
||||
//else
|
||||
if (force_input_type < 0)
|
||||
inputType = getInputType(md);
|
||||
else
|
||||
inputType = force_input_type;
|
||||
int num_joys = joysticksPerFrame[inputType];
|
||||
// retrieve Input data from movie data
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
// Specification file for LagLog class
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
enum LAG_FLAG_VALUES
|
||||
{
|
||||
|
@ -34,9 +37,9 @@ public:
|
|||
|
||||
private:
|
||||
// saved data
|
||||
std::vector<uint8> compressedLagLog;
|
||||
std::vector<uint8_t> compressedLagLog;
|
||||
|
||||
// not saved data
|
||||
std::vector<uint8> lagLog;
|
||||
std::vector<uint8_t> lagLog;
|
||||
bool alreadyCompressed; // to compress only once
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Specification file for Markers_manager class
|
||||
#pragma once
|
||||
|
||||
#include "markers.h"
|
||||
|
||||
|
|
|
@ -20,9 +20,10 @@ Playback - Player of emulation states
|
|||
* stores resources: upper text field prefix, timings of target frame animation, response times of GUI buttons, progressbar scale
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include "taseditor_project.h"
|
||||
#include "../taseditor.h"
|
||||
#include "../../../fceu.h"
|
||||
#include "fceu.h"
|
||||
#include "driver.h"
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
#ifdef _S9XLUA_H
|
||||
extern void ForceExecuteLuaFrameFunctions();
|
||||
|
@ -31,18 +32,18 @@ extern void ForceExecuteLuaFrameFunctions();
|
|||
extern bool mustRewindNow;
|
||||
extern bool turbo;
|
||||
|
||||
extern TASEDITOR_CONFIG taseditorConfig;
|
||||
extern TASEDITOR_WINDOW taseditorWindow;
|
||||
extern SELECTION selection;
|
||||
extern MARKERS_MANAGER markersManager;
|
||||
extern GREENZONE greenzone;
|
||||
extern PIANO_ROLL pianoRoll;
|
||||
extern BOOKMARKS bookmarks;
|
||||
//extern TASEDITOR_CONFIG taseditorConfig;
|
||||
//extern TASEDITOR_WINDOW taseditorWindow;
|
||||
//extern SELECTION selection;
|
||||
//extern MARKERS_MANAGER markersManager;
|
||||
//extern GREENZONE greenzone;
|
||||
//extern PIANO_ROLL pianoRoll;
|
||||
//extern BOOKMARKS bookmarks;
|
||||
|
||||
extern void Update_RAM_Search();
|
||||
//extern void Update_RAM_Search();
|
||||
|
||||
LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
WNDPROC playbackMarkerEdit_oldWndproc;
|
||||
//LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
//WNDPROC playbackMarkerEdit_oldWndproc;
|
||||
|
||||
// resources
|
||||
char upperMarkerText[] = "Marker ";
|
||||
|
@ -53,19 +54,19 @@ PLAYBACK::PLAYBACK()
|
|||
|
||||
void PLAYBACK::init()
|
||||
{
|
||||
hwndProgressbar = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PROGRESS1);
|
||||
SendMessage(hwndProgressbar, PBM_SETRANGE, 0, MAKELPARAM(0, PROGRESSBAR_WIDTH));
|
||||
hwndRewind = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_REWIND);
|
||||
hwndForward = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_FORWARD);
|
||||
hwndRewindFull = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_REWIND_FULL);
|
||||
hwndForwardFull = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_FORWARD_FULL);
|
||||
hwndPlaybackMarkerNumber = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PLAYBACK_MARKER);
|
||||
SendMessage(hwndPlaybackMarkerNumber, WM_SETFONT, (WPARAM)pianoRoll.hMarkersFont, 0);
|
||||
hwndPlaybackMarkerEditField = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PLAYBACK_MARKER_EDIT);
|
||||
SendMessage(hwndPlaybackMarkerEditField, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
|
||||
SendMessage(hwndPlaybackMarkerEditField, WM_SETFONT, (WPARAM)pianoRoll.hMarkersEditFont, 0);
|
||||
//hwndProgressbar = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PROGRESS1);
|
||||
//SendMessage(hwndProgressbar, PBM_SETRANGE, 0, MAKELPARAM(0, PROGRESSBAR_WIDTH));
|
||||
//hwndRewind = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_REWIND);
|
||||
//hwndForward = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_FORWARD);
|
||||
//hwndRewindFull = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_REWIND_FULL);
|
||||
//hwndForwardFull = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_FORWARD_FULL);
|
||||
//hwndPlaybackMarkerNumber = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PLAYBACK_MARKER);
|
||||
//SendMessage(hwndPlaybackMarkerNumber, WM_SETFONT, (WPARAM)pianoRoll.hMarkersFont, 0);
|
||||
//hwndPlaybackMarkerEditField = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_PLAYBACK_MARKER_EDIT);
|
||||
//SendMessage(hwndPlaybackMarkerEditField, EM_SETLIMITTEXT, MAX_NOTE_LEN - 1, 0);
|
||||
//SendMessage(hwndPlaybackMarkerEditField, WM_SETFONT, (WPARAM)pianoRoll.hMarkersEditFont, 0);
|
||||
// subclass the edit control
|
||||
playbackMarkerEdit_oldWndproc = (WNDPROC)SetWindowLongPtr(hwndPlaybackMarkerEditField, GWLP_WNDPROC, (LONG_PTR)UpperMarkerEditWndProc);
|
||||
//playbackMarkerEdit_oldWndproc = (WNDPROC)SetWindowLongPtr(hwndPlaybackMarkerEditField, GWLP_WNDPROC, (LONG_PTR)UpperMarkerEditWndProc);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ void PLAYBACK::update()
|
|||
// controls:
|
||||
// update < and > buttons
|
||||
rewindButtonOldState = rewindButtonState;
|
||||
rewindButtonState = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || mustRewindNow);
|
||||
//rewindButtonState = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || mustRewindNow);
|
||||
if (rewindButtonState)
|
||||
{
|
||||
if (!rewindButtonOldState)
|
||||
|
@ -102,7 +103,7 @@ void PLAYBACK::update()
|
|||
}
|
||||
}
|
||||
forwardButtonOldState = forwardButtonState;
|
||||
forwardButtonState = (Button_GetState(hwndForward) & BST_PUSHED) != 0;
|
||||
//forwardButtonState = (Button_GetState(hwndForward) & BST_PUSHED) != 0;
|
||||
if (forwardButtonState && !rewindButtonState)
|
||||
{
|
||||
if (!forwardButtonOldState)
|
||||
|
@ -116,7 +117,7 @@ void PLAYBACK::update()
|
|||
}
|
||||
// update << and >> buttons
|
||||
rewindFullButtonOldState = rewindFullButtonState;
|
||||
rewindFullButtonState = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0);
|
||||
//rewindFullButtonState = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0);
|
||||
if (rewindFullButtonState && !rewindButtonState && !forwardButtonState)
|
||||
{
|
||||
if (!rewindFullButtonOldState)
|
||||
|
@ -129,7 +130,7 @@ void PLAYBACK::update()
|
|||
}
|
||||
}
|
||||
forwardFullButtonOldState = forwardFullButtonState;
|
||||
forwardFullButtonState = (Button_GetState(hwndForwardFull) & BST_PUSHED) != 0;
|
||||
//forwardFullButtonState = (Button_GetState(hwndForwardFull) & BST_PUSHED) != 0;
|
||||
if (forwardFullButtonState && !rewindButtonState && !forwardButtonState && !rewindFullButtonState)
|
||||
{
|
||||
if (!forwardFullButtonOldState)
|
||||
|
@ -146,20 +147,20 @@ void PLAYBACK::update()
|
|||
if (currFrameCounter != lastCursorPos)
|
||||
{
|
||||
// update gfx of the old and new rows
|
||||
pianoRoll.redrawRow(lastCursorPos);
|
||||
bookmarks.redrawChangedBookmarks(lastCursorPos);
|
||||
pianoRoll.redrawRow(currFrameCounter);
|
||||
bookmarks.redrawChangedBookmarks(currFrameCounter);
|
||||
//pianoRoll.redrawRow(lastCursorPos);
|
||||
bookmarks->redrawChangedBookmarks(lastCursorPos);
|
||||
//pianoRoll.redrawRow(currFrameCounter);
|
||||
bookmarks->redrawChangedBookmarks(currFrameCounter);
|
||||
lastCursorPos = currFrameCounter;
|
||||
// follow the Playback cursor, but in case of seeking don't follow it
|
||||
pianoRoll.followPlaybackCursorIfNeeded(false); //pianoRoll.updatePlaybackCursorPositionInPianoRoll(); // an unfinished experiment
|
||||
//pianoRoll.followPlaybackCursorIfNeeded(false); //pianoRoll.updatePlaybackCursorPositionInPianoRoll(); // an unfinished experiment
|
||||
// enforce redrawing now
|
||||
UpdateWindow(pianoRoll.hwndList);
|
||||
//UpdateWindow(pianoRoll.hwndList);
|
||||
// lazy update of "Playback's Marker text"
|
||||
int current_marker = markersManager.getMarkerAboveFrame(currFrameCounter);
|
||||
int current_marker = markersManager->getMarkerAboveFrame(currFrameCounter);
|
||||
if (displayedMarkerNumber != current_marker)
|
||||
{
|
||||
markersManager.updateEditedMarkerNote();
|
||||
markersManager->updateEditedMarkerNote();
|
||||
displayedMarkerNumber = current_marker;
|
||||
redrawMarkerData();
|
||||
mustFindCurrentMarker = false;
|
||||
|
@ -168,8 +169,8 @@ void PLAYBACK::update()
|
|||
// [non-lazy] update "Playback's Marker text" if needed
|
||||
if (mustFindCurrentMarker)
|
||||
{
|
||||
markersManager.updateEditedMarkerNote();
|
||||
displayedMarkerNumber = markersManager.getMarkerAboveFrame(currFrameCounter);
|
||||
markersManager->updateEditedMarkerNote();
|
||||
displayedMarkerNumber = markersManager->getMarkerAboveFrame(currFrameCounter);
|
||||
redrawMarkerData();
|
||||
mustFindCurrentMarker = false;
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ void PLAYBACK::update()
|
|||
// pause when seeking hits pause_frame
|
||||
if (pauseFrame && currFrameCounter + 1 >= pauseFrame)
|
||||
stopSeeking();
|
||||
else if (currFrameCounter >= getLastPosition() && currFrameCounter >= currMovieData.getNumRecords() - 1 && mustAutopauseAtTheEnd && taseditorConfig.autopauseAtTheEndOfMovie && !isTaseditorRecording())
|
||||
else if (currFrameCounter >= getLastPosition() && currFrameCounter >= currMovieData.getNumRecords() - 1 && mustAutopauseAtTheEnd && taseditorConfig->autopauseAtTheEndOfMovie && !isTaseditorRecording())
|
||||
// pause at the end of the movie
|
||||
pauseEmulation();
|
||||
|
||||
|
@ -185,8 +186,8 @@ void PLAYBACK::update()
|
|||
if (oldPauseFrame != pauseFrame && oldPauseFrame)
|
||||
{
|
||||
// pause_frame was changed, clear old_pauseframe gfx
|
||||
pianoRoll.redrawRow(oldPauseFrame-1);
|
||||
bookmarks.redrawChangedBookmarks(oldPauseFrame-1);
|
||||
//pianoRoll.redrawRow(oldPauseFrame-1);
|
||||
bookmarks->redrawChangedBookmarks(oldPauseFrame-1);
|
||||
}
|
||||
oldPauseFrame = pauseFrame;
|
||||
oldStateOfShowPauseFrame = showPauseFrame;
|
||||
|
@ -200,8 +201,8 @@ void PLAYBACK::update()
|
|||
if (oldStateOfShowPauseFrame != showPauseFrame)
|
||||
{
|
||||
// update pauseframe gfx
|
||||
pianoRoll.redrawRow(pauseFrame - 1);
|
||||
bookmarks.redrawChangedBookmarks(pauseFrame - 1);
|
||||
//pianoRoll.redrawRow(pauseFrame - 1);
|
||||
bookmarks->redrawChangedBookmarks(pauseFrame - 1);
|
||||
}
|
||||
|
||||
// update seeking progressbar
|
||||
|
@ -256,7 +257,7 @@ void PLAYBACK::updateProgressbar()
|
|||
// cleared progressbar
|
||||
setProgressbar(0, 1);
|
||||
}
|
||||
RedrawWindow(hwndProgressbar, NULL, NULL, RDW_INVALIDATE);
|
||||
//RedrawWindow(hwndProgressbar, NULL, NULL, RDW_INVALIDATE);
|
||||
}
|
||||
|
||||
void PLAYBACK::toggleEmulationPause()
|
||||
|
@ -286,48 +287,48 @@ void PLAYBACK::restoreLastPosition()
|
|||
}
|
||||
void PLAYBACK::handleMiddleButtonClick()
|
||||
{
|
||||
if (emuPausedState)
|
||||
{
|
||||
// Unpause or start seeking
|
||||
// works only when right mouse button is released
|
||||
if (GetAsyncKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON) >= 0)
|
||||
{
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
{
|
||||
// if Shift is held, seek to nearest Marker
|
||||
int last_frame = markersManager.getMarkersArraySize() - 1; // the end of movie Markers
|
||||
int target_frame = currFrameCounter + 1;
|
||||
for (; target_frame <= last_frame; ++target_frame)
|
||||
if (markersManager.getMarkerAtFrame(target_frame)) break;
|
||||
if (target_frame <= last_frame)
|
||||
startSeekingToFrame(target_frame);
|
||||
} else if (GetAsyncKeyState(VK_CONTROL) < 0)
|
||||
{
|
||||
// if Ctrl is held, seek to Selection cursor or replay from Selection cursor
|
||||
int selection_beginning = selection.getCurrentRowsSelectionBeginning();
|
||||
if (selection_beginning > currFrameCounter)
|
||||
{
|
||||
startSeekingToFrame(selection_beginning);
|
||||
} else if (selection_beginning < currFrameCounter)
|
||||
{
|
||||
int saved_currFrameCounter = currFrameCounter;
|
||||
if (selection_beginning < 0)
|
||||
selection_beginning = 0;
|
||||
jump(selection_beginning);
|
||||
startSeekingToFrame(saved_currFrameCounter);
|
||||
}
|
||||
} else if (getPauseFrame() < 0 && getLastPosition() >= greenzone.getSize())
|
||||
{
|
||||
restoreLastPosition();
|
||||
} else
|
||||
{
|
||||
unpauseEmulation();
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
pauseEmulation();
|
||||
}
|
||||
// if (emuPausedState)
|
||||
// {
|
||||
// // Unpause or start seeking
|
||||
// // works only when right mouse button is released
|
||||
// if (GetAsyncKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON) >= 0)
|
||||
// {
|
||||
// if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
// {
|
||||
// // if Shift is held, seek to nearest Marker
|
||||
// int last_frame = markersManager.getMarkersArraySize() - 1; // the end of movie Markers
|
||||
// int target_frame = currFrameCounter + 1;
|
||||
// for (; target_frame <= last_frame; ++target_frame)
|
||||
// if (markersManager.getMarkerAtFrame(target_frame)) break;
|
||||
// if (target_frame <= last_frame)
|
||||
// startSeekingToFrame(target_frame);
|
||||
// } else if (GetAsyncKeyState(VK_CONTROL) < 0)
|
||||
// {
|
||||
// // if Ctrl is held, seek to Selection cursor or replay from Selection cursor
|
||||
// int selection_beginning = selection.getCurrentRowsSelectionBeginning();
|
||||
// if (selection_beginning > currFrameCounter)
|
||||
// {
|
||||
// startSeekingToFrame(selection_beginning);
|
||||
// } else if (selection_beginning < currFrameCounter)
|
||||
// {
|
||||
// int saved_currFrameCounter = currFrameCounter;
|
||||
// if (selection_beginning < 0)
|
||||
// selection_beginning = 0;
|
||||
// jump(selection_beginning);
|
||||
// startSeekingToFrame(saved_currFrameCounter);
|
||||
// }
|
||||
// } else if (getPauseFrame() < 0 && getLastPosition() >= greenzone.getSize())
|
||||
// {
|
||||
// restoreLastPosition();
|
||||
// } else
|
||||
// {
|
||||
// unpauseEmulation();
|
||||
// }
|
||||
// }
|
||||
// } else
|
||||
// {
|
||||
// pauseEmulation();
|
||||
// }
|
||||
}
|
||||
|
||||
void PLAYBACK::startSeekingToFrame(int frame)
|
||||
|
@ -337,7 +338,7 @@ void PLAYBACK::startSeekingToFrame(int frame)
|
|||
seekingBeginningFrame = currFrameCounter;
|
||||
pauseFrame = frame + 1;
|
||||
}
|
||||
if (taseditorConfig.turboSeek)
|
||||
if (taseditorConfig->turboSeek)
|
||||
turbo = true;
|
||||
unpauseEmulation();
|
||||
}
|
||||
|
@ -353,10 +354,14 @@ void PLAYBACK::handleRewindFrame()
|
|||
{
|
||||
if (pauseFrame && !emuPausedState) return;
|
||||
if (currFrameCounter > 0)
|
||||
{
|
||||
jump(currFrameCounter - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// cursor is at frame 0 - can't rewind, but still must make cursor visible if needed
|
||||
pianoRoll.followPlaybackCursorIfNeeded(true);
|
||||
//pianoRoll.followPlaybackCursorIfNeeded(true);
|
||||
}
|
||||
if (!pauseFrame)
|
||||
pauseEmulation();
|
||||
}
|
||||
|
@ -375,7 +380,7 @@ void PLAYBACK::handleRewindFull(int speed)
|
|||
while (speed > 0)
|
||||
{
|
||||
for (; index >= 0; index--)
|
||||
if (markersManager.getMarkerAtFrame(index)) break;
|
||||
if (markersManager->getMarkerAtFrame(index)) break;
|
||||
speed--;
|
||||
}
|
||||
if (index >= 0)
|
||||
|
@ -385,13 +390,13 @@ void PLAYBACK::handleRewindFull(int speed)
|
|||
}
|
||||
void PLAYBACK::handleForwardFull(int speed)
|
||||
{
|
||||
int last_frame = markersManager.getMarkersArraySize() - 1; // the end of movie Markers
|
||||
int last_frame = markersManager->getMarkersArraySize() - 1; // the end of movie Markers
|
||||
int index = currFrameCounter + 1;
|
||||
// jump trough "speed" amount of next Markers
|
||||
while (speed > 0)
|
||||
{
|
||||
for (; index <= last_frame; ++index)
|
||||
if (markersManager.getMarkerAtFrame(index)) break;
|
||||
if (markersManager->getMarkerAtFrame(index)) break;
|
||||
speed--;
|
||||
}
|
||||
if (index <= last_frame)
|
||||
|
@ -405,17 +410,19 @@ void PLAYBACK::redrawMarkerData()
|
|||
// redraw Marker num
|
||||
char new_text[MAX_NOTE_LEN] = {0};
|
||||
if (displayedMarkerNumber <= 9999) // if there's too many digits in the number then don't show the word "Marker" before the number
|
||||
{
|
||||
strcpy(new_text, upperMarkerText);
|
||||
}
|
||||
char num[11];
|
||||
_itoa(displayedMarkerNumber, num, 10);
|
||||
//_itoa(displayedMarkerNumber, num, 10);
|
||||
strcat(new_text, num);
|
||||
strcat(new_text, " ");
|
||||
SetWindowText(hwndPlaybackMarkerNumber, new_text);
|
||||
//SetWindowText(hwndPlaybackMarkerNumber, new_text);
|
||||
// change Marker Note
|
||||
strcpy(new_text, markersManager.getNoteCopy(displayedMarkerNumber).c_str());
|
||||
SetWindowText(hwndPlaybackMarkerEditField, new_text);
|
||||
strcpy(new_text, markersManager->getNoteCopy(displayedMarkerNumber).c_str());
|
||||
//SetWindowText(hwndPlaybackMarkerEditField, new_text);
|
||||
// reset search_similar_marker, because source Marker changed
|
||||
markersManager.currentIterationOfFindSimilar = 0;
|
||||
markersManager->currentIterationOfFindSimilar = 0;
|
||||
}
|
||||
|
||||
void PLAYBACK::restartPlaybackFromZeroGround()
|
||||
|
@ -431,15 +438,15 @@ void PLAYBACK::restartPlaybackFromZeroGround()
|
|||
void PLAYBACK::ensurePlaybackIsInsideGreenzone(bool executeLua)
|
||||
{
|
||||
// set the Playback cursor to the frame or at least above the frame
|
||||
if (setPlaybackAboveOrToFrame(greenzone.getSize() - 1))
|
||||
if (setPlaybackAboveOrToFrame(greenzone->getSize() - 1))
|
||||
{
|
||||
// since the game state was changed by this jump, we must update possible Lua callbacks and other tools that would normally only update in FCEUI_Emulate
|
||||
if (executeLua)
|
||||
ForceExecuteLuaFrameFunctions();
|
||||
Update_RAM_Search(); // Update_RAM_Watch() is also called.
|
||||
//Update_RAM_Search(); // Update_RAM_Watch() is also called.
|
||||
}
|
||||
// follow the Playback cursor, but in case of seeking don't follow it
|
||||
pianoRoll.followPlaybackCursorIfNeeded(false);
|
||||
//pianoRoll.followPlaybackCursorIfNeeded(false);
|
||||
}
|
||||
|
||||
// an interface for sending Playback cursor to any frame
|
||||
|
@ -455,7 +462,7 @@ void PLAYBACK::jump(int frame, bool forceStateReload, bool executeLua, bool foll
|
|||
// since the game state was changed by this jump, we must update possible Lua callbacks and other tools that would normally only update in FCEUI_Emulate
|
||||
if (executeLua)
|
||||
ForceExecuteLuaFrameFunctions();
|
||||
Update_RAM_Search(); // Update_RAM_Watch() is also called.
|
||||
//Update_RAM_Search(); // Update_RAM_Watch() is also called.
|
||||
}
|
||||
|
||||
// 2 - seek from the current frame if we still aren't at the needed frame
|
||||
|
@ -466,18 +473,20 @@ void PLAYBACK::jump(int frame, bool forceStateReload, bool executeLua, bool foll
|
|||
{
|
||||
// the Playback is already at the needed frame
|
||||
if (pauseFrame) // if Playback was seeking, pause emulation right here
|
||||
{
|
||||
stopSeeking();
|
||||
}
|
||||
}
|
||||
|
||||
// follow the Playback cursor, and optionally follow pauseframe (if seeking was launched)
|
||||
pianoRoll.followPlaybackCursorIfNeeded(followPauseframe);
|
||||
//pianoRoll.followPlaybackCursorIfNeeded(followPauseframe);
|
||||
|
||||
// redraw respective Piano Roll lines if needed
|
||||
if (lastCursor != currFrameCounter)
|
||||
{
|
||||
// redraw row where Playback cursor was (in case there's two or more drags before playback.update())
|
||||
pianoRoll.redrawRow(lastCursor);
|
||||
bookmarks.redrawChangedBookmarks(lastCursor);
|
||||
//pianoRoll.redrawRow(lastCursor);
|
||||
bookmarks->redrawChangedBookmarks(lastCursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,19 +495,21 @@ bool PLAYBACK::setPlaybackAboveOrToFrame(int frame, bool forceStateReload)
|
|||
{
|
||||
bool state_changed = false;
|
||||
// search backwards for an earlier frame with valid savestate
|
||||
int i = greenzone.getSize() - 1;
|
||||
int i = greenzone->getSize() - 1;
|
||||
if (i > frame)
|
||||
{
|
||||
i = frame;
|
||||
}
|
||||
for (; i >= 0; i--)
|
||||
{
|
||||
if (!forceStateReload && !state_changed && i == currFrameCounter)
|
||||
{
|
||||
// we can remain at current game state
|
||||
break;
|
||||
} else if (!greenzone.isSavestateEmpty(i))
|
||||
} else if (!greenzone->isSavestateEmpty(i))
|
||||
{
|
||||
state_changed = true; // after we once tried loading a savestate, we cannot use currFrameCounter state anymore, because the game state might have been corrupted by this loading attempt
|
||||
if (greenzone.loadSavestateOfFrame(i))
|
||||
if (greenzone->loadSavestateOfFrame(i))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +527,9 @@ void PLAYBACK::setLastPosition(int frame)
|
|||
if ((lastPositionFrame - 1 < frame) || (lastPositionFrame - 1 >= frame && !lastPositionIsStable))
|
||||
{
|
||||
if (lastPositionFrame)
|
||||
pianoRoll.redrawRow(lastPositionFrame - 1);
|
||||
{
|
||||
//pianoRoll.redrawRow(lastPositionFrame - 1);
|
||||
}
|
||||
lastPositionFrame = frame + 1;
|
||||
lastPositionIsStable = true;
|
||||
}
|
||||
|
@ -540,7 +553,7 @@ int PLAYBACK::getFlashingPauseFrame()
|
|||
|
||||
void PLAYBACK::setProgressbar(int a, int b)
|
||||
{
|
||||
SendMessage(hwndProgressbar, PBM_SETPOS, PROGRESSBAR_WIDTH * a / b, 0);
|
||||
//SendMessage(hwndProgressbar, PBM_SETPOS, PROGRESSBAR_WIDTH * a / b, 0);
|
||||
}
|
||||
void PLAYBACK::cancelSeeking()
|
||||
{
|
||||
|
@ -548,80 +561,80 @@ void PLAYBACK::cancelSeeking()
|
|||
stopSeeking();
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
extern PLAYBACK playback;
|
||||
extern SELECTION selection;
|
||||
switch(msg)
|
||||
{
|
||||
case WM_SETFOCUS:
|
||||
{
|
||||
markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_UPPER;
|
||||
// enable editing
|
||||
SendMessage(playback.hwndPlaybackMarkerEditField, EM_SETREADONLY, false, 0);
|
||||
// disable FCEUX keyboard
|
||||
disableGeneralKeyboardInput();
|
||||
break;
|
||||
}
|
||||
case WM_KILLFOCUS:
|
||||
{
|
||||
// if we were editing, save and finish editing
|
||||
if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_UPPER)
|
||||
{
|
||||
markersManager.updateEditedMarkerNote();
|
||||
markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_NONE;
|
||||
}
|
||||
// disable editing (make the bg grayed)
|
||||
SendMessage(playback.hwndPlaybackMarkerEditField, EM_SETREADONLY, true, 0);
|
||||
// enable FCEUX keyboard
|
||||
if (taseditorWindow.TASEditorIsInFocus)
|
||||
enableGeneralKeyboardInput();
|
||||
break;
|
||||
}
|
||||
case WM_CHAR:
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_UPPER)
|
||||
{
|
||||
switch(wParam)
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
// revert text to original note text
|
||||
SetWindowText(playback.hwndPlaybackMarkerEditField, markersManager.getNoteCopy(playback.displayedMarkerNumber).c_str());
|
||||
SetFocus(pianoRoll.hwndList);
|
||||
return 0;
|
||||
case VK_RETURN:
|
||||
// exit and save text changes
|
||||
SetFocus(pianoRoll.hwndList);
|
||||
return 0;
|
||||
case VK_TAB:
|
||||
{
|
||||
// switch to lower edit control (also exit and save text changes)
|
||||
SetFocus(selection.hwndSelectionMarkerEditField);
|
||||
// scroll to the Marker
|
||||
if (taseditorConfig.followMarkerNoteContext)
|
||||
pianoRoll.followMarker(selection.displayedMarkerNumber);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
{
|
||||
playback.handleMiddleButtonClick();
|
||||
return 0;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
// scroll to the Marker
|
||||
if (taseditorConfig.followMarkerNoteContext)
|
||||
pianoRoll.followMarker(playback.displayedMarkerNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CallWindowProc(playbackMarkerEdit_oldWndproc, hWnd, msg, wParam, lParam);
|
||||
}
|
||||
//LRESULT APIENTRY UpperMarkerEditWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
//{
|
||||
// extern PLAYBACK playback;
|
||||
// extern SELECTION selection;
|
||||
// switch(msg)
|
||||
// {
|
||||
// case WM_SETFOCUS:
|
||||
// {
|
||||
// markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_UPPER;
|
||||
// // enable editing
|
||||
// SendMessage(playback.hwndPlaybackMarkerEditField, EM_SETREADONLY, false, 0);
|
||||
// // disable FCEUX keyboard
|
||||
// disableGeneralKeyboardInput();
|
||||
// break;
|
||||
// }
|
||||
// case WM_KILLFOCUS:
|
||||
// {
|
||||
// // if we were editing, save and finish editing
|
||||
// if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_UPPER)
|
||||
// {
|
||||
// markersManager.updateEditedMarkerNote();
|
||||
// markersManager.markerNoteEditMode = MARKER_NOTE_EDIT_NONE;
|
||||
// }
|
||||
// // disable editing (make the bg grayed)
|
||||
// SendMessage(playback.hwndPlaybackMarkerEditField, EM_SETREADONLY, true, 0);
|
||||
// // enable FCEUX keyboard
|
||||
// if (taseditorWindow.TASEditorIsInFocus)
|
||||
// enableGeneralKeyboardInput();
|
||||
// break;
|
||||
// }
|
||||
// case WM_CHAR:
|
||||
// case WM_KEYDOWN:
|
||||
// {
|
||||
// if (markersManager.markerNoteEditMode == MARKER_NOTE_EDIT_UPPER)
|
||||
// {
|
||||
// switch(wParam)
|
||||
// {
|
||||
// case VK_ESCAPE:
|
||||
// // revert text to original note text
|
||||
// SetWindowText(playback.hwndPlaybackMarkerEditField, markersManager.getNoteCopy(playback.displayedMarkerNumber).c_str());
|
||||
// SetFocus(pianoRoll.hwndList);
|
||||
// return 0;
|
||||
// case VK_RETURN:
|
||||
// // exit and save text changes
|
||||
// SetFocus(pianoRoll.hwndList);
|
||||
// return 0;
|
||||
// case VK_TAB:
|
||||
// {
|
||||
// // switch to lower edit control (also exit and save text changes)
|
||||
// SetFocus(selection.hwndSelectionMarkerEditField);
|
||||
// // scroll to the Marker
|
||||
// if (taseditorConfig.followMarkerNoteContext)
|
||||
// pianoRoll.followMarker(selection.displayedMarkerNumber);
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case WM_MBUTTONDOWN:
|
||||
// case WM_MBUTTONDBLCLK:
|
||||
// {
|
||||
// playback.handleMiddleButtonClick();
|
||||
// return 0;
|
||||
// }
|
||||
// case WM_LBUTTONDOWN:
|
||||
// case WM_RBUTTONDOWN:
|
||||
// {
|
||||
// // scroll to the Marker
|
||||
// if (taseditorConfig.followMarkerNoteContext)
|
||||
// pianoRoll.followMarker(playback.displayedMarkerNumber);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return CallWindowProc(playbackMarkerEdit_oldWndproc, hWnd, msg, wParam, lParam);
|
||||
//}
|
||||
|
||||
|
|
|
@ -16,22 +16,22 @@ Recorder - Tool for Input recording
|
|||
* stores resources: ids and names of multitracking modes, suffixes for TAS Editor window caption
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include "taseditor_project.h"
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
extern int joysticksPerFrame[INPUT_TYPES_TOTAL];
|
||||
|
||||
extern uint32 GetGamepadPressedImmediate();
|
||||
extern int getInputType(MovieData& md);
|
||||
|
||||
extern char lagFlag;
|
||||
|
||||
extern TASEDITOR_CONFIG taseditorConfig;
|
||||
extern TASEDITOR_WINDOW taseditorWindow;
|
||||
extern BOOKMARKS bookmarks;
|
||||
extern HISTORY history;
|
||||
extern GREENZONE greenzone;
|
||||
extern PIANO_ROLL pianoRoll;
|
||||
extern EDITOR editor;
|
||||
//extern TASEDITOR_CONFIG taseditorConfig;
|
||||
//extern TASEDITOR_WINDOW taseditorWindow;
|
||||
//extern BOOKMARKS bookmarks;
|
||||
//extern HISTORY history;
|
||||
//extern GREENZONE greenzone;
|
||||
//extern PIANO_ROLL pianoRoll;
|
||||
//extern EDITOR editor;
|
||||
|
||||
// resources
|
||||
const char recordingCheckbox[11] = " Recording";
|
||||
|
@ -53,12 +53,12 @@ RECORDER::RECORDER()
|
|||
|
||||
void RECORDER::init()
|
||||
{
|
||||
hwndRecordingCheckbox = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RECORDING);
|
||||
hwndRadioButtonRecordAll = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_ALL);
|
||||
hwndRadioButtonRecord1P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_1P);
|
||||
hwndRadioButtonRecord2P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_2P);
|
||||
hwndRadioButtonRecord3P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_3P);
|
||||
hwndRadioButtonRecord4P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_4P);
|
||||
//hwndRecordingCheckbox = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RECORDING);
|
||||
//hwndRadioButtonRecordAll = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_ALL);
|
||||
//hwndRadioButtonRecord1P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_1P);
|
||||
//hwndRadioButtonRecord2P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_2P);
|
||||
//hwndRadioButtonRecord3P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_3P);
|
||||
//hwndRadioButtonRecord4P = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_RADIO_4P);
|
||||
oldMultitrackRecordingJoypadNumber = multitrackRecordingJoypadNumber;
|
||||
oldCurrentPattern = oldPatternOffset = 0;
|
||||
mustIncreasePatternOffset = false;
|
||||
|
@ -76,80 +76,92 @@ void RECORDER::reset()
|
|||
mustIncreasePatternOffset = false;
|
||||
uncheckRecordingRadioButtons();
|
||||
recheckRecordingRadioButtons();
|
||||
switch (getInputType(currMovieData))
|
||||
{
|
||||
case INPUT_TYPE_FOURSCORE:
|
||||
{
|
||||
// enable all 4 radiobuttons
|
||||
EnableWindow(hwndRadioButtonRecord1P, true);
|
||||
EnableWindow(hwndRadioButtonRecord2P, true);
|
||||
EnableWindow(hwndRadioButtonRecord3P, true);
|
||||
EnableWindow(hwndRadioButtonRecord4P, true);
|
||||
break;
|
||||
}
|
||||
case INPUT_TYPE_2P:
|
||||
{
|
||||
// enable radiobuttons 1 and 2
|
||||
EnableWindow(hwndRadioButtonRecord1P, true);
|
||||
EnableWindow(hwndRadioButtonRecord2P, true);
|
||||
// disable radiobuttons 3 and 4
|
||||
EnableWindow(hwndRadioButtonRecord3P, false);
|
||||
EnableWindow(hwndRadioButtonRecord4P, false);
|
||||
break;
|
||||
}
|
||||
case INPUT_TYPE_1P:
|
||||
{
|
||||
// enable radiobutton 1
|
||||
EnableWindow(hwndRadioButtonRecord1P, true);
|
||||
// disable radiobuttons 2, 3 and 4
|
||||
EnableWindow(hwndRadioButtonRecord2P, false);
|
||||
EnableWindow(hwndRadioButtonRecord3P, false);
|
||||
EnableWindow(hwndRadioButtonRecord4P, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//switch (getInputType(currMovieData))
|
||||
//{
|
||||
// case INPUT_TYPE_FOURSCORE:
|
||||
// {
|
||||
// // enable all 4 radiobuttons
|
||||
// EnableWindow(hwndRadioButtonRecord1P, true);
|
||||
// EnableWindow(hwndRadioButtonRecord2P, true);
|
||||
// EnableWindow(hwndRadioButtonRecord3P, true);
|
||||
// EnableWindow(hwndRadioButtonRecord4P, true);
|
||||
// break;
|
||||
// }
|
||||
// case INPUT_TYPE_2P:
|
||||
// {
|
||||
// // enable radiobuttons 1 and 2
|
||||
// EnableWindow(hwndRadioButtonRecord1P, true);
|
||||
// EnableWindow(hwndRadioButtonRecord2P, true);
|
||||
// // disable radiobuttons 3 and 4
|
||||
// EnableWindow(hwndRadioButtonRecord3P, false);
|
||||
// EnableWindow(hwndRadioButtonRecord4P, false);
|
||||
// break;
|
||||
// }
|
||||
// case INPUT_TYPE_1P:
|
||||
// {
|
||||
// // enable radiobutton 1
|
||||
// EnableWindow(hwndRadioButtonRecord1P, true);
|
||||
// // disable radiobuttons 2, 3 and 4
|
||||
// EnableWindow(hwndRadioButtonRecord2P, false);
|
||||
// EnableWindow(hwndRadioButtonRecord3P, false);
|
||||
// EnableWindow(hwndRadioButtonRecord4P, false);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
void RECORDER::update()
|
||||
{
|
||||
// update window caption if needed
|
||||
if (oldStateOfMovieReadonly != movie_readonly || oldMultitrackRecordingJoypadNumber != multitrackRecordingJoypadNumber)
|
||||
taseditorWindow.updateCaption();
|
||||
{
|
||||
//taseditorWindow.updateCaption();
|
||||
}
|
||||
// update Bookmarks/Branches groupbox caption if needed
|
||||
if (taseditorConfig.oldControlSchemeForBranching && oldStateOfMovieReadonly != movie_readonly)
|
||||
bookmarks.redrawBookmarksSectionCaption();
|
||||
if (taseditorConfig->oldControlSchemeForBranching && oldStateOfMovieReadonly != movie_readonly)
|
||||
{
|
||||
bookmarks->redrawBookmarksSectionCaption();
|
||||
}
|
||||
// update "Recording" checkbox state
|
||||
if (oldStateOfMovieReadonly != movie_readonly)
|
||||
{
|
||||
Button_SetCheck(hwndRecordingCheckbox, movie_readonly?BST_UNCHECKED : BST_CHECKED);
|
||||
//Button_SetCheck(hwndRecordingCheckbox, movie_readonly?BST_UNCHECKED : BST_CHECKED);
|
||||
oldStateOfMovieReadonly = movie_readonly;
|
||||
if (movie_readonly)
|
||||
{
|
||||
stateWasLoadedInReadWriteMode = false;
|
||||
}
|
||||
}
|
||||
// reset pattern_offset if current_pattern has changed
|
||||
if (oldCurrentPattern != taseditorConfig.currentPattern)
|
||||
if (oldCurrentPattern != taseditorConfig->currentPattern)
|
||||
{
|
||||
patternOffset = 0;
|
||||
}
|
||||
// increase pattern_offset if needed
|
||||
if (mustIncreasePatternOffset)
|
||||
{
|
||||
mustIncreasePatternOffset = false;
|
||||
if (!taseditorConfig.autofirePatternSkipsLag || lagFlag == 0)
|
||||
if (!taseditorConfig->autofirePatternSkipsLag || lagFlag == 0)
|
||||
{
|
||||
patternOffset++;
|
||||
if (patternOffset >= (int)editor.patterns[oldCurrentPattern].size())
|
||||
patternOffset -= editor.patterns[oldCurrentPattern].size();
|
||||
//if (patternOffset >= (int)editor.patterns[oldCurrentPattern].size())
|
||||
// patternOffset -= editor.patterns[oldCurrentPattern].size();
|
||||
}
|
||||
}
|
||||
// update "Recording" checkbox text if something changed in pattern
|
||||
if (oldCurrentPattern != taseditorConfig.currentPattern || oldPatternOffset != patternOffset)
|
||||
if (oldCurrentPattern != taseditorConfig->currentPattern || oldPatternOffset != patternOffset)
|
||||
{
|
||||
oldCurrentPattern = taseditorConfig.currentPattern;
|
||||
oldCurrentPattern = taseditorConfig->currentPattern;
|
||||
oldPatternOffset = patternOffset;
|
||||
if (!taseditorConfig.recordingUsePattern || editor.patterns[oldCurrentPattern][patternOffset])
|
||||
if (!taseditorConfig->recordingUsePattern /*|| editor.patterns[oldCurrentPattern][patternOffset] */)
|
||||
{
|
||||
// either not using Patterns or current pattern has 1 in current offset
|
||||
SetWindowText(hwndRecordingCheckbox, recordingCheckbox);
|
||||
//SetWindowText(hwndRecordingCheckbox, recordingCheckbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
// current pattern has 0 in current offset, this means next recorded frame will be blank
|
||||
SetWindowText(hwndRecordingCheckbox, recordingCheckboxBlankPattern);
|
||||
//SetWindowText(hwndRecordingCheckbox, recordingCheckboxBlankPattern);
|
||||
}
|
||||
}
|
||||
// update recording radio buttons if user changed multitrack_recording_joypad
|
||||
if (oldMultitrackRecordingJoypadNumber != multitrackRecordingJoypadNumber)
|
||||
|
@ -165,7 +177,7 @@ void RECORDER::update()
|
|||
oldJoyData[2] = currentJoypadData[2];
|
||||
oldJoyData[3] = currentJoypadData[3];
|
||||
// fill current_joy data for Piano Roll header lights
|
||||
uint32 joypads = GetGamepadPressedImmediate();
|
||||
uint32 joypads = 0; //GetGamepadPressedImmediate();
|
||||
currentJoypadData[0] = (joypads & 0xFF);
|
||||
currentJoypadData[1] = ((joypads >> 8) & 0xFF);
|
||||
currentJoypadData[2] = ((joypads >> 16) & 0xFF);
|
||||
|
@ -175,66 +187,74 @@ void RECORDER::update()
|
|||
{
|
||||
int joy = multitrackRecordingJoypadNumber - 1;
|
||||
// substitute target joypad with 1p joypad
|
||||
if (multitrackRecordingJoypadNumber > MULTITRACK_RECORDING_1P && taseditorConfig.use1PKeysForAllSingleRecordings)
|
||||
if (multitrackRecordingJoypadNumber > MULTITRACK_RECORDING_1P && taseditorConfig->use1PKeysForAllSingleRecordings)
|
||||
{
|
||||
currentJoypadData[joy] = currentJoypadData[0];
|
||||
}
|
||||
// clear all other joypads (pressing them does not count)
|
||||
for (int i = 0; i < num_joys; ++i)
|
||||
{
|
||||
if (i != joy)
|
||||
{
|
||||
currentJoypadData[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// call ColumnSet if needed
|
||||
if (taseditorConfig.useInputKeysForColumnSet && movie_readonly && taseditorWindow.TASEditorIsInFocus)
|
||||
if (taseditorConfig->useInputKeysForColumnSet && movie_readonly && 0 /*taseditorWindow.TASEditorIsInFocus*/)
|
||||
{
|
||||
// if Ctrl or Shift is held, do not call ColumnSet, because maybe this is accelerator
|
||||
if ((GetAsyncKeyState(VK_CONTROL) >= 0) && (GetAsyncKeyState(VK_SHIFT) >= 0))
|
||||
{
|
||||
bool alt_pressed = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0);
|
||||
for (int joy = 0; joy < num_joys; ++joy)
|
||||
{
|
||||
for (int button = 0; button < NUM_JOYPAD_BUTTONS; ++button)
|
||||
{
|
||||
// if the button was pressed right now
|
||||
if ((currentJoypadData[joy] & (1 << button)) && !(oldJoyData[joy] & (1 << button)))
|
||||
pianoRoll.handleColumnSet(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, alt_pressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if ((GetAsyncKeyState(VK_CONTROL) >= 0) && (GetAsyncKeyState(VK_SHIFT) >= 0))
|
||||
//{
|
||||
// bool alt_pressed = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0);
|
||||
// for (int joy = 0; joy < num_joys; ++joy)
|
||||
// {
|
||||
// for (int button = 0; button < NUM_JOYPAD_BUTTONS; ++button)
|
||||
// {
|
||||
// // if the button was pressed right now
|
||||
// if ((currentJoypadData[joy] & (1 << button)) && !(oldJoyData[joy] & (1 << button)))
|
||||
// {
|
||||
// //pianoRoll.handleColumnSet(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, alt_pressed);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------
|
||||
void RECORDER::uncheckRecordingRadioButtons()
|
||||
{
|
||||
Button_SetCheck(hwndRadioButtonRecordAll, BST_UNCHECKED);
|
||||
Button_SetCheck(hwndRadioButtonRecord1P, BST_UNCHECKED);
|
||||
Button_SetCheck(hwndRadioButtonRecord2P, BST_UNCHECKED);
|
||||
Button_SetCheck(hwndRadioButtonRecord3P, BST_UNCHECKED);
|
||||
Button_SetCheck(hwndRadioButtonRecord4P, BST_UNCHECKED);
|
||||
//Button_SetCheck(hwndRadioButtonRecordAll, BST_UNCHECKED);
|
||||
//Button_SetCheck(hwndRadioButtonRecord1P, BST_UNCHECKED);
|
||||
//Button_SetCheck(hwndRadioButtonRecord2P, BST_UNCHECKED);
|
||||
//Button_SetCheck(hwndRadioButtonRecord3P, BST_UNCHECKED);
|
||||
//Button_SetCheck(hwndRadioButtonRecord4P, BST_UNCHECKED);
|
||||
}
|
||||
void RECORDER::recheckRecordingRadioButtons()
|
||||
{
|
||||
oldMultitrackRecordingJoypadNumber = multitrackRecordingJoypadNumber;
|
||||
switch(multitrackRecordingJoypadNumber)
|
||||
{
|
||||
case MULTITRACK_RECORDING_ALL:
|
||||
Button_SetCheck(hwndRadioButtonRecordAll, BST_CHECKED);
|
||||
break;
|
||||
case MULTITRACK_RECORDING_1P:
|
||||
Button_SetCheck(hwndRadioButtonRecord1P, BST_CHECKED);
|
||||
break;
|
||||
case MULTITRACK_RECORDING_2P:
|
||||
Button_SetCheck(hwndRadioButtonRecord2P, BST_CHECKED);
|
||||
break;
|
||||
case MULTITRACK_RECORDING_3P:
|
||||
Button_SetCheck(hwndRadioButtonRecord3P, BST_CHECKED);
|
||||
break;
|
||||
case MULTITRACK_RECORDING_4P:
|
||||
Button_SetCheck(hwndRadioButtonRecord4P, BST_CHECKED);
|
||||
break;
|
||||
default:
|
||||
multitrackRecordingJoypadNumber = MULTITRACK_RECORDING_ALL;
|
||||
Button_SetCheck(hwndRadioButtonRecordAll, BST_CHECKED);
|
||||
break;
|
||||
}
|
||||
//oldMultitrackRecordingJoypadNumber = multitrackRecordingJoypadNumber;
|
||||
//switch(multitrackRecordingJoypadNumber)
|
||||
//{
|
||||
//case MULTITRACK_RECORDING_ALL:
|
||||
// Button_SetCheck(hwndRadioButtonRecordAll, BST_CHECKED);
|
||||
// break;
|
||||
//case MULTITRACK_RECORDING_1P:
|
||||
// Button_SetCheck(hwndRadioButtonRecord1P, BST_CHECKED);
|
||||
// break;
|
||||
//case MULTITRACK_RECORDING_2P:
|
||||
// Button_SetCheck(hwndRadioButtonRecord2P, BST_CHECKED);
|
||||
// break;
|
||||
//case MULTITRACK_RECORDING_3P:
|
||||
// Button_SetCheck(hwndRadioButtonRecord3P, BST_CHECKED);
|
||||
// break;
|
||||
//case MULTITRACK_RECORDING_4P:
|
||||
// Button_SetCheck(hwndRadioButtonRecord4P, BST_CHECKED);
|
||||
// break;
|
||||
//default:
|
||||
// multitrackRecordingJoypadNumber = MULTITRACK_RECORDING_ALL;
|
||||
// Button_SetCheck(hwndRadioButtonRecordAll, BST_CHECKED);
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
void RECORDER::recordInput()
|
||||
|
@ -245,22 +265,24 @@ void RECORDER::recordInput()
|
|||
// take previous values from current snapshot, new Input from current movie
|
||||
for (int i = 0; i < num_joys; ++i)
|
||||
{
|
||||
oldJoyData[i] = history.getCurrentSnapshot().inputlog.getJoystickData(currFrameCounter, i);
|
||||
if (!taseditorConfig.recordingUsePattern || editor.patterns[oldCurrentPattern][patternOffset])
|
||||
newJoyData[i] = currMovieData.records[currFrameCounter].joysticks[i];
|
||||
else
|
||||
newJoyData[i] = 0; // blank
|
||||
oldJoyData[i] = history->getCurrentSnapshot().inputlog.getJoystickData(currFrameCounter, i);
|
||||
//if (!taseditorConfig->recordingUsePattern || editor.patterns[oldCurrentPattern][patternOffset])
|
||||
// newJoyData[i] = currMovieData.records[currFrameCounter].joysticks[i];
|
||||
//else
|
||||
// newJoyData[i] = 0; // blank
|
||||
}
|
||||
if (taseditorConfig.recordingUsePattern)
|
||||
if (taseditorConfig->recordingUsePattern)
|
||||
{
|
||||
// postpone incrementing pattern_offset to the end of the frame (when lagFlag will be known)
|
||||
mustIncreasePatternOffset = true;
|
||||
}
|
||||
// combine old and new data (superimpose) and filter out joystics that should not be recorded
|
||||
if (multitrackRecordingJoypadNumber == MULTITRACK_RECORDING_ALL)
|
||||
{
|
||||
for (int i = num_joys-1; i >= 0; i--)
|
||||
{
|
||||
// superimpose (bitwise OR) if needed
|
||||
if (taseditorConfig.superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig.superimpose == SUPERIMPOSE_INDETERMINATE && newJoyData[i] == 0))
|
||||
if (taseditorConfig->superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig->superimpose == SUPERIMPOSE_INDETERMINATE && newJoyData[i] == 0))
|
||||
newJoyData[i] |= oldJoyData[i];
|
||||
// change this joystick
|
||||
currMovieData.records[currFrameCounter].joysticks[i] = newJoyData[i];
|
||||
|
@ -270,18 +292,22 @@ void RECORDER::recordInput()
|
|||
joypad_diff_bits |= (1 << (i + 1)); // bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
|
||||
// set lights for changed buttons
|
||||
for (int button = 0; button < NUM_JOYPAD_BUTTONS; ++button)
|
||||
{
|
||||
if ((newJoyData[i] & (1 << button)) && !(oldJoyData[i] & (1 << button)))
|
||||
pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + i * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
|
||||
{
|
||||
//pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + i * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
int joy = multitrackRecordingJoypadNumber - 1;
|
||||
// substitute target joypad with 1p joypad
|
||||
if (multitrackRecordingJoypadNumber > MULTITRACK_RECORDING_1P && taseditorConfig.use1PKeysForAllSingleRecordings)
|
||||
if (multitrackRecordingJoypadNumber > MULTITRACK_RECORDING_1P && taseditorConfig->use1PKeysForAllSingleRecordings)
|
||||
newJoyData[joy] = newJoyData[0];
|
||||
// superimpose (bitwise OR) if needed
|
||||
if (taseditorConfig.superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig.superimpose == SUPERIMPOSE_INDETERMINATE && newJoyData[joy] == 0))
|
||||
if (taseditorConfig->superimpose == SUPERIMPOSE_CHECKED || (taseditorConfig->superimpose == SUPERIMPOSE_INDETERMINATE && newJoyData[joy] == 0))
|
||||
newJoyData[joy] |= oldJoyData[joy];
|
||||
// other joysticks should not be changed
|
||||
for (int i = num_joys-1; i >= 0; i--)
|
||||
|
@ -294,13 +320,17 @@ void RECORDER::recordInput()
|
|||
joypad_diff_bits |= (1 << (joy + 1)); // bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
|
||||
// set lights for changed buttons
|
||||
for (int button = 0; button < NUM_JOYPAD_BUTTONS; ++button)
|
||||
{
|
||||
if ((newJoyData[joy] & (1 << button)) && !(oldJoyData[joy] & (1 << button)))
|
||||
pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
|
||||
{
|
||||
//pianoRoll.setLightInHeaderColumn(COLUMN_JOYPAD1_A + joy * NUM_JOYPAD_BUTTONS + button, HEADER_LIGHT_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if new commands were recorded
|
||||
if (currMovieData.records[currFrameCounter].commands != history.getCurrentSnapshot().inputlog.getCommandsData(currFrameCounter))
|
||||
if (currMovieData.records[currFrameCounter].commands != history->getCurrentSnapshot().inputlog.getCommandsData(currFrameCounter))
|
||||
{
|
||||
changes_made = true;
|
||||
joypad_diff_bits |= 1; // bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
|
||||
|
@ -309,8 +339,8 @@ void RECORDER::recordInput()
|
|||
// register changes
|
||||
if (changes_made)
|
||||
{
|
||||
history.registerRecording(currFrameCounter, joypad_diff_bits);
|
||||
greenzone.invalidate(currFrameCounter);
|
||||
history->registerRecording(currFrameCounter, joypad_diff_bits);
|
||||
greenzone->invalidate(currFrameCounter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
typedef std::set<int> RowsSelection;
|
||||
|
||||
#define SELECTION_ID_LEN 10
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
/* ---------------------------------------------------------------------------------
|
||||
Implementation file of Snapshot class
|
||||
Copyright (c) 2011-2013 AnS
|
||||
|
||||
(The MIT License)
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------------
|
||||
Snapshot - Snapshot of all edited data
|
||||
|
||||
* stores the data of specific snapshot of the movie: InputLog, LagLog, Markers at the moment of creating the snapshot, keyframe, start and end frame of operation, type of operation and description of the snapshot (including the time of creation)
|
||||
* also stores info about sequential recording/drawing of Input
|
||||
* streamlines snapshot creation: copying Input from movie data, copying LagLog from Greenzone, copying Markers from Markers Manager, setting time of creation
|
||||
* streamlines restoring Markers data from snapshot
|
||||
* saves and loads stored data from a project file. On error: sends warning to caller
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include <zlib.h>
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
//extern MARKERS_MANAGER markersManager;
|
||||
//extern SELECTION selection;
|
||||
//extern GREENZONE greenzone;
|
||||
|
||||
extern int getInputType(MovieData& md);
|
||||
|
||||
SNAPSHOT::SNAPSHOT()
|
||||
{
|
||||
}
|
||||
|
||||
void SNAPSHOT::init(MovieData& md, LAGLOG& lagLog, bool hotchanges, int enforceInputType)
|
||||
{
|
||||
inputlog.init(md, hotchanges, enforceInputType);
|
||||
|
||||
// make a copy of the given laglog
|
||||
laglog = lagLog;
|
||||
laglog.resetCompressedStatus();
|
||||
|
||||
// take a copy of markers_manager.markers
|
||||
markersManager->makeCopyOfCurrentMarkersTo(markers);
|
||||
if ((int)markers.markersArray.size() < inputlog.size)
|
||||
markers.markersArray.resize(inputlog.size);
|
||||
|
||||
// save current time to description
|
||||
time_t raw_time;
|
||||
time(&raw_time);
|
||||
struct tm * timeinfo = localtime(&raw_time);
|
||||
strftime(description, 10, "%H:%M:%S", timeinfo);
|
||||
}
|
||||
|
||||
void SNAPSHOT::reinit(MovieData& md, LAGLOG& lagLog, bool hotchanges, int frameOfChanges)
|
||||
{
|
||||
inputlog.reinit(md, hotchanges, frameOfChanges);
|
||||
|
||||
// do not copy laglog, because it will be updated later, when Greenzone will sync its data with the current history snapshot
|
||||
|
||||
// Markers are supposed to be the same, because this is consecutive Recording
|
||||
|
||||
// save current time to description
|
||||
time_t raw_time;
|
||||
time(&raw_time);
|
||||
struct tm * timeinfo = localtime(&raw_time);
|
||||
strftime(description, 10, "%H:%M:%S", timeinfo);
|
||||
}
|
||||
|
||||
bool SNAPSHOT::areMarkersDifferentFromCurrentMarkers()
|
||||
{
|
||||
return markersManager->checkMarkersDiff(markers);
|
||||
}
|
||||
void SNAPSHOT::copyToCurrentMarkers()
|
||||
{
|
||||
markersManager->restoreMarkersFromCopy(markers);
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------
|
||||
void SNAPSHOT::compressData()
|
||||
{
|
||||
if (!inputlog.isAlreadyCompressed())
|
||||
inputlog.compressData();
|
||||
if (!laglog.isAlreadyCompressed())
|
||||
laglog.compressData();
|
||||
if (!markers.isAalreadyCompressed())
|
||||
markers.compressData();
|
||||
}
|
||||
bool SNAPSHOT::isAlreadyCompressed()
|
||||
{
|
||||
// only consider this snapshot fully compressed when all of InputLog, LagLog and Markers are compressed
|
||||
return (inputlog.isAlreadyCompressed() && laglog.isAlreadyCompressed() && markers.isAalreadyCompressed());
|
||||
}
|
||||
|
||||
void SNAPSHOT::save(EMUFILE *os)
|
||||
{
|
||||
// write vars
|
||||
write32le(keyFrame, os);
|
||||
write32le(startFrame, os);
|
||||
write32le(endFrame, os);
|
||||
write32le(consecutivenessTag, os);
|
||||
write32le(recordedJoypadDifferenceBits, os);
|
||||
write32le(modificationType, os);
|
||||
// write description
|
||||
int len = strlen(description);
|
||||
write8le(len, os);
|
||||
os->fwrite(&description[0], len);
|
||||
// save InputLog data
|
||||
inputlog.save(os);
|
||||
// save LagLog data
|
||||
laglog.save(os);
|
||||
// save Markers data
|
||||
markers.save(os);
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool SNAPSHOT::load(EMUFILE *is)
|
||||
{
|
||||
uint8 tmp;
|
||||
// read vars
|
||||
if (!read32le(&keyFrame, is)) return true;
|
||||
if (!read32le(&startFrame, is)) return true;
|
||||
if (!read32le(&endFrame, is)) return true;
|
||||
if (!read32le(&consecutivenessTag, is)) return true;
|
||||
if (!read32le(&recordedJoypadDifferenceBits, is)) return true;
|
||||
if (!read32le(&modificationType, is)) return true;
|
||||
// read description
|
||||
if (!read8le(&tmp, is)) return true;
|
||||
if (tmp >= SNAPSHOT_DESCRIPTION_MAX_LEN) return true;
|
||||
if (is->fread(&description[0], tmp) != tmp) return true;
|
||||
description[tmp] = 0; // add '0' because it wasn't saved in the file
|
||||
// load InputLog data
|
||||
if (inputlog.load(is)) return true;
|
||||
// load LagLog data
|
||||
if (laglog.load(is)) return true;
|
||||
// load Markers data
|
||||
if (markers.load(is)) return true;
|
||||
return false;
|
||||
}
|
||||
bool SNAPSHOT::skipLoad(EMUFILE *is)
|
||||
{
|
||||
uint8 tmp1;
|
||||
// skip vars
|
||||
if (is->fseek(sizeof(int) + // keyframe
|
||||
sizeof(int) + // start_frame
|
||||
sizeof(int) + // end_frame
|
||||
sizeof(int) + // consecutivenessTag
|
||||
sizeof(int) + // recordedJoypadDifferenceBits
|
||||
sizeof(int) // mod_type
|
||||
, SEEK_CUR)) return true;
|
||||
// skip description
|
||||
if (!read8le(&tmp1, is)) return true;
|
||||
if (tmp1 >= SNAPSHOT_DESCRIPTION_MAX_LEN) return true;
|
||||
if (is->fseek(tmp1, SEEK_CUR) != 0) return true;
|
||||
// skip InputLog data
|
||||
if (inputlog.skipLoad(is)) return true;
|
||||
// skip LagLog data
|
||||
if (laglog.skipLoad(is)) return true;
|
||||
// skip Markers data
|
||||
if (markers.skipLoad(is)) return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Specification file for Snapshot class
|
||||
#pragma once
|
||||
|
||||
#include "Qt/TasEditor/inputlog.h"
|
||||
#include "Qt/TasEditor/laglog.h"
|
||||
#include "Qt/TasEditor/markers.h"
|
||||
|
||||
#define SNAPSHOT_DESCRIPTION_MAX_LEN 100
|
||||
|
||||
class SNAPSHOT
|
||||
{
|
||||
public:
|
||||
SNAPSHOT();
|
||||
void init(MovieData& md, LAGLOG& lagLog, bool hotChanges, int enforceInputType = -1);
|
||||
void reinit(MovieData& md, LAGLOG& lagLog, bool hotChanges, int frameOfChanges); // used when combining consecutive Recordings
|
||||
|
||||
bool areMarkersDifferentFromCurrentMarkers();
|
||||
void copyToCurrentMarkers();
|
||||
|
||||
void compressData();
|
||||
bool isAlreadyCompressed();
|
||||
|
||||
void save(EMUFILE *os);
|
||||
bool load(EMUFILE *is);
|
||||
bool skipLoad(EMUFILE *is);
|
||||
|
||||
// saved data
|
||||
INPUTLOG inputlog;
|
||||
LAGLOG laglog;
|
||||
MARKERS markers;
|
||||
int keyFrame; // for jumping when making undo
|
||||
int startFrame; // for consecutive Draws and "Related items highlighting"
|
||||
int endFrame; // for consecutive Draws and "Related items highlighting"
|
||||
int consecutivenessTag; // for consecutive Recordings and Draws
|
||||
uint32 recordedJoypadDifferenceBits; // for consecutive Recordings: bit 0 = Commands, bit 1 = Joypad 1, bit 2 = Joypad 2, bit 3 = Joypad 3, bit 4 = Joypad 4
|
||||
int modificationType;
|
||||
char description[SNAPSHOT_DESCRIPTION_MAX_LEN];
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,502 @@
|
|||
/* ---------------------------------------------------------------------------------
|
||||
Implementation file of TASEDITOR_LUA class
|
||||
Copyright (c) 2011-2013 AnS
|
||||
|
||||
(The MIT License)
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------------
|
||||
Lua - Manager of Lua features
|
||||
[Single instance]
|
||||
|
||||
* implements logic of all functions of "taseditor" Lua library
|
||||
* stores the list of pending Input changes
|
||||
* on demand: (from FCEUX Lua engine) updates "Run function" button
|
||||
* stores resources: ids of joypads for Input changes, max length of a name for applychanges(), default caption for "Run function" button
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
//extern TASEDITOR_CONFIG taseditorConfig;
|
||||
//extern TASEDITOR_WINDOW taseditorWindow;
|
||||
//extern HISTORY history;
|
||||
//extern MARKERS_MANAGER markersManager;
|
||||
//extern BOOKMARKS bookmarks;
|
||||
//extern BRANCHES branches;
|
||||
//extern RECORDER recorder;
|
||||
//extern PLAYBACK playback;
|
||||
//extern GREENZONE greenzone;
|
||||
//extern PIANO_ROLL pianoRoll;
|
||||
//extern SELECTION selection;
|
||||
|
||||
extern void TaseditorDisableManualFunctionIfNeeded();
|
||||
|
||||
const char defaultRunFunctionCaption[] = "Run function";
|
||||
|
||||
TASEDITOR_LUA::TASEDITOR_LUA()
|
||||
{
|
||||
}
|
||||
|
||||
void TASEDITOR_LUA::init()
|
||||
{
|
||||
pending_changes.resize(0);
|
||||
//hwndRunFunctionButton = GetDlgItem(taseditorWindow.hwndTASEditor, TASEDITOR_RUN_MANUAL);
|
||||
reset();
|
||||
}
|
||||
void TASEDITOR_LUA::reset()
|
||||
{
|
||||
TaseditorDisableManualFunctionIfNeeded();
|
||||
}
|
||||
void TASEDITOR_LUA::update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TASEDITOR_LUA::enableRunFunction(const char* caption)
|
||||
{
|
||||
//if (caption)
|
||||
// SetWindowText(hwndRunFunctionButton, caption);
|
||||
//else
|
||||
// SetWindowText(hwndRunFunctionButton, defaultRunFunctionCaption);
|
||||
//EnableWindow(hwndRunFunctionButton, true);
|
||||
}
|
||||
void TASEDITOR_LUA::disableRunFunction()
|
||||
{
|
||||
//SetWindowText(hwndRunFunctionButton, defaultRunFunctionCaption);
|
||||
//EnableWindow(hwndRunFunctionButton, false);
|
||||
}
|
||||
|
||||
void TASEDITOR_LUA::insertAndDeleteRowsInSnaphot(SNAPSHOT& snapshot)
|
||||
{
|
||||
int size = pending_changes.size();
|
||||
if (size)
|
||||
{
|
||||
// apply changes to given snapshot (only insertion/deletion)
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
if (pending_changes[i].frame >= snapshot.inputlog.size)
|
||||
{
|
||||
// expand snapshot to fit the frame
|
||||
snapshot.inputlog.insertFrames(-1, 1 + pending_changes[i].frame - snapshot.inputlog.size);
|
||||
}
|
||||
switch (pending_changes[i].type)
|
||||
{
|
||||
case LUA_CHANGE_TYPE_INSERTFRAMES:
|
||||
{
|
||||
snapshot.inputlog.insertFrames(pending_changes[i].frame, pending_changes[i].data);
|
||||
break;
|
||||
}
|
||||
case LUA_CHANGE_TYPE_DELETEFRAMES:
|
||||
{
|
||||
for (int t = pending_changes[i].data; t > 0; t--)
|
||||
{
|
||||
if (pending_changes[i].frame < snapshot.inputlog.size)
|
||||
snapshot.inputlog.eraseFrame(pending_changes[i].frame);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Lua functions of taseditor library
|
||||
|
||||
// bool taseditor.engaged()
|
||||
bool TASEDITOR_LUA::engaged()
|
||||
{
|
||||
return FCEUMOV_Mode(MOVIEMODE_TASEDITOR);
|
||||
}
|
||||
|
||||
// bool taseditor.markedframe(int frame)
|
||||
bool TASEDITOR_LUA::markedframe(int frame)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
return markersManager->getMarkerAtFrame(frame) != 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// int taseditor.getmarker(int frame)
|
||||
int TASEDITOR_LUA::getmarker(int frame)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
return markersManager->getMarkerAboveFrame(frame);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// int taseditor.setmarker(int frame)
|
||||
int TASEDITOR_LUA::setmarker(int frame)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
int marker_id = markersManager->getMarkerAtFrame(frame);
|
||||
if (!marker_id)
|
||||
{
|
||||
marker_id = markersManager->setMarkerAtFrame(frame);
|
||||
if (marker_id)
|
||||
{
|
||||
// new Marker was created - register changes in TAS Editor
|
||||
history->registerMarkersChange(MODTYPE_LUA_MARKER_SET, frame);
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
//pianoRoll.redrawRow(frame);
|
||||
//pianoRoll.setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX);
|
||||
}
|
||||
}
|
||||
return marker_id;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// taseditor.removemarker(int frame)
|
||||
void TASEDITOR_LUA::removemarker(int frame)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
if (markersManager->getMarkerAtFrame(frame))
|
||||
{
|
||||
markersManager->removeMarkerFromFrame(frame);
|
||||
// Marker was deleted - register changes in TAS Editor
|
||||
history->registerMarkersChange(MODTYPE_LUA_MARKER_REMOVE, frame);
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
//pianoRoll.redrawRow(frame);
|
||||
//pianoRoll.setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// string taseditor.getnote(int index)
|
||||
const char* TASEDITOR_LUA::getnote(int index)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
return strdup(markersManager->getNoteCopy(index).c_str());
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// taseditor.setnote(int index, string newtext)
|
||||
void TASEDITOR_LUA::setnote(int index, const char* newtext)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
// rename only if newtext is different from old text
|
||||
char text[MAX_NOTE_LEN];
|
||||
strncpy(text, newtext, MAX_NOTE_LEN - 1);
|
||||
if (strcmp(markersManager->getNoteCopy(index).c_str(), text))
|
||||
{
|
||||
// text differs from old Note - rename
|
||||
markersManager->setNote(index, text);
|
||||
history->registerMarkersChange(MODTYPE_LUA_MARKER_RENAME, markersManager->getMarkerFrameNumber(index), -1, text);
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// int taseditor.getcurrentbranch()
|
||||
int TASEDITOR_LUA::getcurrentbranch()
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
return branches->getCurrentBranch();
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// string taseditor.getrecordermode()
|
||||
const char* TASEDITOR_LUA::getrecordermode()
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
return recorder->getRecordingMode();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// int taseditor.getsuperimpose()
|
||||
int TASEDITOR_LUA::getsuperimpose()
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
return taseditorConfig->superimpose;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// int taseditor.getlostplayback()
|
||||
int TASEDITOR_LUA::getlostplayback()
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
return playback->getLastPosition();
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// int taseditor.getplaybacktarget()
|
||||
int TASEDITOR_LUA::getplaybacktarget()
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
return playback->getPauseFrame();
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// taseditor.setplayback(int frame)
|
||||
void TASEDITOR_LUA::setplayback(int frame)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
// force reload if sending to the same frame as current frame
|
||||
// but don't trigger lua registered functions
|
||||
playback->jump(frame, true, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
// taseditor.stopseeking()
|
||||
void TASEDITOR_LUA::stopseeking()
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
playback->stopSeeking();
|
||||
}
|
||||
}
|
||||
|
||||
// table taseditor.getselection()
|
||||
void TASEDITOR_LUA::getselection(std::vector<int>& placeholder)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
RowsSelection* current_selection = selection->getCopyOfCurrentRowsSelection();
|
||||
int frames = current_selection->size();
|
||||
if (!frames) return;
|
||||
|
||||
placeholder.resize(frames);
|
||||
RowsSelection::iterator current_selection_end(current_selection->end());
|
||||
int i = 0;
|
||||
for(RowsSelection::iterator it(current_selection->begin()); it != current_selection_end; ++it)
|
||||
{
|
||||
placeholder[i++] = *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// taseditor.setselection(table new_set)
|
||||
void TASEDITOR_LUA::setselection(std::vector<int>& new_set)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
selection->clearAllRowsSelection();
|
||||
for (int i = new_set.size() - 1; i >= 0; i--)
|
||||
{
|
||||
selection->setRowSelection(new_set[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// int taseditor.getinput(int frame, int joypad)
|
||||
int TASEDITOR_LUA::getinput(int frame, int joypad)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
if (frame < 0) return -1;
|
||||
if (frame >= currMovieData.getNumRecords()) return 0;
|
||||
switch (joypad)
|
||||
{
|
||||
case LUA_JOYPAD_COMMANDS:
|
||||
return currMovieData.records[frame].commands;
|
||||
case LUA_JOYPAD_1P:
|
||||
return currMovieData.records[frame].joysticks[0];
|
||||
case LUA_JOYPAD_2P:
|
||||
return currMovieData.records[frame].joysticks[1];
|
||||
case LUA_JOYPAD_3P:
|
||||
return currMovieData.records[frame].joysticks[2];
|
||||
case LUA_JOYPAD_4P:
|
||||
return currMovieData.records[frame].joysticks[3];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// taseditor.submitinputchange(int frame, int joypad, int input)
|
||||
void TASEDITOR_LUA::submitinputchange(int frame, int joypad, int input)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
if (frame >= 0)
|
||||
{
|
||||
if (joypad == LUA_JOYPAD_COMMANDS || joypad == LUA_JOYPAD_1P || joypad == LUA_JOYPAD_2P || joypad == LUA_JOYPAD_3P || joypad == LUA_JOYPAD_4P)
|
||||
{
|
||||
PENDING_CHANGES new_change;
|
||||
new_change.type = LUA_CHANGE_TYPE_INPUTCHANGE;
|
||||
new_change.frame = frame;
|
||||
new_change.joypad = joypad;
|
||||
new_change.data = input;
|
||||
pending_changes.push_back(new_change);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// taseditor.submitinsertframes(int frame, int number)
|
||||
void TASEDITOR_LUA::submitinsertframes(int frame, int number)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
if (frame >= 0 && number > 0)
|
||||
{
|
||||
PENDING_CHANGES new_change;
|
||||
new_change.type = LUA_CHANGE_TYPE_INSERTFRAMES;
|
||||
new_change.frame = frame;
|
||||
new_change.joypad = 0; // doesn't matter in TAS Editor v1.0, whole frame will be inserted
|
||||
new_change.data = number;
|
||||
pending_changes.push_back(new_change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// taseditor.submitdeleteframes(int frame, int number)
|
||||
void TASEDITOR_LUA::submitdeleteframes(int frame, int number)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
if (frame >= 0 && number > 0)
|
||||
{
|
||||
PENDING_CHANGES new_change;
|
||||
new_change.type = LUA_CHANGE_TYPE_DELETEFRAMES;
|
||||
new_change.frame = frame;
|
||||
new_change.joypad = 0; // doesn't matter in TAS Editor v1.0, whole frame will be deleted
|
||||
new_change.data = number;
|
||||
pending_changes.push_back(new_change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// int taseditor.applyinputchanges([string name])
|
||||
int TASEDITOR_LUA::applyinputchanges(const char* name)
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
int size = pending_changes.size();
|
||||
int start_index = currMovieData.getNumRecords() - 1;
|
||||
bool InsertionDeletion_was_made = false;
|
||||
if (size)
|
||||
{
|
||||
// apply changes to current movie data
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
if (pending_changes[i].frame < start_index)
|
||||
{
|
||||
start_index = pending_changes[i].frame;
|
||||
}
|
||||
if (pending_changes[i].frame >= (int)currMovieData.getNumRecords())
|
||||
{
|
||||
// expand movie to fit the frame
|
||||
currMovieData.insertEmpty(-1, 1 + pending_changes[i].frame - currMovieData.getNumRecords());
|
||||
markersManager->update();
|
||||
InsertionDeletion_was_made = true;
|
||||
}
|
||||
switch (pending_changes[i].type)
|
||||
{
|
||||
case LUA_CHANGE_TYPE_INPUTCHANGE:
|
||||
{
|
||||
switch (pending_changes[i].joypad)
|
||||
{
|
||||
case LUA_JOYPAD_COMMANDS:
|
||||
currMovieData.records[pending_changes[i].frame].commands = pending_changes[i].data;
|
||||
break;
|
||||
case LUA_JOYPAD_1P:
|
||||
currMovieData.records[pending_changes[i].frame].joysticks[0] = pending_changes[i].data;
|
||||
break;
|
||||
case LUA_JOYPAD_2P:
|
||||
currMovieData.records[pending_changes[i].frame].joysticks[1] = pending_changes[i].data;
|
||||
break;
|
||||
case LUA_JOYPAD_3P:
|
||||
currMovieData.records[pending_changes[i].frame].joysticks[2] = pending_changes[i].data;
|
||||
break;
|
||||
case LUA_JOYPAD_4P:
|
||||
currMovieData.records[pending_changes[i].frame].joysticks[3] = pending_changes[i].data;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LUA_CHANGE_TYPE_INSERTFRAMES:
|
||||
{
|
||||
InsertionDeletion_was_made = true;
|
||||
currMovieData.insertEmpty(pending_changes[i].frame, pending_changes[i].data);
|
||||
greenzone->lagLog.insertFrame(pending_changes[i].frame, false, pending_changes[i].data);
|
||||
if (taseditorConfig->bindMarkersToInput)
|
||||
{
|
||||
markersManager->insertEmpty(pending_changes[i].frame, pending_changes[i].data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LUA_CHANGE_TYPE_DELETEFRAMES:
|
||||
{
|
||||
InsertionDeletion_was_made = true;
|
||||
for (int t = pending_changes[i].data; t > 0; t--)
|
||||
{
|
||||
if (pending_changes[i].frame < (int)currMovieData.getNumRecords())
|
||||
{
|
||||
currMovieData.eraseRecords(pending_changes[i].frame);
|
||||
}
|
||||
greenzone->lagLog.eraseFrame(pending_changes[i].frame);
|
||||
if (taseditorConfig->bindMarkersToInput)
|
||||
{
|
||||
markersManager->eraseMarker(pending_changes[i].frame);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (taseditorConfig->bindMarkersToInput)
|
||||
{
|
||||
selection->mustFindCurrentMarker = playback->mustFindCurrentMarker = true;
|
||||
}
|
||||
// check if user deleted all frames
|
||||
if (!currMovieData.getNumRecords())
|
||||
{
|
||||
playback->restartPlaybackFromZeroGround();
|
||||
}
|
||||
// reduce Piano Roll
|
||||
//pianoRoll.updateLinesCount();
|
||||
// check actual changes
|
||||
int result = history->registerLuaChanges(name, start_index, InsertionDeletion_was_made);
|
||||
if (result >= 0)
|
||||
{
|
||||
greenzone->invalidateAndUpdatePlayback(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// check for special case: user deleted empty frames of the movie
|
||||
greenzone->invalidateAndUpdatePlayback(currMovieData.getNumRecords() - 1);
|
||||
}
|
||||
pending_changes.resize(0);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// taseditor.clearinputchanges()
|
||||
void TASEDITOR_LUA::clearinputchanges()
|
||||
{
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
|
||||
{
|
||||
pending_changes.resize(0);
|
||||
}
|
||||
}
|
||||
// --------------------------------------------------------------------------------
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
// Specification file for TASEDITOR_LUA class
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#define LUACHANGES_NAME_MAX_LEN 70 // custom name of operation should not be longer than 70 letters
|
||||
|
||||
struct PENDING_CHANGES
|
||||
{
|
||||
uint8_t type;
|
||||
int frame;
|
||||
uint8_t joypad;
|
||||
int data;
|
||||
};
|
||||
|
||||
enum LUA_CHANGE_TYPES
|
||||
{
|
||||
LUA_CHANGE_TYPE_INPUTCHANGE,
|
||||
LUA_CHANGE_TYPE_INSERTFRAMES,
|
||||
LUA_CHANGE_TYPE_DELETEFRAMES,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LUA_JOYPAD_COMMANDS = 0,
|
||||
LUA_JOYPAD_1P = 1,
|
||||
LUA_JOYPAD_2P = 2,
|
||||
LUA_JOYPAD_3P = 3,
|
||||
LUA_JOYPAD_4P = 4,
|
||||
};
|
||||
|
||||
class TASEDITOR_LUA
|
||||
{
|
||||
public:
|
||||
TASEDITOR_LUA();
|
||||
void init();
|
||||
void reset();
|
||||
void update();
|
||||
|
||||
void enableRunFunction(const char* caption = NULL);
|
||||
void disableRunFunction();
|
||||
|
||||
void insertAndDeleteRowsInSnaphot(SNAPSHOT& snapshot);
|
||||
|
||||
// Taseditor Lua library
|
||||
bool engaged();
|
||||
bool markedframe(int frame);
|
||||
int getmarker(int frame);
|
||||
int setmarker(int frame);
|
||||
void removemarker(int frame);
|
||||
const char* getnote(int index);
|
||||
void setnote(int index, const char* newtext);
|
||||
int getcurrentbranch();
|
||||
const char* getrecordermode();
|
||||
int getsuperimpose();
|
||||
int getlostplayback();
|
||||
int getplaybacktarget();
|
||||
void setplayback(int frame);
|
||||
void stopseeking();
|
||||
void getselection(std::vector<int>& placeholder);
|
||||
void setselection(std::vector<int>& new_set);
|
||||
int getinput(int frame, int joypad);
|
||||
void submitinputchange(int frame, int joypad, int input);
|
||||
void submitinsertframes(int frame, int number);
|
||||
void submitdeleteframes(int frame, int number);
|
||||
int applyinputchanges(const char* name);
|
||||
void clearinputchanges();
|
||||
|
||||
private:
|
||||
std::vector<PENDING_CHANGES> pending_changes;
|
||||
|
||||
//HWND hwndRunFunctionButton;
|
||||
|
||||
};
|
|
@ -16,30 +16,32 @@ Project - Manager of working project
|
|||
* stores resources: autosave period scale, default filename, fm3 format offsets
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include "taseditor_project.h"
|
||||
#include "utils/xstring.h"
|
||||
#include "fceu.h"
|
||||
#include "movie.h"
|
||||
#include "driver.h"
|
||||
#include "version.h"
|
||||
#include "utils/xstring.h"
|
||||
#include "Qt/TasEditor/taseditor_project.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
extern TASEDITOR_CONFIG taseditorConfig;
|
||||
extern TASEDITOR_WINDOW taseditorWindow;
|
||||
extern MARKERS_MANAGER markersManager;
|
||||
extern BOOKMARKS bookmarks;
|
||||
extern POPUP_DISPLAY popupDisplay;
|
||||
extern GREENZONE greenzone;
|
||||
extern PLAYBACK playback;
|
||||
extern RECORDER recorder;
|
||||
extern HISTORY history;
|
||||
extern PIANO_ROLL pianoRoll;
|
||||
extern SELECTION selection;
|
||||
extern SPLICER splicer;
|
||||
//extern TASEDITOR_CONFIG taseditorConfig;
|
||||
//extern TASEDITOR_WINDOW taseditorWindow;
|
||||
//extern MARKERS_MANAGER markersManager;
|
||||
//extern BOOKMARKS bookmarks;
|
||||
//extern POPUP_DISPLAY popupDisplay;
|
||||
//extern GREENZONE greenzone;
|
||||
//extern PLAYBACK playback;
|
||||
//extern RECORDER recorder;
|
||||
//extern HISTORY history;
|
||||
//extern PIANO_ROLL pianoRoll;
|
||||
//extern SELECTION selection;
|
||||
//extern SPLICER splicer;
|
||||
|
||||
extern FCEUGI *GameInfo;
|
||||
|
||||
extern void FCEU_PrintError(const char *format, ...);
|
||||
extern bool saveProject(bool save_compact = false);
|
||||
extern bool saveProjectAs(bool save_compact = false);
|
||||
extern int getInputType(MovieData& md);
|
||||
extern void setInputType(MovieData& md, int new_input_type);
|
||||
|
||||
TASEDITOR_PROJECT::TASEDITOR_PROJECT()
|
||||
{
|
||||
|
@ -60,12 +62,16 @@ void TASEDITOR_PROJECT::reset()
|
|||
void TASEDITOR_PROJECT::update()
|
||||
{
|
||||
// if it's time to autosave - pop Save As dialog
|
||||
if (changed && taseditorWindow.TASEditorIsInFocus && taseditorConfig.autosaveEnabled && !projectFile.empty() && clock() >= nextSaveShedule && pianoRoll.dragMode == DRAG_MODE_NONE)
|
||||
if (changed && /*taseditorWindow.TASEditorIsInFocus &&*/ taseditorConfig->autosaveEnabled && !projectFile.empty() && clock() >= nextSaveShedule /*&& pianoRoll.dragMode == DRAG_MODE_NONE*/)
|
||||
{
|
||||
if (taseditorConfig.autosaveSilent)
|
||||
saveProject();
|
||||
else
|
||||
saveProjectAs();
|
||||
//if (taseditorConfig->autosaveSilent)
|
||||
//{
|
||||
// saveProject();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// saveProjectAs();
|
||||
//}
|
||||
// in case user pressed Cancel, postpone saving to next time
|
||||
sheduleNextAutosave();
|
||||
}
|
||||
|
@ -101,17 +107,17 @@ bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool
|
|||
strncat(message, "\nMD5: ", 2047 - strlen(message));
|
||||
strncat(message, md5OfRom, 2047 - strlen(message));
|
||||
strncat(message, "\n\nFix the movie header before saving? ", 2047 - strlen(message));
|
||||
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "ROM Checksum Mismatch", MB_YESNOCANCEL);
|
||||
if (answer == IDCANCEL)
|
||||
{
|
||||
// cancel saving
|
||||
return false;
|
||||
} else if (answer == IDYES)
|
||||
{
|
||||
//int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "ROM Checksum Mismatch", MB_YESNOCANCEL);
|
||||
//if (answer == IDCANCEL)
|
||||
//{
|
||||
// // cancel saving
|
||||
// return false;
|
||||
//} else if (answer == IDYES)
|
||||
//{
|
||||
// change ROM data in the movie to current ROM
|
||||
currMovieData.romFilename = GameInfo->filename;
|
||||
currMovieData.romChecksum = GameInfo->MD5;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
// open file for write
|
||||
|
@ -123,7 +129,7 @@ bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool
|
|||
if (ofs)
|
||||
{
|
||||
// change cursor to hourglass
|
||||
SetCursor(LoadCursor(0, IDC_WAIT));
|
||||
//SetCursor(LoadCursor(0, IDC_WAIT));
|
||||
// save fm2 data to the project file
|
||||
currMovieData.loadFrameCount = currMovieData.records.size();
|
||||
currMovieData.emuVersion = FCEU_VERSION_NUMERIC;
|
||||
|
@ -146,17 +152,17 @@ bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool
|
|||
write32le(0, ofs);
|
||||
// save specified modules
|
||||
unsigned int markersOffset = ofs->ftell();
|
||||
markersManager.save(ofs, saveMarkers);
|
||||
markersManager->save(ofs, saveMarkers);
|
||||
unsigned int bookmarksOffset = ofs->ftell();
|
||||
bookmarks.save(ofs, saveBookmarks);
|
||||
bookmarks->save(ofs, saveBookmarks);
|
||||
unsigned int greenzoneOffset = ofs->ftell();
|
||||
greenzone.save(ofs, saveGreenzone);
|
||||
greenzone->save(ofs, saveGreenzone);
|
||||
unsigned int historyOffset = ofs->ftell();
|
||||
history.save(ofs, saveHistory);
|
||||
history->save(ofs, saveHistory);
|
||||
unsigned int pianoRollOffset = ofs->ftell();
|
||||
pianoRoll.save(ofs, savePianoRoll);
|
||||
//pianoRoll.save(ofs, savePianoRoll);
|
||||
unsigned int selectionOffset = ofs->ftell();
|
||||
selection.save(ofs, saveSelection);
|
||||
selection->save(ofs, saveSelection);
|
||||
// now write offsets (pointers)
|
||||
ofs->fseek(taseditorDataOffset + PROJECT_FILE_OFFSET_OF_POINTERS_DATA, SEEK_SET);
|
||||
write32le(markersOffset, ofs);
|
||||
|
@ -167,12 +173,12 @@ bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool
|
|||
write32le(selectionOffset, ofs);
|
||||
// finish
|
||||
delete ofs;
|
||||
playback.updateProgressbar();
|
||||
playback->updateProgressbar();
|
||||
// also set project.changed to false, unless it was SaveCompact
|
||||
if (!differentName)
|
||||
reset();
|
||||
// restore cursor
|
||||
taseditorWindow.mustUpdateMouseCursor = true;
|
||||
//taseditorWindow.mustUpdateMouseCursor = true;
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
|
@ -192,7 +198,7 @@ bool TASEDITOR_PROJECT::load(const char* fullName)
|
|||
}
|
||||
|
||||
// change cursor to hourglass
|
||||
SetCursor(LoadCursor(0, IDC_WAIT));
|
||||
//SetCursor(LoadCursor(0, IDC_WAIT));
|
||||
// load fm2 data from the project file
|
||||
MovieData tempMovieData = MovieData();
|
||||
extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader);
|
||||
|
@ -223,9 +229,9 @@ bool TASEDITOR_PROJECT::load(const char* fullName)
|
|||
strncat(message, "\nMD5: ", 2047 - strlen(message));
|
||||
strncat(message, md5OfCurrent, 2047 - strlen(message));
|
||||
strncat(message, "\n\nLoad the project anyway?", 2047 - strlen(message));
|
||||
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "ROM Checksum Mismatch", MB_YESNO);
|
||||
if (answer == IDNO)
|
||||
return false;
|
||||
//int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "ROM Checksum Mismatch", MB_YESNO);
|
||||
//if (answer == IDNO)
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
taseditorDataOffset = ifs.ftell();
|
||||
|
@ -238,20 +244,20 @@ bool TASEDITOR_PROJECT::load(const char* fullName)
|
|||
char message[2048] = {0};
|
||||
strcpy(message, "This project was saved using different version of TAS Editor!\n\n");
|
||||
strcat(message, "Original version: ");
|
||||
char versionNum[11];
|
||||
_itoa(projectFileVersion, versionNum, 10);
|
||||
char versionNum[16];
|
||||
sprintf( versionNum, "%i", projectFileVersion);
|
||||
strncat(message, versionNum, 2047 - strlen(message));
|
||||
strncat(message, "\nCurrent version: ", 2047 - strlen(message));
|
||||
_itoa(PROJECT_FILE_CURRENT_VERSION, versionNum, 10);
|
||||
sprintf( versionNum, "%i", PROJECT_FILE_CURRENT_VERSION);
|
||||
strncat(message, versionNum, 2047 - strlen(message));
|
||||
strncat(message, "\n\nClick Yes to try loading all data from the file (may crash).\n", 2047 - strlen(message));
|
||||
strncat(message, "Click No to only load movie data.\n", 2047 - strlen(message));
|
||||
strncat(message, "Click Cancel to abort loading.", 2047 - strlen(message));
|
||||
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "FM3 Version Mismatch", MB_YESNOCANCEL);
|
||||
if (answer == IDCANCEL)
|
||||
return false;
|
||||
else if (answer == IDNO)
|
||||
loadAll = false;
|
||||
//int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "FM3 Version Mismatch", MB_YESNOCANCEL);
|
||||
//if (answer == IDCANCEL)
|
||||
// return false;
|
||||
//else if (answer == IDNO)
|
||||
// loadAll = false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
@ -259,9 +265,9 @@ bool TASEDITOR_PROJECT::load(const char* fullName)
|
|||
loadAll = false;
|
||||
char message[2048];
|
||||
strcpy(message, "This file doesn't seem to be an FM3 project.\nIt only contains FM2 movie data. Load it anyway?");
|
||||
int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "Opening FM2 file", MB_YESNO);
|
||||
if (answer == IDNO)
|
||||
return false;
|
||||
//int answer = MessageBox(taseditorWindow.hwndTASEditor, message, "Opening FM2 file", MB_YESNO);
|
||||
//if (answer == IDNO)
|
||||
// return false;
|
||||
}
|
||||
// save data to currMovieData and continue loading
|
||||
FCEU_printf("\nLoading TAS Editor project %s...\n", fullName);
|
||||
|
@ -289,56 +295,56 @@ bool TASEDITOR_PROJECT::load(const char* fullName)
|
|||
pointerOffset += sizeof(unsigned int);
|
||||
else
|
||||
dataOffset = 0;
|
||||
markersManager.load(&ifs, dataOffset);
|
||||
markersManager->load(&ifs, dataOffset);
|
||||
|
||||
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
|
||||
pointerOffset += sizeof(unsigned int);
|
||||
else
|
||||
dataOffset = 0;
|
||||
bookmarks.load(&ifs, dataOffset);
|
||||
bookmarks->load(&ifs, dataOffset);
|
||||
|
||||
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
|
||||
pointerOffset += sizeof(unsigned int);
|
||||
else
|
||||
dataOffset = 0;
|
||||
greenzone.load(&ifs, dataOffset);
|
||||
greenzone->load(&ifs, dataOffset);
|
||||
|
||||
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
|
||||
pointerOffset += sizeof(unsigned int);
|
||||
else
|
||||
dataOffset = 0;
|
||||
history.load(&ifs, dataOffset);
|
||||
history->load(&ifs, dataOffset);
|
||||
|
||||
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
|
||||
pointerOffset += sizeof(unsigned int);
|
||||
else
|
||||
dataOffset = 0;
|
||||
pianoRoll.load(&ifs, dataOffset);
|
||||
//pianoRoll.load(&ifs, dataOffset);
|
||||
|
||||
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
|
||||
pointerOffset += sizeof(unsigned int);
|
||||
else
|
||||
dataOffset = 0;
|
||||
selection.load(&ifs, dataOffset);
|
||||
selection->load(&ifs, dataOffset);
|
||||
} else
|
||||
{
|
||||
// reset modules
|
||||
markersManager.load(&ifs, 0);
|
||||
bookmarks.load(&ifs, 0);
|
||||
greenzone.load(&ifs, 0);
|
||||
history.load(&ifs, 0);
|
||||
pianoRoll.load(&ifs, 0);
|
||||
selection.load(&ifs, 0);
|
||||
markersManager->load(&ifs, 0);
|
||||
bookmarks->load(&ifs, 0);
|
||||
greenzone->load(&ifs, 0);
|
||||
history->load(&ifs, 0);
|
||||
//pianoRoll.load(&ifs, 0);
|
||||
selection->load(&ifs, 0);
|
||||
}
|
||||
// reset other modules
|
||||
playback.reset();
|
||||
recorder.reset();
|
||||
splicer.reset();
|
||||
popupDisplay.reset();
|
||||
playback->reset();
|
||||
recorder->reset();
|
||||
splicer->reset();
|
||||
//popupDisplay.reset();
|
||||
reset();
|
||||
renameProject(fullName, loadAll);
|
||||
// restore mouse cursor shape
|
||||
taseditorWindow.mustUpdateMouseCursor = true;
|
||||
//taseditorWindow.mustUpdateMouseCursor = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -374,7 +380,7 @@ void TASEDITOR_PROJECT::setProjectChanged()
|
|||
if (!changed)
|
||||
{
|
||||
changed = true;
|
||||
taseditorWindow.updateCaption();
|
||||
//taseditorWindow.updateCaption();
|
||||
sheduleNextAutosave();
|
||||
}
|
||||
}
|
||||
|
@ -385,6 +391,43 @@ bool TASEDITOR_PROJECT::getProjectChanged()
|
|||
|
||||
void TASEDITOR_PROJECT::sheduleNextAutosave()
|
||||
{
|
||||
nextSaveShedule = clock() + taseditorConfig.autosavePeriod * AUTOSAVE_PERIOD_SCALE;
|
||||
nextSaveShedule = clock() + taseditorConfig->autosavePeriod * AUTOSAVE_PERIOD_SCALE;
|
||||
}
|
||||
|
||||
|
||||
int getInputType(MovieData& md)
|
||||
{
|
||||
if (md.fourscore)
|
||||
return INPUT_TYPE_FOURSCORE;
|
||||
else if (md.ports[0] == md.ports[1] == SI_GAMEPAD)
|
||||
return INPUT_TYPE_2P;
|
||||
else
|
||||
return INPUT_TYPE_1P;
|
||||
}
|
||||
void setInputType(MovieData& md, int newInputType)
|
||||
{
|
||||
switch (newInputType)
|
||||
{
|
||||
case INPUT_TYPE_1P:
|
||||
{
|
||||
md.fourscore = false;
|
||||
md.ports[0] = SI_GAMEPAD;
|
||||
md.ports[1] = SI_NONE;
|
||||
break;
|
||||
}
|
||||
case INPUT_TYPE_2P:
|
||||
{
|
||||
md.fourscore = false;
|
||||
md.ports[0] = SI_GAMEPAD;
|
||||
md.ports[1] = SI_GAMEPAD;
|
||||
break;
|
||||
}
|
||||
case INPUT_TYPE_FOURSCORE:
|
||||
{
|
||||
md.fourscore = true;
|
||||
md.ports[0] = SI_GAMEPAD;
|
||||
md.ports[1] = SI_GAMEPAD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
// Specification file for the TASEDITOR_PROJECT class
|
||||
#pragma once
|
||||
|
||||
#include <time.h>
|
||||
#include "movie.h"
|
||||
#include "Qt/TasEditor/taseditor_config.h"
|
||||
//#include "Qt/TasEditor/greenzone.h"
|
||||
#include "Qt/TasEditor/greenzone.h"
|
||||
#include "Qt/TasEditor/selection.h"
|
||||
//#include "Qt/TasEditor/markers_manager.h"
|
||||
//#include "Qt/TasEditor/snapshot.h"
|
||||
//#include "Qt/TasEditor/bookmarks.h"
|
||||
//#include "Qt/TasEditor/branches.h"
|
||||
//#include "Qt/TasEditor/history.h"
|
||||
#include "Qt/TasEditor/markers_manager.h"
|
||||
#include "Qt/TasEditor/snapshot.h"
|
||||
#include "Qt/TasEditor/bookmarks.h"
|
||||
#include "Qt/TasEditor/branches.h"
|
||||
#include "Qt/TasEditor/history.h"
|
||||
#include "Qt/TasEditor/playback.h"
|
||||
//#include "Qt/TasEditor/recorder.h"
|
||||
#include "Qt/TasEditor/recorder.h"
|
||||
//#include "Qt/TasEditor/piano_roll.h"
|
||||
//#include "Qt/TasEditor/taseditor_lua.h"
|
||||
#include "Qt/TasEditor/taseditor_lua.h"
|
||||
#include "Qt/TasEditor/splicer.h"
|
||||
//#include "Qt/TasEditor/editor.h"
|
||||
//#include "Qt/TasEditor/popup_display.h"
|
||||
|
@ -41,6 +42,7 @@
|
|||
#define PROJECT_FILE_OFFSET_OF_POINTERS_DATA (PROJECT_FILE_OFFSET_OF_NUMBER_OF_POINTERS + 4)
|
||||
|
||||
#define NUM_JOYPAD_BUTTONS 8
|
||||
#define MAX_NUM_JOYPADS 4
|
||||
|
||||
class TASEDITOR_PROJECT
|
||||
{
|
||||
|
@ -73,3 +75,6 @@ private:
|
|||
std::string fm2FileName; // same as projectName but with .fm2 extension instead of .fm3
|
||||
|
||||
};
|
||||
|
||||
int getInputType(MovieData& md);
|
||||
void setInputType(MovieData& md, int new_input_type);
|
||||
|
|
|
@ -48,13 +48,18 @@ extern char FileBase[];
|
|||
#include "drivers/win/taseditor/snapshot.h"
|
||||
#include "drivers/win/taseditor/taseditor_lua.h"
|
||||
#include "drivers/win/cdlogger.h"
|
||||
extern TASEDITOR_LUA taseditor_lua;
|
||||
#endif
|
||||
|
||||
#ifdef __SDL__
|
||||
|
||||
#ifdef __QT_DRIVER__
|
||||
#include "drivers/Qt/fceuWrapper.h"
|
||||
#include "drivers/Qt/TasEditor/selection.h"
|
||||
#include "drivers/Qt/TasEditor/laglog.h"
|
||||
#include "drivers/Qt/TasEditor/markers.h"
|
||||
#include "drivers/Qt/TasEditor/snapshot.h"
|
||||
#include "drivers/Qt/TasEditor/taseditor_lua.h"
|
||||
extern TASEDITOR_LUA *taseditor_lua;
|
||||
#else
|
||||
int LoadGame(const char *path, bool silent = false);
|
||||
int reloadLastGame(void);
|
||||
|
@ -2326,6 +2331,18 @@ void TaseditorDisableManualFunctionIfNeeded()
|
|||
lua_pop(L, 1);
|
||||
} else taseditor_lua.disableRunFunction();
|
||||
}
|
||||
#elif __QT_DRIVER__
|
||||
void TaseditorDisableManualFunctionIfNeeded()
|
||||
{
|
||||
if (L)
|
||||
{
|
||||
// check if LUACALL_TASEDITOR_MANUAL function is not nil
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
|
||||
if (!lua_isfunction(L, -1))
|
||||
taseditor_lua->disableRunFunction();
|
||||
lua_pop(L, 1);
|
||||
} else taseditor_lua->disableRunFunction();
|
||||
}
|
||||
#endif
|
||||
|
||||
static int memory_registerHook(lua_State* L, LuaMemHookType hookType, int defaultSize)
|
||||
|
|
Loading…
Reference in New Issue