Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
sprites.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 <QVector>
21#include <QString>
22#include <QHash>
23
24#include <pse-common/types.h>
25#include "./db_autoport.h"
26
27struct MapDBEntrySprite;
28class QQmlEngine;
29
40 SpriteDBEntry(QJsonValue& data);
41
42 QString name;
43 var8 ind = 0;
44
45 QVector<MapDBEntrySprite*> toMaps;
46};
47
55class DB_AUTOPORT SpritesDB : public QObject
56{
57 Q_OBJECT
58 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
59
60public:
61 static SpritesDB* inst();
62
63 [[nodiscard]] const QVector<SpriteDBEntry*> getStore() const;
64 [[nodiscard]] const QHash<QString, SpriteDBEntry*> getInd() const;
65 [[nodiscard]] int getStoreSize() const;
66
67 Q_INVOKABLE SpriteDBEntry* getStoreAt(int idx) const;
68 Q_INVOKABLE SpriteDBEntry* getIndAt(const QString& key) const;
69
70public slots:
71 void load();
72 void index();
73 void qmlProtect(const QQmlEngine* const engine) const;
74
75private slots:
76 void qmlRegister() const;
77
78private:
79 SpritesDB();
80
81 QVector<SpriteDBEntry*> store;
82 QHash<QString, SpriteDBEntry*> ind;
83};
static SpritesDB * inst()
< Number of sprites.
Definition sprites.cpp:36
SpriteDBEntry * getIndAt(const QString &key) const
Sprite by name key (for QML).
Definition sprites.cpp:52
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition sprites.cpp:78
const QHash< QString, SpriteDBEntry * > getInd() const
Name->entry index.
Definition sprites.cpp:43
void load()
Load sprites from JSON.
Definition sprites.cpp:57
const QVector< SpriteDBEntry * > getStore() const
All sprites.
Definition sprites.cpp:42
void index()
Build the name->entry index.
Definition sprites.cpp:67
int getStoreSize() const
Sprite count.
Definition sprites.cpp:44
SpriteDBEntry * getStoreAt(int idx) const
Sprite by store index (for QML).
Definition sprites.cpp:46
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
A map's sprite definition – base class for the four sprite kinds.
One sprite definition: its name/picture-id and the maps that use it.
Definition sprites.h:38
QVector< MapDBEntrySprite * > toMaps
Map-sprites using this picture (back-ref).
Definition sprites.h:45
var8 ind
Picture id.
Definition sprites.h:43
QString name
Sprite name (key).
Definition sprites.h:42
SpriteDBEntry()
Empty entry.
Definition sprites.cpp:29