Skip to content

Commit

Permalink
Qt: Display "Reoot With Custom/Global config" on running game
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jan 30, 2020
1 parent c9e3592 commit dc674b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rpcs3/Emu/Audio/XAudio2/XAudio2Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void XAudio2Backend::Pause()

void XAudio2Backend::Open(u32 /* num_buffers */)
{
if (lib.get() == nullptr)
if (!lib)
{
void* hmodule;

Expand Down
27 changes: 17 additions & 10 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ void game_list_frame::doubleClickedSlot(QTableWidgetItem *item)
game = GetGameInfoFromItem(item);
}

if (game.get() == nullptr)
if (!game)
{
return;
}
Expand All @@ -865,7 +865,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
}

game_info gameinfo = GetGameInfoFromItem(item);
if (gameinfo.get() == nullptr)
if (!gameinfo)
{
return;
}
Expand All @@ -879,12 +879,16 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)

// Make Actions
QMenu myMenu;
QAction* boot = new QAction(gameinfo->hasCustomConfig ? tr("&Boot with global configuration") : tr("&Boot"));

const bool is_current_running_game = (Emu.IsRunning() || Emu.IsPaused()) && currGame.serial == Emu.GetTitleID();

QAction* boot = new QAction(gameinfo->hasCustomConfig ? tr(is_current_running_game ? "&Reboot with global configuartion" : "&Boot with global configuration") : tr("&Boot"));
QFont f = boot->font();
f.setBold(true);

if (gameinfo->hasCustomConfig)
{
QAction* boot_custom = myMenu.addAction(tr("&Boot with custom configuration"));
QAction* boot_custom = myMenu.addAction(tr(is_current_running_game ? "&Reboot with custom configuartion" : "&Boot with custom configuration"));
boot_custom->setFont(f);
connect(boot_custom, &QAction::triggered, [=]
{
Expand All @@ -896,8 +900,16 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
{
boot->setFont(f);
}

myMenu.addAction(boot);
myMenu.addSeparator();

connect(boot, &QAction::triggered, [=]
{
LOG_NOTICE(LOADER, "Booting from gamelist per context menu...");
Q_EMIT RequestBoot(gameinfo, gameinfo->hasCustomConfig);
});

QAction* configure = myMenu.addAction(gameinfo->hasCustomConfig ? tr("&Change Custom Configuration") : tr("&Create Custom Configuration"));
QAction* pad_configure = myMenu.addAction(gameinfo->hasCustomPadConfig ? tr("&Change Custom Gamepad Configuration") : tr("&Create Custom Gamepad Configuration"));
QAction* createPPUCache = myMenu.addAction(tr("&Create PPU Cache"));
Expand Down Expand Up @@ -996,11 +1008,6 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
QAction* copy_name = info_menu->addAction(tr("&Copy Name"));
QAction* copy_serial = info_menu->addAction(tr("&Copy Serial"));

connect(boot, &QAction::triggered, [=]
{
LOG_NOTICE(LOADER, "Booting from gamelist per context menu...");
Q_EMIT RequestBoot(gameinfo, gameinfo->hasCustomConfig);
});
connect(configure, &QAction::triggered, [=]
{
settings_dialog dlg(m_gui_settings, m_emu_settings, 0, this, &currGame);
Expand Down Expand Up @@ -1852,7 +1859,7 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event)

game_info gameinfo = GetGameInfoFromItem(item);

if (gameinfo.get() == nullptr)
if (!gameinfo)
return false;

LOG_NOTICE(LOADER, "Booting from gamelist by pressing %s...", keyEvent->key() == Qt::Key_Enter ? "Enter" : "Return");
Expand Down

0 comments on commit dc674b6

Please sign in to comment.