Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
item.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17#include <QObject>
18#include <QString>
19#include <pse-common/types.h>
21
23class ItemDBEntry;
24
35class SAVEFILE_AUTOPORT Item : public QObject
36{
37 Q_OBJECT
38
39 Q_PROPERTY(int ind MEMBER ind NOTIFY indChanged)
40 Q_PROPERTY(int amount READ getAmount WRITE setAmount NOTIFY amountChanged)
41
42 Q_PROPERTY(bool canSell READ canSell NOTIFY itemChanged STORED false)
43
44 Q_PROPERTY(int buyPriceOneMoney READ buyPriceOneMoney NOTIFY itemChanged STORED false)
45 Q_PROPERTY(int buyPriceOneCoins READ buyPriceOneCoins NOTIFY itemChanged STORED false)
46 Q_PROPERTY(int sellPriceOneMoney READ sellPriceOneMoney NOTIFY itemChanged STORED false)
47 Q_PROPERTY(int sellPriceOneCoins READ sellPriceOneCoins NOTIFY itemChanged STORED false)
48
49 Q_PROPERTY(int buyPriceAllMoney READ buyPriceAllMoney NOTIFY itemChanged STORED false)
50 Q_PROPERTY(int buyPriceAllCoins READ buyPriceAllCoins NOTIFY itemChanged STORED false)
51 Q_PROPERTY(int sellPriceAllMoney READ sellPriceAllMoney NOTIFY itemChanged STORED false)
52 Q_PROPERTY(int sellPriceAllCoins READ sellPriceAllCoins NOTIFY itemChanged STORED false)
53
54public:
57 Item(SaveFileIterator* it = nullptr);
58
61
63 Item(bool random);
64
66 Item(QString name, var8 amount);
67
68 void makeConnect();
69
70 virtual ~Item();
71
73 void save(SaveFileIterator* it);
74
76
77 bool canSell();
78
79 int buyPriceOneMoney();
80 int buyPriceOneCoins();
81 int sellPriceOneMoney();
82 int sellPriceOneCoins();
83
84 int buyPriceAllMoney();
85 int buyPriceAllCoins();
86 int sellPriceAllMoney();
87 int sellPriceAllCoins();
88
89 int getAmount();
90 void setAmount(int val);
91
92signals:
93 void indChanged();
96
97public slots:
98 void load(int ind, int amount);
99 void load(bool random);
100 void load(QString name, int amount);
101 void reset();
102 void randomize();
103
104public:
105 // Item Index
106 int ind;
107
108 // Item Amount, max of 99 for gen 1 games
109 int amount;
110};
int ind
Item index (backs property).
Definition item.h:106
void makeConnect()
Wire up internal signal connections.
Definition item.cpp:60
int sellPriceOneMoney()
Definition item.cpp:134
void reset()
Blank this slot.
Definition item.cpp:74
int amount
Item amount (max 99 in Gen 1; backs property).
Definition item.h:109
void amountChanged()
int getAmount()
Current amount (backs property READ).
Definition item.cpp:174
int buyPriceOneCoins()
Definition item.cpp:124
int sellPriceAllMoney()
Definition item.cpp:164
void randomize()
Randomize this slot.
Definition item.cpp:83
void load(int ind, int amount)
Set from an index + amount.
Definition item.cpp:188
int sellPriceOneCoins()
Definition item.cpp:144
protected::void indChanged()
int buyPriceAllCoins()
Definition item.cpp:159
int sellPriceAllCoins()
Definition item.cpp:169
Item(SaveFileIterator *it=nullptr)
< Item index (into the items DB).
Definition item.cpp:30
void setAmount(int val)
Set amount (backs property WRITE; clamped to the Gen 1 max).
Definition item.cpp:179
bool canSell()
Whether the item may be sold.
Definition item.cpp:104
int buyPriceOneMoney()
Definition item.cpp:114
int buyPriceAllMoney()
Definition item.cpp:154
void itemChanged()
void save(SaveFileIterator *it)
Given an iterator, saves 2 bytes: index and amount.
Definition item.cpp:68
ItemDBEntry * toItem()
Resolve ind to its DB entry.
Definition item.cpp:98
A moving cursor over a SaveFile, layering auto-advancing reads/writes on top of SaveFileToolset.
Project-wide fixed-width integer aliases (var8, var16, ...).
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition types.h:124
Import/export macro for the savefile library, plus the central list of QObject types kept deliberatel...
#define SAVEFILE_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
One item's static data: name/flags, pricing, and where it's used.
Definition itemdbentry.h:46