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.cpp67
1 files changed, 47 insertions, 20 deletions
diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp
index 3d114ae..9394104 100644
--- a/src/gui/SettingsPage.cpp
+++ b/src/gui/SettingsPage.cpp
@@ -8,11 +8,6 @@
#include "../../include/GsrInfo.hpp"
#include "../../include/Utils.hpp"
-#include <mglpp/graphics/Rectangle.hpp>
-#include <mglpp/graphics/Sprite.hpp>
-#include <mglpp/graphics/Text.hpp>
-#include <mglpp/window/Window.hpp>
-
#include <string.h>
namespace gsr {
@@ -22,6 +17,15 @@ namespace gsr {
APPLICATION_CUSTOM
};
+ static const char* settings_page_type_to_title_text(SettingsPage::Type type) {
+ switch(type) {
+ case SettingsPage::Type::REPLAY: return "Instant Replay";
+ case SettingsPage::Type::RECORD: return "Record";
+ case SettingsPage::Type::STREAM: return "Livestream";
+ }
+ return "";
+ }
+
SettingsPage::SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack) :
StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()),
type(type),
@@ -33,7 +37,7 @@ namespace gsr {
application_audio = get_application_audio();
capture_options = get_supported_capture_options(*gsr_info);
- auto content_page = std::make_unique<GsrPage>();
+ auto content_page = std::make_unique<GsrPage>(settings_page_type_to_title_text(type), "Settings");
content_page->add_button("Back", "back", get_color_theme().page_bg_color);
content_page->on_click = [page_stack](const std::string &id) {
if(id == "back")
@@ -171,7 +175,7 @@ namespace gsr {
return checkbox;
}
- std::unique_ptr<Widget> SettingsPage::create_capture_target() {
+ std::unique_ptr<Widget> SettingsPage::create_capture_target_section() {
auto ll = std::make_unique<List>(List::Orientation::VERTICAL);
auto capture_target_list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
@@ -512,7 +516,7 @@ namespace gsr {
auto settings_list = std::make_unique<List>(List::Orientation::VERTICAL);
settings_list->set_spacing(0.018f);
- settings_list->add_widget(create_capture_target());
+ settings_list->add_widget(create_capture_target_section());
settings_list->add_widget(create_audio_section());
settings_list->add_widget(create_video_section());
settings_list_ptr = settings_list.get();
@@ -589,7 +593,7 @@ namespace gsr {
auto save_directory_button = std::make_unique<Button>(&get_theme().body_font, get_videos_dir().c_str(), mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
save_directory_button_ptr = save_directory_button.get();
save_directory_button->on_click = [this]() {
- auto select_directory_page = std::make_unique<GsrPage>();
+ auto select_directory_page = std::make_unique<GsrPage>("File", "Settings");
select_directory_page->add_button("Save", "save", get_color_theme().tint_color);
select_directory_page->add_button("Cancel", "cancel", get_color_theme().page_bg_color);
@@ -629,16 +633,24 @@ namespace gsr {
return container_list;
}
- std::unique_ptr<Entry> SettingsPage::create_replay_time_entry() {
+ std::unique_ptr<List> SettingsPage::create_replay_time_entry() {
+ auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+
auto replay_time_entry = std::make_unique<Entry>(&get_theme().body_font, "60", get_theme().body_font.get_character_size() * 3);
- replay_time_entry->validate_handler = create_entry_validator_integer_in_range(1, 1200);
+ replay_time_entry->validate_handler = create_entry_validator_integer_in_range(1, 10800);
replay_time_entry_ptr = replay_time_entry.get();
- return replay_time_entry;
+ list->add_widget(std::move(replay_time_entry));
+
+ auto replay_time_label = std::make_unique<Label>(&get_theme().body_font, "00h:00m:00s", get_color_theme().text_color);
+ replay_time_label_ptr = replay_time_label.get();
+ list->add_widget(std::move(replay_time_label));
+
+ return list;
}
std::unique_ptr<List> SettingsPage::create_replay_time() {
auto replay_time_list = std::make_unique<List>(List::Orientation::VERTICAL);
- replay_time_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Replay time in seconds:", get_color_theme().text_color));
+ replay_time_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Replay duration in seconds:", get_color_theme().text_color));
replay_time_list->add_widget(create_replay_time_entry());
return replay_time_list;
}
@@ -681,11 +693,25 @@ namespace gsr {
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) / 1000.0 / 1000.0 * 1.024;
- char buffer[512];
- snprintf(buffer, sizeof(buffer), "Estimated video max file size in RAM: %.2fMB", video_filesize_mb);
+ char buffer[256];
+ snprintf(buffer, sizeof(buffer), "Estimated video max file size in RAM: %.2fMB.\nChange video bitrate or replay duration to change file size.", video_filesize_mb);
estimated_file_size_ptr->set_text(buffer);
}
+ void SettingsPage::update_replay_time_text() {
+ int seconds = atoi(replay_time_entry_ptr->get_text().c_str());
+
+ const int hours = seconds / 60 / 60;
+ seconds -= (hours * 60 * 60);
+
+ const int minutes = seconds / 60;
+ seconds -= (minutes * 60);
+
+ char buffer[256];
+ snprintf(buffer, sizeof(buffer), "%02dh:%02dm:%02ds", hours, minutes, seconds);
+ replay_time_label_ptr->set_text(buffer);
+ }
+
void SettingsPage::add_replay_widgets() {
auto file_info_list = std::make_unique<List>(List::Orientation::VERTICAL);
auto file_info_data_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
@@ -739,6 +765,7 @@ namespace gsr {
replay_time_entry_ptr->on_changed = [this](const std::string&) {
update_estimated_replay_file_size();
+ update_replay_time_text();
};
video_bitrate_entry_ptr->on_changed = [this](const std::string&) {
@@ -778,9 +805,7 @@ namespace gsr {
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());
- settings_list_ptr->add_widget(std::make_unique<Subsection>("General", std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
+ settings_list_ptr->add_widget(std::make_unique<Subsection>("General", create_save_recording_in_game_folder(), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL);
@@ -1081,8 +1106,10 @@ namespace gsr {
save_directory_button_ptr->set_text(config.replay_config.save_directory);
container_box_ptr->set_selected_item(config.replay_config.container);
- if(config.replay_config.replay_time < 5)
- config.replay_config.replay_time = 5;
+ if(config.replay_config.replay_time < 2)
+ config.replay_config.replay_time = 2;
+ if(config.replay_config.replay_time > 10800)
+ config.replay_config.replay_time = 10800;
replay_time_entry_ptr->set_text(std::to_string(config.replay_config.replay_time));
}