diff options
Diffstat (limited to 'include/gui')
-rw-r--r-- | include/gui/Button.hpp | 7 | ||||
-rw-r--r-- | include/gui/GlobalSettingsPage.hpp | 97 | ||||
-rw-r--r-- | include/gui/RadioButton.hpp | 3 | ||||
-rw-r--r-- | include/gui/SettingsPage.hpp | 66 | ||||
-rw-r--r-- | include/gui/Utils.hpp | 1 |
5 files changed, 145 insertions, 29 deletions
diff --git a/include/gui/Button.hpp b/include/gui/Button.hpp index bc1dd94..eb68e99 100644 --- a/include/gui/Button.hpp +++ b/include/gui/Button.hpp @@ -5,6 +5,7 @@ #include <mglpp/graphics/Color.hpp> #include <mglpp/graphics/Text.hpp> +#include <mglpp/graphics/Sprite.hpp> namespace gsr { class Button : public Widget { @@ -20,15 +21,21 @@ namespace gsr { mgl::vec2f get_size() override; void set_border_scale(float scale); + void set_bg_hover_color(mgl::Color color); + void set_icon(mgl::Texture *texture); const std::string& get_text() const; void set_text(std::string str); std::function<void()> on_click; private: + void scale_sprite_to_button_size(); + private: mgl::vec2f size; mgl::Color bg_color; + mgl::Color bg_hover_color; mgl::Text text; + mgl::Sprite sprite; float border_scale = 0.0015f; }; }
\ No newline at end of file diff --git a/include/gui/GlobalSettingsPage.hpp b/include/gui/GlobalSettingsPage.hpp new file mode 100644 index 0000000..580e943 --- /dev/null +++ b/include/gui/GlobalSettingsPage.hpp @@ -0,0 +1,97 @@ +#pragma once + +#include "StaticPage.hpp" +#include "../GsrInfo.hpp" +#include "../Config.hpp" + +#include <functional> +#include <mglpp/window/Event.hpp> + +namespace gsr { + class Overlay; + class GsrPage; + class PageStack; + class ScrollablePage; + class Subsection; + class RadioButton; + class Button; + class List; + class CustomRendererWidget; + + enum ConfigureHotkeyType { + NONE, + REPLAY_START_STOP, + REPLAY_SAVE, + RECORD_START_STOP, + RECORD_PAUSE_UNPAUSE, + STREAM_START_STOP, + SHOW_HIDE + }; + + class GlobalSettingsPage : public StaticPage { + public: + GlobalSettingsPage(Overlay *overlay, const GsrInfo *gsr_info, Config &config, PageStack *page_stack); + GlobalSettingsPage(const GlobalSettingsPage&) = delete; + GlobalSettingsPage& operator=(const GlobalSettingsPage&) = delete; + + void load(); + void save(); + void on_navigate_away_from_page() override; + + bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override; + + std::function<void(bool enable, int exit_status)> on_startup_changed; + std::function<void(const char *reason)> on_click_exit_program_button; + std::function<void(const char *hotkey_option)> on_keyboard_hotkey_changed; + std::function<void(const char *hotkey_option)> on_joystick_hotkey_changed; + private: + void load_hotkeys(); + + std::unique_ptr<Subsection> create_appearance_subsection(ScrollablePage *parent_page); + std::unique_ptr<Subsection> create_startup_subsection(ScrollablePage *parent_page); + std::unique_ptr<RadioButton> create_enable_keyboard_hotkeys_button(); + std::unique_ptr<RadioButton> create_enable_joystick_hotkeys_button(); + std::unique_ptr<List> create_show_hide_hotkey_options(); + std::unique_ptr<List> create_replay_hotkey_options(); + std::unique_ptr<List> create_record_hotkey_options(); + std::unique_ptr<List> create_stream_hotkey_options(); + std::unique_ptr<List> create_hotkey_control_buttons(); + std::unique_ptr<Subsection> create_hotkey_subsection(ScrollablePage *parent_page); + std::unique_ptr<Button> create_exit_program_button(); + std::unique_ptr<Button> create_go_back_to_old_ui_button(); + std::unique_ptr<Subsection> create_application_options_subsection(ScrollablePage *parent_page); + std::unique_ptr<Subsection> create_application_info_subsection(ScrollablePage *parent_page); + void add_widgets(); + + Button* configure_hotkey_get_button_by_active_type(); + ConfigHotkey* configure_hotkey_get_config_by_active_type(); + void for_each_config_hotkey(std::function<void(ConfigHotkey *config_hotkey)> callback); + void configure_hotkey_start(ConfigureHotkeyType hotkey_type); + void configure_hotkey_cancel(); + void configure_hotkey_stop_and_save(); + private: + Overlay *overlay = nullptr; + Config &config; + const GsrInfo *gsr_info = nullptr; + + GsrPage *content_page_ptr = nullptr; + PageStack *page_stack = nullptr; + RadioButton *tint_color_radio_button_ptr = nullptr; + RadioButton *startup_radio_button_ptr = nullptr; + RadioButton *enable_keyboard_hotkeys_radio_button_ptr = nullptr; + RadioButton *enable_joystick_hotkeys_radio_button_ptr = nullptr; + + Button *turn_replay_on_off_button_ptr = nullptr; + Button *save_replay_button_ptr = nullptr; + Button *start_stop_recording_button_ptr = nullptr; + Button *pause_unpause_recording_button_ptr = nullptr; + Button *start_stop_streaming_button_ptr = nullptr; + Button *show_hide_button_ptr = nullptr; + + ConfigHotkey configure_config_hotkey; + ConfigureHotkeyType configure_hotkey_type = ConfigureHotkeyType::NONE; + + CustomRendererWidget *hotkey_overlay_ptr = nullptr; + std::string hotkey_configure_action_name; + }; +}
\ No newline at end of file diff --git a/include/gui/RadioButton.hpp b/include/gui/RadioButton.hpp index a009eab..16d638e 100644 --- a/include/gui/RadioButton.hpp +++ b/include/gui/RadioButton.hpp @@ -27,7 +27,8 @@ namespace gsr { mgl::vec2f get_size() override; - std::function<void(const std::string &text, const std::string &id)> on_selection_changed; + // Return false to revert the change + std::function<bool(const std::string &text, const std::string &id)> on_selection_changed; private: void update_if_dirty(); private: diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp index f18ff65..ad5f05a 100644 --- a/include/gui/SettingsPage.hpp +++ b/include/gui/SettingsPage.hpp @@ -10,6 +10,8 @@ #include "../GsrInfo.hpp" #include "../Config.hpp" +#include <functional> + namespace gsr { class GsrPage; class PageStack; @@ -25,17 +27,19 @@ namespace gsr { STREAM }; - SettingsPage(Type type, const GsrInfo &gsr_info, Config &config, PageStack *page_stack); + SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack); SettingsPage(const SettingsPage&) = delete; SettingsPage& operator=(const SettingsPage&) = delete; - void load(const GsrInfo &gsr_info); + void load(); void save(); void on_navigate_away_from_page() override; + + std::function<void()> on_config_changed; private: std::unique_ptr<RadioButton> create_view_radio_button(); - std::unique_ptr<ComboBox> create_record_area_box(const GsrInfo &gsr_info); - std::unique_ptr<Widget> create_record_area(const GsrInfo &gsr_info); + std::unique_ptr<ComboBox> create_record_area_box(); + std::unique_ptr<Widget> create_record_area(); std::unique_ptr<List> create_select_window(); std::unique_ptr<Entry> create_area_width_entry(); std::unique_ptr<Entry> create_area_height_entry(); @@ -48,7 +52,7 @@ namespace gsr { std::unique_ptr<CheckBox> create_restore_portal_session_checkbox(); std::unique_ptr<List> create_restore_portal_session_section(); std::unique_ptr<Widget> create_change_video_resolution_section(); - std::unique_ptr<Widget> create_capture_target(const GsrInfo &gsr_info); + std::unique_ptr<Widget> create_capture_target(); std::unique_ptr<ComboBox> create_audio_device_selection_combobox(); std::unique_ptr<Button> create_remove_audio_device_button(List *audio_device_list_ptr); std::unique_ptr<List> create_audio_device(); @@ -65,13 +69,13 @@ namespace gsr { std::unique_ptr<Widget> create_audio_track_section(); std::unique_ptr<Widget> create_audio_section(); std::unique_ptr<List> create_video_quality_box(); - std::unique_ptr<Entry> create_video_bitrate_entry(); + std::unique_ptr<List> create_video_bitrate_entry(); std::unique_ptr<List> create_video_bitrate(); std::unique_ptr<ComboBox> create_color_range_box(); std::unique_ptr<List> create_color_range(); std::unique_ptr<List> create_video_quality_section(); - std::unique_ptr<ComboBox> create_video_codec_box(const GsrInfo &gsr_info); - std::unique_ptr<List> create_video_codec(const GsrInfo &gsr_info); + std::unique_ptr<ComboBox> create_video_codec_box(); + std::unique_ptr<List> create_video_codec(); std::unique_ptr<ComboBox> create_audio_codec_box(); std::unique_ptr<List> create_audio_codec(); std::unique_ptr<Entry> create_framerate_entry(); @@ -80,24 +84,28 @@ namespace gsr { std::unique_ptr<List> create_framerate_mode(); std::unique_ptr<List> create_framerate_section(); std::unique_ptr<Widget> create_record_cursor_section(); - std::unique_ptr<Widget> create_video_section(const GsrInfo &gsr_info); - std::unique_ptr<Widget> create_settings(const GsrInfo &gsr_info); - void add_widgets(const GsrInfo &gsr_info); + std::unique_ptr<Widget> create_video_section(); + std::unique_ptr<Widget> create_settings(); + void add_widgets(); - void add_page_specific_widgets(const GsrInfo &gsr_info); + void add_page_specific_widgets(); std::unique_ptr<List> create_save_directory(const char *label); std::unique_ptr<ComboBox> create_container_box(); std::unique_ptr<List> create_container_section(); - std::unique_ptr<Entry> create_replay_time_entry(); + std::unique_ptr<List> create_replay_time_entry(); std::unique_ptr<List> create_replay_time(); - std::unique_ptr<RadioButton> create_start_replay_automatically(const GsrInfo &gsr_info); - std::unique_ptr<CheckBox> create_save_replay_in_game_folder(const GsrInfo &gsr_info); - std::unique_ptr<Label> create_estimated_file_size(); - void update_estimated_file_size(); - std::unique_ptr<CheckBox> create_save_recording_in_game_folder(const GsrInfo &gsr_info); - void add_replay_widgets(const GsrInfo &gsr_info); - void add_record_widgets(const GsrInfo &gsr_info); + std::unique_ptr<RadioButton> create_start_replay_automatically(); + std::unique_ptr<CheckBox> create_save_replay_in_game_folder(); + std::unique_ptr<CheckBox> create_restart_replay_on_save(); + std::unique_ptr<Label> create_estimated_replay_file_size(); + void update_estimated_replay_file_size(); + void update_replay_time_text(); + std::unique_ptr<CheckBox> create_save_recording_in_game_folder(); + std::unique_ptr<Label> create_estimated_record_file_size(); + void update_estimated_record_file_size(); + void add_replay_widgets(); + void add_record_widgets(); std::unique_ptr<ComboBox> create_streaming_service_box(); std::unique_ptr<List> create_streaming_service_section(); @@ -105,13 +113,13 @@ namespace gsr { std::unique_ptr<List> create_stream_url_section(); std::unique_ptr<ComboBox> create_stream_container_box(); std::unique_ptr<List> create_stream_container_section(); - void add_stream_widgets(const GsrInfo &gsr_info); + void add_stream_widgets(); - void load_audio_tracks(const RecordOptions &record_options, const GsrInfo &gsr_info); - void load_common(RecordOptions &record_options, const GsrInfo &gsr_info); - void load_replay(const GsrInfo &gsr_info); - void load_record(const GsrInfo &gsr_info); - void load_stream(const GsrInfo &gsr_info); + void load_audio_tracks(const RecordOptions &record_options); + void load_common(RecordOptions &record_options); + void load_replay(); + void load_record(); + void load_stream(); void save_common(RecordOptions &record_options); void save_replay(); @@ -120,8 +128,10 @@ namespace gsr { private: Type type; Config &config; + const GsrInfo *gsr_info = nullptr; std::vector<AudioDevice> audio_devices; std::vector<std::string> application_audio; + SupportedCaptureOptions capture_options; GsrPage *content_page_ptr = nullptr; ScrollablePage *settings_scrollable_page_ptr = nullptr; @@ -162,6 +172,7 @@ namespace gsr { List *stream_url_list_ptr = nullptr; List *container_list_ptr = nullptr; CheckBox *save_replay_in_game_folder_ptr = nullptr; + CheckBox *restart_replay_on_save = nullptr; Label *estimated_file_size_ptr = nullptr; CheckBox *show_replay_started_notification_checkbox_ptr = nullptr; CheckBox *show_replay_stopped_notification_checkbox_ptr = nullptr; @@ -176,10 +187,9 @@ namespace gsr { Entry *youtube_stream_key_entry_ptr = nullptr; Entry *stream_url_entry_ptr = nullptr; Entry *replay_time_entry_ptr = nullptr; + Label *replay_time_label_ptr = nullptr; RadioButton *turn_on_replay_automatically_mode_ptr = nullptr; PageStack *page_stack = nullptr; - - mgl::Text settings_title_text; }; }
\ No newline at end of file diff --git a/include/gui/Utils.hpp b/include/gui/Utils.hpp index 6963bc5..35b2bb7 100644 --- a/include/gui/Utils.hpp +++ b/include/gui/Utils.hpp @@ -15,4 +15,5 @@ namespace gsr { void draw_rectangle_outline(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, mgl::Color color, float border_size); double get_frame_delta_seconds(); void set_frame_delta_seconds(double frame_delta); + mgl::vec2f scale_keep_aspect_ratio(mgl::vec2f from, mgl::vec2f to); }
\ No newline at end of file |