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

Holds contents of a single Pokemon storage box. More...

#include <pokemonstoragebox.h>

Inheritance diagram for PokemonStorageBox:
Collaboration diagram for PokemonStorageBox:

Public Member Functions

 PokemonStorageBox (int maxSize=boxMaxPokemon, SaveFile *saveFile=nullptr, var16 boxOffset=0)
 < How many mons are in the box.
virtual ~PokemonStorageBox ()
virtual void load (SaveFile *saveFile=nullptr, var16 boxOffset=0)
 Expand the box from the save.
virtual void save (SaveFile *saveFile, var16 boxOffset=0)
 Flatten the box to the save.
int pokemonCount ()
 Number of mons present.
int pokemonMax ()
 Capacity (maxSize).
bool isFull ()
 At capacity.
PokemonBoxpokemonAt (int ind)
 Mon at ind (GC-protected return).
void reset ()
 Empty the box.
virtual void randomize (PlayerBasics *basics)
 Fill with constrained random mons.
bool pokemonMove (int from, int to)
 Reorder a mon within the box.
void pokemonRemove (int ind)
 Remove the mon at ind.
virtual void pokemonNew ()
 Add a fresh mon.
bool relocateAll (PokemonStorageBox *dst)
 Move every mon into dst.
virtual bool relocateOne (PokemonStorageBox *dst, int ind)
 Move one mon into dst.

Public Attributes

bool isParty = false
 True if this box is actually the party (affects record format).
QVector< PokemonBox * > pokemon
 The stored mons.
int maxSize = 0
 Capacity.
SaveFilefile
 Owning save.

Protected Member Functions

void pokemonChanged ()
 Box contents changed.
void pokemonMoveChange (int from, int to)
 A mon moved slot.
void pokemonRemoveChange (int ind)
 A mon was removed.
void pokemonInsertChange ()
 A mon was inserted.
void pokemonResetChange ()
 The box was reset.

Protected Attributes

 : void beforePokemonRelocate(PokemonBox* item)
 Emitted before a relocate so models can clean up.

Detailed Description

Holds contents of a single Pokemon storage box.

A container of PokemonBox records – one PC box (or, when subclassed by PlayerPokemon, the party).

Owns a vector of pokemon up to maxSize and provides QML-facing count/full state plus slot access, reordering, removal, insertion, and box-to-box relocation. The isParty flag distinguishes a party from a box, which matters because party and box records are NOT interchangeable on disk (PokemonBox::isBoxMon()).

See also
PokemonBox (the slot type), PlayerPokemon (the party subclass), PokemonStorageSet (the collection of all boxes).

Definition at line 48 of file pokemonstoragebox.h.

Constructor & Destructor Documentation

◆ PokemonStorageBox()

PokemonStorageBox::PokemonStorageBox ( int maxSize = boxMaxPokemon,
SaveFile * saveFile = nullptr,
var16 boxOffset = 0 )

< How many mons are in the box.

Is the box at capacity? Box capacity.

Parameters
maxSizeCapacity.
saveFileSource save.
boxOffsetBox location in the save.

Definition at line 34 of file pokemonstoragebox.cpp.

References load(), and maxSize.

Referenced by PlayerPokemon::PlayerPokemon(), pokemonResetChange(), relocateAll(), and relocateOne().

◆ ~PokemonStorageBox()

PokemonStorageBox::~PokemonStorageBox ( )
virtual

Definition at line 53 of file pokemonstoragebox.cpp.

References pokemon.

Member Function Documentation

◆ isFull()

bool PokemonStorageBox::isFull ( )

At capacity.

Definition at line 69 of file pokemonstoragebox.cpp.

References maxSize, and pokemon.

◆ load()

void PokemonStorageBox::load ( SaveFile * saveFile = nullptr,
var16 boxOffset = 0 )
virtual

Expand the box from the save.

Reimplemented in PlayerPokemon.

Definition at line 160 of file pokemonstoragebox.cpp.

References file, maxSize, pokemon, pokemonChanged(), pokemonInsertChange(), reset(), and SaveFile::toolset.

Referenced by PokemonStorageBox().

◆ pokemonAt()

PokemonBox * PokemonStorageBox::pokemonAt ( int ind)

Mon at ind (GC-protected return).

Definition at line 74 of file pokemonstoragebox.cpp.

References pokemon, and qmlCppOwned().

◆ pokemonChanged()

◆ pokemonCount()

int PokemonStorageBox::pokemonCount ( )

Number of mons present.

Definition at line 59 of file pokemonstoragebox.cpp.

References pokemon.

Referenced by PokemonStorageModel::checkedDelete(), PokemonBoxSelectModel::getDecoratedName(), and PokemonOverviewModel::rebuild().

◆ pokemonInsertChange()

void PokemonStorageBox::pokemonInsertChange ( )
protected

◆ pokemonMax()

int PokemonStorageBox::pokemonMax ( )

Capacity (maxSize).

Definition at line 64 of file pokemonstoragebox.cpp.

References maxSize.

Referenced by PokemonStorageModel::checkedDelete(), PokemonBoxSelectModel::getDecoratedName(), relocateAll(), and relocateOne().

◆ pokemonMove()

bool PokemonStorageBox::pokemonMove ( int from,
int to )

◆ pokemonMoveChange()

void PokemonStorageBox::pokemonMoveChange ( int from,
int to )
protected

A mon moved slot.

Referenced by pokemonMove(), and PokemonStorageModel::switchBox().

◆ pokemonNew()

void PokemonStorageBox::pokemonNew ( )
virtual

Add a fresh mon.

Reimplemented in PlayerPokemon.

Definition at line 115 of file pokemonstoragebox.cpp.

References file, maxSize, PokemonBox::newPokemon(), pokemon, pokemonChanged(), pokemonInsertChange(), and PokemonRandom::Random_Starters.

Referenced by pokemonResetChange().

◆ pokemonRemove()

void PokemonStorageBox::pokemonRemove ( int ind)

Remove the mon at ind.

Definition at line 102 of file pokemonstoragebox.cpp.

References pokemon, pokemonChanged(), and pokemonRemoveChange().

Referenced by PokemonStorageModel::checkedDelete(), and pokemonResetChange().

◆ pokemonRemoveChange()

void PokemonStorageBox::pokemonRemoveChange ( int ind)
protected

A mon was removed.

Referenced by pokemonRemove(), relocateOne(), and PokemonStorageModel::switchBox().

◆ pokemonResetChange()

void PokemonStorageBox::pokemonResetChange ( )
protected

◆ randomize()

void PokemonStorageBox::randomize ( PlayerBasics * basics)
virtual

Fill with constrained random mons.

Reimplemented in PlayerPokemon.

Definition at line 224 of file pokemonstoragebox.cpp.

References Random::inst(), maxSize, pokemon, pokemonChanged(), pokemonInsertChange(), PokemonBox::randomize(), Random::rangeInclusive(), and reset().

Referenced by pokemonResetChange().

◆ relocateAll()

bool PokemonStorageBox::relocateAll ( PokemonStorageBox * dst)

Move every mon into dst.

Definition at line 126 of file pokemonstoragebox.cpp.

References pokemon, pokemonMax(), PokemonStorageBox(), and relocateOne().

Referenced by pokemonResetChange().

◆ relocateOne()

bool PokemonStorageBox::relocateOne ( PokemonStorageBox * dst,
int ind )
virtual

◆ reset()

void PokemonStorageBox::reset ( )

◆ save()

void PokemonStorageBox::save ( SaveFile * saveFile,
var16 boxOffset = 0 )
virtual

Flatten the box to the save.

Reimplemented in PlayerPokemon.

Definition at line 186 of file pokemonstoragebox.cpp.

References maxSize, pokemon, SaveFileToolset::setByte(), and SaveFile::toolset.

Member Data Documentation

◆ __pad0__

PokemonStorageBox::__pad0__
protected

Emitted before a relocate so models can clean up.

Definition at line 68 of file pokemonstoragebox.h.

◆ file

SaveFile* PokemonStorageBox::file

Owning save.

Definition at line 96 of file pokemonstoragebox.h.

Referenced by PlayerPokemon::load(), load(), PlayerPokemon::pokemonNew(), and pokemonNew().

◆ isParty

bool PokemonStorageBox::isParty = false

True if this box is actually the party (affects record format).

Definition at line 93 of file pokemonstoragebox.h.

Referenced by PlayerPokemon::PlayerPokemon().

◆ maxSize

int PokemonStorageBox::maxSize = 0

◆ pokemon


The documentation for this class was generated from the following files: