Add padding for rounded corners

This commit is contained in:
Lorenzooone 2024-05-02 19:44:30 +02:00
parent 5c12303f0e
commit 2b1067d7cc
3 changed files with 30 additions and 0 deletions

View File

@ -34,6 +34,7 @@ struct ScreenInfo {
bool bfi;
double bfi_divider;
double menu_scaling_factor;
bool rounded_corners_fix;
};
struct DisplayData {

View File

@ -4,6 +4,11 @@
#include <cmath>
#include "font_ttf.h"
#define LEFT_ROUNDED_PADDING 5
#define RIGHT_ROUNDED_PADDING 5
#define TOP_ROUNDED_PADDING 0
#define BOTTOM_ROUNDED_PADDING 5
static int top_screen_crop_widths[] = {TOP_WIDTH_3DS, TOP_SPECIAL_DS_WIDTH_3DS, TOP_SCALED_DS_WIDTH_3DS, WIDTH_DS, WIDTH_SCALED_GBA, WIDTH_GBA, WIDTH_SCALED_GB, WIDTH_GB, WIDTH_SCALED_SNES, WIDTH_SNES, WIDTH_NES};
static int top_screen_crop_heights[] = {HEIGHT_3DS, HEIGHT_3DS, HEIGHT_3DS, HEIGHT_DS, HEIGHT_SCALED_GBA, HEIGHT_GBA, HEIGHT_SCALED_GB, HEIGHT_GB, HEIGHT_SCALED_SNES, HEIGHT_SNES, HEIGHT_NES};
static int bot_screen_crop_widths[] = {BOT_WIDTH_3DS, BOT_WIDTH_3DS, BOT_WIDTH_3DS, WIDTH_DS, 0, 0, 0, 0, 0, 0, 0};
@ -324,6 +329,15 @@ bool WindowScreen::main_poll(SFEvent &event_data) {
break;
case 'r':
if(this->m_info.is_fullscreen)
break;
this->m_info.rounded_corners_fix = !this->m_info.rounded_corners_fix;
this->future_operations.call_screen_settings_update = true;
this->print_notification_on_off("Extra Padding", this->m_info.rounded_corners_fix);
break;
case 'm':
audio_data->change_audio_mute();
break;
@ -1045,6 +1059,11 @@ void WindowScreen::resize_window_and_out_rects(bool do_work) {
int max_x = 0;
int max_y = 0;
if((!this->loaded_info.is_fullscreen) && this->loaded_info.rounded_corners_fix) {
offset_y = TOP_ROUNDED_PADDING;
offset_x = LEFT_ROUNDED_PADDING;
}
if(this->loaded_info.is_fullscreen) {
top_height = this->loaded_info.top_scaling * top_screen_size.y;
top_width = this->loaded_info.top_scaling * top_screen_size.x;
@ -1064,6 +1083,10 @@ void WindowScreen::resize_window_and_out_rects(bool do_work) {
this->m_out_rect_bot.out_rect.setTextureRect(sf::IntRect(0, 0, bot_screen_size.x, bot_screen_size.y));
}
this->set_position_screens(new_top_screen_size, new_bot_screen_size, offset_x, offset_y, max_x, max_y, do_work);
if((!this->loaded_info.is_fullscreen) && this->loaded_info.rounded_corners_fix) {
this->m_height += BOTTOM_ROUNDED_PADDING;
this->m_width += RIGHT_ROUNDED_PADDING;
}
}
void WindowScreen::create_window(bool re_prepare_size) {

View File

@ -25,6 +25,7 @@ void reset_screen_info(ScreenInfo &info) {
info.bfi = false;
info.bfi_divider = 2.0;
info.menu_scaling_factor = 1.0;
info.rounded_corners_fix = false;
}
bool load_screen_info(std::string key, std::string value, std::string base, ScreenInfo &info) {
@ -114,6 +115,10 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre
info.menu_scaling_factor = 5.0;
return true;
}
if(key == (base + "rounded_corners_fix")) {
info.rounded_corners_fix = std::stoi(value);
return true;
}
return false;
}
@ -137,6 +142,7 @@ std::string save_screen_info(std::string base, const ScreenInfo &info) {
out += base + "bfi=" + std::to_string(info.bfi) + "\n";
out += base + "bfi_divider=" + std::to_string(info.bfi_divider) + "\n";
out += base + "menu_scaling_factor=" + std::to_string(info.menu_scaling_factor) + "\n";
out += base + "rounded_corners_fix=" + std::to_string(info.rounded_corners_fix) + "\n";
return out;
}