mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Fixed some minor problems with the wizard
This commit is contained in:
parent
f8bb797b8a
commit
6ed76858d9
5 changed files with 106 additions and 41 deletions
|
@ -14,36 +14,30 @@ Wizard::ExistingInstallationPage::ExistingInstallationPage(MainWizard *wizard) :
|
|||
{
|
||||
setupUi(this);
|
||||
|
||||
mEmptyItem = new QListWidgetItem(tr("No existing installations detected"));
|
||||
mEmptyItem->setFlags(Qt::NoItemFlags);
|
||||
installationsList->addItem(mEmptyItem);
|
||||
mEmptyItem->setHidden(true);
|
||||
QListWidgetItem *emptyItem = new QListWidgetItem(tr("No existing installations detected"));
|
||||
emptyItem->setFlags(Qt::NoItemFlags);
|
||||
installationsList->addItem(emptyItem);
|
||||
|
||||
connect(installationsList, SIGNAL(currentTextChanged(QString)),
|
||||
this, SLOT(textChanged(QString)));
|
||||
|
||||
connect(installationsList,SIGNAL(itemSelectionChanged()),
|
||||
this, SIGNAL(completeChanged()));
|
||||
}
|
||||
|
||||
void Wizard::ExistingInstallationPage::initializePage()
|
||||
{
|
||||
// Add the available installation paths
|
||||
QStringList paths(mWizard->mInstallations.keys());
|
||||
|
||||
// Hide the default item if there are installations to choose from
|
||||
if (paths.isEmpty()) {
|
||||
mEmptyItem->setHidden(false);
|
||||
return;
|
||||
installationsList->item(0)->setHidden(false);
|
||||
} else {
|
||||
installationsList->item(0)->setHidden(true);
|
||||
}
|
||||
|
||||
// Make to clear list before adding items
|
||||
// to prevent duplicates when going back and forth between pages
|
||||
installationsList->clear();
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
QListWidgetItem *item = new QListWidgetItem(path);
|
||||
installationsList->addItem(item);
|
||||
}
|
||||
|
||||
connect(installationsList, SIGNAL(currentTextChanged(QString)),
|
||||
this, SLOT(textChanged(QString)));
|
||||
|
||||
connect(installationsList,SIGNAL(itemSelectionChanged()),
|
||||
this, SIGNAL(completeChanged()));
|
||||
}
|
||||
|
||||
bool Wizard::ExistingInstallationPage::validatePage()
|
||||
|
@ -119,7 +113,7 @@ void Wizard::ExistingInstallationPage::on_browseButton_clicked()
|
|||
mWizard->addInstallation(path);
|
||||
|
||||
// Hide the default item
|
||||
mEmptyItem->setHidden(true);
|
||||
installationsList->item(0)->setHidden(true);
|
||||
|
||||
QListWidgetItem *item = new QListWidgetItem(path);
|
||||
installationsList->addItem(item);
|
||||
|
@ -149,17 +143,5 @@ bool Wizard::ExistingInstallationPage::isComplete() const
|
|||
|
||||
int Wizard::ExistingInstallationPage::nextId() const
|
||||
{
|
||||
QString path(field(QLatin1String("installation.path")).toString());
|
||||
|
||||
if (path.isEmpty())
|
||||
return MainWizard::Page_LanguageSelection;
|
||||
|
||||
if (mWizard->mInstallations[path]->hasMorrowind == true &&
|
||||
mWizard->mInstallations[path]->hasTribunal == true &&
|
||||
mWizard->mInstallations[path]->hasBloodmoon == true)
|
||||
{
|
||||
return MainWizard::Page_Import;
|
||||
} else {
|
||||
return MainWizard::Page_LanguageSelection;
|
||||
}
|
||||
return MainWizard::Page_LanguageSelection;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define EXISTINGINSTALLATIONPAGE_HPP
|
||||
|
||||
#include <QWizardPage>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
#include "ui_existinginstallationpage.h"
|
||||
|
||||
|
@ -27,11 +26,7 @@ namespace Wizard
|
|||
|
||||
private:
|
||||
MainWizard *mWizard;
|
||||
QListWidgetItem *mEmptyItem;
|
||||
|
||||
|
||||
protected:
|
||||
void initializePage();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -27,5 +27,18 @@ void Wizard::LanguageSelectionPage::initializePage()
|
|||
|
||||
int Wizard::LanguageSelectionPage::nextId() const
|
||||
{
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
// Check if we have to install something
|
||||
QString path(field(QLatin1String("installation.path")).toString());
|
||||
|
||||
if (path.isEmpty())
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
|
||||
if (mWizard->mInstallations[path]->hasMorrowind == true &&
|
||||
mWizard->mInstallations[path]->hasTribunal == true &&
|
||||
mWizard->mInstallations[path]->hasBloodmoon == true)
|
||||
{
|
||||
return MainWizard::Page_Import;
|
||||
} else {
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ Wizard::MainWizard::MainWizard(QWidget *parent) :
|
|||
|
||||
setupLog();
|
||||
setupGameSettings();
|
||||
setupLauncherSettings();
|
||||
setupInstallations();
|
||||
setupPages();
|
||||
}
|
||||
|
@ -149,6 +150,40 @@ void Wizard::MainWizard::setupGameSettings()
|
|||
}
|
||||
}
|
||||
|
||||
void Wizard::MainWizard::setupLauncherSettings()
|
||||
{
|
||||
QString path(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()));
|
||||
path.append(QLatin1String("launcher.cfg"));
|
||||
|
||||
QString message(tr("<html><head/><body><p><b>Could not open %1 for reading</b></p> \
|
||||
<p>Please make sure you have the right permissions \
|
||||
and try again.</p></body></html>"));
|
||||
|
||||
|
||||
QFile file(path);
|
||||
|
||||
qDebug() << "Loading config file:" << qPrintable(path);
|
||||
|
||||
if (file.exists()) {
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error opening OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(message.arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return qApp->quit();
|
||||
}
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mLauncherSettings.readFile(stream);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
}
|
||||
|
||||
void Wizard::MainWizard::setupInstallations()
|
||||
{
|
||||
// Check if the paths actually contain a Morrowind installation
|
||||
|
@ -211,8 +246,10 @@ void Wizard::MainWizard::runSettingsImporter()
|
|||
arguments.append(QLatin1String("--cfg"));
|
||||
arguments.append(userPath + QLatin1String("openmw.cfg"));
|
||||
|
||||
// if (!ProcessInvoker::startProcess(QLatin1String("mwiniimport"), arguments, false))
|
||||
// return qApp->quit();;
|
||||
ProcessInvoker invoker(this);
|
||||
|
||||
if (!invoker.startProcess(QLatin1String("mwiniimport"), arguments, false))
|
||||
return qApp->quit();;
|
||||
|
||||
// Re-read the game settings
|
||||
setupGameSettings();
|
||||
|
@ -285,6 +322,19 @@ void Wizard::MainWizard::reject()
|
|||
|
||||
void Wizard::MainWizard::writeSettings()
|
||||
{
|
||||
// Write the encoding and language settings
|
||||
QString language(field(QLatin1String("installation.language")).toString());
|
||||
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"));
|
||||
}
|
||||
|
||||
// Write the installation path so that openmw can find them
|
||||
QString path(field(QLatin1String("installation.path")).toString());
|
||||
|
||||
// Make sure the installation path is the last data= entry
|
||||
|
@ -329,6 +379,28 @@ void Wizard::MainWizard::writeSettings()
|
|||
|
||||
mGameSettings.writeFile(stream);
|
||||
file.close();
|
||||
|
||||
// Launcher settings
|
||||
file.setFileName(userPath + QLatin1String("launcher.cfg"));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
|
||||
// File cannot be opened or 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 %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 qApp->quit();
|
||||
}
|
||||
|
||||
stream.setDevice(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mLauncherSettings.writeFile(stream);
|
||||
file.close();
|
||||
}
|
||||
|
||||
bool Wizard::MainWizard::findFiles(const QString &name, const QString &path)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/config/gamesettings.hpp>
|
||||
#include <components/config/launchersettings.hpp>
|
||||
|
||||
namespace Wizard
|
||||
{
|
||||
|
@ -53,12 +54,14 @@ namespace Wizard
|
|||
|
||||
void setupLog();
|
||||
void setupGameSettings();
|
||||
void setupLauncherSettings();
|
||||
void setupInstallations();
|
||||
void setupPages();
|
||||
|
||||
void writeSettings();
|
||||
|
||||
Config::GameSettings mGameSettings;
|
||||
Config::LauncherSettings mLauncherSettings;
|
||||
|
||||
QTextStream *mLog;
|
||||
|
||||
|
|
Loading…
Reference in a new issue