diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index db5b8941c..ca00e192b 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -166,12 +166,14 @@ void MainWindow::exitSetup() void MainWindow::switchToStartTab() { ui->startGameButton->setEnabled(true); + ui->startGameButton->setChecked(true); ui->tabListWidget->setCurrentIndex(TabRows::START); } void MainWindow::switchToModsTab() { ui->startGameButton->setEnabled(true); + ui->modslistButton->setChecked(true); ui->tabListWidget->setCurrentIndex(TabRows::MODS); } diff --git a/launcher/startGame/StartGameTab.cpp b/launcher/startGame/StartGameTab.cpp index 31d97c797..53055ae3a 100644 --- a/launcher/startGame/StartGameTab.cpp +++ b/launcher/startGame/StartGameTab.cpp @@ -4,11 +4,15 @@ #include "../mainwindow_moc.h" #include "../main.h" +#include "../../lib/filesystem/Filesystem.h" + StartGameTab::StartGameTab(QWidget * parent) : QWidget(parent) , ui(new Ui::StartGameTab) { ui->setupUi(this); + + refreshState(); } StartGameTab::~StartGameTab() @@ -24,9 +28,86 @@ MainWindow * StartGameTab::getMainWindow() return nullptr; } -void StartGameTab::on_buttonPlay_clicked() +void StartGameTab::refreshState() +{ + // 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) + // Provide diagnostics to indicate problem with chair-monitor adaptor layer and not with VCMI + static constexpr std::array potentiallyMissingFiles = { + "Data/TpThBkDg.bmp", + "Data/TpThBkFr.bmp", + "Data/TpThBkIn.bmp", + "Data/TpThBkNc.bmp", + "Data/TpThBkSt.bmp", + "Data/TpThBRrm.bmp", + "Data/TpThBkCs.bmp", + "Data/TpThBkRm.bmp", + "Data/TpThBkTw.bmp", + }; + + // Some players for some reason don't have AB expansion campaign files + static constexpr std::array armaggedonBladeCampaigns = { + "DATA/AB", + "DATA/BLOOD", + "DATA/SLAYER", + "DATA/FESTIVAL", + "DATA/FIRE", + "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; + bool missingCampaings = false; + + for (const auto & filename : potentiallyMissingFiles) + missingGameFiles &= !CResourceHandler::get()->existsResource(ImagePath::builtin(filename)); + + 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); + ui->labelMissingSoundtrack->setVisible(missingSoundtrack); + + ui->buttonMissingCampaignsHelp->setVisible(missingCampaings); + ui->buttonMissingFilesHelp->setVisible(missingGameFiles); + ui->buttonMissingVideoHelp->setVisible(missingVideoFiles); + ui->buttonMissingSoundtrackHelp->setVisible(missingSoundtrack); +} + +void StartGameTab::on_buttonGameStart_clicked() { getMainWindow()->hide(); startGame({}); } + +void StartGameTab::on_buttonOpenChangelog_clicked() +{ + QDesktopServices::openUrl(QUrl("https://vcmi.eu/ChangeLog/")); +} + + +void StartGameTab::on_buttonOpenDownloads_clicked() +{ + QDesktopServices::openUrl(QUrl("https://vcmi.eu/download/")); +} + + +void StartGameTab::on_buttonUpdateCheck_clicked() +{ + // TODO: implement +} + diff --git a/launcher/startGame/StartGameTab.h b/launcher/startGame/StartGameTab.h index 10ac0ce62..5c49599ef 100644 --- a/launcher/startGame/StartGameTab.h +++ b/launcher/startGame/StartGameTab.h @@ -15,12 +15,20 @@ class StartGameTab : public QWidget Q_OBJECT MainWindow * getMainWindow(); + + void refreshState(); public: explicit StartGameTab(QWidget * parent = nullptr); ~StartGameTab(); private slots: - void on_buttonPlay_clicked(); + void on_buttonGameStart_clicked(); + + void on_buttonOpenChangelog_clicked(); + + void on_buttonOpenDownloads_clicked(); + + void on_buttonUpdateCheck_clicked(); private: Ui::StartGameTab * ui;