Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
trades.h
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#pragma once
17
18#include <QObject>
19#include <QJsonValue>
20#include <QString>
21#include <QVector>
22
23#include <pse-common/types.h>
24#include "./db_autoport.h"
25
26struct PokemonDBEntry;
27class QQmlEngine;
28
38 TradeDBEntry();
39 TradeDBEntry(QJsonValue& data);
40 void deepLink();
41
42 QString give;
43 QString get;
45 QString nickname;
46 bool unused = false;
47
49 PokemonDBEntry* toGet = nullptr;
50};
51
60class DB_AUTOPORT TradesDB : public QObject
61{
62 Q_OBJECT
63 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
64
65public:
66 static TradesDB* inst();
67
68 [[nodiscard]] const QVector<TradeDBEntry*> getStore() const;
69 [[nodiscard]] int getStoreSize() const;
70
71 Q_INVOKABLE TradeDBEntry* getStoreAt(int idx) const;
72
73public slots:
74 void load();
75 void deepLink();
76 void qmlProtect(const QQmlEngine* const engine) const;
77
78private slots:
79 void qmlRegister() const;
80
81private:
82 TradesDB();
83
84 QVector<TradeDBEntry*> store;
85};
void deepLink()
Resolve each trade's species links.
Definition trades.cpp:81
static TradesDB * inst()
< Number of trades.
Definition trades.cpp:56
int getStoreSize() const
Trade count.
Definition trades.cpp:63
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition trades.cpp:90
void load()
Load trades from JSON.
Definition trades.cpp:71
TradeDBEntry * getStoreAt(int idx) const
Trade by store index (for QML).
Definition trades.cpp:65
const QVector< TradeDBEntry * > getStore() const
All trades.
Definition trades.cpp:62
Project-wide fixed-width integer aliases (var8, var16, ...).
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition types.h:124
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition db_autoport.h:37
One species' complete static data – the richest entry in the db layer.
Definition pokemon.h:98
One in-game (NPC) trade definition: what you give and get.
Definition trades.h:37
PokemonDBEntry * toGet
Resolved species you get (deepLink).
Definition trades.h:49
void deepLink()
Resolve the give/get species links.
Definition trades.cpp:44
var8 textId
Trade dialogue text id.
Definition trades.h:44
TradeDBEntry()
Empty entry.
Definition trades.cpp:34
bool unused
Whether this trade slot is unused.
Definition trades.h:46
QString nickname
Nickname the received mon comes with.
Definition trades.h:45
QString give
Species name you give (resolved to toGive).
Definition trades.h:42
QString get
Species name you get (resolved to toGet).
Definition trades.h:43
PokemonDBEntry * toGive
Resolved species you give (deepLink).
Definition trades.h:48