Skip to content

Commit

Permalink
[added] unix support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAnswer committed Nov 29, 2013
1 parent dc17b1e commit ce1e3be
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 4 deletions.
5 changes: 5 additions & 0 deletions configparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ int ConfigParser::loadFile(const QString& folder, const QString& configFileName)
QString oldFile = currentFile;
QString oldFolder = currentFolder;

//qDebug() << folder + "\\" + configFileName;
#ifdef Q_OS_WIN32
QFile fileObject(folder + "\\" + configFileName);
#else
QFile fileObject(folder + "/" + configFileName);
#endif

if (!fileObject.exists()) {
//qDebug() << configFileName << " doesnt exist";
Expand Down
21 changes: 21 additions & 0 deletions gameprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,28 @@ bool GameProcess::start(const QString& folder, const QString& executable, const

//qDebug() << "env:" << env;
process->setEnvironment(env);
#ifdef Q_OS_WIN32
process->start(folder + "\\" + executable, arguments);
#else
QString wineBinary = settings.value("wine_binary").toString();

if (wineBinary.isEmpty())
wineBinary = "wine";

QString args = settings.value("wine_args").toString();

QStringList argsList;
if (!args.isEmpty())
argsList = args.split(" ");

argsList.append(folder + "\\" + executable);

qDebug() << argsList;

if (!QProcess::startDetached(wineBinary, argsList, folder)) {
QMessageBox::warning(this, "ERROR", "Could not launch game settings!");
}
#endif
return true;
}

Expand Down
46 changes: 45 additions & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ QString MainWindow::gameExecutable = "SWGEmu.exe";
#ifdef Q_OS_WIN32
QString MainWindow::selfUpdateUrl = "http://launchpad2.net/setup.cfg";
#else
QString MainWindow::selfUpdateUrl = "http://launchpad2.net/setuplinux.cfg";
QString MainWindow::selfUpdateUrl = "http://launchpad2.net/setuplinux86_64.cfg";
#endif
const QString MainWindow::version = "0.18";

Expand Down Expand Up @@ -947,9 +947,31 @@ void MainWindow::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
}

void MainWindow::startKodanCalculator() {
#ifdef Q_OS_WIN32
if (!QProcess::startDetached("KSWGProfCalcEditor.exe", QStringList(), QDir::currentPath())) {
QMessageBox::warning(this, "ERROR", "Could not launch profession calculator!");
}
#else
QSettings settings;
QString wineBinary = settings.value("wine_binary").toString();

if (wineBinary.isEmpty())
wineBinary = "wine";

QString args = settings.value("wine_args").toString();

QStringList argsList;
if (!args.isEmpty())
argsList = args.split(" ");

argsList.append("KSWGProfCalcEditor.exe");

qDebug() << argsList;

if (!QProcess::startDetached(wineBinary, argsList, QDir::currentPath())) {
QMessageBox::warning(this, "ERROR", "Could not launch game settings!");
}
#endif
}

void MainWindow::startSWGSetup() {
Expand All @@ -958,13 +980,35 @@ void MainWindow::startSWGSetup() {
QSettings settings;
QString folder = settings.value("swg_folder").toString();

#ifdef Q_OS_WIN32

//qDebug() << folder;
/*process->setWorkingDirectory(folder);
process->start(folder + "\\" + "SWGEmu_Setup.exe");*/

if (!QProcess::startDetached(folder + "\\" + "SWGEmu_Setup.exe", QStringList(), folder)) {
QMessageBox::warning(this, "ERROR", "Could not launch game settings!");
}
#else
QString wineBinary = settings.value("wine_binary").toString();

if (wineBinary.isEmpty())
wineBinary = "wine";

QString args = settings.value("wine_args").toString();

QStringList argsList;
if (!args.isEmpty())
argsList = args.split(" ");

argsList.append(folder + "\\" + "SWGEmu_Setup.exe");

qDebug() << argsList;

if (!QProcess::startDetached(wineBinary, argsList, folder)) {
QMessageBox::warning(this, "ERROR", "Could not launch game settings!");
}
#endif
}

void MainWindow::downloadFinished() {
Expand Down
39 changes: 39 additions & 0 deletions settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Settings::Settings(QWidget *parent) :
ui->checkBox_minimize->setChecked(settings.value("minimize_after_start", false).toBool());
ui->checkBox_debug->setChecked(settings.value("capture_debug_output", false).toBool());
ui->checkBox_multithreaded->setChecked(settings.value("multi_threaded_full_scan", false).toBool());
QString wineBinary = settings.value("wine_binary").toString();

if (!wineBinary.isEmpty())
ui->lineEdit_wine->setText(wineBinary);

ui->lineEdit_wine_args->setText(settings.value("wine_args").toString());

connect(ui->pushButton_SelectFolder, SIGNAL(clicked()), this, SLOT(selectFolder()));
//connect(ui->lineEdit_swgfolder, SIGNAL(textChanged(QString)), this, SLOT(folderChanged(QString)));
Expand All @@ -24,6 +30,10 @@ Settings::Settings(QWidget *parent) :
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(restoreOptions()));
connect(ui->checkBox_close, SIGNAL(toggled(bool)), this, SLOT(closeAfterStartChanged(bool)));
connect(ui->checkBox_minimize, SIGNAL(toggled(bool)), this, SLOT(minimizeToTrayAfterStartChanged(bool)));

#ifndef Q_OS_WIN32
ui->groupBox->setEnabled(true);
#endif
//connect(ui->)
}

Expand Down Expand Up @@ -52,6 +62,8 @@ void Settings::updateAllOptions() {
updateMinimizeAfterStart();
updateCaptureDebugSetting();
updateMultiThreadedFullScan();
updateWineBinary();
updateWineArguments();
}

void Settings::updateMultiThreadedFullScan() {
Expand Down Expand Up @@ -91,12 +103,38 @@ void Settings::updateFolderSetting() {
settings.setValue("swg_folder", newFolder);
}

void Settings::updateWineBinary() {
QString bin = ui->lineEdit_wine->text();

QSettings settings;
settings.setValue("wine_binary", bin);
}

void Settings::updateWineArguments() {
QString arguments = ui->lineEdit_wine_args->text();

QSettings settings;
settings.setValue("wine_args", arguments);
}

void Settings::restoreOptions() {
restoreFolder();
restoreCloseAfterStart();
restoreMimizeAfterStart();
restoreCaptureDebug();
restoreMultiThreadedFullScan();
restoreWineArgs();
restoreWineBinary();
}

void Settings::restoreWineBinary() {
QSettings settings;
ui->lineEdit_wine->setText(settings.value("wine_binary").toString());
}

void Settings::restoreWineArgs() {
QSettings settings;
ui->lineEdit_wine_args->setText(settings.value("wine_args").toString());
}

void Settings::restoreCaptureDebug() {
Expand All @@ -120,3 +158,4 @@ void Settings::restoreFolder() {

ui->lineEdit_swgfolder->setText(folder);
}

4 changes: 4 additions & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ public slots:
void updateMinimizeAfterStart();
void updateCaptureDebugSetting();
void updateMultiThreadedFullScan();
void updateWineBinary();
void updateWineArguments();

void restoreCloseAfterStart();
void restoreMimizeAfterStart();
void restoreCaptureDebug();
void restoreMultiThreadedFullScan();
void restoreFolder();
void restoreWineBinary();
void restoreWineArgs();

void closeAfterStartChanged(bool state);
void minimizeToTrayAfterStartChanged(bool state);
Expand Down
50 changes: 47 additions & 3 deletions settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>122</height>
<width>422</width>
<height>234</height>
</rect>
</property>
<property name="windowTitle">
<string>Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
Expand Down Expand Up @@ -75,6 +75,50 @@
</layout>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Unix/Linux</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Wine binary</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wine">
<property name="text">
<string>wine</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Wine arguments</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wine_args"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down

0 comments on commit ce1e3be

Please sign in to comment.