diff --git a/icons/taseditor-icon32.png b/icons/taseditor-icon32.png
new file mode 100644
index 00000000..32bc52ee
Binary files /dev/null and b/icons/taseditor-icon32.png differ
diff --git a/resources.qrc b/resources.qrc
index 33608756..0b9407ee 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -29,5 +29,6 @@
icons/find.png
icons/cloud.png
icons/branch_spritesheet.png
+ icons/taseditor-icon32.png
diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp
index 6e6ddda8..d179854a 100644
--- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp
+++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp
@@ -86,6 +86,11 @@ enum DRAG_MODES
#define GREEN_BLUE_ARROW_IMAGE_ID (BLUE_ARROW_IMAGE_ID | GREEN_ARROW_IMAGE_ID)
#define MARKER_DRAG_COUNTDOWN_MAX 14
+#define PIANO_ROLL_ID_LEN 11
+
+// resources
+static char pianoRollSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLL";
+static char pianoRollSkipSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLX";
//----------------------------------------------------------------------------
//---- Main TAS Editor Window
@@ -173,6 +178,7 @@ TasEditorWindow::TasEditorWindow(QWidget *parent)
clipboard = QGuiApplication::clipboard();
setWindowTitle("TAS Editor");
+ //setWindowIcon( QIcon(":icons/taseditor-icon32.png") );
resize(512, 512);
@@ -3193,6 +3199,69 @@ void QPianoRoll::reset(void)
}
//----------------------------------------------------------------------------
+void QPianoRoll::save(EMUFILE *os, bool really_save)
+{
+ if (really_save)
+ {
+ updateLinesCount();
+ // write "PIANO_ROLL" string
+ os->fwrite(pianoRollSaveID, PIANO_ROLL_ID_LEN);
+ // write current top item
+ int top_item = lineOffset;
+ write32le(top_item, os);
+ }
+ else
+ {
+ // write "PIANO_ROLX" string
+ os->fwrite(pianoRollSkipSaveID, PIANO_ROLL_ID_LEN);
+ }
+}
+//----------------------------------------------------------------------------
+// returns true if couldn't load
+bool QPianoRoll::load(EMUFILE *is, unsigned int offset)
+{
+ reset();
+ updateLinesCount();
+ if (offset)
+ {
+ if (is->fseek(offset, SEEK_SET)) goto error;
+ }
+ else
+ {
+ // scroll to the beginning
+ //ListView_EnsureVisible(hwndList, 0, FALSE);
+ lineOffset = 0;
+ return false;
+ }
+ // read "PIANO_ROLL" string
+ char save_id[PIANO_ROLL_ID_LEN];
+ if ((int)is->fread(save_id, PIANO_ROLL_ID_LEN) < PIANO_ROLL_ID_LEN) goto error;
+ if (!strcmp(pianoRollSkipSaveID, save_id))
+ {
+ // string says to skip loading Piano Roll
+ FCEU_printf("No Piano Roll data in the file\n");
+ // scroll to the beginning
+ //ListView_EnsureVisible(hwndList, 0, FALSE);
+ lineOffset = 0;
+ return false;
+ }
+ if (strcmp(pianoRollSaveID, save_id)) goto error; // string is not valid
+ // read current top item and scroll Piano Roll there
+ int top_item;
+ if (!read32le(&top_item, is)) goto error;
+ //ListView_EnsureVisible(hwndList, currMovieData.getNumRecords() - 1, FALSE);
+ //ListView_EnsureVisible(hwndList, top_item, FALSE);
+ ensureTheLineIsVisible( currMovieData.getNumRecords() - 1 );
+ ensureTheLineIsVisible( top_item );
+ return false;
+error:
+ FCEU_printf("Error loading Piano Roll data\n");
+ // scroll to the beginning
+ //ListView_EnsureVisible(hwndList, 0, FALSE);
+ lineOffset = 0;
+ return true;
+}
+//----------------------------------------------------------------------------
void QPianoRoll::setScrollBars( QScrollBar *h, QScrollBar *v )
{
hbar = h; vbar = v;
@@ -3431,9 +3500,22 @@ void QPianoRoll::drawArrow( QPainter *painter, int xl, int yl, int value )
}
}
//----------------------------------------------------------------------------
+void QPianoRoll::updateLinesCount(void)
+{
+ // update the number of items in the list
+ int movie_size = currMovieData.getNumRecords();
+
+ maxLineOffset = movie_size - viewLines + 5;
+
+ if ( maxLineOffset < 0 )
+ {
+ maxLineOffset = 0;
+ }
+}
+//----------------------------------------------------------------------------
bool QPianoRoll::lineIsVisible( int lineNum )
{
- int lineEnd = lineOffset + viewLines;
+ int lineEnd = lineOffset + viewLines - 1;
return ( (lineNum >= lineOffset) && (lineNum < lineEnd) );
}
@@ -3444,7 +3526,9 @@ void QPianoRoll::ensureTheLineIsVisible( int lineNum )
{
int scrollOfs;
- lineOffset = lineNum - 3;
+ //printf("Seeking Frame %i\n", lineNum );
+
+ lineOffset = lineNum;
if ( lineOffset < 0 )
{
diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.h b/src/drivers/Qt/TasEditor/TasEditorWindow.h
index b5b85ea8..6de5354d 100644
--- a/src/drivers/Qt/TasEditor/TasEditorWindow.h
+++ b/src/drivers/Qt/TasEditor/TasEditorWindow.h
@@ -135,6 +135,8 @@ class QPianoRoll : public QWidget
~QPianoRoll(void);
void reset(void);
+ void save(EMUFILE *os, bool really_save);
+ bool load(EMUFILE *is, unsigned int offset);
void setScrollBars( QScrollBar *h, QScrollBar *v );
QFont getFont(void){ return font; };
@@ -143,6 +145,7 @@ class QPianoRoll : public QWidget
bool lineIsVisible( int lineNum );
+ void updateLinesCount(void);
void handleColumnSet(int column, bool altPressed);
void centerListAroundLine(int rowIndex);
void ensureTheLineIsVisible( int lineNum );
@@ -447,6 +450,7 @@ class TasEditorWindow : public QDialog
friend class PLAYBACK;
friend class HISTORY;
friend class MARKERS_MANAGER;
+ friend class TASEDITOR_PROJECT;
friend class QPianoRoll;
};
diff --git a/src/drivers/Qt/TasEditor/taseditor_project.cpp b/src/drivers/Qt/TasEditor/taseditor_project.cpp
index 98504a9f..b19bc893 100644
--- a/src/drivers/Qt/TasEditor/taseditor_project.cpp
+++ b/src/drivers/Qt/TasEditor/taseditor_project.cpp
@@ -64,14 +64,14 @@ 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 (taseditorConfig->autosaveSilent)
- //{
- // saveProject();
- //}
- //else
- //{
- // saveProjectAs();
- //}
+ if (taseditorConfig->autosaveSilent)
+ {
+ tasWin->saveProject();
+ }
+ else
+ {
+ tasWin->saveProjectAs();
+ }
// in case user pressed Cancel, postpone saving to next time
sheduleNextAutosave();
}
@@ -80,8 +80,10 @@ void TASEDITOR_PROJECT::update()
bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool saveMarkers, bool saveBookmarks, int saveGreenzone, bool saveHistory, bool savePianoRoll, bool saveSelection)
{
if (!differentName && getProjectFile().empty())
+ {
// no different name specified, and there's no current filename of the project
return false;
+ }
// check MD5
char md5OfMovie[256];
@@ -160,7 +162,7 @@ bool TASEDITOR_PROJECT::save(const char* differentName, bool inputInBinary, bool
unsigned int historyOffset = ofs->ftell();
history->save(ofs, saveHistory);
unsigned int pianoRollOffset = ofs->ftell();
- //pianoRoll.save(ofs, savePianoRoll);
+ tasWin->pianoRoll->save(ofs, savePianoRoll);
unsigned int selectionOffset = ofs->ftell();
selection->save(ofs, saveSelection);
// now write offsets (pointers)
@@ -319,7 +321,7 @@ bool TASEDITOR_PROJECT::load(const char* fullName)
pointerOffset += sizeof(unsigned int);
else
dataOffset = 0;
- //pianoRoll.load(&ifs, dataOffset);
+ tasWin->pianoRoll->load(&ifs, dataOffset);
if (numberOfPointers-- && !(ifs.fseek(pointerOffset, SEEK_SET)) && read32le(&dataOffset, &ifs))
pointerOffset += sizeof(unsigned int);