mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Implemented install of mods via setup
This commit is contained in:
parent
9c92d97f98
commit
1ff317058e
@ -30,8 +30,8 @@ FirstLaunchView::FirstLaunchView(QWidget * parent)
|
||||
enterSetup();
|
||||
activateTabLanguage();
|
||||
|
||||
ui->lineEditDataSystem->setText(boost::filesystem::absolute(VCMIDirs::get().dataPaths().front()).c_str());
|
||||
ui->lineEditDataUser->setText(boost::filesystem::absolute(VCMIDirs::get().userDataPath()).c_str());
|
||||
ui->lineEditDataSystem->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().dataPaths().front())));
|
||||
ui->lineEditDataUser->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().userDataPath())));
|
||||
}
|
||||
|
||||
void FirstLaunchView::on_buttonTabLanguage_clicked()
|
||||
@ -156,7 +156,8 @@ void FirstLaunchView::activateTabModPreset()
|
||||
|
||||
void FirstLaunchView::exitSetup()
|
||||
{
|
||||
//TODO: unlock UI, switch to another tab (mods?)
|
||||
if(auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow()))
|
||||
mainWindow->exitSetup();
|
||||
}
|
||||
|
||||
// Tab Language
|
||||
@ -279,38 +280,37 @@ void FirstLaunchView::forceHeroesLanguage(const QString & language)
|
||||
|
||||
void FirstLaunchView::copyHeroesData()
|
||||
{
|
||||
assert(0); // TODO: test
|
||||
QDir sourceRoot = QFileDialog::getExistingDirectory(this, "", "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
QDir dir = QFileDialog::getExistingDirectory(this, "", "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if(!dir.exists())
|
||||
if(!sourceRoot.exists())
|
||||
return;
|
||||
|
||||
QStringList dirData = dir.entryList({"data"}, QDir::Filter::Dirs);
|
||||
QStringList dirMaps = dir.entryList({"maps"}, QDir::Filter::Dirs);
|
||||
QStringList dirMp3 = dir.entryList({"mp3"}, QDir::Filter::Dirs);
|
||||
QStringList dirData = sourceRoot.entryList({"data"}, QDir::Filter::Dirs);
|
||||
QStringList dirMaps = sourceRoot.entryList({"maps"}, QDir::Filter::Dirs);
|
||||
QStringList dirMp3 = sourceRoot.entryList({"mp3"}, QDir::Filter::Dirs);
|
||||
|
||||
if(dirData.empty() || dirMaps.empty() || dirMp3.empty())
|
||||
return;
|
||||
|
||||
QStringList lodArchives = QDir(dirData.front()).entryList({"*.lod"}, QDir::Filter::Files);
|
||||
QDir sourceData = sourceRoot.filePath(dirData.front());
|
||||
QStringList lodArchives = sourceData.entryList({"*.lod"}, QDir::Filter::Files);
|
||||
|
||||
if(lodArchives.empty())
|
||||
return;
|
||||
|
||||
QStringList copyDirectories = {dirData.front(), dirMaps.front(), dirMp3.front()};
|
||||
|
||||
QDir targetRoot = QString(VCMIDirs::get().userDataPath().c_str());
|
||||
QDir targetRoot = pathToQString(VCMIDirs::get().userDataPath());
|
||||
|
||||
for(QDir sourceDir : copyDirectories)
|
||||
for(const QString & dirName : copyDirectories)
|
||||
{
|
||||
QString dirName = sourceDir.dirName();
|
||||
QDir sourceDir = sourceRoot.filePath(dirName);
|
||||
QDir targetDir = targetRoot.filePath(dirName);
|
||||
|
||||
if(!targetRoot.exists(dirName))
|
||||
targetRoot.mkdir(dirName);
|
||||
|
||||
for(QString filename : sourceDir.entryList(QDir::Filter::Files))
|
||||
for(const QString & filename : sourceDir.entryList(QDir::Filter::Files))
|
||||
{
|
||||
QFile sourceFile(sourceDir.filePath(filename));
|
||||
sourceFile.copy(targetDir.filePath(filename));
|
||||
@ -326,12 +326,12 @@ void FirstLaunchView::modPresetUpdate()
|
||||
bool translationExists = !findTranslationModName().isEmpty();
|
||||
|
||||
ui->labelPresetLanguage->setVisible(translationExists);
|
||||
ui->toolButtonPresetLanguage->setVisible(translationExists);
|
||||
ui->checkBoxPresetLanguage->setVisible(translationExists);
|
||||
|
||||
ui->toolButtonPresetLanguage->setEnabled(checkCanInstallTranslation());
|
||||
ui->toolButtonPresetExtras->setEnabled(checkCanInstallExtras());
|
||||
ui->toolButtonPresetHota->setEnabled(checkCanInstallHota());
|
||||
ui->toolButtonPresetWog->setEnabled(checkCanInstallWog());
|
||||
ui->checkBoxPresetLanguage->setEnabled(checkCanInstallTranslation());
|
||||
ui->checkBoxPresetExtras->setEnabled(checkCanInstallExtras());
|
||||
ui->checkBoxPresetHota->setEnabled(checkCanInstallHota());
|
||||
ui->checkBoxPresetWog->setEnabled(checkCanInstallWog());
|
||||
}
|
||||
|
||||
QString FirstLaunchView::findTranslationModName()
|
||||
@ -389,41 +389,30 @@ bool FirstLaunchView::checkCanInstallMod(const QString & modID)
|
||||
return getModView() && !getModView()->isModInstalled(modID);
|
||||
}
|
||||
|
||||
void FirstLaunchView::installTranslation()
|
||||
{
|
||||
installMod(findTranslationModName());
|
||||
}
|
||||
|
||||
void FirstLaunchView::installWog()
|
||||
{
|
||||
installMod("wake-of-gods");
|
||||
}
|
||||
|
||||
void FirstLaunchView::installHota()
|
||||
{
|
||||
installMod("hota");
|
||||
}
|
||||
|
||||
void FirstLaunchView::instalExtras()
|
||||
{
|
||||
installMod("vcmi-extras");
|
||||
}
|
||||
|
||||
void FirstLaunchView::installMod(const QString & modID)
|
||||
{
|
||||
assert(0); // TODO: test
|
||||
|
||||
return getModView()->doInstallMod(modID);
|
||||
}
|
||||
|
||||
void FirstLaunchView::on_pushButtonPresetBack_clicked()
|
||||
{
|
||||
activateTabHeroesData();
|
||||
}
|
||||
|
||||
|
||||
void FirstLaunchView::on_pushButtonPresetNext_clicked()
|
||||
{
|
||||
QStringList modsToInstall;
|
||||
|
||||
if (ui->checkBoxPresetLanguage && checkCanInstallTranslation())
|
||||
modsToInstall.push_back(findTranslationModName());
|
||||
|
||||
if (ui->checkBoxPresetExtras && checkCanInstallExtras())
|
||||
modsToInstall.push_back("vcmi-extras");
|
||||
|
||||
if (ui->checkBoxPresetWog && checkCanInstallWog())
|
||||
modsToInstall.push_back("wake-of-gods");
|
||||
|
||||
if (ui->checkBoxPresetHota && checkCanInstallHota())
|
||||
modsToInstall.push_back("hota");
|
||||
|
||||
exitSetup();
|
||||
|
||||
for (auto const & modName : modsToInstall)
|
||||
getModView()->doInstallMod(modName);
|
||||
}
|
||||
|
||||
|
@ -65,10 +65,6 @@ class FirstLaunchView : public QWidget
|
||||
bool checkCanInstallExtras();
|
||||
bool checkCanInstallMod(const QString & modID);
|
||||
|
||||
void installTranslation();
|
||||
void installWog();
|
||||
void installHota();
|
||||
void instalExtras();
|
||||
void installMod(const QString & modID);
|
||||
|
||||
public:
|
||||
|
@ -539,135 +539,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4" rowstretch="1,0,0,0,0" columnstretch="3,1">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelPresetHota">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>VCMI provides support for Horn of the Abyss: fan-made Heroes III expansion, ported by VCMI team</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelPresetExtras">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>VCMI provides support for playing Heroes III in resolutions other than 800x600. If you wish, you can install this support</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QToolButton" name="toolButtonPresetExtras">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install HD support</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QToolButton" name="toolButtonPresetWog">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install In the Wake of Gods</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolButton" name="toolButtonPresetLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install localization</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelPresetWog">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>VCMI provides compatible version of the "In The Wake of Gods" fan-made addon</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelPresetLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>VCMI provides translations of Heroes III into a different languages. If you wish, you can install translation to English</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QToolButton" name="toolButtonPresetHota">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install Horn of the Abyss</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="labelPresetDescription">
|
||||
<property name="sizePolicy">
|
||||
@ -677,7 +549,129 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Optionally, you can install additional mods either now or at any point later</string>
|
||||
<string>Optionally, you can install additional mods either now or at any point later:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxPresetLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="labelPresetLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install English translation of Heroes III</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxPresetExtras">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="labelPresetExtras">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install support for playing Heroes III in resolutions other than 800x600.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxPresetHota">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="labelPresetHota">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install compatible version of addon Horn of the Abyss: fan-made Heroes III expansion, ported by VCMI team</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxPresetWog">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="labelPresetWog">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install compatible version of addon "In The Wake of Gods": fan-made Heroes III expansion</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
@ -106,18 +106,9 @@ MainWindow::MainWindow(QWidget * parent)
|
||||
bool setupCompleted = settings["launcher"]["setupCompleted"].Bool();
|
||||
|
||||
if (h3DataFound && setupCompleted)
|
||||
{
|
||||
ui->tabListWidget->setCurrentIndex(TabRows::MODS);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->startGameButton->setEnabled(false);
|
||||
ui->startEditorButton->setEnabled(false);
|
||||
ui->lobbyButton->setEnabled(false);
|
||||
ui->settingsButton->setEnabled(false);
|
||||
ui->modslistButton->setEnabled(false);
|
||||
ui->tabListWidget->setCurrentIndex(TabRows::SETUP);
|
||||
}
|
||||
enterSetup();
|
||||
|
||||
ui->settingsView->isExtraResolutionsModEnabled = ui->modlistView->isExtraResolutionsModEnabled();
|
||||
ui->settingsView->setDisplayList();
|
||||
@ -128,6 +119,29 @@ MainWindow::MainWindow(QWidget * parent)
|
||||
UpdateDialog::showUpdateDialog(false);
|
||||
}
|
||||
|
||||
void MainWindow::enterSetup()
|
||||
{
|
||||
ui->startGameButton->setEnabled(false);
|
||||
ui->startEditorButton->setEnabled(false);
|
||||
ui->lobbyButton->setEnabled(false);
|
||||
ui->settingsButton->setEnabled(false);
|
||||
ui->modslistButton->setEnabled(false);
|
||||
ui->tabListWidget->setCurrentIndex(TabRows::SETUP);
|
||||
}
|
||||
|
||||
void MainWindow::exitSetup()
|
||||
{
|
||||
Settings writer = settings.write["launcher"]["setupCompleted"];
|
||||
writer->Bool() = true;
|
||||
|
||||
ui->startGameButton->setEnabled(true);
|
||||
ui->startEditorButton->setEnabled(true);
|
||||
ui->lobbyButton->setEnabled(true);
|
||||
ui->settingsButton->setEnabled(true);
|
||||
ui->modslistButton->setEnabled(true);
|
||||
ui->tabListWidget->setCurrentIndex(TabRows::MODS);
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *event)
|
||||
{
|
||||
if(event->type() == QEvent::LanguageChange)
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
void updateTranslation();
|
||||
void computeSidePanelSizes();
|
||||
|
||||
void enterSetup();
|
||||
void exitSetup();
|
||||
|
||||
public slots:
|
||||
void on_startGameButton_clicked();
|
||||
|
||||
|
@ -90,12 +90,14 @@ void CModListView::setupModsView()
|
||||
}
|
||||
|
||||
CModListView::CModListView(QWidget * parent)
|
||||
: QWidget(parent), settingsListener(settings.listen["launcher"]["repositoryURL"]), ui(new Ui::CModListView)
|
||||
: QWidget(parent)
|
||||
, settingsListener(settings.listen["launcher"]["repositoryURL"])
|
||||
, ui(new Ui::CModListView)
|
||||
, repositoriesChanged(false)
|
||||
{
|
||||
settingsListener([&](const JsonNode &){ repositoriesChanged = true; });
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
setupModModel();
|
||||
setupFilterModel();
|
||||
setupModsView();
|
||||
@ -835,7 +837,7 @@ bool CModListView::isModInstalled(const QString & modName)
|
||||
|
||||
QString CModListView::getTranslationModName(const QString & language)
|
||||
{
|
||||
for (auto const & modName : modModel->getModList())
|
||||
for(const auto & modName : modModel->getModList())
|
||||
{
|
||||
auto mod = modModel->getMod(modName);
|
||||
|
||||
|
@ -83,12 +83,13 @@ void CSettingsView::loadSettings()
|
||||
ui->spinBoxNetworkPort->setValue(settings["server"]["port"].Integer());
|
||||
|
||||
ui->comboBoxAutoCheck->setCurrentIndex(settings["launcher"]["autoCheckRepositories"].Bool());
|
||||
// all calls to plainText will trigger textChanged() signal overwriting config. Create backup before editing widget
|
||||
JsonNode urls = settings["launcher"]["repositoryURL"];
|
||||
|
||||
JsonNode urls = settings["launcher"]["repositoryURL"];
|
||||
ui->plainTextEditRepos->blockSignals(true); // Do not report loading as change of data
|
||||
ui->plainTextEditRepos->clear();
|
||||
for(auto entry : urls.Vector())
|
||||
ui->plainTextEditRepos->appendPlainText(QString::fromUtf8(entry.String().c_str()));
|
||||
ui->plainTextEditRepos->blockSignals(false);
|
||||
|
||||
ui->lineEditUserDataDir->setText(pathToQString(VCMIDirs::get().userDataPath()));
|
||||
ui->lineEditGameDir->setText(pathToQString(VCMIDirs::get().binaryPath()));
|
||||
|
Loading…
Reference in New Issue
Block a user