Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
mapdbentryspriteitem.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 <QJsonValue>
25
#include "
mapdbentryspriteitem.h
"
26
#include "
../itemsdb.h
"
27
#include "
./itemdbentry.h
"
28
29
MapDBEntrySpriteItem::MapDBEntrySpriteItem
(
const
QJsonValue& data,
30
MapDBEntry
*
const
parent
) :
31
MapDBEntrySprite
(data,
parent
)
32
{
33
qmlRegister
();
34
item
= data[
"item"
].toString();
35
}
36
37
void
MapDBEntrySpriteItem::deepLink
()
38
{
39
// There are 2 exceptions in the game where the item name will literally be
40
// "0". Daisy walking, and Town Map in Rival's house. My only guess is that
41
// they wanted to script an item rather than automate giving you an item but
42
// it's quite weird because Daisy Walking is an item. Another guess is this
43
// is an early in-development code before item automation was programmed in.
44
MapDBEntrySprite::deepLink
();
45
46
if
(
item
==
"0"
)
47
return
;
48
49
toItem
=
ItemsDB::inst
()->
getInd
().value(
item
);
50
51
#ifdef QT_DEBUG
52
if
(
toItem
==
nullptr
)
53
qCritical() <<
"MapDBEntrySpriteItem: Unable to deep link "
+
item
+
" to item"
;
54
#endif
55
56
if
(
toItem
!=
nullptr
)
57
toItem
->toMapSpriteItem.append(
this
);
58
}
59
60
ItemDBEntry
*
MapDBEntrySpriteItem::getToItem
()
const
61
{
62
return
toItem
;
63
}
64
65
const
QString
MapDBEntrySpriteItem::getItem
()
const
66
{
67
return
item
;
68
}
69
70
MapDBEntrySpriteItem::SpriteType
MapDBEntrySpriteItem::type
()
const
71
{
72
return
SpriteType::ITEM
;
73
}
74
75
void
MapDBEntrySpriteItem::qmlRegister
()
const
76
{
77
static
bool
once =
false
;
78
if
(once)
return
;
79
qmlRegisterUncreatableType<MapDBEntrySpriteItem>(
"PSE.DB.MapDBEntrySpriteItem"
, 1, 0,
"MapDBEntrySpriteItem"
,
"Can't instantiate in QML"
);
80
once =
true
;
81
}
ItemsDB::getInd
const QHash< QString, ItemDBEntry * > getInd() const
Name->entry index.
Definition
itemsdb.cpp:48
ItemsDB::inst
static ItemsDB * inst()
< Number of items.
Definition
itemsdb.cpp:37
itemdbentry.h
itemsdb.h
mapdbentryspriteitem.h
ItemDBEntry
One item's static data: name/flags, pricing, and where it's used.
Definition
itemdbentry.h:46
MapDBEntrySpriteItem::MapDBEntrySpriteItem
MapDBEntrySpriteItem(const QJsonValue &data, MapDBEntry *const parent)
Build from JSON under parent.
Definition
mapdbentryspriteitem.cpp:29
MapDBEntrySpriteItem::MapDBEntry
friend class MapDBEntry
Definition
mapdbentryspriteitem.h:54
MapDBEntrySpriteItem::deepLink
virtual void deepLink()
Resolve the item link.
Definition
mapdbentryspriteitem.cpp:37
MapDBEntrySpriteItem::getToItem
ItemDBEntry * getToItem() const
Definition
mapdbentryspriteitem.cpp:60
MapDBEntrySpriteItem::toItem
ItemDBEntry * toItem
Resolved item (deepLink).
Definition
mapdbentryspriteitem.h:52
MapDBEntrySpriteItem::type
virtual SpriteType type() const
< Item name given.
Definition
mapdbentryspriteitem.cpp:70
MapDBEntrySpriteItem::qmlRegister
virtual void qmlRegister() const
Register with QML.
Definition
mapdbentryspriteitem.cpp:75
MapDBEntrySpriteItem::item
QString item
Item name (read via getItem()).
Definition
mapdbentryspriteitem.h:50
MapDBEntrySpriteItem::getItem
const QString getItem() const
Definition
mapdbentryspriteitem.cpp:65
MapDBEntrySprite::MapDBEntrySprite
MapDBEntrySprite()
Empty entry.
Definition
mapdbentrysprite.cpp:31
MapDBEntrySprite::deepLink
virtual void deepLink()
Resolve sprite/missable links.
Definition
mapdbentrysprite.cpp:55
MapDBEntrySprite::parent
MapDBEntry * parent
Owning map.
Definition
mapdbentrysprite.h:140
MapDBEntrySprite::SpriteType
SpriteType
< X adjusted for Gen 1 placement.
Definition
mapdbentrysprite.h:66
MapDBEntrySprite::ITEM
@ ITEM
Definition
mapdbentrysprite.h:71
projects
db
src
pse-db
entries
mapdbentryspriteitem.cpp
Generated by
1.17.0