|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
A container of Items – either the trainer's bag or a PC item box. More...
#include <itemstoragebox.h>
Public Member Functions | |
| ItemStorageBox (bool isBag, int maxSize, SaveFile *saveFile=nullptr, int offset=0) | |
| How many items are there. | |
| virtual | ~ItemStorageBox () |
| void | load (SaveFile *saveFile=nullptr, int offset=0) |
| Expand the box from the save. | |
| void | save (SaveFile *saveFile, int offset) |
| Flatten the box to the save. | |
| int | itemsCount () |
| Distinct item count. | |
| int | itemsCountBulk () |
| Item count including stack amounts. | |
| int | itemsMax () |
| Capacity. | |
| bool | getIsBag () |
| Is this the bag? | |
| bool | relocateFull () |
| Is relocation blocked because the paired box is full? | |
| ItemStorageBox * | destBox () |
| The paired box for relocation. | |
| int | itemsAllBuyMoney () |
| int | itemsAllBuyCoins () |
| int | itemsAllSellMoney () |
| int | itemsAllSellCoins () |
| Item * | itemAt (int ind) |
Item slot ind (GC-protected return). | |
| void | randomizeStorage () |
| Randomizer path for a PC item box. | |
| void | randomizeBag () |
| Randomizer path for the bag. | |
| bool | hasItemInd (int ind) |
Does this box already contain an item with index ind? (Q_INVOKABLE: the SelectItem dropdown greys out already-present names.). | |
| int | amountOfInd (int ind) |
Total amount of item ind across all rows in this box (Q_INVOKABLE: the SelectItem dropdown shows the cross-pane owned total). | |
| int | randomUniqueInd () |
| A random non-glitch/non-once item index absent from this box, or -1 if none remain. | |
| void | reset () |
| Empty the box. | |
| void | randomize () |
| Randomize (dispatches to bag/storage path); sorts afterward. | |
| bool | itemMove (int from, int to) |
| Reorder an item. | |
| void | itemRemove (int ind) |
Remove item ind. | |
| void | itemNew () |
| Add a fresh random item (never a duplicate of one already here). | |
| bool | relocateAll () |
| Move every item to the paired box. | |
| bool | relocateOne (int ind) |
| Move one item to the paired box. | |
| void | sort () |
| Sort the box contents. | |
Public Attributes | |
| QVector< Item * > | items |
| The stored items. | |
| int | maxSize |
| Capacity (set at construction; treat as read-only). | |
| bool | isBag |
| Bag vs PC (set at construction; treat as read-only). | |
| SaveFile * | file |
| Owning save. | |
Protected Member Functions | |
| void | itemsChanged () |
| Box contents changed. | |
| void | itemMoveChange (int from, int to) |
| An item moved slot. | |
| void | itemRemoveChange (int ind) |
| An item was removed. | |
| void | itemInsertChange () |
| An item was inserted. | |
| void | itemsResetChange () |
| The box was reset. | |
Protected Attributes | |
| : void beforeItemRelocate(Item* item) | |
| Emitted before a relocate so models can clean up. | |
A container of Items – either the trainer's bag or a PC item box.
Holds a vector of items up to maxSize. The isBag flag chooses bag vs PC behaviour (and drives which randomizer runs). Exposes live counts and total worth to QML, supports add/remove/move/sort, and can relocate items to its paired box (bag <-> PC) via destBox.
Definition at line 35 of file itemstoragebox.h.
| ItemStorageBox::ItemStorageBox | ( | bool | isBag, |
| int | maxSize, | ||
| SaveFile * | saveFile = nullptr, | ||
| int | offset = 0 ) |
How many items are there.
How many items including item amounts are there. Maximum number of items. Is this the players bag or PC storage. Can we relocate? If the other box is full then we cannot. What's the worth of all the items? < Total buy value in money. Total buy value in coins. Total sell value in money. Total sell value in coins. Get destination box (the paired bag/PC box for relocation).
| isBag | bag vs PC; |
| maxSize | capacity; |
| offset | box location in the save. |
Definition at line 41 of file itemstoragebox.cpp.
References isBag, load(), and maxSize.
Referenced by destBox().
|
virtual |
Definition at line 48 of file itemstoragebox.cpp.
References items.
| int ItemStorageBox::amountOfInd | ( | int | ind | ) |
Total amount of item ind across all rows in this box (Q_INVOKABLE: the SelectItem dropdown shows the cross-pane owned total).
Definition at line 204 of file itemstoragebox.cpp.
References items.
| ItemStorageBox * ItemStorageBox::destBox | ( | ) |
The paired box for relocation.
Definition at line 360 of file itemstoragebox.cpp.
References file, isBag, and ItemStorageBox().
Referenced by relocateAll(), relocateFull(), and relocateOne().
| bool ItemStorageBox::getIsBag | ( | ) |
| bool ItemStorageBox::hasItemInd | ( | int | ind | ) |
Does this box already contain an item with index ind? (Q_INVOKABLE: the SelectItem dropdown greys out already-present names.).
Definition at line 194 of file itemstoragebox.cpp.
References items.
Referenced by randomUniqueInd().
| Item * ItemStorageBox::itemAt | ( | int | ind | ) |
Item slot ind (GC-protected return).
Definition at line 90 of file itemstoragebox.cpp.
References items, and qmlCppOwned().
|
protected |
An item was inserted.
Referenced by itemNew(), ItemStorageModel::ItemStorageModel(), load(), and randomizeBag().
| bool ItemStorageBox::itemMove | ( | int | from, |
| int | to ) |
Reorder an item.
Definition at line 158 of file itemstoragebox.cpp.
References itemMoveChange(), items, and itemsChanged().
Referenced by itemsResetChange().
|
protected |
An item moved slot.
Referenced by itemMove(), and ItemStorageModel::ItemStorageModel().
| void ItemStorageBox::itemNew | ( | ) |
Add a fresh random item (never a duplicate of one already here).
Definition at line 241 of file itemstoragebox.cpp.
References Random::inst(), itemInsertChange(), items, itemsChanged(), maxSize, and randomUniqueInd().
Referenced by itemsResetChange(), randomizeBag(), and randomizeStorage().
| void ItemStorageBox::itemRemove | ( | int | ind | ) |
Remove item ind.
Definition at line 181 of file itemstoragebox.cpp.
References itemRemoveChange(), items, and itemsChanged().
Referenced by itemsResetChange().
|
protected |
An item was removed.
Referenced by itemRemove(), ItemStorageModel::ItemStorageModel(), and relocateOne().
| int ItemStorageBox::itemsAllBuyCoins | ( | ) |
Definition at line 378 of file itemstoragebox.cpp.
References items.
| int ItemStorageBox::itemsAllBuyMoney | ( | ) |
Definition at line 367 of file itemstoragebox.cpp.
References items.
| int ItemStorageBox::itemsAllSellCoins | ( | ) |
Definition at line 400 of file itemstoragebox.cpp.
References items.
| int ItemStorageBox::itemsAllSellMoney | ( | ) |
Definition at line 389 of file itemstoragebox.cpp.
References items.
|
protected |
Box contents changed.
Referenced by itemMove(), itemNew(), ItemOverviewModel::ItemOverviewModel(), itemRemove(), load(), randomize(), relocateOne(), reset(), and sort().
| int ItemStorageBox::itemsCount | ( | ) |
| int ItemStorageBox::itemsCountBulk | ( | ) |
Item count including stack amounts.
Definition at line 59 of file itemstoragebox.cpp.
References items.
| int ItemStorageBox::itemsMax | ( | ) |
|
protected |
The box was reset.
References itemMove(), itemNew(), itemRemove(), randomize(), relocateAll(), relocateOne(), reset(), and sort().
Referenced by ItemStorageModel::ItemStorageModel(), reset(), and sort().
| void ItemStorageBox::load | ( | SaveFile * | saveFile = nullptr, |
| int | offset = 0 ) |
Expand the box from the save.
Definition at line 321 of file itemstoragebox.cpp.
References file, Item::itemChanged(), itemInsertChange(), items, itemsChanged(), SaveFile::iterator(), maxSize, SaveFileIterator::offsetTo(), reset(), and SaveFile::toolset.
Referenced by ItemStorageBox().
| void ItemStorageBox::randomize | ( | ) |
Randomize (dispatches to bag/storage path); sorts afterward.
Definition at line 422 of file itemstoragebox.cpp.
References isBag, itemsChanged(), randomizeBag(), randomizeStorage(), reset(), and sort().
Referenced by itemsResetChange().
| void ItemStorageBox::randomizeBag | ( | ) |
Randomizer path for the bag.
Definition at line 109 of file itemstoragebox.cpp.
References Random::chanceSuccess(), Random::inst(), itemInsertChange(), itemNew(), items, and Random::rangeInclusive().
Referenced by randomize().
| void ItemStorageBox::randomizeStorage | ( | ) |
Randomizer path for a PC item box.
Definition at line 98 of file itemstoragebox.cpp.
References Random::inst(), itemNew(), maxSize, and Random::rangeInclusive().
Referenced by randomize().
| int ItemStorageBox::randomUniqueInd | ( | ) |
A random non-glitch/non-once item index absent from this box, or -1 if none remain.
Definition at line 218 of file itemstoragebox.cpp.
References hasItemInd(), ItemsDB::inst(), and Random::inst().
Referenced by itemNew().
| bool ItemStorageBox::relocateAll | ( | ) |
Move every item to the paired box.
Definition at line 258 of file itemstoragebox.cpp.
References destBox(), items, and relocateOne().
Referenced by itemsResetChange().
| bool ItemStorageBox::relocateFull | ( | ) |
Is relocation blocked because the paired box is full?
Definition at line 80 of file itemstoragebox.cpp.
References destBox().
| bool ItemStorageBox::relocateOne | ( | int | ind | ) |
Move one item to the paired box.
Definition at line 272 of file itemstoragebox.cpp.
References destBox(), itemRemoveChange(), items, and itemsChanged().
Referenced by itemsResetChange(), and relocateAll().
| void ItemStorageBox::reset | ( | ) |
Empty the box.
Definition at line 411 of file itemstoragebox.cpp.
References items, itemsChanged(), and itemsResetChange().
Referenced by itemsResetChange(), load(), and randomize().
| void ItemStorageBox::save | ( | SaveFile * | saveFile, |
| int | offset ) |
Flatten the box to the save.
Definition at line 347 of file itemstoragebox.cpp.
References items, SaveFile::iterator(), maxSize, SaveFileIterator::offsetTo(), and SaveFileIterator::setByte().
| void ItemStorageBox::sort | ( | ) |
Sort the box contents.
Definition at line 296 of file itemstoragebox.cpp.
References items, itemsChanged(), and itemsResetChange().
Referenced by itemsResetChange(), and randomize().
|
protected |
Emitted before a relocate so models can clean up.
Definition at line 96 of file itemstoragebox.h.
| SaveFile* ItemStorageBox::file |
| bool ItemStorageBox::isBag |
Bag vs PC (set at construction; treat as read-only).
Definition at line 128 of file itemstoragebox.h.
Referenced by destBox(), getIsBag(), ItemStorageBox(), and randomize().
| QVector<Item*> ItemStorageBox::items |
The stored items.
Definition at line 123 of file itemstoragebox.h.
Referenced by amountOfInd(), hasItemInd(), itemAt(), itemMove(), itemNew(), itemRemove(), itemsAllBuyCoins(), itemsAllBuyMoney(), itemsAllSellCoins(), itemsAllSellMoney(), itemsCount(), itemsCountBulk(), load(), randomizeBag(), ItemOverviewModel::rebuild(), relocateAll(), relocateOne(), reset(), save(), sort(), and ~ItemStorageBox().
| int ItemStorageBox::maxSize |
Capacity (set at construction; treat as read-only).
Definition at line 127 of file itemstoragebox.h.
Referenced by itemNew(), itemsMax(), ItemStorageBox(), load(), randomizeStorage(), and save().