citra_qt, video_core: Screenshot functionality

Allows capturing screenshot at the current internal resolution (native for software renderer), but a setting is available to capture it in other resolutions. The screenshot is saved to a single PNG in the current layout.
This commit is contained in:
zhupengfei 2018-08-31 14:16:16 +08:00 committed by zhupengfei
parent 7e90abec78
commit 071b41cb61
No known key found for this signature in database
GPG key ID: DD129E108BD09378
14 changed files with 202 additions and 14 deletions

View file

@ -365,6 +365,7 @@ void GMainWindow::InitializeHotkeys() {
Qt::ApplicationShortcut);
hotkey_registry.RegisterHotkey("Main Window", "Remove Amiibo", QKeySequence(Qt::Key_F3),
Qt::ApplicationShortcut);
hotkey_registry.RegisterHotkey("Main Window", "Capture Screenshot", QKeySequence(tr("CTRL+P")));
hotkey_registry.LoadHotkeys();
@ -439,6 +440,12 @@ void GMainWindow::InitializeHotkeys() {
OnRemoveAmiibo();
}
});
connect(hotkey_registry.GetHotkey("Main Window", "Capture Screenshot", this),
&QShortcut::activated, this, [&] {
if (emu_thread->IsRunning()) {
OnCaptureScreenshot();
}
});
}
void GMainWindow::ShowUpdaterWidgets() {
@ -588,6 +595,8 @@ void GMainWindow::ConnectMenuEvents() {
Core::System::GetInstance().frame_limiter.AdvanceFrame();
}
});
connect(ui.action_Capture_Screenshot, &QAction::triggered, this,
&GMainWindow::OnCaptureScreenshot);
// Help
connect(ui.action_Open_Citra_Folder, &QAction::triggered, this,
@ -882,6 +891,7 @@ void GMainWindow::ShutdownGame() {
ui.action_Enable_Frame_Advancing->setEnabled(false);
ui.action_Enable_Frame_Advancing->setChecked(false);
ui.action_Advance_Frame->setEnabled(false);
ui.action_Capture_Screenshot->setEnabled(false);
render_window->hide();
if (game_list->isEmpty())
game_list_placeholder->show();
@ -1169,6 +1179,7 @@ void GMainWindow::OnStartGame() {
ui.action_Load_Amiibo->setEnabled(true);
ui.action_Report_Compatibility->setEnabled(true);
ui.action_Enable_Frame_Advancing->setEnabled(true);
ui.action_Capture_Screenshot->setEnabled(true);
discord_rpc->Update();
}
@ -1179,6 +1190,7 @@ void GMainWindow::OnPauseGame() {
ui.action_Start->setEnabled(true);
ui.action_Pause->setEnabled(false);
ui.action_Stop->setEnabled(true);
ui.action_Capture_Screenshot->setEnabled(false);
}
void GMainWindow::OnStopGame() {
@ -1539,6 +1551,18 @@ void GMainWindow::OnStopRecordingPlayback() {
ui.action_Stop_Recording_Playback->setEnabled(false);
}
void GMainWindow::OnCaptureScreenshot() {
OnPauseGame();
const QString path =
QFileDialog::getSaveFileName(this, tr("Capture Screenshot"),
UISettings::values.screenshot_path, tr("PNG Image (*.png)"));
if (!path.isEmpty()) {
UISettings::values.screenshot_path = QFileInfo(path).path();
render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, path);
}
OnStartGame();
}
void GMainWindow::UpdateStatusBar() {
if (emu_thread == nullptr) {
status_bar_update_timer.stop();