Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
Storage Class Reference

The PC: the item storage box and all 12 Pokemon boxes. More...

#include <storage.h>

Inheritance diagram for Storage:
Collaboration diagram for Storage:

Public Member Functions

 Storage (SaveFile *saveFile=nullptr)
 < The PC item box.
virtual ~Storage ()
void load (SaveFile *saveFile=nullptr)
 Expand the PC (items + both box sets) from the save.
void save (SaveFile *saveFile)
 Flatten the PC back to the save.
int boxCount ()
 Total boxes across both sets (12).
PokemonStorageBoxboxAt (int ind)
 Box ind in the flattened 0..11 space (GC-protected return).
PokemonStorageBoxfreeSpace ()
 First box with room, or null if all full.
bool depositPokemon (PokemonBox *pokemon)
 Put pokemon in the first box with space.
protected::void itemsChanged ()
void curBoxChanged ()
void boxesFormattedChanged ()
void pokemonChanged ()
void reset ()
 Blank the whole PC.
void randomize (PlayerBasics *basics)
 Randomize items and Pokemon.
void randomizePokemon (PlayerBasics *basics)
 Randomize just the boxed Pokemon.
void randomizeItems ()
 Randomize just the PC items.

Public Attributes

ItemStorageBoxitems = nullptr
int curBox
bool boxesFormatted = false
PokemonStorageSetpokemon [maxPokemonStorageSets]
 The two box sets (6 boxes each).

Detailed Description

The PC: the item storage box and all 12 Pokemon boxes.

A top-level region of the save. Holds the PC items box and two PokemonStorageSets (pokemon, 6 boxes each = 12). It flattens the two sets into one consecutive 0..11 box space for QML (boxAt() ignores set boundaries), and offers deposit/free-space helpers. curBox is the active box index. Standard expanded-node convention (see SaveFileExpanded).

See also
SaveFileExpanded, PokemonStorageSet, PokemonStorageBox, ItemStorageBox.

Definition at line 48 of file storage.h.

Constructor & Destructor Documentation

◆ Storage()

Storage::Storage ( SaveFile * saveFile = nullptr)

< The PC item box.

Active PC box index (0..11). Whether the boxes are formatted. Total box count (12).

Definition at line 32 of file storage.cpp.

References items, load(), maxPokemonStorageSets, and pokemon.

◆ ~Storage()

Storage::~Storage ( )
virtual

Definition at line 42 of file storage.cpp.

References items, maxPokemonStorageSets, and pokemon.

Member Function Documentation

◆ boxAt()

PokemonStorageBox * Storage::boxAt ( int ind)

Box ind in the flattened 0..11 space (GC-protected return).

Definition at line 55 of file storage.cpp.

References pokemon, qmlCppOwned(), and setMaxBoxes.

Referenced by freeSpace().

◆ boxCount()

int Storage::boxCount ( )

Total boxes across both sets (12).

Definition at line 50 of file storage.cpp.

References maxPokemonBoxes.

Referenced by freeSpace().

◆ boxesFormattedChanged()

void Storage::boxesFormattedChanged ( )

◆ curBoxChanged()

void Storage::curBoxChanged ( )

◆ depositPokemon()

bool Storage::depositPokemon ( PokemonBox * pokemon)

Put pokemon in the first box with space.

Returns
success.

Definition at line 82 of file storage.cpp.

References freeSpace(), and pokemon.

◆ freeSpace()

PokemonStorageBox * Storage::freeSpace ( )

First box with room, or null if all full.

Definition at line 65 of file storage.cpp.

References boxAt(), boxCount(), boxesFormatted, and curBox.

Referenced by depositPokemon().

◆ itemsChanged()

protected::void Storage::itemsChanged ( )

◆ load()

void Storage::load ( SaveFile * saveFile = nullptr)

Expand the PC (items + both box sets) from the save.

Definition at line 93 of file storage.cpp.

References boxesFormatted, boxesFormattedChanged(), curBox, curBoxChanged(), items, pokemon, reset(), setMaxBoxes, and SaveFile::toolset.

Referenced by Storage().

◆ pokemonChanged()

void Storage::pokemonChanged ( )

◆ randomize()

void Storage::randomize ( PlayerBasics * basics)

Randomize items and Pokemon.

Definition at line 188 of file storage.cpp.

References randomizeItems(), randomizePokemon(), and reset().

Referenced by pokemonChanged(), and randomizePokemon().

◆ randomizeItems()

void Storage::randomizeItems ( )

Randomize just the PC items.

Definition at line 201 of file storage.cpp.

References items.

Referenced by pokemonChanged(), and randomize().

◆ randomizePokemon()

void Storage::randomizePokemon ( PlayerBasics * basics)

Randomize just the boxed Pokemon.

Definition at line 195 of file storage.cpp.

References maxPokemonStorageSets, pokemon, and randomize().

Referenced by pokemonChanged(), and randomize().

◆ reset()

void Storage::reset ( )

Blank the whole PC.

Definition at line 174 of file storage.cpp.

References boxesFormatted, boxesFormattedChanged(), curBox, curBoxChanged(), items, maxPokemonStorageSets, pokemon, and reset().

Referenced by load(), pokemonChanged(), randomize(), and reset().

◆ save()

void Storage::save ( SaveFile * saveFile)

Flatten the PC back to the save.

Definition at line 147 of file storage.cpp.

References boxesFormatted, curBox, items, pokemon, SaveFileToolset::setByte(), setMaxBoxes, and SaveFile::toolset.

Member Data Documentation

◆ boxesFormatted

bool Storage::boxesFormatted = false
See also
boxesFormatted property.

Definition at line 91 of file storage.h.

Referenced by freeSpace(), load(), reset(), and save().

◆ curBox

int Storage::curBox
See also
curBox property.

Definition at line 90 of file storage.h.

Referenced by freeSpace(), load(), reset(), and save().

◆ items

ItemStorageBox* Storage::items = nullptr
See also
items property.

Definition at line 89 of file storage.h.

Referenced by load(), randomizeItems(), reset(), save(), Storage(), and ~Storage().

◆ pokemon

The two box sets (6 boxes each).

Definition at line 96 of file storage.h.

Referenced by boxAt(), depositPokemon(), load(), randomizePokemon(), reset(), save(), Storage(), and ~Storage().


The documentation for this class was generated from the following files:
  • projects/savefile/src/pse-savefile/expanded/storage.h
  • projects/savefile/src/pse-savefile/expanded/storage.cpp