mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Add replay ram usage estimation
This commit is contained in:
@@ -26,6 +26,8 @@ namespace gsr {
|
|||||||
// Return false to specify that the string should not be accepted. This reverts the string back to its previous value.
|
// Return false to specify that the string should not be accepted. This reverts the string back to its previous value.
|
||||||
// The input can be changed by changing the input parameter and returning true.
|
// The input can be changed by changing the input parameter and returning true.
|
||||||
EntryValidateHandler validate_handler;
|
EntryValidateHandler validate_handler;
|
||||||
|
|
||||||
|
std::function<void(const std::string &text)> on_changed;
|
||||||
private:
|
private:
|
||||||
mgl::Text text;
|
mgl::Text text;
|
||||||
float max_width;
|
float max_width;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace gsr {
|
|||||||
void draw(mgl::Window &window, mgl::vec2f offset) override;
|
void draw(mgl::Window &window, mgl::vec2f offset) override;
|
||||||
|
|
||||||
mgl::vec2f get_size() override;
|
mgl::vec2f get_size() override;
|
||||||
|
|
||||||
|
void set_text(std::string str);
|
||||||
private:
|
private:
|
||||||
mgl::Text text;
|
mgl::Text text;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace gsr {
|
|||||||
class GsrPage;
|
class GsrPage;
|
||||||
class PageStack;
|
class PageStack;
|
||||||
class ScrollablePage;
|
class ScrollablePage;
|
||||||
|
class Label;
|
||||||
|
|
||||||
class SettingsPage : public StaticPage {
|
class SettingsPage : public StaticPage {
|
||||||
public:
|
public:
|
||||||
@@ -83,6 +84,8 @@ namespace gsr {
|
|||||||
std::unique_ptr<List> create_replay_time();
|
std::unique_ptr<List> create_replay_time();
|
||||||
std::unique_ptr<CheckBox> create_start_replay_on_startup();
|
std::unique_ptr<CheckBox> create_start_replay_on_startup();
|
||||||
std::unique_ptr<CheckBox> create_save_replay_in_game_folder();
|
std::unique_ptr<CheckBox> create_save_replay_in_game_folder();
|
||||||
|
std::unique_ptr<Label> create_estimated_file_size();
|
||||||
|
void update_estimated_file_size();
|
||||||
std::unique_ptr<CheckBox> create_save_recording_in_game_folder();
|
std::unique_ptr<CheckBox> create_save_recording_in_game_folder();
|
||||||
void add_replay_widgets();
|
void add_replay_widgets();
|
||||||
void add_record_widgets();
|
void add_record_widgets();
|
||||||
@@ -147,6 +150,7 @@ namespace gsr {
|
|||||||
List *container_list_ptr = nullptr;
|
List *container_list_ptr = nullptr;
|
||||||
CheckBox *start_replay_automatically_ptr = nullptr;
|
CheckBox *start_replay_automatically_ptr = nullptr;
|
||||||
CheckBox *save_replay_in_game_folder_ptr = nullptr;
|
CheckBox *save_replay_in_game_folder_ptr = nullptr;
|
||||||
|
Label *estimated_file_size_ptr = nullptr;
|
||||||
CheckBox *show_replay_started_notification_checkbox_ptr = nullptr;
|
CheckBox *show_replay_started_notification_checkbox_ptr = nullptr;
|
||||||
CheckBox *show_replay_stopped_notification_checkbox_ptr = nullptr;
|
CheckBox *show_replay_stopped_notification_checkbox_ptr = nullptr;
|
||||||
CheckBox *show_replay_saved_notification_checkbox_ptr = nullptr;
|
CheckBox *show_replay_saved_notification_checkbox_ptr = nullptr;
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ namespace gsr {
|
|||||||
if(!validate_handler || validate_handler(str)) {
|
if(!validate_handler || validate_handler(str)) {
|
||||||
text.set_string(std::move(str));
|
text.set_string(std::move(str));
|
||||||
caret_offset_x = text.find_character_pos(99999).x - this->text.get_position().x;
|
caret_offset_x = text.find_character_pos(99999).x - this->text.get_position().x;
|
||||||
|
if(on_changed)
|
||||||
|
on_changed(text.get_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ namespace gsr {
|
|||||||
window.draw(text);
|
window.draw(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Label::set_text(std::string str) {
|
||||||
|
text.set_string(std::move(str));
|
||||||
|
}
|
||||||
|
|
||||||
mgl::vec2f Label::get_size() {
|
mgl::vec2f Label::get_size() {
|
||||||
if(!visible)
|
if(!visible)
|
||||||
return {0.0f, 0.0f};
|
return {0.0f, 0.0f};
|
||||||
|
|||||||
@@ -449,8 +449,11 @@ namespace gsr {
|
|||||||
(void)text;
|
(void)text;
|
||||||
const bool custom_selected = id == "custom";
|
const bool custom_selected = id == "custom";
|
||||||
video_bitrate_list_ptr->set_visible(custom_selected);
|
video_bitrate_list_ptr->set_visible(custom_selected);
|
||||||
|
|
||||||
|
if(estimated_file_size_ptr)
|
||||||
|
estimated_file_size_ptr->set_visible(custom_selected);
|
||||||
};
|
};
|
||||||
video_quality_box_ptr->on_selection_changed("Very high", "very_high");
|
video_quality_box_ptr->on_selection_changed("", video_quality_box_ptr->get_selected_id());
|
||||||
|
|
||||||
if(!gsr_info.supported_capture_options.monitors.empty())
|
if(!gsr_info.supported_capture_options.monitors.empty())
|
||||||
record_area_box_ptr->set_selected_item(gsr_info.supported_capture_options.monitors.front().name);
|
record_area_box_ptr->set_selected_item(gsr_info.supported_capture_options.monitors.front().name);
|
||||||
@@ -545,11 +548,30 @@ namespace gsr {
|
|||||||
return checkbox;
|
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);
|
||||||
|
estimated_file_size_ptr = label.get();
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsPage::update_estimated_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;
|
||||||
|
const double video_filesize_mb = ((double)replay_time_seconds * (double)video_bitrate_bps) / 1024.0 / 1024.0 / 3.3333; // Why 3.3333?
|
||||||
|
|
||||||
|
char buffer[512];
|
||||||
|
snprintf(buffer, sizeof(buffer), "Estimated video max file size in RAM: %.2fMB", video_filesize_mb);
|
||||||
|
estimated_file_size_ptr->set_text(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsPage::add_replay_widgets() {
|
void SettingsPage::add_replay_widgets() {
|
||||||
auto file_info_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
|
auto file_info_list = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||||
file_info_list->add_widget(create_save_directory("Directory to save replays:"));
|
auto file_info_data_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
|
||||||
file_info_list->add_widget(create_container_section());
|
file_info_data_list->add_widget(create_save_directory("Directory to save replays:"));
|
||||||
file_info_list->add_widget(create_replay_time());
|
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());
|
||||||
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)));
|
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);
|
auto general_list = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||||
@@ -589,6 +611,14 @@ namespace gsr {
|
|||||||
settings_scrollable_page_ptr->reset_scroll();
|
settings_scrollable_page_ptr->reset_scroll();
|
||||||
};
|
};
|
||||||
view_radio_button_ptr->on_selection_changed("Simple", "simple");
|
view_radio_button_ptr->on_selection_changed("Simple", "simple");
|
||||||
|
|
||||||
|
replay_time_entry_ptr->on_changed = [this](const std::string&) {
|
||||||
|
update_estimated_file_size();
|
||||||
|
};
|
||||||
|
|
||||||
|
video_bitrate_entry_ptr->on_changed = [this](const std::string&) {
|
||||||
|
update_estimated_file_size();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CheckBox> SettingsPage::create_save_recording_in_game_folder() {
|
std::unique_ptr<CheckBox> SettingsPage::create_save_recording_in_game_folder() {
|
||||||
|
|||||||
Reference in New Issue
Block a user