Merge pull request #379 from ElBread3/dbc-game

qt_gui: Added double-click game icon to start game
This commit is contained in:
georgemoralis 2024-08-08 21:51:17 +03:00 committed by GitHub
commit 81be8f270f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 26 deletions

View File

@ -179,32 +179,11 @@ void MainWindow::CreateConnects() {
} }
}); });
connect(ui->playButton, &QPushButton::clicked, this, [this]() { connect(ui->playButton, &QPushButton::clicked, this, &MainWindow::StartGame);
QString gamePath = ""; connect(m_game_grid_frame.get(), &QTableWidget::cellDoubleClicked, this,
int table_mode = Config::getTableMode(); &MainWindow::StartGame);
if (table_mode == 0) { connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this,
if (m_game_list_frame->currentItem()) { &MainWindow::StartGame);
int itemID = m_game_list_frame->currentItem()->row();
gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin");
}
} else if (table_mode == 1) {
if (m_game_grid_frame->cellClicked) {
int itemID = (m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt) +
m_game_grid_frame->crtColumn;
gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin");
}
} else {
if (m_elf_viewer->currentItem()) {
int itemID = m_elf_viewer->currentItem()->row();
gamePath = QString::fromStdString(m_elf_viewer->m_elf_list[itemID].toStdString());
}
}
if (gamePath != "") {
AddRecentFiles(gamePath);
Core::Emulator emulator;
emulator.Run(gamePath.toUtf8().constData());
}
});
connect(ui->setIconSizeTinyAct, &QAction::triggered, this, [this]() { connect(ui->setIconSizeTinyAct, &QAction::triggered, this, [this]() {
if (isTableList) { if (isTableList) {
@ -386,6 +365,33 @@ void MainWindow::CreateConnects() {
}); });
} }
void MainWindow::StartGame() {
QString gamePath = "";
int table_mode = Config::getTableMode();
if (table_mode == 0) {
if (m_game_list_frame->currentItem()) {
int itemID = m_game_list_frame->currentItem()->row();
gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin");
}
} else if (table_mode == 1) {
if (m_game_grid_frame->cellClicked) {
int itemID = (m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt) +
m_game_grid_frame->crtColumn;
gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin");
}
} else {
if (m_elf_viewer->currentItem()) {
int itemID = m_elf_viewer->currentItem()->row();
gamePath = QString::fromStdString(m_elf_viewer->m_elf_list[itemID].toStdString());
}
}
if (gamePath != "") {
AddRecentFiles(gamePath);
Core::Emulator emulator;
emulator.Run(gamePath.toUtf8().constData());
}
}
void MainWindow::SearchGameTable(const QString& text) { void MainWindow::SearchGameTable(const QString& text) {
if (isTableList) { if (isTableList) {
for (int row = 0; row < m_game_list_frame->rowCount(); row++) { for (int row = 0; row < m_game_list_frame->rowCount(); row++) {

View File

@ -39,6 +39,7 @@ public:
bool Init(); bool Init();
void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg); void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg);
void InstallDirectory(); void InstallDirectory();
void StartGame();
private Q_SLOTS: private Q_SLOTS:
void ConfigureGuiFromSettings(); void ConfigureGuiFromSettings();