1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 01:10:10 +00:00

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.
This commit is contained in:
dteviot 2015-03-15 08:08:55 +13:00
parent cf077dcf5d
commit 2ef7fc4e2c
5 changed files with 28 additions and 24 deletions

View File

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

View File

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

View File

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

View File

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

View File

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