From 131e3954709a47ffa63a7d4b1d43bb30a3efaf6e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 15 Aug 2023 07:51:35 -0400 Subject: [PATCH] add common args --- lightpreview/mainwindow.cpp | 19 ++++++++++++++++--- lightpreview/mainwindow.h | 5 +++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lightpreview/mainwindow.cpp b/lightpreview/mainwindow.cpp index 040eb803..b9805f72 100644 --- a/lightpreview/mainwindow.cpp +++ b/lightpreview/mainwindow.cpp @@ -146,6 +146,7 @@ void MainWindow::createPropertiesSidebar() vis_checkbox = new QCheckBox(tr("vis")); + common_options = new QLineEdit(); qbsp_options = new QLineEdit(); vis_options = new QLineEdit(); light_options = new QLineEdit(); @@ -183,6 +184,7 @@ void MainWindow::createPropertiesSidebar() bspx_normals = new QCheckBox(tr("BSPX: Face Normals")); bspx_normals->setChecked(true); + formLayout->addRow(tr("common"), common_options); formLayout->addRow(tr("qbsp"), qbsp_options); formLayout->addRow(vis_checkbox, vis_options); formLayout->addRow(tr("light"), light_options); @@ -220,6 +222,7 @@ void MainWindow::createPropertiesSidebar() // load state persisted in settings QSettings s; + common_options->setText(s.value("common_options").toString()); qbsp_options->setText(s.value("qbsp_options").toString()); vis_checkbox->setChecked(s.value("vis_enabled").toBool()); vis_options->setText(s.value("vis_options").toString()); @@ -483,8 +486,8 @@ std::filesystem::path MakeFSPath(const QString &string) return std::filesystem::path{string.toStdU16String()}; } -bspdata_t MainWindow::QbspVisLight_Common(const std::filesystem::path &name, std::vector extra_qbsp_args, - std::vector extra_vis_args, std::vector extra_light_args, bool run_vis) +bspdata_t MainWindow::QbspVisLight_Common(const std::filesystem::path &name, std::vector extra_common_args, + std::vector extra_qbsp_args, std::vector extra_vis_args, std::vector extra_light_args, bool run_vis) { auto resetActiveTabText = [&]() { QMetaObject::invokeMethod(this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab, @@ -497,6 +500,9 @@ bspdata_t MainWindow::QbspVisLight_Common(const std::filesystem::path &name, std std::vector args{ "", // the exe path, which we're ignoring in this case }; + for (auto &extra : extra_common_args) { + args.push_back(extra); + } for (auto &extra : extra_qbsp_args) { args.push_back(extra); } @@ -516,6 +522,9 @@ bspdata_t MainWindow::QbspVisLight_Common(const std::filesystem::path &name, std std::vector vis_args{ "", // the exe path, which we're ignoring in this case }; + for (auto &extra : extra_common_args) { + vis_args.push_back(extra); + } for (auto &extra : extra_vis_args) { vis_args.push_back(extra); } @@ -531,6 +540,9 @@ bspdata_t MainWindow::QbspVisLight_Common(const std::filesystem::path &name, std std::vector light_args{ "", // the exe path, which we're ignoring in this case }; + for (auto &extra : extra_common_args) { + light_args.push_back(extra); + } for (auto &arg : extra_light_args) { light_args.push_back(arg); } @@ -659,7 +671,7 @@ int MainWindow::compileMap(const QString &file, bool is_reload) ConvertBSPFormat(&m_bspdata, &bspver_generic); } else { - m_bspdata = QbspVisLight_Common(fs_path, ParseArgs(qbsp_options), ParseArgs(vis_options), + m_bspdata = QbspVisLight_Common(fs_path, ParseArgs(common_options), ParseArgs(qbsp_options), ParseArgs(vis_options), ParseArgs(light_options), vis_checkbox->isChecked()); // FIXME: move to a lightpreview_settings @@ -756,6 +768,7 @@ void MainWindow::loadFileInternal(const QString &file, bool is_reload) // persist settings QSettings s; + s.setValue("common_options", common_options->text()); s.setValue("qbsp_options", qbsp_options->text()); s.setValue("vis_enabled", vis_checkbox->isChecked()); s.setValue("vis_options", vis_options->text()); diff --git a/lightpreview/mainwindow.h b/lightpreview/mainwindow.h index b484c525..9de058c7 100644 --- a/lightpreview/mainwindow.h +++ b/lightpreview/mainwindow.h @@ -94,8 +94,8 @@ private: void fileReloadTimerExpired(); int compileMap(const QString &file, bool is_reload); void compileThreadExited(); - bspdata_t QbspVisLight_Common(const fs::path &name, std::vector extra_qbsp_args, - std::vector extra_vis_args, std::vector extra_light_args, bool run_vis); + bspdata_t QbspVisLight_Common(const fs::path &name, std::vector extra_common_args, + std::vector extra_qbsp_args, std::vector extra_vis_args, std::vector extra_light_args, bool run_vis); protected: void dragEnterEvent(QDragEnterEvent *event) override; @@ -116,6 +116,7 @@ private: QCheckBox *bspx_decoupled_lm = nullptr; QCheckBox *bspx_normals = nullptr; + QLineEdit *common_options = nullptr; QLineEdit *qbsp_options = nullptr; QLineEdit *vis_options = nullptr; QLineEdit *light_options = nullptr;