From e27db15bfd4cac67d7bd9e1ca0995b76769ba72b Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Tue, 21 May 2024 23:28:41 +0200 Subject: [PATCH] Add BFI Settings Menu --- CMakeLists.txt | 2 +- README.md | 1 - include/Menus/BFIMenu.hpp | 40 +++++++ include/Menus/OptionSelectionMenu.hpp | 5 + include/Menus/VideoMenu.hpp | 1 + include/display_structs.hpp | 5 +- include/frontend.hpp | 11 ++ source/Menus/AudioMenu.cpp | 19 ++-- source/Menus/BFIMenu.cpp | 146 ++++++++++++++++++++++++++ source/Menus/CropMenu.cpp | 4 +- source/Menus/MainMenu.cpp | 19 ++-- source/Menus/OffsetMenu.cpp | 15 ++- source/Menus/OptionSelectionMenu.cpp | 25 ++++- source/Menus/PARMenu.cpp | 4 +- source/Menus/RotationMenu.cpp | 11 +- source/Menus/VideoMenu.cpp | 49 ++++----- source/WindowScreen.cpp | 129 +++++++++++++++++++++-- source/cc3dsfs.cpp | 4 + source/frontend.cpp | 22 +++- 19 files changed, 418 insertions(+), 94 deletions(-) create mode 100755 include/Menus/BFIMenu.hpp create mode 100755 source/Menus/BFIMenu.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 415f774..604f2ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/Menus/ConnectionMenu.cpp source/Menus/OptionSelectionMenu.cpp source/Menus/MainMenu.cpp source/Menus/VideoMenu.cpp source/Menus/CropMenu.cpp source/Menus/PARMenu.cpp source/Menus/RotationMenu.cpp source/Menus/OffsetMenu.cpp source/Menus/AudioMenu.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/Menus/ConnectionMenu.cpp source/Menus/OptionSelectionMenu.cpp source/Menus/MainMenu.cpp source/Menus/VideoMenu.cpp source/Menus/CropMenu.cpp source/Menus/PARMenu.cpp source/Menus/RotationMenu.cpp source/Menus/OffsetMenu.cpp source/Menus/AudioMenu.cpp source/Menus/BFIMenu.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}) diff --git a/README.md b/README.md index d71a43c..fecae36 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,6 @@ On MacOS, you may also be prompted to install the Apple Command Line Developer T - __5 key__: In Fullscreen mode, changes the Y distance from the border between 0, 1/2 Max and Max. - __6 key__: In Joint mode, changes the position of the smaller screen relative to the bigger one between 0, 1/2 Max and Max. - __7 key__: In Joint Fullscreen mode, changes the distance from the upper screen between 0, 1/2 Max and Max. -- __I key__: Toggles BFI (Motion Blur Reduction) on/off. Best used on 120+hz monitors. DO NOT USE THIS IF YOU'RE AT RISK OF SEIZURES!!! - __Z key__: Decreases the Menu Scaling multiplier by 0.1. 0.3 is the minimum. - __X key__: Increases the Menu Scaling multiplier by 0.1. 10.0 is the maximum. - __R key__: Toggles extra padding on/off. It can be used to account for windows with rounded corners. diff --git a/include/Menus/BFIMenu.hpp b/include/Menus/BFIMenu.hpp new file mode 100755 index 0000000..2839d2f --- /dev/null +++ b/include/Menus/BFIMenu.hpp @@ -0,0 +1,40 @@ +#ifndef __BFIMENU_HPP +#define __BFIMENU_HPP + +#include "OptionSelectionMenu.hpp" +#include + +#include "TextRectangle.hpp" +#include "sfml_gfx_structs.hpp" +#include "display_structs.hpp" + +enum BFIMenuOutAction{ + BFI_MENU_NO_ACTION, + BFI_MENU_BACK, + BFI_MENU_TOGGLE, + BFI_MENU_DIVIDER_DEC, + BFI_MENU_DIVIDER_INC, + BFI_MENU_AMOUNT_DEC, + BFI_MENU_AMOUNT_INC, +}; + +class BFIMenu : public OptionSelectionMenu { +public: + BFIMenu(bool font_load_success, sf::Font &text_font); + ~BFIMenu(); + void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info); + void insert_data(); + BFIMenuOutAction selected_index = BFIMenuOutAction::BFI_MENU_NO_ACTION; + void reset_output_option(); +protected: + bool is_option_selectable(int index, int action); + bool is_option_inc_dec(int index); + void set_output_option(int index, int action); + int get_num_options(); + std::string get_string_option(int index, int action); + void class_setup(); +private: + int *options_indexes; + int num_enabled_options; +}; +#endif diff --git a/include/Menus/OptionSelectionMenu.hpp b/include/Menus/OptionSelectionMenu.hpp index d67bb46..9a2df91 100755 --- a/include/Menus/OptionSelectionMenu.hpp +++ b/include/Menus/OptionSelectionMenu.hpp @@ -13,6 +13,7 @@ #define DEFAULT_ACTION 0 #define DEC_ACTION 1 #define INC_ACTION 2 +#define FALSE_ACTION 3 class OptionSelectionMenu { public: @@ -39,6 +40,7 @@ protected: bool show_x; bool show_title; + virtual bool is_option_selectable(int index, int action); virtual bool is_option_inc_dec(int index); virtual void set_output_option(int index, int action); virtual int get_num_options(); @@ -51,6 +53,9 @@ protected: void initialize(bool font_load_success, sf::Font &text_font); void prepare_options(); void base_prepare(float menu_scaling_factor, int view_size_x, int view_size_y); + std::string setTextOptionInt(int index, int value); + std::string setTextOptionBool(int index, bool value); + std::string setTextOptionFloat(int index, float value); struct MenuData { int page = 0; diff --git a/include/Menus/VideoMenu.hpp b/include/Menus/VideoMenu.hpp index 529b272..24f8f34 100755 --- a/include/Menus/VideoMenu.hpp +++ b/include/Menus/VideoMenu.hpp @@ -55,5 +55,6 @@ protected: private: int *options_indexes; int num_enabled_options; + std::string setTextOptionDualPercentage(int index, int value_1, int value_2); }; #endif diff --git a/include/display_structs.hpp b/include/display_structs.hpp index 474f258..4d17d0c 100755 --- a/include/display_structs.hpp +++ b/include/display_structs.hpp @@ -6,7 +6,7 @@ enum ScreenType { TOP, BOTTOM, JOINT }; enum BottomRelativePosition { UNDER_TOP, LEFT_TOP, ABOVE_TOP, RIGHT_TOP, BOT_REL_POS_END }; -enum CurrMenuType { DEFAULT_MENU_TYPE, CONNECT_MENU_TYPE, MAIN_MENU_TYPE, VIDEO_MENU_TYPE, AUDIO_MENU_TYPE, CROP_MENU_TYPE, TOP_PAR_MENU_TYPE, BOTTOM_PAR_MENU_TYPE, ROTATION_MENU_TYPE, OFFSET_MENU_TYPE }; +enum CurrMenuType { DEFAULT_MENU_TYPE, CONNECT_MENU_TYPE, MAIN_MENU_TYPE, VIDEO_MENU_TYPE, AUDIO_MENU_TYPE, CROP_MENU_TYPE, TOP_PAR_MENU_TYPE, BOTTOM_PAR_MENU_TYPE, ROTATION_MENU_TYPE, OFFSET_MENU_TYPE, BFI_MENU_TYPE, LOAD_MENU_TYPE, SAVE_MENU_TYPE, RESOLUTION_MENU_TYPE, EXTRA_MENU_TYPE, STATUS_MENU_TYPE, LICENSES_MENU_TYPE, RELATIVE_POS_MENU_TYPE }; struct ScreenInfo { bool is_blurred; @@ -21,7 +21,8 @@ struct ScreenInfo { bool async; int top_scaling, bot_scaling; bool bfi; - double bfi_divider; + int bfi_divider; + int bfi_amount; double menu_scaling_factor; bool rounded_corners_fix; int top_par; diff --git a/include/frontend.hpp b/include/frontend.hpp index de4ecc2..b75421d 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -20,6 +20,7 @@ #include "RotationMenu.hpp" #include "OffsetMenu.hpp" #include "AudioMenu.hpp" +#include "BFIMenu.hpp" #include "display_structs.hpp" class WindowScreen { @@ -90,6 +91,7 @@ private: RotationMenu *rotation_menu; OffsetMenu *offset_menu; AudioMenu *audio_menu; + BFIMenu *bfi_menu; std::vector possible_crops; std::vector possible_pars; @@ -141,6 +143,7 @@ private: void window_scaling_change(bool positive); void rotation_change(int &value, bool right); void ratio_change(bool top_priority); + void bfi_change(); void poll_window(); bool common_poll(SFEvent &event_data); bool main_poll(SFEvent &event_data); @@ -176,6 +179,14 @@ private: void setup_offset_menu(); void setup_rotation_menu(); void setup_audio_menu(); + void setup_bfi_menu(); + void setup_load_menu(); + void setup_save_menu(); + void setup_resolution_menu(); + void setup_extra_menu(); + void setup_status_menu(); + void setup_licenses_menu(); + void setup_relative_pos_menu(); void update_connection(); }; diff --git a/source/Menus/AudioMenu.cpp b/source/Menus/AudioMenu.cpp index 4136aea..5b83b6c 100755 --- a/source/Menus/AudioMenu.cpp +++ b/source/Menus/AudioMenu.cpp @@ -90,6 +90,8 @@ std::string AudioMenu::get_string_option(int index, int action) { return pollable_options[this->options_indexes[index]]->inc_str; if((action == DEC_ACTION) && this->is_option_inc_dec(index)) return pollable_options[this->options_indexes[index]]->dec_str; + if(action == FALSE_ACTION) + return pollable_options[this->options_indexes[index]]->false_name; return pollable_options[this->options_indexes[index]]->base_name; } @@ -97,16 +99,6 @@ bool AudioMenu::is_option_inc_dec(int index) { return pollable_options[this->options_indexes[index]]->is_inc; } -static std::string setTextOptionInt(int option_index, int value) { - return pollable_options[option_index]->base_name + ": " + std::to_string(value); -} - -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; -} - void AudioMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, AudioData *audio_data) { int num_pages = this->get_num_pages(); if(this->future_data.page >= num_pages) @@ -116,13 +108,14 @@ void AudioMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz int index = (i * this->single_option_multiplier) + this->elements_start_id; if(!this->future_enabled_labels[index]) continue; - int option_index = this->options_indexes[start + i]; + int real_index = start + i; + int option_index = this->options_indexes[real_index]; switch(pollable_options[option_index]->out_action) { case AUDIO_MENU_VOLUME_DEC: - this->labels[index]->setText(setTextOptionInt(option_index, audio_data->get_real_volume())); + this->labels[index]->setText(this->setTextOptionInt(real_index, audio_data->get_real_volume())); break; case AUDIO_MENU_MUTE: - this->labels[index]->setText(setTextOptionBool(option_index, audio_data->get_mute())); + this->labels[index]->setText(this->setTextOptionBool(real_index, audio_data->get_mute())); break; default: break; diff --git a/source/Menus/BFIMenu.cpp b/source/Menus/BFIMenu.cpp new file mode 100755 index 0000000..562b342 --- /dev/null +++ b/source/Menus/BFIMenu.cpp @@ -0,0 +1,146 @@ +#include "BFIMenu.hpp" + +#define NUM_TOTAL_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0])) + +struct BFIMenuOptionInfo { + const std::string base_name; + const std::string false_name; + const bool is_selectable; + const bool is_inc; + const std::string dec_str; + const std::string inc_str; + const BFIMenuOutAction inc_out_action; + const BFIMenuOutAction out_action; +}; + +static const BFIMenuOptionInfo bfi_warning_option = { +.base_name = "PHOTOSENSITIVITY", .false_name = "", .is_selectable = false, +.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = BFI_MENU_NO_ACTION, +.out_action = BFI_MENU_NO_ACTION}; + +static const BFIMenuOptionInfo bfi_warning2_option = { +.base_name = "WARNING!", .false_name = "", .is_selectable = false, +.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = BFI_MENU_NO_ACTION, +.out_action = BFI_MENU_NO_ACTION}; + +static const BFIMenuOptionInfo bfi_toggle_option = { +.base_name = "Turn BFI Off", .false_name = "Turn BFI On", .is_selectable = true, +.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = BFI_MENU_NO_ACTION, +.out_action = BFI_MENU_TOGGLE}; + +static const BFIMenuOptionInfo bfi_divider_option = { +.base_name = "Frequency", .false_name = "", .is_selectable = true, +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = BFI_MENU_DIVIDER_INC, +.out_action = BFI_MENU_DIVIDER_DEC}; + +static const BFIMenuOptionInfo bfi_amount_option = { +.base_name = "Frames", .false_name = "", .is_selectable = true, +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = BFI_MENU_AMOUNT_INC, +.out_action = BFI_MENU_AMOUNT_DEC}; + +static const BFIMenuOptionInfo* pollable_options[] = { +&bfi_warning_option, +&bfi_warning2_option, +&bfi_toggle_option, +&bfi_divider_option, +&bfi_amount_option, +}; + +BFIMenu::BFIMenu(bool font_load_success, sf::Font &text_font) : OptionSelectionMenu(){ + this->options_indexes = new int[NUM_TOTAL_MENU_OPTIONS]; + this->initialize(font_load_success, text_font); + this->num_enabled_options = 0; +} + +BFIMenu::~BFIMenu() { + delete []this->options_indexes; +} + +void BFIMenu::class_setup() { + this->num_options_per_screen = 5; + this->min_elements_text_scaling_factor = num_options_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 = "Offset Settings"; + this->show_back_x = true; + this->show_x = false; + this->show_title = true; +} + +void BFIMenu::insert_data() { + this->num_enabled_options = 0; + for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = i; + this->num_enabled_options++; + } + this->prepare_options(); +} + +void BFIMenu::reset_output_option() { + this->selected_index = BFIMenuOutAction::BFI_MENU_NO_ACTION; +} + +void BFIMenu::set_output_option(int index, int action) { + if(index == BACK_X_OUTPUT_OPTION) + this->selected_index = BFI_MENU_BACK; + else if((action == INC_ACTION) && this->is_option_inc_dec(index)) + this->selected_index = pollable_options[this->options_indexes[index]]->inc_out_action; + else + this->selected_index = pollable_options[this->options_indexes[index]]->out_action; +} + +int BFIMenu::get_num_options() { + return this->num_enabled_options; +} + +std::string BFIMenu::get_string_option(int index, int action) { + if((action == INC_ACTION) && this->is_option_inc_dec(index)) + return pollable_options[this->options_indexes[index]]->inc_str; + if((action == DEC_ACTION) && this->is_option_inc_dec(index)) + return pollable_options[this->options_indexes[index]]->dec_str; + if(action == FALSE_ACTION) + return pollable_options[this->options_indexes[index]]->false_name; + return pollable_options[this->options_indexes[index]]->base_name; +} + +bool BFIMenu::is_option_selectable(int index, int action) { + return pollable_options[this->options_indexes[index]]->is_selectable; +} + +bool BFIMenu::is_option_inc_dec(int index) { + return pollable_options[this->options_indexes[index]]->is_inc; +} + +void BFIMenu::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_options_per_screen; + for(int i = 0; i < this->num_options_per_screen + 1; i++) { + int index = (i * this->single_option_multiplier) + this->elements_start_id; + if(!this->future_enabled_labels[index]) + continue; + int real_index = start + i; + int option_index = this->options_indexes[real_index]; + switch(pollable_options[option_index]->out_action) { + case BFI_MENU_TOGGLE: + this->labels[index]->setText(this->setTextOptionBool(real_index, info->bfi)); + break; + case BFI_MENU_DIVIDER_DEC: + this->labels[index]->setText(this->setTextOptionInt(real_index, info->bfi_divider * 60) + " hz"); + break; + case BFI_MENU_AMOUNT_DEC: + this->labels[index]->setText(this->setTextOptionInt(real_index, info->bfi_amount)); + break; + default: + break; + } + } + + this->base_prepare(menu_scaling_factor, view_size_x, view_size_y); +} diff --git a/source/Menus/CropMenu.cpp b/source/Menus/CropMenu.cpp index 28e6b83..74f6232 100755 --- a/source/Menus/CropMenu.cpp +++ b/source/Menus/CropMenu.cpp @@ -58,9 +58,9 @@ void CropMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size continue; int crop_index = start + i; if(crop_index == current_crop) - this->labels[index]->setText("<" + (*this->possible_crops)[crop_index]->name + ">"); + this->labels[index]->setText("<" + this->get_string_option(crop_index, DEFAULT_ACTION) + ">"); else - this->labels[index]->setText((*this->possible_crops)[crop_index]->name); + this->labels[index]->setText(this->get_string_option(crop_index, DEFAULT_ACTION)); } this->base_prepare(menu_scaling_factor, view_size_x, view_size_y); } diff --git a/source/Menus/MainMenu.cpp b/source/Menus/MainMenu.cpp index 001a435..940206c 100755 --- a/source/Menus/MainMenu.cpp +++ b/source/Menus/MainMenu.cpp @@ -1,6 +1,6 @@ #include "MainMenu.hpp" -#define NUM_TOTAL_MAIN_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0])) +#define NUM_TOTAL_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0])) #define OPTION_WINDOWED true #define OPTION_FULLSCREEN true @@ -123,7 +123,7 @@ static const MainMenuOptionInfo* pollable_options[] = { }; MainMenu::MainMenu(bool font_load_success, sf::Font &text_font) : OptionSelectionMenu(){ - this->options_indexes = new int[NUM_TOTAL_MAIN_MENU_OPTIONS]; + this->options_indexes = new int[NUM_TOTAL_MENU_OPTIONS]; this->initialize(font_load_success, text_font); this->num_enabled_options = 0; } @@ -150,7 +150,7 @@ void MainMenu::class_setup() { void MainMenu::insert_data(ScreenType s_type, bool is_fullscreen) { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MAIN_MENU_OPTIONS; i++) { + for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { bool valid = true; if(is_fullscreen) valid = valid && pollable_options[i]->active_fullscreen; @@ -186,15 +186,11 @@ int MainMenu::get_num_options() { } std::string MainMenu::get_string_option(int index, int action) { + if(action == FALSE_ACTION) + return pollable_options[this->options_indexes[index]]->false_name; 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; -} - 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) @@ -204,10 +200,11 @@ void MainMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size int index = (i * this->single_option_multiplier) + this->elements_start_id; if(!this->future_enabled_labels[index]) continue; - int option_index = this->options_indexes[start + i]; + int real_index = start + i; + int option_index = this->options_indexes[real_index]; switch(pollable_options[option_index]->out_action) { case MAIN_MENU_OPEN: - this->labels[index]->setText(setTextOptionBool(option_index, connected)); + this->labels[index]->setText(this->setTextOptionBool(real_index, connected)); break; default: break; diff --git a/source/Menus/OffsetMenu.cpp b/source/Menus/OffsetMenu.cpp index cf3322b..8c4f584 100755 --- a/source/Menus/OffsetMenu.cpp +++ b/source/Menus/OffsetMenu.cpp @@ -102,10 +102,6 @@ bool OffsetMenu::is_option_inc_dec(int index) { return pollable_options[this->options_indexes[index]]->is_inc; } -static std::string setTextOptionFloat(int option_index, float value) { - return pollable_options[option_index]->base_name + ": " + get_float_str_decimals(value, 1); -} - void OffsetMenu::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) @@ -115,19 +111,20 @@ void OffsetMenu::prepare(float menu_scaling_factor, int view_size_x, int view_si int index = (i * this->single_option_multiplier) + this->elements_start_id; if(!this->future_enabled_labels[index]) continue; - int option_index = this->options_indexes[start + i]; + int real_index = start + i; + int option_index = this->options_indexes[real_index]; switch(pollable_options[option_index]->out_action) { case OFFSET_MENU_SMALL_OFFSET_DEC: - this->labels[index]->setText(setTextOptionFloat(option_index, info->subscreen_offset)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, info->subscreen_offset)); break; case OFFSET_MENU_SMALL_SCREEN_DISTANCE_DEC: - this->labels[index]->setText(setTextOptionFloat(option_index, info->subscreen_attached_offset)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, info->subscreen_attached_offset)); break; case OFFSET_MENU_SCREENS_X_POS_DEC: - this->labels[index]->setText(setTextOptionFloat(option_index, info->total_offset_x)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, info->total_offset_x)); break; case OFFSET_MENU_SCREENS_Y_POS_DEC: - this->labels[index]->setText(setTextOptionFloat(option_index, info->total_offset_y)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, info->total_offset_y)); break; default: break; diff --git a/source/Menus/OptionSelectionMenu.cpp b/source/Menus/OptionSelectionMenu.cpp index 01261f9..6bf5558 100755 --- a/source/Menus/OptionSelectionMenu.cpp +++ b/source/Menus/OptionSelectionMenu.cpp @@ -1,4 +1,5 @@ #include "OptionSelectionMenu.hpp" +#include "utils.hpp" OptionSelectionMenu::OptionSelectionMenu() { } @@ -200,6 +201,10 @@ int OptionSelectionMenu::get_num_options() { return this->num_options_per_screen; } +bool OptionSelectionMenu::is_option_selectable(int index, int action) { + return true; +} + bool OptionSelectionMenu::is_option_inc_dec(int index) { return false; } @@ -208,6 +213,20 @@ std::string OptionSelectionMenu::get_string_option(int index, int action) { return "Sample Text"; } +std::string OptionSelectionMenu::setTextOptionInt(int index, int value) { + return this->get_string_option(index, DEFAULT_ACTION) + ": " + std::to_string(value); +} + +std::string OptionSelectionMenu::setTextOptionBool(int index, bool value) { + if(value) + return this->get_string_option(index, DEFAULT_ACTION); + return this->get_string_option(index, FALSE_ACTION); +} +std::string OptionSelectionMenu::setTextOptionFloat(int index, float value) { + std::string out = this->get_string_option(index, DEFAULT_ACTION) + ": " + get_float_str_decimals(value, 1); + return out; +} + int OptionSelectionMenu::get_num_pages() { int num_pages = 1 + ((this->get_num_options() - 1) / this->num_options_per_screen); if(this->get_num_options() == (this->num_options_per_screen + 1)) @@ -248,16 +267,16 @@ void OptionSelectionMenu::prepare_options() { this->labels[label_start_index]->setText(this->get_string_option(start + i, DEFAULT_ACTION)); this->labels[label_start_index]->setShowText(true); if(!is_option_inc_dec(start + i)) - this->selectable_labels[label_start_index] = true; + this->selectable_labels[label_start_index] = this->is_option_selectable(start + i, DEFAULT_ACTION); else { this->labels[label_start_index + 1]->setText(this->get_string_option(start + i, DEC_ACTION)); this->labels[label_start_index + 1]->setShowText(true); this->future_enabled_labels[label_start_index + 1] = true; - this->selectable_labels[label_start_index + 1] = true; + this->selectable_labels[label_start_index + 1] = this->is_option_selectable(start + i, DEC_ACTION); this->labels[label_start_index + 2]->setText(this->get_string_option(start + i, INC_ACTION)); this->labels[label_start_index + 2]->setShowText(true); this->future_enabled_labels[label_start_index + 2] = true; - this->selectable_labels[label_start_index + 2] = true; + this->selectable_labels[label_start_index + 2] = this->is_option_selectable(start + i, INC_ACTION); } } if(num_pages > 1) { diff --git a/source/Menus/PARMenu.cpp b/source/Menus/PARMenu.cpp index 95aacd8..02d2302 100755 --- a/source/Menus/PARMenu.cpp +++ b/source/Menus/PARMenu.cpp @@ -62,9 +62,9 @@ void PARMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_ continue; int par_index = start + i; if(par_index == current_par) - this->labels[index]->setText("<" + (*this->possible_pars)[par_index]->name + ">"); + this->labels[index]->setText("<" + this->get_string_option(par_index, DEFAULT_ACTION) + ">"); else - this->labels[index]->setText((*this->possible_pars)[par_index]->name); + this->labels[index]->setText(this->get_string_option(par_index, DEFAULT_ACTION)); } this->base_prepare(menu_scaling_factor, view_size_x, view_size_y); } diff --git a/source/Menus/RotationMenu.cpp b/source/Menus/RotationMenu.cpp index cd1042c..ef029d8 100755 --- a/source/Menus/RotationMenu.cpp +++ b/source/Menus/RotationMenu.cpp @@ -96,10 +96,6 @@ bool RotationMenu::is_option_inc_dec(int index) { return pollable_options[this->options_indexes[index]]->is_inc; } -static std::string setTextOptionInt(int option_index, int value) { - return pollable_options[option_index]->base_name + ": " + std::to_string(value); -} - void RotationMenu::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) @@ -109,13 +105,14 @@ void RotationMenu::prepare(float menu_scaling_factor, int view_size_x, int view_ int index = (i * this->single_option_multiplier) + this->elements_start_id; if(!this->future_enabled_labels[index]) continue; - int option_index = this->options_indexes[start + i]; + int real_index = start + i; + int option_index = this->options_indexes[real_index]; switch(pollable_options[option_index]->out_action) { case ROTATION_MENU_TOP_ROTATION_DEC: - this->labels[index]->setText(setTextOptionInt(option_index, info->top_rotation)); + this->labels[index]->setText(this->setTextOptionInt(real_index, info->top_rotation)); break; case ROTATION_MENU_BOTTOM_ROTATION_DEC: - this->labels[index]->setText(setTextOptionInt(option_index, info->bot_rotation)); + this->labels[index]->setText(this->setTextOptionInt(real_index, info->bot_rotation)); break; default: break; diff --git a/source/Menus/VideoMenu.cpp b/source/Menus/VideoMenu.cpp index 24043e2..af48b75 100755 --- a/source/Menus/VideoMenu.cpp +++ b/source/Menus/VideoMenu.cpp @@ -1,6 +1,6 @@ #include "VideoMenu.hpp" -#define NUM_TOTAL_VIDEO_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0])) +#define NUM_TOTAL_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0])) struct VideoMenuOptionInfo { const std::string base_name; @@ -173,7 +173,7 @@ static const VideoMenuOptionInfo* pollable_options[] = { }; VideoMenu::VideoMenu(bool font_load_success, sf::Font &text_font) : OptionSelectionMenu(){ - this->options_indexes = new int[NUM_TOTAL_VIDEO_MENU_OPTIONS]; + this->options_indexes = new int[NUM_TOTAL_MENU_OPTIONS]; this->initialize(font_load_success, text_font); this->num_enabled_options = 0; } @@ -200,7 +200,7 @@ void VideoMenu::class_setup() { 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++) { + for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { bool valid = true; if(is_fullscreen) valid = valid && pollable_options[i]->active_fullscreen; @@ -242,6 +242,8 @@ std::string VideoMenu::get_string_option(int index, int action) { return pollable_options[this->options_indexes[index]]->inc_str; if((action == DEC_ACTION) && this->is_option_inc_dec(index)) return pollable_options[this->options_indexes[index]]->dec_str; + if(action == FALSE_ACTION) + return pollable_options[this->options_indexes[index]]->false_name; return pollable_options[this->options_indexes[index]]->base_name; } @@ -249,26 +251,12 @@ bool VideoMenu::is_option_inc_dec(int index) { return pollable_options[this->options_indexes[index]]->is_inc; } -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) { +std::string VideoMenu::setTextOptionDualPercentage(int 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); + return this->get_string_option(index, DEFAULT_ACTION) + ": " + 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) { @@ -280,37 +268,38 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz int index = (i * this->single_option_multiplier) + this->elements_start_id; if(!this->future_enabled_labels[index]) continue; - int option_index = this->options_indexes[start + i]; + int real_index = start + i; + int option_index = this->options_indexes[real_index]; switch(pollable_options[option_index]->out_action) { case VIDEO_MENU_VSYNC: - this->labels[index]->setText(setTextOptionBool(option_index, info->v_sync_enabled)); + this->labels[index]->setText(this->setTextOptionBool(real_index, info->v_sync_enabled)); break; case VIDEO_MENU_ASYNC: - this->labels[index]->setText(setTextOptionBool(option_index, info->async)); + this->labels[index]->setText(this->setTextOptionBool(real_index, info->async)); break; case VIDEO_MENU_BLUR: - this->labels[index]->setText(setTextOptionBool(option_index, info->is_blurred)); + this->labels[index]->setText(this->setTextOptionBool(real_index, info->is_blurred)); break; case VIDEO_MENU_PADDING: - this->labels[index]->setText(setTextOptionBool(option_index, info->rounded_corners_fix)); + this->labels[index]->setText(this->setTextOptionBool(real_index, info->rounded_corners_fix)); break; case VIDEO_MENU_WINDOW_SCALING_DEC: - this->labels[index]->setText(setTextOptionFloat(option_index, info->scaling)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, info->scaling)); break; case VIDEO_MENU_MENU_SCALING_DEC: - this->labels[index]->setText(setTextOptionFloat(option_index, info->menu_scaling_factor)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, info->menu_scaling_factor)); break; case VIDEO_MENU_FULLSCREEN_SCALING_TOP: - this->labels[index]->setText(setTextOptionDualPercentage(option_index, info->top_scaling, info->bot_scaling)); + this->labels[index]->setText(this->setTextOptionDualPercentage(real_index, info->top_scaling, info->bot_scaling)); break; case VIDEO_MENU_SMALL_SCREEN_OFFSET_DEC: - this->labels[index]->setText(setTextOptionFloat(option_index, info->subscreen_offset)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, info->subscreen_offset)); break; case VIDEO_MENU_TOP_ROTATION_DEC: - this->labels[index]->setText(setTextOptionInt(option_index, info->top_rotation)); + this->labels[index]->setText(this->setTextOptionInt(real_index, info->top_rotation)); break; case VIDEO_MENU_BOTTOM_ROTATION_DEC: - this->labels[index]->setText(setTextOptionInt(option_index, info->bot_rotation)); + this->labels[index]->setText(this->setTextOptionInt(real_index, info->bot_rotation)); break; default: break; diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index ca28cb6..e857055 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -28,6 +28,7 @@ WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, Disp this->offset_menu = new OffsetMenu(this->font_load_success, this->text_font); this->rotation_menu = new RotationMenu(this->font_load_success, this->text_font); this->audio_menu = new AudioMenu(this->font_load_success, this->text_font); + this->bfi_menu = new BFIMenu(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); @@ -61,6 +62,7 @@ WindowScreen::~WindowScreen() { delete this->offset_menu; delete this->rotation_menu; delete this->audio_menu; + delete this->bfi_menu; } void WindowScreen::build() { @@ -241,6 +243,11 @@ void WindowScreen::ratio_change(bool top_priority) { this->future_operations.call_screen_settings_update = true; } +void WindowScreen::bfi_change() { + this->m_info.bfi = !this->m_info.bfi; + this->print_notification_on_off("BFI", this->m_info.bfi); +} + bool WindowScreen::common_poll(SFEvent &event_data) { bool consumed = true; switch(event_data.type) { @@ -399,6 +406,35 @@ void WindowScreen::setup_audio_menu() { } } +void WindowScreen::setup_bfi_menu() { + if(this->curr_menu != BFI_MENU_TYPE) { + this->curr_menu = BFI_MENU_TYPE; + this->bfi_menu->reset_data(); + this->bfi_menu->insert_data(); + } +} + +void WindowScreen::setup_load_menu() { +} + +void WindowScreen::setup_save_menu() { +} + +void WindowScreen::setup_resolution_menu() { +} + +void WindowScreen::setup_extra_menu() { +} + +void WindowScreen::setup_status_menu() { +} + +void WindowScreen::setup_licenses_menu() { +} + +void WindowScreen::setup_relative_pos_menu() { +} + bool WindowScreen::no_menu_poll(SFEvent &event_data) { bool consumed = true; switch(event_data.type) { @@ -464,10 +500,9 @@ bool WindowScreen::main_poll(SFEvent &event_data) { this->blur_change(); break; - case 'i': - this->m_info.bfi = !this->m_info.bfi; - this->print_notification_on_off("BFI", this->m_info.bfi); - break; + //case 'i': + // this->bfi_change(); + // break; case 'o': this->m_prepare_open = true; @@ -666,6 +701,23 @@ void WindowScreen::poll() { case MAIN_MENU_AUDIO_SETTINGS: this->setup_audio_menu(); return; + case MAIN_MENU_LOAD_PROFILES: + this->setup_load_menu(); + return; + case MAIN_MENU_SAVE_PROFILES: + this->setup_save_menu(); + return; + case MAIN_MENU_STATUS: + this->setup_status_menu(); + return; + case MAIN_MENU_LICENSES: + this->setup_licenses_menu(); + return; + case MAIN_MENU_EXTRA_SETTINGS: + this->setup_extra_menu(); + return; + case MAIN_MENU_SHUTDOWN: + return; default: break; } @@ -773,11 +825,14 @@ void WindowScreen::poll() { this->setup_offset_menu(); return; case VIDEO_MENU_BFI_SETTINGS: - break; + this->setup_bfi_menu(); + return; case VIDEO_MENU_RESOLUTION_SETTINGS: - break; + this->setup_resolution_menu(); + return; case VIDEO_MENU_BOTTOM_SCREEN_POS: - break; + this->setup_relative_pos_menu(); + return; default: break; } @@ -906,6 +961,46 @@ void WindowScreen::poll() { continue; } break; + case BFI_MENU_TYPE: + if(this->bfi_menu->poll(event_data)) { + switch(this->bfi_menu->selected_index) { + case BFI_MENU_BACK: + this->setup_video_menu(); + return; + case BFI_MENU_NO_ACTION: + break; + case BFI_MENU_TOGGLE: + this->bfi_change(); + break; + case BFI_MENU_DIVIDER_DEC: + this->m_info.bfi_divider -= 1; + if(this->m_info.bfi_divider < 2) + this->m_info.bfi_divider = 2; + if(this->m_info.bfi_amount > (this->m_info.bfi_divider - 1)) + this->m_info.bfi_amount = this->m_info.bfi_divider - 1; + break; + case BFI_MENU_DIVIDER_INC: + this->m_info.bfi_divider += 1; + if(this->m_info.bfi_divider > 10) + this->m_info.bfi_divider = 10; + break; + case BFI_MENU_AMOUNT_DEC: + this->m_info.bfi_amount -= 1; + if(this->m_info.bfi_amount < 1) + this->m_info.bfi_amount = 1; + break; + case BFI_MENU_AMOUNT_INC: + this->m_info.bfi_amount += 1; + if(this->m_info.bfi_amount > (this->m_info.bfi_divider - 1)) + this->m_info.bfi_amount = this->m_info.bfi_divider - 1; + break; + default: + break; + } + this->bfi_menu->reset_output_option(); + continue; + } + break; default: break; } @@ -1019,6 +1114,9 @@ void WindowScreen::draw(double frame_time, VideoOutputData* out_buf) { case AUDIO_MENU_TYPE: this->audio_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->audio_data); break; + case BFI_MENU_TYPE: + this->bfi_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + break; default: break; } @@ -1349,6 +1447,9 @@ void WindowScreen::display_data_to_window(bool actually_draw, bool is_debug) { case AUDIO_MENU_TYPE: this->audio_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); break; + case BFI_MENU_TYPE: + this->bfi_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + break; default: break; } @@ -1370,8 +1471,18 @@ void WindowScreen::window_render_call() { if(this->loaded_info.bfi) { if(this->frame_time > 0.0) { - sf::sleep(sf::seconds(frame_time / (this->loaded_info.bfi_divider * 1.1))); - this->display_data_to_window(false); + if(this->loaded_info.bfi_divider < 2) + this->loaded_info.bfi_divider = 2; + if(this->loaded_info.bfi_divider > 10) + this->loaded_info.bfi_divider = 10; + if(this->loaded_info.bfi_amount < 1) + this->loaded_info.bfi_amount = 1; + if(this->loaded_info.bfi_amount > (this->loaded_info.bfi_divider - 1)) + this->loaded_info.bfi_amount = this->loaded_info.bfi_divider - 1; + for(int i = 0; i < this->loaded_info.bfi_amount; i++) { + sf::sleep(sf::seconds(frame_time / (this->loaded_info.bfi_divider * 1.1))); + this->display_data_to_window(false); + } } } } diff --git a/source/cc3dsfs.cpp b/source/cc3dsfs.cpp index 4ef3a88..8fa8ec0 100755 --- a/source/cc3dsfs.cpp +++ b/source/cc3dsfs.cpp @@ -224,6 +224,10 @@ static void mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data if(!skip_io) { load(base_path, base_name, top_screen.m_info, bot_screen.m_info, joint_screen.m_info, frontend_data.display_data, audio_data, out_text_data); + // Due to the risk for seizures, at the start of the program, set BFI to false! + top_screen.m_info.bfi = false; + bot_screen.m_info.bfi = false; + joint_screen.m_info.bfi = false; } top_screen.build(); diff --git a/source/frontend.cpp b/source/frontend.cpp index 6b47c04..ad9aa89 100755 --- a/source/frontend.cpp +++ b/source/frontend.cpp @@ -181,7 +181,8 @@ void reset_screen_info(ScreenInfo &info) { info.top_scaling = -1; info.bot_scaling = -1; info.bfi = false; - info.bfi_divider = 2.0; + info.bfi_divider = 2; + info.bfi_amount = 1; info.menu_scaling_factor = 1.0; info.rounded_corners_fix = false; info.top_par = 0; @@ -270,9 +271,21 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre return true; } if(key == (base + "bfi_divider")) { - info.bfi_divider = std::stod(value); - if(info.bfi_divider < 1.0) - info.bfi_divider = 1.0; + info.bfi_divider = std::stoi(value); + if(info.bfi_divider < 2) + info.bfi_divider = 2; + if(info.bfi_divider > 10) + info.bfi_divider = 10; + if(info.bfi_amount > (info.bfi_divider - 1)) + info.bfi_amount = info.bfi_divider - 1; + return true; + } + if(key == (base + "bfi_amount")) { + info.bfi_amount = std::stoi(value); + if(info.bfi_amount < 1) + info.bfi_amount = 1; + if(info.bfi_amount > (info.bfi_divider - 1)) + info.bfi_amount = info.bfi_divider - 1; return true; } if(key == (base + "menu_scaling_factor")) { @@ -317,6 +330,7 @@ std::string save_screen_info(std::string base, const ScreenInfo &info) { out += base + "bot_scaling=" + std::to_string(info.bot_scaling) + "\n"; out += base + "bfi=" + std::to_string(info.bfi) + "\n"; out += base + "bfi_divider=" + std::to_string(info.bfi_divider) + "\n"; + out += base + "bfi_amount=" + std::to_string(info.bfi_amount) + "\n"; out += base + "menu_scaling_factor=" + std::to_string(info.menu_scaling_factor) + "\n"; out += base + "rounded_corners_fix=" + std::to_string(info.rounded_corners_fix) + "\n"; out += base + "top_par=" + std::to_string(info.top_par) + "\n";