aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-06-30 19:26:37 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-06-30 19:26:37 +0200
commit4833e4be7e55776a47169cdea926444e1cdeabe6 (patch)
treee24b5e70a961574da28218a499c2f9ec281de6a5
parentcbf1b717914ca9d3e52d7ceaae153928afcc9eda (diff)
downloadOFQT-4833e4be7e55776a47169cdea926444e1cdeabe6.tar.gz
OFQT-4833e4be7e55776a47169cdea926444e1cdeabe6.zip
add launch options to Qt frontend
-rw-r--r--src/qt/main.cpp3
-rw-r--r--src/qt/settings.cpp2
-rw-r--r--src/qt/settings.ui119
-rw-r--r--src/qt/workers.cpp25
-rw-r--r--src/qt/workers.hpp5
-rw-r--r--src/vdf/vdf.c2
6 files changed, 110 insertions, 46 deletions
diff --git a/src/qt/main.cpp b/src/qt/main.cpp
index 9cf530b..65a2751 100644
--- a/src/qt/main.cpp
+++ b/src/qt/main.cpp
@@ -4,6 +4,9 @@
int main(int argc, char *argv[])
{
+ QCoreApplication::setOrganizationName("OFQT");
+ QCoreApplication::setApplicationName("OFQT");
+
QApplication a(argc, argv);
MainWindow w;
w.show();
diff --git a/src/qt/settings.cpp b/src/qt/settings.cpp
index 507e8c8..06d2e6f 100644
--- a/src/qt/settings.cpp
+++ b/src/qt/settings.cpp
@@ -23,11 +23,13 @@ void Settings::refresh()
ui->revisionLabel->setText(QString("%1").arg(this->worker->getRevision()));
ui->installLabel->setText(this->worker->getOfDir());
+ ui->argumentsEdit->setText(this->worker->getArguments());
}
void Settings::applySettings()
{
worker->setRemote(ui->serverEdit->text());
+ worker->setArguments(ui->argumentsEdit->text());
this->hide();
}
diff --git a/src/qt/settings.ui b/src/qt/settings.ui
index 4fde446..9f6e972 100644
--- a/src/qt/settings.ui
+++ b/src/qt/settings.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>375</width>
- <height>259</height>
+ <width>560</width>
+ <height>300</height>
</rect>
</property>
<property name="windowTitle">
@@ -19,35 +19,68 @@
<property name="currentIndex">
<number>0</number>
</property>
- <widget class="QWidget" name="serverTab">
+ <property name="usesScrollButtons">
+ <bool>false</bool>
+ </property>
+ <property name="documentMode">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="settingsTab">
<attribute name="title">
- <string>Server</string>
+ <string>Settings</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
- <widget class="QLabel" name="serverLabel">
+ <widget class="QLabel" name="argumentsLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
- <string>Server</string>
+ <string>Launch Arguments</string>
</property>
</widget>
</item>
<item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <widget class="QLineEdit" name="argumentsEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="serverLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- </spacer>
+ <property name="text">
+ <string>Server</string>
+ </property>
+ </widget>
</item>
<item>
- <widget class="QLineEdit" name="serverEdit"/>
+ <widget class="QLineEdit" name="serverEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
</layout>
</item>
@@ -75,29 +108,31 @@
<layout class="QHBoxLayout" name="revisionLayout">
<item>
<widget class="QLabel" name="revisionText">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Current Revision</string>
</property>
</widget>
</item>
<item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
<widget class="QLabel" name="revisionLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>CURRENT_REVISION</string>
</property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
</widget>
</item>
</layout>
@@ -106,29 +141,25 @@
<layout class="QHBoxLayout" name="installLayout">
<item>
<widget class="QLabel" name="installText">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Install Path</string>
</property>
</widget>
</item>
<item>
- <spacer name="horizontalSpacer_4">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="installLabel">
+ <widget class="QLineEdit" name="installLabel">
<property name="text">
<string>INSTALL_PATH</string>
</property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
diff --git a/src/qt/workers.cpp b/src/qt/workers.cpp
index dc761e9..9d5dc37 100644
--- a/src/qt/workers.cpp
+++ b/src/qt/workers.cpp
@@ -86,6 +86,16 @@ void Worker::setRemote(QString remotestr)
setLocalRemote(of_dir, remote);
}
+QString Worker::getArguments()
+{
+ return settings.value("launchArguments", QString()).toString();
+}
+
+void Worker::setArguments(QString argumentstr)
+{
+ settings.setValue("launchArguments", argumentstr);
+}
+
int Worker::getRevision()
{
return getLocalRevision(of_dir);
@@ -309,7 +319,20 @@ void Worker::doWork(const enum Worker::Tasks_t &parameter) {
case TASK_RUN:
result = getSteamPID() > -1 ? RESULT_EXIT : RESULT_NO_STEAM;
- if (result == RESULT_EXIT) runOpenFortress(NULL, 0);
+ if (result == RESULT_EXIT)
+ {
+ auto arg_list = getArguments().split(' ', Qt::SkipEmptyParts);
+
+ auto argv = (char**)malloc(sizeof(char*) * arg_list.size());
+ for (int i = 0; i < arg_list.size(); ++i)
+ argv[i] = strdup(arg_list[i].toStdString().c_str());
+
+ runOpenFortress(argv, arg_list.size());
+
+ for (int i = 0; i < arg_list.size(); ++i)
+ free(argv[i]);
+ free(argv);
+ }
break;
}
diff --git a/src/qt/workers.hpp b/src/qt/workers.hpp
index 82325cb..506d7ce 100644
--- a/src/qt/workers.hpp
+++ b/src/qt/workers.hpp
@@ -2,6 +2,7 @@
#define WORKERS_HPP
#include <QObject>
+#include <QSettings>
#include <limits.h>
QT_BEGIN_NAMESPACE
@@ -22,6 +23,8 @@ private:
bool do_work = true;
bool update_in_progress = false;
+ QSettings settings;
+
public:
int progress = -1;
QString infoText;
@@ -32,6 +35,8 @@ public:
QString getOfDir();
QString getRemote();
void setRemote(QString);
+ QString getArguments();
+ void setArguments(QString);
int getRevision();
int getRemoteRevision();
diff --git a/src/vdf/vdf.c b/src/vdf/vdf.c
index fc43e8c..c9130a6 100644
--- a/src/vdf/vdf.c
+++ b/src/vdf/vdf.c
@@ -195,7 +195,7 @@ struct vdf_object* vdf_parse_buffer(const char* buffer, size_t size)
o->type = VDF_TYPE_ARRAY;
o->data.data_array.len = 0;
o->data.data_array.data_value = malloc((sizeof(void*)) * (o->data.data_array.len + 1));
- o->data.data_array.data_value[o->data.data_array.len] = malloc(sizeof(struct vdf_object)),
+ o->data.data_array.data_value[o->data.data_array.len] = malloc(sizeof(struct vdf_object));
o->data.data_array.data_value[o->data.data_array.len]->parent = o;
o = o->data.data_array.data_value[o->data.data_array.len];