Merge branch 'master' into feature/savestates-2

This commit is contained in:
Hamish Milne
2020-04-12 11:24:06 +01:00
76 changed files with 3507 additions and 1369 deletions

View File

@ -89,6 +89,10 @@
#include "citra_qt/discord_impl.h"
#endif
#ifdef ENABLE_FFMPEG_VIDEO_DUMPER
#include "citra_qt/dumping/dumping_dialog.h"
#endif
#ifdef QT_STATICPLUGIN
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#endif
@ -100,6 +104,8 @@ __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
}
#endif
constexpr int default_mouse_timeout = 2500;
/**
* "Callouts" are one-time instructional messages shown to the user. In the config settings, there
* is a bitfield "callout_flags" options, used to track if a message has already been shown to the
@ -193,6 +199,14 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
// Show one-time "callout" messages to the user
ShowTelemetryCallout();
// make sure menubar has the arrow cursor instead of inheriting from this
ui.menubar->setCursor(QCursor());
statusBar()->setCursor(QCursor());
mouse_hide_timer.setInterval(default_mouse_timeout);
connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
if (UISettings::values.check_for_update_on_start) {
CheckForUpdates();
}
@ -713,9 +727,7 @@ void GMainWindow::ConnectMenuEvents() {
connect(ui.action_Capture_Screenshot, &QAction::triggered, this,
&GMainWindow::OnCaptureScreenshot);
#ifndef ENABLE_FFMPEG_VIDEO_DUMPER
ui.action_Dump_Video->setEnabled(false);
#endif
#ifdef ENABLE_FFMPEG_VIDEO_DUMPER
connect(ui.action_Dump_Video, &QAction::triggered, [this] {
if (ui.action_Dump_Video->isChecked()) {
OnStartVideoDumping();
@ -723,6 +735,9 @@ void GMainWindow::ConnectMenuEvents() {
OnStopVideoDumping();
}
});
#else
ui.action_Dump_Video->setEnabled(false);
#endif
// Help
connect(ui.action_Open_Citra_Folder, &QAction::triggered, this,
@ -994,6 +1009,13 @@ void GMainWindow::BootGame(const QString& filename) {
}
status_bar_update_timer.start(2000);
if (UISettings::values.hide_mouse) {
mouse_hide_timer.start();
setMouseTracking(true);
ui.centralwidget->setMouseTracking(true);
ui.menubar->setMouseTracking(true);
}
// show and hide the render_window to create the context
render_window->show();
render_window->hide();
@ -1009,8 +1031,14 @@ void GMainWindow::BootGame(const QString& filename) {
if (video_dumping_on_start) {
Layout::FramebufferLayout layout{
Layout::FrameLayoutFromResolutionScale(VideoCore::GetResolutionScaleFactor())};
Core::System::GetInstance().VideoDumper().StartDumping(video_dumping_path.toStdString(),
"webm", layout);
if (!Core::System::GetInstance().VideoDumper().StartDumping(
video_dumping_path.toStdString(), layout)) {
QMessageBox::critical(
this, tr("Citra"),
tr("Could not start video dumping.<br>Refer to the log for details."));
ui.action_Dump_Video->setChecked(false);
}
video_dumping_on_start = false;
video_dumping_path.clear();
}
@ -1026,11 +1054,13 @@ void GMainWindow::ShutdownGame() {
HideFullscreen();
}
#ifdef ENABLE_FFMPEG_VIDEO_DUMPER
if (Core::System::GetInstance().VideoDumper().IsDumping()) {
game_shutdown_delayed = true;
OnStopVideoDumping();
return;
}
#endif
AllowOSSleep();
@ -1084,6 +1114,10 @@ void GMainWindow::ShutdownGame() {
game_list->show();
game_list->setFilterFocus();
setMouseTracking(false);
ui.centralwidget->setMouseTracking(false);
ui.menubar->setMouseTracking(false);
// Disable status bar updates
status_bar_update_timer.stop();
message_label->setVisible(false);
@ -1290,7 +1324,7 @@ void GMainWindow::OnGameListDumpRomFS(QString game_path, u64 program_id) {
using FutureWatcher = QFutureWatcher<std::pair<Loader::ResultStatus, Loader::ResultStatus>>;
auto* future_watcher = new FutureWatcher(this);
connect(future_watcher, &FutureWatcher::finished,
[this, program_id, dialog, base_path, update_path, future_watcher] {
[this, dialog, base_path, update_path, future_watcher] {
dialog->hide();
const auto& [base, update] = future_watcher->result();
if (base != Loader::ResultStatus::Success) {
@ -1676,6 +1710,16 @@ void GMainWindow::OnConfigure() {
SyncMenuUISettings();
game_list->RefreshGameDirectory();
config->Save();
if (UISettings::values.hide_mouse && emulation_running) {
setMouseTracking(true);
ui.centralwidget->setMouseTracking(true);
ui.menubar->setMouseTracking(true);
mouse_hide_timer.start();
} else {
setMouseTracking(false);
ui.centralwidget->setMouseTracking(false);
ui.menubar->setMouseTracking(false);
}
} else {
Settings::values.input_profiles = old_input_profiles;
Settings::LoadProfile(old_input_profile_index);
@ -1915,18 +1959,23 @@ void GMainWindow::OnCaptureScreenshot() {
OnStartGame();
}
#ifdef ENABLE_FFMPEG_VIDEO_DUMPER
void GMainWindow::OnStartVideoDumping() {
const QString path = QFileDialog::getSaveFileName(
this, tr("Save Video"), UISettings::values.video_dumping_path, tr("WebM Videos (*.webm)"));
if (path.isEmpty()) {
DumpingDialog dialog(this);
if (dialog.exec() != QDialog::DialogCode::Accepted) {
ui.action_Dump_Video->setChecked(false);
return;
}
UISettings::values.video_dumping_path = QFileInfo(path).path();
const auto path = dialog.GetFilePath();
if (emulation_running) {
Layout::FramebufferLayout layout{
Layout::FrameLayoutFromResolutionScale(VideoCore::GetResolutionScaleFactor())};
Core::System::GetInstance().VideoDumper().StartDumping(path.toStdString(), "webm", layout);
if (!Core::System::GetInstance().VideoDumper().StartDumping(path.toStdString(), layout)) {
QMessageBox::critical(
this, tr("Citra"),
tr("Could not start video dumping.<br>Refer to the log for details."));
ui.action_Dump_Video->setChecked(false);
}
} else {
video_dumping_on_start = true;
video_dumping_path = path;
@ -1943,6 +1992,8 @@ void GMainWindow::OnStopVideoDumping() {
const bool was_dumping = Core::System::GetInstance().VideoDumper().IsDumping();
if (!was_dumping)
return;
game_paused_for_dumping = emu_thread->IsRunning();
OnPauseGame();
auto future =
@ -1952,13 +2003,15 @@ void GMainWindow::OnStopVideoDumping() {
if (game_shutdown_delayed) {
game_shutdown_delayed = false;
ShutdownGame();
} else {
} else if (game_paused_for_dumping) {
game_paused_for_dumping = false;
OnStartGame();
}
});
future_watcher->setFuture(future);
}
}
#endif
void GMainWindow::UpdateStatusBar() {
if (emu_thread == nullptr) {
@ -1983,6 +2036,30 @@ void GMainWindow::UpdateStatusBar() {
emu_frametime_label->setVisible(true);
}
void GMainWindow::HideMouseCursor() {
if (emu_thread == nullptr || UISettings::values.hide_mouse == false) {
mouse_hide_timer.stop();
ShowMouseCursor();
return;
}
setCursor(QCursor(Qt::BlankCursor));
}
void GMainWindow::ShowMouseCursor() {
unsetCursor();
if (emu_thread != nullptr && UISettings::values.hide_mouse) {
mouse_hide_timer.start();
}
}
void GMainWindow::mouseMoveEvent(QMouseEvent* event) {
ShowMouseCursor();
}
void GMainWindow::mousePressEvent(QMouseEvent* event) {
ShowMouseCursor();
}
void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) {
QString status_message;