mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-06 13:25:53 +00:00
Add log saving & hook up options editor
This commit is contained in:
parent
2b6851f7bf
commit
dbeb871336
@ -82,6 +82,24 @@ MainWindow::MainWindow(QWidget* parent)
|
|||||||
mFont.setPointSize(10);
|
mFont.setPointSize(10);
|
||||||
m_ui->processOutput->setFont(mFont);
|
m_ui->processOutput->setFont(mFont);
|
||||||
m_cursor = QTextCursor(m_ui->processOutput->document());
|
m_cursor = QTextCursor(m_ui->processOutput->document());
|
||||||
|
connect(m_ui->saveLogButton, &QPushButton::pressed, this, [this] {
|
||||||
|
QString defaultFileName = QStringLiteral("urde-") + QDateTime::currentDateTime().toString(Qt::DateFormat::ISODate);
|
||||||
|
defaultFileName.replace(QLatin1Char(':'), QLatin1Char('-'));
|
||||||
|
const QString fileName =
|
||||||
|
QFileDialog::getSaveFileName(this, tr("Save Log"), defaultFileName, QStringLiteral("*.log"));
|
||||||
|
if (fileName.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QFile file = QFile(fileName);
|
||||||
|
if (file.open(QFile::OpenModeFlag::WriteOnly | QFile::OpenModeFlag::Truncate | QFile::OpenModeFlag::Text)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
stream << m_ui->processOutput->toPlainText();
|
||||||
|
stream.flush();
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QMessageBox::critical(this, tr("Save Log"), tr("Failed to open log file"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
m_updateURDEButton = new QPushButton(tr("Update URDE"), m_ui->centralwidget);
|
m_updateURDEButton = new QPushButton(tr("Update URDE"), m_ui->centralwidget);
|
||||||
m_ui->gridLayout->addWidget(m_updateURDEButton, 2, 3, 1, 1);
|
m_ui->gridLayout->addWidget(m_updateURDEButton, 2, 3, 1, 1);
|
||||||
@ -592,7 +610,7 @@ void MainWindow::initOptions() {
|
|||||||
bool isChecked = state == Qt::Checked;
|
bool isChecked = state == Qt::Checked;
|
||||||
if (hecl::com_enableCheats->toBoolean() && !isChecked) {
|
if (hecl::com_enableCheats->toBoolean() && !isChecked) {
|
||||||
m_ui->enableCheatsBox->setChecked(false);
|
m_ui->enableCheatsBox->setChecked(false);
|
||||||
m_ui->tweaksOptionsGroup->setVisible(false);
|
// m_ui->tweaksOptionsGroup->setVisible(false);
|
||||||
m_ui->warpBtn->setVisible(false);
|
m_ui->warpBtn->setVisible(false);
|
||||||
}
|
}
|
||||||
m_ui->developerOptionsGroup->setVisible(isChecked);
|
m_ui->developerOptionsGroup->setVisible(isChecked);
|
||||||
@ -602,7 +620,7 @@ void MainWindow::initOptions() {
|
|||||||
|
|
||||||
m_ui->enableCheatsBox->setToolTip(QString::fromUtf8(hecl::com_enableCheats->rawHelp().data()));
|
m_ui->enableCheatsBox->setToolTip(QString::fromUtf8(hecl::com_enableCheats->rawHelp().data()));
|
||||||
m_ui->enableCheatsBox->setChecked(hecl::com_enableCheats->toBoolean());
|
m_ui->enableCheatsBox->setChecked(hecl::com_enableCheats->toBoolean());
|
||||||
m_ui->tweaksOptionsGroup->setVisible(hecl::com_enableCheats->toBoolean());
|
m_ui->tweaksOptionsGroup->setVisible(false); // hecl::com_enableCheats->toBoolean()
|
||||||
m_ui->warpBtn->setVisible(hecl::com_enableCheats->toBoolean());
|
m_ui->warpBtn->setVisible(hecl::com_enableCheats->toBoolean());
|
||||||
connect(m_ui->enableCheatsBox, &QCheckBox::stateChanged, this, [this](int state) {
|
connect(m_ui->enableCheatsBox, &QCheckBox::stateChanged, this, [this](int state) {
|
||||||
bool isChecked = state == Qt::Checked;
|
bool isChecked = state == Qt::Checked;
|
||||||
@ -610,7 +628,7 @@ void MainWindow::initOptions() {
|
|||||||
m_ui->developerModeBox->setChecked(true);
|
m_ui->developerModeBox->setChecked(true);
|
||||||
m_ui->developerOptionsGroup->setVisible(true);
|
m_ui->developerOptionsGroup->setVisible(true);
|
||||||
}
|
}
|
||||||
m_ui->tweaksOptionsGroup->setVisible(isChecked);
|
// m_ui->tweaksOptionsGroup->setVisible(isChecked);
|
||||||
m_ui->warpBtn->setVisible(isChecked);
|
m_ui->warpBtn->setVisible(isChecked);
|
||||||
hecl::CVarManager::instance()->setCheatsEnabled(isChecked, true);
|
hecl::CVarManager::instance()->setCheatsEnabled(isChecked, true);
|
||||||
m_cvarManager.serialize();
|
m_cvarManager.serialize();
|
||||||
@ -630,6 +648,32 @@ void MainWindow::initOptions() {
|
|||||||
hecl::CVarManager::instance()->findOrMakeCVar(
|
hecl::CVarManager::instance()->findOrMakeCVar(
|
||||||
"stateManager.logScripting"sv, "Prints object communication to the console", false,
|
"stateManager.logScripting"sv, "Prints object communication to the console", false,
|
||||||
hecl::CVar::EFlags::ReadOnly | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Game));
|
hecl::CVar::EFlags::ReadOnly | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Game));
|
||||||
|
|
||||||
|
m_launchOptionsModel.setStringList(QSettings().value(QStringLiteral("urde_arguments")).toStringList());
|
||||||
|
m_ui->launchOptionsList->setModel(&m_launchOptionsModel);
|
||||||
|
|
||||||
|
connect(m_ui->launchOptionAddButton, &QPushButton::clicked, this, [this] {
|
||||||
|
int row = m_launchOptionsModel.rowCount();
|
||||||
|
if (m_launchOptionsModel.insertRow(row)) {
|
||||||
|
QModelIndex index = m_launchOptionsModel.index(row);
|
||||||
|
m_ui->launchOptionsList->selectionModel()->select(index, QItemSelectionModel::SelectionFlag::ClearAndSelect);
|
||||||
|
m_ui->launchOptionsList->edit(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(m_ui->launchOptionDeleteButton, &QPushButton::clicked, this, [this] {
|
||||||
|
QItemSelectionModel* selection = m_ui->launchOptionsList->selectionModel();
|
||||||
|
if (selection == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QModelIndexList list = selection->selectedRows();
|
||||||
|
for (QModelIndex index : list) {
|
||||||
|
m_launchOptionsModel.removeRow(index.row());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(&m_launchOptionsModel, &QStringListModel::dataChanged, this,
|
||||||
|
[this]() { QSettings().setValue(QStringLiteral("urde_arguments"), m_launchOptionsModel.stringList()); });
|
||||||
|
connect(&m_launchOptionsModel, &QStringListModel::rowsRemoved, this,
|
||||||
|
[this]() { QSettings().setValue(QStringLiteral("urde_arguments"), m_launchOptionsModel.stringList()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initNumberComboOption(QComboBox* action, hecl::CVar* cvar) {
|
void MainWindow::initNumberComboOption(QComboBox* action, hecl::CVar* cvar) {
|
||||||
|
@ -41,6 +41,7 @@ class MainWindow : public QMainWindow {
|
|||||||
URDEVersion m_recommendedVersion;
|
URDEVersion m_recommendedVersion;
|
||||||
QPushButton* m_updateURDEButton;
|
QPushButton* m_updateURDEButton;
|
||||||
bool m_inContinueNote = false;
|
bool m_inContinueNote = false;
|
||||||
|
QStringListModel m_launchOptionsModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget* parent = nullptr);
|
explicit MainWindow(QWidget* parent = nullptr);
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QTabWidget" name="heclTabs">
|
<widget class="QTabWidget" name="heclTabs">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="dataTab">
|
<widget class="QWidget" name="dataTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -187,6 +187,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QPushButton" name="saveLogButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Save Log</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="optionsTab">
|
<widget class="QWidget" name="optionsTab">
|
||||||
@ -463,6 +476,15 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -475,7 +497,11 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_9">
|
<layout class="QGridLayout" name="gridLayout_9">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QListView" name="tweaksOptionsList"/>
|
<widget class="QListView" name="tweaksOptionsList">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user