Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
27
struct
MapDBEntrySprite
;
28
class
QQmlEngine;
29
38
struct
DB_AUTOPORT
SpriteDBEntry
{
39
SpriteDBEntry
();
40
SpriteDBEntry
(QJsonValue& data);
41
42
QString
name
;
43
var8
ind
= 0;
44
45
QVector<MapDBEntrySprite*>
toMaps
;
46
};
47
55
class
DB_AUTOPORT
SpritesDB :
public
QObject
56
{
57
Q_OBJECT
58
Q_PROPERTY(
int
getStoreSize
READ
getStoreSize
CONSTANT)
59
60
public
:
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
70
public
slots:
71
void
load
();
72
void
index
();
73
void
qmlProtect
(
const
QQmlEngine*
const
engine)
const
;
74
75
private
slots:
76
void
qmlRegister()
const
;
77
78
private
:
79
SpritesDB();
80
81
QVector<SpriteDBEntry*> store;
82
QHash<QString, SpriteDBEntry*> ind;
83
};
SpritesDB::inst
static SpritesDB * inst()
< Number of sprites.
Definition
sprites.cpp:36
SpritesDB::getIndAt
SpriteDBEntry * getIndAt(const QString &key) const
Sprite by name key (for QML).
Definition
sprites.cpp:52
SpritesDB::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
sprites.cpp:78
SpritesDB::getInd
const QHash< QString, SpriteDBEntry * > getInd() const
Name->entry index.
Definition
sprites.cpp:43
SpritesDB::load
void load()
Load sprites from JSON.
Definition
sprites.cpp:57
SpritesDB::getStore
const QVector< SpriteDBEntry * > getStore() const
All sprites.
Definition
sprites.cpp:42
SpritesDB::index
void index()
Build the name->entry index.
Definition
sprites.cpp:67
SpritesDB::getStoreSize
int getStoreSize() const
Sprite count.
Definition
sprites.cpp:44
SpritesDB::getStoreAt
SpriteDBEntry * getStoreAt(int idx) const
Sprite by store index (for QML).
Definition
sprites.cpp:46
types.h
Project-wide fixed-width integer aliases (var8, var16, ...).
var8
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition
types.h:124
db_autoport.h
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
DB_AUTOPORT
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition
db_autoport.h:37
MapDBEntrySprite
A map's sprite definition – base class for the four sprite kinds.
Definition
mapdbentrysprite.h:44
SpriteDBEntry
One sprite definition: its name/picture-id and the maps that use it.
Definition
sprites.h:38
SpriteDBEntry::toMaps
QVector< MapDBEntrySprite * > toMaps
Map-sprites using this picture (back-ref).
Definition
sprites.h:45
SpriteDBEntry::ind
var8 ind
Picture id.
Definition
sprites.h:43
SpriteDBEntry::name
QString name
Sprite name (key).
Definition
sprites.h:42
SpriteDBEntry::SpriteDBEntry
SpriteDBEntry()
Empty entry.
Definition
sprites.cpp:29
projects
db
src
pse-db
sprites.h
Generated by
1.17.0