Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move RSX capture to Utilities menu and add drag and drop confirmation dialogs #8082

Merged
merged 4 commits into from Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions rpcs3/Emu/RSX/RSXThread.cpp
Expand Up @@ -28,7 +28,7 @@ class GSRender;

#define CMD_DEBUG 0

std::atomic<bool> user_asked_for_frame_capture = false;
std::atomic<bool> g_user_asked_for_frame_capture = false;
rsx::frame_trace_data frame_debug;
rsx::frame_capture_data frame_capture;

Expand Down Expand Up @@ -309,7 +309,7 @@ namespace rsx

m_graphics_state = pipeline_state::all_dirty;

user_asked_for_frame_capture = false;
g_user_asked_for_frame_capture = false;

if (g_cfg.misc.use_native_interface && (g_cfg.video.renderer == video_renderer::opengl || g_cfg.video.renderer == video_renderer::vulkan))
{
Expand Down Expand Up @@ -2558,7 +2558,7 @@ namespace rsx
void thread::on_frame_end(u32 buffer, bool forced)
{
// Marks the end of a frame scope GPU-side
if (user_asked_for_frame_capture.exchange(false) && !capture_current_frame)
if (g_user_asked_for_frame_capture.exchange(false) && !capture_current_frame)
{
capture_current_frame = true;
frame_debug.reset();
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/RSXThread.h
Expand Up @@ -28,7 +28,7 @@
extern u64 get_guest_system_time();
extern u64 get_system_time();

extern std::atomic<bool> user_asked_for_frame_capture;
extern std::atomic<bool> g_user_asked_for_frame_capture;
extern rsx::frame_trace_data frame_debug;
extern rsx::frame_capture_data frame_capture;

Expand Down
10 changes: 0 additions & 10 deletions rpcs3/rpcs3qt/debugger_frame.cpp
Expand Up @@ -28,7 +28,6 @@
#include <atomic>

constexpr auto qstr = QString::fromStdString;
extern std::atomic<bool> user_asked_for_frame_capture;

debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *parent)
: custom_dock_widget(tr("Debugger"), parent), xgui_settings(settings)
Expand Down Expand Up @@ -69,7 +68,6 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *

m_go_to_addr = new QPushButton(tr("Go To Address"), this);
m_go_to_pc = new QPushButton(tr("Go To PC"), this);
m_btn_capture = new QPushButton(tr("RSX Capture"), this);
m_btn_step = new QPushButton(tr("Step"), this);
m_btn_step_over = new QPushButton(tr("Step Over"), this);
m_btn_run = new QPushButton(RunString, this);
Expand All @@ -80,7 +78,6 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *

hbox_b_main->addWidget(m_go_to_addr);
hbox_b_main->addWidget(m_go_to_pc);
hbox_b_main->addWidget(m_btn_capture);
hbox_b_main->addWidget(m_btn_step);
hbox_b_main->addWidget(m_btn_step_over);
hbox_b_main->addWidget(m_btn_run);
Expand Down Expand Up @@ -132,11 +129,6 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *
connect(m_go_to_addr, &QAbstractButton::clicked, this, &debugger_frame::ShowGotoAddressDialog);
connect(m_go_to_pc, &QAbstractButton::clicked, this, &debugger_frame::ShowPC);

connect(m_btn_capture, &QAbstractButton::clicked, [this]()
{
user_asked_for_frame_capture = true;
});

connect(m_btn_step, &QAbstractButton::clicked, this, &debugger_frame::DoStep);
connect(m_btn_step_over, &QAbstractButton::clicked, [this]() { DoStep(true); });

Expand Down Expand Up @@ -301,8 +293,6 @@ void debugger_frame::UpdateUI()
{
UpdateUnitList();

m_btn_capture->setEnabled(Emu.IsRunning() || Emu.IsPaused());

if (m_no_thread_selected) return;

const auto cpu = this->cpu.lock();
Expand Down
1 change: 0 additions & 1 deletion rpcs3/rpcs3qt/debugger_frame.h
Expand Up @@ -32,7 +32,6 @@ class debugger_frame : public custom_dock_widget
QTextEdit* m_regs;
QPushButton* m_go_to_addr;
QPushButton* m_go_to_pc;
QPushButton* m_btn_capture;
QPushButton* m_btn_step;
QPushButton* m_btn_step_over;
QPushButton* m_btn_run;
Expand Down
34 changes: 2 additions & 32 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Expand Up @@ -817,36 +817,6 @@ void game_list_frame::itemSelectionChangedSlot()
Q_EMIT NotifyGameSelection(game);
}

bool game_list_frame::GetBootConfirmation(const gui_save& gui_save_entry)
{
if (m_gui_settings && !Emu.IsStopped())
{
QString title = tr("Close Running Game?");
QString message = tr("Performing this action will close the current game.\nDo you really want to continue?\n\nAny unsaved progress will be lost!\n");

if (gui_save_entry == gui::ib_confirm_boot)
{
message = tr("Booting another game will close the current game.\nDo you really want to boot another game?\n\nAny unsaved progress will be lost!\n");
}
else if (gui_save_entry == gui::ib_confirm_exit)
{
title = tr("Exit RPCS3?");
message = tr("A game is currently running. Do you really want to close RPCS3?\n\nAny unsaved progress will be lost!\n");
}

int result = QMessageBox::Yes;

m_gui_settings->ShowConfirmationBox(title, message, gui_save_entry, &result, this);

if (result != QMessageBox::Yes)
{
return false;
}
}

return true;
}

void game_list_frame::ShowContextMenu(const QPoint &pos)
{
QPoint global_pos;
Expand Down Expand Up @@ -1071,7 +1041,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
});
connect(create_ppu_cache, &QAction::triggered, [gameinfo, this]
{
if (GetBootConfirmation())
if (m_gui_settings->GetBootConfirmation(this))
{
CreatePPUCache(gameinfo);
}
Expand Down Expand Up @@ -1431,7 +1401,7 @@ void game_list_frame::BatchCreatePPUCaches()
return;
}

if (!GetBootConfirmation())
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
Expand Down
2 changes: 0 additions & 2 deletions rpcs3/rpcs3qt/game_list_frame.h
Expand Up @@ -69,8 +69,6 @@ class game_list_frame : public custom_dock_widget

void SetShowHidden(bool show);

bool GetBootConfirmation(const gui_save& gui_save_entry = gui_save());

public Q_SLOTS:
void BatchCreatePPUCaches();
void BatchRemovePPUCaches();
Expand Down
32 changes: 32 additions & 0 deletions rpcs3/rpcs3qt/gui_settings.cpp
Expand Up @@ -3,6 +3,8 @@
#include "qt_utils.h"
#include "localized.h"

#include "Emu/System.h"

#include <QCheckBox>
#include <QCoreApplication>
#include <QMessageBox>
Expand Down Expand Up @@ -217,6 +219,36 @@ void gui_settings::ShowInfoBox(const QString& title, const QString& text, const
ShowBox(false, title, text, entry, nullptr, parent, false);
}

bool gui_settings::GetBootConfirmation(QWidget* parent, const gui_save& gui_save_entry)
{
if (!Emu.IsStopped())
{
QString title = tr("Close Running Game?");
QString message = tr("Performing this action will close the current game.\nDo you really want to continue?\n\nAny unsaved progress will be lost!\n");

if (gui_save_entry == gui::ib_confirm_boot)
{
message = tr("Booting another game will close the current game.\nDo you really want to boot another game?\n\nAny unsaved progress will be lost!\n");
}
else if (gui_save_entry == gui::ib_confirm_exit)
{
title = tr("Exit RPCS3?");
message = tr("A game is currently running. Do you really want to close RPCS3?\n\nAny unsaved progress will be lost!\n");
}

int result = QMessageBox::Yes;

ShowConfirmationBox(title, message, gui_save_entry, &result, parent);

if (result != QMessageBox::Yes)
{
return false;
}
}

return true;
}

void gui_settings::SetGamelistColVisibility(int col, bool val)
{
SetValue(GetGuiSaveForColumn(col), val);
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/gui_settings.h
Expand Up @@ -239,6 +239,7 @@ class gui_settings : public settings

void ShowConfirmationBox(const QString& title, const QString& text, const gui_save& entry, int* result, QWidget* parent);
void ShowInfoBox(const QString& title, const QString& text, const gui_save& entry, QWidget* parent);
bool GetBootConfirmation(QWidget* parent, const gui_save& gui_save_entry = gui_save());

logs::level GetLogLevel();
bool GetGamelistColVisibility(int col);
Expand Down
53 changes: 42 additions & 11 deletions rpcs3/rpcs3qt/main_window.cpp
Expand Up @@ -50,6 +50,8 @@

LOG_CHANNEL(gui_log, "GUI");

extern std::atomic<bool> g_user_asked_for_frame_capture;

inline std::string sstr(const QString& _in) { return _in.toStdString(); }

main_window::main_window(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent)
Expand Down Expand Up @@ -300,7 +302,7 @@ void main_window::show_boot_error(game_boot_result status)

void main_window::Boot(const std::string& path, const std::string& title_id, bool direct, bool add_only, bool force_global_config)
{
if (!m_game_list_frame->GetBootConfirmation(gui::ib_confirm_boot))
if (!m_gui_settings->GetBootConfirmation(this, gui::ib_confirm_boot))
{
return;
}
Expand Down Expand Up @@ -419,7 +421,7 @@ void main_window::BootRsxCapture(std::string path)
path = sstr(file_path);
}

if (!m_game_list_frame->GetBootConfirmation())
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
Expand Down Expand Up @@ -476,7 +478,7 @@ void main_window::HandlePackageInstallation(QStringList file_paths)
return;
}

if (!m_game_list_frame->GetBootConfirmation())
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
Expand Down Expand Up @@ -603,7 +605,7 @@ void main_window::HandlePupInstallation(QString file_path)
return;
}

if (!m_game_list_frame->GetBootConfirmation())
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
Expand Down Expand Up @@ -765,7 +767,7 @@ void main_window::DecryptSPRXLibraries()
return;
}

if (!m_game_list_frame->GetBootConfirmation())
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
Expand Down Expand Up @@ -1088,6 +1090,7 @@ void main_window::EnableMenus(bool enabled)
ui->toolsmemory_viewerAct->setEnabled(enabled);
ui->toolsRsxDebuggerAct->setEnabled(enabled);
ui->toolsStringSearchAct->setEnabled(enabled);
ui->actionCreate_RSX_Capture->setEnabled(enabled);
}

void main_window::BootRecentAction(const QAction* act)
Expand Down Expand Up @@ -1359,6 +1362,10 @@ void main_window::CreateConnects()
connect(ui->bootElfAct, &QAction::triggered, this, &main_window::BootElf);
connect(ui->bootGameAct, &QAction::triggered, this, &main_window::BootGame);
connect(ui->actionopen_rsx_capture, &QAction::triggered, [this](){ BootRsxCapture(); });
connect(ui->actionCreate_RSX_Capture, &QAction::triggered, []()
{
g_user_asked_for_frame_capture = true;
});

connect(ui->addGamesAct, &QAction::triggered, [this]()
{
Expand Down Expand Up @@ -2049,7 +2056,7 @@ void main_window::RemoveFirmwareCache()

void main_window::CreateFirmwareCache()
{
if (!m_game_list_frame->GetBootConfirmation())
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
Expand Down Expand Up @@ -2093,7 +2100,7 @@ void main_window::mouseDoubleClickEvent(QMouseEvent *event)
*/
void main_window::closeEvent(QCloseEvent* closeEvent)
{
if (!m_game_list_frame->GetBootConfirmation(gui::ib_confirm_exit))
if (!m_gui_settings->GetBootConfirmation(this, gui::ib_confirm_exit))
{
closeEvent->ignore();
return;
Expand Down Expand Up @@ -2148,9 +2155,9 @@ Check data for valid file types and cache their paths if necessary
@param savePaths = flag for path caching
@returns validity of file type
*/
int main_window::IsValidFile(const QMimeData& md, QStringList* drop_paths)
main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList* drop_paths)
{
int drop_type = drop_type::drop_error;
auto drop_type = drop_type::drop_error;

const QList<QUrl> list = md.urls(); // get list of all the dropped file urls

Expand Down Expand Up @@ -2229,8 +2236,11 @@ void main_window::dropEvent(QDropEvent* event)
switch (IsValidFile(*event->mimeData(), &drop_paths)) // get valid file paths and drop type
{
case drop_type::drop_error:
{
break;
}
case drop_type::drop_pkg: // install the packages
{
if (drop_paths.count() > 1)
{
pkg_install_dialog dlg(drop_paths, this);
Expand All @@ -2249,10 +2259,14 @@ void main_window::dropEvent(QDropEvent* event)
InstallPackages(drop_paths, true);
}
break;
}
case drop_type::drop_pup: // install the firmware
{
InstallPup(drop_paths.first());
break;
}
case drop_type::drop_rap: // import rap files to exdata dir
{
for (const auto& rap : drop_paths)
{
const std::string rapname = sstr(QFileInfo(rap).fileName());
Expand All @@ -2270,14 +2284,26 @@ void main_window::dropEvent(QDropEvent* event)
// Refresh game list since we probably unlocked some games now.
m_game_list_frame->Refresh(true);
break;
}
case drop_type::drop_dir: // import valid games to gamelist (games.yaml)
{
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
for (const auto& path : drop_paths)
{
AddGamesFromDir(path);
}
m_game_list_frame->Refresh(true);
break;
}
case drop_type::drop_game: // import valid games to gamelist (games.yaml)
{
if (!m_gui_settings->GetBootConfirmation(this))
{
return;
}
if (const auto error = Emu.BootGame(sstr(drop_paths.first()), "", true); error != game_boot_result::no_errors)
{
gui_log.error("Boot failed: reason: %s, path: %s", error, sstr(drop_paths.first()));
Expand All @@ -2289,26 +2315,31 @@ void main_window::dropEvent(QDropEvent* event)
m_game_list_frame->Refresh(true);
}
break;
}
case drop_type::drop_rrc: // replay a rsx capture file
{
BootRsxCapture(sstr(drop_paths.first()));
break;
}
default:
{
gui_log.warning("Invalid dropType in gamelist dropEvent");
break;
}
}
}

void main_window::dragEnterEvent(QDragEnterEvent* event)
{
if (IsValidFile(*event->mimeData()))
if (IsValidFile(*event->mimeData()) != drop_type::drop_error)
{
event->accept();
}
}

void main_window::dragMoveEvent(QDragMoveEvent* event)
{
if (IsValidFile(*event->mimeData()))
if (IsValidFile(*event->mimeData()) != drop_type::drop_error)
{
event->accept();
}
Expand Down