24#include <QElapsedTimer>
35 static DB* _inst =
new DB;
79void DB::initRes()
const
84void DB::qmlRegister()
const
86 static bool registered =
false;
87 if (registered)
return;
88 qmlRegisterUncreatableType<DB>(
"PSE.DB", 1, 0,
"DB",
"Can't instantiate in QML");
92void DB::loadAll()
const
94 static bool once =
false;
99 auto lap = [&](
const char* name) {
100 qDebug() <<
"[DB::loadAll]" << name <<
"—" << t.elapsed() <<
"ms";
133void DB::indexAll()
const
135 static bool once =
false;
140 auto lap = [&](
const char* name) {
141 qDebug() <<
"[DB::indexAll]" << name <<
"—" << t.elapsed() <<
"ms";
164void DB::deepLinkAll()
const
166 static bool once =
false;
171 auto lap = [&](
const char* name) {
172 qDebug() <<
"[DB::deepLinkAll]" << name <<
"—" << t.elapsed() <<
"ms";
227 context->setContextProperty(
"pseDB",
const_cast<DB*
>(
this));
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void load()
Load entries from loadFile.
void deepLink()
Resolve each entry's cross-DB links.
The credits/attribution database – and the canonical example of the "DB singleton" pattern every data...
void load()
Load entries from the JSON assets.
static CreditsDB * inst()
< Number of credit entries.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership (anti-GC).
StarterPokemonDB * starters() const
The starters database (backs starters).
SpriteSetDB * spriteSets() const
The sprite-sets database (backs spriteSets).
void qmlHook(QQmlContext *const context) const
Install this DB into a QML context (exposes the db root).
HiddenCoinsDB * hiddenCoins() const
The hidden-coins database (backs hiddenCoins).
HiddenItemsDB * hiddenItems() const
The hidden-items database (backs hiddenItems).
MissablesDB * missables() const
The missables database (backs missables).
CreditsDB * credits() const
The credits database (backs credits).
Examples * examples() const
The examples database (backs examples).
TrainersDB * trainers() const
The trainers database (backs trainers).
SpritesDB * sprites() const
The sprites database (backs sprites).
void qmlProtect(const QQmlEngine *const engine) const
Pin the DB aggregate (and every sub-DB) to C++ ownership so QML never GCs them.
FontsDB * fonts() const
The fonts database (backs fonts).
TmHmsDB * tmHms() const
The TM/HM database (backs tmHms).
EventPokemonDB * eventPokemon() const
The event-Pokemon database (backs eventPokemon).
TradesDB * trades() const
The trades database (backs trades).
TilesetDB * tilesets() const
The tilesets database (backs tilesets).
MovesDB * moves() const
The moves database (backs moves).
MapsDB * maps() const
The maps database (backs maps).
EventsDB * events() const
The events database (backs events).
GameCornerDB * gameCorner() const
The Game Corner database (backs gameCorner).
TypesDB * types() const
The types database (backs types).
GameData * json() const
The GameData JSON source (backs json).
PokemonDB * pokemon() const
The Pokemon database (backs pokemon).
static DB * inst()
< Raw parsed JSON assets behind every DB.
MusicDB * music() const
The music database (backs music).
FlyDB * fly() const
The fly-destinations database (backs fly).
ScriptsDB * scripts() const
The scripts database (backs scripts).
ItemsDB * items() const
The items database (backs items).
Names * names() const
The names database (backs names).
Database of real-world event/distribution Pokemon presets.
void load()
Load event Pokemon from JSON.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
static EventPokemonDB * inst()
< Number of event Pokemon.
The story-events database – metadata for the 508 event flags, keyed by name.
void deepLink()
Resolve each event's cross-DB links.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void load()
Load events from JSON.
void index()
Build the name->entry index.
static EventsDB * inst()
< Number of event definitions.
Aggregate of the example/preset sources (player, rival, Pokemon).
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
static Examples * inst()
< Example player source.
The fly-destinations database – where Fly can take you, keyed by name.
void deepLink()
Resolve each destination's map link.
void index()
Build the name->entry index.
static FlyDB * inst()
< Number of fly destinations.
void load()
Load destinations from JSON.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
The font database – the in-game character set and the text codec.
static FontsDB * inst()
< Number of font glyphs.
void load()
Load glyphs from JSON.
void index()
Build the name->glyph index.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
The Game Corner database – prize entries plus the coin exchange rate.
void deepLink()
Resolve each prize's item/Pokemon links.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void load()
Load prizes from JSON.
static GameCornerDB * inst()
< Number of prize entries.
The JSON asset loader – the raw data source behind every database.
static GameData * inst()
The process-wide GameData singleton.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
The hidden-coins database – AbstractHiddenItemDB loaded from the coins file.
static HiddenCoinsDB * inst()
The process-wide HiddenCoinsDB singleton.
The hidden-items database – AbstractHiddenItemDB loaded from the items file.
static HiddenItemsDB * inst()
The process-wide HiddenItemsDB singleton.
The items database – every item (with prices), keyed by name.
void load()
Load items from JSON.
static ItemsDB * inst()
< Number of items.
void index()
Build the name->entry index.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
The maps database – every map and its full layout, keyed by name.
static MapsDB * inst()
< Number of maps.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void index()
Build the name->map index.
void load()
Load maps from JSON.
The missables database – metadata for the missable-sprite flags, keyed by name.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void index()
Build the name->entry index.
static MissablesDB * inst()
< Number of missable definitions.
void load()
Load missables from JSON.
The moves database – every move, keyed by name.
void load()
Load moves from JSON.
void deepLink()
Resolve every move's cross-DB links.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void index()
Build the name->entry index.
static MovesDB * inst()
< Number of moves.
The music database – every track, keyed by name.
void load()
Load tracks from JSON.
void index()
Build the name->entry index.
static MusicDB * inst()
< Number of tracks.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Small aggregate of the two random-name sources (player and Pokemon).
static Names * inst()
< Random player-name source.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
The Pokemon database – all 151 species, keyed by name.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
static PokemonDB * inst()
< Number of species.
void deepLink()
Resolve every species' cross-reference web.
void index()
Build the name->species index.
void load()
Load species from JSON.
The map-scripts database, keyed by name.
void deepLink()
Resolve each script's map links.
void load()
Load scripts from JSON.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
static ScriptsDB * inst()
< Number of scripts.
void index()
Build the name->entry index.
The sprite-sets database, keyed by name.
void deepLink()
Resolve sprites, split neighbours, and maps.
void load()
Load sprite-sets from JSON.
static SpriteSetDB * inst()
< Number of sprite-sets.
void index()
Build the name->entry index.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
The sprites database, keyed by name.
static SpritesDB * inst()
< Number of sprites.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void load()
Load sprites from JSON.
void index()
Build the name->entry index.
The curated list of "good starter" species, for the randomizer.
static StarterPokemonDB * inst()
< Number of starter choices.
void load()
Load the starter list from JSON.
void deepLink()
Resolve the names to species entries.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
The tilesets database, keyed by name.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void load()
Load tilesets from JSON.
static TilesetDB * inst()
< Number of tilesets.
void index()
Build the name->entry index.
The TM/HM database – the ordered list of TM/HM moves and their items.
void load()
Load the TM/HM list from JSON.
static TmHmsDB * inst()
< Number of TMs+HMs.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void deepLink()
Resolve the parallel item/move vectors.
The in-game trades database.
void deepLink()
Resolve each trade's species links.
static TradesDB * inst()
< Number of trades.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void load()
Load trades from JSON.
The trainers database – every trainer class, keyed by name.
void index()
Build the name->entry index.
static TrainersDB * inst()
< Number of trainer classes.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void load()
Load trainers from JSON.
The types database – the type list, keyed by name.
void load()
Load types from JSON.
static TypesDB * inst()
< Number of types.
void index()
Build the name->entry index.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
static void qmlProtectUtil(const QObject *const obj, const QQmlEngine *const engine)
Pin obj to C++ ownership so the QML engine never garbage-collects it.