Implement non-integer scaling modes

This commit is contained in:
Lorenzooone 2024-06-26 05:24:41 +02:00
parent 1d2288a6c9
commit 2ff03a67a2
10 changed files with 549 additions and 67 deletions

View File

@ -251,7 +251,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/WindowScreen_Menu.cpp source/3dscapture_ftd3.cpp source/dscapture_ftd2.cpp source/usb_ds_3ds_capture.cpp source/devicecapture.cpp source/conversions.cpp source/ExtraButtons.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 source/Menus/RelativePositionMenu.cpp source/Menus/ResolutionMenu.cpp source/Menus/FileConfigMenu.cpp source/Menus/ExtraSettingsMenu.cpp source/Menus/StatusMenu.cpp source/Menus/LicenseMenu.cpp source/WindowCommands.cpp source/Menus/ShortcutMenu.cpp source/Menus/ActionSelectionMenu.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/WindowScreen_Menu.cpp source/3dscapture_ftd3.cpp source/dscapture_ftd2.cpp source/usb_ds_3ds_capture.cpp source/devicecapture.cpp source/conversions.cpp source/ExtraButtons.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 source/Menus/RelativePositionMenu.cpp source/Menus/ResolutionMenu.cpp source/Menus/FileConfigMenu.cpp source/Menus/ExtraSettingsMenu.cpp source/Menus/StatusMenu.cpp source/Menus/LicenseMenu.cpp source/WindowCommands.cpp source/Menus/ShortcutMenu.cpp source/Menus/ActionSelectionMenu.cpp source/Menus/ScalingRatioMenu.cpp ${TOOLS_DATA_DIR}/font_ttf.cpp)
add_dependencies(${OUTPUT_NAME} FTD3XX_BUILD_PROJECT FTD2XX_BUILD_PROJECT CMakeBin2C)
target_link_libraries(${OUTPUT_NAME} PRIVATE sfml-graphics sfml-audio sfml-window sfml-system usb-1.0 ${ftd3xx_BINARY_DIR}/${FTD3XX_SUBFOLDER}/${FTD3XX_LIB} ${ftd2xx_BINARY_DIR}/${FTD2XX_SUBFOLDER}/${FTD2XX_LIB} ${EXTRA_LIBRARIES})
target_link_directories(${OUTPUT_NAME} PRIVATE ${ftd3xx_BINARY_DIR}/${FTD3XX_SUBFOLDER} ${ftd2xx_BINARY_DIR}/${FTD2XX_SUBFOLDER})

View File

@ -0,0 +1,41 @@
#ifndef __SCALINGRATIOMENU_HPP
#define __SCALINGRATIOMENU_HPP
#include "OptionSelectionMenu.hpp"
#include <chrono>
#include "TextRectangle.hpp"
#include "sfml_gfx_structs.hpp"
#include "display_structs.hpp"
enum ScalingRatioMenuOutAction{
SCALING_RATIO_MENU_NO_ACTION,
SCALING_RATIO_MENU_BACK,
SCALING_RATIO_MENU_FULLSCREEN_SCALING_TOP,
SCALING_RATIO_MENU_FULLSCREEN_SCALING_BOTTOM,
SCALING_RATIO_MENU_NON_INT_SCALING_TOP,
SCALING_RATIO_MENU_NON_INT_SCALING_BOTTOM,
SCALING_RATIO_MENU_ALGO_INC,
SCALING_RATIO_MENU_ALGO_DEC,
};
class ScalingRatioMenu : public OptionSelectionMenu {
public:
ScalingRatioMenu(bool font_load_success, sf::Font &text_font);
~ScalingRatioMenu();
void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info);
void insert_data();
ScalingRatioMenuOutAction selected_index = ScalingRatioMenuOutAction::SCALING_RATIO_MENU_NO_ACTION;
void reset_output_option();
protected:
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;
std::string setTextOptionDualPercentage(int index, float value_1, float value_2);
};
#endif

View File

@ -26,8 +26,6 @@ enum VideoMenuOutAction{
VIDEO_MENU_OFFSET_SETTINGS,
VIDEO_MENU_WINDOW_SCALING_DEC,
VIDEO_MENU_WINDOW_SCALING_INC,
VIDEO_MENU_FULLSCREEN_SCALING_TOP,
VIDEO_MENU_FULLSCREEN_SCALING_BOTTOM,
VIDEO_MENU_BFI_SETTINGS,
VIDEO_MENU_MENU_SCALING_DEC,
VIDEO_MENU_MENU_SCALING_INC,
@ -38,13 +36,15 @@ enum VideoMenuOutAction{
VIDEO_MENU_BOTTOM_ROTATION_DEC,
VIDEO_MENU_BOTTOM_ROTATION_INC,
VIDEO_MENU_FAST_POLL,
VIDEO_MENU_NON_INT_SCALING,
VIDEO_MENU_SCALING_RATIO_SETTINGS,
};
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, bool fast_poll);
void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info, bool fast_poll, ScreenType screen_type);
void insert_data(ScreenType s_type, bool is_fullscreen);
VideoMenuOutAction selected_index = VideoMenuOutAction::VIDEO_MENU_NO_ACTION;
void reset_output_option();
@ -57,6 +57,5 @@ protected:
private:
int *options_indexes;
int num_enabled_options;
std::string setTextOptionDualPercentage(int index, int value_1, int value_2);
};
#endif

View File

@ -6,7 +6,8 @@
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, 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, SHORTCUTS_MENU_TYPE, ACTION_SELECTION_MENU_TYPE };
enum NonIntegerScalingModes { SMALLER_PRIORITY, INVERSE_PROPORTIONAL_PRIORITY, EQUAL_PRIORITY, PROPORTIONAL_PRIORITY, BIGGER_PRIORITY, END_NONINT_SCALE_MODES };
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, SHORTCUTS_MENU_TYPE, ACTION_SELECTION_MENU_TYPE, SCALING_RATIO_MENU_TYPE };
struct ScreenInfo {
bool is_blurred;
@ -22,6 +23,7 @@ struct ScreenInfo {
bool v_sync_enabled;
bool async;
int top_scaling, bot_scaling;
float non_integer_top_scaling, non_integer_bot_scaling;
bool bfi;
int bfi_divider;
int bfi_amount;
@ -32,6 +34,9 @@ struct ScreenInfo {
int fullscreen_mode_width;
int fullscreen_mode_height;
int fullscreen_mode_bpp;
NonIntegerScalingModes non_integer_mode;
bool use_non_integer_scaling_top;
bool use_non_integer_scaling_bottom;
};
struct DisplayData {

View File

@ -29,6 +29,7 @@
#include "LicenseMenu.hpp"
#include "ShortcutMenu.hpp"
#include "ActionSelectionMenu.hpp"
#include "ScalingRatioMenu.hpp"
#include "display_structs.hpp"
#include "WindowCommands.hpp"
@ -88,6 +89,8 @@ private:
struct ResizingScreenData {
sf::Vector2f size;
int *scaling;
float* non_int_scaling;
bool use_non_int_scaling;
int rotation;
const PARData *par;
};
@ -142,6 +145,7 @@ private:
LicenseMenu *license_menu;
ShortcutMenu *shortcut_menu;
ActionSelectionMenu *action_selection_menu;
ScalingRatioMenu *scaling_ratio_menu;
std::vector<const CropData*> possible_crops;
std::vector<const CropData*> possible_crops_ds;
std::vector<const CropData*> possible_crops_with_games;
@ -221,6 +225,8 @@ private:
void ratio_change(bool top_priority, bool cycle = false);
void bfi_change();
void bottom_pos_change(int new_bottom_pos);
void non_int_scaling_change(bool target_top);
void non_int_mode_change(bool positive);
bool query_reset_request();
void reset_held_times();
void poll_window(bool do_everything);
@ -236,8 +242,15 @@ private:
void display_data_to_window(bool actually_draw, bool is_debug = false);
void window_render_call();
void set_position_screens(sf::Vector2f &curr_top_screen_size, sf::Vector2f &curr_bot_screen_size, int offset_x, int offset_y, int max_x, int max_y, bool do_work = true);
int prepare_screen_ratio(sf::Vector2f &screen_size, int own_rotation, int width_limit, int height_limit, int other_rotation, const PARData *own_par);
float get_max_float_screen_multiplier(ResizingScreenData *own_screen, int width_limit, int height_limit, int other_rotation);
int prepare_screen_ratio(ResizingScreenData *own_screen, int width_limit, int height_limit, int other_rotation);
bool can_non_integerly_scale();
void calc_scaling_resize_screens(ResizingScreenData *own_screen, ResizingScreenData* other_screen, bool increase, bool mantain, bool set_to_zero, bool cycle);
void rescale_nonint_subscreen(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data);
void direct_scale_nonint_screen(ResizingScreenData *main_screen_resize_data, int sub_min_width, int sub_min_height, int sub_screen_rotation);
void non_int_scale_screens_with_main(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data, int sub_min_width, int sub_height_min);
void non_int_scale_screens_both(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data, int free_width, int free_height, float multiplier_main, int main_min_width, int main_height_min, int sub_min_width, int sub_height_min);
void non_integer_scale_screens(ResizingScreenData *top_screen_resize_data, ResizingScreenData *bot_screen_resize_data);
void prepare_size_ratios(bool top_increase, bool bot_increase, bool cycle = false);
int get_fullscreen_offset_x(int top_width, int top_height, int bot_width, int bot_height);
int get_fullscreen_offset_y(int top_width, int top_height, int bot_width, int bot_height);
@ -271,6 +284,7 @@ private:
void setup_status_menu(bool reset_data = true);
void setup_licenses_menu(bool reset_data = true);
void setup_relative_pos_menu(bool reset_data = true);
void setup_scaling_ratio_menu(bool reset_data = true);
void update_connection();
};
@ -293,8 +307,10 @@ void reset_screen_info(ScreenInfo &info);
bool load_screen_info(std::string key, std::string value, std::string base, ScreenInfo &info);
std::string save_screen_info(std::string base, const ScreenInfo &info);
void get_par_size(int &width, int &height, float multiplier_factor, const PARData *correction_factor);
float get_par_mult_factor(float width, float height, float max_width, float max_height, const PARData *correction_factor, bool is_rotated);
void default_sleep(int wanted_ms = -1);
void update_output(FrontendData* frontend_data, double frame_time = 0.0, VideoOutputData *out_buf = NULL);
void update_connected_3ds_ds(FrontendData* frontend_data, const CaptureDevice &old_cc_device, const CaptureDevice &new_cc_device);
void screen_display_thread(WindowScreen *screen);
std::string get_name_non_int_mode(NonIntegerScalingModes input);
#endif

153
source/Menus/ScalingRatioMenu.cpp Executable file
View File

@ -0,0 +1,153 @@
#include "ScalingRatioMenu.hpp"
#include "frontend.hpp"
#define NUM_TOTAL_MENU_OPTIONS (sizeof(pollable_options)/sizeof(pollable_options[0]))
struct ScalingRatioMenuOptionInfo {
const std::string base_name;
const std::string false_name;
const bool is_inc;
const std::string dec_str;
const std::string inc_str;
const ScalingRatioMenuOutAction inc_out_action;
const ScalingRatioMenuOutAction out_action;
};
static const ScalingRatioMenuOptionInfo ratio_option = {
.base_name = "Screens Ratio", .false_name = "",
.is_inc = true, .dec_str = "+ Top", .inc_str = "+ Bot.", .inc_out_action = SCALING_RATIO_MENU_FULLSCREEN_SCALING_BOTTOM,
.out_action = SCALING_RATIO_MENU_FULLSCREEN_SCALING_TOP};
static const ScalingRatioMenuOptionInfo top_fill_option = {
.base_name = "Disable Top Screen Fill", .false_name = "Enable Top Screen Fill",
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = SCALING_RATIO_MENU_NO_ACTION,
.out_action = SCALING_RATIO_MENU_NON_INT_SCALING_TOP};
static const ScalingRatioMenuOptionInfo bot_fill_option = {
.base_name = "Disable Bot. Screen Fill", .false_name = "Enable Bot. Screen Fill",
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = SCALING_RATIO_MENU_NO_ACTION,
.out_action = SCALING_RATIO_MENU_NON_INT_SCALING_BOTTOM};
static const ScalingRatioMenuOptionInfo ratio_algo_option = {
.base_name = "Ratio Mode", .false_name = "",
.is_inc = true, .dec_str = "<", .inc_str = ">", .inc_out_action = SCALING_RATIO_MENU_ALGO_INC,
.out_action = SCALING_RATIO_MENU_ALGO_DEC};
static const ScalingRatioMenuOptionInfo* pollable_options[] = {
&ratio_option,
&top_fill_option,
&bot_fill_option,
&ratio_algo_option,
};
ScalingRatioMenu::ScalingRatioMenu(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;
}
ScalingRatioMenu::~ScalingRatioMenu() {
delete []this->options_indexes;
}
void ScalingRatioMenu::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 = "Scaling & Ratio Settings";
this->show_back_x = true;
this->show_x = false;
this->show_title = true;
}
void ScalingRatioMenu::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 ScalingRatioMenu::reset_output_option() {
this->selected_index = ScalingRatioMenuOutAction::SCALING_RATIO_MENU_NO_ACTION;
}
void ScalingRatioMenu::set_output_option(int index, int action) {
if(index == BACK_X_OUTPUT_OPTION)
this->selected_index = SCALING_RATIO_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 ScalingRatioMenu::get_num_options() {
return this->num_enabled_options;
}
std::string ScalingRatioMenu::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 ScalingRatioMenu::is_option_inc_dec(int index) {
return pollable_options[this->options_indexes[index]]->is_inc;
}
std::string ScalingRatioMenu::setTextOptionDualPercentage(int index, float value_1, float value_2) {
float sum = value_1 + value_2;
if(sum > 0) {
value_1 = (value_1 * 100) / sum;
value_2 = (value_2 * 100) / sum;
value_1 += 100 - (value_1 + value_2);
}
else {
value_1 = 0;
value_2 = 0;
}
return this->get_string_option(index, DEFAULT_ACTION) + ": " + get_float_str_decimals(value_1, 1) + " - " + get_float_str_decimals(value_2, 1);
}
void ScalingRatioMenu::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 SCALING_RATIO_MENU_FULLSCREEN_SCALING_TOP:
this->labels[index]->setText(this->setTextOptionDualPercentage(real_index, info->non_integer_top_scaling, info->non_integer_bot_scaling));
break;
case SCALING_RATIO_MENU_NON_INT_SCALING_TOP:
this->labels[index]->setText(this->setTextOptionBool(real_index, info->use_non_integer_scaling_top));
break;
case SCALING_RATIO_MENU_NON_INT_SCALING_BOTTOM:
this->labels[index]->setText(this->setTextOptionBool(real_index, info->use_non_integer_scaling_bottom));
break;
case SCALING_RATIO_MENU_ALGO_DEC:
this->labels[index]->setText(this->setTextOptionString(real_index, get_name_non_int_mode(info->non_integer_mode)));
break;
default:
break;
}
}
this->base_prepare(menu_scaling_factor, view_size_x, view_size_y);
}

View File

@ -101,13 +101,6 @@ static const VideoMenuOptionInfo window_scaling_option = {
.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 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,
.out_action = VIDEO_MENU_FULLSCREEN_SCALING_TOP};
static const VideoMenuOptionInfo bfi_settings_option = {
.base_name = "BFI Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
@ -164,10 +157,25 @@ static const VideoMenuOptionInfo allow_game_crops_option = {
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_GAMES_CROPPING};
static const VideoMenuOptionInfo allow_fill_scaling_option = {
.base_name = "Disable Fill Scaling", .false_name = "Enable Fill Scaling",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = false, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_NON_INT_SCALING};
static const VideoMenuOptionInfo scaling_ratio_settings_option = {
.base_name = "Scaling & Ratio 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_SCALING_RATIO_SETTINGS};
static const VideoMenuOptionInfo* pollable_options[] = {
&crop_option,
&window_scaling_option,
&fullscreen_scaling_option,
&allow_fill_scaling_option,
&scaling_ratio_settings_option,
&menu_scaling_option,
&bottom_screen_pos_option,
&vsync_option,
@ -267,21 +275,7 @@ bool VideoMenu::is_option_inc_dec(int index) {
return pollable_options[this->options_indexes[index]]->is_inc;
}
std::string VideoMenu::setTextOptionDualPercentage(int index, int value_1, int value_2) {
int sum = value_1 + value_2;
if(sum > 0) {
value_1 = ((value_1 * 100) + (sum / 2)) / sum;
value_2 = ((value_2 * 100) + (sum / 2)) / sum;
value_1 += 100 - (value_1 + value_2);
}
else {
value_1 = 0;
value_2 = 0;
}
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, bool fast_poll) {
void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info, bool fast_poll, ScreenType screen_type) {
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
@ -311,9 +305,6 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz
case VIDEO_MENU_MENU_SCALING_DEC:
this->labels[index]->setText(this->setTextOptionFloat(real_index, info->menu_scaling_factor));
break;
case VIDEO_MENU_FULLSCREEN_SCALING_TOP:
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(this->setTextOptionFloat(real_index, info->subscreen_offset));
break;
@ -325,8 +316,16 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz
break;
case VIDEO_MENU_FAST_POLL:
this->labels[index]->setText(this->setTextOptionBool(real_index, fast_poll));
break;
case VIDEO_MENU_GAMES_CROPPING:
this->labels[index]->setText(this->setTextOptionBool(real_index, info->allow_games_crops));
break;
case VIDEO_MENU_NON_INT_SCALING:
if(screen_type == ScreenType::TOP)
this->labels[index]->setText(this->setTextOptionBool(real_index, info->use_non_integer_scaling_top));
else if(screen_type == ScreenType::BOTTOM)
this->labels[index]->setText(this->setTextOptionBool(real_index, info->use_non_integer_scaling_bottom));
break;
default:
break;
}

View File

@ -535,8 +535,8 @@ void WindowScreen::set_position_screens(sf::Vector2f &curr_top_screen_size, sf::
this->m_height = bot_end_y;
}
int WindowScreen::prepare_screen_ratio(sf::Vector2f &screen_size, int own_rotation, int width_limit, int height_limit, int other_rotation, const PARData* own_par) {
if((screen_size.x < 1.0) || (screen_size.y < 1.0))
float WindowScreen::get_max_float_screen_multiplier(ResizingScreenData *own_screen, int width_limit, int height_limit, int other_rotation) {
if((own_screen->size.x < 1.0) || (own_screen->size.y < 1.0))
return 0;
if((other_rotation / 10) % 2)
@ -558,32 +558,20 @@ int WindowScreen::prepare_screen_ratio(sf::Vector2f &screen_size, int own_rotati
break;
}
int explored_multiplier = 1;
bool done = false;
while(!done) {
int own_width = screen_size.x;
int own_height = screen_size.y;
get_par_size(own_width, own_height, explored_multiplier, own_par);
return get_par_mult_factor(own_screen->size.x, own_screen->size.y, width_max, height_max, own_screen->par, (own_screen->rotation / 10) % 2);
}
if((own_rotation / 10) % 2)
std::swap(own_width, own_height);
if((own_width > width_max) || (own_height > height_max))
done = true;
else
explored_multiplier += 1;
}
return explored_multiplier - 1;
int WindowScreen::prepare_screen_ratio(ResizingScreenData *own_screen, int width_limit, int height_limit, int other_rotation) {
return this->get_max_float_screen_multiplier(own_screen, width_limit, height_limit, other_rotation);
}
void WindowScreen::calc_scaling_resize_screens(ResizingScreenData *own_screen, ResizingScreenData* other_screen, bool increase, bool mantain, bool set_to_zero, bool cycle) {
int other_width = other_screen->size.x;
int other_height = other_screen->size.y;
get_par_size(other_width, other_height, 1, other_screen->par);
int chosen_ratio = prepare_screen_ratio(own_screen->size, own_screen->rotation, other_width, other_height, other_screen->rotation, own_screen->par);
int chosen_ratio = prepare_screen_ratio(own_screen, other_width, other_height, other_screen->rotation);
if(chosen_ratio <= 0) {
chosen_ratio = prepare_screen_ratio(own_screen->size, own_screen->rotation, 0, 0, other_screen->rotation, own_screen->par);
chosen_ratio = prepare_screen_ratio(own_screen, 0, 0, other_screen->rotation);
if(chosen_ratio <= 0)
chosen_ratio = 0;
}
@ -604,7 +592,7 @@ void WindowScreen::calc_scaling_resize_screens(ResizingScreenData *own_screen, R
if((increase && ((old_scaling == (*own_screen->scaling)) || ((*other_screen->scaling) == 0)) || (mantain && ((*other_screen->scaling) == 0))) && ((*own_screen->scaling) > 0))
(*other_screen->scaling) = 0;
else
(*other_screen->scaling) = prepare_screen_ratio(other_screen->size, other_screen->rotation, own_width, own_height, own_screen->rotation, other_screen->par);
(*other_screen->scaling) = prepare_screen_ratio(other_screen, own_width, own_height, own_screen->rotation);
if((*other_screen->scaling) < 0)
(*other_screen->scaling) = 0;
if((this->m_stype == ScreenType::JOINT) && (((*own_screen->scaling) > 0) || (((*other_screen->scaling) == 0) && ((*own_screen->scaling) == 0)))) {
@ -614,12 +602,130 @@ void WindowScreen::calc_scaling_resize_screens(ResizingScreenData *own_screen, R
other_width = other_screen->size.x;
other_height = other_screen->size.y;
get_par_size(other_width, other_height, *other_screen->scaling, other_screen->par);
(*own_screen->scaling) = prepare_screen_ratio(own_screen->size, own_screen->rotation, other_width, other_height, other_screen->rotation, own_screen->par);
(*own_screen->scaling) = prepare_screen_ratio(own_screen, other_width, other_height, other_screen->rotation);
if((*own_screen->scaling) < 0)
(*own_screen->scaling) = 0;
}
}
bool WindowScreen::can_non_integerly_scale() {
return ((this->m_info.top_scaling != 0) || (this->m_info.bot_scaling != 0)) && ((this->m_info.use_non_integer_scaling_top && (this->m_info.top_scaling != 0)) || (this->m_info.use_non_integer_scaling_bottom && (this->m_info.bot_scaling != 0)));
}
void WindowScreen::rescale_nonint_subscreen(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data) {
int new_width = main_screen_resize_data->size.x;
int new_height = main_screen_resize_data->size.y;
get_par_size(new_width, new_height, *main_screen_resize_data->non_int_scaling, main_screen_resize_data->par);
*sub_screen_resize_data->non_int_scaling = this->get_max_float_screen_multiplier(sub_screen_resize_data, new_width, new_height, main_screen_resize_data->rotation);
if(!sub_screen_resize_data->use_non_int_scaling)
*sub_screen_resize_data->non_int_scaling = static_cast<int>(*sub_screen_resize_data->non_int_scaling);
}
void WindowScreen::direct_scale_nonint_screen(ResizingScreenData *main_screen_resize_data, int sub_min_width, int sub_height_min, int sub_screen_rotation) {
*main_screen_resize_data->non_int_scaling = this->get_max_float_screen_multiplier(main_screen_resize_data, sub_min_width, sub_height_min, sub_screen_rotation);
if(!main_screen_resize_data->use_non_int_scaling)
*main_screen_resize_data->non_int_scaling = static_cast<int>(*main_screen_resize_data->non_int_scaling);
}
void WindowScreen::non_int_scale_screens_with_main(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data, int sub_min_width, int sub_height_min) {
this->direct_scale_nonint_screen(main_screen_resize_data, sub_min_width, sub_height_min, sub_screen_resize_data->rotation);
this->rescale_nonint_subscreen(main_screen_resize_data, sub_screen_resize_data);
}
void WindowScreen::non_int_scale_screens_both(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data, int free_width, int free_height, float multiplier_main, int main_min_width, int main_height_min, int sub_min_width, int sub_height_min) {
int main_free_width = (free_width * multiplier_main) + 0.5;
int main_free_height = (free_height * multiplier_main) + 0.5;
int sub_free_width = free_width - main_free_width;
int sub_free_height = free_height - main_free_height;
this->direct_scale_nonint_screen(main_screen_resize_data, sub_min_width + sub_free_width, sub_height_min + sub_free_height, sub_screen_resize_data->rotation);
this->direct_scale_nonint_screen(sub_screen_resize_data, main_min_width + main_free_width, main_height_min + main_free_height, main_screen_resize_data->rotation);
this->rescale_nonint_subscreen(main_screen_resize_data, sub_screen_resize_data);
this->rescale_nonint_subscreen(sub_screen_resize_data, main_screen_resize_data);
}
void WindowScreen::non_integer_scale_screens(ResizingScreenData *top_screen_resize_data, ResizingScreenData *bot_screen_resize_data) {
if(!this->can_non_integerly_scale()) {
this->m_info.non_integer_top_scaling = this->m_info.top_scaling;
this->m_info.non_integer_bot_scaling = this->m_info.bot_scaling;
return;
}
if(this->m_info.top_scaling == 0) {
this->m_info.non_integer_top_scaling = 0;
this->m_info.non_integer_bot_scaling = this->get_max_float_screen_multiplier(bot_screen_resize_data, 0, 0, 0);
return;
}
if(this->m_info.bot_scaling == 0) {
this->m_info.non_integer_bot_scaling = 0;
this->m_info.non_integer_top_scaling = this->get_max_float_screen_multiplier(top_screen_resize_data, 0, 0, 0);
return;
}
int more_top_top_scaling = this->m_info.top_scaling;
int more_top_bot_scaling = this->m_info.bot_scaling;
int more_bot_top_scaling = this->m_info.top_scaling;
int more_bot_bot_scaling = this->m_info.bot_scaling;
top_screen_resize_data->scaling = &more_top_top_scaling;
bot_screen_resize_data->scaling = &more_top_bot_scaling;
calc_scaling_resize_screens(top_screen_resize_data, bot_screen_resize_data, true, false, this->m_stype == ScreenType::BOTTOM, false);
top_screen_resize_data->scaling = &more_bot_top_scaling;
bot_screen_resize_data->scaling = &more_bot_bot_scaling;
calc_scaling_resize_screens(bot_screen_resize_data, top_screen_resize_data, true, false, this->m_stype == ScreenType::TOP, false);
top_screen_resize_data->scaling = &this->m_info.top_scaling;
bot_screen_resize_data->scaling = &this->m_info.bot_scaling;
int min_top_scaling = more_bot_top_scaling + 1;
int min_bot_scaling = more_top_bot_scaling + 1;
if(min_top_scaling > this->m_info.top_scaling)
min_top_scaling = this->m_info.top_scaling;
if(min_bot_scaling > this->m_info.bot_scaling)
min_bot_scaling = this->m_info.bot_scaling;
int min_top_screen_width = top_screen_resize_data->size.x;
int min_top_screen_height = top_screen_resize_data->size.y;
int min_bot_screen_width = bot_screen_resize_data->size.x;
int min_bot_screen_height = bot_screen_resize_data->size.y;
get_par_size(min_top_screen_width, min_top_screen_height, min_top_scaling, top_screen_resize_data->par);
get_par_size(min_bot_screen_width, min_bot_screen_height, min_bot_scaling, bot_screen_resize_data->par);
ResizingScreenData *bigger_screen_resize_data = top_screen_resize_data;
ResizingScreenData *smaller_screen_resize_data = bot_screen_resize_data;
int min_bigger_screen_width = min_top_screen_width;
int min_bigger_screen_height = min_top_screen_height;
int min_smaller_screen_width = min_bot_screen_width;
int min_smaller_screen_height = min_bot_screen_height;
bool is_top_bigger = this->m_info.top_scaling >= this->m_info.bot_scaling;
if(!is_top_bigger) {
std::swap(bigger_screen_resize_data, smaller_screen_resize_data);
std::swap(min_bigger_screen_width, min_smaller_screen_width);
std::swap(min_bigger_screen_height, min_smaller_screen_height);
}
if((top_screen_resize_data->rotation / 10) % 2)
std::swap(min_top_screen_width, min_top_screen_height);
if((bot_screen_resize_data->rotation / 10) % 2)
std::swap(min_bot_screen_width, min_bot_screen_height);
int free_width = curr_desk_mode.width - (min_bot_screen_width + min_top_screen_width);
int free_height = curr_desk_mode.height - (min_bot_screen_height + min_top_screen_height);
switch(this->m_info.non_integer_mode) {
case SMALLER_PRIORITY:
this->non_int_scale_screens_with_main(smaller_screen_resize_data, bigger_screen_resize_data, min_bigger_screen_width, min_bigger_screen_height);
break;
case BIGGER_PRIORITY:
this->non_int_scale_screens_with_main(bigger_screen_resize_data, smaller_screen_resize_data, min_smaller_screen_width, min_smaller_screen_height);
break;
case EQUAL_PRIORITY:
this->non_int_scale_screens_both(bigger_screen_resize_data, smaller_screen_resize_data, free_width, free_height, 0.5, min_bigger_screen_width, min_bigger_screen_height, min_smaller_screen_width, min_smaller_screen_height);
break;
case PROPORTIONAL_PRIORITY:
this->non_int_scale_screens_both(bigger_screen_resize_data, smaller_screen_resize_data, free_width, free_height, ((float)(*bigger_screen_resize_data->scaling)) / ((*bigger_screen_resize_data->scaling) + (*smaller_screen_resize_data->scaling)), min_bigger_screen_width, min_bigger_screen_height, min_smaller_screen_width, min_smaller_screen_height);
break;
case INVERSE_PROPORTIONAL_PRIORITY:
this->non_int_scale_screens_both(bigger_screen_resize_data, smaller_screen_resize_data, free_width, free_height, ((float)(*smaller_screen_resize_data->scaling)) / ((*bigger_screen_resize_data->scaling) + (*smaller_screen_resize_data->scaling)), min_bigger_screen_width, min_bigger_screen_height, min_smaller_screen_width, min_smaller_screen_height);
break;
default:
break;
}
}
void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase, bool cycle) {
if(!this->m_info.is_fullscreen)
return;
@ -645,12 +751,14 @@ void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase, boo
this->m_info.top_par = 0;
if((this->m_info.bot_par >= this->possible_pars.size()) || (this->m_info.bot_par < 0))
this->m_info.bot_par = 0;
ResizingScreenData top_screen_resize_data = {.size = top_screen_size, .scaling = &this->m_info.top_scaling, .rotation = this->m_info.top_rotation, .par = this->possible_pars[this->m_info.top_par]};
ResizingScreenData bot_screen_resize_data = {.size = bot_screen_size, .scaling = &this->m_info.bot_scaling, .rotation = this->m_info.bot_rotation, .par = this->possible_pars[this->m_info.bot_par]};
ResizingScreenData top_screen_resize_data = {.size = top_screen_size, .scaling = &this->m_info.top_scaling, .non_int_scaling = &this->m_info.non_integer_top_scaling, .use_non_int_scaling = this->m_info.use_non_integer_scaling_top, .rotation = this->m_info.top_rotation, .par = this->possible_pars[this->m_info.top_par]};
ResizingScreenData bot_screen_resize_data = {.size = bot_screen_size, .scaling = &this->m_info.bot_scaling, .non_int_scaling = &this->m_info.non_integer_bot_scaling, .use_non_int_scaling = this->m_info.use_non_integer_scaling_bottom, .rotation = this->m_info.bot_rotation, .par = this->possible_pars[this->m_info.bot_par]};
if(prioritize_top)
calc_scaling_resize_screens(&top_screen_resize_data, &bot_screen_resize_data, top_increase, try_mantain_ratio, this->m_stype == ScreenType::BOTTOM, cycle);
else
calc_scaling_resize_screens(&bot_screen_resize_data, &top_screen_resize_data, bot_increase, try_mantain_ratio, this->m_stype == ScreenType::TOP, cycle);
this->non_integer_scale_screens(&top_screen_resize_data, &bot_screen_resize_data);
}
int WindowScreen::get_fullscreen_offset_x(int top_width, int top_height, int bot_width, int bot_height) {
@ -716,8 +824,8 @@ void WindowScreen::resize_window_and_out_rects(bool do_work) {
int max_y = 0;
if(this->loaded_info.is_fullscreen) {
top_scaling = this->loaded_info.top_scaling;
bot_scaling = this->loaded_info.bot_scaling;
top_scaling = this->loaded_info.non_integer_top_scaling;
bot_scaling = this->loaded_info.non_integer_bot_scaling;
}
if((this->loaded_info.top_par >= this->possible_pars.size()) || (this->loaded_info.top_par < 0))
this->loaded_info.top_par = 0;

View File

@ -76,6 +76,7 @@ void WindowScreen::init_menus() {
this->license_menu = new LicenseMenu(this->font_load_success, this->text_font);
this->shortcut_menu = new ShortcutMenu(this->font_load_success, this->text_font);
this->action_selection_menu = new ActionSelectionMenu(this->font_load_success, this->text_font);
this->scaling_ratio_menu = new ScalingRatioMenu(this->font_load_success, this->text_font);
}
void WindowScreen::destroy_menus() {
@ -96,6 +97,7 @@ void WindowScreen::destroy_menus() {
delete this->license_menu;
delete this->shortcut_menu;
delete this->action_selection_menu;
delete this->scaling_ratio_menu;
}
void WindowScreen::set_close(int ret_val) {
@ -283,6 +285,28 @@ void WindowScreen::bottom_pos_change(int new_bottom_pos) {
}
}
void WindowScreen::non_int_scaling_change(bool target_top) {
if(this->m_stype == ScreenType::TOP)
target_top = true;
else if(this->m_stype == ScreenType::BOTTOM)
target_top = false;
if(target_top)
this->m_info.use_non_integer_scaling_top = !this->m_info.use_non_integer_scaling_top;
else
this->m_info.use_non_integer_scaling_bottom = !this->m_info.use_non_integer_scaling_bottom;
this->prepare_size_ratios(true, true);
this->future_operations.call_screen_settings_update = true;
}
void WindowScreen::non_int_mode_change(bool positive) {
int change = 1;
if(!positive)
change = END_NONINT_SCALE_MODES - 1;
this->m_info.non_integer_mode = static_cast<NonIntegerScalingModes>((this->m_info.non_integer_mode + change) % END_NONINT_SCALE_MODES);
this->prepare_size_ratios(true, true);
this->future_operations.call_screen_settings_update = true;
}
bool WindowScreen::can_execute_cmd(const WindowCommand* window_cmd, bool is_extra, bool is_always) {
if((!window_cmd->usable_always) && is_always)
return false;
@ -818,6 +842,18 @@ void WindowScreen::setup_relative_pos_menu(bool reset_data) {
}
}
void WindowScreen::setup_scaling_ratio_menu(bool reset_data) {
if(!this->can_setup_menu())
return;
if(this->curr_menu != SCALING_RATIO_MENU_TYPE) {
this->curr_menu = SCALING_RATIO_MENU_TYPE;
if(reset_data)
this->scaling_ratio_menu->reset_data();
this->scaling_ratio_menu->insert_data();
this->last_menu_change_time = std::chrono::high_resolution_clock::now();
}
}
void WindowScreen::update_save_menu() {
if(this->curr_menu == SAVE_MENU_TYPE) {
this->curr_menu = DEFAULT_MENU_TYPE;
@ -1312,12 +1348,6 @@ void WindowScreen::poll(bool do_everything) {
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();
done = true;
@ -1341,6 +1371,12 @@ void WindowScreen::poll(bool do_everything) {
case VIDEO_MENU_GAMES_CROPPING:
this->game_crop_enable_change();
break;
case VIDEO_MENU_NON_INT_SCALING:
this->non_int_scaling_change(false);
break;
case VIDEO_MENU_SCALING_RATIO_SETTINGS:
this->setup_scaling_ratio_menu();
break;
default:
break;
}
@ -1652,6 +1688,40 @@ void WindowScreen::poll(bool do_everything) {
continue;
}
break;
case SCALING_RATIO_MENU_TYPE:
if(this->scaling_ratio_menu->poll(event_data)) {
switch(this->scaling_ratio_menu->selected_index) {
case SCALING_RATIO_MENU_BACK:
this->setup_video_menu(false);
done = true;
break;
case SCALING_RATIO_MENU_NO_ACTION:
break;
case SCALING_RATIO_MENU_FULLSCREEN_SCALING_TOP:
this->ratio_change(true);
break;
case SCALING_RATIO_MENU_FULLSCREEN_SCALING_BOTTOM:
this->ratio_change(false);
break;
case SCALING_RATIO_MENU_NON_INT_SCALING_TOP:
this->non_int_scaling_change(true);
break;
case SCALING_RATIO_MENU_NON_INT_SCALING_BOTTOM:
this->non_int_scaling_change(false);
break;
case SCALING_RATIO_MENU_ALGO_DEC:
this->non_int_mode_change(false);
break;
case SCALING_RATIO_MENU_ALGO_INC:
this->non_int_mode_change(true);
break;
default:
break;
}
this->scaling_ratio_menu->reset_output_option();
continue;
}
break;
default:
break;
}
@ -1813,7 +1883,7 @@ void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) {
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, this->display_data->fast_poll);
this->video_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->display_data->fast_poll, this->m_stype);
break;
case CROP_MENU_TYPE:
this->crop_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, *this->get_crop_index_ptr(&this->loaded_info));
@ -1863,6 +1933,9 @@ void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) {
case LICENSES_MENU_TYPE:
this->license_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y);
break;
case SCALING_RATIO_MENU_TYPE:
this->scaling_ratio_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info);
break;
default:
break;
}
@ -1927,6 +2000,9 @@ void WindowScreen::execute_menu_draws() {
case LICENSES_MENU_TYPE:
this->license_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
case SCALING_RATIO_MENU_TYPE:
this->scaling_ratio_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
default:
break;
}

View File

@ -421,6 +421,8 @@ void reset_screen_info(ScreenInfo &info) {
info.async = true;
info.top_scaling = -1;
info.bot_scaling = -1;
info.non_integer_top_scaling = -1.0;
info.non_integer_bot_scaling = -1.0;
info.bfi = false;
info.bfi_divider = 2;
info.bfi_amount = 1;
@ -429,6 +431,9 @@ void reset_screen_info(ScreenInfo &info) {
info.top_par = 0;
info.bot_par = 0;
reset_fullscreen_info(info);
info.non_integer_mode = SMALLER_PRIORITY;
info.use_non_integer_scaling_top = false;
info.use_non_integer_scaling_bottom = false;
}
static float offset_sanitization(float value) {
@ -510,10 +515,12 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre
}
if(key == (base + "top_scaling")) {
info.top_scaling = std::stoi(value);
info.non_integer_top_scaling = info.top_scaling;
return true;
}
if(key == (base + "bot_scaling")) {
info.bot_scaling = std::stoi(value);
info.non_integer_bot_scaling = info.bot_scaling;
return true;
}
if(key == (base + "bfi")) {
@ -570,6 +577,21 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre
info.fullscreen_mode_bpp = std::stoi(value);
return true;
}
if(key == (base + "non_integer_mode")) {
int read_value = std::stoi(value);
if((read_value < 0) || (read_value >= END_NONINT_SCALE_MODES))
read_value = 0;
info.non_integer_mode = static_cast<NonIntegerScalingModes>(read_value);
return true;
}
if(key == (base + "use_non_integer_scaling_top")) {
info.use_non_integer_scaling_top = std::stoi(value);
return true;
}
if(key == (base + "use_non_integer_scaling_bottom")) {
info.use_non_integer_scaling_bottom = std::stoi(value);
return true;
}
return false;
}
@ -602,6 +624,9 @@ std::string save_screen_info(std::string base, const ScreenInfo &info) {
out += base + "fullscreen_mode_width=" + std::to_string(info.fullscreen_mode_width) + "\n";
out += base + "fullscreen_mode_height=" + std::to_string(info.fullscreen_mode_height) + "\n";
out += base + "fullscreen_mode_bpp=" + std::to_string(info.fullscreen_mode_bpp) + "\n";
out += base + "non_integer_mode=" + std::to_string(info.non_integer_mode) + "\n";
out += base + "use_non_integer_scaling_top=" + std::to_string(info.use_non_integer_scaling_top) + "\n";
out += base + "use_non_integer_scaling_bottom=" + std::to_string(info.use_non_integer_scaling_bottom) + "\n";
return out;
}
@ -638,6 +663,43 @@ void get_par_size(int &width, int &height, float multiplier_factor, const PARDat
}
}
float get_par_mult_factor(float width, float height, float max_width, float max_height, const PARData *correction_factor, bool is_rotated) {
float correction_factor_divisor = correction_factor->width_multiplier;
float correction_factor_multiplier = correction_factor->width_divisor;
if(correction_factor->is_width_main) {
correction_factor_divisor = correction_factor->width_divisor;
correction_factor_multiplier = correction_factor->width_multiplier;
}
if(correction_factor->is_fit) {
if(correction_factor->is_width_main)
width = height * correction_factor_multiplier;
else
height = width * correction_factor_multiplier;
}
else {
if(correction_factor->is_width_main)
width = width * correction_factor_multiplier;
else
height = height * correction_factor_multiplier;
}
bool apply_to_max_width = correction_factor->is_width_main;
if(is_rotated) {
std::swap(width, height);
apply_to_max_width = !apply_to_max_width;
}
if(apply_to_max_width)
max_width = max_width * correction_factor_divisor;
else
max_height = max_height * correction_factor_divisor;
if((height == 0) || (width == 0))
return 0;
float factor_width = max_width / width;
float factor_height = max_height / height;
if(factor_height < factor_width)
return factor_height;
return factor_width;
}
JoystickDirection get_joystick_direction(uint32_t joystickId, sf::Joystick::Axis axis, float position) {
bool is_horizontal = false;
if((axis == sf::Joystick::Z) || (axis == sf::Joystick::R))
@ -722,9 +784,32 @@ void update_connected_3ds_ds(FrontendData* frontend_data, const CaptureDevice &o
frontend_data->bot_screen->update_ds_3ds_connection(changed_type);
frontend_data->joint_screen->update_ds_3ds_connection(changed_type);
}
}
void screen_display_thread(WindowScreen *screen) {
screen->display_thread();
}
std::string get_name_non_int_mode(NonIntegerScalingModes input) {
std::string output = "";
switch(input) {
case SMALLER_PRIORITY:
output = "Smaller Priority";
break;
case EQUAL_PRIORITY:
output = "Same Priority";
break;
case PROPORTIONAL_PRIORITY:
output = "Prop. Priority";
break;
case INVERSE_PROPORTIONAL_PRIORITY:
output = "Inv. Prop. Priority";
break;
case BIGGER_PRIORITY:
output = "Bigger Priority";
break;
default:
break;
}
return output;
}