Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
abstracthiddenitemdb.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2019 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
22
23
#include <
pse-common/utility.h
>
24
#include <QVector>
25
#include <QJsonArray>
26
27
#ifdef QT_DEBUG
28
#include <QtDebug>
29
#endif
30
31
#include "
./abstracthiddenitemdb.h
"
32
#include "
./mapsdb.h
"
33
#include "
./util/gamedata.h
"
34
#include "
./entries/hiddenitemdbentry.h
"
35
36
const
QVector<HiddenItemDBEntry*>
AbstractHiddenItemDB::getStore
()
const
37
{
38
return
store
;
39
}
40
41
int
AbstractHiddenItemDB::getStoreSize
()
const
42
{
43
return
store
.size();
44
}
45
46
HiddenItemDBEntry
*
AbstractHiddenItemDB::getStoreAt
(
const
int
ind)
const
47
{
48
if
(ind >=
store
.size())
49
return
nullptr
;
50
51
return
store
.at(ind);
52
}
53
54
void
AbstractHiddenItemDB::load
()
55
{
56
static
bool
once =
false
;
57
if
(once)
58
return
;
59
60
// Grab Event Pokemon Data
61
auto
jsonData =
GameData::inst
()->
json
(
loadFile
);
62
63
// Go through each event Pokemon
64
for
(QJsonValue jsonEntry : jsonData.array())
65
{
66
// Create a new event Pokemon entry
67
auto
entry =
new
HiddenItemDBEntry
(jsonEntry);
68
69
// Add to array
70
store
.append(entry);
71
}
72
73
once =
true
;
74
}
75
76
void
AbstractHiddenItemDB::deepLink
()
77
{
78
static
bool
once =
false
;
79
if
(once)
80
return
;
81
82
for
(
auto
entry :
store
)
83
{
84
entry->deepLink();
85
}
86
87
once =
true
;
88
}
89
90
void
AbstractHiddenItemDB::qmlProtect
(
const
QQmlEngine*
const
engine)
const
91
{
92
Utility::qmlProtectUtil
(
this
, engine);
93
94
for
(
auto
el :
store
)
95
el->qmlProtect(engine);
96
}
97
98
AbstractHiddenItemDB::AbstractHiddenItemDB
(
const
QString
loadFile
)
99
:
loadFile
(
loadFile
)
100
{
101
load
();
102
}
abstracthiddenitemdb.h
AbstractHiddenItemDB::AbstractHiddenItemDB
AbstractHiddenItemDB(const QString loadFile)
Definition
abstracthiddenitemdb.cpp:98
AbstractHiddenItemDB::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
abstracthiddenitemdb.cpp:90
AbstractHiddenItemDB::getStoreSize
int getStoreSize() const
Entry count.
Definition
abstracthiddenitemdb.cpp:41
AbstractHiddenItemDB::loadFile
const QString loadFile
JSON asset path (set by the subclass).
Definition
abstracthiddenitemdb.h:60
AbstractHiddenItemDB::getStoreAt
HiddenItemDBEntry * getStoreAt(const int ind) const
Entry by store index (for QML).
Definition
abstracthiddenitemdb.cpp:46
AbstractHiddenItemDB::store
QVector< HiddenItemDBEntry * > store
The loaded entries.
Definition
abstracthiddenitemdb.h:59
AbstractHiddenItemDB::load
void load()
Load entries from loadFile.
Definition
abstracthiddenitemdb.cpp:54
AbstractHiddenItemDB::getStore
const QVector< HiddenItemDBEntry * > getStore() const
< Number of hidden pickups.
Definition
abstracthiddenitemdb.cpp:36
AbstractHiddenItemDB::deepLink
void deepLink()
Resolve each entry's cross-DB links.
Definition
abstracthiddenitemdb.cpp:76
GameData::json
const QJsonDocument json(const QString filename) const
Parsed document for filename.
Definition
gamedata.cpp:45
GameData::inst
static GameData * inst()
The process-wide GameData singleton.
Definition
gamedata.cpp:71
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
gamedata.h
hiddenitemdbentry.h
mapsdb.h
HiddenItemDBEntry
One hidden pickup's location: its map and tile coordinates.
Definition
hiddenitemdbentry.h:35
utility.h
projects
db
src
pse-db
abstracthiddenitemdb.cpp
Generated by
1.17.0