diff --git a/include/Overlay.hpp b/include/Overlay.hpp index e39765b..a353e39 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -108,6 +108,7 @@ namespace gsr { void on_event(mgl::Event &event); void recreate_global_hotkeys(const char *hotkey_option); + void update_led_indicator_after_settings_change(); void create_frontpage_ui_components(); void xi_setup(); void handle_xi_events(); diff --git a/include/gui/ScreenshotSettingsPage.hpp b/include/gui/ScreenshotSettingsPage.hpp index 57fe5ef..e5209e8 100644 --- a/include/gui/ScreenshotSettingsPage.hpp +++ b/include/gui/ScreenshotSettingsPage.hpp @@ -23,6 +23,8 @@ namespace gsr { void load(); void save(); void on_navigate_away_from_page() override; + + std::function on_config_changed; private: std::unique_ptr create_record_area_box(); std::unique_ptr create_record_area(); diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 383c3ba..622f5f5 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -525,8 +525,7 @@ namespace gsr { } } - // TODO: Only do this if led indicator is enabled (at startup or when changing recording/screenshot settings to enabled it) - led_indicator = std::make_unique(); + update_led_indicator_after_settings_change(); } Overlay::~Overlay() { @@ -1179,6 +1178,15 @@ namespace gsr { global_hotkeys.reset(); } + void Overlay::update_led_indicator_after_settings_change() { + if(config.record_config.record_options.use_led_indicator || config.replay_config.record_options.use_led_indicator || config.streaming_config.record_options.use_led_indicator || config.screenshot_config.use_led_indicator) { + if(!led_indicator) + led_indicator = std::make_unique(); + } else { + led_indicator.reset(); + } + } + void Overlay::create_frontpage_ui_components() { bg_screenshot_overlay = mgl::Rectangle(mgl::vec2f(get_theme().window_width, get_theme().window_height)); top_bar_background = mgl::Rectangle(mgl::vec2f(get_theme().window_width, get_theme().window_height*0.06f).floor()); @@ -1269,6 +1277,8 @@ namespace gsr { record_settings_page->on_config_changed = [this]() { if(recording_status == RecordingStatus::RECORD) show_notification("Recording settings have been modified.\nYou may need to restart recording to apply the changes.", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD); + + update_led_indicator_after_settings_change(); }; page_stack.push(std::move(record_settings_page)); } else if(id == "pause") { @@ -1294,6 +1304,8 @@ namespace gsr { stream_settings_page->on_config_changed = [this]() { if(recording_status == RecordingStatus::STREAM) show_notification("Streaming settings have been modified.\nYou may need to restart streaming to apply the changes.", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM); + + update_led_indicator_after_settings_change(); }; page_stack.push(std::move(stream_settings_page)); } else if(id == "start") { @@ -1376,6 +1388,9 @@ namespace gsr { button->set_icon_padding_scale(1.2f); button->on_click = [&]() { auto screenshot_settings_page = std::make_unique(&gsr_info, config, &page_stack); + screenshot_settings_page->on_config_changed = [this]() { + update_led_indicator_after_settings_change(); + }; page_stack.push(std::move(screenshot_settings_page)); }; front_page_ptr->add_widget(std::move(button)); diff --git a/src/gui/ScreenshotSettingsPage.cpp b/src/gui/ScreenshotSettingsPage.cpp index f8a86db..bd805ee 100644 --- a/src/gui/ScreenshotSettingsPage.cpp +++ b/src/gui/ScreenshotSettingsPage.cpp @@ -357,6 +357,8 @@ namespace gsr { } void ScreenshotSettingsPage::save() { + Config prev_config = config; + config.screenshot_config.record_area_option = record_area_box_ptr->get_selected_id(); config.screenshot_config.image_width = atoi(image_width_entry_ptr->get_text().c_str()); config.screenshot_config.image_height = atoi(image_height_entry_ptr->get_text().c_str()); @@ -390,5 +392,8 @@ namespace gsr { } save_config(config); + + if(on_config_changed && config != prev_config) + on_config_changed(); } }