Create Video Settings submenu

This commit is contained in:
Lorenzooone 2024-05-14 18:56:11 +02:00
parent daa7137872
commit ae93229394
8 changed files with 410 additions and 224 deletions

View File

@ -132,7 +132,7 @@ file(MAKE_DIRECTORY ${TOOLS_DATA_DIR})
set(OUTPUT_NAME cc3dsfs)
add_executable(CMakeBin2C tools/bin2c.cpp)
add_executable(${OUTPUT_NAME} source/cc3dsfs.cpp source/utils.cpp source/audio_data.cpp source/audio.cpp source/frontend.cpp source/TextRectangle.cpp source/WindowScreen.cpp source/3dscapture.cpp source/conversions.cpp source/ConnectionMenu.cpp source/OptionSelectionMenu.cpp source/MainMenu.cpp ${TOOLS_DATA_DIR}/font_ttf.cpp)
add_executable(${OUTPUT_NAME} source/cc3dsfs.cpp source/utils.cpp source/audio_data.cpp source/audio.cpp source/frontend.cpp source/TextRectangle.cpp source/WindowScreen.cpp source/3dscapture.cpp source/conversions.cpp source/ConnectionMenu.cpp source/OptionSelectionMenu.cpp source/MainMenu.cpp source/VideoMenu.cpp ${TOOLS_DATA_DIR}/font_ttf.cpp)
add_dependencies(${OUTPUT_NAME} FTD3XX_BUILD_PROJECT CMakeBin2C)
target_link_libraries(${OUTPUT_NAME} PRIVATE sfml-graphics sfml-audio sfml-window sfml-system ${ftd3xx_BINARY_DIR}/${FTD3XX_SUBFOLDER}/${FTD3XX_LIB})
target_link_directories(${OUTPUT_NAME} PRIVATE ${ftd3xx_BINARY_DIR}/${FTD3XX_SUBFOLDER})

View File

@ -15,32 +15,13 @@ enum MainMenuOutAction{
MAIN_MENU_QUIT_APPLICATION,
MAIN_MENU_FULLSCREEN,
MAIN_MENU_SPLIT,
MAIN_MENU_VSYNC,
MAIN_MENU_ASYNC,
MAIN_MENU_BLUR,
MAIN_MENU_PADDING,
MAIN_MENU_CROPPING,
MAIN_MENU_TOP_PAR,
MAIN_MENU_BOT_PAR,
MAIN_MENU_ONE_PAR,
MAIN_MENU_BOTTOM_SCREEN_POS,
MAIN_MENU_SMALL_SCREEN_OFFSET,
MAIN_MENU_SMALL_SCREEN_DISTANCE,
MAIN_MENU_SCREENS_X_POS,
MAIN_MENU_SCREENS_Y_POS,
MAIN_MENU_WINDOW_SCALING,
MAIN_MENU_FULLSCREEN_SCALING,
MAIN_MENU_BFI_SETTINGS,
MAIN_MENU_MENU_SCALING,
MAIN_MENU_RESOLUTION_SETTINGS,
MAIN_MENU_VIDEO_SETTINGS,
MAIN_MENU_AUDIO_SETTINGS,
MAIN_MENU_SAVE_PROFILES,
MAIN_MENU_LOAD_PROFILES,
MAIN_MENU_STATUS,
MAIN_MENU_LICENSES,
MAIN_MENU_EXTRA_SETTINGS,
MAIN_MENU_TOP_ROTATION,
MAIN_MENU_BOTTOM_ROTATION,
MAIN_MENU_SHUTDOWN,
};
@ -48,7 +29,7 @@ class MainMenu : public OptionSelectionMenu {
public:
MainMenu(bool font_load_success, sf::Font &text_font);
~MainMenu();
void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info, bool connected);
void prepare(float scaling_factor, int view_size_x, int view_size_y, bool connected);
void insert_data(ScreenType s_type, bool is_fullscreen);
MainMenuOutAction selected_index = MainMenuOutAction::MAIN_MENU_NO_ACTION;
protected:

53
include/VideoMenu.hpp Executable file
View File

@ -0,0 +1,53 @@
#ifndef __VIDEOMENU_HPP
#define __VIDEOMENU_HPP
#include "OptionSelectionMenu.hpp"
#include <chrono>
#include "TextRectangle.hpp"
#include "sfml_gfx_structs.hpp"
#include "display_structs.hpp"
enum VideoMenuOutAction{
VIDEO_MENU_NO_ACTION,
VIDEO_MENU_BACK,
VIDEO_MENU_VSYNC,
VIDEO_MENU_ASYNC,
VIDEO_MENU_BLUR,
VIDEO_MENU_PADDING,
VIDEO_MENU_CROPPING,
VIDEO_MENU_TOP_PAR,
VIDEO_MENU_BOT_PAR,
VIDEO_MENU_ONE_PAR,
VIDEO_MENU_BOTTOM_SCREEN_POS,
VIDEO_MENU_SMALL_SCREEN_OFFSET,
VIDEO_MENU_SMALL_SCREEN_DISTANCE,
VIDEO_MENU_SCREENS_X_POS,
VIDEO_MENU_SCREENS_Y_POS,
VIDEO_MENU_WINDOW_SCALING,
VIDEO_MENU_FULLSCREEN_SCALING,
VIDEO_MENU_BFI_SETTINGS,
VIDEO_MENU_MENU_SCALING,
VIDEO_MENU_RESOLUTION_SETTINGS,
VIDEO_MENU_TOP_ROTATION,
VIDEO_MENU_BOTTOM_ROTATION,
};
class VideoMenu : public OptionSelectionMenu {
public:
VideoMenu(bool font_load_success, sf::Font &text_font);
~VideoMenu();
void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info);
void insert_data(ScreenType s_type, bool is_fullscreen);
VideoMenuOutAction selected_index = VideoMenuOutAction::VIDEO_MENU_NO_ACTION;
protected:
void reset_output_option();
void set_output_option(int index);
int get_num_options();
std::string get_string_option(int index);
void class_setup();
private:
int *options_indexes;
int num_enabled_options;
};
#endif

View File

@ -7,7 +7,7 @@
enum ScreenType { TOP, BOTTOM, JOINT };
enum BottomRelativePosition { UNDER_TOP, LEFT_TOP, ABOVE_TOP, RIGHT_TOP, BOT_REL_POS_END };
enum OffsetAlgorithm { NO_DISTANCE, HALF_DISTANCE, MAX_DISTANCE, OFF_ALGO_END };
enum CurrMenuType { DEFAULT_MENU_TYPE, CONNECT_MENU_TYPE, MAIN_MENU_TYPE };
enum CurrMenuType { DEFAULT_MENU_TYPE, CONNECT_MENU_TYPE, MAIN_MENU_TYPE, VIDEO_MENU_TYPE, AUDIO_MENU_TYPE };
struct ScreenInfo {
bool is_blurred;

View File

@ -14,6 +14,7 @@
#include "sfml_gfx_structs.hpp"
#include "ConnectionMenu.hpp"
#include "MainMenu.hpp"
#include "VideoMenu.hpp"
#include "display_structs.hpp"
class WindowScreen {
@ -78,6 +79,7 @@ private:
CurrMenuType loaded_menu;
ConnectionMenu *connection_menu;
MainMenu *main_menu;
VideoMenu *video_menu;
std::vector<const CropData*> possible_crops;
std::vector<const PARData*> possible_pars;
@ -152,6 +154,7 @@ private:
void crop();
void setWinSize(bool is_main_thread);
void setup_main_menu();
void setup_video_menu();
void update_connection();
};

View File

@ -51,29 +51,11 @@ static const MainMenuOptionInfo split_screens_option = {
.active_joint_screen = OPTION_SPLIT, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_SPLIT};
static const MainMenuOptionInfo vsync_option = {
.base_name = "Turn VSync Off", .false_name = "Turn VSync On",
static const MainMenuOptionInfo video_settings_option = {
.base_name = "Video Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_VSYNC};
static const MainMenuOptionInfo async_option = {
.base_name = "Turn Async Off", .false_name = "Turn Async On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_ASYNC};
static const MainMenuOptionInfo blur_option = {
.base_name = "Turn Blur Off", .false_name = "Turn Blur On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_BLUR};
static const MainMenuOptionInfo padding_option = {
.base_name = "Turn Padding Off", .false_name = "Turn Padding On",
.active_fullscreen = false, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_PADDING};
.out_action = MAIN_MENU_VIDEO_SETTINGS};
static const MainMenuOptionInfo quit_option = {
.base_name = "Quit Application", .false_name = "",
@ -87,90 +69,6 @@ static const MainMenuOptionInfo shutdown_option = {
.active_joint_screen = OPTION_SHUTDOWN, .active_top_screen = OPTION_SHUTDOWN, .active_bottom_screen = OPTION_SHUTDOWN,
.out_action = MAIN_MENU_SHUTDOWN};
static const MainMenuOptionInfo crop_option = {
.base_name = "Crop Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_CROPPING};
static const MainMenuOptionInfo top_par_option = {
.base_name = "Top Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_TOP_PAR};
static const MainMenuOptionInfo bot_par_option = {
.base_name = "Bottom Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_BOT_PAR};
static const MainMenuOptionInfo one_par_option = {
.base_name = "Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_ONE_PAR};
static const MainMenuOptionInfo bottom_screen_pos_option = {
.base_name = "Bottom Screen Pos.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_BOTTOM_SCREEN_POS};
static const MainMenuOptionInfo small_screen_offset_option = {
.base_name = "Smaller Screen Offset", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_SMALL_SCREEN_OFFSET};
static const MainMenuOptionInfo subscreen_distance_option = {
.base_name = "Sub-Screen Distance", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_SMALL_SCREEN_DISTANCE};
static const MainMenuOptionInfo canvas_x_pos_option = {
.base_name = "Canvas X Position", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_SCREENS_X_POS};
static const MainMenuOptionInfo canvas_y_pos_option = {
.base_name = "Canvas Y Position", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_SCREENS_Y_POS};
static const MainMenuOptionInfo window_scaling_option = {
.base_name = "Scaling Factor", .false_name = "",
.active_fullscreen = false, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_WINDOW_SCALING};
static const MainMenuOptionInfo fullscreen_scaling_option = {
.base_name = "Screens Scaling", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_FULLSCREEN_SCALING};
static const MainMenuOptionInfo bfi_settings_option = {
.base_name = "BFI Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_BFI_SETTINGS};
static const MainMenuOptionInfo menu_scaling_option = {
.base_name = "Menu Scaling", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_MENU_SCALING};
static const MainMenuOptionInfo resolution_settings_option = {
.base_name = "Resolution Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = MAIN_MENU_RESOLUTION_SETTINGS};
static const MainMenuOptionInfo audio_settings_option = {
.base_name = "Audio Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
@ -207,58 +105,13 @@ static const MainMenuOptionInfo extra_settings_option = {
.active_joint_screen = OPTION_EXTRA, .active_top_screen = OPTION_EXTRA, .active_bottom_screen = OPTION_EXTRA,
.out_action = MAIN_MENU_EXTRA_SETTINGS};
static const MainMenuOptionInfo top_rotation_option = {
.base_name = "Top Screen Rot.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_TOP_ROTATION};
static const MainMenuOptionInfo bottom_rotation_option = {
.base_name = "Bottom Screen Rot.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = MAIN_MENU_BOTTOM_ROTATION};
static const MainMenuOptionInfo top_one_rotation_option = {
.base_name = "Screen Rotation", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = true, .active_bottom_screen = false,
.out_action = MAIN_MENU_TOP_ROTATION};
static const MainMenuOptionInfo bottom_one_rotation_option = {
.base_name = "Screen Rotation", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = false, .active_bottom_screen = true,
.out_action = MAIN_MENU_BOTTOM_ROTATION};
static const MainMenuOptionInfo* pollable_options[] = {
&connect_option,
&windowed_option,
&fullscreen_option,
&join_screens_option,
&split_screens_option,
&crop_option,
&top_par_option,
&bot_par_option,
&one_par_option,
&vsync_option,
&async_option,
&blur_option,
&bottom_screen_pos_option,
&small_screen_offset_option,
&subscreen_distance_option,
&canvas_x_pos_option,
&canvas_y_pos_option,
&top_rotation_option,
&bottom_rotation_option,
&top_one_rotation_option,
&bottom_one_rotation_option,
&window_scaling_option,
&fullscreen_scaling_option,
&menu_scaling_option,
&resolution_settings_option,
&padding_option,
&bfi_settings_option,
&video_settings_option,
&audio_settings_option,
&save_profiles_option,
&load_profiles_option,
@ -342,23 +195,7 @@ static std::string setTextOptionBool(int option_index, bool value) {
return pollable_options[option_index]->false_name;
}
static std::string setTextOptionFloat(int option_index, float value) {
return pollable_options[option_index]->base_name + ": " + get_float_str_decimals(value, 1);
}
static std::string setTextOptionInt(int option_index, int value) {
return pollable_options[option_index]->base_name + ": " + std::to_string(value);
}
static std::string setTextOptionDualPercentage(int option_index, int value_1, int value_2) {
int sum = value_1 + value_2;
value_1 = ((value_1 * 100) + (sum / 2)) / sum;
value_2 = ((value_2 * 100) + (sum / 2)) / sum;
value_1 += 100 - (value_1 + value_2);
return pollable_options[option_index]->base_name + ": " + std::to_string(value_1) + " - " + std::to_string(value_2);
}
void MainMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info, bool connected) {
void MainMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, bool connected) {
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
@ -372,33 +209,6 @@ void MainMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size
case MAIN_MENU_OPEN:
this->labels[index]->setText(setTextOptionBool(option_index, connected));
break;
case MAIN_MENU_VSYNC:
this->labels[index]->setText(setTextOptionBool(option_index, info->v_sync_enabled));
break;
case MAIN_MENU_ASYNC:
this->labels[index]->setText(setTextOptionBool(option_index, info->async));
break;
case MAIN_MENU_BLUR:
this->labels[index]->setText(setTextOptionBool(option_index, info->is_blurred));
break;
case MAIN_MENU_PADDING:
this->labels[index]->setText(setTextOptionBool(option_index, info->rounded_corners_fix));
break;
case MAIN_MENU_WINDOW_SCALING:
this->labels[index]->setText(setTextOptionFloat(option_index, info->scaling));
break;
case MAIN_MENU_MENU_SCALING:
this->labels[index]->setText(setTextOptionFloat(option_index, info->menu_scaling_factor));
break;
case MAIN_MENU_FULLSCREEN_SCALING:
this->labels[index]->setText(setTextOptionDualPercentage(option_index, info->top_scaling, info->bot_scaling));
break;
case MAIN_MENU_TOP_ROTATION:
this->labels[index]->setText(setTextOptionInt(option_index, info->top_rotation));
break;
case MAIN_MENU_BOTTOM_ROTATION:
this->labels[index]->setText(setTextOptionInt(option_index, info->bot_rotation));
break;
default:
break;
}

306
source/VideoMenu.cpp Executable file
View File

@ -0,0 +1,306 @@
#include "VideoMenu.hpp"
#define NUM_TOTAL_VIDEO_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0]))
struct VideoMenuOptionInfo {
const std::string base_name;
const std::string false_name;
const bool active_fullscreen;
const bool active_windowed_screen;
const bool active_joint_screen;
const bool active_top_screen;
const bool active_bottom_screen;
const VideoMenuOutAction out_action;
};
static const VideoMenuOptionInfo vsync_option = {
.base_name = "Turn VSync Off", .false_name = "Turn VSync On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_VSYNC};
static const VideoMenuOptionInfo async_option = {
.base_name = "Turn Async Off", .false_name = "Turn Async On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_ASYNC};
static const VideoMenuOptionInfo blur_option = {
.base_name = "Turn Blur Off", .false_name = "Turn Blur On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_BLUR};
static const VideoMenuOptionInfo padding_option = {
.base_name = "Turn Padding Off", .false_name = "Turn Padding On",
.active_fullscreen = false, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_PADDING};
static const VideoMenuOptionInfo crop_option = {
.base_name = "Crop Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_CROPPING};
static const VideoMenuOptionInfo top_par_option = {
.base_name = "Top Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_TOP_PAR};
static const VideoMenuOptionInfo bot_par_option = {
.base_name = "Bottom Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_BOT_PAR};
static const VideoMenuOptionInfo one_par_option = {
.base_name = "Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_ONE_PAR};
static const VideoMenuOptionInfo bottom_screen_pos_option = {
.base_name = "Bottom Screen Pos.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_BOTTOM_SCREEN_POS};
static const VideoMenuOptionInfo small_screen_offset_option = {
.base_name = "Smaller Screen Offset", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_SMALL_SCREEN_OFFSET};
static const VideoMenuOptionInfo subscreen_distance_option = {
.base_name = "Sub-Screen Distance", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_SMALL_SCREEN_DISTANCE};
static const VideoMenuOptionInfo canvas_x_pos_option = {
.base_name = "Canvas X Position", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_SCREENS_X_POS};
static const VideoMenuOptionInfo canvas_y_pos_option = {
.base_name = "Canvas Y Position", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_SCREENS_Y_POS};
static const VideoMenuOptionInfo window_scaling_option = {
.base_name = "Scaling Factor", .false_name = "",
.active_fullscreen = false, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_WINDOW_SCALING};
static const VideoMenuOptionInfo fullscreen_scaling_option = {
.base_name = "Screens Scaling", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_FULLSCREEN_SCALING};
static const VideoMenuOptionInfo bfi_settings_option = {
.base_name = "BFI Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_BFI_SETTINGS};
static const VideoMenuOptionInfo menu_scaling_option = {
.base_name = "Menu Scaling", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_MENU_SCALING};
static const VideoMenuOptionInfo resolution_settings_option = {
.base_name = "Resolution Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_RESOLUTION_SETTINGS};
static const VideoMenuOptionInfo top_rotation_option = {
.base_name = "Top Screen Rot.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_TOP_ROTATION};
static const VideoMenuOptionInfo bottom_rotation_option = {
.base_name = "Bottom Screen Rot.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_BOTTOM_ROTATION};
static const VideoMenuOptionInfo top_one_rotation_option = {
.base_name = "Screen Rotation", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = true, .active_bottom_screen = false,
.out_action = VIDEO_MENU_TOP_ROTATION};
static const VideoMenuOptionInfo bottom_one_rotation_option = {
.base_name = "Screen Rotation", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = false, .active_bottom_screen = true,
.out_action = VIDEO_MENU_BOTTOM_ROTATION};
static const VideoMenuOptionInfo* pollable_options[] = {
&crop_option,
&top_par_option,
&bot_par_option,
&one_par_option,
&vsync_option,
&async_option,
&blur_option,
&bottom_screen_pos_option,
&small_screen_offset_option,
&subscreen_distance_option,
&canvas_x_pos_option,
&canvas_y_pos_option,
&top_rotation_option,
&bottom_rotation_option,
&top_one_rotation_option,
&bottom_one_rotation_option,
&window_scaling_option,
&fullscreen_scaling_option,
&menu_scaling_option,
&resolution_settings_option,
&padding_option,
&bfi_settings_option,
};
VideoMenu::VideoMenu(bool font_load_success, sf::Font &text_font) : OptionSelectionMenu(){
this->options_indexes = new int[NUM_TOTAL_VIDEO_MENU_OPTIONS];
this->initialize(font_load_success, text_font);
this->num_enabled_options = 0;
}
VideoMenu::~VideoMenu() {
delete []this->options_indexes;
}
void VideoMenu::class_setup() {
this->num_elements_per_screen = 5;
this->min_elements_text_scaling_factor = num_elements_per_screen + 2;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 12;
this->base_height_divisor_menu = 6;
this->min_text_size = 0.3;
this->max_width_slack = 1.1;
this->menu_color = sf::Color(30, 30, 60, 192);
this->title = "Video Settings";
this->show_back_x = true;
this->show_x = false;
this->show_title = true;
}
void VideoMenu::insert_data(ScreenType s_type, bool is_fullscreen) {
this->num_enabled_options = 0;
for(int i = 0; i < NUM_TOTAL_VIDEO_MENU_OPTIONS; i++) {
bool valid = true;
if(is_fullscreen)
valid = valid && pollable_options[i]->active_fullscreen;
else
valid = valid && pollable_options[i]->active_windowed_screen;
if(s_type == ScreenType::TOP)
valid = valid && pollable_options[i]->active_top_screen;
else if(s_type == ScreenType::BOTTOM)
valid = valid && pollable_options[i]->active_bottom_screen;
else
valid = valid && pollable_options[i]->active_joint_screen;
if(valid) {
this->options_indexes[this->num_enabled_options] = i;
this->num_enabled_options++;
}
}
this->prepare_options();
}
void VideoMenu::reset_output_option() {
this->selected_index = VideoMenuOutAction::VIDEO_MENU_NO_ACTION;
}
void VideoMenu::set_output_option(int index) {
if(index == -1)
this->selected_index = VIDEO_MENU_BACK;
else
this->selected_index = pollable_options[this->options_indexes[index]]->out_action;
}
int VideoMenu::get_num_options() {
return this->num_enabled_options;
}
std::string VideoMenu::get_string_option(int index) {
return pollable_options[this->options_indexes[index]]->base_name;
}
static std::string setTextOptionBool(int option_index, bool value) {
if(value)
return pollable_options[option_index]->base_name;
return pollable_options[option_index]->false_name;
}
static std::string setTextOptionFloat(int option_index, float value) {
return pollable_options[option_index]->base_name + ": " + get_float_str_decimals(value, 1);
}
static std::string setTextOptionInt(int option_index, int value) {
return pollable_options[option_index]->base_name + ": " + std::to_string(value);
}
static std::string setTextOptionDualPercentage(int option_index, int value_1, int value_2) {
int sum = value_1 + value_2;
value_1 = ((value_1 * 100) + (sum / 2)) / sum;
value_2 = ((value_2 * 100) + (sum / 2)) / sum;
value_1 += 100 - (value_1 + value_2);
return pollable_options[option_index]->base_name + ": " + std::to_string(value_1) + " - " + std::to_string(value_2);
}
void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info) {
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
int start = this->future_data.page * this->num_elements_per_screen;
for(int i = 0; i < this->num_elements_per_screen; i++) {
int index = i + this->elements_start_id;
if(!this->future_enabled_labels[index])
continue;
int option_index = this->options_indexes[start + i];
switch(pollable_options[option_index]->out_action) {
case VIDEO_MENU_VSYNC:
this->labels[index]->setText(setTextOptionBool(option_index, info->v_sync_enabled));
break;
case VIDEO_MENU_ASYNC:
this->labels[index]->setText(setTextOptionBool(option_index, info->async));
break;
case VIDEO_MENU_BLUR:
this->labels[index]->setText(setTextOptionBool(option_index, info->is_blurred));
break;
case VIDEO_MENU_PADDING:
this->labels[index]->setText(setTextOptionBool(option_index, info->rounded_corners_fix));
break;
case VIDEO_MENU_WINDOW_SCALING:
this->labels[index]->setText(setTextOptionFloat(option_index, info->scaling));
break;
case VIDEO_MENU_MENU_SCALING:
this->labels[index]->setText(setTextOptionFloat(option_index, info->menu_scaling_factor));
break;
case VIDEO_MENU_FULLSCREEN_SCALING:
this->labels[index]->setText(setTextOptionDualPercentage(option_index, info->top_scaling, info->bot_scaling));
break;
case VIDEO_MENU_TOP_ROTATION:
this->labels[index]->setText(setTextOptionInt(option_index, info->top_rotation));
break;
case VIDEO_MENU_BOTTOM_ROTATION:
this->labels[index]->setText(setTextOptionInt(option_index, info->bot_rotation));
break;
default:
break;
}
}
this->base_prepare(menu_scaling_factor, view_size_x, view_size_y);
}

View File

@ -22,6 +22,7 @@ WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, Disp
this->notification = new TextRectangle(this->font_load_success, this->text_font);
this->connection_menu = new ConnectionMenu(this->font_load_success, this->text_font);
this->main_menu = new MainMenu(this->font_load_success, this->text_font);
this->video_menu = new VideoMenu(this->font_load_success, this->text_font);
this->in_tex.create(IN_VIDEO_WIDTH, IN_VIDEO_HEIGHT);
this->m_in_rect_top.setTexture(&this->in_tex);
this->m_in_rect_bot.setTexture(&this->in_tex);
@ -49,6 +50,7 @@ WindowScreen::~WindowScreen() {
delete this->notification;
delete this->connection_menu;
delete this->main_menu;
delete this->video_menu;
}
void WindowScreen::build() {
@ -252,6 +254,14 @@ void WindowScreen::setup_main_menu() {
}
}
void WindowScreen::setup_video_menu() {
if(this->curr_menu != VIDEO_MENU_TYPE) {
this->curr_menu = VIDEO_MENU_TYPE;
this->video_menu->reset_data();
this->video_menu->insert_data(this->m_stype, this->m_info.is_fullscreen);
}
}
bool WindowScreen::no_menu_poll(SFEvent &event_data) {
bool consumed = true;
switch(event_data.type) {
@ -557,22 +567,39 @@ void WindowScreen::poll() {
this->split_change();
return;
break;
case MAIN_MENU_VSYNC:
case MAIN_MENU_VIDEO_SETTINGS:
this->setup_video_menu();
return;
default:
break;
}
this->main_menu->selected_index = MAIN_MENU_NO_ACTION;
continue;
}
break;
case VIDEO_MENU_TYPE:
if(this->video_menu->poll(event_data)) {
switch(this->video_menu->selected_index) {
case VIDEO_MENU_BACK:
this->setup_main_menu();
return;
break;
case VIDEO_MENU_VSYNC:
this->vsync_change();
break;
case MAIN_MENU_ASYNC:
case VIDEO_MENU_ASYNC:
this->async_change();
break;
case MAIN_MENU_BLUR:
case VIDEO_MENU_BLUR:
this->blur_change();
break;
case MAIN_MENU_PADDING:
case VIDEO_MENU_PADDING:
this->padding_change();
break;
default:
break;
}
this->main_menu->selected_index = MAIN_MENU_NO_ACTION;
this->video_menu->selected_index = VIDEO_MENU_NO_ACTION;
continue;
}
break;
@ -666,7 +693,10 @@ void WindowScreen::draw(double frame_time, VideoOutputData* out_buf) {
this->connection_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y);
break;
case MAIN_MENU_TYPE:
this->main_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->capture_status->connected);
this->main_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->capture_status->connected);
break;
case VIDEO_MENU_TYPE:
this->video_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info);
break;
default:
break;
@ -966,6 +996,9 @@ void WindowScreen::display_data_to_window(bool actually_draw) {
case MAIN_MENU_TYPE:
this->main_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
case VIDEO_MENU_TYPE:
this->video_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
default:
break;
}