|
@@ -4,7 +4,10 @@
|
|
|
#include "../mainwindow_moc.h"
|
|
|
#include "../main.h"
|
|
|
|
|
|
+#include "../modManager/cmodlistview_moc.h"
|
|
|
+
|
|
|
#include "../../lib/filesystem/Filesystem.h"
|
|
|
+#include "../../lib/VCMIDirs.h"
|
|
|
|
|
|
StartGameTab::StartGameTab(QWidget * parent)
|
|
|
: QWidget(parent)
|
|
@@ -13,6 +16,8 @@ StartGameTab::StartGameTab(QWidget * parent)
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
refreshState();
|
|
|
+
|
|
|
+ ui->buttonGameResume->setVisible(false); // TODO: implement
|
|
|
}
|
|
|
|
|
|
StartGameTab::~StartGameTab()
|
|
@@ -29,6 +34,14 @@ MainWindow * StartGameTab::getMainWindow()
|
|
|
}
|
|
|
|
|
|
void StartGameTab::refreshState()
|
|
|
+{
|
|
|
+ refreshGameData();
|
|
|
+ refreshUpdateStatus(EGameUpdateStatus::NOT_CHECKED);//TODO
|
|
|
+ refreshTranslation(ETranslationStatus::ACTIVE);
|
|
|
+ refreshMods();
|
|
|
+}
|
|
|
+
|
|
|
+void StartGameTab::refreshGameData()
|
|
|
{
|
|
|
// Some players are using pirated version of the game with some of the files missing
|
|
|
// leading to broken town hall menu (and possibly other dialogs)
|
|
@@ -55,9 +68,6 @@ void StartGameTab::refreshState()
|
|
|
"DATA/FOOL",
|
|
|
};
|
|
|
|
|
|
- bool updateAvailable = false;
|
|
|
- bool checkedForUpdate = false;
|
|
|
-
|
|
|
bool missingSoundtrack = !CResourceHandler::get()->existsResource(AudioPath::builtin("Music/MainMenu"));
|
|
|
bool missingVideoFiles = !CResourceHandler::get()->existsResource(VideoPath::builtin("Video/H3Intro"));
|
|
|
bool missingGameFiles = false;
|
|
@@ -69,13 +79,6 @@ void StartGameTab::refreshState()
|
|
|
for (const auto & filename : armaggedonBladeCampaigns)
|
|
|
missingCampaings &= !CResourceHandler::get()->existsResource(ResourcePath(filename, EResType::CAMPAIGN));
|
|
|
|
|
|
- ui->buttonEngine->setText("VCMI " VCMI_VERSION_STRING);
|
|
|
- ui->buttonUpdateCheck->setVisible(!checkedForUpdate);
|
|
|
- ui->labelUpdateAvailable->setVisible(checkedForUpdate && updateAvailable);
|
|
|
- ui->labelUpdateNotFound->setVisible(checkedForUpdate && !updateAvailable);
|
|
|
- ui->buttonOpenChangelog->setVisible(checkedForUpdate && updateAvailable);
|
|
|
- ui->buttonOpenDownloads->setVisible(checkedForUpdate && updateAvailable);
|
|
|
-
|
|
|
ui->labelMissingCampaigns->setVisible(missingCampaings);
|
|
|
ui->labelMissingFiles->setVisible(missingGameFiles);
|
|
|
ui->labelMissingVideo->setVisible(missingVideoFiles);
|
|
@@ -85,6 +88,35 @@ void StartGameTab::refreshState()
|
|
|
ui->buttonMissingFilesHelp->setVisible(missingGameFiles);
|
|
|
ui->buttonMissingVideoHelp->setVisible(missingVideoFiles);
|
|
|
ui->buttonMissingSoundtrackHelp->setVisible(missingSoundtrack);
|
|
|
+
|
|
|
+ // TODO: Chronicles
|
|
|
+}
|
|
|
+
|
|
|
+void StartGameTab::refreshTranslation(ETranslationStatus status)
|
|
|
+{
|
|
|
+ ui->buttonInstallTranslation->setVisible(status == ETranslationStatus::NOT_INSTALLLED);
|
|
|
+ ui->buttonInstallTranslationHelp->setVisible(status == ETranslationStatus::NOT_INSTALLLED);
|
|
|
+
|
|
|
+ ui->buttonActivateTranslation->setVisible(status == ETranslationStatus::NOT_INSTALLLED);
|
|
|
+ ui->buttonActivateTranslationHelp->setVisible(status == ETranslationStatus::NOT_INSTALLLED);
|
|
|
+}
|
|
|
+
|
|
|
+void StartGameTab::refreshMods()
|
|
|
+{
|
|
|
+ QStringList updateableMods;
|
|
|
+
|
|
|
+ ui->buttonUpdateMods->setVisible(!updateableMods.empty());
|
|
|
+ ui->buttonUpdateModsHelp->setVisible(!updateableMods.empty());
|
|
|
+}
|
|
|
+
|
|
|
+void StartGameTab::refreshUpdateStatus(EGameUpdateStatus status)
|
|
|
+{
|
|
|
+ ui->buttonEngine->setText("VCMI " VCMI_VERSION_STRING);
|
|
|
+ ui->buttonUpdateCheck->setVisible(status == EGameUpdateStatus::NOT_CHECKED);
|
|
|
+ ui->labelUpdateNotFound->setVisible(status == EGameUpdateStatus::NO_UPDATE);
|
|
|
+ ui->labelUpdateAvailable->setVisible(status == EGameUpdateStatus::UPDATE_AVAILABLE);
|
|
|
+ ui->buttonOpenChangelog->setVisible(status == EGameUpdateStatus::UPDATE_AVAILABLE);
|
|
|
+ ui->buttonOpenDownloads->setVisible(status == EGameUpdateStatus::UPDATE_AVAILABLE);
|
|
|
}
|
|
|
|
|
|
void StartGameTab::on_buttonGameStart_clicked()
|
|
@@ -93,7 +125,6 @@ void StartGameTab::on_buttonGameStart_clicked()
|
|
|
startGame({});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void StartGameTab::on_buttonOpenChangelog_clicked()
|
|
|
{
|
|
|
QDesktopServices::openUrl(QUrl("https://vcmi.eu/ChangeLog/"));
|
|
@@ -111,3 +142,40 @@ void StartGameTab::on_buttonUpdateCheck_clicked()
|
|
|
// TODO: implement
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+void StartGameTab::on_buttonGameEditor_clicked()
|
|
|
+{
|
|
|
+ getMainWindow()->hide();
|
|
|
+ startEditor({});
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void StartGameTab::on_buttonImportFiles_clicked()
|
|
|
+{
|
|
|
+ const auto & importFunctor = [this]
|
|
|
+ {
|
|
|
+#ifndef VCMI_MOBILE
|
|
|
+ QString filter =
|
|
|
+ tr("All supported files") + " (*.h3m *.vmap *.h3c *.vcmp *.zip *.json *.exe);;" +
|
|
|
+ tr("Maps") + " (*.h3m *.vmap);;" +
|
|
|
+ tr("Campaigns") + " (*.h3c *.vcmp);;" +
|
|
|
+ tr("Configs") + " (*.json);;" +
|
|
|
+ tr("Mods") + " (*.zip);;" +
|
|
|
+ tr("Gog files") + " (*.exe)";
|
|
|
+#else
|
|
|
+ //Workaround for sometimes incorrect mime for some extensions (e.g. for exe)
|
|
|
+ QString filter = tr("All files (*.*)");
|
|
|
+#endif
|
|
|
+ QStringList files = QFileDialog::getOpenFileNames(this, tr("Select files (configs, mods, maps, campaigns, gog files) to install..."), QDir::homePath(), filter);
|
|
|
+
|
|
|
+ for(const auto & file : files)
|
|
|
+ getMainWindow()->manualInstallFile(file);
|
|
|
+ };
|
|
|
+
|
|
|
+ // iOS can't display modal dialogs when called directly on button press
|
|
|
+ // https://bugreports.qt.io/browse/QTBUG-98651
|
|
|
+ QTimer::singleShot(0, this, importFunctor);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|