Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
mapdbentry.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 <QHash>
19#include <QVector>
20
21#include "../db_autoport.h"
22
23class QQmlEngine;
24class MapsDB;
27class MapDBEntrySign;
32class MusicDBEntry;
33class TilesetDBEntry;
34class EventDBEntry;
35class FlyDBEntry;
37class ScriptDBEntry;
38
56struct DB_AUTOPORT MapDBEntry : public QObject {
57 Q_OBJECT
58 Q_PROPERTY(QString bestName READ bestName CONSTANT)
59 Q_PROPERTY(int height2X2 READ height2X2 CONSTANT)
60 Q_PROPERTY(int width2X2 READ width2X2 CONSTANT)
61 Q_PROPERTY(QString getName READ getName CONSTANT)
62 Q_PROPERTY(int getInd READ getInd CONSTANT)
63 Q_PROPERTY(bool getGlitch READ getGlitch CONSTANT)
64 Q_PROPERTY(bool getSpecial READ getSpecial CONSTANT)
65 Q_PROPERTY(int getWarpOutSize READ getWarpOutSize CONSTANT)
66 Q_PROPERTY(int getWarpInSize READ getWarpInSize CONSTANT)
67 Q_PROPERTY(int getSignsSize READ getSignsSize CONSTANT)
68 Q_PROPERTY(int getSpritesSize READ getSpritesSize CONSTANT)
69 Q_PROPERTY(int getMonRate READ getMonRate CONSTANT)
70 Q_PROPERTY(int getMonRateWater READ getMonRateWater CONSTANT)
71 Q_PROPERTY(int getMonsRedSize READ getMonsRedSize CONSTANT)
72 Q_PROPERTY(int getMonsBlueSize READ getMonsBlueSize CONSTANT)
73 Q_PROPERTY(int getMonsWaterSize READ getMonsWaterSize CONSTANT)
74 Q_PROPERTY(int getSpriteSet READ getSpriteSet CONSTANT)
75 Q_PROPERTY(SpriteSetDBEntry* getToSpriteSet READ getToSpriteSet CONSTANT)
76 Q_PROPERTY(int getBorder READ getBorder CONSTANT)
77 Q_PROPERTY(int getBank READ getBank CONSTANT)
78 Q_PROPERTY(int getDataPtr READ getDataPtr CONSTANT)
79 Q_PROPERTY(int getScriptPtr READ getScriptPtr CONSTANT)
80 Q_PROPERTY(int getTextPtr READ getTextPtr CONSTANT)
81 Q_PROPERTY(int getWidth READ getWidth CONSTANT)
82 Q_PROPERTY(int getHeight READ getHeight CONSTANT)
83 Q_PROPERTY(QString getMusic READ getMusic CONSTANT)
84 Q_PROPERTY(QString getTileset READ getTileset CONSTANT)
85 Q_PROPERTY(QString getModernName READ getModernName CONSTANT)
86 Q_PROPERTY(QString getIncomplete READ getIncomplete CONSTANT)
87 Q_PROPERTY(MusicDBEntry* getToMusic READ getToMusic CONSTANT)
88 Q_PROPERTY(TilesetDBEntry* getToTileset READ getToTileset CONSTANT)
89 Q_PROPERTY(MapDBEntry* getToComplete READ getToComplete CONSTANT)
90 Q_PROPERTY(int getToEventsSize READ getToEventsSize CONSTANT)
91 Q_PROPERTY(FlyDBEntry* getToFlyDestination READ getToFlyDestination CONSTANT)
92 Q_PROPERTY(int getToHiddenItemsSize READ getToHiddenItemsSize CONSTANT)
93 Q_PROPERTY(ScriptDBEntry* getToScript READ getToScript CONSTANT)
94
95public:
96 // Provides the best display name
97 const QString bestName() const;
98
99 // These have been removed from the JSON data because they are simply
100 // dimensions times 2 and thus redundant and repetitive to inlclude in JSON
101 int height2X2() const;
102 int width2X2() const;
103
104 const QString getName() const;
105 int getInd() const;
106 bool getGlitch() const;
107 bool getSpecial() const;
108
109 const QVector<MapDBEntryWarpOut*> getWarpOut() const;
110 int getWarpOutSize() const;
111 Q_INVOKABLE const MapDBEntryWarpOut* getWarpOutAt(const int ind) const;
112
113 const QVector<MapDBEntryWarpIn*> getWarpIn() const;
114 int getWarpInSize() const;
115 Q_INVOKABLE const MapDBEntryWarpIn* getWarpInAt(const int ind) const;
116
117 const QVector<MapDBEntrySign*> getSigns() const;
118 int getSignsSize() const;
119 Q_INVOKABLE const MapDBEntrySign* getSignsAt(const int ind) const;
120
121 const QVector<MapDBEntrySprite*> getSprites() const;
122 int getSpritesSize() const;
123 Q_INVOKABLE const MapDBEntrySprite* getSpritesAt(const int ind) const;
124
125 const QHash<int, MapDBEntryConnect*> getConnect() const;
126 Q_INVOKABLE const MapDBEntryConnect* getConnectAt(const int val) const;
127
128 int getMonRate() const;
129 int getMonRateWater() const;
130
131 const QVector<MapDBEntryWildMon*> getMonsRed() const;
132 int getMonsRedSize() const;
133 Q_INVOKABLE const MapDBEntryWildMon* getMonsRedAt(const int ind) const;
134
135 const QVector<MapDBEntryWildMon*> getMonsBlue() const;
136 int getMonsBlueSize() const;
137 Q_INVOKABLE const MapDBEntryWildMon* getMonsBlueAt(const int ind) const;
138
139 const QVector<MapDBEntryWildMon*> getMonsWater() const;
140 int getMonsWaterSize() const;
141 Q_INVOKABLE const MapDBEntryWildMon* getMonsWaterAt(const int ind) const;
142
143 int getSpriteSet() const;
145 int getBorder() const;
146 int getBank() const;
147 int getDataPtr() const;
148 int getScriptPtr() const;
149 int getTextPtr() const;
150 int getWidth() const;
151 int getHeight() const;
152 const QString getMusic() const;
153 const QString getTileset() const;
154 const QString getModernName() const;
155 const QString getIncomplete() const;
156 MusicDBEntry* getToMusic() const;
158 MapDBEntry* getToComplete() const;
159
160 const QVector<EventDBEntry*> getToEvents() const;
161 int getToEventsSize() const;
162 Q_INVOKABLE const EventDBEntry* getToEventsAt(const int ind) const;
163
165
166 const QVector<HiddenItemDBEntry*> getToHiddenItems() const;
167 int getToHiddenItemsSize() const;
168 Q_INVOKABLE const HiddenItemDBEntry* getToHiddenItemsAt(const int ind) const;
169
170 ScriptDBEntry* getToScript() const;
171
172public slots:
173 void qmlProtect(const QQmlEngine* const engine) const;
174
175protected:
176 MapDBEntry();
177 MapDBEntry(const QJsonValue& data);
178 void deepLink();
179 void qmlRegister() const;
180
181 // Optional bool values are only present when true, so we simplify things
182 // and mark then false unless they're present skipping dealing with variant
183
184 QString name = "";
185 int ind = -1;
186
187 bool glitch = false;
188 bool special = false;
189
190 // Warps to other maps
191 QVector<MapDBEntryWarpOut*> warpOut;
192
193 // Warps In from other maps
194 QVector<MapDBEntryWarpIn*> warpIn;
195
196 // Signs on map
197 QVector<MapDBEntrySign*> signs;
198
199 // Sprites on map
200 QVector<MapDBEntrySprite*> sprites;
201
202 // Connecting Maps
203 QHash<int, MapDBEntryConnect*> connect;
204
205 // Wild Pokemon Encounter Rate
206 // Along with mons for Red & Blue & Water Mons
207 // Although there is strangely only 1 map in the game that carries both
208 // water and land Pokemon. More strangely there's only 1 set of water Pokemon
209 // that all maps share that have water
210 int monRate = -1;
211 int monRateWater = -1;
212 QVector<MapDBEntryWildMon*> monsRed;
213 QVector<MapDBEntryWildMon*> monsBlue;
214 QVector<MapDBEntryWildMon*> monsWater;
215
216 // Sprite Set
217 int spriteSet = -1;
219
220 // Border Block #
221 int border = -1;
222
223 int bank = -1;
224 int dataPtr = -1;
225 int scriptPtr = -1;
226 int textPtr = -1;
227 int width = -1;
228 int height = -1;
229
230 QString music = "";
231 QString tileset = "";
232 QString modernName = "";
233 QString incomplete = "";
234
235 // Deep Linking
236 MusicDBEntry* toMusic = nullptr; // To Map Music
237 TilesetDBEntry* toTileset = nullptr; // To Map Tileset
238 MapDBEntry* toComplete = nullptr; // To Complete Version of Map
239 QVector<EventDBEntry*> toEvents; // To Associated Events
240 FlyDBEntry* toFlyDestination = nullptr; // To Associated Fly Destination
241 QVector<HiddenItemDBEntry*> toHiddenItems; // To Associated Hidden Items
243
244 friend class MapsDB;
245 friend class MapSearch; // reads filter fields in filter methods
246 friend struct EventDBEntry; // writes toEvents in deepLink
247 friend struct FlyDBEntry; // writes toFlyDestination in deepLink
248 friend struct HiddenItemDBEntry; // writes toHiddenItems in deepLink
249 friend struct ScriptDBEntry; // writes toScript in deepLink
250};
class SAVEFILE_AUTOPORT MapDBEntry
Definition areageneral.h:52
The maps database – every map and its full layout, keyed by name.
Definition mapsdb.h:41
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition db_autoport.h:37
One story-event definition: its name and where its flag lives in the save.
One fly destination: its name/index and the map it flies to.
Definition flydbentry.h:37
One hidden pickup's location: its map and tile coordinates.
One edge connection of a map (the seam to a neighbouring map).
One sign defined on a map: its position and text id.
A map's sprite definition – base class for the four sprite kinds.
A warp-in point: a destination spot other maps' warp-outs land on.
A warp-out point: a tile that warps the player to another map.
One wild-encounter slot in a map's encounter table: species + level.
const QVector< EventDBEntry * > getToEvents() const
Events associated with this map.
const QVector< MapDBEntryWarpOut * > getWarpOut() const
Outgoing warps.
const QString getTileset() const
ScriptDBEntry * getToScript() const
const QString getIncomplete() const
void deepLink()
Resolve the full cross-reference web.
QString music
Music name.
Definition mapdbentry.h:230
QVector< HiddenItemDBEntry * > toHiddenItems
Definition mapdbentry.h:241
int textPtr
Map text pointer.
Definition mapdbentry.h:226
QVector< MapDBEntryWildMon * > monsBlue
Blue-version land encounters.
Definition mapdbentry.h:213
const MapDBEntryWildMon * getMonsRedAt(const int ind) const
Red wild ind (for QML).
int getMonRate() const
int border
Border block number.
Definition mapdbentry.h:221
SpriteSetDBEntry * toSpriteSet
Resolved sprite set (deepLink).
Definition mapdbentry.h:218
QVector< MapDBEntryWildMon * > monsWater
Water encounters (shared; see note).
Definition mapdbentry.h:214
bool getGlitch() const
int scriptPtr
Map script pointer.
Definition mapdbentry.h:225
FlyDBEntry * toFlyDestination
Definition mapdbentry.h:240
const QString getName() const
int getSpriteSet() const
TilesetDBEntry * getToTileset() const
int getWarpInSize() const
int getWarpOutSize() const
SpriteSetDBEntry * getToSpriteSet() const
QString tileset
Tileset name.
Definition mapdbentry.h:231
const MapDBEntryConnect * getConnectAt(const int val) const
Connection in direction val (for QML).
int bank
Map data bank.
Definition mapdbentry.h:223
int height
Height (blocks).
Definition mapdbentry.h:228
friend class MapSearch
Definition mapdbentry.h:245
friend struct ScriptDBEntry
Definition mapdbentry.h:249
int getDataPtr() const
MapDBEntry()
Empty entry (built by MapsDB).
QVector< MapDBEntryWarpOut * > warpOut
Outgoing warps.
Definition mapdbentry.h:191
int spriteSet
Sprite-set index.
Definition mapdbentry.h:217
bool glitch
Backing field (read via getGlitch()).
Definition mapdbentry.h:187
int getToEventsSize() const
friend struct FlyDBEntry
Definition mapdbentry.h:247
friend struct EventDBEntry
Definition mapdbentry.h:246
int dataPtr
Map data pointer.
Definition mapdbentry.h:224
int getToHiddenItemsSize() const
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
int getMonsWaterSize() const
bool special
Backing field (read via getSpecial()).
Definition mapdbentry.h:188
friend class MapsDB
Definition mapdbentry.h:244
int getWidth() const
QVector< MapDBEntryWildMon * > monsRed
Red-version land encounters.
Definition mapdbentry.h:212
const QVector< MapDBEntrySprite * > getSprites() const
Sprites on the map.
int getMonsBlueSize() const
const QVector< MapDBEntryWildMon * > getMonsBlue() const
Blue-version wild encounters.
friend struct HiddenItemDBEntry
Definition mapdbentry.h:248
void qmlRegister() const
Register with QML.
TilesetDBEntry * toTileset
Definition mapdbentry.h:237
const QVector< MapDBEntryWarpIn * > getWarpIn() const
Incoming warps.
const QVector< MapDBEntryWildMon * > getMonsWater() const
Water wild encounters.
QVector< MapDBEntryWarpIn * > warpIn
Incoming warps.
Definition mapdbentry.h:194
QVector< MapDBEntrySprite * > sprites
Sprites.
Definition mapdbentry.h:200
int getScriptPtr() const
MusicDBEntry * toMusic
Definition mapdbentry.h:236
const QVector< MapDBEntrySign * > getSigns() const
Signs on the map.
int getMonRateWater() const
const QVector< MapDBEntryWildMon * > getMonsRed() const
Red-version wild encounters.
const MapDBEntrySprite * getSpritesAt(const int ind) const
Sprite ind (for QML).
const MapDBEntryWarpIn * getWarpInAt(const int ind) const
Incoming warp ind (for QML).
int getBorder() const
FlyDBEntry * getToFlyDestination() const
int getTextPtr() const
const MapDBEntryWildMon * getMonsWaterAt(const int ind) const
Water wild ind (for QML).
int getSpritesSize() const
QVector< MapDBEntrySign * > signs
Signs.
Definition mapdbentry.h:197
int getMonsRedSize() const
const QString getModernName() const
const QString getMusic() const
const MapDBEntryWarpOut * getWarpOutAt(const int ind) const
Outgoing warp ind (for QML).
const MapDBEntrySign * getSignsAt(const int ind) const
Sign ind (for QML).
const QString bestName() const
< Best display name (modern/internal).
ScriptDBEntry * toScript
Resolved script (deepLink).
Definition mapdbentry.h:242
int monRate
Land encounter rate.
Definition mapdbentry.h:210
QVector< EventDBEntry * > toEvents
Definition mapdbentry.h:239
QHash< int, MapDBEntryConnect * > connect
Edge connections by direction.
Definition mapdbentry.h:203
bool getSpecial() const
QString modernName
Modern display name.
Definition mapdbentry.h:232
int getBank() const
int width
Width (blocks).
Definition mapdbentry.h:227
MusicDBEntry * getToMusic() const
const EventDBEntry * getToEventsAt(const int ind) const
Associated event ind (for QML).
const HiddenItemDBEntry * getToHiddenItemsAt(const int ind) const
Hidden item ind (for QML).
int monRateWater
Water encounter rate.
Definition mapdbentry.h:211
int height2X2() const
Height x2 (derived; see note).
QString name
Backing field (read via getName()).
Definition mapdbentry.h:184
MapDBEntry * toComplete
Definition mapdbentry.h:238
int width2X2() const
Width x2 (derived; see note).
MapDBEntry * getToComplete() const
const MapDBEntryWildMon * getMonsBlueAt(const int ind) const
Blue wild ind (for QML).
int getHeight() const
const QVector< HiddenItemDBEntry * > getToHiddenItems() const
Hidden items on this map.
int getInd() const
const QHash< int, MapDBEntryConnect * > getConnect() const
Edge connections by direction.
int getSignsSize() const
QString incomplete
Incomplete-map marker.
Definition mapdbentry.h:233
int ind
Backing field (read via getInd()).
Definition mapdbentry.h:185
One music track: its name and bank/id, plus the maps that use it.
Definition music.h:38
One map-script definition: its id/size and which maps use it.
Definition scripts.h:40
One sprite-set: the pre-loaded sprite group for an outdoor area.
Definition spriteSet.h:47
One tileset definition: its type, graphics/block/collision pointers, etc.
Definition tileset.h:45