2016-02-25 20:19:27 +00:00
|
|
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
|
|
|
// Copyright (C) 2010 Winch Gate Property Limited
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include "stdpch.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "downloader.h"
|
2016-03-01 12:48:51 +00:00
|
|
|
#include "profilesdialog.h"
|
2016-06-12 13:40:38 +00:00
|
|
|
#include "settingsdialog.h"
|
|
|
|
#include "uninstalldialog.h"
|
2016-05-29 18:30:12 +00:00
|
|
|
#include "operationdialog.h"
|
2016-02-25 20:19:27 +00:00
|
|
|
#include "configfile.h"
|
|
|
|
#include "config.h"
|
2016-05-14 16:51:33 +00:00
|
|
|
#include "profilesmodel.h"
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_NEW
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#endif
|
|
|
|
|
2016-05-25 21:25:10 +00:00
|
|
|
CMainWindow::CMainWindow():QMainWindow()
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
2016-05-18 12:30:33 +00:00
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
// downloader
|
2016-06-12 12:11:58 +00:00
|
|
|
m_downloader = new CDownloader(this, NULL);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
connect(m_downloader, SIGNAL(htmlPageContent(QString)), SLOT(onHtmlPageContent(QString)));
|
|
|
|
|
2016-03-01 12:48:51 +00:00
|
|
|
connect(actionProfiles, SIGNAL(triggered()), SLOT(onProfiles()));
|
2016-09-14 06:14:34 +00:00
|
|
|
|
|
|
|
// remove debug options
|
2016-09-20 19:41:05 +00:00
|
|
|
#ifndef _DEBUG
|
2016-09-14 06:14:34 +00:00
|
|
|
actionSettings->setVisible(false);
|
|
|
|
actionUninstall->setVisible(false);
|
2016-09-20 19:41:05 +00:00
|
|
|
#endif
|
2016-09-14 06:14:34 +00:00
|
|
|
|
2016-06-12 13:41:35 +00:00
|
|
|
connect(actionSettings, SIGNAL(triggered()), SLOT(onSettings()));
|
2016-05-29 18:30:12 +00:00
|
|
|
connect(actionUninstall, SIGNAL(triggered()), SLOT(onUninstall()));
|
2016-06-11 15:03:37 +00:00
|
|
|
connect(actionQuit, SIGNAL(triggered()), SLOT(onQuit()));
|
2016-03-01 12:48:51 +00:00
|
|
|
|
2016-05-14 16:51:33 +00:00
|
|
|
connect(playButton, SIGNAL(clicked()), SLOT(onPlayClicked()));
|
|
|
|
connect(configureButton, SIGNAL(clicked()), SLOT(onConfigureClicked()));
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
connect(actionAboutQt, SIGNAL(triggered()), SLOT(onAboutQt()));
|
|
|
|
connect(actionAbout, SIGNAL(triggered()), SLOT(onAbout()));
|
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onProfileChanged(int)));
|
|
|
|
|
2016-06-12 13:11:39 +00:00
|
|
|
// resize layout depending on content and constraints
|
|
|
|
adjustSize();
|
|
|
|
|
|
|
|
// fix height because to left bitmap
|
|
|
|
setFixedHeight(height());
|
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
updateProfiles();
|
2016-09-14 06:14:00 +00:00
|
|
|
updateButtons();
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CMainWindow::~CMainWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainWindow::showEvent(QShowEvent *e)
|
|
|
|
{
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainWindow::closeEvent(QCloseEvent *e)
|
|
|
|
{
|
|
|
|
hide();
|
|
|
|
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
void CMainWindow::updateProfiles()
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-05-16 09:11:40 +00:00
|
|
|
profilesComboBox->setModel(new CProfilesModel(this));
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-09-14 06:14:00 +00:00
|
|
|
void CMainWindow::updateButtons()
|
|
|
|
{
|
|
|
|
int profileIndex = profilesComboBox->currentIndex();
|
|
|
|
|
|
|
|
if (profileIndex < 0) return;
|
|
|
|
|
|
|
|
CConfigFile *config = CConfigFile::getInstance();
|
|
|
|
|
|
|
|
const CProfile &profile = config->getProfile(profileIndex);
|
|
|
|
const CServer &server = config->getServer(profile.server);
|
|
|
|
|
|
|
|
// get full path of client executable
|
|
|
|
QString executable = profile.getClientFullPath();
|
|
|
|
|
|
|
|
playButton->setEnabled(!executable.isEmpty() && QFile::exists(executable));
|
|
|
|
|
|
|
|
// get full path of configuration executable
|
|
|
|
executable = server.getConfigurationFullPath();
|
|
|
|
|
|
|
|
configureButton->setEnabled(!executable.isEmpty() && QFile::exists(executable));
|
|
|
|
}
|
|
|
|
|
2016-05-14 16:51:33 +00:00
|
|
|
void CMainWindow::onPlayClicked()
|
|
|
|
{
|
|
|
|
int profileIndex = profilesComboBox->currentIndex();
|
|
|
|
|
|
|
|
if (profileIndex < 0) return;
|
|
|
|
|
2016-06-11 15:02:44 +00:00
|
|
|
CConfigFile *config = CConfigFile::getInstance();
|
|
|
|
|
|
|
|
const CProfile &profile = config->getProfile(profileIndex);
|
2016-06-18 17:51:04 +00:00
|
|
|
const CServer &server = config->getServer(profile.server);
|
2016-05-14 16:51:33 +00:00
|
|
|
|
2016-06-12 11:55:27 +00:00
|
|
|
// get full path of client executable
|
2016-06-19 19:04:00 +00:00
|
|
|
QString executable = profile.getClientFullPath();
|
2016-06-11 15:02:44 +00:00
|
|
|
|
|
|
|
if (executable.isEmpty() || !QFile::exists(executable)) return;
|
2016-05-14 16:51:33 +00:00
|
|
|
|
2016-06-12 11:55:27 +00:00
|
|
|
// create arguments list
|
2016-05-14 16:51:33 +00:00
|
|
|
QStringList arguments;
|
|
|
|
arguments << "-p";
|
2016-06-11 15:04:19 +00:00
|
|
|
arguments << profile.id;
|
2016-05-29 18:33:16 +00:00
|
|
|
arguments << profile.arguments.split(' ');
|
2016-05-14 16:51:33 +00:00
|
|
|
|
2016-06-18 17:51:04 +00:00
|
|
|
// launch the game with all arguments and from server root directory (to use right data)
|
|
|
|
bool started = QProcess::startDetached(executable, arguments, server.getDirectory());
|
2016-05-16 09:11:40 +00:00
|
|
|
|
2016-06-12 11:55:27 +00:00
|
|
|
// define this profile as default one
|
2016-05-16 09:11:40 +00:00
|
|
|
CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex);
|
2016-05-14 16:51:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainWindow::onConfigureClicked()
|
|
|
|
{
|
2016-05-18 07:53:36 +00:00
|
|
|
int profileIndex = profilesComboBox->currentIndex();
|
|
|
|
|
|
|
|
if (profileIndex < 0) return;
|
|
|
|
|
2016-06-11 15:02:44 +00:00
|
|
|
CConfigFile *config = CConfigFile::getInstance();
|
2016-05-18 07:53:36 +00:00
|
|
|
|
2016-06-11 15:02:44 +00:00
|
|
|
const CProfile &profile = config->getProfile(profileIndex);
|
2016-06-19 19:04:00 +00:00
|
|
|
const CServer &server = config->getServer(profile.server);
|
2016-05-18 07:53:36 +00:00
|
|
|
|
2016-09-14 06:14:00 +00:00
|
|
|
// get full path of configuration executable
|
2016-06-19 19:04:00 +00:00
|
|
|
QString executable = server.getConfigurationFullPath();
|
2016-05-18 07:53:36 +00:00
|
|
|
|
2016-06-11 15:02:44 +00:00
|
|
|
if (executable.isEmpty() || !QFile::exists(executable)) return;
|
2016-05-18 07:53:36 +00:00
|
|
|
|
|
|
|
QStringList arguments;
|
|
|
|
arguments << "-p";
|
2016-06-11 15:04:19 +00:00
|
|
|
arguments << profile.id;
|
2016-05-18 07:53:36 +00:00
|
|
|
|
2016-06-11 15:02:44 +00:00
|
|
|
bool started = QProcess::startDetached(executable, arguments);
|
2016-05-18 07:53:36 +00:00
|
|
|
|
|
|
|
CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex);
|
2016-05-14 16:51:33 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 12:48:51 +00:00
|
|
|
void CMainWindow::onProfiles()
|
|
|
|
{
|
2016-06-12 11:54:47 +00:00
|
|
|
bool updated = false;
|
2016-03-01 12:48:51 +00:00
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
{
|
2016-06-12 11:54:47 +00:00
|
|
|
CProfilesDialog dialog(this);
|
|
|
|
|
|
|
|
if (dialog.exec())
|
|
|
|
{
|
|
|
|
updateProfiles();
|
|
|
|
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updated)
|
|
|
|
{
|
|
|
|
COperationDialog dialog(this);
|
|
|
|
|
2016-06-14 17:39:39 +00:00
|
|
|
dialog.setOperation(OperationUpdateProfiles);
|
2016-06-12 11:54:47 +00:00
|
|
|
|
|
|
|
if (!dialog.exec())
|
|
|
|
{
|
|
|
|
// aborted
|
|
|
|
}
|
2016-05-16 09:11:40 +00:00
|
|
|
}
|
2016-03-01 12:48:51 +00:00
|
|
|
}
|
2016-05-29 18:30:12 +00:00
|
|
|
|
2016-06-12 13:41:35 +00:00
|
|
|
void CMainWindow::onSettings()
|
|
|
|
{
|
|
|
|
bool updated = false;
|
|
|
|
|
|
|
|
{
|
|
|
|
CSettingsDialog dialog(this);
|
|
|
|
|
|
|
|
if (dialog.exec())
|
|
|
|
{
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updated)
|
|
|
|
{
|
|
|
|
// COperationDialog dialog(this);
|
|
|
|
|
|
|
|
// dialog.setOperation(COperationDialog::OperationUpdateProfiles);
|
|
|
|
|
|
|
|
// if (!dialog.exec())
|
|
|
|
// {
|
|
|
|
// aborted
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-29 18:30:12 +00:00
|
|
|
void CMainWindow::onUninstall()
|
|
|
|
{
|
2016-06-04 17:57:50 +00:00
|
|
|
CConfigFile *config = CConfigFile::getInstance();
|
|
|
|
|
2016-06-19 19:02:17 +00:00
|
|
|
SComponents components;
|
2016-06-04 17:57:50 +00:00
|
|
|
|
|
|
|
// add all servers by default
|
|
|
|
for (int i = 0; i < config->getServersCount(); ++i)
|
|
|
|
{
|
2016-06-14 17:43:45 +00:00
|
|
|
components.servers << config->getServer(i).id;
|
2016-06-04 17:57:50 +00:00
|
|
|
}
|
2016-05-29 18:30:12 +00:00
|
|
|
|
|
|
|
{
|
2016-06-12 13:40:38 +00:00
|
|
|
CUninstallDialog dialog(this);
|
2016-06-04 17:57:50 +00:00
|
|
|
|
|
|
|
dialog.setSelectedComponents(components);
|
2016-05-29 18:30:12 +00:00
|
|
|
|
2016-06-04 17:57:50 +00:00
|
|
|
if (!dialog.exec()) return;
|
2016-05-29 18:30:12 +00:00
|
|
|
|
2016-06-04 17:57:50 +00:00
|
|
|
components = dialog.getSelectedCompenents();
|
|
|
|
}
|
|
|
|
|
|
|
|
COperationDialog dialog;
|
|
|
|
|
2016-06-14 17:39:39 +00:00
|
|
|
dialog.setOperation(OperationUninstall);
|
2016-06-04 17:57:50 +00:00
|
|
|
dialog.setUninstallComponents(components);
|
|
|
|
|
|
|
|
if (dialog.exec())
|
|
|
|
{
|
2016-05-29 18:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-11 15:03:37 +00:00
|
|
|
|
|
|
|
void CMainWindow::onQuit()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
2016-03-01 12:48:51 +00:00
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
void CMainWindow::onAbout()
|
|
|
|
{
|
|
|
|
QString br("<br>");
|
|
|
|
|
|
|
|
QMessageBox::about(this,
|
|
|
|
tr("About %1").arg("Ryzom Installer"),
|
2016-05-16 09:11:40 +00:00
|
|
|
QString("Ryzom Installer %1").arg(QApplication::applicationVersion()) + br +
|
2016-06-12 11:55:07 +00:00
|
|
|
tr("Program to install, download and manage Ryzom profiles.") +
|
2016-02-25 20:19:27 +00:00
|
|
|
br+br+
|
2016-06-12 11:55:16 +00:00
|
|
|
tr("Author: %1").arg("Cédric 'Kervala' OCHS") + br +
|
2016-02-25 20:19:27 +00:00
|
|
|
tr("Copyright: %1").arg(COPYRIGHT) + br +
|
|
|
|
tr("Support: %1").arg("<a href=\"https://bitbucket.org/ryzom/ryzomcore/issues?status=new&status=open\">Ryzom Core on Bitbucket</a>"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainWindow::onAboutQt()
|
|
|
|
{
|
|
|
|
QMessageBox::aboutQt(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainWindow::onHtmlPageContent(const QString &html)
|
|
|
|
{
|
|
|
|
htmlTextEdit->setHtml(html);
|
|
|
|
}
|
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
void CMainWindow::onProfileChanged(int profileIndex)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-05-16 09:11:40 +00:00
|
|
|
if (profileIndex < 0) return;
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
CConfigFile *config = CConfigFile::getInstance();
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
CProfile profile = config->getProfile(profileIndex);
|
|
|
|
CServer server = config->getServer(profile.server);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-05-16 09:11:40 +00:00
|
|
|
// load changelog
|
|
|
|
m_downloader->getHtmlPageContent(config->expandVariables(server.displayUrl));
|
2016-09-14 06:14:00 +00:00
|
|
|
|
|
|
|
updateButtons();
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|