mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
Fixed: Use the right executable for client or default one
This commit is contained in:
parent
ca0d73fcf4
commit
3e0cd2667a
5 changed files with 60 additions and 28 deletions
|
@ -575,13 +575,33 @@ bool CConfigFile::shouldCreateDesktopShortcut() const
|
|||
return profile.desktopShortcut && !QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
|
||||
}
|
||||
|
||||
QString CConfigFile::getClientFullPath() const
|
||||
QString CConfigFile::getProfileClientFullPath(int profileIndex) const
|
||||
{
|
||||
QString path = getProfile().executable;
|
||||
const CProfile &profile = getProfile(profileIndex);
|
||||
|
||||
QString path = profile.executable;
|
||||
|
||||
if (!path.isEmpty()) return path;
|
||||
|
||||
return getInstallationDirectory() + "/" + getServer().id + "/" + getServer().clientFilename;
|
||||
return getServerClientFullPath(profile.server);
|
||||
}
|
||||
|
||||
QString CConfigFile::getServerClientFullPath(const QString &serverId) const
|
||||
{
|
||||
const CServer &server = getServer(serverId);
|
||||
|
||||
if (server.clientFilename.isEmpty()) return "";
|
||||
|
||||
return getInstallationDirectory() + "/" + server.id + "/" + server.clientFilename;
|
||||
}
|
||||
|
||||
QString CConfigFile::getServerConfigurationFullPath(const QString &serverId) const
|
||||
{
|
||||
const CServer &server = getServer(serverId);
|
||||
|
||||
if (server.configurationFilename.isEmpty()) return "";
|
||||
|
||||
return getInstallationDirectory() + "/" + server.id + "/" + server.configurationFilename;
|
||||
}
|
||||
|
||||
QString CConfigFile::getSrcServerClientBNPFullPath() const
|
||||
|
|
|
@ -171,7 +171,9 @@ public:
|
|||
|
||||
QString getClientArch() const;
|
||||
|
||||
QString getClientFullPath() const;
|
||||
QString getProfileClientFullPath(int profileIndex = -1) const;
|
||||
QString getServerClientFullPath(const QString &serverId = "") const;
|
||||
QString getServerConfigurationFullPath(const QString &serverId = "") const;
|
||||
|
||||
QString getSrcServerClientBNPFullPath() const;
|
||||
|
||||
|
|
|
@ -80,16 +80,20 @@ void CMainWindow::onPlayClicked()
|
|||
|
||||
if (profileIndex < 0) return;
|
||||
|
||||
CProfile profile = CConfigFile::getInstance()->getProfile(profileIndex);
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
if (profile.executable.isEmpty()) return;
|
||||
const CProfile &profile = config->getProfile(profileIndex);
|
||||
|
||||
QString executable = config->getProfileClientFullPath(profileIndex);
|
||||
|
||||
if (executable.isEmpty() || !QFile::exists(executable)) return;
|
||||
|
||||
QStringList arguments;
|
||||
arguments << "-p";
|
||||
arguments << QString::number(profileIndex);
|
||||
arguments << profile.arguments.split(' ');
|
||||
|
||||
bool started = QProcess::startDetached(profile.executable, arguments);
|
||||
bool started = QProcess::startDetached(executable, arguments);
|
||||
|
||||
CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex);
|
||||
}
|
||||
|
@ -100,19 +104,19 @@ void CMainWindow::onConfigureClicked()
|
|||
|
||||
if (profileIndex < 0) return;
|
||||
|
||||
CProfile profile = CConfigFile::getInstance()->getProfile(profileIndex);
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
if (profile.server.isEmpty()) return;
|
||||
const CProfile &profile = config->getProfile(profileIndex);
|
||||
|
||||
CServer server = CConfigFile::getInstance()->getServer(profile.server);
|
||||
QString executable = config->getServerConfigurationFullPath(profile.server);
|
||||
|
||||
if (server.configurationFilename.isEmpty()) return;
|
||||
if (executable.isEmpty() || !QFile::exists(executable)) return;
|
||||
|
||||
QStringList arguments;
|
||||
arguments << "-p";
|
||||
arguments << QString::number(profileIndex);
|
||||
|
||||
bool started = QProcess::startDetached(server.configurationFilename, arguments);
|
||||
bool started = QProcess::startDetached(executable, arguments);
|
||||
|
||||
CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex);
|
||||
}
|
||||
|
|
|
@ -590,7 +590,6 @@ bool COperationDialog::createDefaultProfile()
|
|||
CProfile profile;
|
||||
|
||||
profile.id = "0";
|
||||
profile.executable = config->getClientFullPath();
|
||||
profile.name = QString("Ryzom (%1)").arg(server.name);
|
||||
profile.server = server.id;
|
||||
profile.comments = "Default profile created by Ryzom Installer";
|
||||
|
|
|
@ -111,7 +111,7 @@ void CProfilesDialog::displayProfile(int index)
|
|||
profileIdLabel->setText(profile.id);
|
||||
nameEdit->setText(profile.name);
|
||||
serverComboBox->setCurrentIndex(m_serversModel->getIndexFromServerID(profile.server));
|
||||
executablePathLabel->setText(QFileInfo(profile.executable).fileName());
|
||||
executablePathLabel->setText(QFileInfo(executable).fileName());
|
||||
argumentsEdit->setText(profile.arguments);
|
||||
commentsEdit->setPlainText(profile.comments);
|
||||
directoryPathLabel->setText(profileDirectory);
|
||||
|
@ -208,19 +208,11 @@ void CProfilesDialog::updateExecutableVersion(int index)
|
|||
// file empty, use default one
|
||||
if (executable.isEmpty())
|
||||
{
|
||||
executable = CConfigFile::getInstance()->getInstallationDirectory() + "/" + profile.server + "/";
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
executable += "ryzom_client_r.exe";
|
||||
#elif defined(Q_OS_APPLE)
|
||||
executable += "Ryzom.app/Contents/MacOS/Ryzom";
|
||||
#else
|
||||
executable += "ryzom_client";
|
||||
#endif
|
||||
executable += CConfigFile::getInstance()->getServerClientFullPath(profile.server);
|
||||
}
|
||||
|
||||
// file doesn't exist
|
||||
if (!QFile::exists(executable)) return;
|
||||
if (executable.isEmpty() || !QFile::exists(executable)) return;
|
||||
|
||||
// launch executable with --version argument
|
||||
QProcess process;
|
||||
|
@ -252,13 +244,28 @@ void CProfilesDialog::onExecutableBrowseClicked()
|
|||
|
||||
CProfile &profile = m_model->getProfiles()[m_currentProfileIndex];
|
||||
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Please choose Ryzom client executable to launch"), profile.executable, tr("Executables (*.exe)"));
|
||||
QString executable = profile.executable;
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
if (executable.isEmpty())
|
||||
{
|
||||
executable = CConfigFile::getInstance()->getServerClientFullPath(profile.server);
|
||||
}
|
||||
|
||||
profile.executable = file;
|
||||
executable = QFileDialog::getOpenFileName(this, tr("Please choose Ryzom client executable to launch"), executable, tr("Executables (*.exe)"));
|
||||
|
||||
executablePathLabel->setText(QFileInfo(profile.executable).fileName());
|
||||
if (executable.isEmpty()) return;
|
||||
|
||||
// don't need to save the new executable if the same as default one
|
||||
if (executable == CConfigFile::getInstance()->getServerClientFullPath(profile.server))
|
||||
{
|
||||
profile.executable.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
profile.executable = executable;
|
||||
}
|
||||
|
||||
executablePathLabel->setText(QFileInfo(executable).fileName());
|
||||
|
||||
updateExecutableVersion(m_currentProfileIndex);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue