Added TAS input pattern selection Qt GUI code. Fixed a few clock timing calculations in Qt TAS editor.

This commit is contained in:
mjbudd77 2021-11-26 05:45:16 -05:00
parent 22b28195c6
commit c7bfb684ae
4 changed files with 52 additions and 5 deletions

View File

@ -329,8 +329,9 @@ void TasEditorWindow::closeWindow(void)
QMenuBar *TasEditorWindow::buildMenuBar(void)
{
QMenu *fileMenu, *editMenu, *viewMenu,
*confMenu, *luaMenu, *helpMenu;
//QActionGroup *actGroup;
*confMenu, *luaMenu, *helpMenu,
*patternMenu;
QActionGroup *actGroup;
QAction *act;
int useNativeMenuBar=0;
@ -861,6 +862,27 @@ QMenuBar *TasEditorWindow::buildMenuBar(void)
luaMenu->addAction(act);
// Pattern
patternMenu = menuBar->addMenu(tr("&Pattern"));
actGroup = new QActionGroup(this);
for (size_t i=0; i<patternsNames.size(); i++)
{
// Pattern -> Names
act = new QAction(tr(patternsNames[i].c_str()), this);
act->setCheckable(true);
//act->setShortcut(QKeySequence(tr("Ctrl+N")));
act->setStatusTip(tr(patternsNames[i].c_str()));
//act->setIcon( style()->standardIcon( QStyle::SP_FileDialogStart ) );
connect(act, &QAction::triggered, [this, i] { setCurrentPattern(i); } );
actGroup->addAction(act);
patternMenu->addAction(act);
act->setChecked( taseditorConfig.currentPattern == i );
}
// Help
helpMenu = menuBar->addMenu(tr("&Help"));
@ -2074,6 +2096,20 @@ void TasEditorWindow::openOnlineDocs(void)
return;
}
//----------------------------------------------------------------------------
void TasEditorWindow::setCurrentPattern(int idx)
{
if ( idx < 0 )
{
return;
}
if ( (size_t)idx >= patternsNames.size() )
{
return;
}
//printf("Set Pattern: %i\n", idx);
taseditorConfig.currentPattern = idx;
}
//----------------------------------------------------------------------------
void TasEditorWindow::recordingChanged(int state)
{
FCEUI_MovieToggleReadOnly();
@ -2705,7 +2741,9 @@ void TasEditorWindow::setInputUsingPattern(int start, int end, int joy, int butt
}
if (start < 0) start = end;
if (end >= currMovieData.getNumRecords())
{
return;
}
int pattern_offset = 0, current_pattern = taseditorConfig.currentPattern;
bool changes_made = false;
@ -2715,7 +2753,9 @@ void TasEditorWindow::setInputUsingPattern(int start, int end, int joy, int butt
{
// skip lag frames
if (taseditorConfig.autofirePatternSkipsLag && greenzone.lagLog.getLagInfoAtFrame(i) == LAGGED_YES)
{
continue;
}
value = (patterns[current_pattern][pattern_offset] != 0);
if (currMovieData.records[i].checkBit(joy, button) != value)
{
@ -2724,10 +2764,14 @@ void TasEditorWindow::setInputUsingPattern(int start, int end, int joy, int butt
}
pattern_offset++;
if (pattern_offset >= (int)patterns[current_pattern].size())
{
pattern_offset -= patterns[current_pattern].size();
}
}
if (changes_made)
{
greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_PATTERN, start, end, 0, patternsNames[current_pattern].c_str(), consecutivenessTag));
}
}
// following functions use current Selection to determine range of frames

View File

@ -371,6 +371,7 @@ class TasEditorWindow : public QDialog
void openProjectSaveOptions(void);
void setGreenzoneCapacity(void);
void setMaxUndoCapacity(void);
void setCurrentPattern(int);
void tabViewChanged(int);
friend class RECORDER;

View File

@ -7,7 +7,8 @@
#define GREENZONE_ID_LEN 10
#define TIME_BETWEEN_CLEANINGS 10000 // in milliseconds
#define TIME_BETWEEN_CLEANINGS (10000 * (CLOCKS_PER_SEC / 1000)) // in milliseconds
// Greenzone cleaning masks
#define EVERY16TH 0xFFFFFFF0
#define EVERY8TH 0xFFFFFFF8

View File

@ -1,16 +1,17 @@
// Specification file for History class
#pragma once
#include <stdint.h>
#include <time.h>
#include <vector>
#include "fceu.h"
#include "Qt/TasEditor/bookmark.h"
#include "Qt/TasEditor/snapshot.h"
#define UNDO_HINT_TIME 200 // in milliseconds
#define UNDO_HINT_TIME (200 * (CLOCKS_PER_SEC / 1000)) // in milliseconds
#define SAVING_HISTORY_PROGRESSBAR_UPDATE_RATE 10
#define TIME_BETWEEN_AUTOCOMPRESSIONS 500 // in milliseconds
#define TIME_BETWEEN_AUTOCOMPRESSIONS (500 * (CLOCKS_PER_SEC / 1000)) // in milliseconds
#define HISTORY_LIST_WIDTH 500