aboutsummaryrefslogtreecommitdiff
path: root/src/gui/GlobalSettingsPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/GlobalSettingsPage.cpp')
-rw-r--r--src/gui/GlobalSettingsPage.cpp290
1 files changed, 195 insertions, 95 deletions
diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp
index 81e1d9a..6650c69 100644
--- a/src/gui/GlobalSettingsPage.cpp
+++ b/src/gui/GlobalSettingsPage.cpp
@@ -1,7 +1,6 @@
#include "../../include/gui/GlobalSettingsPage.hpp"
#include "../../include/Overlay.hpp"
-#include "../../include/GlobalHotkeys.hpp"
#include "../../include/Theme.hpp"
#include "../../include/Process.hpp"
#include "../../include/gui/GsrPage.hpp"
@@ -10,6 +9,7 @@
#include "../../include/gui/Subsection.hpp"
#include "../../include/gui/List.hpp"
#include "../../include/gui/Label.hpp"
+#include "../../include/gui/Image.hpp"
#include "../../include/gui/RadioButton.hpp"
#include "../../include/gui/LineSeparator.hpp"
#include "../../include/gui/CustomRendererWidget.hpp"
@@ -34,20 +34,22 @@ extern "C" {
namespace gsr {
static const char* gpu_vendor_to_color_name(GpuVendor vendor) {
switch(vendor) {
- case GpuVendor::UNKNOWN: return "amd";
- case GpuVendor::AMD: return "amd";
- case GpuVendor::INTEL: return "intel";
- case GpuVendor::NVIDIA: return "nvidia";
+ case GpuVendor::UNKNOWN: return "amd";
+ case GpuVendor::AMD: return "amd";
+ case GpuVendor::INTEL: return "intel";
+ case GpuVendor::NVIDIA: return "nvidia";
+ case GpuVendor::BROADCOM: return "broadcom";
}
return "amd";
}
static const char* gpu_vendor_to_string(GpuVendor vendor) {
switch(vendor) {
- case GpuVendor::UNKNOWN: return "Unknown";
- case GpuVendor::AMD: return "AMD";
- case GpuVendor::INTEL: return "Intel";
- case GpuVendor::NVIDIA: return "NVIDIA";
+ case GpuVendor::UNKNOWN: return "Unknown";
+ case GpuVendor::AMD: return "AMD";
+ case GpuVendor::INTEL: return "Intel";
+ case GpuVendor::NVIDIA: return "NVIDIA";
+ case GpuVendor::BROADCOM: return "Broadcom";
}
return "unknown";
}
@@ -67,44 +69,8 @@ namespace gsr {
return 0;
}
- static std::vector<mgl::Keyboard::Key> hotkey_modifiers_to_mgl_keys(uint32_t modifiers) {
- std::vector<mgl::Keyboard::Key> result;
- if(modifiers & HOTKEY_MOD_LCTRL)
- result.push_back(mgl::Keyboard::LControl);
- if(modifiers & HOTKEY_MOD_LSHIFT)
- result.push_back(mgl::Keyboard::LShift);
- if(modifiers & HOTKEY_MOD_LALT)
- result.push_back(mgl::Keyboard::LAlt);
- if(modifiers & HOTKEY_MOD_LSUPER)
- result.push_back(mgl::Keyboard::LSystem);
- if(modifiers & HOTKEY_MOD_RCTRL)
- result.push_back(mgl::Keyboard::RControl);
- if(modifiers & HOTKEY_MOD_RSHIFT)
- result.push_back(mgl::Keyboard::RShift);
- if(modifiers & HOTKEY_MOD_RALT)
- result.push_back(mgl::Keyboard::RAlt);
- if(modifiers & HOTKEY_MOD_RSUPER)
- result.push_back(mgl::Keyboard::RSystem);
- return result;
- }
-
- static std::string config_hotkey_to_string(ConfigHotkey config_hotkey) {
- std::string result;
-
- const std::vector<mgl::Keyboard::Key> modifier_keys = hotkey_modifiers_to_mgl_keys(config_hotkey.modifiers);
- for(const mgl::Keyboard::Key modifier_key : modifier_keys) {
- if(!result.empty())
- result += " + ";
- result += mgl::Keyboard::key_to_string(modifier_key);
- }
-
- if(config_hotkey.key != 0) {
- if(!result.empty())
- result += " + ";
- result += mgl::Keyboard::key_to_string((mgl::Keyboard::Key)config_hotkey.key);
- }
-
- return result;
+ static bool key_is_alpha_numerical(mgl::Keyboard::Key key) {
+ return key >= mgl::Keyboard::A && key <= mgl::Keyboard::Num9;
}
GlobalSettingsPage::GlobalSettingsPage(Overlay *overlay, const GsrInfo *gsr_info, Config &config, PageStack *page_stack) :
@@ -114,7 +80,7 @@ namespace gsr {
gsr_info(gsr_info),
page_stack(page_stack)
{
- auto content_page = std::make_unique<GsrPage>();
+ auto content_page = std::make_unique<GsrPage>("Global", "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")
@@ -134,13 +100,13 @@ namespace gsr {
mgl::Text title_text("Press a key combination to use for the hotkey \"" + hotkey_configure_action_name + "\":", get_theme().title_font);
mgl::Text hotkey_text(configure_hotkey_button->get_text(), get_theme().top_bar_font);
- mgl::Text description_text("The hotkey has to contain one or more of these keys: Alt, Ctrl, Shift and Super. Press Esc to cancel.", get_theme().body_font);
+ mgl::Text description_text("Alpha-numerical keys can't be used alone in hotkeys, they have to be used one or more of these keys: Alt, Ctrl, Shift and Super.\nPress Esc to cancel or Backspace to remove the hotkey.", get_theme().body_font);
const float text_max_width = std::max(title_text.get_bounds().size.x, std::max(hotkey_text.get_bounds().size.x, description_text.get_bounds().size.x));
const float padding_horizontal = int(get_theme().window_height * 0.01f);
const float padding_vertical = int(get_theme().window_height * 0.01f);
- const mgl::vec2f bg_size = mgl::vec2f(text_max_width + padding_horizontal*2.0f, get_theme().window_height * 0.1f).floor();
+ const mgl::vec2f bg_size = mgl::vec2f(text_max_width + padding_horizontal*2.0f, get_theme().window_height * 0.13f).floor();
mgl::Rectangle bg_rect(mgl::vec2f(get_theme().window_width*0.5f - bg_size.x*0.5f, get_theme().window_height*0.5f - bg_size.y*0.5f).floor(), bg_size);
bg_rect.set_color(get_color_theme().page_bg_color);
window.draw(bg_rect);
@@ -151,9 +117,16 @@ namespace gsr {
window.draw(tint_rect);
title_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - title_text.get_bounds().size.x*0.5f, padding_vertical)).floor());
+ description_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - description_text.get_bounds().size.x*0.5f, bg_rect.get_size().y - description_text.get_bounds().size.y - padding_vertical)).floor());
+
window.draw(title_text);
- hotkey_text.set_position(mgl::vec2f(bg_rect.get_position() + bg_rect.get_size()*0.5f - hotkey_text.get_bounds().size*0.5f).floor());
+ const float title_text_bottom = title_text.get_position().y + title_text.get_bounds().size.y;
+ hotkey_text.set_position(
+ mgl::vec2f(
+ bg_rect.get_position().x + bg_rect.get_size().x*0.5f - hotkey_text.get_bounds().size.x*0.5f,
+ title_text_bottom + (description_text.get_position().y - title_text_bottom) * 0.5f - hotkey_text.get_bounds().size.y*0.5f
+ ).floor());
window.draw(hotkey_text);
const float caret_padding_x = int(0.001f * get_theme().window_height);
@@ -161,7 +134,6 @@ namespace gsr {
mgl::Rectangle caret_rect(hotkey_text.get_position() + mgl::vec2f(hotkey_text.get_bounds().size.x + caret_padding_x, hotkey_text.get_bounds().size.y*0.5f - caret_size.y*0.5f).floor(), caret_size);
window.draw(caret_rect);
- description_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - description_text.get_bounds().size.x*0.5f, bg_rect.get_size().y - description_text.get_bounds().size.y - padding_vertical)).floor());
window.draw(description_text);
};
hotkey_overlay->set_visible(false);
@@ -171,12 +143,12 @@ namespace gsr {
std::unique_ptr<Subsection> GlobalSettingsPage::create_appearance_subsection(ScrollablePage *parent_page) {
auto list = std::make_unique<List>(List::Orientation::VERTICAL);
- list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Tint color", get_color_theme().text_color));
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Accent color", get_color_theme().text_color));
auto tint_color_radio_button = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL);
tint_color_radio_button_ptr = tint_color_radio_button.get();
tint_color_radio_button->add_item("Red", "amd");
tint_color_radio_button->add_item("Green", "nvidia");
- tint_color_radio_button->add_item("blue", "intel");
+ tint_color_radio_button->add_item("Blue", "intel");
tint_color_radio_button->on_selection_changed = [](const std::string&, const std::string &id) {
if(id == "amd")
get_color_theme().tint_color = mgl::Color(221, 0, 49);
@@ -283,6 +255,30 @@ namespace gsr {
return list;
}
+ std::unique_ptr<List> GlobalSettingsPage::create_replay_partial_save_hotkey_options() {
+ auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Save 1 minute replay:", get_color_theme().text_color));
+ auto save_replay_1_min_button = std::make_unique<Button>(&get_theme().body_font, "", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ save_replay_1_min_button_ptr = save_replay_1_min_button.get();
+ list->add_widget(std::move(save_replay_1_min_button));
+
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Save 10 minute replay:", get_color_theme().text_color));
+ auto save_replay_10_min_button = std::make_unique<Button>(&get_theme().body_font, "", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ save_replay_10_min_button_ptr = save_replay_10_min_button.get();
+ list->add_widget(std::move(save_replay_10_min_button));
+
+ save_replay_1_min_button_ptr->on_click = [this] {
+ configure_hotkey_start(ConfigureHotkeyType::REPLAY_SAVE_1_MIN);
+ };
+
+ save_replay_10_min_button_ptr->on_click = [this] {
+ configure_hotkey_start(ConfigureHotkeyType::REPLAY_SAVE_10_MIN);
+ };
+
+ return list;
+ }
+
std::unique_ptr<List> GlobalSettingsPage::create_record_hotkey_options() {
auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
@@ -322,30 +318,59 @@ namespace gsr {
return list;
}
+ std::unique_ptr<List> GlobalSettingsPage::create_screenshot_hotkey_options() {
+ auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Take a screenshot:", get_color_theme().text_color));
+ auto take_screenshot_button = std::make_unique<Button>(&get_theme().body_font, "", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ take_screenshot_button_ptr = take_screenshot_button.get();
+ list->add_widget(std::move(take_screenshot_button));
+
+ take_screenshot_button_ptr->on_click = [this] {
+ configure_hotkey_start(ConfigureHotkeyType::TAKE_SCREENSHOT);
+ };
+
+ return list;
+ }
+
+ std::unique_ptr<List> GlobalSettingsPage::create_screenshot_region_hotkey_options() {
+ auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Take a screenshot of a region:", get_color_theme().text_color));
+ auto take_screenshot_region_button = std::make_unique<Button>(&get_theme().body_font, "", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ take_screenshot_region_button_ptr = take_screenshot_region_button.get();
+ list->add_widget(std::move(take_screenshot_region_button));
+
+ take_screenshot_region_button_ptr->on_click = [this] {
+ configure_hotkey_start(ConfigureHotkeyType::TAKE_SCREENSHOT_REGION);
+ };
+
+ return list;
+ }
+
std::unique_ptr<List> GlobalSettingsPage::create_hotkey_control_buttons() {
auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
- // auto clear_hotkeys_button = std::make_unique<Button>(&get_theme().body_font, "Clear hotkeys", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
- // clear_hotkeys_button->on_click = [this] {
- // config.streaming_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
- // config.record_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
- // config.record_config.pause_unpause_hotkey = {mgl::Keyboard::Unknown, 0};
- // config.replay_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
- // config.replay_config.save_hotkey = {mgl::Keyboard::Unknown, 0};
- // config.main_config.show_hide_hotkey = {mgl::Keyboard::Unknown, 0};
- // load_hotkeys();
- // overlay->rebind_all_keyboard_hotkeys();
- // };
- // list->add_widget(std::move(clear_hotkeys_button));
+ auto clear_hotkeys_button = std::make_unique<Button>(&get_theme().body_font, "Clear hotkeys", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ clear_hotkeys_button->on_click = [this] {
+ config.streaming_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.record_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.record_config.pause_unpause_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.replay_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.replay_config.save_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.replay_config.save_1_min_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.replay_config.save_10_min_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.screenshot_config.take_screenshot_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.screenshot_config.take_screenshot_region_hotkey = {mgl::Keyboard::Unknown, 0};
+ config.main_config.show_hide_hotkey = {mgl::Keyboard::Unknown, 0};
+ load_hotkeys();
+ overlay->rebind_all_keyboard_hotkeys();
+ };
+ list->add_widget(std::move(clear_hotkeys_button));
auto reset_hotkeys_button = std::make_unique<Button>(&get_theme().body_font, "Reset hotkeys to default", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
reset_hotkeys_button->on_click = [this] {
- config.streaming_config.start_stop_hotkey = {mgl::Keyboard::F8, HOTKEY_MOD_LALT};
- config.record_config.start_stop_hotkey = {mgl::Keyboard::F9, HOTKEY_MOD_LALT};
- config.record_config.pause_unpause_hotkey = {mgl::Keyboard::F7, HOTKEY_MOD_LALT};
- config.replay_config.start_stop_hotkey = {mgl::Keyboard::F10, HOTKEY_MOD_LALT | HOTKEY_MOD_LSHIFT};
- config.replay_config.save_hotkey = {mgl::Keyboard::F10, HOTKEY_MOD_LALT};
- config.main_config.show_hide_hotkey = {mgl::Keyboard::Z, HOTKEY_MOD_LALT};
+ config.set_hotkeys_to_default();
load_hotkeys();
overlay->rebind_all_keyboard_hotkeys();
};
@@ -354,25 +379,53 @@ namespace gsr {
return list;
}
- std::unique_ptr<Subsection> GlobalSettingsPage::create_hotkey_subsection(ScrollablePage *parent_page) {
+ static std::unique_ptr<List> create_joystick_hotkey_text(mgl::Texture *image1, mgl::Texture *image2, float max_height, const char *suffix) {
+ auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Press", get_color_theme().text_color));
+ list->add_widget(std::make_unique<Image>(image1, mgl::vec2f{max_height, 1000.0f}, Image::ScaleBehavior::SCALE));
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "and", get_color_theme().text_color));
+ list->add_widget(std::make_unique<Image>(image2, mgl::vec2f{max_height, 1000.0f}, Image::ScaleBehavior::SCALE));
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, suffix, get_color_theme().text_color));
+ return list;
+ }
+
+ std::unique_ptr<Subsection> GlobalSettingsPage::create_keyboard_hotkey_subsection(ScrollablePage *parent_page) {
auto list = std::make_unique<List>(List::Orientation::VERTICAL);
List *list_ptr = list.get();
- auto subsection = std::make_unique<Subsection>("Hotkeys", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));
+ auto subsection = std::make_unique<Subsection>("Keyboard hotkeys", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));
list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Enable keyboard hotkeys?", get_color_theme().text_color));
list_ptr->add_widget(create_enable_keyboard_hotkeys_button());
- list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Enable controller hotkeys?", get_color_theme().text_color));
- list_ptr->add_widget(create_enable_joystick_hotkeys_button());
list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Orientation::HORIZONTAL, subsection->get_inner_size().x));
list_ptr->add_widget(create_show_hide_hotkey_options());
list_ptr->add_widget(create_replay_hotkey_options());
+ list_ptr->add_widget(create_replay_partial_save_hotkey_options());
list_ptr->add_widget(create_record_hotkey_options());
list_ptr->add_widget(create_stream_hotkey_options());
- list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Double-click the controller share button to save a replay", get_color_theme().text_color));
+ list_ptr->add_widget(create_screenshot_hotkey_options());
+ list_ptr->add_widget(create_screenshot_region_hotkey_options());
list_ptr->add_widget(create_hotkey_control_buttons());
return subsection;
}
+ std::unique_ptr<Subsection> GlobalSettingsPage::create_controller_hotkey_subsection(ScrollablePage *parent_page) {
+ auto list = std::make_unique<List>(List::Orientation::VERTICAL);
+ List *list_ptr = list.get();
+ auto subsection = std::make_unique<Subsection>("Controller hotkeys", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));
+
+ list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Enable controller hotkeys?", get_color_theme().text_color));
+ list_ptr->add_widget(create_enable_joystick_hotkeys_button());
+ list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Orientation::HORIZONTAL, subsection->get_inner_size().x));
+ list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_options_texture, get_theme().body_font.get_character_size(), "to show/hide the UI"));
+ list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_up_texture, get_theme().body_font.get_character_size(), "to take a screenshot"));
+ list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_down_texture, get_theme().body_font.get_character_size(), "to save a replay"));
+ list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_left_texture, get_theme().body_font.get_character_size(), "to start/stop recording"));
+ list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_right_texture, get_theme().body_font.get_character_size(), "to turn replay on/off"));
+ list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_cross_texture, get_theme().body_font.get_character_size(), "to save a 1 minute replay"));
+ list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_triangle_texture, get_theme().body_font.get_character_size(), "to save a 10 minute replay"));
+ return subsection;
+ }
+
std::unique_ptr<Button> GlobalSettingsPage::create_exit_program_button() {
auto exit_program_button = std::make_unique<Button>(&get_theme().body_font, "Exit program", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
exit_program_button->on_click = [&]() {
@@ -430,7 +483,8 @@ namespace gsr {
settings_list->set_spacing(0.018f);
settings_list->add_widget(create_appearance_subsection(scrollable_page.get()));
settings_list->add_widget(create_startup_subsection(scrollable_page.get()));
- settings_list->add_widget(create_hotkey_subsection(scrollable_page.get()));
+ settings_list->add_widget(create_keyboard_hotkey_subsection(scrollable_page.get()));
+ settings_list->add_widget(create_controller_hotkey_subsection(scrollable_page.get()));
settings_list->add_widget(create_application_options_subsection(scrollable_page.get()));
settings_list->add_widget(create_application_info_subsection(scrollable_page.get()));
scrollable_page->add_widget(std::move(settings_list));
@@ -440,6 +494,8 @@ namespace gsr {
void GlobalSettingsPage::on_navigate_away_from_page() {
save();
+ if(on_page_closed)
+ on_page_closed();
}
void GlobalSettingsPage::load() {
@@ -460,15 +516,20 @@ namespace gsr {
}
void GlobalSettingsPage::load_hotkeys() {
- turn_replay_on_off_button_ptr->set_text(config_hotkey_to_string(config.replay_config.start_stop_hotkey));
- save_replay_button_ptr->set_text(config_hotkey_to_string(config.replay_config.save_hotkey));
+ turn_replay_on_off_button_ptr->set_text(config.replay_config.start_stop_hotkey.to_string());
+ save_replay_button_ptr->set_text(config.replay_config.save_hotkey.to_string());
+ save_replay_1_min_button_ptr->set_text(config.replay_config.save_1_min_hotkey.to_string());
+ save_replay_10_min_button_ptr->set_text(config.replay_config.save_10_min_hotkey.to_string());
+
+ start_stop_recording_button_ptr->set_text(config.record_config.start_stop_hotkey.to_string());
+ pause_unpause_recording_button_ptr->set_text(config.record_config.pause_unpause_hotkey.to_string());
- start_stop_recording_button_ptr->set_text(config_hotkey_to_string(config.record_config.start_stop_hotkey));
- pause_unpause_recording_button_ptr->set_text(config_hotkey_to_string(config.record_config.pause_unpause_hotkey));
+ start_stop_streaming_button_ptr->set_text(config.streaming_config.start_stop_hotkey.to_string());
- start_stop_streaming_button_ptr->set_text(config_hotkey_to_string(config.streaming_config.start_stop_hotkey));
+ take_screenshot_button_ptr->set_text(config.screenshot_config.take_screenshot_hotkey.to_string());
+ take_screenshot_region_button_ptr->set_text(config.screenshot_config.take_screenshot_region_hotkey.to_string());
- show_hide_button_ptr->set_text(config_hotkey_to_string(config.main_config.show_hide_hotkey));
+ show_hide_button_ptr->set_text(config.main_config.show_hide_hotkey.to_string());
}
void GlobalSettingsPage::save() {
@@ -494,12 +555,19 @@ namespace gsr {
if(event.key.code == mgl::Keyboard::Escape)
return false;
+ if(event.key.code == mgl::Keyboard::Backspace) {
+ configure_config_hotkey = {mgl::Keyboard::Unknown, 0};
+ configure_hotkey_button->set_text("");
+ configure_hotkey_stop_and_save();
+ return false;
+ }
+
if(mgl::Keyboard::key_is_modifier(event.key.code)) {
configure_config_hotkey.modifiers |= mgl_modifier_to_hotkey_modifier(event.key.code);
- configure_hotkey_button->set_text(config_hotkey_to_string(configure_config_hotkey));
- } else if(configure_config_hotkey.modifiers != 0) {
+ configure_hotkey_button->set_text(configure_config_hotkey.to_string());
+ } else if(event.key.code != mgl::Keyboard::Unknown && (configure_config_hotkey.modifiers != 0 || !key_is_alpha_numerical(event.key.code))) {
configure_config_hotkey.key = event.key.code;
- configure_hotkey_button->set_text(config_hotkey_to_string(configure_config_hotkey));
+ configure_hotkey_button->set_text(configure_config_hotkey.to_string());
configure_hotkey_stop_and_save();
}
@@ -512,7 +580,7 @@ namespace gsr {
if(mgl::Keyboard::key_is_modifier(event.key.code)) {
configure_config_hotkey.modifiers &= ~mgl_modifier_to_hotkey_modifier(event.key.code);
- configure_hotkey_button->set_text(config_hotkey_to_string(configure_config_hotkey));
+ configure_hotkey_button->set_text(configure_config_hotkey.to_string());
}
return false;
@@ -529,12 +597,20 @@ namespace gsr {
return turn_replay_on_off_button_ptr;
case ConfigureHotkeyType::REPLAY_SAVE:
return save_replay_button_ptr;
+ case ConfigureHotkeyType::REPLAY_SAVE_1_MIN:
+ return save_replay_1_min_button_ptr;
+ case ConfigureHotkeyType::REPLAY_SAVE_10_MIN:
+ return save_replay_10_min_button_ptr;
case ConfigureHotkeyType::RECORD_START_STOP:
return start_stop_recording_button_ptr;
case ConfigureHotkeyType::RECORD_PAUSE_UNPAUSE:
return pause_unpause_recording_button_ptr;
case ConfigureHotkeyType::STREAM_START_STOP:
return start_stop_streaming_button_ptr;
+ case ConfigureHotkeyType::TAKE_SCREENSHOT:
+ return take_screenshot_button_ptr;
+ case ConfigureHotkeyType::TAKE_SCREENSHOT_REGION:
+ return take_screenshot_region_button_ptr;
case ConfigureHotkeyType::SHOW_HIDE:
return show_hide_button_ptr;
}
@@ -549,12 +625,20 @@ namespace gsr {
return &config.replay_config.start_stop_hotkey;
case ConfigureHotkeyType::REPLAY_SAVE:
return &config.replay_config.save_hotkey;
+ case ConfigureHotkeyType::REPLAY_SAVE_1_MIN:
+ return &config.replay_config.save_1_min_hotkey;
+ case ConfigureHotkeyType::REPLAY_SAVE_10_MIN:
+ return &config.replay_config.save_10_min_hotkey;
case ConfigureHotkeyType::RECORD_START_STOP:
return &config.record_config.start_stop_hotkey;
case ConfigureHotkeyType::RECORD_PAUSE_UNPAUSE:
return &config.record_config.pause_unpause_hotkey;
case ConfigureHotkeyType::STREAM_START_STOP:
return &config.streaming_config.start_stop_hotkey;
+ case ConfigureHotkeyType::TAKE_SCREENSHOT:
+ return &config.screenshot_config.take_screenshot_hotkey;
+ case ConfigureHotkeyType::TAKE_SCREENSHOT_REGION:
+ return &config.screenshot_config.take_screenshot_region_hotkey;
case ConfigureHotkeyType::SHOW_HIDE:
return &config.main_config.show_hide_hotkey;
}
@@ -568,6 +652,8 @@ namespace gsr {
&config.record_config.start_stop_hotkey,
&config.record_config.pause_unpause_hotkey,
&config.streaming_config.start_stop_hotkey,
+ &config.screenshot_config.take_screenshot_hotkey,
+ &config.screenshot_config.take_screenshot_region_hotkey,
&config.main_config.show_hide_hotkey
};
for(ConfigHotkey *config_hotkey : config_hotkeys) {
@@ -595,6 +681,12 @@ namespace gsr {
case ConfigureHotkeyType::REPLAY_SAVE:
hotkey_configure_action_name = "Save replay";
break;
+ case ConfigureHotkeyType::REPLAY_SAVE_1_MIN:
+ hotkey_configure_action_name = "Save 1 minute replay";
+ break;
+ case ConfigureHotkeyType::REPLAY_SAVE_10_MIN:
+ hotkey_configure_action_name = "Save 10 minute replay";
+ break;
case ConfigureHotkeyType::RECORD_START_STOP:
hotkey_configure_action_name = "Start/stop recording";
break;
@@ -604,6 +696,12 @@ namespace gsr {
case ConfigureHotkeyType::STREAM_START_STOP:
hotkey_configure_action_name = "Start/stop streaming";
break;
+ case ConfigureHotkeyType::TAKE_SCREENSHOT:
+ hotkey_configure_action_name = "Take a screenshot";
+ break;
+ case ConfigureHotkeyType::TAKE_SCREENSHOT_REGION:
+ hotkey_configure_action_name = "Take a screenshot of a region";
+ break;
case ConfigureHotkeyType::SHOW_HIDE:
hotkey_configure_action_name = "Show/hide UI";
break;
@@ -614,7 +712,7 @@ namespace gsr {
Button *config_hotkey_button = configure_hotkey_get_button_by_active_type();
ConfigHotkey *config_hotkey = configure_hotkey_get_config_by_active_type();
if(config_hotkey_button && config_hotkey)
- config_hotkey_button->set_text(config_hotkey_to_string(*config_hotkey));
+ config_hotkey_button->set_text(config_hotkey->to_string());
configure_config_hotkey = {0, 0};
configure_hotkey_type = ConfigureHotkeyType::NONE;
@@ -628,15 +726,17 @@ namespace gsr {
ConfigHotkey *config_hotkey = configure_hotkey_get_config_by_active_type();
if(config_hotkey_button && config_hotkey) {
bool hotkey_used_by_another_action = false;
- for_each_config_hotkey([&](ConfigHotkey *config_hotkey_item) {
- if(config_hotkey_item != config_hotkey && *config_hotkey_item == configure_config_hotkey)
- hotkey_used_by_another_action = true;
- });
+ if(configure_config_hotkey.key != mgl::Keyboard::Unknown) {
+ for_each_config_hotkey([&](ConfigHotkey *config_hotkey_item) {
+ if(config_hotkey_item != config_hotkey && *config_hotkey_item == configure_config_hotkey)
+ hotkey_used_by_another_action = true;
+ });
+ }
if(hotkey_used_by_another_action) {
- const std::string error_msg = "The hotkey \"" + config_hotkey_to_string(configure_config_hotkey) + " is already used for something else";
+ const std::string error_msg = "The hotkey \"" + configure_config_hotkey.to_string() + " is already used for something else";
overlay->show_notification(error_msg.c_str(), 3.0, mgl::Color(255, 0, 0, 255), mgl::Color(255, 0, 0, 255), NotificationType::NONE);
- config_hotkey_button->set_text(config_hotkey_to_string(*config_hotkey));
+ config_hotkey_button->set_text(config_hotkey->to_string());
configure_config_hotkey = {0, 0};
return;
}