Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
types.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
18#include <QObject>
19#include <QJsonValue>
20#include <QString>
21#include <QHash>
22#include <QVector>
23
24#include <pse-common/types.h>
25#include "./db_autoport.h"
26
27struct MoveDBEntry;
28struct PokemonDBEntry;
29class QQmlEngine;
30
40 TypeDBEntry();
41 TypeDBEntry(QJsonValue& data);
42
43 QString name;
44 var8 ind = 0;
45 QString readable;
46
47 QVector<MoveDBEntry*> toMoves;
48 QVector<PokemonDBEntry*> toPokemon;
49};
50
58class DB_AUTOPORT TypesDB : public QObject
59{
60 Q_OBJECT
61 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
62
63public:
64 static TypesDB* inst();
65
66 [[nodiscard]] const QVector<TypeDBEntry*> getStore() const;
67 [[nodiscard]] const QHash<QString, TypeDBEntry*> getInd() const;
68 [[nodiscard]] int getStoreSize() const;
69
70 Q_INVOKABLE TypeDBEntry* getStoreAt(int idx) const;
71 Q_INVOKABLE TypeDBEntry* getIndAt(const QString& key) const;
72
73public slots:
74 void load();
75 void index();
76 void qmlProtect(const QQmlEngine* const engine) const;
77
78private slots:
79 void qmlRegister() const;
80
81private:
82 TypesDB();
83
84 QVector<TypeDBEntry*> store;
85 QHash<QString, TypeDBEntry*> ind;
86};
void load()
Load types from JSON.
Definition types.cpp:58
TypeDBEntry * getIndAt(const QString &key) const
Type by name key (for QML).
Definition types.cpp:53
int getStoreSize() const
Type count.
Definition types.cpp:45
static TypesDB * inst()
< Number of types.
Definition types.cpp:37
const QVector< TypeDBEntry * > getStore() const
All types.
Definition types.cpp:43
const QHash< QString, TypeDBEntry * > getInd() const
Name->entry index.
Definition types.cpp:44
void index()
Build the name->entry index.
Definition types.cpp:68
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition types.cpp:80
TypeDBEntry * getStoreAt(int idx) const
Type by store index (for QML).
Definition types.cpp:47
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 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 move's static data (type, power, accuracy, PP, TM/HM), with links.
Definition moves.h:46
One species' complete static data – the richest entry in the db layer.
Definition pokemon.h:98
One elemental type: its name plus the moves and Pokemon of that type.
Definition types.h:39
QVector< PokemonDBEntry * > toPokemon
Pokemon of this type (back-ref).
Definition types.h:48
QVector< MoveDBEntry * > toMoves
Moves of this type (back-ref).
Definition types.h:47
QString readable
Human-readable type name.
Definition types.h:45
var8 ind
Type index/id.
Definition types.h:44
TypeDBEntry()
Empty entry.
Definition types.cpp:29
QString name
Internal type name (key).
Definition types.h:43