diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index f752e85d..ce31269f 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -2649,6 +2649,7 @@ Help + @@ -2944,6 +2945,11 @@ Export Map Timelapse Image... + + + Open Log File + + diff --git a/include/core/parseutil.h b/include/core/parseutil.h index 82fad4e2..96cc1201 100644 --- a/include/core/parseutil.h +++ b/include/core/parseutil.h @@ -42,6 +42,7 @@ public: ParseUtil(); void set_root(QString); static QString readTextFile(QString); + static int textFileLineCount(const QString &path); void strip_comment(QString*); QList* parseAsm(QString); int evaluateDefine(QString, QMap*); diff --git a/include/editor.h b/include/editor.h index e876a3ca..e03b3a9e 100644 --- a/include/editor.h +++ b/include/editor.h @@ -154,6 +154,7 @@ public: void shouldReselectEvents(); void scaleMapView(int); + void openInTextEditor(const QString &path, int lineNum = 0) const; public slots: void openMapScripts() const; @@ -188,7 +189,6 @@ private: QString getMovementPermissionText(uint16_t collision, uint16_t elevation); QString getMetatileDisplayMessage(uint16_t metatileId); bool eventLimitReached(Map *, QString); - void openInTextEditor(const QString &path, int lineNum = 0) const; bool startDetachedProcess(const QString &command, const QString &workingDirectory = QString(), qint64 *pid = nullptr) const; diff --git a/include/mainwindow.h b/include/mainwindow.h index 3d09c5e7..d6754f1b 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -222,6 +222,7 @@ private slots: void on_toolButton_ExpandAll_clicked(); void on_toolButton_CollapseAll_clicked(); void on_actionAbout_Porymap_triggered(); + void on_actionOpen_Log_File_triggered(); void on_pushButton_AddCustomHeaderField_clicked(); void on_pushButton_DeleteCustomHeaderField_clicked(); void on_tableWidget_CustomHeaderFields_cellChanged(int row, int column); diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index 74330738..e59cee49 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -49,11 +49,16 @@ QString ParseUtil::readTextFile(QString path) { in.setCodec("UTF-8"); QString text = ""; while (!in.atEnd()) { - text += in.readLine() + "\n"; + text += in.readLine() + '\n'; } return text; } +int ParseUtil::textFileLineCount(const QString &path) { + const QString text = readTextFile(path); + return text.split('\n').count() + 1; +} + QList* ParseUtil::parseAsm(QString filename) { QList *parsed = new QList; diff --git a/src/editor.cpp b/src/editor.cpp index 617f29d3..cd11a598 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -2078,7 +2078,6 @@ bool Editor::startDetachedProcess(const QString &command, const QString &working logInfo("Executing command: " + command); QProcess process; #ifdef Q_OS_WIN - // Windows is WeirdChamp QStringList arguments = ParseUtil::splitShellCommand(command); const QString program = arguments.takeFirst(); QFileInfo programFileInfo(program); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dd7f71bf..467ac6bc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2691,6 +2691,12 @@ void MainWindow::on_actionAbout_Porymap_triggered() window->show(); } +void MainWindow::on_actionOpen_Log_File_triggered() { + const QString logPath = getLogPath(); + const int lineCount = ParseUtil::textFileLineCount(logPath); + editor->openInTextEditor(logPath, lineCount); +} + void MainWindow::on_actionEdit_Preferences_triggered() { if (!preferenceEditor) { preferenceEditor = new PreferenceEditor(this);