diff --git a/rpcs3/rpcs3_app.cpp b/rpcs3/rpcs3_app.cpp index 61729186db..a3c2849a5a 100644 --- a/rpcs3/rpcs3_app.cpp +++ b/rpcs3/rpcs3_app.cpp @@ -1,7 +1,6 @@ #include "rpcs3_app.h" #include "rpcs3qt/welcome_dialog.h" -#include "rpcs3qt/gui_settings.h" #include "Emu/System.h" #include "rpcs3qt/gs_frame.h" @@ -56,8 +55,10 @@ void rpcs3_app::Init() { Emu.Init(); + guiSettings.reset(new gui_settings()); + // Create the main window - RPCS3MainWin = new main_window(nullptr); + RPCS3MainWin = new main_window(guiSettings, nullptr); // Reset the pads -- see the method for why this is currently needed. ResetPads(); @@ -76,9 +77,7 @@ void rpcs3_app::Init() // Create the thumbnail toolbar after the main_window is created RPCS3MainWin->CreateThumbnailToolbar(); - // Slightly inneficient to make a gui_settings instance right here. - // But, I don't really feel like adding this as a dependency injection into RPCS3MainWin. - if (gui_settings().GetValue(GUI::ib_show_welcome).toBool()) + if (guiSettings->GetValue(GUI::ib_show_welcome).toBool()) { welcome_dialog* welcome = new welcome_dialog(); welcome->exec(); @@ -148,14 +147,22 @@ void rpcs3_app::InitializeCallbacks() extern const std::unordered_map, value_hash> g_video_out_resolution_map; const auto size = g_video_out_resolution_map.at(g_cfg.video.resolution); + int w = size.first; + int h = size.second; + + if (guiSettings->GetValue(GUI::gs_resize).toBool()) + { + w = guiSettings->GetValue(GUI::gs_width).toInt(); + h = guiSettings->GetValue(GUI::gs_height).toInt(); + } switch (video_renderer type = g_cfg.video.renderer) { - case video_renderer::null: return std::make_unique("Null", size.first, size.second, RPCS3MainWin->GetAppIcon()); - case video_renderer::opengl: return std::make_unique(size.first, size.second, RPCS3MainWin->GetAppIcon()); - case video_renderer::vulkan: return std::make_unique("Vulkan", size.first, size.second, RPCS3MainWin->GetAppIcon()); + case video_renderer::null: return std::make_unique("Null", w, h, RPCS3MainWin->GetAppIcon()); + case video_renderer::opengl: return std::make_unique(w, h, RPCS3MainWin->GetAppIcon()); + case video_renderer::vulkan: return std::make_unique("Vulkan", w, h, RPCS3MainWin->GetAppIcon()); #ifdef _MSC_VER - case video_renderer::dx12: return std::make_unique("DirectX 12", size.first, size.second, RPCS3MainWin->GetAppIcon()); + case video_renderer::dx12: return std::make_unique("DirectX 12", w, h, RPCS3MainWin->GetAppIcon()); #endif default: fmt::throw_exception("Invalid video renderer: %s" HERE, type); } diff --git a/rpcs3/rpcs3_app.h b/rpcs3/rpcs3_app.h index 1864c27e03..430aebe756 100644 --- a/rpcs3/rpcs3_app.h +++ b/rpcs3/rpcs3_app.h @@ -15,6 +15,7 @@ #include "rpcs3qt/msg_dialog_frame.h" #include "rpcs3qt/main_window.h" +#include "rpcs3qt/gui_settings.h" #include @@ -51,4 +52,6 @@ private: std::shared_ptr m_basicMouseHandler; main_window* RPCS3MainWin; + + std::shared_ptr guiSettings; }; diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index e63f50b5b6..e0e5eebdcf 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -52,6 +52,7 @@ namespace GUI const QString logger = "Logger"; const QString meta = "Meta"; const QString fs = "FileSystem"; + const QString gs_frame = "GSFrame"; const QColor mw_tool_bar_color = QColor(227, 227, 227, 255); const QColor mw_tool_icon_color = QColor(64, 64, 64, 255); @@ -113,6 +114,10 @@ namespace GUI const GUI_SAVE m_currentConfig = GUI_SAVE(meta, "currentConfig", QObject::tr("CurrentSettings")); const GUI_SAVE m_currentStylesheet = GUI_SAVE(meta, "currentStylesheet", QObject::tr("default")); + + const GUI_SAVE gs_resize = GUI_SAVE(gs_frame, "resize", false); + const GUI_SAVE gs_width = GUI_SAVE(gs_frame, "width", 1280); + const GUI_SAVE gs_height = GUI_SAVE(gs_frame, "height", 720); } /** Class for GUI settings.. diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 0ccf5ec464..0abc52043e 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -46,7 +46,7 @@ inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); } -main_window::main_window(QWidget *parent) : QMainWindow(parent), m_sys_menu_opened(false), ui(new Ui::main_window) +main_window::main_window(std::shared_ptr guiSettings, QWidget *parent) : QMainWindow(parent), guiSettings(guiSettings), m_sys_menu_opened(false), ui(new Ui::main_window) { } @@ -69,8 +69,6 @@ void main_window::Init() { ui->setupUi(this); - guiSettings.reset(new gui_settings()); - // Load Icons: This needs to happen before any actions or buttons are created RepaintToolBarIcons(); appIcon = QIcon(":/rpcs3.ico"); diff --git a/rpcs3/rpcs3qt/main_window.h b/rpcs3/rpcs3qt/main_window.h index 52ed1e7727..f1e95c0a06 100644 --- a/rpcs3/rpcs3qt/main_window.h +++ b/rpcs3/rpcs3qt/main_window.h @@ -56,7 +56,7 @@ class main_window : public QMainWindow #endif public: - explicit main_window(QWidget *parent = 0); + explicit main_window(std::shared_ptr guiSettings, QWidget *parent = 0); void Init(); ~main_window(); void CreateThumbnailToolbar(); diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index c96c8c4d7e..4732147cb7 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -8,6 +8,9 @@ #include #include #include +#include +#include +#include #include "settings_dialog.h" @@ -733,6 +736,37 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const addColoredIcon(ui->pb_gl_tool_icon_color, xgui_settings->GetValue(GUI::gl_toolIconColor).value(), QIcon(":/Icons/home_blue.png"), GUI::gl_tool_icon_color); addColoredIcon(ui->pb_tool_icon_color, xgui_settings->GetValue(GUI::mw_toolIconColor).value(), QIcon(":/Icons/stop.png"), GUI::mw_tool_icon_color); + bool enableButtons = xgui_settings->GetValue(GUI::gs_resize).toBool(); + ui->gs_resizeOnBoot->setChecked(enableButtons); + ui->gs_width->setEnabled(enableButtons); + ui->gs_height->setEnabled(enableButtons); + + QRect rec = QApplication::desktop()->screenGeometry(); + int width = xgui_settings->GetValue(GUI::gs_width).toInt(); + int height = xgui_settings->GetValue(GUI::gs_height).toInt(); + const int max_width = rec.width(); + const int max_height = rec.height(); + ui->gs_width->setValue(width < max_width ? width : max_width); + ui->gs_height->setValue(height < max_height ? height : max_height); + + connect(ui->gs_resizeOnBoot, &QCheckBox::clicked, [=](bool val) { + xgui_settings->SetValue(GUI::gs_resize, val); + ui->gs_width->setEnabled(val); + ui->gs_height->setEnabled(val); + }); + connect(ui->gs_width, static_cast(&QSpinBox::valueChanged), [=](int w) { + int width = QApplication::desktop()->screenGeometry().width(); + w = w > width ? width : w; + ui->gs_width->setValue(w); + xgui_settings->SetValue(GUI::gs_width, w); + }); + connect(ui->gs_height, static_cast(&QSpinBox::valueChanged), [=](int h) { + int height = QApplication::desktop()->screenGeometry().height(); + h = h > height ? height : h; + ui->gs_height->setValue(h); + xgui_settings->SetValue(GUI::gs_height, h); + }); + AddConfigs(); AddStylesheets(); } diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 558b07b074..fb878295b5 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -1147,7 +1147,89 @@ - + + + Viewport + + + + + + Resize game window on boot + + + + + + + + + Width + + + + + + true + + + QAbstractSpinBox::CorrectToNearestValue + + + false + + + 0 + + + 9999 + + + 0 + + + + + + + + + + Heigth + + + + + + true + + + true + + + QAbstractSpinBox::CorrectToNearestValue + + + false + + + 0 + + + 9999 + + + 0 + + + + + + + + + +