Added 3DS controls in main window.

This commit is contained in:
RedTrainer97 2017-03-30 16:26:29 +02:00
parent d78c87e3db
commit ef56b7dcc7
7 changed files with 211 additions and 33 deletions

View File

@ -168,6 +168,7 @@ void Config::ReadValues() {
qt_config->endGroup(); qt_config->endGroup();
UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); 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.display_titlebar = qt_config->value("displayTitleBars", true).toBool();
UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool(); UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool();
UISettings::values.confirm_before_closing = qt_config->value("confirmClose", 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->endGroup();
qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); 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("displayTitleBars", UISettings::values.display_titlebar);
qt_config->setValue("showStatusBar", UISettings::values.show_status_bar); qt_config->setValue("showStatusBar", UISettings::values.show_status_bar);
qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing); qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing);

View File

@ -51,7 +51,6 @@ void ConfigureAudio::setConfiguration() {
} }
} }
ui->audio_device_combo_box->setCurrentIndex(new_device_index); ui->audio_device_combo_box->setCurrentIndex(new_device_index);
ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum());
} }
void ConfigureAudio::applyConfiguration() { void ConfigureAudio::applyConfiguration() {
@ -62,8 +61,6 @@ void ConfigureAudio::applyConfiguration() {
Settings::values.audio_device_id = Settings::values.audio_device_id =
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
.toStdString(); .toStdString();
Settings::values.volume = (float)ui->volume_slider->value() / ui->volume_slider->maximum();
Settings::Apply(); Settings::Apply();
} }

View File

@ -46,33 +46,6 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="audio_device_combo_box"> <widget class="QComboBox" name="audio_device_combo_box">
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Volume:</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="volume_slider">
<property name="maximum">
<number>1023</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -69,6 +69,8 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
ConnectMenuEvents(); ConnectMenuEvents();
ConnectWidgetEvents(); ConnectWidgetEvents();
ui.centralwidget->setStyleSheet("background-color: white;");
setWindowTitle(QString("Citra %1| %2-%3") setWindowTitle(QString("Citra %1| %2-%3")
.arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); .arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc));
show(); show();
@ -79,6 +81,10 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
if (args.length() >= 2) { if (args.length() >= 2) {
BootGame(args[1]); BootGame(args[1]);
} }
volume_slider = ui.centralwidget->findChild<QSlider*>("volume_slider");
volume_slider->setValue(Settings::values.volume * volume_slider->maximum());
connect(volume_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateVolume()));
} }
GMainWindow::~GMainWindow() { GMainWindow::~GMainWindow() {
@ -93,6 +99,15 @@ void GMainWindow::InitializeWidgets() {
render_window = new GRenderWindow(this, emu_thread.get()); render_window = new GRenderWindow(this, emu_thread.get());
render_window->hide(); render_window->hide();
left_widget = ui.centralwidget->findChild<QWidget*>("left_widget");
left_widget->hide();
central_widget = ui.centralwidget->findChild<QWidget*>("central_widget");
central_widget->hide();
right_widget = ui.centralwidget->findChild<QWidget*>("right_widget");
right_widget->hide();
game_list = new GameList(); game_list = new GameList();
ui.horizontalLayout->addWidget(game_list); ui.horizontalLayout->addWidget(game_list);
@ -243,6 +258,8 @@ void GMainWindow::RestoreUIState() {
ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode); ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode);
ToggleWindowMode(); ToggleWindowMode();
ui.action_Show_3DS_Controls->setChecked(UISettings::values.show_3DS_controls);
ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar); ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar);
OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked());
@ -280,6 +297,8 @@ void GMainWindow::ConnectMenuEvents() {
// View // View
connect(ui.action_Single_Window_Mode, &QAction::triggered, this, connect(ui.action_Single_Window_Mode, &QAction::triggered, this,
&GMainWindow::ToggleWindowMode); &GMainWindow::ToggleWindowMode);
connect(ui.action_Show_3DS_Controls, &QAction::triggered, this,
&GMainWindow::Toggle3dsControls);
connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this, connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this,
&GMainWindow::OnDisplayTitleBars); &GMainWindow::OnDisplayTitleBars);
connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); 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->show();
render_window->setFocus(); render_window->setFocus();
central_widget->show();
if (ui.action_Show_3DS_Controls->isChecked()) {
left_widget->show();
right_widget->show();
}
emulation_running = true; emulation_running = true;
OnStartGame(); OnStartGame();
@ -442,6 +466,9 @@ void GMainWindow::ShutdownGame() {
ui.action_Pause->setEnabled(false); ui.action_Pause->setEnabled(false);
ui.action_Stop->setEnabled(false); ui.action_Stop->setEnabled(false);
render_window->hide(); render_window->hide();
left_widget->hide();
central_widget->hide();
right_widget->hide();
game_list->show(); game_list->show();
// Disable status bar updates // Disable status bar updates
@ -586,7 +613,7 @@ void GMainWindow::ToggleWindowMode() {
if (ui.action_Single_Window_Mode->isChecked()) { if (ui.action_Single_Window_Mode->isChecked()) {
// Render in the main window... // Render in the main window...
render_window->BackupGeometry(); render_window->BackupGeometry();
ui.horizontalLayout->addWidget(render_window); ui.centralwidget->findChild<QWidget*>("central_widget")->layout()->addWidget(render_window);
render_window->setFocusPolicy(Qt::ClickFocus); render_window->setFocusPolicy(Qt::ClickFocus);
if (emulation_running) { if (emulation_running) {
render_window->setVisible(true); render_window->setVisible(true);
@ -596,7 +623,9 @@ void GMainWindow::ToggleWindowMode() {
} else { } else {
// Render in a separate window... // Render in a separate window...
ui.horizontalLayout->removeWidget(render_window); ui.centralwidget->findChild<QWidget*>("central_widget")
->layout()
->removeWidget(render_window);
render_window->setParent(nullptr); render_window->setParent(nullptr);
render_window->setFocusPolicy(Qt::NoFocus); render_window->setFocusPolicy(Qt::NoFocus);
if (emulation_running) { 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() { void GMainWindow::OnConfigure() {
ConfigureDialog configureDialog(this); ConfigureDialog configureDialog(this);
auto result = configureDialog.exec(); auto result = configureDialog.exec();
@ -669,6 +710,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
UISettings::values.microprofile_visible = microProfileDialog->isVisible(); UISettings::values.microprofile_visible = microProfileDialog->isVisible();
#endif #endif
UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); 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.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked();
UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked(); UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked();
UISettings::values.first_start = false; UISettings::values.first_start = false;
@ -681,6 +723,8 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
ShutdownGame(); ShutdownGame();
render_window->close(); render_window->close();
left_widget->close();
right_widget->close();
QWidget::closeEvent(event); QWidget::closeEvent(event);
} }
@ -719,6 +763,10 @@ bool GMainWindow::ConfirmChangeGame() {
return answer != QMessageBox::No; return answer != QMessageBox::No;
} }
void GMainWindow::UpdateVolume() {
Settings::values.volume = (float)volume_slider->value() / volume_slider->maximum();
}
#ifdef main #ifdef main
#undef main #undef main
#endif #endif

View File

@ -125,6 +125,8 @@ private slots:
void OnDisplayTitleBars(bool); void OnDisplayTitleBars(bool);
void ToggleWindowMode(); void ToggleWindowMode();
void OnCreateGraphicsSurfaceViewer(); void OnCreateGraphicsSurfaceViewer();
void Toggle3dsControls();
void UpdateVolume();
private: private:
void UpdateStatusBar(); void UpdateStatusBar();
@ -133,6 +135,9 @@ private:
GRenderWindow* render_window; GRenderWindow* render_window;
GameList* game_list; GameList* game_list;
QWidget* left_widget;
QWidget* central_widget;
QWidget* right_widget;
// Status bar elements // Status bar elements
QLabel* emu_speed_label = nullptr; QLabel* emu_speed_label = nullptr;
@ -161,6 +166,8 @@ private:
QAction* actions_recent_files[max_recent_files_item]; QAction* actions_recent_files[max_recent_files_item];
QSlider* volume_slider;
protected: protected:
void dropEvent(QDropEvent* event) override; void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override; void dragEnterEvent(QDragEnterEvent* event) override;

View File

@ -37,6 +37,146 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="QWidget" name="left_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Volume</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QSlider" name="volume_slider">
<property name="maximum">
<number>1023</number>
</property>
<property name="pageStep">
<number>16</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="central_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="right_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="wifi_check_box">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>WiFi</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>3D</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QSlider" name="three_d_slider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>1023</number>
</property>
<property name="pageStep">
<number>16</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
@ -45,7 +185,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1081</width> <width>1081</width>
<height>19</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menu_File"> <widget class="QMenu" name="menu_File">
@ -88,6 +228,7 @@
</widget> </widget>
<addaction name="action_Single_Window_Mode"/> <addaction name="action_Single_Window_Mode"/>
<addaction name="action_Display_Dock_Widget_Headers"/> <addaction name="action_Display_Dock_Widget_Headers"/>
<addaction name="action_Show_3DS_Controls"/>
<addaction name="action_Show_Status_Bar"/> <addaction name="action_Show_Status_Bar"/>
<addaction name="menu_View_Debugging"/> <addaction name="menu_View_Debugging"/>
</widget> </widget>
@ -188,6 +329,15 @@
<string>Create Pica Surface Viewer</string> <string>Create Pica Surface Viewer</string>
</property> </property>
</action> </action>
<action name="action_Show_3DS_Controls">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show 3DS Controls</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/>
</ui> </ui>

View File

@ -26,6 +26,7 @@ struct Values {
bool microprofile_visible; bool microprofile_visible;
bool single_window_mode; bool single_window_mode;
bool show_3DS_controls;
bool display_titlebar; bool display_titlebar;
bool show_status_bar; bool show_status_bar;