From 229f9fed2501ae7bb9233f147aca80c1bdba52f0 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 21 May 2023 00:29:22 -0600 Subject: [PATCH] lightpreview: hack in quote parsing for qbsp/vis/light args --- lightpreview/glview.cpp | 3 +++ lightpreview/mainwindow.cpp | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lightpreview/glview.cpp b/lightpreview/glview.cpp index afb9156a..755ccf9c 100644 --- a/lightpreview/glview.cpp +++ b/lightpreview/glview.cpp @@ -174,6 +174,9 @@ void GLView::renderBSP(const QString &file, const mbsp_t &bsp) // FIXME: move to a lightpreview_settings settings::common_settings settings; + // FIXME: copy the -path args from light + settings.paths.copy_from(light_options.paths); + bsp.loadversion->game->init_filesystem(file.toStdString(), settings); img::load_textures(&bsp, settings); diff --git a/lightpreview/mainwindow.cpp b/lightpreview/mainwindow.cpp index b4408c9a..c320971d 100644 --- a/lightpreview/mainwindow.cpp +++ b/lightpreview/mainwindow.cpp @@ -19,6 +19,7 @@ See file, 'COPYING', for details. #include "mainwindow.h" +#include #include #include #include @@ -182,9 +183,21 @@ static std::vector ParseArgs(const QLineEdit *line_edit) if (text.isEmpty()) return result; - for (const auto &str : text.split(' ')) { - qDebug() << "got token " << str; - result.push_back(str.toStdString()); + bool inside_quotes = false; + for (const auto &str : text.split('"')) { + qDebug() << "got token " << str << " inside quote? " << inside_quotes; + + if (inside_quotes) { + result.push_back(str.toStdString()); + } else { + // split by spaces + for (const auto &str2 : str.split(' ', QString::SkipEmptyParts)) { + qDebug() << "got sub token " << str2; + result.push_back(str2.toStdString()); + } + } + + inside_quotes = !inside_quotes; } return result;