Add game specific crops, and more PARs

This commit is contained in:
Lorenzooone 2024-06-24 23:45:11 +02:00
parent 9c7978bcbd
commit f609be0721
7 changed files with 296 additions and 90 deletions

View File

@ -16,6 +16,7 @@ enum VideoMenuOutAction{
VIDEO_MENU_BLUR,
VIDEO_MENU_PADDING,
VIDEO_MENU_CROPPING,
VIDEO_MENU_GAMES_CROPPING,
VIDEO_MENU_TOP_PAR,
VIDEO_MENU_BOT_PAR,
VIDEO_MENU_ONE_PAR,

View File

@ -12,6 +12,9 @@ struct ScreenInfo {
bool is_blurred;
int crop_kind;
int crop_kind_ds;
int crop_kind_games;
int crop_kind_ds_games;
bool allow_games_crops;
double scaling;
bool is_fullscreen;
BottomRelativePosition bottom_pos;
@ -62,6 +65,7 @@ struct CropData {
bool allowed_bottom;
bool allowed_3ds;
bool allowed_ds;
bool is_game_specific;
std::string name;
};
@ -69,6 +73,7 @@ struct PARData {
float width_multiplier;
float width_divisor;
bool is_width_main;
bool is_fit;
std::string name;
};

View File

@ -144,6 +144,8 @@ private:
ActionSelectionMenu *action_selection_menu;
std::vector<const CropData*> possible_crops;
std::vector<const CropData*> possible_crops_ds;
std::vector<const CropData*> possible_crops_with_games;
std::vector<const CropData*> possible_crops_ds_with_games;
std::vector<const PARData*> possible_pars;
std::vector<sf::VideoMode> possible_resolutions;
std::vector<FileData> possible_files;
@ -209,6 +211,7 @@ private:
void blur_change();
void fast_poll_change();
void padding_change();
void game_crop_enable_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);
@ -245,7 +248,9 @@ private:
void open();
void update_screen_settings();
void rotate();
sf::Vector2f getShownScreenSize(bool is_top, int &crop_kind);
std::vector<const CropData*>* get_crop_data_vector(ScreenInfo* info);
int* get_crop_index_ptr(ScreenInfo* info);
sf::Vector2f getShownScreenSize(bool is_top, ScreenInfo* info);
void crop();
void setWinSize(bool is_main_thread);
bool can_setup_menu();
@ -280,14 +285,13 @@ struct FrontendData {
void FPSArrayInit(FPSArray *array);
void FPSArrayDestroy(FPSArray *array);
void FPSArrayInsertElement(FPSArray *array, double frame_time);
void insert_basic_crops(std::vector<const CropData*> &crop_vector, ScreenType s_type, bool is_ds);
void insert_basic_crops(std::vector<const CropData*> &crop_vector, ScreenType s_type, bool is_ds, bool allow_game_specific);
void insert_basic_pars(std::vector<const PARData*> &par_vector);
void reset_display_data(DisplayData *display_data);
void reset_fullscreen_info(ScreenInfo &info);
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(float &width, float &height, float multiplier_factor, const PARData *correction_factor);
void get_par_size(int &width, int &height, float multiplier_factor, const PARData *correction_factor);
void default_sleep(int wanted_ms = -1);
void update_output(FrontendData* frontend_data, double frame_time = 0.0, VideoOutputData *out_buf = NULL);

View File

@ -157,8 +157,16 @@ static const VideoMenuOptionInfo fast_poll_option = {
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_FAST_POLL};
static const VideoMenuOptionInfo allow_game_crops_option = {
.base_name = "Disable Game Crops", .false_name = "Enable Game Crops",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .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_GAMES_CROPPING};
static const VideoMenuOptionInfo* pollable_options[] = {
&crop_option,
//&allow_game_crops_option,
&window_scaling_option,
&fullscreen_scaling_option,
&menu_scaling_option,
@ -317,6 +325,8 @@ 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));
case VIDEO_MENU_GAMES_CROPPING:
this->labels[index]->setText(this->setTextOptionBool(real_index, info->allow_games_crops));
default:
break;
}

View File

@ -10,8 +10,10 @@
WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, DisplayData* display_data, AudioData* audio_data, ExtraButtonShortcuts* extra_button_shortcuts) {
this->m_stype = stype;
insert_basic_crops(this->possible_crops, this->m_stype, false);
insert_basic_crops(this->possible_crops_ds, this->m_stype, true);
insert_basic_crops(this->possible_crops, this->m_stype, false, false);
insert_basic_crops(this->possible_crops_ds, this->m_stype, true, false);
insert_basic_crops(this->possible_crops_with_games, this->m_stype, false, true);
insert_basic_crops(this->possible_crops_ds_with_games, this->m_stype, true, true);
insert_basic_pars(this->possible_pars);
this->m_prepare_save = 0;
this->m_prepare_load = 0;
@ -622,12 +624,8 @@ void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase, boo
if(!this->m_info.is_fullscreen)
return;
sf::Vector2f top_screen_size = getShownScreenSize(true, this->m_info.crop_kind);
sf::Vector2f bot_screen_size = getShownScreenSize(false, this->m_info.crop_kind);
if(this->display_data->last_connected_ds) {
top_screen_size = getShownScreenSize(true, this->m_info.crop_kind_ds);
bot_screen_size = getShownScreenSize(false, this->m_info.crop_kind_ds);
}
sf::Vector2f top_screen_size = getShownScreenSize(true, &this->m_info);
sf::Vector2f bot_screen_size = getShownScreenSize(false, &this->m_info);
if(this->m_stype == ScreenType::TOP) {
bot_increase = true;
@ -700,12 +698,8 @@ int WindowScreen::get_fullscreen_offset_y(int top_width, int top_height, int bot
}
void WindowScreen::resize_window_and_out_rects(bool do_work) {
sf::Vector2f top_screen_size = getShownScreenSize(true, this->loaded_info.crop_kind);
sf::Vector2f bot_screen_size = getShownScreenSize(false, this->loaded_info.crop_kind);
if(this->display_data->last_connected_ds) {
top_screen_size = getShownScreenSize(true, this->loaded_info.crop_kind_ds);
bot_screen_size = getShownScreenSize(false, this->loaded_info.crop_kind_ds);
}
sf::Vector2f top_screen_size = getShownScreenSize(true, &this->loaded_info);
sf::Vector2f bot_screen_size = getShownScreenSize(false, &this->loaded_info);
int top_width = top_screen_size.x;
int top_height = top_screen_size.y;
float top_scaling = this->loaded_info.scaling;
@ -798,34 +792,53 @@ void WindowScreen::rotate() {
this->loaded_operations.call_screen_settings_update = true;
}
sf::Vector2f WindowScreen::getShownScreenSize(bool is_top, int &crop_kind) {
std::vector<const CropData*>* WindowScreen::get_crop_data_vector(ScreenInfo* info) {
std::vector<const CropData*> *crops = &this->possible_crops;
if(this->display_data->last_connected_ds)
if(info->allow_games_crops)
crops = &this->possible_crops_with_games;
if(this->display_data->last_connected_ds) {
crops = &this->possible_crops_ds;
if(crop_kind >= crops->size())
crop_kind = 0;
int width = (*crops)[crop_kind]->top_width;
int height = (*crops)[crop_kind]->top_height;
if(info->allow_games_crops)
crops = &this->possible_crops_ds_with_games;
}
return crops;
}
int* WindowScreen::get_crop_index_ptr(ScreenInfo* info) {
int *crop_ptr = &info->crop_kind;
if(info->allow_games_crops)
crop_ptr = &info->crop_kind_games;
if(this->display_data->last_connected_ds) {
crop_ptr = &info->crop_kind_ds;
if(info->allow_games_crops)
crop_ptr = &info->crop_kind_ds_games;
}
return crop_ptr;
}
sf::Vector2f WindowScreen::getShownScreenSize(bool is_top, ScreenInfo* info) {
std::vector<const CropData*> *crops = this->get_crop_data_vector(info);
int *crop_kind = this->get_crop_index_ptr(info);
if((*crop_kind) >= crops->size())
*crop_kind = 0;
int width = (*crops)[*crop_kind]->top_width;
int height = (*crops)[*crop_kind]->top_height;
if(!is_top) {
width = (*crops)[crop_kind]->bot_width;
height = (*crops)[crop_kind]->bot_height;
width = (*crops)[*crop_kind]->bot_width;
height = (*crops)[*crop_kind]->bot_height;
}
return sf::Vector2f(width, height);
}
void WindowScreen::crop() {
std::vector<const CropData*> *crops = &this->possible_crops;
int *crop_value = &this->loaded_info.crop_kind;
if(this->display_data->last_connected_ds) {
crops = &this->possible_crops_ds;
crop_value = &this->loaded_info.crop_kind_ds;
}
std::vector<const CropData*> *crops = this->get_crop_data_vector(&this->loaded_info);
int *crop_value = this->get_crop_index_ptr(&this->loaded_info);
if((*crop_value) >= crops->size())
*crop_value = 0;
sf::Vector2f top_screen_size = getShownScreenSize(true, *crop_value);
sf::Vector2f bot_screen_size = getShownScreenSize(false, *crop_value);
sf::Vector2f top_screen_size = getShownScreenSize(true, &this->loaded_info);
sf::Vector2f bot_screen_size = getShownScreenSize(false, &this->loaded_info);
this->resize_in_rect(this->m_in_rect_top, this->capture_status->device.top_screen_x + (*crops)[*crop_value]->top_x, this->capture_status->device.top_screen_y + (*crops)[*crop_value]->top_y, top_screen_size.x, top_screen_size.y);
this->resize_in_rect(this->m_in_rect_bot, this->capture_status->device.bot_screen_x + (*crops)[*crop_value]->bot_x, this->capture_status->device.bot_screen_y + (*crops)[*crop_value]->bot_y, bot_screen_size.x, bot_screen_size.y);

View File

@ -146,13 +146,16 @@ void WindowScreen::padding_change() {
this->print_notification_on_off("Extra Padding", this->m_info.rounded_corners_fix);
}
void WindowScreen::game_crop_enable_change() {
this->m_info.allow_games_crops = !this->m_info.allow_games_crops;
this->print_notification_on_off("Game Specific Crops", this->m_info.allow_games_crops);
this->prepare_size_ratios(false, false);
this->future_operations.call_crop = true;
}
void WindowScreen::crop_value_change(int new_crop_value) {
std::vector<const CropData*> *crops = &this->possible_crops;
int *crop_value = &this->m_info.crop_kind;
if(this->display_data->last_connected_ds) {
crops = &this->possible_crops_ds;
crop_value = &this->m_info.crop_kind_ds;
}
std::vector<const CropData*> *crops = this->get_crop_data_vector(&this->m_info);
int *crop_value = this->get_crop_index_ptr(&this->m_info);
int new_value = new_crop_value % crops->size();
if((*crop_value) != new_value) {
*crop_value = new_value;
@ -295,10 +298,7 @@ bool WindowScreen::execute_cmd(PossibleWindowCommands id) {
this->fullscreen_change();
break;
case WINDOW_COMMAND_CROP:
if(this->display_data->last_connected_ds)
this->crop_value_change(this->m_info.crop_kind_ds + 1);
else
this->crop_value_change(this->m_info.crop_kind + 1);
this->crop_value_change(*this->get_crop_index_ptr(&this->m_info) + 1);
break;
case WINDOW_COMMAND_ASYNC:
this->async_change();
@ -576,10 +576,7 @@ void WindowScreen::setup_crop_menu(bool reset_data) {
this->curr_menu = CROP_MENU_TYPE;
if(reset_data)
this->crop_menu->reset_data();
if(this->display_data->last_connected_ds)
this->crop_menu->insert_data(&this->possible_crops_ds);
else
this->crop_menu->insert_data(&this->possible_crops);
this->crop_menu->insert_data(this->get_crop_data_vector(&this->m_info));
this->last_menu_change_time = std::chrono::high_resolution_clock::now();
}
}
@ -1335,6 +1332,9 @@ void WindowScreen::poll(bool do_everything) {
this->setup_relative_pos_menu();
done = true;
break;
case VIDEO_MENU_GAMES_CROPPING:
this->game_crop_enable_change();
break;
default:
break;
}
@ -1810,7 +1810,7 @@ void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) {
this->video_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->display_data->fast_poll);
break;
case CROP_MENU_TYPE:
this->crop_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.crop_kind);
this->crop_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, *this->get_crop_index_ptr(&this->loaded_info));
break;
case TOP_PAR_MENU_TYPE:
this->par_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.top_par);

View File

@ -7,7 +7,7 @@ const CropData default_3ds_crop = {
.bot_width = BOT_WIDTH_3DS, .bot_height = HEIGHT_3DS,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "3DS"};
const CropData special_ds_crop = {
@ -16,7 +16,7 @@ const CropData special_ds_crop = {
.bot_width = BOT_WIDTH_3DS, .bot_height = HEIGHT_3DS,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "16:10"};
const CropData scaled_ds_crop = {
@ -25,7 +25,7 @@ const CropData scaled_ds_crop = {
.bot_width = BOT_WIDTH_3DS, .bot_height = HEIGHT_3DS,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "Scaled DS"};
const CropData native_ds_crop = {
@ -34,7 +34,7 @@ const CropData native_ds_crop = {
.bot_width = WIDTH_DS, .bot_height = HEIGHT_DS,
.bot_x = (BOT_WIDTH_3DS - WIDTH_DS) / 2, .bot_y = HEIGHT_3DS - HEIGHT_DS,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "Native DS"};
const CropData scaled_gba_crop = {
@ -43,7 +43,7 @@ const CropData scaled_gba_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "Scaled GBA"};
const CropData native_gba_crop = {
@ -52,7 +52,7 @@ const CropData native_gba_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "Native GBA"};
const CropData scaled_vc_gb_crop = {
@ -61,7 +61,7 @@ const CropData scaled_vc_gb_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "Scaled VC GB"};
const CropData vc_gb_crop = {
@ -70,7 +70,7 @@ const CropData vc_gb_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "VC GB"};
const CropData scaled_snes_crop = {
@ -79,7 +79,7 @@ const CropData scaled_snes_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "Scaled SNES"};
const CropData vc_snes_crop = {
@ -88,7 +88,7 @@ const CropData vc_snes_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "VC SNES"};
const CropData vc_nes_crop = {
@ -97,34 +97,70 @@ const CropData vc_nes_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = false,
.name = "VC NES"};
const CropData scaled_ds_pokemon_crop = {
.top_width = TOP_SCALED_DS_WIDTH_3DS - 4, .top_height = HEIGHT_3DS - 4,
.top_x = (TOP_WIDTH_3DS - TOP_SCALED_DS_WIDTH_3DS + 4) / 2, .top_y = 2,
.top_width = TOP_SCALED_DS_WIDTH_3DS - 6, .top_height = HEIGHT_3DS - 6,
.top_x = (TOP_WIDTH_3DS - TOP_SCALED_DS_WIDTH_3DS + 6) / 2, .top_y = 3,
.bot_width = BOT_WIDTH_3DS, .bot_height = HEIGHT_3DS,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Scaled Pokemon DS"};
const CropData scaled_ds_pmd_brt_crop = {
.top_width = TOP_SCALED_DS_WIDTH_3DS, .top_height = HEIGHT_3DS,
.top_x = (TOP_WIDTH_3DS - TOP_SCALED_DS_WIDTH_3DS) / 2, .top_y = 0,
.bot_width = BOT_WIDTH_3DS - 3, .bot_height = HEIGHT_3DS,
.bot_x = 3, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Scaled PMD:BRT"};
const CropData native_ds_pokemon_crop = {
.top_width = WIDTH_DS - 2, .top_height = HEIGHT_DS - 2,
.top_x = (TOP_WIDTH_3DS - WIDTH_DS + 2) / 2, .top_y = 1,
.bot_width = WIDTH_DS, .bot_height = HEIGHT_DS,
.bot_x = (BOT_WIDTH_3DS - WIDTH_DS) / 2, .bot_y = HEIGHT_3DS - HEIGHT_DS,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = true, .allowed_ds = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Native Pokemon DS"};
const CropData native_ds_pmd_brt_crop = {
.top_width = WIDTH_DS, .top_height = HEIGHT_DS,
.top_x = (TOP_WIDTH_3DS - WIDTH_DS) / 2, .top_y = 0,
.bot_width = WIDTH_DS - 1, .bot_height = HEIGHT_DS,
.bot_x = (BOT_WIDTH_3DS - WIDTH_DS + 2) / 2, .bot_y = HEIGHT_3DS - HEIGHT_DS,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Native PMD:BRT"};
const CropData scaled_gba_pmd_rrt_crop = {
.top_width = WIDTH_SCALED_GBA - 3, .top_height = HEIGHT_SCALED_GBA,
.top_x = (TOP_WIDTH_3DS - WIDTH_SCALED_GBA + 6) / 2, .top_y = (HEIGHT_3DS - HEIGHT_SCALED_GBA) / 2,
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Scaled PMD:RRT"};
const CropData native_gba_pmd_rrt_crop = {
.top_width = WIDTH_GBA - 1, .top_height = HEIGHT_GBA,
.top_x = (TOP_WIDTH_3DS - WIDTH_GBA + 2) / 2, .top_y = (HEIGHT_3DS - HEIGHT_GBA) / 2,
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Native PMD:RRT"};
const CropData default_ds_crop = {
.top_width = WIDTH_DS, .top_height = HEIGHT_DS,
.top_x = 0, .top_y = 0,
.bot_width = WIDTH_DS, .bot_height = HEIGHT_DS,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = false, .allowed_ds = true,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = false,
.name = "DS"};
const CropData top_gba_ds_crop = {
@ -133,7 +169,7 @@ const CropData top_gba_ds_crop = {
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = false, .allowed_ds = true,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = false,
.name = "Top GBA"};
const CropData bottom_gba_ds_crop = {
@ -142,7 +178,7 @@ const CropData bottom_gba_ds_crop = {
.bot_width = WIDTH_GBA, .bot_height = HEIGHT_GBA,
.bot_x = (WIDTH_DS - WIDTH_GBA) / 2, .bot_y = (HEIGHT_DS - HEIGHT_GBA) / 2,
.allowed_joint = true, .allowed_top = false, .allowed_bottom = true,
.allowed_3ds = false, .allowed_ds = true,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = false,
.name = "Bottom GBA"};
const CropData ds_pokemon_crop = {
@ -151,9 +187,36 @@ const CropData ds_pokemon_crop = {
.bot_width = WIDTH_DS, .bot_height = HEIGHT_DS,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = false, .allowed_ds = true,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = true,
.name = "Pokemon DS"};
const CropData ds_pmd_brt_crop = {
.top_width = WIDTH_DS, .top_height = HEIGHT_DS,
.top_x = 0, .top_y = 0,
.bot_width = WIDTH_DS - 1, .bot_height = HEIGHT_DS,
.bot_x = 1, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = true,
.name = "PMD:BRT"};
const CropData top_gba_ds_pmd_rrt_crop = {
.top_width = WIDTH_GBA - 1, .top_height = HEIGHT_GBA,
.top_x = (WIDTH_DS - WIDTH_GBA + 2) / 2, .top_y = (HEIGHT_DS - HEIGHT_GBA) / 2,
.bot_width = 0, .bot_height = 0,
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = true,
.name = "Top GBA"};
const CropData bottom_gba_ds_pmd_rrt_crop = {
.top_width = 0, .top_height = 0,
.top_x = 0, .top_y = 0,
.bot_width = WIDTH_GBA - 1, .bot_height = HEIGHT_GBA,
.bot_x = (WIDTH_DS - WIDTH_GBA + 2) / 2, .bot_y = (HEIGHT_DS - HEIGHT_GBA) / 2,
.allowed_joint = true, .allowed_top = false, .allowed_bottom = true,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = true,
.name = "Bottom GBA"};
static const CropData* basic_possible_crops[] = {
&default_3ds_crop,
&special_ds_crop,
@ -166,37 +229,114 @@ static const CropData* basic_possible_crops[] = {
&scaled_snes_crop,
&vc_snes_crop,
&vc_nes_crop,
&scaled_ds_pokemon_crop,
&native_ds_pokemon_crop,
&default_ds_crop,
&top_gba_ds_crop,
&bottom_gba_ds_crop,
&scaled_ds_pokemon_crop,
&native_ds_pokemon_crop,
&ds_pokemon_crop,
&scaled_ds_pmd_brt_crop,
&native_ds_pmd_brt_crop,
&ds_pmd_brt_crop,
&scaled_gba_pmd_rrt_crop,
&native_gba_pmd_rrt_crop,
&top_gba_ds_pmd_rrt_crop,
&bottom_gba_ds_pmd_rrt_crop,
};
const PARData base_par = {
.width_multiplier = 1.0, .width_divisor = 1.0,
.is_width_main = true,
.is_width_main = true, .is_fit = false,
.name = "1:1"};
const PARData snes_horizontal_par = {
.width_multiplier = 8.0, .width_divisor = 7.0,
.is_width_main = true,
.is_width_main = true, .is_fit = false,
.name = "SNES Horizontal"};
const PARData snes_vertical_par = {
.width_multiplier = 8.0, .width_divisor = 7.0,
.is_width_main = false,
.is_width_main = false, .is_fit = false,
.name = "SNES Vertical"};
const PARData lb_horizontal_par = {
.width_multiplier = 4.0, .width_divisor = 3.0,
.is_width_main = true, .is_fit = false,
.name = "4:3 Horizontal"};
const PARData lb_vertical_par = {
.width_multiplier = 4.0, .width_divisor = 3.0,
.is_width_main = false, .is_fit = false,
.name = "4:3 Vertical"};
const PARData top_3ds_horizontal_par = {
.width_multiplier = 5.0, .width_divisor = 3.0,
.is_width_main = true, .is_fit = false,
.name = "5:3 Horizontal"};
const PARData top_3ds_vertical_par = {
.width_multiplier = 5.0, .width_divisor = 3.0,
.is_width_main = false, .is_fit = false,
.name = "5:3 Vertical"};
const PARData wide_horizontal_par = {
.width_multiplier = 16.0, .width_divisor = 9.0,
.is_width_main = true, .is_fit = false,
.name = "16:9 Horizontal"};
const PARData wide_vertical_par = {
.width_multiplier = 16.0, .width_divisor = 9.0,
.is_width_main = false, .is_fit = false,
.name = "16:9 Vertical"};
const PARData fit_square_horizontal_par = {
.width_multiplier = 1.0, .width_divisor = 1.0,
.is_width_main = true, .is_fit = true,
.name = "Fit to 1:1 H."};
const PARData fit_square_vertical_par = {
.width_multiplier = 1.0, .width_divisor = 1.0,
.is_width_main = false, .is_fit = true,
.name = "Fit to 1:1 V."};
const PARData fit_lb_horizontal_par = {
.width_multiplier = 4.0, .width_divisor = 3.0,
.is_width_main = true, .is_fit = true,
.name = "Fit to 4:3 H."};
const PARData fit_lb_vertical_par = {
.width_multiplier = 4.0, .width_divisor = 3.0,
.is_width_main = false, .is_fit = true,
.name = "Fit to 4:3 V."};
const PARData fit_top_3ds_horizontal_par = {
.width_multiplier = 5.0, .width_divisor = 3.0,
.is_width_main = true, .is_fit = true,
.name = "Fit to 5:3 H."};
const PARData fit_top_3ds_vertical_par = {
.width_multiplier = 5.0, .width_divisor = 3.0,
.is_width_main = false, .is_fit = true,
.name = "Fit to 5:3 V."};
const PARData fit_wide_horizontal_par = {
.width_multiplier = 16.0, .width_divisor = 9.0,
.is_width_main = true, .is_fit = true,
.name = "Fit to 16:9 H."};
const PARData fit_wide_vertical_par = {
.width_multiplier = 16.0, .width_divisor = 9.0,
.is_width_main = false, .is_fit = true,
.name = "Fit to 16:9 V."};
const PARData special_3ds_horizontal_par = {
.width_multiplier = 1.0, .width_divisor = 2.0,
.is_width_main = true,
.is_width_main = true, .is_fit = false,
.name = "3DS 800x240 Horizontal"};
const PARData special_3ds_vertical_par = {
.width_multiplier = 1.0, .width_divisor = 2.0,
.is_width_main = false,
.is_width_main = false, .is_fit = false,
.name = "3DS 800x240 Vertical"};
static const PARData* basic_possible_pars[] = {
@ -205,13 +345,29 @@ static const PARData* basic_possible_pars[] = {
&snes_vertical_par,
//&special_3ds_horizontal_par,
//&special_3ds_vertical_par,
&lb_horizontal_par,
&lb_vertical_par,
&top_3ds_horizontal_par,
&top_3ds_vertical_par,
&wide_horizontal_par,
&wide_vertical_par,
&fit_square_horizontal_par,
&fit_square_vertical_par,
&fit_lb_horizontal_par,
&fit_lb_vertical_par,
&fit_top_3ds_horizontal_par,
&fit_top_3ds_vertical_par,
&fit_wide_horizontal_par,
&fit_wide_vertical_par,
};
static bool is_allowed_crop(const CropData* crop_data, ScreenType s_type, bool is_ds) {
static bool is_allowed_crop(const CropData* crop_data, ScreenType s_type, bool is_ds, bool allow_game_specific) {
if(is_ds && (!crop_data->allowed_ds))
return false;
if((!is_ds) && (!crop_data->allowed_3ds))
return false;
if((!allow_game_specific) && (crop_data->is_game_specific))
return false;
if((s_type == ScreenType::JOINT) && (!crop_data->allowed_joint))
return false;
if((s_type == ScreenType::TOP) && (!crop_data->allowed_top))
@ -221,9 +377,9 @@ static bool is_allowed_crop(const CropData* crop_data, ScreenType s_type, bool i
return true;
}
void insert_basic_crops(std::vector<const CropData*> &crop_vector, ScreenType s_type, bool is_ds) {
void insert_basic_crops(std::vector<const CropData*> &crop_vector, ScreenType s_type, bool is_ds, bool allow_game_specific) {
for(int i = 0; i < (sizeof(basic_possible_crops) / sizeof(basic_possible_crops[0])); i++) {
if(is_allowed_crop(basic_possible_crops[i], s_type, is_ds))
if(is_allowed_crop(basic_possible_crops[i], s_type, is_ds, allow_game_specific))
crop_vector.push_back(basic_possible_crops[i]);
}
}
@ -250,6 +406,9 @@ void reset_screen_info(ScreenInfo &info) {
info.is_blurred = false;
info.crop_kind = 0;
info.crop_kind_ds = 0;
info.crop_kind_games = 0;
info.crop_kind_ds_games = 0;
info.allow_games_crops = true;
info.scaling = 1.0;
info.is_fullscreen = false;
info.bottom_pos = UNDER_TOP;
@ -295,6 +454,18 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre
info.crop_kind_ds = std::stoi(value);
return true;
}
if(key == (base + "crop_kind_games")) {
info.crop_kind_games = std::stoi(value);
return true;
}
if(key == (base + "crop_kind_ds_games")) {
info.crop_kind_ds_games = std::stoi(value);
return true;
}
if(key == (base + "allow_games_crops")) {
info.allow_games_crops = std::stoi(value);
return true;
}
if(key == (base + "scale")) {
info.scaling = std::stod(value);
if(info.scaling < 1.25)
@ -417,6 +588,9 @@ std::string save_screen_info(std::string base, const ScreenInfo &info) {
out += base + "blur=" + std::to_string(info.is_blurred) + "\n";
out += base + "crop=" + std::to_string(info.crop_kind) + "\n";
out += base + "crop_ds=" + std::to_string(info.crop_kind_ds) + "\n";
out += base + "crop_kind_games=" + std::to_string(info.crop_kind_games) + "\n";
out += base + "crop_kind_ds_games=" + std::to_string(info.crop_kind_ds_games) + "\n";
out += base + "allow_games_crops=" + std::to_string(info.allow_games_crops) + "\n";
out += base + "scale=" + std::to_string(info.scaling) + "\n";
out += base + "fullscreen=" + std::to_string(info.is_fullscreen) + "\n";
out += base + "bot_pos=" + std::to_string(info.bottom_pos) + "\n";
@ -462,19 +636,18 @@ void get_par_size(int &width, int &height, float multiplier_factor, const PARDat
if(correction_factor->is_width_main)
correction_factor_divisor = correction_factor->width_divisor;
float correction_factor_approx_contribute = correction_factor_divisor / 2;
if(correction_factor->is_width_main)
width = ((width * correction_factor->width_multiplier) + correction_factor_approx_contribute) / correction_factor_divisor;
else
height = ((height * correction_factor->width_divisor) + correction_factor_approx_contribute) / correction_factor_divisor;
}
void get_par_size(float &width, float &height, float multiplier_factor, const PARData *correction_factor) {
width *= multiplier_factor;
height *= multiplier_factor;
if(correction_factor->is_width_main)
width = (width * correction_factor->width_multiplier) / correction_factor->width_divisor;
else
height = (height * correction_factor->width_divisor) / correction_factor->width_multiplier;
if(correction_factor->is_fit) {
if(correction_factor->is_width_main)
width = ((height * correction_factor->width_multiplier) + correction_factor_approx_contribute) / correction_factor_divisor;
else
height = ((width * correction_factor->width_divisor) + correction_factor_approx_contribute) / correction_factor_divisor;
}
else {
if(correction_factor->is_width_main)
width = ((width * correction_factor->width_multiplier) + correction_factor_approx_contribute) / correction_factor_divisor;
else
height = ((height * correction_factor->width_divisor) + correction_factor_approx_contribute) / correction_factor_divisor;
}
}
JoystickDirection get_joystick_direction(uint32_t joystickId, sf::Joystick::Axis axis, float position) {