From ef56b7dcc72fc3e0de8e45c20d84442d65564eb1 Mon Sep 17 00:00:00 2001 From: RedTrainer97 Date: Thu, 30 Mar 2017 16:26:29 +0200 Subject: [PATCH] Added 3DS controls in main window. --- src/citra_qt/config.cpp | 2 + src/citra_qt/configure_audio.cpp | 3 - src/citra_qt/configure_audio.ui | 27 ------ src/citra_qt/main.cpp | 52 ++++++++++- src/citra_qt/main.h | 7 ++ src/citra_qt/main.ui | 152 ++++++++++++++++++++++++++++++- src/citra_qt/ui_settings.h | 1 + 7 files changed, 211 insertions(+), 33 deletions(-) diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index b9ec351fc..b9b411c88 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -168,6 +168,7 @@ void Config::ReadValues() { qt_config->endGroup(); UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); + UISettings::values.show_3DS_controls = qt_config->value("show3dsControls", true).toBool(); UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool(); UISettings::values.confirm_before_closing = qt_config->value("confirmClose", true).toBool(); @@ -278,6 +279,7 @@ void Config::SaveValues() { qt_config->endGroup(); qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); + qt_config->setValue("show3dsControls", UISettings::values.single_window_mode); qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); qt_config->setValue("showStatusBar", UISettings::values.show_status_bar); qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing); diff --git a/src/citra_qt/configure_audio.cpp b/src/citra_qt/configure_audio.cpp index 0247cac1d..3ddcf9232 100644 --- a/src/citra_qt/configure_audio.cpp +++ b/src/citra_qt/configure_audio.cpp @@ -51,7 +51,6 @@ void ConfigureAudio::setConfiguration() { } } ui->audio_device_combo_box->setCurrentIndex(new_device_index); - ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum()); } void ConfigureAudio::applyConfiguration() { @@ -62,8 +61,6 @@ void ConfigureAudio::applyConfiguration() { Settings::values.audio_device_id = ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) .toStdString(); - Settings::values.volume = (float)ui->volume_slider->value() / ui->volume_slider->maximum(); - Settings::Apply(); } diff --git a/src/citra_qt/configure_audio.ui b/src/citra_qt/configure_audio.ui index 301282ee7..dd870eb61 100644 --- a/src/citra_qt/configure_audio.ui +++ b/src/citra_qt/configure_audio.ui @@ -46,33 +46,6 @@ - - - - - - - - - - Volume: - - - - - - - 1023 - - - 1 - - - 0 - - - Qt::Horizontal - diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 2723a0217..1124686b7 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -69,6 +69,8 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { ConnectMenuEvents(); ConnectWidgetEvents(); + ui.centralwidget->setStyleSheet("background-color: white;"); + setWindowTitle(QString("Citra %1| %2-%3") .arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); show(); @@ -79,6 +81,10 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { if (args.length() >= 2) { BootGame(args[1]); } + + volume_slider = ui.centralwidget->findChild("volume_slider"); + volume_slider->setValue(Settings::values.volume * volume_slider->maximum()); + connect(volume_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateVolume())); } GMainWindow::~GMainWindow() { @@ -93,6 +99,15 @@ void GMainWindow::InitializeWidgets() { render_window = new GRenderWindow(this, emu_thread.get()); render_window->hide(); + left_widget = ui.centralwidget->findChild("left_widget"); + left_widget->hide(); + + central_widget = ui.centralwidget->findChild("central_widget"); + central_widget->hide(); + + right_widget = ui.centralwidget->findChild("right_widget"); + right_widget->hide(); + game_list = new GameList(); ui.horizontalLayout->addWidget(game_list); @@ -243,6 +258,8 @@ void GMainWindow::RestoreUIState() { ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode); ToggleWindowMode(); + ui.action_Show_3DS_Controls->setChecked(UISettings::values.show_3DS_controls); + ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar); OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); @@ -280,6 +297,8 @@ void GMainWindow::ConnectMenuEvents() { // View connect(ui.action_Single_Window_Mode, &QAction::triggered, this, &GMainWindow::ToggleWindowMode); + connect(ui.action_Show_3DS_Controls, &QAction::triggered, this, + &GMainWindow::Toggle3dsControls); connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this, &GMainWindow::OnDisplayTitleBars); connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); @@ -412,6 +431,11 @@ void GMainWindow::BootGame(const QString& filename) { render_window->show(); render_window->setFocus(); + central_widget->show(); + if (ui.action_Show_3DS_Controls->isChecked()) { + left_widget->show(); + right_widget->show(); + } emulation_running = true; OnStartGame(); @@ -442,6 +466,9 @@ void GMainWindow::ShutdownGame() { ui.action_Pause->setEnabled(false); ui.action_Stop->setEnabled(false); render_window->hide(); + left_widget->hide(); + central_widget->hide(); + right_widget->hide(); game_list->show(); // Disable status bar updates @@ -586,7 +613,7 @@ void GMainWindow::ToggleWindowMode() { if (ui.action_Single_Window_Mode->isChecked()) { // Render in the main window... render_window->BackupGeometry(); - ui.horizontalLayout->addWidget(render_window); + ui.centralwidget->findChild("central_widget")->layout()->addWidget(render_window); render_window->setFocusPolicy(Qt::ClickFocus); if (emulation_running) { render_window->setVisible(true); @@ -596,7 +623,9 @@ void GMainWindow::ToggleWindowMode() { } else { // Render in a separate window... - ui.horizontalLayout->removeWidget(render_window); + ui.centralwidget->findChild("central_widget") + ->layout() + ->removeWidget(render_window); render_window->setParent(nullptr); render_window->setFocusPolicy(Qt::NoFocus); if (emulation_running) { @@ -607,6 +636,18 @@ void GMainWindow::ToggleWindowMode() { } } +void GMainWindow::Toggle3dsControls() { + if (ui.action_Show_3DS_Controls->isChecked()) { + if (emulation_running) { + left_widget->show(); + right_widget->show(); + } + } else { + left_widget->hide(); + right_widget->hide(); + } +} + void GMainWindow::OnConfigure() { ConfigureDialog configureDialog(this); auto result = configureDialog.exec(); @@ -669,6 +710,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) { UISettings::values.microprofile_visible = microProfileDialog->isVisible(); #endif UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); + UISettings::values.show_3DS_controls = ui.action_Show_3DS_Controls->isChecked(); UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked(); UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked(); UISettings::values.first_start = false; @@ -681,6 +723,8 @@ void GMainWindow::closeEvent(QCloseEvent* event) { ShutdownGame(); render_window->close(); + left_widget->close(); + right_widget->close(); QWidget::closeEvent(event); } @@ -719,6 +763,10 @@ bool GMainWindow::ConfirmChangeGame() { return answer != QMessageBox::No; } +void GMainWindow::UpdateVolume() { + Settings::values.volume = (float)volume_slider->value() / volume_slider->maximum(); +} + #ifdef main #undef main #endif diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index ec841eaa5..b48981f74 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -125,6 +125,8 @@ private slots: void OnDisplayTitleBars(bool); void ToggleWindowMode(); void OnCreateGraphicsSurfaceViewer(); + void Toggle3dsControls(); + void UpdateVolume(); private: void UpdateStatusBar(); @@ -133,6 +135,9 @@ private: GRenderWindow* render_window; GameList* game_list; + QWidget* left_widget; + QWidget* central_widget; + QWidget* right_widget; // Status bar elements QLabel* emu_speed_label = nullptr; @@ -161,6 +166,8 @@ private: QAction* actions_recent_files[max_recent_files_item]; + QSlider* volume_slider; + protected: void dropEvent(QDropEvent* event) override; void dragEnterEvent(QDragEnterEvent* event) override; diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index 47dbb6ef7..61cc790ca 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui @@ -37,6 +37,146 @@ 0 + + + + + 0 + 0 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Volume + + + Qt::AlignCenter + + + + + + + 1023 + + + 16 + + + Qt::Vertical + + + + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + 0 + 0 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + false + + + WiFi + + + + + + + 3D + + + Qt::AlignCenter + + + + + + + false + + + 1023 + + + 16 + + + Qt::Vertical + + + + + + @@ -45,7 +185,7 @@ 0 0 1081 - 19 + 21 @@ -88,6 +228,7 @@ + @@ -188,6 +329,15 @@ Create Pica Surface Viewer + + + true + + + Show 3DS Controls + + + diff --git a/src/citra_qt/ui_settings.h b/src/citra_qt/ui_settings.h index 6408ece2b..ec9d61716 100644 --- a/src/citra_qt/ui_settings.h +++ b/src/citra_qt/ui_settings.h @@ -26,6 +26,7 @@ struct Values { bool microprofile_visible; bool single_window_mode; + bool show_3DS_controls; bool display_titlebar; bool show_status_bar;