Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
28
MapDBEntryWildMon::MapDBEntryWildMon
() {
29
qmlRegister
();
30
}
31
32
MapDBEntryWildMon::MapDBEntryWildMon
(
const
QJsonValue& value,
MapDBEntry
*
const
parent
) :
33
parent
(
parent
)
34
{
35
qmlRegister
();
36
37
name
= value[
"name"
].toString();
38
level
= value[
"level"
].toDouble();
39
}
40
41
void
MapDBEntryWildMon::deepLink
()
42
{
43
toPokemon
=
PokemonDB::inst
()->
getIndAt
(
name
);
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
57
void
MapDBEntryWildMon::qmlRegister
()
const
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
68
MapDBEntry
*
MapDBEntryWildMon::getParent
()
const
69
{
70
return
parent
;
71
}
72
73
void
MapDBEntryWildMon::qmlProtect
(
const
QQmlEngine*
const
engine)
const
74
{
75
Utility::qmlProtectUtil
(
this
, engine);
76
}
77
78
PokemonDBEntry
*
MapDBEntryWildMon::getToPokemon
()
const
79
{
80
return
toPokemon
;
81
}
82
83
int
MapDBEntryWildMon::getLevel
()
const
84
{
85
return
level
;
86
}
87
88
const
QString
MapDBEntryWildMon::getName
()
const
89
{
90
return
name
;
91
}
PokemonDB::inst
static PokemonDB * inst()
< Number of species.
Definition
pokemon.cpp:183
PokemonDB::getIndAt
PokemonDBEntry * getIndAt(const QString &key) const
Species by name key (for QML).
Definition
pokemon.cpp:199
Utility::qmlProtectUtil
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
mapdbentrywildmon.h
pokemon.h
MapDBEntryWildMon::deepLink
void deepLink()
Resolve the species link.
Definition
mapdbentrywildmon.cpp:41
MapDBEntryWildMon::MapDBEntry
friend class MapDBEntry
Definition
mapdbentrywildmon.h:64
MapDBEntryWildMon::MapDBEntryWildMon
MapDBEntryWildMon()
Empty entry.
Definition
mapdbentrywildmon.cpp:28
MapDBEntryWildMon::getToPokemon
PokemonDBEntry * getToPokemon() const
Definition
mapdbentrywildmon.cpp:78
MapDBEntryWildMon::getLevel
int getLevel() const
Definition
mapdbentrywildmon.cpp:83
MapDBEntryWildMon::parent
MapDBEntry * parent
Owning map.
Definition
mapdbentrywildmon.h:61
MapDBEntryWildMon::name
QString name
Species name.
Definition
mapdbentrywildmon.h:57
MapDBEntryWildMon::toPokemon
PokemonDBEntry * toPokemon
Resolved species (deepLink).
Definition
mapdbentrywildmon.h:60
MapDBEntryWildMon::getName
const QString getName() const
< Species name.
Definition
mapdbentrywildmon.cpp:88
MapDBEntryWildMon::qmlRegister
void qmlRegister() const
Register with QML.
Definition
mapdbentrywildmon.cpp:57
MapDBEntryWildMon::level
int level
Encounter level.
Definition
mapdbentrywildmon.h:58
MapDBEntryWildMon::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
mapdbentrywildmon.cpp:73
MapDBEntryWildMon::getParent
MapDBEntry * getParent() const
Definition
mapdbentrywildmon.cpp:68
PokemonDBEntry
One species' complete static data – the richest entry in the db layer.
Definition
pokemon.h:98
utility.h
projects
db
src
pse-db
entries
mapdbentrywildmon.cpp
Generated by
1.17.0