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

One inventory slot: an item index and an amount, with live pricing. More...

#include <item.h>

Inheritance diagram for Item:
Collaboration diagram for Item:

Public Member Functions

 Item (SaveFileIterator *it=nullptr)
 < Item index (into the items DB).
 Item (var8 ind, var8 amount)
 New Item from a given index and amount.
 Item (bool random)
 New Item either blank or random.
 Item (QString name, var8 amount)
 Given name and amount.
void makeConnect ()
 Wire up internal signal connections.
virtual ~Item ()
void save (SaveFileIterator *it)
 Given an iterator, saves 2 bytes: index and amount.
ItemDBEntrytoItem ()
 Resolve ind to its DB entry.
bool canSell ()
 Whether the item may be sold.
int buyPriceOneMoney ()
int buyPriceOneCoins ()
int sellPriceOneMoney ()
int sellPriceOneCoins ()
int buyPriceAllMoney ()
int buyPriceAllCoins ()
int sellPriceAllMoney ()
int sellPriceAllCoins ()
int getAmount ()
 Current amount (backs property READ).
void setAmount (int val)
 Set amount (backs property WRITE; clamped to the Gen 1 max).
protected::void indChanged ()
void amountChanged ()
void itemChanged ()
void load (int ind, int amount)
 Set from an index + amount.
void load (bool random)
 Set blank or random.
void load (QString name, int amount)
 Set from an item name + amount.
void reset ()
 Blank this slot.
void randomize ()
 Randomize this slot.

Public Attributes

int ind
 Item index (backs property).
int amount
 Item amount (max 99 in Gen 1; backs property).

Detailed Description

One inventory slot: an item index and an amount, with live pricing.

On disk an item is just two bytes (index + amount). On top of those, this object computes a set of QML pricing properties – buy/sell, single/all, money/coins – by resolving ind through the items DB. Lives inside an ItemStorageBox (bag or PC).

See also
ItemStorageBox (container), ItemDBEntry (item data / prices).

Definition at line 35 of file item.h.

Constructor & Destructor Documentation

◆ Item() [1/4]

Item::Item ( SaveFileIterator * it = nullptr)

< Item index (into the items DB).

Quantity (max 99 in Gen 1). < Is this item sellable? < Buy price (one) in money. Buy price (one) in coins. Sell price (one) in money. Sell price (one) in coins. < Buy price (whole stack) in money. Buy price (whole stack) in coins. Sell price (whole stack) in money. Sell price (whole stack) in coins. New Item from iterator or a blank item. If iterator provided it extracts 2 bytes for index and amount.

Definition at line 30 of file item.cpp.

References amount, SaveFileIterator::getByte(), ind, makeConnect(), and reset().

◆ Item() [2/4]

Item::Item ( var8 ind,
var8 amount )

New Item from a given index and amount.

Definition at line 42 of file item.cpp.

References amount, ind, load(), and makeConnect().

◆ Item() [3/4]

Item::Item ( bool random)

New Item either blank or random.

Definition at line 48 of file item.cpp.

References load(), and makeConnect().

◆ Item() [4/4]

Item::Item ( QString name,
var8 amount )

Given name and amount.

Definition at line 54 of file item.cpp.

References amount, load(), and makeConnect().

◆ ~Item()

Item::~Item ( )
virtual

Definition at line 66 of file item.cpp.

Member Function Documentation

◆ amountChanged()

void Item::amountChanged ( )

Referenced by makeConnect(), randomize(), and reset().

◆ buyPriceAllCoins()

int Item::buyPriceAllCoins ( )
See also
buyPriceAllCoins property.

Definition at line 159 of file item.cpp.

References amount, and buyPriceOneCoins().

◆ buyPriceAllMoney()

int Item::buyPriceAllMoney ( )
See also
buyPriceAllMoney property.

Definition at line 154 of file item.cpp.

References amount, and buyPriceOneMoney().

◆ buyPriceOneCoins()

int Item::buyPriceOneCoins ( )
See also
buyPriceOneCoins property.

Definition at line 124 of file item.cpp.

References toItem().

Referenced by buyPriceAllCoins().

◆ buyPriceOneMoney()

int Item::buyPriceOneMoney ( )
See also
buyPriceOneMoney property.

Definition at line 114 of file item.cpp.

References toItem().

Referenced by buyPriceAllMoney().

◆ canSell()

bool Item::canSell ( )

Whether the item may be sold.

Definition at line 104 of file item.cpp.

References toItem().

◆ getAmount()

int Item::getAmount ( )

Current amount (backs property READ).

Definition at line 174 of file item.cpp.

References amount.

◆ indChanged()

protected::void Item::indChanged ( )

Referenced by makeConnect(), randomize(), and reset().

◆ itemChanged()

void Item::itemChanged ( )

References amount, ind, load(), randomize(), and reset().

Referenced by ItemStorageBox::load(), and makeConnect().

◆ load() [1/3]

void Item::load ( bool random)

Set blank or random.

Definition at line 194 of file item.cpp.

References randomize(), and reset().

◆ load() [2/3]

void Item::load ( int ind,
int amount )

Set from an index + amount.

Definition at line 188 of file item.cpp.

References amount, and ind.

Referenced by Item(), Item(), Item(), and itemChanged().

◆ load() [3/3]

void Item::load ( QString name,
int amount )

Set from an item name + amount.

Definition at line 204 of file item.cpp.

References amount, ItemsDB::getIndAt(), ind, and ItemsDB::inst().

◆ makeConnect()

void Item::makeConnect ( )

Wire up internal signal connections.

Definition at line 60 of file item.cpp.

References amountChanged(), indChanged(), and itemChanged().

Referenced by Item(), Item(), Item(), and Item().

◆ randomize()

void Item::randomize ( )

Randomize this slot.

Definition at line 83 of file item.cpp.

References amount, amountChanged(), ItemsDB::getStore(), ind, indChanged(), ItemsDB::inst(), Random::inst(), and Random::rangeInclusive().

Referenced by itemChanged(), and load().

◆ reset()

void Item::reset ( )

Blank this slot.

Definition at line 74 of file item.cpp.

References amount, amountChanged(), ind, and indChanged().

Referenced by Item(), itemChanged(), and load().

◆ save()

void Item::save ( SaveFileIterator * it)

Given an iterator, saves 2 bytes: index and amount.

Definition at line 68 of file item.cpp.

References amount, ind, and SaveFileIterator::setByte().

◆ sellPriceAllCoins()

int Item::sellPriceAllCoins ( )
See also
sellPriceAllCoins property.

Definition at line 169 of file item.cpp.

References amount, and sellPriceOneCoins().

◆ sellPriceAllMoney()

int Item::sellPriceAllMoney ( )
See also
sellPriceAllMoney property.

Definition at line 164 of file item.cpp.

References amount, and sellPriceOneMoney().

◆ sellPriceOneCoins()

int Item::sellPriceOneCoins ( )
See also
sellPriceOneCoins property.

Definition at line 144 of file item.cpp.

References toItem().

Referenced by sellPriceAllCoins().

◆ sellPriceOneMoney()

int Item::sellPriceOneMoney ( )
See also
sellPriceOneMoney property.

Definition at line 134 of file item.cpp.

References toItem().

Referenced by sellPriceAllMoney().

◆ setAmount()

void Item::setAmount ( int val)

Set amount (backs property WRITE; clamped to the Gen 1 max).

Definition at line 179 of file item.cpp.

References amount.

Referenced by ItemStorageModel::dragTransfer().

◆ toItem()

ItemDBEntry * Item::toItem ( )

Resolve ind to its DB entry.

Definition at line 98 of file item.cpp.

References ItemsDB::getIndAt(), ind, and ItemsDB::inst().

Referenced by buyPriceOneCoins(), buyPriceOneMoney(), canSell(), sellPriceOneCoins(), and sellPriceOneMoney().

Member Data Documentation

◆ amount

◆ ind

int Item::ind

Item index (backs property).

Definition at line 106 of file item.h.

Referenced by Item(), Item(), itemChanged(), load(), load(), randomize(), reset(), save(), and toItem().


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