aboutsummaryrefslogtreecommitdiff
path: root/include/Config.hpp
blob: 1c828225b12305b0e757c058da47f9bf16145cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

#pragma once

#include <stdint.h>
#include <string>
#include <vector>
#include <optional>

#define GSR_CONFIG_FILE_VERSION 1

namespace gsr {
    struct SupportedCaptureOptions;

    struct ConfigHotkey {
        int64_t key = 0;        // Mgl key
        uint32_t modifiers = 0; // HotkeyModifier

        bool operator==(const ConfigHotkey &other) const;
        bool operator!=(const ConfigHotkey &other) const;

        std::string to_string(bool spaces = true, bool modifier_side = true) const;
    };

    struct RecordOptions {
        std::string record_area_option = "screen";
        int32_t record_area_width = 0;
        int32_t record_area_height = 0;
        int32_t video_width = 0;
        int32_t video_height = 0;
        int32_t fps = 60;
        int32_t video_bitrate = 15000;
        bool merge_audio_tracks = true; // Currently unused for streaming because all known streaming sites only support 1 audio track
        bool application_audio_invert = false;
        bool change_video_resolution = false;
        std::vector<std::string> audio_tracks;
        std::string color_range = "limited";
        std::string video_quality = "very_high";
        std::string video_codec = "auto";
        std::string audio_codec = "opus";
        std::string framerate_mode = "vfr";
        bool advanced_view = false;
        bool overclock = false;
        bool record_cursor = true;
        bool restore_portal_session = true;
    };

    struct MainConfig {
        int32_t config_file_version = GSR_CONFIG_FILE_VERSION;
        bool software_encoding_warning_shown = false;
        std::string hotkeys_enable_option = "enable_hotkeys";
        std::string joystick_hotkeys_enable_option = "disable_hotkeys";
        std::string tint_color;
        ConfigHotkey show_hide_hotkey;
    };

    struct YoutubeStreamConfig {
        std::string stream_key;
    };

    struct TwitchStreamConfig {
        std::string stream_key;
    };

    struct CustomStreamConfig {
        std::string url;
        std::string container = "flv";
    };

    struct StreamingConfig {
        RecordOptions record_options;
        bool show_streaming_started_notifications = true;
        bool show_streaming_stopped_notifications = true;
        std::string streaming_service = "twitch";
        YoutubeStreamConfig youtube;
        TwitchStreamConfig twitch;
        CustomStreamConfig custom;
        ConfigHotkey start_stop_hotkey;
    };

    struct RecordConfig {
        RecordOptions record_options;
        bool save_video_in_game_folder = false;
        bool show_recording_started_notifications = true;
        bool show_video_saved_notifications = true;
        std::string save_directory;
        std::string container = "mp4";
        ConfigHotkey start_stop_hotkey;
        ConfigHotkey pause_unpause_hotkey;
    };

    struct ReplayConfig {
        RecordOptions record_options;
        std::string turn_on_replay_automatically_mode = "dont_turn_on_automatically";
        bool save_video_in_game_folder = false;
        bool restart_replay_on_save = false;
        bool show_replay_started_notifications = true;
        bool show_replay_stopped_notifications = true;
        bool show_replay_saved_notifications = true;
        std::string save_directory;
        std::string container = "mp4";
        int32_t replay_time = 60;
        ConfigHotkey start_stop_hotkey;
        ConfigHotkey save_hotkey;
    };

    struct ScreenshotConfig {
        std::string record_area_option = "screen";
        int32_t image_width = 0;
        int32_t image_height = 0;
        bool change_image_resolution = false;
        std::string image_quality = "very_high";
        std::string image_format = "jpg";
        bool record_cursor = true;
        bool restore_portal_session = true;

        bool save_screenshot_in_game_folder = false;
        bool show_screenshot_saved_notifications = true;
        std::string save_directory;
        ConfigHotkey take_screenshot_hotkey;
    };

    struct Config {
        Config(const SupportedCaptureOptions &capture_options);
        bool operator==(const Config &other);
        bool operator!=(const Config &other);

        void set_hotkeys_to_default();

        MainConfig main_config;
        StreamingConfig streaming_config;
        RecordConfig record_config;
        ReplayConfig replay_config;
        ScreenshotConfig screenshot_config;
    };

    std::optional<Config> read_config(const SupportedCaptureOptions &capture_options);
    void save_config(Config &config);
}