mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 03:39:42 +00:00
Fixed file loading problem with relative paths when launcher wasn't run from cmdline
This commit is contained in:
parent
c42f99a586
commit
2131452fac
4 changed files with 43 additions and 16 deletions
|
@ -309,7 +309,7 @@ void DataFilesPage::setupDataFiles(const QString &path)
|
|||
void DataFilesPage::setupConfig()
|
||||
{
|
||||
qDebug() << "setupConfig called";
|
||||
QString config = "launcher.cfg";
|
||||
QString config = "./launcher.cfg";
|
||||
QFile file(config);
|
||||
|
||||
if (!file.exists()) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include "maindialog.hpp"
|
||||
|
||||
|
@ -6,6 +7,24 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// Now we make sure the current dir is set to application path
|
||||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
#if defined(Q_OS_WIN)
|
||||
if (dir.dirName().toLower() == "debug" ||
|
||||
dir.dirName().toLower() == "release")
|
||||
{
|
||||
dir.cdUp();
|
||||
}
|
||||
#elif defined(Q_OS_MAC)
|
||||
if (dir.dirName() == "MacOS")
|
||||
{
|
||||
dir.cdUp();
|
||||
dir.cdUp();
|
||||
dir.cdUp();
|
||||
}
|
||||
#endif
|
||||
|
||||
QDir::setCurrent(dir.absolutePath());
|
||||
MainDialog dialog;
|
||||
return dialog.exec();
|
||||
|
||||
|
|
|
@ -151,10 +151,8 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
|||
void MainDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
qDebug() << "Close event";
|
||||
mDataFilesPage->writeConfig();
|
||||
mDataFilesPage->mLauncherConfig->sync();
|
||||
|
||||
// Now write to the game config
|
||||
// Now write all config files
|
||||
writeConfig();
|
||||
event->accept();
|
||||
|
||||
|
@ -162,6 +160,8 @@ void MainDialog::closeEvent(QCloseEvent *event)
|
|||
|
||||
void MainDialog::play()
|
||||
{
|
||||
// First do a write of all the configs, just to be sure
|
||||
writeConfig();
|
||||
|
||||
#if Q_WS_WIN
|
||||
// Windows TODO: proper install path handling
|
||||
|
@ -192,7 +192,7 @@ void MainDialog::play()
|
|||
void MainDialog::setupConfig()
|
||||
{
|
||||
// First we read the OpenMW config
|
||||
QString config = "openmw.cfg";
|
||||
QString config = "./openmw.cfg";
|
||||
QFile file(config);
|
||||
|
||||
if (!file.exists()) {
|
||||
|
@ -210,9 +210,13 @@ void MainDialog::setupConfig()
|
|||
|
||||
void MainDialog::writeConfig()
|
||||
{
|
||||
// Write the profiles
|
||||
mDataFilesPage->writeConfig();
|
||||
mDataFilesPage->mLauncherConfig->sync();
|
||||
|
||||
// Write to the openmw.cfg
|
||||
QString dataPath = mGameConfig->value("data").toString();
|
||||
dataPath.append("/");
|
||||
//QString dataPath = mGameConfig->value("data").toString();
|
||||
//dataPath.append("/");
|
||||
|
||||
QStringList dataFiles = mDataFilesPage->selectedMasters();
|
||||
dataFiles.append(mDataFilesPage->checkedPlugins());
|
||||
|
@ -220,7 +224,10 @@ void MainDialog::writeConfig()
|
|||
qDebug() << "Writing to openmw.cfg";
|
||||
|
||||
// Open the config as a QFile
|
||||
QFile file(mGameConfig->fileName());
|
||||
|
||||
QString cfgfile = "./openmw.cfg";
|
||||
|
||||
QFile file(cfgfile);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
// File cannot be opened or created TODO: throw error
|
||||
}
|
||||
|
@ -248,16 +255,17 @@ void MainDialog::writeConfig()
|
|||
|
||||
// Write the list of game files to the config
|
||||
foreach (const QString ¤tFile, dataFiles) {
|
||||
QFileInfo dataFile = QFileInfo(QString(currentFile).prepend(dataPath));
|
||||
//QFileInfo dataFile = QFileInfo(QString(currentFile).prepend(dataPath));
|
||||
|
||||
if (dataFile.exists()) {
|
||||
if (currentFile.endsWith(QString(".esm"), Qt::CaseInsensitive)) {
|
||||
out << "master=" << currentFile << endl;
|
||||
} else if (currentFile.endsWith(QString(".esp"), Qt::CaseInsensitive)) {
|
||||
out << "plugin=" << currentFile << endl;
|
||||
}
|
||||
//if (dataFile.exists()) {
|
||||
if (currentFile.endsWith(QString(".esm"), Qt::CaseInsensitive)) {
|
||||
out << "master=" << currentFile << endl;
|
||||
} else if (currentFile.endsWith(QString(".esp"), Qt::CaseInsensitive)) {
|
||||
out << "plugin=" << currentFile << endl;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
file.close();
|
||||
qDebug() << "Writing done!";
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
// Load the stylesheet
|
||||
QFile file("launcher.qss");
|
||||
QFile file("./launcher.qss");
|
||||
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
|
|
Loading…
Reference in a new issue