diff --git a/CMakeLists.txt b/CMakeLists.txt index ebb733e..bc672f4 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/ConnectionMenu.cpp source/OptionSelectionMenu.cpp source/MainMenu.cpp source/VideoMenu.cpp source/CropMenu.cpp source/PARMenu.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 source/CropMenu.cpp source/PARMenu.cpp source/RotationMenu.cpp source/OffsetMenu.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/include/OffsetMenu.hpp b/include/OffsetMenu.hpp new file mode 100755 index 0000000..ecc051b --- /dev/null +++ b/include/OffsetMenu.hpp @@ -0,0 +1,42 @@ +#ifndef __OFFSETMENU_HPP +#define __OFFSETMENU_HPP + +#include "OptionSelectionMenu.hpp" +#include + +#include "TextRectangle.hpp" +#include "sfml_gfx_structs.hpp" +#include "display_structs.hpp" + +enum OffsetMenuOutAction{ + OFFSET_MENU_NO_ACTION, + OFFSET_MENU_BACK, + OFFSET_MENU_SMALL_OFFSET_DEC, + OFFSET_MENU_SMALL_OFFSET_INC, + OFFSET_MENU_SMALL_SCREEN_DISTANCE_DEC, + OFFSET_MENU_SMALL_SCREEN_DISTANCE_INC, + OFFSET_MENU_SCREENS_X_POS_DEC, + OFFSET_MENU_SCREENS_X_POS_INC, + OFFSET_MENU_SCREENS_Y_POS_DEC, + OFFSET_MENU_SCREENS_Y_POS_INC, +}; + +class OffsetMenu : public OptionSelectionMenu { +public: + OffsetMenu(bool font_load_success, sf::Font &text_font); + ~OffsetMenu(); + void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info); + void insert_data(); + OffsetMenuOutAction selected_index = OffsetMenuOutAction::OFFSET_MENU_NO_ACTION; +protected: + bool is_option_inc_dec(int index); + void reset_output_option(); + 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/OptionSelectionMenu.hpp b/include/OptionSelectionMenu.hpp index eb8d4d2..8729992 100755 --- a/include/OptionSelectionMenu.hpp +++ b/include/OptionSelectionMenu.hpp @@ -97,6 +97,7 @@ private: bool is_option_location_left(int option); bool is_option_element(int option); bool is_option_location_multichoice(int option); + void set_default_cursor_position(); void decrement_selected_option(bool is_simple); void increment_selected_option(bool is_simple); }; diff --git a/include/RotationMenu.hpp b/include/RotationMenu.hpp new file mode 100755 index 0000000..a566bbd --- /dev/null +++ b/include/RotationMenu.hpp @@ -0,0 +1,38 @@ +#ifndef __ROTATIONMENU_HPP +#define __ROTATIONMENU_HPP + +#include "OptionSelectionMenu.hpp" +#include + +#include "TextRectangle.hpp" +#include "sfml_gfx_structs.hpp" +#include "display_structs.hpp" + +enum RotationMenuOutAction{ + ROTATION_MENU_NO_ACTION, + ROTATION_MENU_BACK, + ROTATION_MENU_TOP_ROTATION_DEC, + ROTATION_MENU_TOP_ROTATION_INC, + ROTATION_MENU_BOTTOM_ROTATION_DEC, + ROTATION_MENU_BOTTOM_ROTATION_INC, +}; + +class RotationMenu : public OptionSelectionMenu { +public: + RotationMenu(bool font_load_success, sf::Font &text_font); + ~RotationMenu(); + void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info); + void insert_data(); + RotationMenuOutAction selected_index = RotationMenuOutAction::ROTATION_MENU_NO_ACTION; +protected: + bool is_option_inc_dec(int index); + void reset_output_option(); + 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/VideoMenu.hpp b/include/VideoMenu.hpp index c3eac75..dc3ec4e 100755 --- a/include/VideoMenu.hpp +++ b/include/VideoMenu.hpp @@ -20,10 +20,9 @@ enum VideoMenuOutAction{ 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_SMALL_SCREEN_OFFSET_DEC, + VIDEO_MENU_SMALL_SCREEN_OFFSET_INC, + VIDEO_MENU_OFFSET_SETTINGS, VIDEO_MENU_WINDOW_SCALING_DEC, VIDEO_MENU_WINDOW_SCALING_INC, VIDEO_MENU_FULLSCREEN_SCALING_TOP, @@ -32,8 +31,11 @@ enum VideoMenuOutAction{ VIDEO_MENU_MENU_SCALING_DEC, VIDEO_MENU_MENU_SCALING_INC, VIDEO_MENU_RESOLUTION_SETTINGS, - VIDEO_MENU_TOP_ROTATION, - VIDEO_MENU_BOTTOM_ROTATION, + VIDEO_MENU_ROTATION_SETTINGS, + VIDEO_MENU_TOP_ROTATION_DEC, + VIDEO_MENU_TOP_ROTATION_INC, + VIDEO_MENU_BOTTOM_ROTATION_DEC, + VIDEO_MENU_BOTTOM_ROTATION_INC, }; class VideoMenu : public OptionSelectionMenu { diff --git a/include/display_structs.hpp b/include/display_structs.hpp index da197cc..474f258 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 }; +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 }; struct ScreenInfo { bool is_blurred; diff --git a/include/frontend.hpp b/include/frontend.hpp index d16d6a2..d3a2123 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -17,6 +17,8 @@ #include "VideoMenu.hpp" #include "CropMenu.hpp" #include "PARMenu.hpp" +#include "RotationMenu.hpp" +#include "OffsetMenu.hpp" #include "display_structs.hpp" class WindowScreen { @@ -84,6 +86,8 @@ private: VideoMenu *video_menu; CropMenu *crop_menu; PARMenu *par_menu; + RotationMenu *rotation_menu; + OffsetMenu *offset_menu; std::vector possible_crops; std::vector possible_pars; @@ -127,13 +131,15 @@ private: void async_change(); void vsync_change(); void blur_change(); - void poll_window(); void padding_change(); void crop_value_change(int new_crop_value); void par_value_change(int new_par_value, bool is_top); void offset_change(float &value, float change); void menu_scaling_change(bool positive); void window_scaling_change(bool positive); + void rotation_change(int &value, bool right); + void ratio_change(bool top_priority); + void poll_window(); bool common_poll(SFEvent &event_data); bool main_poll(SFEvent &event_data); bool no_menu_poll(SFEvent &event_data); @@ -165,6 +171,8 @@ private: void setup_video_menu(); void setup_crop_menu(); void setup_par_menu(bool is_top); + void setup_offset_menu(); + void setup_rotation_menu(); void update_connection(); }; diff --git a/source/3dscapture.cpp b/source/3dscapture.cpp index a63c3ea..51a98a9 100755 --- a/source/3dscapture.cpp +++ b/source/3dscapture.cpp @@ -276,7 +276,7 @@ static void fast_capture_call(CaptureData* capture_data, OVERLAPPED overlap[NUM_ capture_data->status.curr_in = (inner_curr_in + 1) % NUM_CONCURRENT_DATA_BUFFERS; if(capture_data->status.cooldown_curr_in) - capture_data->status.cooldown_curr_in--; + capture_data->status.cooldown_curr_in = capture_data->status.cooldown_curr_in - 1; // Signal that there is data available capture_data->status.video_wait.unlock(); capture_data->status.audio_wait.unlock(); @@ -305,7 +305,7 @@ static bool safe_capture_call(CaptureData* capture_data) { inner_curr_in = (inner_curr_in + 1) % NUM_CONCURRENT_DATA_BUFFERS; capture_data->status.curr_in = inner_curr_in; if(capture_data->status.cooldown_curr_in) - capture_data->status.cooldown_curr_in--; + capture_data->status.cooldown_curr_in = capture_data->status.cooldown_curr_in - 1; capture_data->status.video_wait.unlock(); capture_data->status.audio_wait.unlock(); } diff --git a/source/OffsetMenu.cpp b/source/OffsetMenu.cpp new file mode 100755 index 0000000..cf3322b --- /dev/null +++ b/source/OffsetMenu.cpp @@ -0,0 +1,138 @@ +#include "OffsetMenu.hpp" + +#define NUM_TOTAL_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0])) + +struct OffsetMenuOptionInfo { + const std::string base_name; + const bool is_inc; + const std::string dec_str; + const std::string inc_str; + const OffsetMenuOutAction inc_out_action; + const OffsetMenuOutAction out_action; +}; + +static const OffsetMenuOptionInfo small_screen_offset_option = { +.base_name = "Screens Offsets", +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = OFFSET_MENU_SMALL_OFFSET_INC, +.out_action = OFFSET_MENU_SMALL_OFFSET_DEC}; + +static const OffsetMenuOptionInfo subscreen_distance_option = { +.base_name = "Sub-Screen Distance", +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = OFFSET_MENU_SMALL_SCREEN_DISTANCE_INC, +.out_action = OFFSET_MENU_SMALL_SCREEN_DISTANCE_DEC}; + +static const OffsetMenuOptionInfo canvas_x_pos_option = { +.base_name = "Canvas X Position", +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = OFFSET_MENU_SCREENS_X_POS_INC, +.out_action = OFFSET_MENU_SCREENS_X_POS_DEC}; + +static const OffsetMenuOptionInfo canvas_y_pos_option = { +.base_name = "Canvas Y Position", +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = OFFSET_MENU_SCREENS_Y_POS_INC, +.out_action = OFFSET_MENU_SCREENS_Y_POS_DEC}; + +static const OffsetMenuOptionInfo* pollable_options[] = { +&small_screen_offset_option, +&subscreen_distance_option, +&canvas_x_pos_option, +&canvas_y_pos_option, +}; + +OffsetMenu::OffsetMenu(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; +} + +OffsetMenu::~OffsetMenu() { + delete []this->options_indexes; +} + +void OffsetMenu::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 OffsetMenu::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 OffsetMenu::reset_output_option() { + this->selected_index = OffsetMenuOutAction::OFFSET_MENU_NO_ACTION; +} + +void OffsetMenu::set_output_option(int index, int action) { + if(index == BACK_X_OUTPUT_OPTION) + this->selected_index = OFFSET_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 OffsetMenu::get_num_options() { + return this->num_enabled_options; +} + +std::string OffsetMenu::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; + return pollable_options[this->options_indexes[index]]->base_name; +} + +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) + 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 option_index = this->options_indexes[start + i]; + switch(pollable_options[option_index]->out_action) { + case OFFSET_MENU_SMALL_OFFSET_DEC: + this->labels[index]->setText(setTextOptionFloat(option_index, info->subscreen_offset)); + break; + case OFFSET_MENU_SMALL_SCREEN_DISTANCE_DEC: + this->labels[index]->setText(setTextOptionFloat(option_index, info->subscreen_attached_offset)); + break; + case OFFSET_MENU_SCREENS_X_POS_DEC: + this->labels[index]->setText(setTextOptionFloat(option_index, info->total_offset_x)); + break; + case OFFSET_MENU_SCREENS_Y_POS_DEC: + this->labels[index]->setText(setTextOptionFloat(option_index, info->total_offset_y)); + break; + default: + break; + } + } + + this->base_prepare(menu_scaling_factor, view_size_x, view_size_y); +} diff --git a/source/OptionSelectionMenu.cpp b/source/OptionSelectionMenu.cpp index e6217a4..01261f9 100755 --- a/source/OptionSelectionMenu.cpp +++ b/source/OptionSelectionMenu.cpp @@ -119,9 +119,20 @@ bool OptionSelectionMenu::is_option_location_multichoice(int option) { return false; } +void OptionSelectionMenu::set_default_cursor_position() { + this->future_data.option_selected = this->elements_start_id; + while(!(this->selectable_labels[this->future_data.option_selected] && this->future_enabled_labels[this->future_data.option_selected])){ + this->future_data.option_selected += 1; + if(this->future_data.option_selected >= this->num_elements_displayed_per_screen) + this->future_data.option_selected = 0; + if(this->future_data.option_selected == this->elements_start_id) + break; + } +} + void OptionSelectionMenu::decrement_selected_option(bool is_simple) { if(this->future_data.option_selected < 0) { - this->future_data.option_selected = this->elements_start_id; + this->set_default_cursor_position(); return; } bool location_left = this->is_option_location_left(this->future_data.option_selected); @@ -148,7 +159,7 @@ void OptionSelectionMenu::decrement_selected_option(bool is_simple) { void OptionSelectionMenu::increment_selected_option(bool is_simple) { if(this->future_data.option_selected < 0){ - this->future_data.option_selected = this->elements_start_id; + this->set_default_cursor_position(); return; } bool location_left = this->is_option_location_left(this->future_data.option_selected); diff --git a/source/RotationMenu.cpp b/source/RotationMenu.cpp new file mode 100755 index 0000000..9415540 --- /dev/null +++ b/source/RotationMenu.cpp @@ -0,0 +1,120 @@ +#include "RotationMenu.hpp" + +#define NUM_TOTAL_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0])) + +struct RotationMenuOptionInfo { + const std::string base_name; + const bool is_inc; + const std::string dec_str; + const std::string inc_str; + const RotationMenuOutAction inc_out_action; + const RotationMenuOutAction out_action; +}; + +static const RotationMenuOptionInfo top_rotation_option = { +.base_name = "Top Screen", +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = ROTATION_MENU_TOP_ROTATION_INC, +.out_action = ROTATION_MENU_TOP_ROTATION_DEC}; + +static const RotationMenuOptionInfo bottom_rotation_option = { +.base_name = "Bottom Screen", +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = ROTATION_MENU_BOTTOM_ROTATION_INC, +.out_action = ROTATION_MENU_BOTTOM_ROTATION_DEC}; + +static const RotationMenuOptionInfo* pollable_options[] = { +&top_rotation_option, +&bottom_rotation_option, +}; + +RotationMenu::RotationMenu(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; +} + +RotationMenu::~RotationMenu() { + delete []this->options_indexes; +} + +void RotationMenu::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 = "Rotation Settings"; + this->show_back_x = true; + this->show_x = false; + this->show_title = true; +} + +void RotationMenu::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 RotationMenu::reset_output_option() { + this->selected_index = RotationMenuOutAction::ROTATION_MENU_NO_ACTION; +} + +void RotationMenu::set_output_option(int index, int action) { + if(index == BACK_X_OUTPUT_OPTION) + this->selected_index = ROTATION_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 RotationMenu::get_num_options() { + return this->num_enabled_options; +} + +std::string RotationMenu::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; + return pollable_options[this->options_indexes[index]]->base_name; +} + +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) + 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 option_index = this->options_indexes[start + i]; + switch(pollable_options[option_index]->out_action) { + case ROTATION_MENU_TOP_ROTATION_DEC: + this->labels[index]->setText(setTextOptionInt(option_index, info->top_rotation)); + break; + case ROTATION_MENU_BOTTOM_ROTATION_DEC: + 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); +} diff --git a/source/VideoMenu.cpp b/source/VideoMenu.cpp index b0d4968..24043e2 100755 --- a/source/VideoMenu.cpp +++ b/source/VideoMenu.cpp @@ -74,49 +74,35 @@ static const VideoMenuOptionInfo one_par_option = { .out_action = VIDEO_MENU_ONE_PAR}; static const VideoMenuOptionInfo bottom_screen_pos_option = { -.base_name = "Bottom Screen Pos.", .false_name = "", +.base_name = "Screens Relative Positions", .false_name = "", .active_fullscreen = true, .active_windowed_screen = true, .active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false, .is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, .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, +.base_name = "Screen Offset", .false_name = "", +.active_fullscreen = false, .active_windowed_screen = true, .active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false, -.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.out_action = VIDEO_MENU_SMALL_SCREEN_OFFSET}; +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = VIDEO_MENU_SMALL_SCREEN_OFFSET_INC, +.out_action = VIDEO_MENU_SMALL_SCREEN_OFFSET_DEC}; -static const VideoMenuOptionInfo subscreen_distance_option = { -.base_name = "Sub-Screen Distance", .false_name = "", +static const VideoMenuOptionInfo offset_settings_option = { +.base_name = "Offset Settings", .false_name = "", .active_fullscreen = true, .active_windowed_screen = false, .active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false, .is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.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, -.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.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, -.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.out_action = VIDEO_MENU_SCREENS_Y_POS}; +.out_action = VIDEO_MENU_OFFSET_SETTINGS}; 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, -.is_inc = true, .dec_str = "-0.5", .inc_str = "+0.5", .inc_out_action = VIDEO_MENU_WINDOW_SCALING_INC, +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = VIDEO_MENU_WINDOW_SCALING_INC, .out_action = VIDEO_MENU_WINDOW_SCALING_DEC}; static const VideoMenuOptionInfo fullscreen_scaling_option = { -.base_name = "Screens Scaling", .false_name = "", +.base_name = "Screens Ratio", .false_name = "", .active_fullscreen = true, .active_windowed_screen = false, .active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false, .is_inc = true, .dec_str = "+ Top", .inc_str = "+ Bot.", .inc_out_action = VIDEO_MENU_FULLSCREEN_SCALING_BOTTOM, @@ -133,7 +119,7 @@ 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, -.is_inc = true, .dec_str = "-0.1", .inc_str = "+0.1", .inc_out_action = VIDEO_MENU_MENU_SCALING_INC, +.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = VIDEO_MENU_MENU_SCALING_INC, .out_action = VIDEO_MENU_MENU_SCALING_DEC}; static const VideoMenuOptionInfo resolution_settings_option = { @@ -143,33 +129,26 @@ static const VideoMenuOptionInfo resolution_settings_option = { .is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, .out_action = VIDEO_MENU_RESOLUTION_SETTINGS}; -static const VideoMenuOptionInfo top_rotation_option = { -.base_name = "Top Screen Rot.", .false_name = "", +static const VideoMenuOptionInfo rotation_settings_option = { +.base_name = "Rotation Settings", .false_name = "", .active_fullscreen = true, .active_windowed_screen = true, .active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false, .is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.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, -.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.out_action = VIDEO_MENU_BOTTOM_ROTATION}; +.out_action = VIDEO_MENU_ROTATION_SETTINGS}; 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, -.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.out_action = VIDEO_MENU_TOP_ROTATION}; +.is_inc = true, .dec_str = "Left", .inc_str = "Right", .inc_out_action = VIDEO_MENU_TOP_ROTATION_INC, +.out_action = VIDEO_MENU_TOP_ROTATION_DEC}; 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, -.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, -.out_action = VIDEO_MENU_BOTTOM_ROTATION}; +.is_inc = true, .dec_str = "Left", .inc_str = "Right", .inc_out_action = VIDEO_MENU_BOTTOM_ROTATION_INC, +.out_action = VIDEO_MENU_BOTTOM_ROTATION_DEC}; static const VideoMenuOptionInfo* pollable_options[] = { &crop_option, @@ -181,11 +160,8 @@ static const VideoMenuOptionInfo* pollable_options[] = { &async_option, &blur_option, &small_screen_offset_option, -&subscreen_distance_option, -&canvas_x_pos_option, -&canvas_y_pos_option, -&top_rotation_option, -&bottom_rotation_option, +&offset_settings_option, +&rotation_settings_option, &top_one_rotation_option, &bottom_one_rotation_option, &top_par_option, @@ -327,10 +303,13 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz case VIDEO_MENU_FULLSCREEN_SCALING_TOP: this->labels[index]->setText(setTextOptionDualPercentage(option_index, info->top_scaling, info->bot_scaling)); break; - case VIDEO_MENU_TOP_ROTATION: + case VIDEO_MENU_SMALL_SCREEN_OFFSET_DEC: + this->labels[index]->setText(setTextOptionFloat(option_index, info->subscreen_offset)); + break; + case VIDEO_MENU_TOP_ROTATION_DEC: this->labels[index]->setText(setTextOptionInt(option_index, info->top_rotation)); break; - case VIDEO_MENU_BOTTOM_ROTATION: + case VIDEO_MENU_BOTTOM_ROTATION_DEC: this->labels[index]->setText(setTextOptionInt(option_index, info->bot_rotation)); break; default: diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index beaf9e1..dd3e7df 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -25,6 +25,8 @@ WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, Disp this->video_menu = new VideoMenu(this->font_load_success, this->text_font); this->crop_menu = new CropMenu(this->font_load_success, this->text_font); this->par_menu = new PARMenu(this->font_load_success, this->text_font); + 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->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); @@ -54,6 +56,9 @@ WindowScreen::~WindowScreen() { delete this->main_menu; delete this->video_menu; delete this->crop_menu; + delete this->par_menu; + delete this->offset_menu; + delete this->rotation_menu; } void WindowScreen::build() { @@ -78,6 +83,7 @@ void WindowScreen::build() { } void WindowScreen::reload() { + this->curr_menu = DEFAULT_MENU_TYPE; this->future_operations.call_crop = true; this->future_operations.call_rotate = true; this->future_operations.call_blur = true; @@ -219,6 +225,20 @@ void WindowScreen::window_scaling_change(bool positive) { } } +void WindowScreen::rotation_change(int &value, bool right) { + int add_value = 90; + if(!right) + add_value = 270; + value = (value + add_value) % 360; + this->prepare_size_ratios(false, false); + this->future_operations.call_rotate = true; +} + +void WindowScreen::ratio_change(bool top_priority) { + this->prepare_size_ratios(top_priority, !top_priority); + this->future_operations.call_screen_settings_update = true; +} + bool WindowScreen::common_poll(SFEvent &event_data) { bool consumed = true; switch(event_data.type) { @@ -353,6 +373,22 @@ void WindowScreen::setup_par_menu(bool is_top) { } } +void WindowScreen::setup_offset_menu() { + if(this->curr_menu != OFFSET_MENU_TYPE) { + this->curr_menu = OFFSET_MENU_TYPE; + this->offset_menu->reset_data(); + this->offset_menu->insert_data(); + } +} + +void WindowScreen::setup_rotation_menu() { + if(this->curr_menu != ROTATION_MENU_TYPE) { + this->curr_menu = ROTATION_MENU_TYPE; + this->rotation_menu->reset_data(); + this->rotation_menu->insert_data(); + } +} + bool WindowScreen::no_menu_poll(SFEvent &event_data) { bool consumed = true; switch(event_data.type) { @@ -450,56 +486,37 @@ bool WindowScreen::main_poll(SFEvent &event_data) { break; case 'y': - this->prepare_size_ratios(true, false); - this->future_operations.call_screen_settings_update = true; + this->ratio_change(true); break; case 'u': - this->prepare_size_ratios(false, true); - this->future_operations.call_screen_settings_update = true; + this->ratio_change(false); break; case '8': - this->m_info.top_rotation = (this->m_info.top_rotation + 270) % 360; - this->m_info.bot_rotation = (this->m_info.bot_rotation + 270) % 360; - this->prepare_size_ratios(false, false); - this->future_operations.call_rotate = true; - + this->rotation_change(this->m_info.top_rotation, false); + this->rotation_change(this->m_info.bot_rotation, false); break; case '9': - this->m_info.top_rotation = (this->m_info.top_rotation + 90) % 360; - this->m_info.bot_rotation = (this->m_info.bot_rotation + 90) % 360; - this->prepare_size_ratios(false, false); - this->future_operations.call_rotate = true; + this->rotation_change(this->m_info.top_rotation, true); + this->rotation_change(this->m_info.bot_rotation, true); break; case 'h': - this->m_info.top_rotation = (this->m_info.top_rotation + 270) % 360; - this->prepare_size_ratios(false, false); - this->future_operations.call_rotate = true; - + this->rotation_change(this->m_info.top_rotation, false); break; case 'j': - this->m_info.top_rotation = (this->m_info.top_rotation + 90) % 360; - this->prepare_size_ratios(false, false); - this->future_operations.call_rotate = true; - + this->rotation_change(this->m_info.top_rotation, true); break; case 'k': - this->m_info.bot_rotation = (this->m_info.bot_rotation + 270) % 360; - this->prepare_size_ratios(false, false); - this->future_operations.call_rotate = true; - + this->rotation_change(this->m_info.bot_rotation, false); break; case 'l': - this->m_info.bot_rotation = (this->m_info.bot_rotation + 90) % 360; - this->prepare_size_ratios(false, false); - this->future_operations.call_rotate = true; - + this->rotation_change(this->m_info.bot_rotation, true); break; case 'r': @@ -686,6 +703,42 @@ void WindowScreen::poll() { case VIDEO_MENU_WINDOW_SCALING_INC: this->window_scaling_change(true); break; + case VIDEO_MENU_TOP_ROTATION_DEC: + this->rotation_change(this->m_info.top_rotation, false); + break; + case VIDEO_MENU_TOP_ROTATION_INC: + this->rotation_change(this->m_info.top_rotation, true); + break; + case VIDEO_MENU_BOTTOM_ROTATION_DEC: + this->rotation_change(this->m_info.bot_rotation, false); + break; + case VIDEO_MENU_BOTTOM_ROTATION_INC: + this->rotation_change(this->m_info.bot_rotation, true); + break; + case VIDEO_MENU_SMALL_SCREEN_OFFSET_DEC: + this->offset_change(this->m_info.subscreen_offset, -0.1); + break; + case VIDEO_MENU_SMALL_SCREEN_OFFSET_INC: + this->offset_change(this->m_info.subscreen_offset, 0.1); + break; + case VIDEO_MENU_FULLSCREEN_SCALING_TOP: + this->ratio_change(true); + break; + case VIDEO_MENU_FULLSCREEN_SCALING_BOTTOM: + this->ratio_change(false); + break; + case VIDEO_MENU_ROTATION_SETTINGS: + this->setup_rotation_menu(); + return; + case VIDEO_MENU_OFFSET_SETTINGS: + this->setup_offset_menu(); + return; + case VIDEO_MENU_BFI_SETTINGS: + break; + case VIDEO_MENU_RESOLUTION_SETTINGS: + break; + case VIDEO_MENU_BOTTOM_SCREEN_POS: + break; default: break; } @@ -740,6 +793,72 @@ void WindowScreen::poll() { continue; } break; + case ROTATION_MENU_TYPE: + if(this->rotation_menu->poll(event_data)) { + switch(this->rotation_menu->selected_index) { + case ROTATION_MENU_BACK: + this->setup_video_menu(); + return; + case ROTATION_MENU_NO_ACTION: + break; + case ROTATION_MENU_TOP_ROTATION_DEC: + this->rotation_change(this->m_info.top_rotation, false); + break; + case ROTATION_MENU_TOP_ROTATION_INC: + this->rotation_change(this->m_info.top_rotation, true); + break; + case ROTATION_MENU_BOTTOM_ROTATION_DEC: + this->rotation_change(this->m_info.bot_rotation, false); + break; + case ROTATION_MENU_BOTTOM_ROTATION_INC: + this->rotation_change(this->m_info.bot_rotation, true); + break; + default: + break; + } + this->rotation_menu->selected_index = ROTATION_MENU_NO_ACTION; + continue; + } + break; + case OFFSET_MENU_TYPE: + if(this->offset_menu->poll(event_data)) { + switch(this->offset_menu->selected_index) { + case OFFSET_MENU_BACK: + this->setup_video_menu(); + return; + case OFFSET_MENU_NO_ACTION: + break; + case OFFSET_MENU_SMALL_OFFSET_DEC: + this->offset_change(this->m_info.subscreen_offset, -0.1); + break; + case OFFSET_MENU_SMALL_OFFSET_INC: + this->offset_change(this->m_info.subscreen_offset, 0.1); + break; + case OFFSET_MENU_SMALL_SCREEN_DISTANCE_DEC: + this->offset_change(this->m_info.subscreen_attached_offset, -0.1); + break; + case OFFSET_MENU_SMALL_SCREEN_DISTANCE_INC: + this->offset_change(this->m_info.subscreen_attached_offset, 0.1); + break; + case OFFSET_MENU_SCREENS_X_POS_DEC: + this->offset_change(this->m_info.total_offset_x, -0.1); + break; + case OFFSET_MENU_SCREENS_X_POS_INC: + this->offset_change(this->m_info.total_offset_x, 0.1); + break; + case OFFSET_MENU_SCREENS_Y_POS_DEC: + this->offset_change(this->m_info.total_offset_y, -0.1); + break; + case OFFSET_MENU_SCREENS_Y_POS_INC: + this->offset_change(this->m_info.total_offset_y, 0.1); + break; + default: + break; + } + this->offset_menu->selected_index = OFFSET_MENU_NO_ACTION; + continue; + } + break; default: break; } @@ -844,6 +963,12 @@ void WindowScreen::draw(double frame_time, VideoOutputData* out_buf) { case BOTTOM_PAR_MENU_TYPE: this->par_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.bot_par); break; + case ROTATION_MENU_TYPE: + this->rotation_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + break; + case OFFSET_MENU_TYPE: + this->offset_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + break; default: break; } @@ -1154,6 +1279,12 @@ void WindowScreen::display_data_to_window(bool actually_draw) { case BOTTOM_PAR_MENU_TYPE: this->par_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); break; + case ROTATION_MENU_TYPE: + this->rotation_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + break; + case OFFSET_MENU_TYPE: + this->offset_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + break; default: break; } @@ -1300,9 +1431,10 @@ void WindowScreen::calc_scaling_resize_screens(sf::Vector2f &own_screen_size, sf int min_other_height = other_screen_size.y; get_par_size(min_other_width, min_other_height, 1, other_par); int chosen_ratio = prepare_screen_ratio(own_screen_size, own_rotation, min_other_width, min_other_height, other_rotation, own_par); - if(increase && (chosen_ratio > own_scaling) && (own_scaling > 0)) + int old_scaling = own_scaling; + if(increase && (chosen_ratio > own_scaling) && (chosen_ratio > 0)) own_scaling += 1; - else if(mantain && (chosen_ratio >= own_scaling) && (own_scaling > 0)) + else if(mantain && (chosen_ratio >= own_scaling) && (chosen_ratio > 0)) own_scaling = own_scaling; else own_scaling = chosen_ratio; @@ -1311,8 +1443,11 @@ void WindowScreen::calc_scaling_resize_screens(sf::Vector2f &own_screen_size, sf int own_height = own_screen_size.y; int own_width = own_screen_size.x; get_par_size(own_width, own_height, own_scaling, own_par); - other_scaling = prepare_screen_ratio(other_screen_size, other_rotation, own_width, own_height, own_rotation, other_par); - if(this->m_stype == ScreenType::JOINT) { + if((increase && ((old_scaling == own_scaling) || (other_scaling == 0)) || (mantain && (other_scaling == 0))) && (own_scaling > 0)) + other_scaling = 0; + else + other_scaling = prepare_screen_ratio(other_screen_size, other_rotation, own_width, own_height, own_rotation, other_par); + if((this->m_stype == ScreenType::JOINT) && (own_scaling > 0)) { // Due to size differences, it may be possible that // the chosen screen might be able to increase its // scaling even more without compromising the other one...