Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
hiddenitemdbentry.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 <QQmlEngine>
23#include <QDebug>
24#include <pse-common/utility.h>
25
26#include "../mapsdb.h"
27#include "./mapdbentry.h"
28#include "hiddenitemdbentry.h"
29
33
35{
37
38 // Set simple properties
39 map = data["map"].toString();
40 x = data["x"].toDouble();
41 y = data["y"].toDouble();
42}
43
45{
47
48#ifdef QT_DEBUG
49 if(toMap == nullptr)
50 qCritical() << "Hidden Coins Map: " << map << ", could not be deep linked." ;
51#endif
52
53 if(toMap != nullptr)
54 toMap->toHiddenItems.append(this);
55}
56
58{
59 static bool once = false;
60 if(once)
61 return;
62
63 qmlRegisterUncreatableType<HiddenItemDBEntry>(
64 "PSE.DB.HiddenItemDBEntry", 1, 0, "HiddenItemDBEntry", "Can't instantiate in QML");
65 once = true;
66}
67
69{
70 return map;
71}
72
74{
75 return x;
76}
77
79{
80 return y;
81}
82
84{
85 return toMap;
86}
87
88void HiddenItemDBEntry::qmlProtect(const QQmlEngine* const engine) const
89{
90 Utility::qmlProtectUtil(this, engine);
91}
static MapsDB * inst()
< Number of maps.
Definition mapsdb.cpp:35
MapDBEntry * getIndAt(const QString val) const
Map by name key (for QML).
Definition mapsdb.cpp:155
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 qmlRegister() const
Register with QML.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
MapDBEntry * toMap
Resolved map (deepLink).
QString getMap() const
< Map name the pickup is on.
void deepLink()
Resolve the map link.
QString map
Backing field (read via getMap()).
MapDBEntry * getToMap() const
int x
Backing field (read via getX()).
int y
Backing field (read via getY()).
HiddenItemDBEntry()
Empty entry (built by the DB).
One map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56