1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

Implemented some of Start Game tab functionality

This commit is contained in:
Ivan Savenko 2024-12-01 19:04:58 +00:00
parent d46eadab79
commit 4e83120882
3 changed files with 93 additions and 2 deletions

View File

@ -166,12 +166,14 @@ void MainWindow::exitSetup()
void MainWindow::switchToStartTab() void MainWindow::switchToStartTab()
{ {
ui->startGameButton->setEnabled(true); ui->startGameButton->setEnabled(true);
ui->startGameButton->setChecked(true);
ui->tabListWidget->setCurrentIndex(TabRows::START); ui->tabListWidget->setCurrentIndex(TabRows::START);
} }
void MainWindow::switchToModsTab() void MainWindow::switchToModsTab()
{ {
ui->startGameButton->setEnabled(true); ui->startGameButton->setEnabled(true);
ui->modslistButton->setChecked(true);
ui->tabListWidget->setCurrentIndex(TabRows::MODS); ui->tabListWidget->setCurrentIndex(TabRows::MODS);
} }

View File

@ -4,11 +4,15 @@
#include "../mainwindow_moc.h" #include "../mainwindow_moc.h"
#include "../main.h" #include "../main.h"
#include "../../lib/filesystem/Filesystem.h"
StartGameTab::StartGameTab(QWidget * parent) StartGameTab::StartGameTab(QWidget * parent)
: QWidget(parent) : QWidget(parent)
, ui(new Ui::StartGameTab) , ui(new Ui::StartGameTab)
{ {
ui->setupUi(this); ui->setupUi(this);
refreshState();
} }
StartGameTab::~StartGameTab() StartGameTab::~StartGameTab()
@ -24,9 +28,86 @@ MainWindow * StartGameTab::getMainWindow()
return nullptr; 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(); getMainWindow()->hide();
startGame({}); 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
}

View File

@ -15,12 +15,20 @@ class StartGameTab : public QWidget
Q_OBJECT Q_OBJECT
MainWindow * getMainWindow(); MainWindow * getMainWindow();
void refreshState();
public: public:
explicit StartGameTab(QWidget * parent = nullptr); explicit StartGameTab(QWidget * parent = nullptr);
~StartGameTab(); ~StartGameTab();
private slots: private slots:
void on_buttonPlay_clicked(); void on_buttonGameStart_clicked();
void on_buttonOpenChangelog_clicked();
void on_buttonOpenDownloads_clicked();
void on_buttonUpdateCheck_clicked();
private: private:
Ui::StartGameTab * ui; Ui::StartGameTab * ui;