Make enabling game crops more seamless

This commit is contained in:
Lorenzooone 2024-06-25 00:28:50 +02:00
parent 781d7e28e7
commit e899286865
8 changed files with 19 additions and 28 deletions

View File

@ -12,8 +12,6 @@ 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;

View File

@ -212,7 +212,7 @@ private:
void fast_poll_change();
void padding_change();
void game_crop_enable_change();
void crop_value_change(int new_crop_value);
void crop_value_change(int new_crop_value, bool do_print_notification = true, bool do_cycle = true);
void par_value_change(int new_par_value, bool is_top);
void offset_change(float &value, float change);
void menu_scaling_change(bool positive);

View File

@ -24,7 +24,7 @@
#define SIMPLE_RESET_DATA_INDEX -2
#define CREATE_NEW_FILE_INDEX -3
std::string get_version_string();
std::string get_version_string(bool get_letter = true);
std::string LayoutNameGenerator(int index);
std::string LayoutPathGenerator(int index);
std::string load_layout_name(int index, bool &success);

View File

@ -806,13 +806,8 @@ std::vector<const CropData*>* WindowScreen::get_crop_data_vector(ScreenInfo* inf
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) {
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;
}

View File

@ -149,17 +149,21 @@ void WindowScreen::padding_change() {
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;
this->crop_value_change(*this->get_crop_index_ptr(&this->m_info), false, false);
}
void WindowScreen::crop_value_change(int new_crop_value) {
void WindowScreen::crop_value_change(int new_crop_value, bool do_print_notification, bool do_cycle) {
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((!do_cycle) && ((new_crop_value < 0) || (new_crop_value >= crops->size())))
new_value = 0;
if(new_value < 0)
new_value = 0;
if((*crop_value) != new_value) {
*crop_value = new_value;
this->print_notification("Crop: " + (*crops)[*crop_value]->name);
if(do_print_notification)
this->print_notification("Crop: " + (*crops)[*crop_value]->name);
this->prepare_size_ratios(false, false);
this->future_operations.call_crop = true;
}
@ -169,6 +173,8 @@ void WindowScreen::par_value_change(int new_par_value, bool is_top) {
if(((!is_top) && (this->m_stype == ScreenType::TOP)) || ((is_top) && (this->m_stype == ScreenType::BOTTOM)))
return;
int par_index = new_par_value % this->possible_pars.size();
if(par_index < 0)
par_index = 0;
std::string setting_name = "PAR: ";
bool updated = false;
if(is_top) {

View File

@ -174,6 +174,7 @@ static bool save(const std::string path, const std::string name, const std::stri
}
file << "name=" << save_name << std::endl;
file << "version=" << get_version_string(false) << std::endl;
file << save_screen_info("bot_", bottom_info);
file << save_screen_info("joint_", joint_info);
file << save_screen_info("top_", top_info);

View File

@ -406,8 +406,6 @@ 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 = false;
info.scaling = 1.0;
info.is_fullscreen = false;
@ -454,14 +452,6 @@ 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;
@ -588,8 +578,6 @@ 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";

View File

@ -30,8 +30,11 @@ bool is_big_endian(void) {
return value.c[0] == 1;
}
std::string get_version_string() {
return std::to_string(APP_VERSION_MAJOR) + "." + std::to_string(APP_VERSION_MINOR) + "." + std::to_string(APP_VERSION_REVISION) + xstr(APP_VERSION_LETTER);
std::string get_version_string(bool get_letter) {
std::string version_str = std::to_string(APP_VERSION_MAJOR) + "." + std::to_string(APP_VERSION_MINOR) + "." + std::to_string(APP_VERSION_REVISION);
if(get_letter)
return version_str + xstr(APP_VERSION_LETTER);
return version_str;
}
std::string get_float_str_decimals(float value, int decimals) {