diff --git a/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp b/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp index 7b7a032d8a..78f2952ffd 100644 --- a/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp +++ b/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog_native.cpp @@ -17,7 +17,7 @@ namespace rsx type.disable_cancel = true; type.progress_bar_count = 2; - dlg = g_fxo->get().create(!!g_cfg.video.shader_preloading_dialog.use_custom_background); + dlg = g_fxo->get().create(true); dlg->progress_bar_set_taskbar_index(-1); dlg->show(false, msg, type, [](s32 status) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index 1885d99040..88bc964f63 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -923,12 +923,18 @@ namespace rsx external_ref = nullptr; } - void set_raw_image(image_info *raw_image) + void set_raw_image(image_info* raw_image) { image_resource_ref = image_resource_id::raw_image; external_ref = raw_image; } + void clear_image() + { + image_resource_ref = image_resource_id::none; + external_ref = nullptr; + } + void set_blur_strength(u8 strength) { blur_strength = strength; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp index cc990c4bed..64b85b3b1b 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp @@ -12,7 +12,8 @@ namespace rsx { namespace overlays { - message_dialog::message_dialog(bool use_custom_background) + message_dialog::message_dialog(bool allow_custom_background) + : custom_background_allowed(allow_custom_background) { background.set_size(1280, 720); background.back_color.a = 0.85f; @@ -54,42 +55,7 @@ namespace rsx btn_cancel.set_image_resource(resource_config::standard_image_resource::circle); } - if (use_custom_background) - { - const auto picture_path = Emu.GetBackgroundPicturePath(); - - if (fs::exists(picture_path)) - { - background_image = std::make_unique(picture_path.c_str()); - - if (background_image->data) - { - const f32 color = (100 - g_cfg.video.shader_preloading_dialog.darkening_strength) / 100.f; - background_poster.fore_color = color4f(color, color, color, 1.); - background.back_color.a = 0.f; - - background_poster.set_size(1280, 720); - background_poster.set_raw_image(background_image.get()); - background_poster.set_blur_strength(static_cast(g_cfg.video.shader_preloading_dialog.blur_strength)); - - ensure(background_image->w > 0); - ensure(background_image->h > 0); - ensure(background_poster.h > 0); - - // Set padding in order to keep the aspect ratio - if ((background_image->w / static_cast(background_image->h)) > (background_poster.w / static_cast(background_poster.h))) - { - const int padding = (background_poster.h - static_cast(background_image->h * (background_poster.w / static_cast(background_image->w)))) / 2; - background_poster.set_padding(0, 0, padding, padding); - } - else - { - const int padding = (background_poster.w - static_cast(background_image->w * (background_poster.h / static_cast(background_image->h)))) / 2; - background_poster.set_padding(padding, padding, 0, 0); - } - } - } - } + update_custom_background(); return_code = CELL_MSGDIALOG_BUTTON_NONE; } @@ -103,6 +69,8 @@ namespace rsx compiled_resource result; + update_custom_background(); + if (background_image && background_image->data) { result.add(background_poster.get_compiled()); @@ -321,6 +289,60 @@ namespace rsx text_display.translate(0, -(text_h - 16)); } + void message_dialog::update_custom_background() + { + if (custom_background_allowed && g_cfg.video.shader_preloading_dialog.use_custom_background) + { + bool dirty = std::exchange(background_blur_strength, g_cfg.video.shader_preloading_dialog.blur_strength.get()); + dirty |= std::exchange(background_darkening_strength, g_cfg.video.shader_preloading_dialog.darkening_strength.get()); + + if (!background_image) + { + if (const auto picture_path = Emu.GetBackgroundPicturePath(); fs::exists(picture_path)) + { + background_image = std::make_unique(picture_path.c_str()); + dirty |= !!background_image->data; + } + } + + if (dirty && background_image && background_image->data) + { + const f32 color = (100 - background_darkening_strength) / 100.f; + background_poster.fore_color = color4f(color, color, color, 1.); + background.back_color.a = 0.f; + + background_poster.set_size(1280, 720); + background_poster.set_raw_image(background_image.get()); + background_poster.set_blur_strength(static_cast(background_blur_strength)); + + ensure(background_image->w > 0); + ensure(background_image->h > 0); + ensure(background_poster.h > 0); + + // Set padding in order to keep the aspect ratio + if ((background_image->w / static_cast(background_image->h)) > (background_poster.w / static_cast(background_poster.h))) + { + const int padding = (background_poster.h - static_cast(background_image->h * (background_poster.w / static_cast(background_image->w)))) / 2; + background_poster.set_padding(0, 0, padding, padding); + } + else + { + const int padding = (background_poster.w - static_cast(background_image->w * (background_poster.h / static_cast(background_image->h)))) / 2; + background_poster.set_padding(padding, padding, 0, 0); + } + } + } + else + { + if (background_image) + { + background_poster.clear_image(); + background_image.reset(); + } + background.back_color.a = 0.85f; + } + } + u32 message_dialog::progress_bar_count() const { return num_progress_bars; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h index 9bccea4751..1824a25c26 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.h @@ -24,10 +24,13 @@ namespace rsx bool ok_only = false; bool cancel_only = false; + bool custom_background_allowed = false; + u32 background_blur_strength = 0; + u32 background_darkening_strength = 0; std::unique_ptr background_image; public: - message_dialog(bool use_custom_background = false); + message_dialog(bool allow_custom_background = false); compiled_resource get_compiled() override; @@ -37,6 +40,7 @@ namespace rsx error_code show(bool is_blocking, const std::string& text, const MsgDialogType& type, std::function on_close); void set_text(const std::string& text); + void update_custom_background(); u32 progress_bar_count() const; void progress_bar_set_taskbar_index(s32 index); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 2b7f1c2057..5ce23a6af0 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -381,7 +381,7 @@ namespace type.disable_cancel = true; type.progress_bar_count = 1; - native_dlg = manager->create(!!g_cfg.video.shader_preloading_dialog.use_custom_background); + native_dlg = manager->create(true); native_dlg->show(false, text0, type, nullptr); native_dlg->progress_bar_set_message(0, "Please wait"); } diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index a407cdb9a1..407bcf3e64 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -207,8 +207,8 @@ struct cfg_root : cfg::node node_shader_preloading_dialog(cfg::node* _this) : cfg::node(_this, "Shader Loading Dialog") {} cfg::_bool use_custom_background{ this, "Allow custom background", true, true }; - cfg::_int<0, 100> darkening_strength{ this, "Darkening effect strength", 30, true }; - cfg::_int<0, 100> blur_strength{ this, "Blur effect strength", 0, true }; + cfg::uint<0, 100> darkening_strength{ this, "Darkening effect strength", 30, true }; + cfg::uint<0, 100> blur_strength{ this, "Blur effect strength", 0, true }; } shader_preloading_dialog{ this };