Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
mapsdb.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 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 <QVector>
19#include <QHash>
20#include "./db_autoport.h"
21
22class MapDBEntry;
23class QQmlEngine;
24class MapSearch;
25
26// With amazing help of Quicktype!!!
27// https://app.quicktype.io
28
40class DB_AUTOPORT MapsDB : public QObject
41{
42 Q_OBJECT
43 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
44 Q_PROPERTY(MapSearch* search READ searchRaw STORED false)
45
46public:
47 // Get Instance
48 static MapsDB* inst();
49
50 // Get Properties, includes QML array helpers
51 const QVector<MapDBEntry*> getStore() const;
52 const QHash<QString, MapDBEntry*> getInd() const;
53 int getStoreSize() const;
54
55 MapSearch* searchRaw() const;
56 QScopedPointer<MapSearch, QScopedPointerDeleteLater> search() const;
57
58 // QML Methods that can't be a property or slot because they take an argument
59 Q_INVOKABLE MapDBEntry* getStoreAt(const int ind) const;
60 Q_INVOKABLE MapDBEntry* getIndAt(const QString val) const;
61
62public slots:
63 void load();
64 void index();
65 void deepLink();
66 void qmlProtect(const QQmlEngine* const engine) const;
67
68private slots:
69 void qmlRegister() const;
70
71private:
72 MapsDB();
73
74 QVector<MapDBEntry*> store;
75 QHash<QString, MapDBEntry*> ind;
76};
A chainable filter ("finder") over the maps – the heart of map randomization.
Definition mapsearch.h:42
void deepLink()
Resolve every map's warps/sprites/connections/etc.
Definition mapsdb.cpp:98
static MapsDB * inst()
< Number of maps.
Definition mapsdb.cpp:35
QScopedPointer< MapSearch, QScopedPointerDeleteLater > search() const
C++-owned finder (smart pointer).
Definition mapsdb.cpp:141
MapDBEntry * getIndAt(const QString val) const
Map by name key (for QML).
Definition mapsdb.cpp:155
int getStoreSize() const
Map count.
Definition mapsdb.cpp:51
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition mapsdb.cpp:112
void index()
Build the name->map index.
Definition mapsdb.cpp:78
const QVector< MapDBEntry * > getStore() const
All maps.
Definition mapsdb.cpp:41
MapDBEntry * getStoreAt(const int ind) const
Map by store index (for QML).
Definition mapsdb.cpp:147
const QHash< QString, MapDBEntry * > getInd() const
Name->map index.
Definition mapsdb.cpp:46
MapSearch * searchRaw() const
Raw finder for QML (QML-managed ownership).
Definition mapsdb.cpp:136
void load()
Load maps from JSON.
Definition mapsdb.cpp:56
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 map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56