1313
1414#include " ../src/TombRaiderLinuxLauncher.hpp"
1515#include " ui_TombRaiderLinuxLauncher.h"
16+ #include < qlineedit.h>
1617
1718
1819TombRaiderLinuxLauncher::TombRaiderLinuxLauncher (QWidget *parent)
@@ -369,6 +370,27 @@ void TombRaiderLinuxLauncher::setOptionsClicked() {
369370 readSavedSettings ();
370371}
371372
373+ QStringList TombRaiderLinuxLauncher::parsToArg (const QString& str) {
374+ return str.split (QRegularExpression (" \\ s+" ), Qt::SkipEmptyParts);
375+ }
376+
377+ QVector<QPair<QString, QString>>
378+ TombRaiderLinuxLauncher::parsToEnv (const QString& str) {
379+ QRegularExpression re (" (\\ w+)\\ s*=\\ s*\" ([^\" ]*)\" " );
380+ QRegularExpressionMatchIterator it = re.globalMatch (str);
381+
382+ QVector<QPair<QString, QString>> envList;
383+ while (it.hasNext ()) {
384+ QRegularExpressionMatch match = it.next ();
385+ // VARIABLE="some text here"
386+ QPair<QString, QString> env;
387+ env.first = match.captured (1 ); // VARIABLE
388+ env.second = match.captured (2 ); // "some text here"
389+ envList.append (env);
390+ }
391+ return envList;
392+ }
393+
372394void TombRaiderLinuxLauncher::linkClicked () {
373395 qDebug () << " linkClicked()" ;
374396 QModelIndex current = ui->listViewLevels ->currentIndex ();
@@ -377,45 +399,58 @@ void TombRaiderLinuxLauncher::linkClicked() {
377399 if (id != 0 ) {
378400 qint64 type = settings.value (
379401 QString (" level%1/RunnerType" ).arg (id)).toInt ();
402+ QLineEdit* input = ui->lineEditEnvironmentVariables ;
380403 qDebug () << " Type was: " << type;
404+
381405 if (type == 0 ) {
382- Model::getInstance ().runWine (id);
406+ QVector<QPair<QString, QString>> envList =
407+ parsToEnv (input->text ());
408+ if (ui->checkBoxSetup ->isChecked ()) {
409+ Model::getInstance ().setUmuSetup ();
410+ }
411+ Model::getInstance ().setUmuEnv (envList);
412+ Model::getInstance ().runUmu (id);
413+
383414 } else if (type == 1 ) {
384- const QString arg = ui->lineEditEnvironmentVariables ->text ();
385- QStringList argList = arg.split (
386- QRegularExpression (" \\ s+" ), Qt::SkipEmptyParts);
387- Model::getInstance ().runLutris (argList);
415+ QVector<QPair<QString, QString>> envList =
416+ parsToEnv (input->text ());
417+ if (ui->checkBoxSetup ->isChecked ()) {
418+ Model::getInstance ().setUmuSetup ();
419+ }
420+ Model::getInstance ().setWineEnv (envList);
421+ Model::getInstance ().runWine (id);
422+
388423 } else if (type == 2 ) {
424+ QStringList argList = parsToArg (input->text ());
425+ Model::getInstance ().runLutris (argList);
426+
427+ } else if (type == 3 ) {
389428 if (!controller.link (id)) {
390429 qDebug () << " link error" ;
391430 }
392- const QString arg = ui->lineEditEnvironmentVariables ->text ();
393- QStringList argList = arg.split (
394- QRegularExpression (" \\ s+" ), Qt::SkipEmptyParts);
431+ QStringList argList = parsToArg (input->text ());
395432 Model::getInstance ().runLutris (argList);
396- } else if (type == 3 ) {
397- Model::getInstance ().runSteam (id);
433+
398434 } else if (type == 4 ) {
435+ Model::getInstance ().runSteam (id);
436+
437+ } else if (type == 5 ) {
399438 if (levelListModel->getListType ()) {
400439 id = (-1 )*id;
401440 }
402441 if (!controller.link (id)) {
403442 qDebug () << " link error" ;
404443 }
405444 QApplication::quit ();
406- } else if (type == 5 ) {
445+
446+ } else if (type == 6 ) {
407447 if (levelListModel->getListType ()) {
408448 id = (-1 )*id;
409449 }
410450 if (!controller.link (id)) {
411451 qDebug () << " link error" ;
412452 }
413- } else if (type == 6 ) {
414- const QString arg = ui->lineEditEnvironmentVariables ->text ();
415- QStringList argList = arg.split (
416- QRegularExpression (" \\ s+" ), Qt::SkipEmptyParts);
417- qDebug () << " args was: " << argList[0 ];
418- Model::getInstance ().runUmu (id);
453+
419454 } else if (type == 7 ) {
420455 Model::getInstance ().runBash (id);
421456 }
0 commit comments