Installer work for Windows (Fixes #1621)

1. Correctly reads Windows registry for vanilla MW install location.
2. Populates existing installation page with location of vanilla, when found.
3. On Windows, installer wizard now gets to Import page.
pull/534/head
dteviot 10 years ago
parent cf077dcf5d
commit 2ef7fc4e2c

@ -156,9 +156,13 @@ bool Wizard::ComponentSelectionPage::validatePage()
int Wizard::ComponentSelectionPage::nextId() const
{
#ifdef OPENMW_USE_UNSHIELD
if (isCommitPage()) {
return MainWizard::Page_Installation;
} else {
return MainWizard::Page_Import;
}
#else
return MainWizard::Page_Import;
#endif
}

@ -29,11 +29,7 @@ void Wizard::ExistingInstallationPage::initializePage()
QStringList paths(mWizard->mInstallations.keys());
// Hide the default item if there are installations to choose from
if (paths.isEmpty()) {
installationsList->item(0)->setHidden(false);
} else {
installationsList->item(0)->setHidden(true);
}
installationsList->item(0)->setHidden(!paths.isEmpty());
foreach (const QString &path, paths) {
QListWidgetItem *item = new QListWidgetItem(path);

@ -62,6 +62,12 @@ Wizard::MainWizard::MainWizard(QWidget *parent) :
setupLauncherSettings();
setupInstallations();
setupPages();
const boost::filesystem::path& installedPath = mCfgMgr.getInstallPath();
if (!installedPath.empty())
{
addInstallation(toQString(installedPath));
}
}
Wizard::MainWizard::~MainWizard()
@ -71,7 +77,7 @@ Wizard::MainWizard::~MainWizard()
void Wizard::MainWizard::setupLog()
{
QString logPath(QString::fromUtf8(mCfgMgr.getLogPath().string().c_str()));
QString logPath(toQString(mCfgMgr.getLogPath()));
logPath.append(QLatin1String("wizard.log"));
QFile file(logPath);
@ -93,7 +99,7 @@ void Wizard::MainWizard::setupLog()
void Wizard::MainWizard::addLogText(const QString &text)
{
QString logPath(QString::fromUtf8(mCfgMgr.getLogPath().string().c_str()));
QString logPath(toQString(mCfgMgr.getLogPath()));
logPath.append(QLatin1String("wizard.log"));
QFile file(logPath);
@ -121,8 +127,8 @@ void Wizard::MainWizard::addLogText(const QString &text)
void Wizard::MainWizard::setupGameSettings()
{
QString userPath(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()));
QString globalPath(QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str()));
QString userPath(toQString(mCfgMgr.getUserConfigPath()));
QString globalPath(toQString(mCfgMgr.getGlobalPath()));
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>"));
@ -181,7 +187,7 @@ void Wizard::MainWizard::setupGameSettings()
void Wizard::MainWizard::setupLauncherSettings()
{
QString path(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()));
QString path(toQString(mCfgMgr.getUserConfigPath()));
path.append(QLatin1String(Config::LauncherSettings::sLauncherConfigFileName));
QString message(tr("<html><head/><body><p><b>Could not open %1 for reading</b></p> \
@ -228,7 +234,7 @@ void Wizard::MainWizard::runSettingsImporter()
QString path(field(QLatin1String("installation.path")).toString());
// Create the file if it doesn't already exist, else the importer will fail
QString userPath(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()));
QString userPath(toQString(mCfgMgr.getUserConfigPath()));
QFile file(userPath + QLatin1String("openmw.cfg"));
if (!file.exists()) {
@ -387,7 +393,7 @@ void Wizard::MainWizard::writeSettings()
mGameSettings.removeDataDir(path);
mGameSettings.addDataDir(path);
QString userPath(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()));
QString userPath(toQString(mCfgMgr.getUserConfigPath()));
QDir dir(userPath);
if (!dir.exists()) {
@ -460,3 +466,8 @@ bool Wizard::MainWizard::findFiles(const QString &name, const QString &path)
return (dir.entryList().contains(name + QLatin1String(".esm"), Qt::CaseInsensitive)
&& dir.entryList().contains(name + QLatin1String(".bsa"), Qt::CaseInsensitive));
}
QString Wizard::MainWizard::toQString(const boost::filesystem::path& path)
{
return QString::fromUtf8(path.string().c_str());
}

@ -59,6 +59,8 @@ namespace Wizard
void addLogText(const QString &text);
private:
/// convert boost::filesystem::path to QString
QString toQString(const boost::filesystem::path& path);
void setupLog();
void setupGameSettings();

@ -94,18 +94,8 @@ boost::filesystem::path WindowsPath::getInstallPath() const
HKEY hKey;
BOOL f64 = FALSE;
LPCTSTR regkey;
if ((IsWow64Process(GetCurrentProcess(), &f64) && f64) || sizeof(void*) == 8)
{
regkey = "SOFTWARE\\Wow6432Node\\Bethesda Softworks\\Morrowind";
}
else
{
regkey = "SOFTWARE\\Bethesda Softworks\\Morrowind";
}
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(regkey), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
LPCTSTR regkey = TEXT("SOFTWARE\\Bethesda Softworks\\Morrowind");
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey) == ERROR_SUCCESS)
{
//Key existed, let's try to read the install dir
std::vector<char> buf(512);
@ -115,6 +105,7 @@ boost::filesystem::path WindowsPath::getInstallPath() const
{
installPath = &buf[0];
}
RegCloseKey(hKey);
}
return installPath;

Loading…
Cancel
Save