aboutsummaryrefslogtreecommitdiff
path: root/src/gui/SettingsPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/SettingsPage.cpp')
-rw-r--r--src/gui/SettingsPage.cpp96
1 files changed, 72 insertions, 24 deletions
diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp
index 2e6fa08..5fdcc91 100644
--- a/src/gui/SettingsPage.cpp
+++ b/src/gui/SettingsPage.cpp
@@ -304,7 +304,8 @@ namespace gsr {
std::unique_ptr<Widget> SettingsPage::create_audio_section() {
auto audio_device_section_list = std::make_unique<List>(List::Orientation::VERTICAL);
audio_device_section_list->add_widget(create_audio_track_section());
- audio_device_section_list->add_widget(create_merge_audio_tracks_checkbox());
+ if(type != Type::STREAM)
+ audio_device_section_list->add_widget(create_merge_audio_tracks_checkbox());
audio_device_section_list->add_widget(create_application_audio_invert_checkbox());
audio_device_section_list->add_widget(create_audio_codec());
return std::make_unique<Subsection>("Audio", std::move(audio_device_section_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f));
@@ -338,11 +339,27 @@ namespace gsr {
return list;
}
- std::unique_ptr<Entry> SettingsPage::create_video_bitrate_entry() {
+ std::unique_ptr<List> SettingsPage::create_video_bitrate_entry() {
+ auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
auto video_bitrate_entry = std::make_unique<Entry>(&get_theme().body_font, "15000", (int)(get_theme().body_font.get_character_size() * 4.0f));
video_bitrate_entry->validate_handler = create_entry_validator_integer_in_range(1, 500000);
video_bitrate_entry_ptr = video_bitrate_entry.get();
- return video_bitrate_entry;
+ list->add_widget(std::move(video_bitrate_entry));
+
+ if(type == Type::STREAM) {
+ auto size_mb_label = std::make_unique<Label>(&get_theme().body_font, "1.92MB", get_color_theme().text_color);
+ Label *size_mb_label_ptr = size_mb_label.get();
+ list->add_widget(std::move(size_mb_label));
+
+ video_bitrate_entry_ptr->on_changed = [size_mb_label_ptr](const std::string &text) {
+ const double video_bitrate_mb_per_seconds = (double)atoi(text.c_str()) / 1000LL / 8LL * 1.024;
+ char buffer[32];
+ snprintf(buffer, sizeof(buffer), "%.2fMB", video_bitrate_mb_per_seconds);
+ size_mb_label_ptr->set_text(buffer);
+ };
+ }
+
+ return list;
}
std::unique_ptr<List> SettingsPage::create_video_bitrate() {
@@ -387,20 +404,20 @@ namespace gsr {
video_codec_box->add_item("H264", "h264");
if(gsr_info->supported_video_codecs.hevc)
video_codec_box->add_item("HEVC", "hevc");
+ if(gsr_info->supported_video_codecs.hevc_10bit)
+ video_codec_box->add_item("HEVC (10 bit, reduces banding)", "hevc_10bit");
+ if(gsr_info->supported_video_codecs.hevc_hdr)
+ video_codec_box->add_item("HEVC (HDR)", "hevc_hdr");
if(gsr_info->supported_video_codecs.av1)
video_codec_box->add_item("AV1", "av1");
+ if(gsr_info->supported_video_codecs.av1_10bit)
+ video_codec_box->add_item("AV1 (10 bit, reduces banding)", "av1_10bit");
+ if(gsr_info->supported_video_codecs.av1_hdr)
+ video_codec_box->add_item("AV1 (HDR)", "av1_hdr");
if(gsr_info->supported_video_codecs.vp8)
video_codec_box->add_item("VP8", "vp8");
if(gsr_info->supported_video_codecs.vp9)
video_codec_box->add_item("VP9", "vp9");
- if(gsr_info->supported_video_codecs.hevc_hdr)
- video_codec_box->add_item("HEVC (HDR)", "hevc_hdr");
- if(gsr_info->supported_video_codecs.hevc_10bit)
- video_codec_box->add_item("HEVC (10 bit, reduces banding)", "hevc_10bit");
- if(gsr_info->supported_video_codecs.av1_hdr)
- video_codec_box->add_item("AV1 (HDR)", "av1_hdr");
- if(gsr_info->supported_video_codecs.av1_10bit)
- video_codec_box->add_item("AV1 (10 bit, reduces banding)", "av1_10bit");
if(gsr_info->supported_video_codecs.h264_software)
video_codec_box->add_item("H264 Software Encoder (Slow, not recommended)", "h264_software");
video_codec_box_ptr = video_codec_box.get();
@@ -516,6 +533,7 @@ namespace gsr {
video_resolution_list_ptr->set_visible(!focused_selected && change_video_resolution_checkbox_ptr->is_checked());
change_video_resolution_checkbox_ptr->set_visible(!focused_selected);
restore_portal_session_list_ptr->set_visible(portal_selected);
+ return true;
};
change_video_resolution_checkbox_ptr->on_changed = [this](bool checked) {
@@ -530,6 +548,8 @@ namespace gsr {
if(estimated_file_size_ptr)
estimated_file_size_ptr->set_visible(custom_selected);
+
+ return true;
};
video_quality_box_ptr->on_selection_changed("", video_quality_box_ptr->get_selected_id());
@@ -644,16 +664,16 @@ namespace gsr {
return checkbox;
}
- std::unique_ptr<Label> SettingsPage::create_estimated_file_size() {
- auto label = std::make_unique<Label>(&get_theme().body_font, "Estimated video max file size in RAM: 5.23MB", get_color_theme().text_color);
+ std::unique_ptr<Label> SettingsPage::create_estimated_replay_file_size() {
+ auto label = std::make_unique<Label>(&get_theme().body_font, "Estimated video max file size in RAM: 57.60MB", get_color_theme().text_color);
estimated_file_size_ptr = label.get();
return label;
}
- void SettingsPage::update_estimated_file_size() {
+ void SettingsPage::update_estimated_replay_file_size() {
const int64_t replay_time_seconds = atoi(replay_time_entry_ptr->get_text().c_str());
const int64_t video_bitrate_bps = atoi(video_bitrate_entry_ptr->get_text().c_str()) * 1000LL / 8LL;
- const double video_filesize_mb = ((double)replay_time_seconds * (double)video_bitrate_bps) / 1024.0 / 1024.0;
+ const double video_filesize_mb = ((double)replay_time_seconds * (double)video_bitrate_bps) / 1000.0 / 1000.0 * 1.024;
char buffer[512];
snprintf(buffer, sizeof(buffer), "Estimated video max file size in RAM: %.2fMB", video_filesize_mb);
@@ -667,7 +687,7 @@ namespace gsr {
file_info_data_list->add_widget(create_container_section());
file_info_data_list->add_widget(create_replay_time());
file_info_list->add_widget(std::move(file_info_data_list));
- file_info_list->add_widget(create_estimated_file_size());
+ file_info_list->add_widget(create_estimated_replay_file_size());
settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_info_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto general_list = std::make_unique<List>(List::Orientation::VERTICAL);
@@ -705,15 +725,16 @@ namespace gsr {
framerate_mode_list_ptr->set_visible(advanced_view);
notifications_subsection_ptr->set_visible(advanced_view);
settings_scrollable_page_ptr->reset_scroll();
+ return true;
};
view_radio_button_ptr->on_selection_changed("Simple", "simple");
replay_time_entry_ptr->on_changed = [this](const std::string&) {
- update_estimated_file_size();
+ update_estimated_replay_file_size();
};
video_bitrate_entry_ptr->on_changed = [this](const std::string&) {
- update_estimated_file_size();
+ update_estimated_replay_file_size();
};
}
@@ -725,11 +746,29 @@ namespace gsr {
return checkbox;
}
+ std::unique_ptr<Label> SettingsPage::create_estimated_record_file_size() {
+ auto label = std::make_unique<Label>(&get_theme().body_font, "Estimated video file size per minute (excluding audio): 345.60MB", get_color_theme().text_color);
+ estimated_file_size_ptr = label.get();
+ return label;
+ }
+
+ void SettingsPage::update_estimated_record_file_size() {
+ const int64_t video_bitrate_bps = atoi(video_bitrate_entry_ptr->get_text().c_str()) * 1000LL / 8LL;
+ const double video_filesize_mb_per_minute = (60.0 * (double)video_bitrate_bps) / 1000.0 / 1000.0 * 1.024;
+
+ char buffer[512];
+ snprintf(buffer, sizeof(buffer), "Estimated video file size per minute (excluding audio): %.2fMB", video_filesize_mb_per_minute);
+ estimated_file_size_ptr->set_text(buffer);
+ }
+
void SettingsPage::add_record_widgets() {
- auto file_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
- file_list->add_widget(create_save_directory("Directory to save the video:"));
- file_list->add_widget(create_container_section());
- settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
+ auto file_info_list = std::make_unique<List>(List::Orientation::VERTICAL);
+ auto file_info_data_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
+ file_info_data_list->add_widget(create_save_directory("Directory to save the video:"));
+ file_info_data_list->add_widget(create_container_section());
+ file_info_list->add_widget(std::move(file_info_data_list));
+ file_info_list->add_widget(create_estimated_record_file_size());
+ settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_info_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto general_list = std::make_unique<List>(List::Orientation::VERTICAL);
general_list->add_widget(create_save_recording_in_game_folder());
@@ -760,8 +799,13 @@ namespace gsr {
framerate_mode_list_ptr->set_visible(advanced_view);
notifications_subsection_ptr->set_visible(advanced_view);
settings_scrollable_page_ptr->reset_scroll();
+ return true;
};
view_radio_button_ptr->on_selection_changed("Simple", "simple");
+
+ video_bitrate_entry_ptr->on_changed = [this](const std::string&) {
+ update_estimated_record_file_size();
+ };
}
std::unique_ptr<ComboBox> SettingsPage::create_streaming_service_box() {
@@ -860,6 +904,7 @@ namespace gsr {
container_list_ptr->set_visible(custom_option);
twitch_stream_key_entry_ptr->set_visible(twitch_option);
youtube_stream_key_entry_ptr->set_visible(youtube_option);
+ return true;
};
streaming_service_box_ptr->on_selection_changed("Twitch", "twitch");
@@ -872,6 +917,7 @@ namespace gsr {
framerate_mode_list_ptr->set_visible(advanced_view);
notifications_subsection_ptr->set_visible(advanced_view);
settings_scrollable_page_ptr->reset_scroll();
+ return true;
};
view_radio_button_ptr->on_selection_changed("Simple", "simple");
}
@@ -962,7 +1008,8 @@ namespace gsr {
void SettingsPage::load_common(RecordOptions &record_options) {
record_area_box_ptr->set_selected_item(record_options.record_area_option);
- merge_audio_tracks_checkbox_ptr->set_checked(record_options.merge_audio_tracks);
+ if(merge_audio_tracks_checkbox_ptr)
+ merge_audio_tracks_checkbox_ptr->set_checked(record_options.merge_audio_tracks);
application_audio_invert_checkbox_ptr->set_checked(record_options.application_audio_invert);
change_video_resolution_checkbox_ptr->set_checked(record_options.change_video_resolution);
load_audio_tracks(record_options);
@@ -1083,7 +1130,8 @@ namespace gsr {
record_options.video_height = atoi(video_height_entry_ptr->get_text().c_str());
record_options.fps = atoi(framerate_entry_ptr->get_text().c_str());
record_options.video_bitrate = atoi(video_bitrate_entry_ptr->get_text().c_str());
- record_options.merge_audio_tracks = merge_audio_tracks_checkbox_ptr->is_checked();
+ if(merge_audio_tracks_checkbox_ptr)
+ record_options.merge_audio_tracks = merge_audio_tracks_checkbox_ptr->is_checked();
record_options.application_audio_invert = application_audio_invert_checkbox_ptr->is_checked();
record_options.change_video_resolution = change_video_resolution_checkbox_ptr->is_checked();
save_audio_tracks(record_options.audio_tracks, audio_track_list_ptr);