Skip to content

Commit

Permalink
Merge pull request #104 from savaughn/evolve-ux-update
Browse files Browse the repository at this point in the history
updated evolve ux
  • Loading branch information
savaughn authored Nov 21, 2023
2 parents f79bffd + a814ba1 commit 268810c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 81 deletions.
2 changes: 0 additions & 2 deletions include/pksavhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 0 additions & 9 deletions src/filehelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -758,8 +751,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);
Expand Down
28 changes: 2 additions & 26 deletions src/pksavhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
21 changes: 10 additions & 11 deletions src/screens/EvolveScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand All @@ -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;

Expand Down Expand Up @@ -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
{
Expand All @@ -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();
}
34 changes: 1 addition & 33 deletions src/screens/SettingsScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand All @@ -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};
Expand Down

0 comments on commit 268810c

Please sign in to comment.