Skip to content

Commit

Permalink
added save backups
Browse files Browse the repository at this point in the history
  • Loading branch information
savaughn committed Dec 1, 2023
1 parent 31fa341 commit c057231
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ PLATFORM ?= PLATFORM_DESKTOP

# Define project variables
PROJECT_NAME ?= pokeromtrader
PROJECT_VERSION := 0.10.1
PROJECT_VERSION := 1.0.0
# prerelease or release
PROJECT_VERSION_TYPE ?= release
PROJECT_VERSION_TYPE ?= prerelease
PROJECT_BUILD_PATH ?= .

RAYLIB_PATH ?= deps/raylib
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
## Overview

Pokerom Trader is an open-source project that simplifies the process of trading Pokémon between two save files using the [PKSav](https://github.com/savaughn/pksav) C library. This graphical user interface (GUI) provides an intuitive way for Pokémon enthusiasts to transfer Pokémon between different save files. This is not another save file editor. This replicates the in-game trading experience resulting in legal pokémon.
There is no backup system implemented yet. Make backup saves before using this on your own personal files.

### Features
- Trade - Allows a user to trade Pokémon between save files
- Evolve - A shortcut for evolving Pokémon that only evolve through trading
- This replicates a trade, the evolution, and a trade back to OT
- Save backup - Automatically backs up save files in the same directory before writing to them

### Settings

Expand Down
6 changes: 6 additions & 0 deletions src/screens/EvolveScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ void draw_evolve(PokemonSave *pkmn_save, char *save_path, struct trainer_info *t
case E_UI_EVOLVE:
if (CheckCollisionPointRec(GetMousePosition(), evolve_button_rec))
{
// Create backup save before evolving
char backup_path[1004] = "\0";
strcpy(backup_path, save_path);
strcat(backup_path, "_bak");
save_savefile_to_path(pkmn_save, backup_path);

// Evolve pokemon with the simulated new trainer
evolve_party_pokemon_at_index(pkmn_save, selected_index);
// Update stats
Expand Down
9 changes: 9 additions & 0 deletions src/screens/TradeScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ void draw_trade(PokemonSave *save_player1, PokemonSave *save_player2, char *play
reset_toast_message();
}

// create backup before trading
char backup_path[1004] = "\0";
strcpy(backup_path, player1_save_path);
strcat(backup_path, "_bak");
pksavhelper_error = save_savefile_to_path(save_player1, backup_path);
strcpy(backup_path, player2_save_path);
strcat(backup_path, "_bak");
pksavhelper_error = save_savefile_to_path(save_player2, backup_path);

if (*is_same_generation)
{
pksavhelper_error = swap_pkmn_at_index_between_saves(save_player1, save_player2, selected_index_trainer1, selected_index_trainer2);
Expand Down

0 comments on commit c057231

Please sign in to comment.