Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
db.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
18#include <QObject>
19#include <QQmlContext>
20#include "./db_autoport.h"
21
22// Qt 6 requires Q_PROPERTY pointer types to be fully defined (not just
23// forward-declared) so MOC can register them as metatypes. Include all
24// sub-database headers here rather than forward-declaring them.
25#include "./util/gamedata.h"
26#include "./creditsdb.h"
27#include "./eventpokemondb.h"
28#include "./eventsdb.h"
29#include "./examples.h"
30#include "./names.h"
31#include "./flydb.h"
32#include "./fontsdb.h"
33#include "./gamecornerdb.h"
34#include "./hiddencoinsdb.h"
35#include "./hiddenItemsdb.h"
36#include "./itemsdb.h"
37#include "./mapsdb.h"
38#include "./missablesdb.h"
39#include "./moves.h"
40#include "./music.h"
41#include "./pokemon.h"
42#include "./scripts.h"
43#include "./spriteSet.h"
44#include "./sprites.h"
45#include "./starterPokemon.h"
46#include "./tileset.h"
47#include "./tmHm.h"
48#include "./trades.h"
49#include "./trainers.h"
50#include "./types.h"
51
52class QQmlEngine;
53
74class DB_AUTOPORT DB : public QObject
75{
76 Q_OBJECT
77
78 Q_PROPERTY(GameData* json READ json CONSTANT)
79 Q_PROPERTY(CreditsDB* credits READ credits CONSTANT)
80 Q_PROPERTY(EventPokemonDB* eventPokemon READ eventPokemon CONSTANT)
81 Q_PROPERTY(EventsDB* events READ events CONSTANT)
82 Q_PROPERTY(Examples* examples READ examples CONSTANT)
83 Q_PROPERTY(Names* names READ names CONSTANT)
84 Q_PROPERTY(FlyDB* fly READ fly CONSTANT)
85 Q_PROPERTY(FontsDB* fonts READ fonts CONSTANT)
86 Q_PROPERTY(GameCornerDB* gameCorner READ gameCorner CONSTANT)
87 Q_PROPERTY(HiddenCoinsDB* hiddenCoins READ hiddenCoins CONSTANT)
88 Q_PROPERTY(HiddenItemsDB* hiddenItems READ hiddenItems CONSTANT)
89 Q_PROPERTY(ItemsDB* items READ items CONSTANT)
90 Q_PROPERTY(MapsDB* maps READ maps CONSTANT)
91 Q_PROPERTY(MissablesDB* missables READ missables CONSTANT)
92 Q_PROPERTY(MovesDB* moves READ moves CONSTANT)
93 Q_PROPERTY(MusicDB* music READ music CONSTANT)
94 Q_PROPERTY(PokemonDB* pokemon READ pokemon CONSTANT)
95 Q_PROPERTY(ScriptsDB* scripts READ scripts CONSTANT)
96 Q_PROPERTY(SpriteSetDB* spriteSets READ spriteSets CONSTANT)
97 Q_PROPERTY(SpritesDB* sprites READ sprites CONSTANT)
98 Q_PROPERTY(StarterPokemonDB* starters READ starters CONSTANT)
99 Q_PROPERTY(TilesetDB* tilesets READ tilesets CONSTANT)
100 Q_PROPERTY(TmHmsDB* tmHms READ tmHms CONSTANT)
101 Q_PROPERTY(TradesDB* trades READ trades CONSTANT)
102 Q_PROPERTY(TrainersDB* trainers READ trainers CONSTANT)
103 Q_PROPERTY(TypesDB* types READ types CONSTANT)
104
105public:
107 [[nodiscard]] static DB* inst();
108
109 [[nodiscard]] GameData* json() const;
110 [[nodiscard]] CreditsDB* credits() const;
111 [[nodiscard]] EventPokemonDB* eventPokemon() const;
112 [[nodiscard]] EventsDB* events() const;
113 [[nodiscard]] Examples* examples() const;
114 [[nodiscard]] Names* names() const;
115 [[nodiscard]] FlyDB* fly() const;
116 [[nodiscard]] FontsDB* fonts() const;
117 [[nodiscard]] GameCornerDB* gameCorner() const;
118 [[nodiscard]] HiddenCoinsDB* hiddenCoins() const;
119 [[nodiscard]] HiddenItemsDB* hiddenItems() const;
120 [[nodiscard]] ItemsDB* items() const;
121 [[nodiscard]] MapsDB* maps() const;
122 [[nodiscard]] MissablesDB* missables() const;
123 [[nodiscard]] MovesDB* moves() const;
124 [[nodiscard]] MusicDB* music() const;
125 [[nodiscard]] PokemonDB* pokemon() const;
126 [[nodiscard]] ScriptsDB* scripts() const;
127 [[nodiscard]] SpriteSetDB* spriteSets() const;
128 [[nodiscard]] SpritesDB* sprites() const;
129 [[nodiscard]] StarterPokemonDB* starters() const;
130 [[nodiscard]] TilesetDB* tilesets() const;
131 [[nodiscard]] TmHmsDB* tmHms() const;
132 [[nodiscard]] TradesDB* trades() const;
133 [[nodiscard]] TrainersDB* trainers() const;
134 [[nodiscard]] TypesDB* types() const;
135
136public slots:
138 void qmlProtect(const QQmlEngine* const engine) const;
140 void qmlHook(QQmlContext* const context) const;
141
142private slots:
143 void initRes() const;
144 void qmlRegister() const;
145 void loadAll() const;
146 void indexAll() const;
147 void deepLinkAll() const;
148
149private:
151 DB();
152};
The credits/attribution database – and the canonical example of the "DB singleton" pattern every data...
Definition creditsdb.h:49
StarterPokemonDB * starters() const
The starters database (backs starters).
Definition db.cpp:61
SpriteSetDB * spriteSets() const
The sprite-sets database (backs spriteSets).
Definition db.cpp:59
void qmlHook(QQmlContext *const context) const
Install this DB into a QML context (exposes the db root).
Definition db.cpp:224
HiddenCoinsDB * hiddenCoins() const
The hidden-coins database (backs hiddenCoins).
Definition db.cpp:50
HiddenItemsDB * hiddenItems() const
The hidden-items database (backs hiddenItems).
Definition db.cpp:51
MissablesDB * missables() const
The missables database (backs missables).
Definition db.cpp:54
CreditsDB * credits() const
The credits database (backs credits).
Definition db.cpp:42
Examples * examples() const
The examples database (backs examples).
Definition db.cpp:45
TrainersDB * trainers() const
The trainers database (backs trainers).
Definition db.cpp:65
SpritesDB * sprites() const
The sprites database (backs sprites).
Definition db.cpp:60
void qmlProtect(const QQmlEngine *const engine) const
Pin the DB aggregate (and every sub-DB) to C++ ownership so QML never GCs them.
Definition db.cpp:192
FontsDB * fonts() const
The fonts database (backs fonts).
Definition db.cpp:48
TmHmsDB * tmHms() const
The TM/HM database (backs tmHms).
Definition db.cpp:63
EventPokemonDB * eventPokemon() const
The event-Pokemon database (backs eventPokemon).
Definition db.cpp:43
TradesDB * trades() const
The trades database (backs trades).
Definition db.cpp:64
TilesetDB * tilesets() const
The tilesets database (backs tilesets).
Definition db.cpp:62
MovesDB * moves() const
The moves database (backs moves).
Definition db.cpp:55
MapsDB * maps() const
The maps database (backs maps).
Definition db.cpp:53
EventsDB * events() const
The events database (backs events).
Definition db.cpp:44
GameCornerDB * gameCorner() const
The Game Corner database (backs gameCorner).
Definition db.cpp:49
TypesDB * types() const
The types database (backs types).
Definition db.cpp:66
GameData * json() const
The GameData JSON source (backs json).
Definition db.cpp:41
PokemonDB * pokemon() const
The Pokemon database (backs pokemon).
Definition db.cpp:57
static DB * inst()
< Raw parsed JSON assets behind every DB.
Definition db.cpp:33
MusicDB * music() const
The music database (backs music).
Definition db.cpp:56
FlyDB * fly() const
The fly-destinations database (backs fly).
Definition db.cpp:47
ScriptsDB * scripts() const
The scripts database (backs scripts).
Definition db.cpp:58
ItemsDB * items() const
The items database (backs items).
Definition db.cpp:52
Names * names() const
The names database (backs names).
Definition db.cpp:46
Database of real-world event/distribution Pokemon presets.
The story-events database – metadata for the 508 event flags, keyed by name.
Definition eventsdb.h:41
Aggregate of the example/preset sources (player, rival, Pokemon).
Definition examples.h:36
The fly-destinations database – where Fly can take you, keyed by name.
Definition flydb.h:38
The font database – the in-game character set and the text codec.
Definition fontsdb.h:50
The Game Corner database – prize entries plus the coin exchange rate.
The JSON asset loader – the raw data source behind every database.
Definition gamedata.h:36
The hidden-coins database – AbstractHiddenItemDB loaded from the coins file.
The hidden-items database – AbstractHiddenItemDB loaded from the items file.
The items database – every item (with prices), keyed by name.
Definition itemsdb.h:36
The maps database – every map and its full layout, keyed by name.
Definition mapsdb.h:41
The missables database – metadata for the missable-sprite flags, keyed by name.
Definition missablesdb.h:36
The moves database – every move, keyed by name.
Definition moves.h:82
The music database – every track, keyed by name.
Definition music.h:57
Small aggregate of the two random-name sources (player and Pokemon).
Definition names.h:35
The Pokemon database – all 151 species, keyed by name.
Definition pokemon.h:147
The map-scripts database, keyed by name.
Definition scripts.h:63
The sprite-sets database, keyed by name.
Definition spriteSet.h:79
The sprites database, keyed by name.
Definition sprites.h:56
The curated list of "good starter" species, for the randomizer.
The tilesets database, keyed by name.
Definition tileset.h:75
The TM/HM database – the ordered list of TM/HM moves and their items.
Definition tmHm.h:41
The in-game trades database.
Definition trades.h:61
The trainers database – every trainer class, keyed by name.
Definition trainers.h:58
The types database – the type list, keyed by name.
Definition types.h:59
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