mirror of
https://github.com/vcmi/vcmi.git
synced 2025-10-08 23:22:25 +02:00
fixes for launcher, as discussed on forums:
- renamed files that should be preprocessed with moc: they will have _moc suffix (cpp files were also renamed for consistency) - fixed disabling of mods that have dependent on them mods - repositories will be reloaded if changed - may have fixed non-starting vcmi client on Win
This commit is contained in:
@@ -5,29 +5,29 @@ include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR})
|
|||||||
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
|
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
|
||||||
|
|
||||||
set(launcher_modmanager_SRCS
|
set(launcher_modmanager_SRCS
|
||||||
modManager/cdownloadmanager.cpp
|
modManager/cdownloadmanager_moc.cpp
|
||||||
modManager/cmodlist.cpp
|
modManager/cmodlist.cpp
|
||||||
modManager/cmodlistmodel.cpp
|
modManager/cmodlistmodel_moc.cpp
|
||||||
modManager/cmodlistview.cpp
|
modManager/cmodlistview_moc.cpp
|
||||||
modManager/cmodmanager.cpp
|
modManager/cmodmanager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(launcher_settingsview_SRCS
|
set(launcher_settingsview_SRCS
|
||||||
settingsView/csettingsview.cpp
|
settingsView/csettingsview_moc.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(launcher_SRCS
|
set(launcher_SRCS
|
||||||
${launcher_modmanager_SRCS}
|
${launcher_modmanager_SRCS}
|
||||||
${launcher_settingsview_SRCS}
|
${launcher_settingsview_SRCS}
|
||||||
main.cpp
|
main.cpp
|
||||||
mainwindow.cpp
|
mainwindow_moc.cpp
|
||||||
launcherdirs.cpp
|
launcherdirs.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(launcher_FORMS
|
set(launcher_FORMS
|
||||||
modManager/cmodlistview.ui
|
modManager/cmodlistview_moc.ui
|
||||||
settingsView/csettingsview.ui
|
settingsView/csettingsview_moc.ui
|
||||||
mainwindow.ui
|
mainwindow_moc.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
# Tell CMake to run moc when necessary:
|
# Tell CMake to run moc when necessary:
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow_moc.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow_moc.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow_moc.h"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -46,13 +46,7 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
void MainWindow::on_startGameButon_clicked()
|
void MainWindow::on_startGameButon_clicked()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
startExecutable(QString::fromUtf8(VCMIDirs::get().clientPath().c_str()));
|
||||||
QString clientName = "VCMI_Client.exe";
|
|
||||||
#else
|
|
||||||
// TODO: Right now launcher will only start vcmi from system-default locations
|
|
||||||
QString clientName = "vcmiclient";
|
|
||||||
#endif
|
|
||||||
startExecutable(clientName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::startExecutable(QString name)
|
void MainWindow::startExecutable(QString name)
|
||||||
@@ -68,7 +62,8 @@ void MainWindow::startExecutable(QString name)
|
|||||||
{
|
{
|
||||||
QMessageBox::critical(this,
|
QMessageBox::critical(this,
|
||||||
"Error starting executable",
|
"Error starting executable",
|
||||||
"Failed to start " + name + ": " + process.errorString(),
|
"Failed to start " + name + "\n"
|
||||||
|
"Reason: " + process.errorString(),
|
||||||
QMessageBox::Ok,
|
QMessageBox::Ok,
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
return;
|
return;
|
@@ -187,13 +187,13 @@
|
|||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CModListView</class>
|
<class>CModListView</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>modManager/cmodlistview.h</header>
|
<header>modManager/cmodlistview_moc.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CSettingsView</class>
|
<class>CSettingsView</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>settingsView/csettingsview.h</header>
|
<header>settingsView/csettingsview_moc.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
@@ -1,5 +1,5 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "cdownloadmanager.h"
|
#include "cdownloadmanager_moc.h"
|
||||||
|
|
||||||
#include "launcherdirs.h"
|
#include "launcherdirs.h"
|
||||||
|
|
@@ -111,9 +111,14 @@ QJsonObject CModList::copyField(QJsonObject data, QString from, QString to)
|
|||||||
return renamed;
|
return renamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModList::resetRepositories()
|
||||||
|
{
|
||||||
|
repositories.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void CModList::addRepository(QJsonObject data)
|
void CModList::addRepository(QJsonObject data)
|
||||||
{
|
{
|
||||||
repositores.push_back(copyField(data, "version", "latestVersion"));
|
repositories.push_back(copyField(data, "version", "latestVersion"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModList::setLocalModList(QJsonObject data)
|
void CModList::setLocalModList(QJsonObject data)
|
||||||
@@ -134,7 +139,7 @@ CModEntry CModList::getMod(QString modname) const
|
|||||||
QJsonObject local = localModList[modname].toObject();
|
QJsonObject local = localModList[modname].toObject();
|
||||||
QJsonValue settings = modSettings[modname];
|
QJsonValue settings = modSettings[modname];
|
||||||
|
|
||||||
for (auto entry : repositores)
|
for (auto entry : repositories)
|
||||||
{
|
{
|
||||||
if (entry.contains(modname))
|
if (entry.contains(modname))
|
||||||
{
|
{
|
||||||
@@ -157,7 +162,7 @@ bool CModList::hasMod(QString modname) const
|
|||||||
if (localModList.contains(modname))
|
if (localModList.contains(modname))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (auto entry : repositores)
|
for (auto entry : repositories)
|
||||||
if (entry.contains(modname))
|
if (entry.contains(modname))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -184,7 +189,7 @@ QVector<QString> CModList::getModList() const
|
|||||||
{
|
{
|
||||||
QSet<QString> knownMods;
|
QSet<QString> knownMods;
|
||||||
QVector<QString> modList;
|
QVector<QString> modList;
|
||||||
for (auto repo : repositores)
|
for (auto repo : repositories)
|
||||||
{
|
{
|
||||||
for (auto it = repo.begin(); it != repo.end(); it++)
|
for (auto it = repo.begin(); it != repo.end(); it++)
|
||||||
{
|
{
|
||||||
|
@@ -52,12 +52,13 @@ public:
|
|||||||
|
|
||||||
class CModList
|
class CModList
|
||||||
{
|
{
|
||||||
QVector<QJsonObject> repositores;
|
QVector<QJsonObject> repositories;
|
||||||
QJsonObject localModList;
|
QJsonObject localModList;
|
||||||
QJsonObject modSettings;
|
QJsonObject modSettings;
|
||||||
|
|
||||||
QJsonObject copyField(QJsonObject data, QString from, QString to);
|
QJsonObject copyField(QJsonObject data, QString from, QString to);
|
||||||
public:
|
public:
|
||||||
|
virtual void resetRepositories();
|
||||||
virtual void addRepository(QJsonObject data);
|
virtual void addRepository(QJsonObject data);
|
||||||
virtual void setLocalModList(QJsonObject data);
|
virtual void setLocalModList(QJsonObject data);
|
||||||
virtual void setModSettings(QJsonObject data);
|
virtual void setModSettings(QJsonObject data);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "cmodlistmodel.h"
|
#include "cmodlistmodel_moc.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
@@ -110,6 +110,13 @@ QVariant CModListModel::headerData(int section, Qt::Orientation orientation, int
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModListModel::resetRepositories()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
CModList::resetRepositories();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
void CModListModel::addRepository(QJsonObject data)
|
void CModListModel::addRepository(QJsonObject data)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
@@ -29,6 +29,7 @@ class CModListModel : public QAbstractTableModel, public CModList
|
|||||||
void endResetModel();
|
void endResetModel();
|
||||||
public:
|
public:
|
||||||
/// CModListContainer overrides
|
/// CModListContainer overrides
|
||||||
|
void resetRepositories();
|
||||||
void addRepository(QJsonObject data);
|
void addRepository(QJsonObject data);
|
||||||
void setLocalModList(QJsonObject data);
|
void setLocalModList(QJsonObject data);
|
||||||
void setModSettings(QJsonObject data);
|
void setModSettings(QJsonObject data);
|
@@ -1,13 +1,13 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "cmodlistview.h"
|
#include "cmodlistview_moc.h"
|
||||||
#include "ui_cmodlistview.h"
|
#include "ui_cmodlistview_moc.h"
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
#include "cmodlistmodel.h"
|
#include "cmodlistmodel_moc.h"
|
||||||
#include "cmodmanager.h"
|
#include "cmodmanager.h"
|
||||||
#include "cdownloadmanager.h"
|
#include "cdownloadmanager_moc.h"
|
||||||
#include "launcherdirs.h"
|
#include "launcherdirs.h"
|
||||||
|
|
||||||
#include "../lib/CConfigHandler.h"
|
#include "../lib/CConfigHandler.h"
|
||||||
@@ -42,12 +42,16 @@ void CModListView::setupModsView()
|
|||||||
|
|
||||||
connect( filterModel, SIGNAL( modelReset()),
|
connect( filterModel, SIGNAL( modelReset()),
|
||||||
this, SLOT( modelReset()));
|
this, SLOT( modelReset()));
|
||||||
|
|
||||||
|
selectMod(filterModel->rowCount() > 0 ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CModListView::CModListView(QWidget *parent) :
|
CModListView::CModListView(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
settingsListener(settings.listen["launcher"]["repositoryURL"]),
|
||||||
ui(new Ui::CModListView)
|
ui(new Ui::CModListView)
|
||||||
{
|
{
|
||||||
|
settingsListener([&](const JsonNode &){ repositoriesChanged = true; });
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setupModModel();
|
setupModModel();
|
||||||
@@ -56,10 +60,12 @@ CModListView::CModListView(QWidget *parent) :
|
|||||||
|
|
||||||
ui->progressWidget->setVisible(false);
|
ui->progressWidget->setVisible(false);
|
||||||
dlManager = nullptr;
|
dlManager = nullptr;
|
||||||
|
loadRepositories();
|
||||||
|
}
|
||||||
|
|
||||||
// hide mod description on start. looks better this way
|
void CModListView::loadRepositories()
|
||||||
hideModInfo();
|
{
|
||||||
|
manager->resetRepositories();
|
||||||
for (auto entry : settings["launcher"]["repositoryURL"].Vector())
|
for (auto entry : settings["launcher"]["repositoryURL"].Vector())
|
||||||
{
|
{
|
||||||
QString str = QString::fromUtf8(entry.String().c_str());
|
QString str = QString::fromUtf8(entry.String().c_str());
|
||||||
@@ -77,6 +83,16 @@ CModListView::~CModListView()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModListView::showEvent(QShowEvent * event)
|
||||||
|
{
|
||||||
|
QWidget::showEvent(event);
|
||||||
|
if (repositoriesChanged)
|
||||||
|
{
|
||||||
|
repositoriesChanged = false;
|
||||||
|
loadRepositories();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CModListView::showModInfo()
|
void CModListView::showModInfo()
|
||||||
{
|
{
|
||||||
ui->modInfoWidget->show();
|
ui->modInfoWidget->show();
|
||||||
@@ -174,6 +190,7 @@ QString CModListView::genModInfoText(CModEntry &mod)
|
|||||||
|
|
||||||
void CModListView::enableModInfo()
|
void CModListView::enableModInfo()
|
||||||
{
|
{
|
||||||
|
showModInfo();
|
||||||
ui->hideModInfoButton->setEnabled(true);
|
ui->hideModInfoButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,5 +531,6 @@ void CModListView::on_pushButton_clicked()
|
|||||||
|
|
||||||
void CModListView::modelReset()
|
void CModListView::modelReset()
|
||||||
{
|
{
|
||||||
selectMod(filterModel->mapToSource(ui->allModsView->currentIndex()).row());
|
//selectMod(filterModel->mapToSource(ui->allModsView->currentIndex()).row());
|
||||||
|
selectMod(filterModel->rowCount() > 0 ? 0 : -1);
|
||||||
}
|
}
|
@@ -1,5 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "../../lib/CConfigHandler.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class CModListView;
|
class CModListView;
|
||||||
}
|
}
|
||||||
@@ -21,11 +24,17 @@ class CModListView : public QWidget
|
|||||||
CModFilterModel * filterModel;
|
CModFilterModel * filterModel;
|
||||||
CDownloadManager * dlManager;
|
CDownloadManager * dlManager;
|
||||||
|
|
||||||
|
SettingsListener settingsListener;
|
||||||
|
bool repositoriesChanged;
|
||||||
|
|
||||||
|
void showEvent(QShowEvent * event);
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent * event);
|
void keyPressEvent(QKeyEvent * event);
|
||||||
|
|
||||||
void setupModModel();
|
void setupModModel();
|
||||||
void setupFilterModel();
|
void setupFilterModel();
|
||||||
void setupModsView();
|
void setupModsView();
|
||||||
|
void loadRepositories();
|
||||||
|
|
||||||
// find mods unknown to mod list (not present in repo and not installed)
|
// find mods unknown to mod list (not present in repo and not installed)
|
||||||
QStringList findInvalidDependencies(QString mod);
|
QStringList findInvalidDependencies(QString mod);
|
@@ -61,6 +61,11 @@ void CModManager::loadModSettings()
|
|||||||
modList->setModSettings(modSettings["activeMods"].toObject());
|
modList->setModSettings(modSettings["activeMods"].toObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModManager::resetRepositories()
|
||||||
|
{
|
||||||
|
modList->resetRepositories();
|
||||||
|
}
|
||||||
|
|
||||||
void CModManager::loadRepository(QString file)
|
void CModManager::loadRepository(QString file)
|
||||||
{
|
{
|
||||||
modList->addRepository(JsonFromFile(file));
|
modList->addRepository(JsonFromFile(file));
|
||||||
@@ -182,7 +187,7 @@ bool CModManager::canDisableMod(QString modname)
|
|||||||
auto current = modList->getMod(modEntry);
|
auto current = modList->getMod(modEntry);
|
||||||
|
|
||||||
if (current.getValue("depends").toStringList().contains(modname) &&
|
if (current.getValue("depends").toStringList().contains(modname) &&
|
||||||
!current.isDisabled())
|
current.isEnabled())
|
||||||
return false; // this mod must be disabled first
|
return false; // this mod must be disabled first
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -19,6 +19,7 @@ class CModManager
|
|||||||
public:
|
public:
|
||||||
CModManager(CModList * modList);
|
CModManager(CModList * modList);
|
||||||
|
|
||||||
|
void resetRepositories();
|
||||||
void loadRepository(QString filename);
|
void loadRepository(QString filename);
|
||||||
void loadModSettings();
|
void loadModSettings();
|
||||||
void loadMods();
|
void loadMods();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "csettingsview.h"
|
#include "csettingsview_moc.h"
|
||||||
#include "ui_csettingsview.h"
|
#include "ui_csettingsview_moc.h"
|
||||||
|
|
||||||
#include "../lib/CConfigHandler.h"
|
#include "../lib/CConfigHandler.h"
|
||||||
#include "../lib/VCMIDirs.h"
|
#include "../lib/VCMIDirs.h"
|
@@ -60,6 +60,11 @@ std::string VCMIDirs::libraryPath() const
|
|||||||
return userDataPath();
|
return userDataPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VCMIDirs::clientPath() const
|
||||||
|
{
|
||||||
|
return userDataPath() + "\\" + "VCMI_client.exe";
|
||||||
|
}
|
||||||
|
|
||||||
std::string VCMIDirs::serverPath() const
|
std::string VCMIDirs::serverPath() const
|
||||||
{
|
{
|
||||||
return userDataPath() + "\\" + "VCMI_server.exe";
|
return userDataPath() + "\\" + "VCMI_server.exe";
|
||||||
@@ -96,9 +101,14 @@ std::string VCMIDirs::libraryPath() const
|
|||||||
return ".";
|
return ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VCMIDirs::clientPath() const
|
||||||
|
{
|
||||||
|
return userDataPath() + "\\" + "VCMI_client.exe";
|
||||||
|
}
|
||||||
|
|
||||||
std::string VCMIDirs::serverPath() const
|
std::string VCMIDirs::serverPath() const
|
||||||
{
|
{
|
||||||
return "./vcmiserver";
|
return userDataPath() + "\\" + "VCMI_server.exe";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> VCMIDirs::dataPaths() const
|
std::vector<std::string> VCMIDirs::dataPaths() const
|
||||||
@@ -125,6 +135,11 @@ std::string VCMIDirs::libraryPath() const
|
|||||||
return M_LIB_DIR;
|
return M_LIB_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VCMIDirs::clientPath() const
|
||||||
|
{
|
||||||
|
return std::string(M_BIN_DIR) + "/" + "vcmiclient";
|
||||||
|
}
|
||||||
|
|
||||||
std::string VCMIDirs::serverPath() const
|
std::string VCMIDirs::serverPath() const
|
||||||
{
|
{
|
||||||
return std::string(M_BIN_DIR) + "/" + "vcmiserver";
|
return std::string(M_BIN_DIR) + "/" + "vcmiserver";
|
||||||
|
@@ -39,7 +39,10 @@ public:
|
|||||||
/// Paths to global system-wide data directories. First items have higher priority
|
/// Paths to global system-wide data directories. First items have higher priority
|
||||||
std::vector<std::string> dataPaths() const;
|
std::vector<std::string> dataPaths() const;
|
||||||
|
|
||||||
/// Full path to vcmiserver executable, including server name (e.g. /usr/bin/vcmiserver)
|
/// Full path to client executable, including server name (e.g. /usr/bin/vcmiclient)
|
||||||
|
std::string clientPath() const;
|
||||||
|
|
||||||
|
/// Full path to server executable, including server name (e.g. /usr/bin/vcmiserver)
|
||||||
std::string serverPath() const;
|
std::string serverPath() const;
|
||||||
|
|
||||||
/// Path where vcmi libraries can be found (in AI and Scripting subdirectories)
|
/// Path where vcmi libraries can be found (in AI and Scripting subdirectories)
|
||||||
|
Reference in New Issue
Block a user