Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
storage.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 <pse-common/types.h>
20
24
25class SaveFile;
26
27class ItemStorageBox;
30class PlayerBasics;
31class PokemonBox;
32
33// 2 Sets of 6 Pokemon Boxes
36
48class SAVEFILE_AUTOPORT Storage : public QObject
49{
50 Q_OBJECT
51
52 Q_PROPERTY(ItemStorageBox* items MEMBER items NOTIFY itemsChanged)
53 Q_PROPERTY(int curBox MEMBER curBox NOTIFY curBoxChanged)
54 Q_PROPERTY(bool boxesFormatted MEMBER boxesFormatted NOTIFY boxesFormattedChanged)
55 Q_PROPERTY(int boxCount READ boxCount CONSTANT)
56
57public:
58 Storage(SaveFile* saveFile = nullptr);
59 virtual ~Storage();
60
61 void load(SaveFile* saveFile = nullptr);
62 void save(SaveFile* saveFile);
63
64 // Ignores the sets and returns the box with given box number
65 // Also allow swapping ignoring set boundraries (Appearing as one consecutive
66 // array of boxes)
67 int boxCount();
68 Q_INVOKABLE PokemonStorageBox* boxAt(int ind);
69
70 // Returns a box pointer that has free space
72
73 // Deposits a pokemon into a box
75
76signals:
81
82public slots:
83 void reset();
84 void randomize(PlayerBasics* basics);
85 void randomizePokemon(PlayerBasics* basics);
86 void randomizeItems();
87
88public:
89 ItemStorageBox* items = nullptr;
90 int curBox;
91 bool boxesFormatted = false;
92
93 // Because this is a C++ array, it can't be a Q_PROPERTY and since the array
94 // contents never change and have no properties of themselves there's no need
95 // for a signal either
97};
A container of Items – either the trainer's bag or a PC item box.
The trainer's headline values: name, ID, money, coins, badges, starter.
A single Pokemon record – the most property-rich object in the tree.
Definition pokemonbox.h:213
Holds contents of a single Pokemon storage box.
Holds contents of a single box set, basically a row or array of boxes each holding Pokemon.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46
int boxCount()
Total boxes across both sets (12).
Definition storage.cpp:50
Storage(SaveFile *saveFile=nullptr)
< The PC item box.
Definition storage.cpp:32
void pokemonChanged()
ItemStorageBox * items
Definition storage.h:89
int curBox
Definition storage.h:90
void randomizeItems()
Randomize just the PC items.
Definition storage.cpp:201
PokemonStorageSet * pokemon[maxPokemonStorageSets]
The two box sets (6 boxes each).
Definition storage.h:96
void reset()
Blank the whole PC.
Definition storage.cpp:174
void randomize(PlayerBasics *basics)
Randomize items and Pokemon.
Definition storage.cpp:188
void curBoxChanged()
PokemonStorageBox * freeSpace()
First box with room, or null if all full.
Definition storage.cpp:65
void save(SaveFile *saveFile)
Flatten the PC back to the save.
Definition storage.cpp:147
void load(SaveFile *saveFile=nullptr)
Expand the PC (items + both box sets) from the save.
Definition storage.cpp:93
void randomizePokemon(PlayerBasics *basics)
Randomize just the boxed Pokemon.
Definition storage.cpp:195
void boxesFormattedChanged()
PokemonStorageBox * boxAt(int ind)
Box ind in the flattened 0..11 space (GC-protected return).
Definition storage.cpp:55
bool boxesFormatted
Definition storage.h:91
protected::void itemsChanged()
bool depositPokemon(PokemonBox *pokemon)
Put pokemon in the first box with space.
Definition storage.cpp:82
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.
constexpr var8 maxPokemonBoxes
Total PC boxes (12).
Definition storage.h:35
constexpr var8 maxPokemonStorageSets
PC Pokemon-box banks (2 sets).
Definition storage.h:34