mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 04:51:48 +00:00
Merge with develop
This commit is contained in:
parent
b85c2753a8
commit
9a61bd9a7c
12 changed files with 179 additions and 85 deletions
|
@ -105,7 +105,7 @@ bool CConfigFile::load(const QString &filename)
|
|||
|
||||
settings.beginGroup(QString("profile_%1").arg(i));
|
||||
|
||||
profile.id = settings.value("id").toInt();
|
||||
profile.id = settings.value("id").toString();
|
||||
profile.name = settings.value("name").toString();
|
||||
profile.account = settings.value("account").toString();
|
||||
profile.server = settings.value("server").toString();
|
||||
|
@ -410,11 +410,20 @@ bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const
|
|||
// directory doesn't exist
|
||||
if (!dir.exists()) return false;
|
||||
|
||||
if (!dir.cd("data") && dir.exists()) return false;
|
||||
if (!dir.cd("data") || !dir.exists()) return false;
|
||||
|
||||
// at least 200 BNP in data directory
|
||||
if (dir.entryList(QStringList() << "*.bnp", QDir::Files).size() < 200) return false;
|
||||
|
||||
// fonts.bnp is required
|
||||
if (!dir.exists("fonts.bnp")) return false;
|
||||
|
||||
// gamedev.bnp is required
|
||||
if (!dir.exists("gamedev.bnp")) return false;
|
||||
|
||||
// interfaces.bnp is required
|
||||
if (!dir.exists("interfaces.bnp")) return false;
|
||||
|
||||
// TODO: more checks
|
||||
|
||||
return true;
|
||||
|
@ -550,16 +559,18 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
|
|||
{
|
||||
// user decided to copy files
|
||||
|
||||
// selected directory contains Ryzom files (shouldn't fail)
|
||||
if (!areRyzomDataInstalledIn(getSrcServerDirectory()))
|
||||
{
|
||||
return ShowWizard;
|
||||
}
|
||||
|
||||
// data are not copied
|
||||
if (!areRyzomDataInstalledIn(serverDirectory))
|
||||
{
|
||||
return CopyServerFiles;
|
||||
// selected directory contains Ryzom files (shouldn't fail)
|
||||
if (areRyzomDataInstalledIn(getSrcServerDirectory()))
|
||||
{
|
||||
return CopyServerFiles;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ShowWizard;
|
||||
}
|
||||
}
|
||||
|
||||
// client is not extracted from BNP
|
||||
|
@ -590,7 +601,7 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
|
|||
}
|
||||
|
||||
// no default profile
|
||||
if (profile.id < 0)
|
||||
if (profile.id.isEmpty())
|
||||
{
|
||||
return CreateProfile;
|
||||
}
|
||||
|
|
|
@ -46,12 +46,11 @@ struct CProfile
|
|||
{
|
||||
CProfile()
|
||||
{
|
||||
id = -1;
|
||||
desktopShortcut = false;
|
||||
menuShortcut = false;
|
||||
}
|
||||
|
||||
int id;
|
||||
QString id;
|
||||
QString account;
|
||||
QString name;
|
||||
QString server;
|
||||
|
|
|
@ -52,6 +52,8 @@ void CFilesCleaner::setDirectory(const QString &src)
|
|||
|
||||
bool CFilesCleaner::exec()
|
||||
{
|
||||
if (m_listener) m_listener->operationPrepare();
|
||||
|
||||
QDir dir(m_directory);
|
||||
|
||||
// directory doesn't exist
|
||||
|
@ -62,9 +64,21 @@ bool CFilesCleaner::exec()
|
|||
// temporary files
|
||||
QStringList files = dir.entryList(QStringList() << "*.string_cache" << "*.packed_sheets" << "*.packed" << "*.pem", QDir::Files);
|
||||
|
||||
if (m_listener)
|
||||
{
|
||||
m_listener->operationInit(0, files.size());
|
||||
m_listener->operationStart();
|
||||
}
|
||||
|
||||
int filesCount = 0;
|
||||
|
||||
foreach(const QString &file, files)
|
||||
{
|
||||
dir.remove(file);
|
||||
|
||||
if (m_listener) m_listener->operationProgress(filesCount, file);
|
||||
|
||||
++filesCount;
|
||||
}
|
||||
|
||||
// fonts directory is not needed anymore
|
||||
|
@ -73,7 +87,7 @@ bool CFilesCleaner::exec()
|
|||
dir.removeRecursively();
|
||||
}
|
||||
|
||||
if (m_listener) m_listener->operationFinish();
|
||||
if (m_listener) m_listener->operationSuccess(files.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -181,7 +181,6 @@ bool CFilesCopier::copyFiles(const FilesToCopy &files)
|
|||
if (m_listener)
|
||||
{
|
||||
m_listener->operationSuccess(totalSize);
|
||||
m_listener->operationFinish();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -457,7 +457,6 @@ bool CFilesExtractor::extract7z()
|
|||
if (m_listener)
|
||||
{
|
||||
m_listener->operationSuccess(totalUncompressed);
|
||||
m_listener->operationFinish();
|
||||
}
|
||||
return true;
|
||||
|
||||
|
@ -563,7 +562,6 @@ bool CFilesExtractor::extractZip()
|
|||
if (m_listener)
|
||||
{
|
||||
m_listener->operationSuccess(totalSize);
|
||||
m_listener->operationFinish();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -594,7 +592,6 @@ bool CFilesExtractor::progress(const std::string &filename, uint32 currentSize,
|
|||
if (m_listener)
|
||||
{
|
||||
m_listener->operationSuccess((qint64)totalSize);
|
||||
m_listener->operationFinish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -617,6 +614,7 @@ bool CFilesExtractor::extractBnp()
|
|||
if (m_listener && m_listener->operationShouldStop())
|
||||
{
|
||||
// stopped
|
||||
m_listener->operationStop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ public:
|
|||
virtual void operationProgress(qint64 current, const QString &filename) =0;
|
||||
virtual void operationSuccess(qint64 total) =0;
|
||||
virtual void operationFail(const QString &error) =0;
|
||||
virtual void operationFinish() =0;
|
||||
|
||||
virtual bool operationShouldStop() =0;
|
||||
};
|
||||
|
|
|
@ -42,6 +42,8 @@ COperationDialog::COperationDialog():QDialog(), m_aborting(false)
|
|||
{
|
||||
setupUi(this);
|
||||
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
#if defined(Q_OS_WIN32) && defined(QT_WINEXTRAS_LIB)
|
||||
m_button = new QWinTaskbarButton(this);
|
||||
#endif
|
||||
|
@ -70,6 +72,7 @@ COperationDialog::COperationDialog():QDialog(), m_aborting(false)
|
|||
connect(this, SIGNAL(progress(qint64, QString)), SLOT(onProgressProgress(qint64, QString)));
|
||||
connect(this, SIGNAL(success(qint64)), SLOT(onProgressSuccess(qint64)));
|
||||
connect(this, SIGNAL(fail(QString)), SLOT(onProgressFail(QString)));
|
||||
connect(this, SIGNAL(done()), SLOT(onDone()));
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
|
@ -88,7 +91,10 @@ void COperationDialog::processNextStep()
|
|||
// default profile
|
||||
const CProfile &configuration = config->getProfile();
|
||||
|
||||
switch(config->getNextStep())
|
||||
// long operations are done in a thread
|
||||
CConfigFile::InstallationStep step = config->getNextStep();
|
||||
|
||||
switch(step)
|
||||
{
|
||||
case CConfigFile::DisplayNoServerError:
|
||||
break;
|
||||
|
@ -97,7 +103,7 @@ void COperationDialog::processNextStep()
|
|||
break;
|
||||
|
||||
case CConfigFile::DownloadData:
|
||||
m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part");
|
||||
downloadData();
|
||||
break;
|
||||
|
||||
case CConfigFile::ExtractDownloadedData:
|
||||
|
@ -105,7 +111,7 @@ void COperationDialog::processNextStep()
|
|||
break;
|
||||
|
||||
case CConfigFile::DownloadClient:
|
||||
m_downloader->prepareFile(config->expandVariables(server.clientDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename) + ".part");
|
||||
downloadClient();
|
||||
break;
|
||||
|
||||
case CConfigFile::ExtractDownloadedClient:
|
||||
|
@ -136,12 +142,14 @@ void COperationDialog::processNextStep()
|
|||
createDefaultShortcuts();
|
||||
break;
|
||||
|
||||
case CConfigFile::Done:
|
||||
accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
// cases already managed in main.cpp
|
||||
break;
|
||||
}
|
||||
|
||||
m_downloader->getHtmlPageContent(config->expandVariables(server.displayUrl));
|
||||
}
|
||||
|
||||
void COperationDialog::showEvent(QShowEvent *e)
|
||||
|
@ -218,7 +226,7 @@ void COperationDialog::onProgressStop()
|
|||
m_button->progress()->hide();
|
||||
#endif
|
||||
|
||||
close();
|
||||
reject();
|
||||
}
|
||||
|
||||
void COperationDialog::onProgressProgress(qint64 current, const QString &filename)
|
||||
|
@ -248,7 +256,33 @@ void COperationDialog::onProgressFail(const QString &error)
|
|||
|
||||
void COperationDialog::onDone()
|
||||
{
|
||||
processNextStep();
|
||||
if (!operationShouldStop()) processNextStep();
|
||||
}
|
||||
|
||||
void COperationDialog::downloadData()
|
||||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
// default server
|
||||
const CServer &server = config->getServer();
|
||||
|
||||
m_currentOperation = QApplication::tr("Download data required by server %1").arg(server.name);
|
||||
m_currentOperationProgressFormat = QApplication::tr("Downloading %1...");
|
||||
|
||||
m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part");
|
||||
}
|
||||
|
||||
void COperationDialog::downloadClient()
|
||||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
// default server
|
||||
const CServer &server = config->getServer();
|
||||
|
||||
m_currentOperation = QApplication::tr("Download client required by server %1").arg(server.name);
|
||||
m_currentOperationProgressFormat = QApplication::tr("Downloading %1...");
|
||||
|
||||
m_downloader->prepareFile(config->expandVariables(server.clientDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename) + ".part");
|
||||
}
|
||||
|
||||
void COperationDialog::copyServerFiles()
|
||||
|
@ -258,8 +292,8 @@ void COperationDialog::copyServerFiles()
|
|||
// default server
|
||||
const CServer &server = config->getServer();
|
||||
|
||||
// default profile
|
||||
const CProfile &configuration = config->getProfile();
|
||||
m_currentOperation = QApplication::tr("Copy client files required by server %1").arg(server.name);
|
||||
m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
|
||||
|
||||
QStringList serverFiles;
|
||||
serverFiles << "cfg";
|
||||
|
@ -269,9 +303,6 @@ void COperationDialog::copyServerFiles()
|
|||
serverFiles << "unpack";
|
||||
serverFiles << "client_default.cfg";
|
||||
|
||||
m_currentOperation = QApplication::tr("Copying client files needed for server %1...").arg(server.name);
|
||||
m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
|
||||
|
||||
CFilesCopier copier(this);
|
||||
copier.setSourceDirectory(config->getSrcServerDirectory());
|
||||
copier.setDesinationDirectory(config->getInstallationDirectory() + "/" + server.id);
|
||||
|
@ -283,6 +314,8 @@ void COperationDialog::copyServerFiles()
|
|||
else
|
||||
{
|
||||
}
|
||||
|
||||
emit done();
|
||||
}
|
||||
|
||||
void COperationDialog::copyProfileFiles()
|
||||
|
@ -295,6 +328,9 @@ void COperationDialog::copyProfileFiles()
|
|||
// default profile
|
||||
const CProfile &profile = config->getProfile();
|
||||
|
||||
m_currentOperation = QApplication::tr("Copy old profile to new location");
|
||||
m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
|
||||
|
||||
QStringList profileFiles;
|
||||
profileFiles << "cache";
|
||||
profileFiles << "save";
|
||||
|
@ -314,6 +350,8 @@ void COperationDialog::copyProfileFiles()
|
|||
else
|
||||
{
|
||||
}
|
||||
|
||||
emit done();
|
||||
}
|
||||
|
||||
void COperationDialog::extractBnpClient()
|
||||
|
@ -323,13 +361,44 @@ void COperationDialog::extractBnpClient()
|
|||
// default server
|
||||
const CServer &server = config->getServer();
|
||||
|
||||
// default profile
|
||||
const CProfile &profile = config->getProfile();
|
||||
m_currentOperation = QApplication::tr("Extract client to new location");
|
||||
m_currentOperationProgressFormat = QApplication::tr("Extracting %1...");
|
||||
|
||||
QString destinationDirectory = config->getInstallationDirectory() + "/" + server.id;
|
||||
|
||||
CFilesExtractor extractor(this);
|
||||
extractor.setSourceFile(config->getSrcServerClientBNPFullPath());
|
||||
extractor.setDesinationDirectory(config->getInstallationDirectory() + "/" + server.id);
|
||||
extractor.setDesinationDirectory(destinationDirectory);
|
||||
extractor.exec();
|
||||
|
||||
QString upgradeScript = destinationDirectory + "/upgd_nl.";
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
upgradeScript += "bat";
|
||||
#else
|
||||
upgradeScript += "sh";
|
||||
#endif
|
||||
|
||||
if (QFile::exists(upgradeScript))
|
||||
{
|
||||
QProcess process;
|
||||
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("RYZOM_CLIENT", QDir::toNativeSeparators(destinationDirectory + "/ryzom_client_r.exe"));
|
||||
env.insert("UNPACKPATH", QDir::toNativeSeparators(destinationDirectory + "/unpack"));
|
||||
env.insert("ROOTPATH", QDir::toNativeSeparators(destinationDirectory));
|
||||
env.insert("STARTUPPATH", "");
|
||||
process.setProcessEnvironment(env);
|
||||
|
||||
process.start(upgradeScript);
|
||||
|
||||
while (process.waitForFinished())
|
||||
{
|
||||
qDebug() << "waiting";
|
||||
}
|
||||
}
|
||||
|
||||
emit done();
|
||||
}
|
||||
|
||||
void COperationDialog::cleanFiles()
|
||||
|
@ -339,12 +408,54 @@ void COperationDialog::cleanFiles()
|
|||
// default server
|
||||
const CServer &server = config->getServer();
|
||||
|
||||
// default profile
|
||||
const CProfile &profile = config->getProfile();
|
||||
m_currentOperation = QApplication::tr("Clean obsolete files");
|
||||
m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
|
||||
|
||||
CFilesCleaner cleaner(this);
|
||||
cleaner.setDirectory(config->getInstallationDirectory() + "/" + server.id);
|
||||
cleaner.exec();
|
||||
|
||||
emit done();
|
||||
}
|
||||
|
||||
bool COperationDialog::createDefaultProfile()
|
||||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
CServer server = config->getServer(config->getDefaultServerIndex());
|
||||
|
||||
m_currentOperation = QApplication::tr("Create default profile");
|
||||
m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
|
||||
|
||||
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";
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
// C:\Users\Public\Desktop
|
||||
profile.desktopShortcut = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
|
||||
#endif
|
||||
|
||||
// TODO
|
||||
// profile.menuShortcut
|
||||
|
||||
config->addProfile(profile);
|
||||
config->save();
|
||||
|
||||
emit done();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COperationDialog::createDefaultShortcuts()
|
||||
{
|
||||
emit done();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void COperationDialog::operationPrepare()
|
||||
|
@ -382,50 +493,9 @@ void COperationDialog::operationFail(const QString &error)
|
|||
emit fail(error);
|
||||
}
|
||||
|
||||
void COperationDialog::operationFinish()
|
||||
{
|
||||
emit done();
|
||||
}
|
||||
|
||||
bool COperationDialog::operationShouldStop()
|
||||
{
|
||||
QMutexLocker locker(&m_abortingMutex);
|
||||
|
||||
return m_aborting;
|
||||
}
|
||||
|
||||
bool COperationDialog::createDefaultProfile()
|
||||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
||||
CServer server = config->getServer(config->getDefaultServerIndex());
|
||||
|
||||
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";
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
profile.desktopShortcut = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
|
||||
#endif
|
||||
|
||||
// TODO
|
||||
// profile.menuShortcut
|
||||
|
||||
config->addProfile(profile);
|
||||
config->save();
|
||||
|
||||
onDone();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COperationDialog::createDefaultShortcuts()
|
||||
{
|
||||
onDone();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@ protected:
|
|||
void processNextStep();
|
||||
|
||||
// operations
|
||||
void downloadData();
|
||||
void downloadClient();
|
||||
void copyServerFiles();
|
||||
void copyProfileFiles();
|
||||
void extractBnpClient();
|
||||
|
@ -97,7 +99,6 @@ protected:
|
|||
virtual void operationProgress(qint64 current, const QString &filename);
|
||||
virtual void operationSuccess(qint64 total);
|
||||
virtual void operationFail(const QString &error);
|
||||
virtual void operationFinish();
|
||||
|
||||
virtual bool operationShouldStop();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ CProfilesDialog::CProfilesDialog():QDialog(), m_currentProfileIndex(-1)
|
|||
profilesListView->setModel(m_model);
|
||||
serverComboBox->setModel(m_serversModel);
|
||||
|
||||
int index = m_model->getIndexFromProfileID(CConfigFile::getInstance()->getDefaultProfileIndex());
|
||||
int index = CConfigFile::getInstance()->getDefaultProfileIndex();
|
||||
|
||||
profilesListView->setCurrentIndex(m_model->index(index, 0));
|
||||
displayProfile(index);
|
||||
|
@ -97,7 +97,7 @@ void CProfilesDialog::displayProfile(int index)
|
|||
const CProfile &profile = m_model->getProfiles()[index];
|
||||
|
||||
// update all widgets with content of profile
|
||||
profileIdLabel->setText(QString::number(profile.id));
|
||||
profileIdLabel->setText(profile.id);
|
||||
accountEdit->setText(profile.account);
|
||||
nameEdit->setText(profile.name);
|
||||
serverComboBox->setCurrentIndex(m_serversModel->getIndexFromServerID(profile.server));
|
||||
|
|
|
@ -24,7 +24,7 @@ QVariant CProfilesModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
const CProfile &profile = m_profiles.at(index.row());
|
||||
|
||||
return QString("%1 (#%2)").arg(profile.name).arg(profile.id);
|
||||
return tr("#%1: %2").arg(profile.id).arg(profile.name);
|
||||
}
|
||||
|
||||
bool CProfilesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
|
@ -48,7 +48,7 @@ bool CProfilesModel::save() const
|
|||
return true;
|
||||
}
|
||||
|
||||
int CProfilesModel::getIndexFromProfileID(int profileId) const
|
||||
int CProfilesModel::getIndexFromProfileID(const QString &profileId) const
|
||||
{
|
||||
for(int i = 0; i < m_profiles.size(); ++i)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ int CProfilesModel::getIndexFromProfileID(int profileId) const
|
|||
return -1;
|
||||
}
|
||||
|
||||
int CProfilesModel::getProfileIDFromIndex(int index) const
|
||||
QString CProfilesModel::getProfileIDFromIndex(int index) const
|
||||
{
|
||||
if (index < 0 || index >= m_profiles.size()) return -1;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
|
||||
bool save() const;
|
||||
|
||||
int getIndexFromProfileID(int profileId) const;
|
||||
int getProfileIDFromIndex(int index) const;
|
||||
int getIndexFromProfileID(const QString &profileId) const;
|
||||
QString getProfileIDFromIndex(int index) const;
|
||||
|
||||
private:
|
||||
CProfiles m_profiles;
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<ui version="4.0">
|
||||
<class>OperationDialog</class>
|
||||
<widget class="QDialog" name="OperationDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
@ -11,7 +14,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Ryzom Installer</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
|
|
Loading…
Reference in a new issue