Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
mapdbentrywildmon.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 <QQmlEngine>
24#include <pse-common/utility.h>
25#include "mapdbentrywildmon.h"
26#include "../pokemon.h"
27
31
32MapDBEntryWildMon::MapDBEntryWildMon(const QJsonValue& value, MapDBEntry* const parent) :
34{
36
37 name = value["name"].toString();
38 level = value["level"].toDouble();
39}
40
42{
44
45#ifdef QT_DEBUG
46 // Stop here if toMap is nullptr
47 if(toPokemon == nullptr) {
48 qCritical() << "Wild Pokemon Entry: " << name << ", could not be deep linked";
49 return;
50 }
51#endif
52
53 if(toPokemon != nullptr)
54 toPokemon->toWildMonMaps.append(this);
55}
56
58{
59 static bool once = false;
60 if(once)
61 return;
62
63 qmlRegisterUncreatableType<MapDBEntryWildMon>(
64 "PSE.DB.MapDBEntryWildMon", 1, 0, "MapDBEntryWildMon", "Can't instantiate in QML");
65 once = true;
66}
67
72
73void MapDBEntryWildMon::qmlProtect(const QQmlEngine* const engine) const
74{
75 Utility::qmlProtectUtil(this, engine);
76}
77
82
84{
85 return level;
86}
87
88const QString MapDBEntryWildMon::getName() const
89{
90 return name;
91}
static PokemonDB * inst()
< Number of species.
Definition pokemon.cpp:183
PokemonDBEntry * getIndAt(const QString &key) const
Species by name key (for QML).
Definition pokemon.cpp:199
static void qmlProtectUtil(const QObject *const obj, const QQmlEngine *const engine)
Pin obj to C++ ownership so the QML engine never garbage-collects it.
Definition utility.cpp:63
void deepLink()
Resolve the species link.
friend class MapDBEntry
MapDBEntryWildMon()
Empty entry.
PokemonDBEntry * getToPokemon() const
MapDBEntry * parent
Owning map.
QString name
Species name.
PokemonDBEntry * toPokemon
Resolved species (deepLink).
const QString getName() const
< Species name.
void qmlRegister() const
Register with QML.
int level
Encounter level.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
MapDBEntry * getParent() const
One species' complete static data – the richest entry in the db layer.
Definition pokemon.h:98