|
12 | 12 |
|
13 | 13 | #include "./bitwise.hpp" |
14 | 14 | #include "./icons.hpp" |
| 15 | +#include "./log.hpp" |
15 | 16 | #include "./mutex.hpp" |
16 | 17 |
|
17 | 18 | namespace renodx::utils::settings { |
@@ -364,23 +365,6 @@ static void WriteGlobalString(const std::string& key, const std::string& value) |
364 | 365 | // Runs first |
365 | 366 | // https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html |
366 | 367 | static void OnRegisterOverlay(reshade::api::effect_runtime* runtime) { |
367 | | - // Load last selected profile from reshade.ini (section [renodx], key SelectedProfile). |
368 | | - // If the key is present, apply that preset on startup. |
369 | | - { |
370 | | - int stored_profile = preset_index; |
371 | | - if (reshade::get_config_value(nullptr, global_name.c_str(), "SelectedProfile", stored_profile)) { |
372 | | - if (stored_profile < 0) { |
373 | | - stored_profile = 0; |
374 | | - } else if (stored_profile >= static_cast<int>(preset_strings.size())) { |
375 | | - stored_profile = static_cast<int>(preset_strings.size() - 1); |
376 | | - } |
377 | | - preset_index = stored_profile; |
378 | | - if (preset_index != 0) { |
379 | | - LoadSettings(GetCurrentPresetName()); |
380 | | - } |
381 | | - } |
382 | | - } |
383 | | - |
384 | 368 | bool changed_preset = false; |
385 | 369 | bool has_drawn_presets = !use_presets; |
386 | 370 |
|
@@ -675,7 +659,43 @@ static void Use(DWORD fdw_reason, Settings* new_settings, void (*new_on_preset_o |
675 | 659 | on_preset_off_callbacks.emplace_back(new_on_preset_off); |
676 | 660 | } |
677 | 661 | LoadGlobalSettings(); |
678 | | - LoadSettings(global_name + "-preset1"); |
| 662 | + |
| 663 | + if (use_presets) { |
| 664 | + // Decide which preset to apply on startup |
| 665 | + int stored_profile = preset_index; |
| 666 | + const bool has_stored = reshade::get_config_value(nullptr, global_name.c_str(), "SelectedProfile", stored_profile); |
| 667 | + |
| 668 | + if (!has_stored) { |
| 669 | + // No stored profile -> default to preset 1 |
| 670 | + preset_index = 1; |
| 671 | + renodx::utils::log::d("utils::settings::Use(No SelectedProfile -> Defaulting to ", GetCurrentPresetName(), ")"); |
| 672 | + LoadSettings(GetCurrentPresetName()); |
| 673 | + } else { |
| 674 | + // Clamp stored value to valid range |
| 675 | + if (stored_profile < 0) { |
| 676 | + stored_profile = 0; |
| 677 | + } else if (stored_profile >= static_cast<int>(preset_strings.size())) { |
| 678 | + stored_profile = static_cast<int>(preset_strings.size() - 1); |
| 679 | + } |
| 680 | + preset_index = stored_profile; |
| 681 | + |
| 682 | + if (preset_index == 0) { |
| 683 | + renodx::utils::log::d("utils::settings::Use(SelectedProfile=", preset_index, " -> Applying Off)"); |
| 684 | + for (auto& callback : on_preset_off_callbacks) { |
| 685 | + callback(); |
| 686 | + } |
| 687 | + } else { |
| 688 | + // Load the named preset section |
| 689 | + renodx::utils::log::d("utils::settings::Use(SelectedProfile=", preset_index, " -> Loading ", GetCurrentPresetName(), ")"); |
| 690 | + LoadSettings(GetCurrentPresetName()); |
| 691 | + } |
| 692 | + } |
| 693 | + } else { |
| 694 | + // Presets disabled — keep previous behavior (load preset1 by default) |
| 695 | + preset_index = 1; |
| 696 | + LoadSettings(global_name + "-preset1"); |
| 697 | + } |
| 698 | + |
679 | 699 | reshade::register_overlay(overlay_title.c_str(), OnRegisterOverlay); |
680 | 700 |
|
681 | 701 | break; |
|
0 commit comments