Qt Tas editor module setup in work.
This commit is contained in:
parent
a77f69a931
commit
f523b49f9b
|
@ -529,6 +529,7 @@ 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/laglog.cpp
|
||||
)
|
||||
|
||||
set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_SDL})
|
||||
|
|
|
@ -2819,13 +2819,21 @@ void consoleWin_t::openAviRiffViewer(void)
|
|||
|
||||
void consoleWin_t::openTasEditor(void)
|
||||
{
|
||||
TasEditorWindow *win;
|
||||
fceuWrapperLock();
|
||||
|
||||
//printf("Open TAS Editor Window\n");
|
||||
|
||||
win = new TasEditorWindow(this);
|
||||
|
||||
win->show();
|
||||
if ( tasWindowIsOpen() )
|
||||
{
|
||||
tasWindowSetFocus(true);
|
||||
}
|
||||
else if (FCEU_IsValidUI(FCEUI_TASEDITOR))
|
||||
{
|
||||
TasEditorWindow *win;
|
||||
|
||||
win = new TasEditorWindow(this);
|
||||
|
||||
win->show();
|
||||
}
|
||||
fceuWrapperUnLock();
|
||||
}
|
||||
|
||||
void consoleWin_t::openMovieOptWin(void)
|
||||
|
|
|
@ -28,13 +28,47 @@
|
|||
#include <QMessageBox>
|
||||
#include <QFontMetrics>
|
||||
|
||||
#include "fceu.h"
|
||||
#include "movie.h"
|
||||
#include "driver.h"
|
||||
|
||||
#include "Qt/config.h"
|
||||
#include "Qt/fceuWrapper.h"
|
||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||
|
||||
TasEditorWindow *tasWin = NULL;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//---- Main TAS Editor Window
|
||||
//----------------------------------------------------------------------------
|
||||
bool tasWindowIsOpen(void)
|
||||
{
|
||||
return tasWin != NULL;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void tasWindowSetFocus(bool val)
|
||||
{
|
||||
if ( tasWin )
|
||||
{
|
||||
tasWin->activateWindow();
|
||||
tasWin->raise();
|
||||
tasWin->setFocus();
|
||||
}
|
||||
}
|
||||
// this getter contains formula to decide whether to record or replay movie
|
||||
bool isTaseditorRecording(void)
|
||||
{
|
||||
//if (movie_readonly || playback.getPauseFrame() >= 0 || (taseditorConfig.oldControlSchemeForBranching && !recorder.stateWasLoadedInReadWriteMode))
|
||||
// return false; // replay
|
||||
return true; // record
|
||||
}
|
||||
|
||||
bool recordInputByTaseditor(void)
|
||||
{
|
||||
//recorder.recordInput();
|
||||
return 0;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
TasEditorWindow::TasEditorWindow(QWidget *parent)
|
||||
: QDialog( parent, Qt::Window )
|
||||
{
|
||||
|
@ -42,6 +76,8 @@ TasEditorWindow::TasEditorWindow(QWidget *parent)
|
|||
//QHBoxLayout *hbox;
|
||||
QMenuBar *menuBar;
|
||||
|
||||
tasWin = this;
|
||||
|
||||
setWindowTitle("TAS Editor");
|
||||
|
||||
resize(512, 512);
|
||||
|
@ -60,11 +96,23 @@ TasEditorWindow::TasEditorWindow(QWidget *parent)
|
|||
|
||||
setLayout(mainLayout);
|
||||
mainLayout->setMenuBar( menuBar );
|
||||
|
||||
initModules();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
TasEditorWindow::~TasEditorWindow(void)
|
||||
{
|
||||
printf("Destroy Tas Editor Window\n");
|
||||
|
||||
if ( tasWin == this )
|
||||
{
|
||||
tasWin = NULL;
|
||||
}
|
||||
|
||||
// switch off TAS Editor mode
|
||||
movieMode = MOVIEMODE_INACTIVE;
|
||||
FCEU_DispMessage("TAS Editor disengaged", 0);
|
||||
FCEUMOV_CreateCleanMovie();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void TasEditorWindow::closeEvent(QCloseEvent *event)
|
||||
|
@ -357,6 +405,65 @@ void TasEditorWindow::buildSideControlPanel(void)
|
|||
controlPanelContainerWidget->setLayout( ctlPanelMainVbox );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
int TasEditorWindow::initModules(void)
|
||||
{
|
||||
// init modules
|
||||
//editor.init();
|
||||
//pianoRoll.init();
|
||||
//selection.init();
|
||||
//splicer.init();
|
||||
//playback.init();
|
||||
//greenzone.init();
|
||||
//recorder.init();
|
||||
//markersManager.init();
|
||||
//project.init();
|
||||
//bookmarks.init();
|
||||
//branches.init();
|
||||
//popupDisplay.init();
|
||||
//history.init();
|
||||
//taseditor_lua.init();
|
||||
// either start new movie or use current movie
|
||||
if (!FCEUMOV_Mode(MOVIEMODE_RECORD|MOVIEMODE_PLAY) || currMovieData.savestate.size() != 0)
|
||||
{
|
||||
if (currMovieData.savestate.size() != 0)
|
||||
{
|
||||
FCEUD_PrintError("This version of TAS Editor doesn't work with movies starting from savestate.");
|
||||
}
|
||||
// create new movie
|
||||
FCEUI_StopMovie();
|
||||
movieMode = MOVIEMODE_TASEDITOR;
|
||||
FCEUMOV_CreateCleanMovie();
|
||||
//playback.restartPlaybackFromZeroGround();
|
||||
} else
|
||||
{
|
||||
// use current movie to create a new project
|
||||
FCEUI_StopMovie();
|
||||
movieMode = MOVIEMODE_TASEDITOR;
|
||||
}
|
||||
// if movie length is less or equal to currFrame, pad it with empty frames
|
||||
if (((int)currMovieData.records.size() - 1) < currFrameCounter)
|
||||
{
|
||||
currMovieData.insertEmpty(-1, currFrameCounter - ((int)currMovieData.records.size() - 1));
|
||||
}
|
||||
// ensure that movie has correct set of ports/fourscore
|
||||
//setInputType(currMovieData, getInputType(currMovieData));
|
||||
// force the input configuration stored in the movie to apply to FCEUX config
|
||||
//applyMovieInputConfig();
|
||||
// reset some modules that need MovieData info
|
||||
//pianoRoll.reset();
|
||||
//recorder.reset();
|
||||
// create initial snapshot in history
|
||||
//history.reset();
|
||||
// reset Taseditor variables
|
||||
//mustCallManualLuaFunction = false;
|
||||
|
||||
//SetFocus(history.hwndHistoryList); // set focus only once, to show blue selection cursor
|
||||
//SetFocus(pianoRoll.hwndList);
|
||||
FCEU_DispMessage("TAS Editor engaged", 0);
|
||||
//taseditorWindow.redraw();
|
||||
return 0;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
//---- TAS Piano Roll Widget
|
||||
//----------------------------------------------------------------------------
|
||||
QPianoRoll::QPianoRoll(QWidget *parent)
|
||||
|
|
|
@ -133,7 +133,18 @@ class TasEditorWindow : public QDialog
|
|||
QPushButton *moreBtn;
|
||||
private:
|
||||
|
||||
int initModules(void);
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
private slots:
|
||||
};
|
||||
|
||||
bool tasWindowIsOpen(void);
|
||||
|
||||
void tasWindowSetFocus(bool val);
|
||||
|
||||
bool isTaseditorRecording(void);
|
||||
bool recordInputByTaseditor(void);
|
||||
|
||||
extern TasEditorWindow *tasWin;
|
||||
|
|
|
@ -0,0 +1,211 @@
|
|||
/* ---------------------------------------------------------------------------------
|
||||
Implementation file of LagLog 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.
|
||||
------------------------------------------------------------------------------------
|
||||
LagLog - Log of Lag appearance
|
||||
|
||||
* stores the frame-by-frame log of lag appearance
|
||||
* implements compression and decompression of stored data
|
||||
* saves and loads the data from a project file. On error: sends warning to caller
|
||||
* provides interface for reading and writing log data
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
//#include "taseditor_project.h"
|
||||
#include <zlib.h>
|
||||
|
||||
#include "fceu.h"
|
||||
#include "Qt/TasEditor/laglog.h"
|
||||
|
||||
LAGLOG::LAGLOG(void)
|
||||
{
|
||||
alreadyCompressed = false;
|
||||
}
|
||||
|
||||
void LAGLOG::reset(void)
|
||||
{
|
||||
lagLog.resize(0);
|
||||
alreadyCompressed = false;
|
||||
}
|
||||
|
||||
void LAGLOG::compressData(void)
|
||||
{
|
||||
int len = lagLog.size() * sizeof(uint8);
|
||||
if (len)
|
||||
{
|
||||
uLongf comprlen = (len>>9)+12 + len;
|
||||
compressedLagLog.resize(comprlen, LAGGED_UNKNOWN);
|
||||
compress(&compressedLagLog[0], &comprlen, (uint8*)&lagLog[0], len);
|
||||
compressedLagLog.resize(comprlen);
|
||||
} else
|
||||
{
|
||||
// LagLog can even be empty
|
||||
compressedLagLog.resize(0);
|
||||
}
|
||||
alreadyCompressed = true;
|
||||
}
|
||||
bool LAGLOG::isAlreadyCompressed(void)
|
||||
{
|
||||
return alreadyCompressed;
|
||||
}
|
||||
void LAGLOG::resetCompressedStatus(void)
|
||||
{
|
||||
alreadyCompressed = false;
|
||||
}
|
||||
|
||||
void LAGLOG::save(EMUFILE *os)
|
||||
{
|
||||
// write size
|
||||
int size = lagLog.size();
|
||||
write32le(size, os);
|
||||
if (size)
|
||||
{
|
||||
// write array
|
||||
if (!alreadyCompressed)
|
||||
compressData();
|
||||
write32le(compressedLagLog.size(), os);
|
||||
os->fwrite(&compressedLagLog[0], compressedLagLog.size());
|
||||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool LAGLOG::load(EMUFILE *is)
|
||||
{
|
||||
int size;
|
||||
if (read32le(&size, is))
|
||||
{
|
||||
alreadyCompressed = true;
|
||||
lagLog.resize(size, LAGGED_UNKNOWN);
|
||||
if (size)
|
||||
{
|
||||
// read and uncompress array
|
||||
int comprlen;
|
||||
uLongf destlen = size * sizeof(int);
|
||||
if (!read32le(&comprlen, is)) return true;
|
||||
if (comprlen <= 0) return true;
|
||||
compressedLagLog.resize(comprlen);
|
||||
if (is->fread(&compressedLagLog[0], comprlen) != comprlen) return true;
|
||||
int e = uncompress((uint8*)&lagLog[0], &destlen, &compressedLagLog[0], comprlen);
|
||||
if (e != Z_OK && e != Z_BUF_ERROR) return true;
|
||||
} else
|
||||
{
|
||||
compressedLagLog.resize(0);
|
||||
}
|
||||
// all ok
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool LAGLOG::skipLoad(EMUFILE *is)
|
||||
{
|
||||
int size;
|
||||
if (read32le(&size, is))
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
// skip array
|
||||
if (!read32le(&size, is)) return true;
|
||||
if (is->fseek(size, SEEK_CUR) != 0) return true;
|
||||
}
|
||||
// all ok
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
void LAGLOG::invalidateFromFrame(int frame)
|
||||
{
|
||||
if (frame >= 0 && frame < (int)lagLog.size())
|
||||
{
|
||||
lagLog.resize(frame);
|
||||
alreadyCompressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LAGLOG::setLagInfo(int frame, bool lagFlag)
|
||||
{
|
||||
if ((int)lagLog.size() <= frame)
|
||||
lagLog.resize(frame + 1, LAGGED_UNKNOWN);
|
||||
|
||||
if (lagFlag)
|
||||
lagLog[frame] = LAGGED_YES;
|
||||
else
|
||||
lagLog[frame] = LAGGED_NO;
|
||||
|
||||
alreadyCompressed = false;
|
||||
}
|
||||
void LAGLOG::eraseFrame(int frame, int numFrames)
|
||||
{
|
||||
if (frame < (int)lagLog.size())
|
||||
{
|
||||
if (numFrames == 1)
|
||||
{
|
||||
// erase 1 frame
|
||||
lagLog.erase(lagLog.begin() + frame);
|
||||
alreadyCompressed = false;
|
||||
} else if (numFrames > 1)
|
||||
{
|
||||
// erase many frames
|
||||
if (frame + numFrames > (int)lagLog.size())
|
||||
numFrames = (int)lagLog.size() - frame;
|
||||
lagLog.erase(lagLog.begin() + frame, lagLog.begin() + (frame + numFrames));
|
||||
alreadyCompressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
void LAGLOG::insertFrame(int frame, bool lagFlag, int numFrames)
|
||||
{
|
||||
if (frame < (int)lagLog.size())
|
||||
{
|
||||
// insert
|
||||
lagLog.insert(lagLog.begin() + frame, numFrames, (lagFlag) ? LAGGED_YES : LAGGED_NO);
|
||||
} else
|
||||
{
|
||||
// append
|
||||
lagLog.resize(frame + 1, LAGGED_UNKNOWN);
|
||||
if (lagFlag)
|
||||
lagLog[frame] = LAGGED_YES;
|
||||
else
|
||||
lagLog[frame] = LAGGED_NO;
|
||||
}
|
||||
alreadyCompressed = false;
|
||||
}
|
||||
|
||||
// getters
|
||||
int LAGLOG::getSize(void)
|
||||
{
|
||||
return lagLog.size();
|
||||
}
|
||||
int LAGLOG::getLagInfoAtFrame(int frame)
|
||||
{
|
||||
if (frame < (int)lagLog.size())
|
||||
return lagLog[frame];
|
||||
else
|
||||
return LAGGED_UNKNOWN;
|
||||
}
|
||||
|
||||
int LAGLOG::findFirstChange(LAGLOG& theirLog)
|
||||
{
|
||||
// search for differences to the end of this or their LagLog, whichever is less
|
||||
int end = lagLog.size() - 1;
|
||||
int their_log_end = theirLog.getSize() - 1;
|
||||
if (end > their_log_end)
|
||||
end = their_log_end;
|
||||
|
||||
uint8 my_lag_info, their_lag_info;
|
||||
for (int i = 0; i <= end; ++i)
|
||||
{
|
||||
// if old info != new info and both infos are known
|
||||
my_lag_info = lagLog[i];
|
||||
their_lag_info = theirLog.getLagInfoAtFrame(i);
|
||||
if ((my_lag_info == LAGGED_YES && their_lag_info == LAGGED_NO) || (my_lag_info == LAGGED_NO && their_lag_info == LAGGED_YES))
|
||||
return i;
|
||||
}
|
||||
// no difference was found
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Specification file for LagLog class
|
||||
|
||||
enum LAG_FLAG_VALUES
|
||||
{
|
||||
LAGGED_NO = 0,
|
||||
LAGGED_YES = 1,
|
||||
LAGGED_UNKNOWN = 2
|
||||
};
|
||||
|
||||
class LAGLOG
|
||||
{
|
||||
public:
|
||||
LAGLOG(void);
|
||||
void reset(void);
|
||||
|
||||
void compressData(void);
|
||||
bool isAlreadyCompressed(void);
|
||||
void resetCompressedStatus(void);
|
||||
|
||||
void save(EMUFILE *os);
|
||||
bool load(EMUFILE *is);
|
||||
bool skipLoad(EMUFILE *is);
|
||||
|
||||
void invalidateFromFrame(int frame);
|
||||
|
||||
void setLagInfo(int frame, bool lagFlag);
|
||||
void eraseFrame(int frame, int numFrames = 1);
|
||||
void insertFrame(int frame, bool lagFlag, int numFrames = 1);
|
||||
|
||||
int getSize(void);
|
||||
int getLagInfoAtFrame(int frame);
|
||||
|
||||
int findFirstChange(LAGLOG& theirLog);
|
||||
|
||||
private:
|
||||
// saved data
|
||||
std::vector<uint8> compressedLagLog;
|
||||
|
||||
// not saved data
|
||||
std::vector<uint8> lagLog;
|
||||
bool alreadyCompressed; // to compress only once
|
||||
};
|
|
@ -40,6 +40,10 @@ extern bool mustEngageTaseditor;
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef __QT_DRIVER__
|
||||
#include "./drivers/Qt/TasEditor/TasEditorWindow.h"
|
||||
#endif
|
||||
|
||||
extern int RAMInitOption;
|
||||
extern int RAMInitSeed;
|
||||
|
||||
|
@ -1184,7 +1188,7 @@ void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author)
|
|||
//either dumps the current joystick state or loads one state from the movie
|
||||
void FCEUMOV_AddInputState()
|
||||
{
|
||||
#ifdef __WIN_DRIVER__
|
||||
#if defined(__WIN_DRIVER__) || defined(__QT_DRIVER__)
|
||||
if (movieMode == MOVIEMODE_TASEDITOR)
|
||||
{
|
||||
// if movie length is less or equal to currFrame, pad it with empty frames
|
||||
|
|
|
@ -269,6 +269,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
extern EMOVIEMODE movieMode;
|
||||
extern MovieData currMovieData;
|
||||
extern int currFrameCounter;
|
||||
extern char curMovieFilename[512];
|
||||
|
|
Loading…
Reference in New Issue