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