mirror of
https://github.com/redstrate/Novus.git
synced 2025-05-02 16:17:44 +00:00
The game has *tons* of Lua scripts for event scripting, and are very interesting to explore. I had to do manually call luadec before, but now it should be much easier by automatically decompiling Lua scripts in the Data Explorer.
48 lines
No EOL
1.2 KiB
C++
48 lines
No EOL
1.2 KiB
C++
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "luabpart.h"
|
|
|
|
#include <QFile>
|
|
#include <QJsonArray>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QProcess>
|
|
#include <QTemporaryFile>
|
|
#include <QTextEdit>
|
|
#include <QVBoxLayout>
|
|
#include <physis.hpp>
|
|
|
|
LuabPart::LuabPart(QWidget *parent)
|
|
: QWidget(parent)
|
|
{
|
|
auto layout = new QVBoxLayout();
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
m_codeEdit = new QTextEdit();
|
|
m_codeEdit->setReadOnly(true);
|
|
layout->addWidget(m_codeEdit);
|
|
|
|
setLayout(layout);
|
|
}
|
|
|
|
void LuabPart::load(physis_Buffer buffer)
|
|
{
|
|
QTemporaryFile temporaryFile;
|
|
if (temporaryFile.open()) {
|
|
QFile file(temporaryFile.fileName());
|
|
file.open(QIODevice::WriteOnly);
|
|
file.write(reinterpret_cast<const char *>(buffer.data), buffer.size);
|
|
file.close();
|
|
|
|
QProcess luaDecProcess;
|
|
luaDecProcess.setProgram(QStringLiteral("./luadec"));
|
|
luaDecProcess.setArguments({temporaryFile.fileName()});
|
|
luaDecProcess.start();
|
|
luaDecProcess.waitForFinished();
|
|
|
|
m_codeEdit->setText(QString::fromUtf8(luaDecProcess.readAllStandardOutput()));
|
|
}
|
|
}
|
|
|
|
#include "moc_luabpart.cpp" |