From c75ae6c585f651a1b7c162c2e1ecccd22a1c587d Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 19 Feb 2017 14:34:47 -0800 Subject: Add performance statistics to status bar --- src/citra_qt/main.cpp | 27 +++++++++++++++++++++++++++ src/citra_qt/main.h | 3 +++ 2 files changed, 30 insertions(+) (limited to 'src/citra_qt') diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 43530b275..41356a6ca 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -253,6 +253,8 @@ void GMainWindow::ConnectWidgetEvents() { connect(this, SIGNAL(EmulationStarting(EmuThread*)), render_window, SLOT(OnEmulationStarting(EmuThread*))); connect(this, SIGNAL(EmulationStopping()), render_window, SLOT(OnEmulationStopping())); + + connect(&status_bar_update_timer, &QTimer::timeout, this, &GMainWindow::UpdateStatusBar); } void GMainWindow::ConnectMenuEvents() { @@ -401,6 +403,8 @@ void GMainWindow::BootGame(const QString& filename) { if (ui.action_Single_Window_Mode->isChecked()) { game_list->hide(); } + status_bar_update_timer.start(1000); + render_window->show(); render_window->setFocus(); @@ -435,6 +439,12 @@ void GMainWindow::ShutdownGame() { render_window->hide(); game_list->show(); + // Disable status bar updates + status_bar_update_timer.stop(); + emu_speed_label->setVisible(false); + game_fps_label->setVisible(false); + emu_frametime_label->setVisible(false); + emulation_running = false; } @@ -614,6 +624,23 @@ void GMainWindow::OnCreateGraphicsSurfaceViewer() { graphicsSurfaceViewerWidget->show(); } +void GMainWindow::UpdateStatusBar() { + if (emu_thread == nullptr) { + status_bar_update_timer.stop(); + return; + } + + auto results = Core::System::GetInstance().GetAndResetPerfStats(); + + emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 2)); + game_fps_label->setText(tr("Game: %1 FPS").arg(results.game_fps, 0, 'f', 1)); + emu_frametime_label->setText(tr("Frame: %1 ms").arg(results.frametime * 1000.0, 0, 'f', 2)); + + emu_speed_label->setVisible(true); + game_fps_label->setVisible(true); + emu_frametime_label->setVisible(true); +} + bool GMainWindow::ConfirmClose() { if (emu_thread == nullptr || !UISettings::values.confirm_before_closing) return true; diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 3cbf4ea99..ec841eaa5 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -127,6 +127,8 @@ private slots: void OnCreateGraphicsSurfaceViewer(); private: + void UpdateStatusBar(); + Ui::MainWindow ui; GRenderWindow* render_window; @@ -136,6 +138,7 @@ private: QLabel* emu_speed_label = nullptr; QLabel* game_fps_label = nullptr; QLabel* emu_frametime_label = nullptr; + QTimer status_bar_update_timer; std::unique_ptr config; -- cgit v1.2.3