diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index 124495b3..f3e1f043 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -57,6 +57,93 @@ RECORDER *recorder = NULL; HISTORY *history = NULL; SPLICER *splicer = NULL; +// Piano Roll Colors +#define NORMAL_TEXT_COLOR 0x0 +#define NORMAL_BACKGROUND_COLOR 0xFFFFFF + +//#define NORMAL_FRAMENUM_COLOR 0xFFFFFF +//#define NORMAL_INPUT_COLOR1 0xEDEDED +//#define NORMAL_INPUT_COLOR2 0xE2E2E2 + +#define NORMAL_FRAMENUM_COLOR 0xFF, 0xFF, 0xFF +#define NORMAL_INPUT_COLOR1 0xED, 0xED, 0xED +#define NORMAL_INPUT_COLOR2 0xE2, 0xE2, 0xE2 + +//#define GREENZONE_FRAMENUM_COLOR 0xDDFFDD +//#define GREENZONE_INPUT_COLOR1 0xC8F7C4 +//#define GREENZONE_INPUT_COLOR2 0xADE7AD + +#define GREENZONE_FRAMENUM_COLOR 0xDD, 0xFF, 0xDD +#define GREENZONE_INPUT_COLOR1 0xC4, 0xF7, 0xC8 +#define GREENZONE_INPUT_COLOR2 0xAD, 0xE7, 0xAD + +//#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4FFE4 +//#define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2 +//#define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA + +#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4, 0xFF, 0xE4 +#define PALE_GREENZONE_INPUT_COLOR1 0xD2, 0xF9, 0xD3 +#define PALE_GREENZONE_INPUT_COLOR2 0xBA, 0xEB, 0xBA + +//#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF9FFF9 +//#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE0FBE0 +//#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD2F2D2 + +#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF9, 0xFF, 0xF9 +#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE0, 0xFB, 0xE0 +#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD2, 0xF2, 0xD2 + +//#define LAG_FRAMENUM_COLOR 0xDDDCFF +//#define LAG_INPUT_COLOR1 0xD2D0F0 +//#define LAG_INPUT_COLOR2 0xC9C6E8 + +#define LAG_FRAMENUM_COLOR 0xFF, 0xDC, 0xDD +#define LAG_INPUT_COLOR1 0xF0, 0xD0, 0xD2 +#define LAG_INPUT_COLOR2 0xE8, 0xC6, 0xC9 + +//#define PALE_LAG_FRAMENUM_COLOR 0xE3E3FF +//#define PALE_LAG_INPUT_COLOR1 0xDADAF4 +//#define PALE_LAG_INPUT_COLOR2 0xCFCEEA + +#define PALE_LAG_FRAMENUM_COLOR 0xFF, 0xE3, 0xE3 +#define PALE_LAG_INPUT_COLOR1 0xF4, 0xDA, 0xDA +#define PALE_LAG_INPUT_COLOR2 0xEA, 0xCE, 0xCF + +//#define VERY_PALE_LAG_FRAMENUM_COLOR 0xE9E9FF +//#define VERY_PALE_LAG_INPUT_COLOR1 0xE5E5F7 +//#define VERY_PALE_LAG_INPUT_COLOR2 0xE0E0F1 + +#define VERY_PALE_LAG_FRAMENUM_COLOR 0xFF, 0xE9, 0xE9 +#define VERY_PALE_LAG_INPUT_COLOR1 0xF7, 0xE5, 0xE5 +#define VERY_PALE_LAG_INPUT_COLOR2 0xF1, 0xE0, 0xE0 + +//#define CUR_FRAMENUM_COLOR 0xFCEDCF +//#define CUR_INPUT_COLOR1 0xF7E7B5 +//#define CUR_INPUT_COLOR2 0xE5DBA5 + +#define CUR_FRAMENUM_COLOR 0xCF, 0xED, 0xFC +#define CUR_INPUT_COLOR1 0xB5, 0xE7, 0xF7 +#define CUR_INPUT_COLOR2 0xA5, 0xDB, 0xE5 + +//#define UNDOHINT_FRAMENUM_COLOR 0xF9DDE6 +//#define UNDOHINT_INPUT_COLOR1 0xF7D2E1 +//#define UNDOHINT_INPUT_COLOR2 0xE9BED1 + +#define UNDOHINT_FRAMENUM_COLOR 0xE6, 0xDD, 0xF9 +#define UNDOHINT_INPUT_COLOR1 0xE1, 0xD2, 0xF7 +#define UNDOHINT_INPUT_COLOR2 0xD1, 0xBE, 0xE9 + +#define MARKED_FRAMENUM_COLOR 0xAEF0FF +#define CUR_MARKED_FRAMENUM_COLOR 0xCAEDEA +#define MARKED_UNDOHINT_FRAMENUM_COLOR 0xDDE5E9 + +#define BINDMARKED_FRAMENUM_COLOR 0xC9FFF7 +#define CUR_BINDMARKED_FRAMENUM_COLOR 0xD5F2EC +#define BINDMARKED_UNDOHINT_FRAMENUM_COLOR 0xE1EBED + +#define PLAYBACK_MARKER_COLOR 0xC9AF00 + + //---------------------------------------------------------------------------- //---- Main TAS Editor Window //---------------------------------------------------------------------------- @@ -518,6 +605,9 @@ void TasEditorWindow::buildSideControlPanel(void) controlPanelContainerWidget = new QWidget(); controlPanelContainerWidget->setLayout( ctlPanelMainVbox ); + + recRecordingCbox->setChecked( !movie_readonly ); + connect( recRecordingCbox, SIGNAL(stateChanged(int)), this, SLOT(recordingChanged(int)) ); } //---------------------------------------------------------------------------- int TasEditorWindow::initModules(void) @@ -548,8 +638,9 @@ int TasEditorWindow::initModules(void) FCEUI_StopMovie(); movieMode = MOVIEMODE_TASEDITOR; FCEUMOV_CreateCleanMovie(); - //playback.restartPlaybackFromZeroGround(); - } else + playback.restartPlaybackFromZeroGround(); + } + else { // use current movie to create a new project FCEUI_StopMovie(); @@ -608,6 +699,9 @@ void TasEditorWindow::frameUpdate(void) // TaseditorManualFunction(); // mustCallManualLuaFunction = false; //} + + pianoRoll->update(); + fceuWrapperUnLock(); } //---------------------------------------------------------------------------- @@ -944,6 +1038,12 @@ void TasEditorWindow::saveProjectCompactCb(void) saveProject(true); } //---------------------------------------------------------------------------- +void TasEditorWindow::recordingChanged(int state) +{ + FCEUI_MovieToggleReadOnly(); +} +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- //---- TAS Piano Roll Widget //---------------------------------------------------------------------------- QPianoRoll::QPianoRoll(QWidget *parent) @@ -1097,6 +1197,8 @@ void QPianoRoll::resizeEvent(QResizeEvent *event) { maxLineOffset = 0; } + vbar->setMinimum(0); + vbar->setMaximum(maxLineOffset); if ( viewWidth >= pxLineWidth ) { @@ -1115,10 +1217,11 @@ void QPianoRoll::resizeEvent(QResizeEvent *event) //---------------------------------------------------------------------------- void QPianoRoll::paintEvent(QPaintEvent *event) { - int x, y, nrow; + int x, y, row, nrow, lineNum; QPainter painter(this); - QColor white("white"), black("black"); + QColor white("white"), black("black"), blkColor; static const char *buttonNames[] = { "A", "B", "S", "T", "U", "D", "L", "R", NULL }; + char stmp[32]; painter.setFont(font); viewWidth = event->rect().width(); @@ -1145,6 +1248,8 @@ void QPianoRoll::paintEvent(QPaintEvent *event) { lineOffset = maxLineOffset; } + vbar->setMinimum(0); + vbar->setMaximum(maxLineOffset); painter.fillRect( 0, 0, viewWidth, viewHeight, this->palette().color(QPalette::Window) ); @@ -1170,6 +1275,127 @@ void QPianoRoll::paintEvent(QPaintEvent *event) { painter.fillRect( x, pxLineSpacing, pxWidthCtlCol, viewHeight, this->palette().color(QPalette::AlternateBase) ); } + } + + y = pxLineSpacing; + + for (row=0; row= currMovieData.records.size() ) + { + break; + } + int frame_lag = greenzone->lagLog.getLagInfoAtFrame(lineNum); + + x = pxFrameCtlX[0] - pxLineXScroll; + + if ( lineNum == history->getUndoHint()) + { + // undo hint here + blkColor = QColor(UNDOHINT_INPUT_COLOR1); + } + else if ( lineNum == currFrameCounter || lineNum == (playback->getFlashingPauseFrame() - 1)) + { + // this is current frame + blkColor = QColor(CUR_INPUT_COLOR1); + } + else if ( lineNum < greenzone->getSize() ) + { + if (!greenzone->isSavestateEmpty(lineNum)) + { + // the frame is normal Greenzone frame + if (frame_lag == LAGGED_YES) + { + blkColor = QColor(LAG_FRAMENUM_COLOR); + } + else + { + blkColor = QColor(GREENZONE_FRAMENUM_COLOR); + } + } + else if ( !greenzone->isSavestateEmpty(lineNum & EVERY16TH) + || !greenzone->isSavestateEmpty(lineNum & EVERY8TH) + || !greenzone->isSavestateEmpty(lineNum & EVERY4TH) + || !greenzone->isSavestateEmpty(lineNum & EVERY2ND)) + { + // the frame is in a gap (in Greenzone tail) + if (frame_lag == LAGGED_YES) + { + blkColor = QColor(PALE_LAG_FRAMENUM_COLOR); + } + else + { + blkColor = QColor(PALE_GREENZONE_FRAMENUM_COLOR); + } + } + else + { + // the frame is above Greenzone tail + if (frame_lag == LAGGED_YES) + { + blkColor = QColor(VERY_PALE_LAG_FRAMENUM_COLOR); + } + else if (frame_lag == LAGGED_NO) + { + blkColor = QColor(VERY_PALE_GREENZONE_FRAMENUM_COLOR); + } + else + { + blkColor = QColor(NORMAL_FRAMENUM_COLOR); + } + } + } + else + { + // the frame is below Greenzone head + if (frame_lag == LAGGED_YES) + { + blkColor = QColor(VERY_PALE_LAG_FRAMENUM_COLOR); + } + else if (frame_lag == LAGGED_NO) + { + blkColor = QColor(VERY_PALE_GREENZONE_FRAMENUM_COLOR); + } + else + { + blkColor = QColor(NORMAL_FRAMENUM_COLOR); + } + } + painter.fillRect( x, y, pxWidthCtlCol, pxLineSpacing, blkColor ); + + for (int i=0; i> 8) & 0xFF); currentJoypadData[2] = ((joypads >> 16) & 0xFF); @@ -224,6 +224,11 @@ void RECORDER::update() // ------------------------------------------------------------------------------------ void RECORDER::uncheckRecordingRadioButtons() { + tasWin->recAllBtn->setChecked(false); + tasWin->rec1PBtn->setChecked(false); + tasWin->rec2PBtn->setChecked(false); + tasWin->rec3PBtn->setChecked(false); + tasWin->rec4PBtn->setChecked(false); //Button_SetCheck(hwndRadioButtonRecordAll, BST_UNCHECKED); //Button_SetCheck(hwndRadioButtonRecord1P, BST_UNCHECKED); //Button_SetCheck(hwndRadioButtonRecord2P, BST_UNCHECKED); @@ -232,29 +237,36 @@ void RECORDER::uncheckRecordingRadioButtons() } 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); + tasWin->recAllBtn->setChecked(true); + break; + case MULTITRACK_RECORDING_1P: + //Button_SetCheck(hwndRadioButtonRecord1P, BST_CHECKED); + tasWin->rec1PBtn->setChecked(true); + break; + case MULTITRACK_RECORDING_2P: + //Button_SetCheck(hwndRadioButtonRecord2P, BST_CHECKED); + tasWin->rec2PBtn->setChecked(true); + break; + case MULTITRACK_RECORDING_3P: + //Button_SetCheck(hwndRadioButtonRecord3P, BST_CHECKED); + tasWin->rec3PBtn->setChecked(true); + break; + case MULTITRACK_RECORDING_4P: + //Button_SetCheck(hwndRadioButtonRecord4P, BST_CHECKED); + tasWin->rec4PBtn->setChecked(true); + break; + default: + multitrackRecordingJoypadNumber = MULTITRACK_RECORDING_ALL; + //Button_SetCheck(hwndRadioButtonRecordAll, BST_CHECKED); + tasWin->recAllBtn->setChecked(true); + break; + } } void RECORDER::recordInput() @@ -266,10 +278,11 @@ void RECORDER::recordInput() 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 + + if (!taseditorConfig->recordingUsePattern /*|| editor.patterns[oldCurrentPattern][patternOffset]*/) + newJoyData[i] = currMovieData.records[currFrameCounter].joysticks[i]; + else + newJoyData[i] = 0; // blank } if (taseditorConfig->recordingUsePattern) { @@ -283,7 +296,9 @@ void RECORDER::recordInput() { // superimpose (bitwise OR) if needed 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]; if (newJoyData[i] != oldJoyData[i]) @@ -300,18 +315,25 @@ void RECORDER::recordInput() } } } - } else + } + else { int joy = multitrackRecordingJoypadNumber - 1; // substitute target joypad with 1p joypad 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)) + { newJoyData[joy] |= oldJoyData[joy]; + } // other joysticks should not be changed for (int i = num_joys-1; i >= 0; i--) + { currMovieData.records[currFrameCounter].joysticks[i] = oldJoyData[i]; // revert to old + } // change only this joystick currMovieData.records[currFrameCounter].joysticks[joy] = newJoyData[joy]; if (newJoyData[joy] != oldJoyData[joy]) diff --git a/src/drivers/Qt/input.cpp b/src/drivers/Qt/input.cpp index 2be5dec0..864c0b35 100644 --- a/src/drivers/Qt/input.cpp +++ b/src/drivers/Qt/input.cpp @@ -189,6 +189,12 @@ _keyonly(int a) return 0; } +uint32 GetGamepadPressedImmediate(void) +{ + //printf("JSreturn: 0x%08X\n", JSreturn); + return JSreturn; +} + #define keyonly(__a) _keyonly(MKK(__a)) static bool g_fkbEnabled = false;