Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
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>
26#include "../itemsdb.h"
27#include "./itemdbentry.h"
28
30 MapDBEntry* const parent) :
32{
34 item = data["item"].toString();
35}
36
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.
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
64
65const QString MapDBEntrySpriteItem::getItem() const
66{
67 return item;
68}
69
74
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}
const QHash< QString, ItemDBEntry * > getInd() const
Name->entry index.
Definition itemsdb.cpp:48
static ItemsDB * inst()
< Number of items.
Definition itemsdb.cpp:37
One item's static data: name/flags, pricing, and where it's used.
Definition itemdbentry.h:46
MapDBEntrySpriteItem(const QJsonValue &data, MapDBEntry *const parent)
Build from JSON under parent.
virtual void deepLink()
Resolve the item link.
ItemDBEntry * getToItem() const
ItemDBEntry * toItem
Resolved item (deepLink).
virtual SpriteType type() const
< Item name given.
virtual void qmlRegister() const
Register with QML.
QString item
Item name (read via getItem()).
const QString getItem() const
MapDBEntrySprite()
Empty entry.
virtual void deepLink()
Resolve sprite/missable links.
MapDBEntry * parent
Owning map.
SpriteType
< X adjusted for Gen 1 placement.