Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
mapdbentrywarpin.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 <QJsonValue>
23#include <QQmlEngine>
24#include <pse-common/utility.h>
25#include "mapdbentrywarpin.h"
26
30MapDBEntryWarpIn::MapDBEntryWarpIn(const QJsonValue& data, MapDBEntry* const parent) :
32{
34
35 x = data["x"].toDouble();
36 y = data["y"].toDouble();
37}
38
40{
41 static bool once = false;
42 if(once)
43 return;
44
45 qmlRegisterUncreatableType<MapDBEntryWarpIn>(
46 "PSE.DB.MapDBEntryWarpIn", 1, 0, "MapDBEntryWarpIn", "Can't instantiate in QML");
47 once = true;
48}
49
51{
52 return parent;
53}
54
55void MapDBEntryWarpIn::qmlProtect(const QQmlEngine* const engine) const
56{
57 Utility::qmlProtectUtil(this, engine);
58}
59
60const QVector<MapDBEntryWarpOut*> MapDBEntryWarpIn::getToConnectingWarps() const
61{
62 return toConnectingWarps;
63}
64
69
71{
72 if(ind >= toConnectingWarps.size())
73 return nullptr;
74
75 return toConnectingWarps.at(ind);
76}
77
79{
80 return y;
81}
82
84{
85 return x;
86}
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
int getX() const
< Warp-in tile X.
int getToConnectingWarpsSize() const
void qmlRegister() const
Register with QML.
int y
Warp-in tile Y.
friend class MapDBEntry
QVector< MapDBEntryWarpOut * > toConnectingWarps
Warp-outs arriving here (filled by warp-out deepLink).
MapDBEntryWarpIn()
Empty entry.
MapDBEntry * parent
Owning map.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
friend class MapDBEntryWarpOut
MapDBEntryWarpOut * getToConnectingWarpsAt(const int ind) const
Connecting warp ind (for QML).
MapDBEntry * getParent() const
const QVector< MapDBEntryWarpOut * > getToConnectingWarps() const
Warp-outs that land here.
int x
Warp-in tile X.