Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
30
HiddenItemDBEntry::HiddenItemDBEntry
() {
31
qmlRegister
();
32
}
33
34
HiddenItemDBEntry::HiddenItemDBEntry
(
const
QJsonValue& data)
35
{
36
qmlRegister
();
37
38
// Set simple properties
39
map
= data[
"map"
].toString();
40
x
= data[
"x"
].toDouble();
41
y
= data[
"y"
].toDouble();
42
}
43
44
void
HiddenItemDBEntry::deepLink
()
45
{
46
toMap
=
MapsDB::inst
()->
getIndAt
(
map
);
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
57
void
HiddenItemDBEntry::qmlRegister
()
const
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
68
QString
HiddenItemDBEntry::getMap
()
const
69
{
70
return
map
;
71
}
72
73
int
HiddenItemDBEntry::getX
()
const
74
{
75
return
x
;
76
}
77
78
int
HiddenItemDBEntry::getY
()
const
79
{
80
return
y
;
81
}
82
83
MapDBEntry
*
HiddenItemDBEntry::getToMap
()
const
84
{
85
return
toMap
;
86
}
87
88
void
HiddenItemDBEntry::qmlProtect
(
const
QQmlEngine*
const
engine)
const
89
{
90
Utility::qmlProtectUtil
(
this
, engine);
91
}
MapsDB::inst
static MapsDB * inst()
< Number of maps.
Definition
mapsdb.cpp:35
MapsDB::getIndAt
MapDBEntry * getIndAt(const QString val) const
Map by name key (for QML).
Definition
mapsdb.cpp:155
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
hiddenitemdbentry.h
mapdbentry.h
mapsdb.h
HiddenItemDBEntry::qmlRegister
void qmlRegister() const
Register with QML.
Definition
hiddenitemdbentry.cpp:57
HiddenItemDBEntry::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
hiddenitemdbentry.cpp:88
HiddenItemDBEntry::toMap
MapDBEntry * toMap
Resolved map (deepLink).
Definition
hiddenitemdbentry.h:60
HiddenItemDBEntry::getMap
QString getMap() const
< Map name the pickup is on.
Definition
hiddenitemdbentry.cpp:68
HiddenItemDBEntry::deepLink
void deepLink()
Resolve the map link.
Definition
hiddenitemdbentry.cpp:44
HiddenItemDBEntry::map
QString map
Backing field (read via getMap()).
Definition
hiddenitemdbentry.h:57
HiddenItemDBEntry::getToMap
MapDBEntry * getToMap() const
Definition
hiddenitemdbentry.cpp:83
HiddenItemDBEntry::x
int x
Backing field (read via getX()).
Definition
hiddenitemdbentry.h:58
HiddenItemDBEntry::getX
int getX() const
Definition
hiddenitemdbentry.cpp:73
HiddenItemDBEntry::y
int y
Backing field (read via getY()).
Definition
hiddenitemdbentry.h:59
HiddenItemDBEntry::getY
int getY() const
Definition
hiddenitemdbentry.cpp:78
HiddenItemDBEntry::HiddenItemDBEntry
HiddenItemDBEntry()
Empty entry (built by the DB).
Definition
hiddenitemdbentry.cpp:30
MapDBEntry
One map's complete static definition – the root of the MapDBEntry family.
Definition
mapdbentry.h:56
utility.h
projects
db
src
pse-db
entries
hiddenitemdbentry.cpp
Generated by
1.17.0