From fac279e60b638e2a95b50e306f6aa9f16fa5e73b Mon Sep 17 00:00:00 2001 From: Spencer Vaughn Date: Mon, 20 Nov 2023 20:13:43 -0600 Subject: [PATCH 1/2] updated evolve ux --- include/pksavhelper.h | 2 -- src/filehelper.c | 2 -- src/pksavhelper.c | 28 ++-------------------------- src/screens/EvolveScreen.c | 21 ++++++++++----------- src/screens/SettingsScreen.c | 34 +--------------------------------- 5 files changed, 13 insertions(+), 74 deletions(-) diff --git a/include/pksavhelper.h b/include/pksavhelper.h index 607d0ce..b71ffaa 100644 --- a/include/pksavhelper.h +++ b/include/pksavhelper.h @@ -94,8 +94,6 @@ void update_pkmn_DVs(PokemonSave *pkmn_save, uint8_t pkmn_party_index); void update_pkmn_stats(PokemonSave *pkmn_save, uint8_t pkmn_party_index); bool get_is_random_DVs_disabled(void); void set_is_random_DVs_disabled(bool is_disabled); -bool get_is_item_required(void); -void set_is_item_required(bool is_required); void generate_rand_num_step(SaveGenerationType save_generation_type); enum eligible_trade_status check_trade_eligibility(struct trainer_info *trainer, uint8_t pkmn_party_index); diff --git a/src/filehelper.c b/src/filehelper.c index 14cfb87..8bb6e1a 100644 --- a/src/filehelper.c +++ b/src/filehelper.c @@ -758,8 +758,6 @@ void init_settings_from_config(struct save_file_data *save_file_data) // Read and save the disable random setting from config.ini set_is_random_DVs_disabled(strcmp(read_key_from_config("DISABLE_RANDOM_IVS_ON_TRADE"), "false")); - // Read and save the item required evolutions setting from config.ini - set_is_item_required(strcmp(read_key_from_config("ITEM_REQUIRED_EVOLUTIONS"), "false")); // malloc'd from read_key_from_config free(config_save_path); diff --git a/src/pksavhelper.c b/src/pksavhelper.c index ef470d1..734681c 100644 --- a/src/pksavhelper.c +++ b/src/pksavhelper.c @@ -165,24 +165,12 @@ enum eligible_evolution_status check_trade_evolution_gen2(PokemonSave *pkmn_save { // Species index of pokemon being checked int species = pkmn_save->save.gen2_save.pokemon_storage.p_party->species[pkmn_party_index]; - // Item held index by pokemon being checked - int item = pkmn_save->save.gen2_save.pokemon_storage.p_party->party[pkmn_party_index].pc_data.held_item; - struct pkmn_evolution_pair_data evo_pair = pkmn_evolution_pairs_gen2[species]; + // If the pkmn species has an initialized evolution pair if (species == evo_pair.species_index) { - // Pokemon eligible for trade evolution but missing item - if (evo_pair.evolution_item != item && get_is_item_required()) - { - return E_EVO_STATUS_MISSING_ITEM; - } - - // Pokemon eligible for trade evolution - if (evo_pair.evolution_item == item || !get_is_item_required()) - { - return E_EVO_STATUS_ELIGIBLE; - } + return E_EVO_STATUS_ELIGIBLE; } return E_EVO_STATUS_NOT_ELIGIBLE; @@ -902,15 +890,3 @@ void set_is_random_DVs_disabled(bool is_disabled) { disable_random_DVs_on_trade = is_disabled; } - -// Settings getter disable item required for trade -bool get_is_item_required(void) -{ - return item_required_evolutions; -} - -// Settings setter disable item required for trade -void set_is_item_required(bool is_required) -{ - item_required_evolutions = is_required; -} diff --git a/src/screens/EvolveScreen.c b/src/screens/EvolveScreen.c index 751b2b4..723c7e7 100644 --- a/src/screens/EvolveScreen.c +++ b/src/screens/EvolveScreen.c @@ -77,9 +77,8 @@ void draw_evolve(PokemonSave *pkmn_save, char *save_path, struct trainer_info *t const int NONE = -1; static int selected_index = NONE; - static enum eligible_trade_status trade_eligible = E_EVO_STATUS_ELIGIBLE; + static enum eligible_evolution_status evolve_eligible = E_EVO_STATUS_ELIGIBLE; char pokemon_nickname[PKMN_NAME_TEXT_MAX + 1] = "\0"; - int eligible_pokemon_count = 0; const int TRAINER_NAME_X = 50; const int TRAINER_NAME_Y = 115; static bool is_trade_eligible = false; @@ -121,19 +120,15 @@ void draw_evolve(PokemonSave *pkmn_save, char *save_path, struct trainer_info *t { if (save_generation_type == SAVE_GENERATION_1) { - trade_eligible = check_trade_evolution_gen1(pkmn_save, i); - eligible_pokemon_count++; + evolve_eligible = check_trade_evolution_gen1(pkmn_save, i); pksav_gen1_import_text(pkmn_save->save.gen1_save.pokemon_storage.p_party->nicknames[i], pokemon_nickname, PKMN_NAME_TEXT_MAX); - draw_pkmn_button((Rectangle){TRAINER_NAME_X, TRAINER_NAME_Y + 75 + (i * 30), 200, 30}, i, pokemon_nickname, selected_index == i || trade_eligible == E_EVO_STATUS_NOT_ELIGIBLE); + draw_pkmn_button((Rectangle){TRAINER_NAME_X, TRAINER_NAME_Y + 75 + (i * 30), 200, 30}, i, pokemon_nickname, selected_index == i || evolve_eligible == E_EVO_STATUS_NOT_ELIGIBLE); } else if (save_generation_type == SAVE_GENERATION_2) { - trade_eligible = check_trade_evolution_gen2(pkmn_save, i); - eligible_pokemon_count++; + evolve_eligible = check_trade_evolution_gen2(pkmn_save, i); pksav_gen2_import_text(pkmn_save->save.gen2_save.pokemon_storage.p_party->nicknames[i], pokemon_nickname, PKMN_NAME_TEXT_MAX); - draw_pkmn_button((Rectangle){TRAINER_NAME_X, TRAINER_NAME_Y + 75 + (i * 30), MeasureText(pokemon_nickname, 20) + 10, 30}, i, pokemon_nickname, selected_index == i || trade_eligible == E_EVO_STATUS_NOT_ELIGIBLE); - if (trade_eligible == E_EVO_STATUS_MISSING_ITEM) - shadow_text("Missing required item!", 75 + MeasureText(pokemon_nickname, 20), TRAINER_NAME_Y + 75 + (i * 30), 20, RED); + draw_pkmn_button((Rectangle){TRAINER_NAME_X, TRAINER_NAME_Y + 75 + (i * 30), MeasureText(pokemon_nickname, 20) + 10, 30}, i, pokemon_nickname, selected_index == i || evolve_eligible == E_EVO_STATUS_NOT_ELIGIBLE); } // Selected pokemon button if (CheckCollisionPointRec(GetMousePosition(), (Rectangle){TRAINER_NAME_X, TRAINER_NAME_Y + 75 + (i * 30), 200, 30}) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) @@ -158,7 +153,6 @@ void draw_evolve(PokemonSave *pkmn_save, char *save_path, struct trainer_info *t const int x_offset = SCREEN_WIDTH - 400; int text_pos_x = container_rec.x + x_offset + 70; - int warn_text_pos_x = container_rec.x + x_offset + 30; int stat_text_pos_x = container_rec.x + x_offset + 150; int dv_text_pos_x = container_rec.x + x_offset + 210; @@ -287,6 +281,7 @@ void draw_evolve(PokemonSave *pkmn_save, char *save_path, struct trainer_info *t selected_index = NONE; is_trade_eligible = false; + show_evolve_toast = true; } else { @@ -313,6 +308,10 @@ void draw_evolve(PokemonSave *pkmn_save, char *save_path, struct trainer_info *t { show_saving_icon = draw_save_icon(SCREEN_WIDTH - 50, 10, show_saving_icon); } + if (show_evolve_toast) + { + show_evolve_toast = !draw_toast_message("Evolved Successfully!", TOAST_SHORT, TOAST_INFO); + } EndDrawing(); } diff --git a/src/screens/SettingsScreen.c b/src/screens/SettingsScreen.c index 4a8ec94..b4a8c1f 100644 --- a/src/screens/SettingsScreen.c +++ b/src/screens/SettingsScreen.c @@ -68,15 +68,6 @@ void draw_settings(struct save_file_data *save_file_data, GameScreen *current_sc Rectangle checkbox_rec_off = (Rectangle){checkbox_rec_on.x + checkbox_rec_on.width + 5, start_y - 25, 20, 20}; DrawRectangleLinesEx(checkbox_rec_off, 2, settings_text_color); DrawText("OFF", checkbox_rec_off.x + checkbox_rec_off.width + 5, checkbox_rec_off.y, 20, settings_text_color); - // Toggle for item override evolutions - DrawText("Item required for evolution", 50, start_y, 20, settings_text_color); - // Checkbox for item override evolutions - DrawText("ON", 385, start_y, 20, settings_text_color); - Rectangle checkbox_rec_on_item = (Rectangle){385 + MeasureText("ON", 20) + 5, start_y, 20, 20}; - DrawRectangleLinesEx(checkbox_rec_on_item, 2, settings_text_color); - Rectangle checkbox_rec_off_item = (Rectangle){checkbox_rec_on_item.x + checkbox_rec_on_item.width + 5, start_y, 20, 20}; - DrawRectangleLinesEx(checkbox_rec_off_item, 2, settings_text_color); - DrawText("OFF", checkbox_rec_off_item.x + checkbox_rec_off_item.width + 5, checkbox_rec_off_item.y, 20, settings_text_color); bool _is_rand_disabled = get_is_random_DVs_disabled(); if (_is_rand_disabled) @@ -92,19 +83,6 @@ void draw_settings(struct save_file_data *save_file_data, GameScreen *current_sc DrawText("DVs will not be retained (default)", checkbox_rec_off.x + checkbox_rec_off.width + 65, start_y - 25, 16, settings_text_color); } - bool _is_item_required = get_is_item_required(); - if (_is_item_required) - { - // Draw filled in square - DrawRectangle(checkbox_rec_on_item.x + 3, checkbox_rec_on_item.y + 3, checkbox_rec_on_item.width - 6, checkbox_rec_on_item.height - 6, settings_text_color); - DrawText("Items will be required (default)", checkbox_rec_off_item.x + checkbox_rec_off_item.width + 65, start_y, 16, settings_text_color); - } - else - { - // Draw filled in square - DrawRectangle(checkbox_rec_off_item.x + 3, checkbox_rec_off_item.y + 3, checkbox_rec_off_item.width - 6, checkbox_rec_off_item.height - 6, settings_text_color); - DrawText("Items will not be required", checkbox_rec_off_item.x + checkbox_rec_off_item.width + 65, start_y, 16, settings_text_color); - } if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { if (CheckCollisionPointRec(GetMousePosition(), checkbox_rec_on)) @@ -117,22 +95,12 @@ void draw_settings(struct save_file_data *save_file_data, GameScreen *current_sc set_is_random_DVs_disabled(false); write_key_to_config("DISABLE_RANDOM_IVS_ON_TRADE", "false"); } - else if (CheckCollisionPointRec(GetMousePosition(), checkbox_rec_on_item)) - { - set_is_item_required(true); - write_key_to_config("ITEM_REQUIRED_EVOLUTIONS", "true"); - } - else if (CheckCollisionPointRec(GetMousePosition(), checkbox_rec_off_item)) - { - set_is_item_required(false); - write_key_to_config("ITEM_REQUIRED_EVOLUTIONS", "false"); - } } Rectangle change_dir_rec = (Rectangle){50, start_y + 75, 200, 20}; DrawText("Change Save Directory", change_dir_rec.x, change_dir_rec.y, 20, selected_index == BUTTON_CHANGE_DIR ? settings_text_color_selected : settings_text_color); // Draw reset default config button const char *reset_config_text = "Reset to defaults"; - Rectangle reset_config_rec = (Rectangle){50, start_y + 25, MeasureText(reset_config_text, 20) + 10, 30}; + Rectangle reset_config_rec = (Rectangle){50, start_y, MeasureText(reset_config_text, 20) + 10, 30}; DrawText(reset_config_text, reset_config_rec.x, reset_config_rec.y, 20, selected_index == BUTTON_RESET ? settings_text_color_selected : settings_text_color); const Rectangle about_button_rec = (Rectangle){50, start_y + 100, MeasureText("About Pokerom Trader", 20) + 10, 30}; From 6caef8bf1e77dbf69513166d045d2ddb2d0fc015 Mon Sep 17 00:00:00 2001 From: Spencer Vaughn Date: Mon, 20 Nov 2023 20:50:03 -0600 Subject: [PATCH 2/2] removed references to evolution item settings --- src/filehelper.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/filehelper.c b/src/filehelper.c index 8bb6e1a..4f90710 100644 --- a/src/filehelper.c +++ b/src/filehelper.c @@ -141,7 +141,6 @@ void create_default_config(void) LPCSTR ini = config_path; WritePrivateProfileStringA("app", "SAVE_FILE_DIR", saves_dir, ini); WritePrivateProfileStringA("app", "DISABLE_RANDOM_IVS_ON_TRADE", "false", ini); - WritePrivateProfileStringA("app", "ITEM_REQUIRED_EVOLUTIONS", "true", ini); } struct config_data read_key_from_config(void) { @@ -164,13 +163,10 @@ struct config_data read_key_from_config(void) char disable_random_ivs_on_trade[MAX_FILE_PATH_CHAR]; GetPrivateProfileString("app", "DISABLE_RANDOM_IVS_ON_TRADE", 0, disable_random_ivs_on_trade, MAX_FILE_PATH_CHAR, ini); - char item_required_evolutions[MAX_FILE_PATH_CHAR]; - GetPrivateProfileString("app", "ITEM_REQUIRED_EVOLUTIONS", 0, item_required_evolutions, MAX_FILE_PATH_CHAR, ini); return (struct config_data){ .save_file_dir = save_file_str, .disable_random_ivs_on_trade = disable_random_ivs_on_trade, - .item_required_evolutions = item_required_evolutions, }; } void write_to_log(const char *msg, const uint8_t message_type) @@ -341,7 +337,6 @@ void init_settings_from_config(struct save_file_data *save_file_data) } set_is_random_DVs_disabled(strcmp(config_data.disable_random_ivs_on_trade, "false")); - set_is_item_required(strcmp(config_data.item_required_evolutions, "false")); free(save_file_dir); } @@ -535,8 +530,6 @@ void create_default_config(bool overwrite) fputs(default_key, fp); fputs("\n", fp); fputs("DISABLE_RANDOM_IVS_ON_TRADE=false", fp); - fputs("\n", fp); - fputs("ITEM_REQUIRED_EVOLUTIONS=true", fp); fclose(fp); }