Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
mapdbentryspritetrainer.cpp
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
21
22#include <QDebug>
23#include <QJsonValue>
24#include <QQmlEngine>
25#include <pse-common/utility.h>
27
28#include "../trainers.h"
29
31 MapDBEntry* const parent) :
33{
35
36 trainerClass = data["class"].toString();
37 team = data["team"].toDouble();
38}
39
41{
44
45#ifdef QT_DEBUG
46 if(toTrainer == nullptr)
47 qCritical() << "MapDBEntrySpriteTrainer: Unable to deep link " + trainerClass + " to trainer";
48#endif
49
50 if(toTrainer != nullptr)
51 toTrainer->tpMapSpriteTrainers.append(this);
52}
53
55{
56 static bool once = false;
57 if(once)
58 return;
59
60 qmlRegisterUncreatableType<MapDBEntrySpriteTrainer>(
61 "PSE.DB.MapDBEntrySpriteTrainer", 1, 0, "MapDBEntrySpriteTrainer", "Can't instantiate in QML");
62 once = true;
63}
64
69
71{
72 return team;
73}
74
76{
77 return trainerClass;
78}
79
TrainerDBEntry * getIndAt(const QString &key) const
Trainer by name key (for QML).
Definition trainers.cpp:54
static TrainersDB * inst()
< Number of trainer classes.
Definition trainers.cpp:38
QString trainerClass
Trainer class name (read via getTrainerClass()).
virtual SpriteType type() const
< Trainer class name.
TrainerDBEntry * toTrainer
Resolved trainer class (deepLink).
MapDBEntrySpriteTrainer(const QJsonValue &data, MapDBEntry *const parent)
Build from JSON under parent.
virtual void qmlRegister() const
Register with QML.
const QString getTrainerClass() const
TrainerDBEntry * getToTrainer() const
virtual void deepLink()
Resolve the trainer-class link.
MapDBEntrySprite()
Empty entry.
virtual void deepLink()
Resolve sprite/missable links.
MapDBEntry * parent
Owning map.
SpriteType
< X adjusted for Gen 1 placement.
One trainer-class definition (its name/index and flags).
Definition trainers.h:38