Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
trainers.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 <QVector>
21
#include <QString>
22
#include <QHash>
23
24
#include <
pse-common/types.h
>
25
#include "
./db_autoport.h
"
26
27
struct
MapDBEntrySpriteTrainer
;
28
class
QQmlEngine;
29
38
struct
DB_AUTOPORT
TrainerDBEntry
{
39
TrainerDBEntry
();
40
TrainerDBEntry
(QJsonValue& data);
41
42
QString
name
;
43
var8
ind
= 0;
44
bool
unused
=
false
;
45
bool
opp
=
false
;
46
47
QVector<MapDBEntrySpriteTrainer*>
tpMapSpriteTrainers
;
48
};
49
57
class
DB_AUTOPORT
TrainersDB :
public
QObject
58
{
59
Q_OBJECT
60
Q_PROPERTY(
int
getStoreSize
READ
getStoreSize
CONSTANT)
61
62
public
:
63
static
TrainersDB*
inst
();
64
65
[[nodiscard]]
const
QVector<TrainerDBEntry*>
getStore
()
const
;
66
[[nodiscard]]
const
QHash<QString, TrainerDBEntry*>
getInd
()
const
;
67
[[nodiscard]]
int
getStoreSize
()
const
;
68
69
Q_INVOKABLE
TrainerDBEntry
*
getStoreAt
(
int
idx)
const
;
70
Q_INVOKABLE
TrainerDBEntry
*
getIndAt
(
const
QString& key)
const
;
71
72
public
slots:
73
void
load
();
74
void
index
();
75
void
qmlProtect
(
const
QQmlEngine*
const
engine)
const
;
76
77
private
slots:
78
void
qmlRegister()
const
;
79
80
private
:
81
TrainersDB();
82
83
QVector<TrainerDBEntry*> store;
84
QHash<QString, TrainerDBEntry*> ind;
85
};
TrainersDB::getIndAt
TrainerDBEntry * getIndAt(const QString &key) const
Trainer by name key (for QML).
Definition
trainers.cpp:54
TrainersDB::getStore
const QVector< TrainerDBEntry * > getStore() const
All trainer classes.
Definition
trainers.cpp:44
TrainersDB::index
void index()
Build the name->entry index.
Definition
trainers.cpp:69
TrainersDB::inst
static TrainersDB * inst()
< Number of trainer classes.
Definition
trainers.cpp:38
TrainersDB::getStoreAt
TrainerDBEntry * getStoreAt(int idx) const
Trainer by store index (for QML).
Definition
trainers.cpp:48
TrainersDB::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
trainers.cpp:80
TrainersDB::getInd
const QHash< QString, TrainerDBEntry * > getInd() const
Name->entry index.
Definition
trainers.cpp:45
TrainersDB::load
void load()
Load trainers from JSON.
Definition
trainers.cpp:59
TrainersDB::getStoreSize
int getStoreSize() const
Trainer-class count.
Definition
trainers.cpp:46
types.h
Project-wide fixed-width integer aliases (var8, var16, ...).
var8
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition
types.h:124
db_autoport.h
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
DB_AUTOPORT
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition
db_autoport.h:37
MapDBEntrySpriteTrainer
A map sprite that is a battleable trainer (type TRAINER).
Definition
mapdbentryspritetrainer.h:32
TrainerDBEntry
One trainer-class definition (its name/index and flags).
Definition
trainers.h:38
TrainerDBEntry::TrainerDBEntry
TrainerDBEntry()
Empty entry.
Definition
trainers.cpp:29
TrainerDBEntry::name
QString name
Trainer-class name (key).
Definition
trainers.h:42
TrainerDBEntry::unused
bool unused
Whether this slot is unused.
Definition
trainers.h:44
TrainerDBEntry::tpMapSpriteTrainers
QVector< MapDBEntrySpriteTrainer * > tpMapSpriteTrainers
On-map trainers of this class (back-ref).
Definition
trainers.h:47
TrainerDBEntry::ind
var8 ind
Trainer-class index.
Definition
trainers.h:43
TrainerDBEntry::opp
bool opp
Whether it's an opponent class.
Definition
trainers.h:45
projects
db
src
pse-db
trainers.h
Generated by
1.17.0