Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
mapdbentryspritepokemon.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 "
mapdbentryspritepokemon.h
"
26
#include "
../pokemon.h
"
27
28
MapDBEntrySpritePokemon::MapDBEntrySpritePokemon
(
const
QJsonValue& data,
29
MapDBEntry
*
const
parent
) :
30
MapDBEntrySprite
(data,
parent
)
31
{
32
pokemon
= data[
"pokemon"
].toString();
33
level
= data[
"level"
].toDouble();
34
}
35
36
void
MapDBEntrySpritePokemon::deepLink
()
37
{
38
MapDBEntrySprite::deepLink
();
39
toPokemon
=
PokemonDB::inst
()->
getIndAt
(
pokemon
);
40
41
#ifdef QT_DEBUG
42
if
(
toPokemon
==
nullptr
)
43
qCritical() <<
"MapDBEntrySpritePokemon: Unable to deep link "
+
pokemon
+
" to pokemon"
;
44
#endif
45
46
if
(
toPokemon
!=
nullptr
)
47
toPokemon
->toMapSpritePokemon =
this
;
48
}
49
50
void
MapDBEntrySpritePokemon::qmlRegister
()
const
51
{
52
static
bool
once =
false
;
53
if
(once)
54
return
;
55
56
qmlRegisterUncreatableType<MapDBEntrySpritePokemon>(
57
"PSE.DB.MapDBEntrySpritePokemon"
, 1, 0,
"MapDBEntrySpritePokemon"
,
"Can't instantiate in QML"
);
58
once =
true
;
59
}
60
61
PokemonDBEntry
*
MapDBEntrySpritePokemon::getToPokemon
()
const
62
{
63
return
toPokemon
;
64
}
65
66
int
MapDBEntrySpritePokemon::getLevel
()
const
67
{
68
return
level
;
69
}
70
71
const
QString
MapDBEntrySpritePokemon::getPokemon
()
const
72
{
73
return
pokemon
;
74
}
75
76
MapDBEntrySpritePokemon::SpriteType
MapDBEntrySpritePokemon::type
()
const
77
{
78
return
SpriteType::POKEMON
;
79
}
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
mapdbentryspritepokemon.h
pokemon.h
MapDBEntrySpritePokemon::MapDBEntrySpritePokemon
MapDBEntrySpritePokemon(const QJsonValue &data, MapDBEntry *const parent)
Build from JSON under parent.
Definition
mapdbentryspritepokemon.cpp:28
MapDBEntrySpritePokemon::MapDBEntry
friend class MapDBEntry
Definition
mapdbentryspritepokemon.h:57
MapDBEntrySpritePokemon::toPokemon
PokemonDBEntry * toPokemon
Resolved species (deepLink).
Definition
mapdbentryspritepokemon.h:55
MapDBEntrySpritePokemon::pokemon
QString pokemon
Species name (read via getPokemon()).
Definition
mapdbentryspritepokemon.h:52
MapDBEntrySpritePokemon::level
int level
Encounter level.
Definition
mapdbentryspritepokemon.h:53
MapDBEntrySpritePokemon::type
virtual SpriteType type() const
< Species name.
Definition
mapdbentryspritepokemon.cpp:76
MapDBEntrySpritePokemon::qmlRegister
virtual void qmlRegister() const
Register with QML.
Definition
mapdbentryspritepokemon.cpp:50
MapDBEntrySpritePokemon::deepLink
virtual void deepLink()
Resolve the species link.
Definition
mapdbentryspritepokemon.cpp:36
MapDBEntrySpritePokemon::getLevel
int getLevel() const
Definition
mapdbentryspritepokemon.cpp:66
MapDBEntrySpritePokemon::getPokemon
const QString getPokemon() const
Definition
mapdbentryspritepokemon.cpp:71
MapDBEntrySpritePokemon::getToPokemon
PokemonDBEntry * getToPokemon() const
Definition
mapdbentryspritepokemon.cpp:61
MapDBEntrySprite::MapDBEntrySprite
MapDBEntrySprite()
Empty entry.
Definition
mapdbentrysprite.cpp:31
MapDBEntrySprite::deepLink
virtual void deepLink()
Resolve sprite/missable links.
Definition
mapdbentrysprite.cpp:55
MapDBEntrySprite::parent
MapDBEntry * parent
Owning map.
Definition
mapdbentrysprite.h:140
MapDBEntrySprite::SpriteType
SpriteType
< X adjusted for Gen 1 placement.
Definition
mapdbentrysprite.h:66
MapDBEntrySprite::POKEMON
@ POKEMON
Definition
mapdbentrysprite.h:74
PokemonDBEntry
One species' complete static data – the richest entry in the db layer.
Definition
pokemon.h:98
projects
db
src
pse-db
entries
mapdbentryspritepokemon.cpp
Generated by
1.17.0