mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 20:39:40 +00:00
Working on importing content lists in the launcher
This commit is contained in:
parent
6ed76858d9
commit
30c3c3e245
6 changed files with 257 additions and 223 deletions
|
@ -34,16 +34,68 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
|
||||||
setupDataFiles();
|
setupDataFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::DataFilesPage::loadSettings()
|
void Launcher::DataFilesPage::buildView()
|
||||||
|
{
|
||||||
|
ui.verticalLayout->insertWidget (0, mSelector->uiWidget());
|
||||||
|
|
||||||
|
//tool buttons
|
||||||
|
ui.newProfileButton->setToolTip ("Create a new profile");
|
||||||
|
ui.deleteProfileButton->setToolTip ("Delete an existing profile");
|
||||||
|
|
||||||
|
//combo box
|
||||||
|
ui.profilesComboBox->addItem ("Default");
|
||||||
|
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
||||||
|
ui.profilesComboBox->setCurrentIndex(ui.profilesComboBox->findText(QLatin1String("Default")));
|
||||||
|
|
||||||
|
// Add the actions to the toolbuttons
|
||||||
|
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
||||||
|
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
||||||
|
|
||||||
|
//establish connections
|
||||||
|
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)),
|
||||||
|
this, SLOT (slotProfileChanged(int)));
|
||||||
|
|
||||||
|
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString, QString)),
|
||||||
|
this, SLOT (slotProfileRenamed(QString, QString)));
|
||||||
|
|
||||||
|
connect (ui.profilesComboBox, SIGNAL (signalProfileChanged(QString, QString)),
|
||||||
|
this, SLOT (slotProfileChangedByUser(QString, QString)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Launcher::DataFilesPage::setupDataFiles()
|
||||||
|
{
|
||||||
|
QStringList paths = mGameSettings.getDataDirs();
|
||||||
|
|
||||||
|
foreach (const QString &path, paths)
|
||||||
|
mSelector->addFiles(path);
|
||||||
|
|
||||||
|
mDataLocal = mGameSettings.getDataLocal();
|
||||||
|
|
||||||
|
if (!mDataLocal.isEmpty())
|
||||||
|
mSelector->addFiles(mDataLocal);
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Launcher::DataFilesPage::loadSettings()
|
||||||
{
|
{
|
||||||
QStringList paths = mGameSettings.getDataDirs();
|
QStringList paths = mGameSettings.getDataDirs();
|
||||||
paths.insert (0, mDataLocal);
|
paths.insert (0, mDataLocal);
|
||||||
PathIterator pathIterator (paths);
|
PathIterator pathIterator (paths);
|
||||||
|
|
||||||
QString profileName = ui.profilesComboBox->currentText();
|
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||||
|
QString currentProfile = mLauncherSettings.getSettings().value("Profiles/currentprofile");
|
||||||
|
|
||||||
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/content"), Qt::MatchExactly);
|
qDebug() << "current profile is: " << currentProfile;
|
||||||
|
|
||||||
|
foreach (const QString &item, profiles)
|
||||||
|
addProfile (item, false);
|
||||||
|
|
||||||
|
// Hack: also add the current profile
|
||||||
|
if (!currentProfile.isEmpty())
|
||||||
|
addProfile(currentProfile, true);
|
||||||
|
|
||||||
|
QStringList files = mLauncherSettings.values(QString("Profiles/") + currentProfile + QString("/content"), Qt::MatchExactly);
|
||||||
QStringList filepaths;
|
QStringList filepaths;
|
||||||
|
|
||||||
foreach (const QString &file, files)
|
foreach (const QString &file, files)
|
||||||
|
@ -55,6 +107,8 @@ void Launcher::DataFilesPage::loadSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
mSelector->setProfileContent (filepaths);
|
mSelector->setProfileContent (filepaths);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
||||||
|
@ -81,33 +135,6 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::DataFilesPage::buildView()
|
|
||||||
{
|
|
||||||
ui.verticalLayout->insertWidget (0, mSelector->uiWidget());
|
|
||||||
|
|
||||||
//tool buttons
|
|
||||||
ui.newProfileButton->setToolTip ("Create a new profile");
|
|
||||||
ui.deleteProfileButton->setToolTip ("Delete an existing profile");
|
|
||||||
|
|
||||||
//combo box
|
|
||||||
ui.profilesComboBox->addItem ("Default");
|
|
||||||
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
|
||||||
|
|
||||||
// Add the actions to the toolbuttons
|
|
||||||
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
|
||||||
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
|
||||||
|
|
||||||
//establish connections
|
|
||||||
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)),
|
|
||||||
this, SLOT (slotProfileChanged(int)));
|
|
||||||
|
|
||||||
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString, QString)),
|
|
||||||
this, SLOT (slotProfileRenamed(QString, QString)));
|
|
||||||
|
|
||||||
connect (ui.profilesComboBox, SIGNAL (signalProfileChanged(QString, QString)),
|
|
||||||
this, SLOT (slotProfileChangedByUser(QString, QString)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::DataFilesPage::removeProfile(const QString &profile)
|
void Launcher::DataFilesPage::removeProfile(const QString &profile)
|
||||||
{
|
{
|
||||||
mLauncherSettings.remove(QString("Profiles/") + profile);
|
mLauncherSettings.remove(QString("Profiles/") + profile);
|
||||||
|
@ -140,6 +167,9 @@ void Launcher::DataFilesPage::setProfile (const QString &previous, const QString
|
||||||
if (previous == current)
|
if (previous == current)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (previous.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
if (!previous.isEmpty() && savePrevious)
|
if (!previous.isEmpty() && savePrevious)
|
||||||
saveSettings (previous);
|
saveSettings (previous);
|
||||||
|
|
||||||
|
@ -180,42 +210,6 @@ void Launcher::DataFilesPage::slotProfileChanged(int index)
|
||||||
setProfile (index, true);
|
setProfile (index, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::DataFilesPage::setupDataFiles()
|
|
||||||
{
|
|
||||||
QStringList paths = mGameSettings.getDataDirs();
|
|
||||||
|
|
||||||
foreach (const QString &path, paths)
|
|
||||||
mSelector->addFiles(path);
|
|
||||||
|
|
||||||
mDataLocal = mGameSettings.getDataLocal();
|
|
||||||
|
|
||||||
if (!mDataLocal.isEmpty())
|
|
||||||
mSelector->addFiles(mDataLocal);
|
|
||||||
|
|
||||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
|
||||||
QString currentProfile = mLauncherSettings.getSettings().value("Profiles/currentprofile");
|
|
||||||
|
|
||||||
// foreach (QString key, mLauncherSettings.getSettings().keys())
|
|
||||||
// {
|
|
||||||
// if (key.contains("Profiles/"))
|
|
||||||
// {
|
|
||||||
// QString profile = key.mid (9);
|
|
||||||
// if (profile != "currentprofile")
|
|
||||||
// {
|
|
||||||
// if (!profiles.contains(profile))
|
|
||||||
// profiles << profile;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
foreach (const QString &item, profiles)
|
|
||||||
addProfile (item, false);
|
|
||||||
|
|
||||||
setProfile (ui.profilesComboBox->findText(currentProfile), false);
|
|
||||||
|
|
||||||
loadSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::DataFilesPage::on_newProfileAction_triggered()
|
void Launcher::DataFilesPage::on_newProfileAction_triggered()
|
||||||
{
|
{
|
||||||
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
||||||
|
|
|
@ -39,7 +39,9 @@ namespace Launcher
|
||||||
|
|
||||||
//void writeConfig(QString profile = QString());
|
//void writeConfig(QString profile = QString());
|
||||||
void saveSettings(const QString &profile = "");
|
void saveSettings(const QString &profile = "");
|
||||||
void loadSettings();
|
bool loadSettings();
|
||||||
|
|
||||||
|
void setupDataFiles();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalProfileChanged (int index);
|
void signalProfileChanged (int index);
|
||||||
|
@ -70,7 +72,6 @@ namespace Launcher
|
||||||
void setPluginsCheckstates(Qt::CheckState state);
|
void setPluginsCheckstates(Qt::CheckState state);
|
||||||
|
|
||||||
void buildView();
|
void buildView();
|
||||||
void setupDataFiles();
|
|
||||||
void setupConfig();
|
void setupConfig();
|
||||||
void readConfig();
|
void readConfig();
|
||||||
void setProfile (int index, bool savePrevious);
|
void setProfile (int index, bool savePrevious);
|
||||||
|
|
|
@ -137,7 +137,7 @@ void Launcher::MainDialog::createPages()
|
||||||
mPlayPage = new PlayPage(this);
|
mPlayPage = new PlayPage(this);
|
||||||
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
||||||
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
||||||
mSettingsPage = new SettingsPage(mGameSettings, mLauncherSettings, this);
|
mSettingsPage = new SettingsPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
||||||
|
|
||||||
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
||||||
mPlayPage->setProfilesModel(mDataFilesPage->profilesModel());
|
mPlayPage->setProfilesModel(mDataFilesPage->profilesModel());
|
||||||
|
@ -161,150 +161,103 @@ void Launcher::MainDialog::createPages()
|
||||||
|
|
||||||
bool Launcher::MainDialog::showFirstRunDialog()
|
bool Launcher::MainDialog::showFirstRunDialog()
|
||||||
{
|
{
|
||||||
QStringList iniPaths;
|
|
||||||
|
|
||||||
foreach (const QString &path, mGameSettings.getDataDirs()) {
|
|
||||||
QDir dir(path);
|
|
||||||
dir.setPath(dir.canonicalPath()); // Resolve symlinks
|
|
||||||
|
|
||||||
if (dir.exists(QString("Morrowind.ini")))
|
|
||||||
iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!dir.cdUp())
|
|
||||||
continue; // Cannot move from Data Files
|
|
||||||
|
|
||||||
if (dir.exists(QString("Morrowind.ini")))
|
|
||||||
iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ask the user where the Morrowind.ini is
|
|
||||||
if (iniPaths.empty()) {
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setWindowTitle(tr("Error detecting Morrowind configuration"));
|
|
||||||
msgBox.setIcon(QMessageBox::Warning);
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
|
||||||
msgBox.setText(QObject::tr("<br><b>Could not find Morrowind.ini</b><br><br> \
|
|
||||||
OpenMW needs to import settings from this file.<br><br> \
|
|
||||||
Press \"Browse...\" to specify the location manually.<br>"));
|
|
||||||
|
|
||||||
QAbstractButton *dirSelectButton =
|
|
||||||
msgBox.addButton(QObject::tr("B&rowse..."), QMessageBox::ActionRole);
|
|
||||||
|
|
||||||
msgBox.exec();
|
|
||||||
|
|
||||||
QString iniFile;
|
|
||||||
if (msgBox.clickedButton() == dirSelectButton) {
|
|
||||||
iniFile = QFileDialog::getOpenFileName(
|
|
||||||
NULL,
|
|
||||||
QObject::tr("Select configuration file"),
|
|
||||||
QDir::currentPath(),
|
|
||||||
QString(tr("Morrowind configuration file (*.ini)")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iniFile.isEmpty())
|
|
||||||
return false; // Cancel was clicked;
|
|
||||||
|
|
||||||
QFileInfo info(iniFile);
|
|
||||||
iniPaths.clear();
|
|
||||||
iniPaths.append(info.absoluteFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckableMessageBox msgBox(this);
|
|
||||||
msgBox.setWindowTitle(tr("Morrowind installation detected"));
|
|
||||||
|
|
||||||
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
|
|
||||||
int size = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
|
|
||||||
msgBox.setIconPixmap(icon.pixmap(size, size));
|
|
||||||
|
|
||||||
QAbstractButton *importerButton =
|
|
||||||
msgBox.addButton(tr("Import"), QDialogButtonBox::AcceptRole); // ActionRole doesn't work?!
|
|
||||||
QAbstractButton *skipButton =
|
|
||||||
msgBox.addButton(tr("Skip"), QDialogButtonBox::RejectRole);
|
|
||||||
|
|
||||||
Q_UNUSED(skipButton); // Surpress compiler unused warning
|
|
||||||
|
|
||||||
msgBox.setStandardButtons(QDialogButtonBox::NoButton);
|
|
||||||
msgBox.setText(tr("<br><b>An existing Morrowind configuration was detected</b><br> \
|
|
||||||
<br>Would you like to import settings from Morrowind.ini?<br> \
|
|
||||||
<br><b>Warning: In most cases OpenMW needs these settings to run properly</b><br>"));
|
|
||||||
msgBox.setCheckBoxText(tr("Include selected masters and plugins (creates a new profile)"));
|
|
||||||
msgBox.exec();
|
|
||||||
|
|
||||||
|
|
||||||
if (msgBox.clickedButton() == importerButton) {
|
|
||||||
|
|
||||||
if (iniPaths.count() > 1) {
|
// CheckableMessageBox msgBox(this);
|
||||||
// Multiple Morrowind.ini files found
|
// msgBox.setWindowTitle(tr("Morrowind installation detected"));
|
||||||
bool ok;
|
|
||||||
QString path = QInputDialog::getItem(this, tr("Multiple configurations found"),
|
|
||||||
tr("<br><b>There are multiple Morrowind.ini files found.</b><br><br> \
|
|
||||||
Please select the one you wish to import from:"), iniPaths, 0, false, &ok);
|
|
||||||
if (ok && !path.isEmpty()) {
|
|
||||||
iniPaths.clear();
|
|
||||||
iniPaths.append(path);
|
|
||||||
} else {
|
|
||||||
// Cancel was clicked
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the file if it doesn't already exist, else the importer will fail
|
// QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
|
||||||
QString path = QString::fromStdString(mCfgMgr.getUserConfigPath().string()) + QString("openmw.cfg");
|
// int size = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
|
||||||
QFile file(path);
|
// msgBox.setIconPixmap(icon.pixmap(size, size));
|
||||||
|
|
||||||
if (!file.exists()) {
|
// QAbstractButton *importerButton =
|
||||||
if (!file.open(QIODevice::ReadWrite)) {
|
// msgBox.addButton(tr("Import"), QDialogButtonBox::AcceptRole); // ActionRole doesn't work?!
|
||||||
// File cannot be created
|
// QAbstractButton *skipButton =
|
||||||
QMessageBox msgBox;
|
// msgBox.addButton(tr("Skip"), QDialogButtonBox::RejectRole);
|
||||||
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
|
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
||||||
msgBox.setText(tr("<br><b>Could not open or create %0 for writing</b><br><br> \
|
|
||||||
Please make sure you have the right permissions \
|
|
||||||
and try again.<br>").arg(file.fileName()));
|
|
||||||
msgBox.exec();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
// Q_UNUSED(skipButton); // Surpress compiler unused warning
|
||||||
}
|
|
||||||
|
|
||||||
// Construct the arguments to run the importer
|
// msgBox.setStandardButtons(QDialogButtonBox::NoButton);
|
||||||
QStringList arguments;
|
// msgBox.setText(tr("<br><b>An existing Morrowind configuration was detected</b><br> \
|
||||||
|
// <br>Would you like to import settings from Morrowind.ini?<br> \
|
||||||
|
// <br><b>Warning: In most cases OpenMW needs these settings to run properly</b><br>"));
|
||||||
|
// msgBox.setCheckBoxText(tr("Include selected masters and plugins (creates a new profile)"));
|
||||||
|
// msgBox.exec();
|
||||||
|
|
||||||
if (msgBox.isChecked())
|
|
||||||
arguments.append(QString("--game-files"));
|
|
||||||
|
|
||||||
arguments.append(QString("--encoding"));
|
// if (msgBox.clickedButton() == importerButton) {
|
||||||
arguments.append(mGameSettings.value(QString("encoding"), QString("win1252")));
|
|
||||||
arguments.append(QString("--ini"));
|
|
||||||
arguments.append(iniPaths.first());
|
|
||||||
arguments.append(QString("--cfg"));
|
|
||||||
arguments.append(path);
|
|
||||||
|
|
||||||
ProcessInvoker invoker(this);
|
// if (iniPaths.count() > 1) {
|
||||||
|
// // Multiple Morrowind.ini files found
|
||||||
|
// bool ok;
|
||||||
|
// QString path = QInputDialog::getItem(this, tr("Multiple configurations found"),
|
||||||
|
// tr("<br><b>There are multiple Morrowind.ini files found.</b><br><br> \
|
||||||
|
// Please select the one you wish to import from:"), iniPaths, 0, false, &ok);
|
||||||
|
// if (ok && !path.isEmpty()) {
|
||||||
|
// iniPaths.clear();
|
||||||
|
// iniPaths.append(path);
|
||||||
|
// } else {
|
||||||
|
// // Cancel was clicked
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (!invoker.startProcess(QLatin1String("mwiniimport"), arguments, false))
|
// // Create the file if it doesn't already exist, else the importer will fail
|
||||||
return false;
|
// QString path = QString::fromStdString(mCfgMgr.getUserConfigPath().string()) + QString("openmw.cfg");
|
||||||
|
// QFile file(path);
|
||||||
|
|
||||||
// Re-read the game settings
|
// if (!file.exists()) {
|
||||||
if (!setupGameSettings())
|
// if (!file.open(QIODevice::ReadWrite)) {
|
||||||
return false;
|
// // File cannot be created
|
||||||
|
// QMessageBox msgBox;
|
||||||
|
// msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
|
||||||
|
// msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
// msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
// msgBox.setText(tr("<br><b>Could not open or create %0 for writing</b><br><br> \
|
||||||
|
// Please make sure you have the right permissions \
|
||||||
|
// and try again.<br>").arg(file.fileName()));
|
||||||
|
// msgBox.exec();
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
// Add a new profile
|
// file.close();
|
||||||
if (msgBox.isChecked()) {
|
// }
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), QString("Imported"));
|
|
||||||
mLauncherSettings.remove(QString("Profiles/Imported/content"));
|
|
||||||
|
|
||||||
QStringList contents = mGameSettings.values(QString("content"));
|
// // Construct the arguments to run the importer
|
||||||
foreach (const QString &content, contents) {
|
// QStringList arguments;
|
||||||
mLauncherSettings.setMultiValue(QString("Profiles/Imported/content"), content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// if (msgBox.isChecked())
|
||||||
|
// arguments.append(QString("--game-files"));
|
||||||
|
|
||||||
|
// arguments.append(QString("--encoding"));
|
||||||
|
// arguments.append(mGameSettings.value(QString("encoding"), QString("win1252")));
|
||||||
|
// arguments.append(QString("--ini"));
|
||||||
|
// arguments.append(iniPaths.first());
|
||||||
|
// arguments.append(QString("--cfg"));
|
||||||
|
// arguments.append(path);
|
||||||
|
|
||||||
|
// ProcessInvoker invoker(this);
|
||||||
|
|
||||||
|
// if (!invoker.startProcess(QLatin1String("mwiniimport"), arguments, false))
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
// // Re-read the game settings
|
||||||
|
// if (!setupGameSettings())
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
// // Add a new profile
|
||||||
|
// if (msgBox.isChecked()) {
|
||||||
|
// mLauncherSettings.setValue(QString("Profiles/currentprofile"), QString("Imported"));
|
||||||
|
// mLauncherSettings.remove(QString("Profiles/Imported/content"));
|
||||||
|
|
||||||
|
// QStringList contents = mGameSettings.values(QString("content"));
|
||||||
|
// foreach (const QString &content, contents) {
|
||||||
|
// mLauncherSettings.setMultiValue(QString("Profiles/Imported/content"), content);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -349,8 +302,11 @@ bool Launcher::MainDialog::reloadSettings()
|
||||||
if (!setupGraphicsSettings())
|
if (!setupGraphicsSettings())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// if (!mSettingsPage->loadSettings())
|
if (!mSettingsPage->loadSettings())
|
||||||
// return false;
|
return false;
|
||||||
|
|
||||||
|
if (!mDataFilesPage->loadSettings())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!mGraphicsPage->loadSettings())
|
if (!mGraphicsPage->loadSettings())
|
||||||
return false;
|
return false;
|
||||||
|
@ -371,17 +327,17 @@ void Launcher::MainDialog::changePage(QListWidgetItem *current, QListWidgetItem
|
||||||
DataFilesPage *previousPage = dynamic_cast<DataFilesPage *>(pagesWidget->widget(previousIndex));
|
DataFilesPage *previousPage = dynamic_cast<DataFilesPage *>(pagesWidget->widget(previousIndex));
|
||||||
DataFilesPage *currentPage = dynamic_cast<DataFilesPage *>(pagesWidget->widget(currentIndex));
|
DataFilesPage *currentPage = dynamic_cast<DataFilesPage *>(pagesWidget->widget(currentIndex));
|
||||||
|
|
||||||
//special call to update/save data files page list view when it's displayed/hidden.
|
// //special call to update/save data files page list view when it's displayed/hidden.
|
||||||
if (previousPage)
|
// if (previousPage)
|
||||||
{
|
// {
|
||||||
if (previousPage->objectName() == "DataFilesPage")
|
// if (previousPage->objectName() == "DataFilesPage")
|
||||||
previousPage->saveSettings();
|
// previousPage->saveSettings();
|
||||||
}
|
// }
|
||||||
else if (currentPage)
|
// else if (currentPage)
|
||||||
{
|
// {
|
||||||
if (currentPage->objectName() == "DataFilesPage")
|
// if (currentPage->objectName() == "DataFilesPage")
|
||||||
currentPage->loadSettings();
|
// currentPage->loadSettings();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launcher::MainDialog::setupLauncherSettings()
|
bool Launcher::MainDialog::setupLauncherSettings()
|
||||||
|
@ -729,8 +685,9 @@ bool Launcher::MainDialog::writeSettings()
|
||||||
{
|
{
|
||||||
// Now write all config files
|
// Now write all config files
|
||||||
saveSettings();
|
saveSettings();
|
||||||
mGraphicsPage->saveSettings();
|
|
||||||
mDataFilesPage->saveSettings();
|
mDataFilesPage->saveSettings();
|
||||||
|
mGraphicsPage->saveSettings();
|
||||||
|
mSettingsPage->saveSettings();
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
||||||
QDir dir(userPath);
|
QDir dir(userPath);
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include <components/config/gamesettings.hpp>
|
#include <components/config/gamesettings.hpp>
|
||||||
#include <components/config/launchersettings.hpp>
|
#include <components/config/launchersettings.hpp>
|
||||||
|
|
||||||
|
@ -12,12 +14,14 @@
|
||||||
|
|
||||||
using namespace Process;
|
using namespace Process;
|
||||||
|
|
||||||
Launcher::SettingsPage::SettingsPage(Config::GameSettings &gameSettings,
|
Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
|
||||||
Config::LauncherSettings &launcherSettings, MainDialog *parent) :
|
Config::GameSettings &gameSettings,
|
||||||
mGameSettings(gameSettings),
|
Config::LauncherSettings &launcherSettings, MainDialog *parent)
|
||||||
mLauncherSettings(launcherSettings),
|
: mCfgMgr(cfg)
|
||||||
QWidget(parent),
|
, mGameSettings(gameSettings)
|
||||||
mMain(parent)
|
, mLauncherSettings(launcherSettings)
|
||||||
|
, QWidget(parent)
|
||||||
|
, mMain(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
@ -77,17 +81,60 @@ Launcher::SettingsPage::SettingsPage(Config::GameSettings &gameSettings,
|
||||||
} else {
|
} else {
|
||||||
importerButton->setEnabled(false);
|
importerButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::SettingsPage::on_wizardButton_clicked()
|
void Launcher::SettingsPage::on_wizardButton_clicked()
|
||||||
{
|
{
|
||||||
|
saveSettings();
|
||||||
|
|
||||||
if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false))
|
if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::SettingsPage::on_importerButton_clicked()
|
void Launcher::SettingsPage::on_importerButton_clicked()
|
||||||
{
|
{
|
||||||
if (!mImporterInvoker->startProcess(QLatin1String("mwiniimport"), false))
|
saveSettings();
|
||||||
|
|
||||||
|
// Create the file if it doesn't already exist, else the importer will fail
|
||||||
|
QString path(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()));
|
||||||
|
path.append(QLatin1String("openmw.cfg"));
|
||||||
|
QFile file(path);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
if (!file.open(QIODevice::ReadWrite)) {
|
||||||
|
// File cannot be created
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
|
||||||
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
msgBox.setText(tr("<html><head/><body><p><b>Could not open or create %1 for writing </b></p> \
|
||||||
|
<p>Please make sure you have the right permissions \
|
||||||
|
and try again.</p></body></html>").arg(file.fileName()));
|
||||||
|
msgBox.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct the arguments to run the importer
|
||||||
|
QStringList arguments;
|
||||||
|
|
||||||
|
if (addonsCheckBox->isChecked())
|
||||||
|
arguments.append(QString("--game-files"));
|
||||||
|
|
||||||
|
arguments.append(QString("--encoding"));
|
||||||
|
arguments.append(mGameSettings.value(QString("encoding"), QString("win1252")));
|
||||||
|
arguments.append(QString("--ini"));
|
||||||
|
arguments.append(settingsComboBox->currentText());
|
||||||
|
arguments.append(QString("--cfg"));
|
||||||
|
arguments.append(path);
|
||||||
|
|
||||||
|
qDebug() << "arguments " << arguments;
|
||||||
|
|
||||||
|
if (!mImporterInvoker->startProcess(QLatin1String("mwiniimport"), arguments, false))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +176,6 @@ void Launcher::SettingsPage::wizardFinished(int exitCode, QProcess::ExitStatus e
|
||||||
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mMain->writeSettings();
|
|
||||||
mMain->reloadSettings();
|
mMain->reloadSettings();
|
||||||
wizardButton->setEnabled(true);
|
wizardButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -146,6 +192,9 @@ void Launcher::SettingsPage::importerFinished(int exitCode, QProcess::ExitStatus
|
||||||
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Re-read the settings in their current state
|
||||||
|
mMain->reloadSettings();
|
||||||
|
|
||||||
// Import selected data files from openmw.cfg
|
// Import selected data files from openmw.cfg
|
||||||
if (addonsCheckBox->isChecked())
|
if (addonsCheckBox->isChecked())
|
||||||
{
|
{
|
||||||
|
@ -154,6 +203,8 @@ void Launcher::SettingsPage::importerFinished(int exitCode, QProcess::ExitStatus
|
||||||
const QString profile(mProfileDialog->lineEdit()->text());
|
const QString profile(mProfileDialog->lineEdit()->text());
|
||||||
const QStringList files(mGameSettings.values(QLatin1String("content")));
|
const QStringList files(mGameSettings.values(QLatin1String("content")));
|
||||||
|
|
||||||
|
qDebug() << "Profile " << profile << files;
|
||||||
|
|
||||||
// Doesn't quite work right now
|
// Doesn't quite work right now
|
||||||
mLauncherSettings.setValue(QLatin1String("Profiles/currentprofile"), profile);
|
mLauncherSettings.setValue(QLatin1String("Profiles/currentprofile"), profile);
|
||||||
|
|
||||||
|
@ -165,7 +216,6 @@ void Launcher::SettingsPage::importerFinished(int exitCode, QProcess::ExitStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mMain->writeSettings();
|
|
||||||
mMain->reloadSettings();
|
mMain->reloadSettings();
|
||||||
importerButton->setEnabled(true);
|
importerButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -184,3 +234,30 @@ void Launcher::SettingsPage::updateOkButton(const QString &text)
|
||||||
? mProfileDialog->setOkButtonEnabled(false)
|
? mProfileDialog->setOkButtonEnabled(false)
|
||||||
: mProfileDialog->setOkButtonEnabled(true);
|
: mProfileDialog->setOkButtonEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Launcher::SettingsPage::saveSettings()
|
||||||
|
{
|
||||||
|
QString language(languageComboBox->currentText());
|
||||||
|
|
||||||
|
mLauncherSettings.setValue(QLatin1String("Settings/language"), language);
|
||||||
|
|
||||||
|
if (language == QLatin1String("Polish")) {
|
||||||
|
mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1250"));
|
||||||
|
} else if (language == QLatin1String("Russian")) {
|
||||||
|
mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1251"));
|
||||||
|
} else {
|
||||||
|
mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1252"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Launcher::SettingsPage::loadSettings()
|
||||||
|
{
|
||||||
|
QString language(mLauncherSettings.value(QLatin1String("Settings/language")));
|
||||||
|
|
||||||
|
int index = languageComboBox->findText(language);
|
||||||
|
|
||||||
|
if (index != -1)
|
||||||
|
languageComboBox->setCurrentIndex(index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "maindialog.hpp"
|
#include "maindialog.hpp"
|
||||||
|
|
||||||
|
namespace Files { struct ConfigurationManager; }
|
||||||
namespace Config { class GameSettings;
|
namespace Config { class GameSettings;
|
||||||
class LauncherSettings; }
|
class LauncherSettings; }
|
||||||
|
|
||||||
|
@ -22,13 +23,14 @@ namespace Launcher
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsPage( Config::GameSettings &gameSettings,
|
SettingsPage(Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings,
|
||||||
Config::LauncherSettings &launcherSettings, MainDialog *parent = 0);
|
Config::LauncherSettings &launcherSettings, MainDialog *parent = 0);
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
bool loadSettings();
|
bool loadSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void on_wizardButton_clicked();
|
void on_wizardButton_clicked();
|
||||||
void on_importerButton_clicked();
|
void on_importerButton_clicked();
|
||||||
void on_browseButton_clicked();
|
void on_browseButton_clicked();
|
||||||
|
@ -42,9 +44,12 @@ namespace Launcher
|
||||||
void updateOkButton(const QString &text);
|
void updateOkButton(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Process::ProcessInvoker *mWizardInvoker;
|
Process::ProcessInvoker *mWizardInvoker;
|
||||||
Process::ProcessInvoker *mImporterInvoker;
|
Process::ProcessInvoker *mImporterInvoker;
|
||||||
|
|
||||||
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
|
|
||||||
Config::GameSettings &mGameSettings;
|
Config::GameSettings &mGameSettings;
|
||||||
Config::LauncherSettings &mLauncherSettings;
|
Config::LauncherSettings &mLauncherSettings;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString &
|
||||||
mButtonBox = new QDialogButtonBox(this);
|
mButtonBox = new QDialogButtonBox(this);
|
||||||
mButtonBox->addButton(QDialogButtonBox::Ok);
|
mButtonBox->addButton(QDialogButtonBox::Ok);
|
||||||
mButtonBox->addButton(QDialogButtonBox::Cancel);
|
mButtonBox->addButton(QDialogButtonBox::Cancel);
|
||||||
// mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false);
|
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false);
|
||||||
|
|
||||||
QLabel *label = new QLabel(this);
|
QLabel *label = new QLabel(this);
|
||||||
label->setText(text);
|
label->setText(text);
|
||||||
|
|
Loading…
Reference in a new issue