Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
mapdbentrywarpout.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 "
mapdbentrywarpout.h
"
26
#include "
./mapdbentry.h
"
27
#include "
./mapdbentrywarpin.h
"
28
#include "
../mapsdb.h
"
29
30
MapDBEntryWarpOut::MapDBEntryWarpOut
() {
31
qmlRegister
();
32
}
33
MapDBEntryWarpOut::MapDBEntryWarpOut
(
const
QJsonValue& data,
MapDBEntry
*
const
parent
) :
34
parent
(
parent
)
35
{
36
qmlRegister
();
37
x
= data[
"x"
].toDouble();
38
y
= data[
"y"
].toDouble();
39
warp
= data[
"toWarp"
].toDouble();
40
map
= data[
"toMap"
].toString();
41
glitch
= data[
"glitch"
].toBool(
false
);
42
}
43
44
void
MapDBEntryWarpOut::deepLink
()
45
{
46
toMap
=
MapsDB::inst
()->
getInd
().value(
map
,
nullptr
);
47
48
#ifdef QT_DEBUG
49
// Stop here if toMap is nullptr
50
if
(
toMap
==
nullptr
) {
51
qCritical() <<
"Map Warp Out entry: "
<<
map
<<
", could not be deep linked to map"
;
52
return
;
53
}
54
#endif
55
56
// Stop here if this is a special warp to simply return to the last map
57
if
(
map
==
"Last Map"
)
58
return
;
59
60
// Also stop here if this is the silph co elevator which warps to an invalid
61
// map. Why would the elevator do this? No idea.
62
if
(
map
==
"237"
)
63
return
;
64
65
// Deep link to the destination warp coordinates
66
// This will immidiately crash if toMap isn't set
67
toWarp
=
const_cast<
MapDBEntryWarpIn
*
>
(
toMap
->getWarpInAt(
warp
));
68
69
toWarp
->toConnectingWarps.append(
this
);
70
}
71
72
void
MapDBEntryWarpOut::qmlRegister
()
const
73
{
74
static
bool
once =
false
;
75
if
(once)
76
return
;
77
78
qmlRegisterUncreatableType<MapDBEntryWarpOut>(
79
"PSE.DB.MapDBEntryWarpOut"
, 1, 0,
"MapDBEntryWarpOut"
,
"Can't instantiate in QML"
);
80
once =
true
;
81
}
82
83
MapDBEntryWarpIn
*
MapDBEntryWarpOut::getToWarp
()
const
84
{
85
return
toWarp
;
86
}
87
88
void
MapDBEntryWarpOut::qmlProtect
(
const
QQmlEngine*
const
engine)
const
89
{
90
Utility::qmlProtectUtil
(
this
, engine);
91
}
92
93
MapDBEntry
*
MapDBEntryWarpOut::getParent
()
const
94
{
95
return
parent
;
96
}
97
98
MapDBEntry
*
MapDBEntryWarpOut::getToMap
()
const
99
{
100
return
toMap
;
101
}
102
103
bool
MapDBEntryWarpOut::getGlitch
()
const
104
{
105
return
glitch
;
106
}
107
108
const
QString
MapDBEntryWarpOut::getMap
()
const
109
{
110
return
map
;
111
}
112
113
int
MapDBEntryWarpOut::getWarp
()
const
114
{
115
return
warp
;
116
}
117
118
int
MapDBEntryWarpOut::getY
()
const
119
{
120
return
y
;
121
}
122
123
int
MapDBEntryWarpOut::getX
()
const
124
{
125
return
x
;
126
}
MapsDB::inst
static MapsDB * inst()
< Number of maps.
Definition
mapsdb.cpp:35
MapsDB::getInd
const QHash< QString, MapDBEntry * > getInd() const
Name->map index.
Definition
mapsdb.cpp:46
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
mapdbentry.h
mapdbentrywarpin.h
mapdbentrywarpout.h
mapsdb.h
MapDBEntryWarpOut::MapDBEntryWarpOut
MapDBEntryWarpOut()
Empty entry.
Definition
mapdbentrywarpout.cpp:30
MapDBEntryWarpOut::toMap
MapDBEntry * toMap
Resolved destination map (deepLink).
Definition
mapdbentrywarpout.h:81
MapDBEntryWarpOut::getToWarp
MapDBEntryWarpIn * getToWarp() const
Definition
mapdbentrywarpout.cpp:83
MapDBEntryWarpOut::deepLink
void deepLink()
Resolve the destination map + warp-in.
Definition
mapdbentrywarpout.cpp:44
MapDBEntryWarpOut::toWarp
MapDBEntryWarpIn * toWarp
Resolved destination warp-in (deepLink).
Definition
mapdbentrywarpout.h:85
MapDBEntryWarpOut::MapDBEntry
friend class MapDBEntry
Definition
mapdbentrywarpout.h:87
MapDBEntryWarpOut::getX
int getX() const
< Warp-out tile X.
Definition
mapdbentrywarpout.cpp:123
MapDBEntryWarpOut::getWarp
int getWarp() const
Definition
mapdbentrywarpout.cpp:113
MapDBEntryWarpOut::MapDBEntryWarpIn
friend class MapDBEntryWarpIn
Definition
mapdbentrywarpout.h:89
MapDBEntryWarpOut::qmlRegister
void qmlRegister() const
Register with QML.
Definition
mapdbentrywarpout.cpp:72
MapDBEntryWarpOut::getMap
const QString getMap() const
Definition
mapdbentrywarpout.cpp:108
MapDBEntryWarpOut::x
int x
Warp-out tile X.
Definition
mapdbentrywarpout.h:68
MapDBEntryWarpOut::getY
int getY() const
Definition
mapdbentrywarpout.cpp:118
MapDBEntryWarpOut::y
int y
Warp-out tile Y.
Definition
mapdbentrywarpout.h:69
MapDBEntryWarpOut::getParent
MapDBEntry * getParent() const
Definition
mapdbentrywarpout.cpp:93
MapDBEntryWarpOut::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
mapdbentrywarpout.cpp:88
MapDBEntryWarpOut::parent
MapDBEntry * parent
Owning map.
Definition
mapdbentrywarpout.h:82
MapDBEntryWarpOut::map
QString map
Destination map name.
Definition
mapdbentrywarpout.h:75
MapDBEntryWarpOut::getGlitch
bool getGlitch() const
Definition
mapdbentrywarpout.cpp:103
MapDBEntryWarpOut::glitch
bool glitch
Glitch/unintended warp.
Definition
mapdbentrywarpout.h:78
MapDBEntryWarpOut::getToMap
MapDBEntry * getToMap() const
Definition
mapdbentrywarpout.cpp:98
MapDBEntryWarpOut::warp
int warp
Target warp-in index.
Definition
mapdbentrywarpout.h:72
utility.h
projects
db
src
pse-db
entries
mapdbentrywarpout.cpp
Generated by
1.17.0