Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
tileset.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
MapDBEntry
;
28
class
QQmlEngine;
29
31
enum class
TilesetType
{
INDOOR
= 0,
CAVE
,
OUTDOOR
};
32
33
constexpr
var8
talkCount
= 3;
34
45
struct
DB_AUTOPORT
TilesetDBEntry
{
46
TilesetDBEntry
();
47
TilesetDBEntry
(QJsonValue& data);
48
49
QString
name
;
50
QString
type
;
51
QString
nameAlias
;
52
QString
typeAlias
;
53
54
TilesetType
typeAsEnum
()
const
;
55
56
var8
ind
= 0;
57
var8
talk
[3] = {0, 0, 0};
58
var8
grass
= 0;
59
var8
bank
= 0;
60
var16
blockPtr
= 0;
61
var16
gfxPtr
= 0;
62
var16
collPtr
= 0;
63
64
QVector<MapDBEntry*>
toMaps
;
65
};
66
74
class
DB_AUTOPORT
TilesetDB :
public
QObject
75
{
76
Q_OBJECT
77
Q_PROPERTY(
int
getStoreSize
READ
getStoreSize
CONSTANT)
78
79
public
:
80
static
TilesetDB*
inst
();
81
82
[[nodiscard]]
const
QVector<TilesetDBEntry*>
getStore
()
const
;
83
[[nodiscard]]
const
QHash<QString, TilesetDBEntry*>
getInd
()
const
;
84
[[nodiscard]]
int
getStoreSize
()
const
;
85
86
Q_INVOKABLE
TilesetDBEntry
*
getStoreAt
(
int
idx)
const
;
87
Q_INVOKABLE
TilesetDBEntry
*
getIndAt
(
const
QString& key)
const
;
88
89
public
slots:
90
void
load
();
91
void
index
();
92
void
qmlProtect
(
const
QQmlEngine*
const
engine)
const
;
93
94
private
slots:
95
void
qmlRegister()
const
;
96
97
private
:
98
TilesetDB();
99
100
QVector<TilesetDBEntry*> store;
101
QHash<QString, TilesetDBEntry*> ind;
102
};
TilesetDB::getStoreAt
TilesetDBEntry * getStoreAt(int idx) const
Tileset by store index (for QML).
Definition
tileset.cpp:66
TilesetDB::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
tileset.cpp:98
TilesetDB::getInd
const QHash< QString, TilesetDBEntry * > getInd() const
Name->entry index.
Definition
tileset.cpp:63
TilesetDB::getStore
const QVector< TilesetDBEntry * > getStore() const
All tilesets.
Definition
tileset.cpp:62
TilesetDB::load
void load()
Load tilesets from JSON.
Definition
tileset.cpp:77
TilesetDB::getIndAt
TilesetDBEntry * getIndAt(const QString &key) const
Tileset by name key (for QML).
Definition
tileset.cpp:72
TilesetDB::inst
static TilesetDB * inst()
< Number of tilesets.
Definition
tileset.cpp:56
TilesetDB::getStoreSize
int getStoreSize() const
Tileset count.
Definition
tileset.cpp:64
TilesetDB::index
void index()
Build the name->entry index.
Definition
tileset.cpp:87
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
var16
var16e var16
Everyday 16-bit alias. Exact width to avoid the "fastest" widening bug.
Definition
types.h:125
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
MapDBEntry
One map's complete static definition – the root of the MapDBEntry family.
Definition
mapdbentry.h:56
TilesetDBEntry
One tileset definition: its type, graphics/block/collision pointers, etc.
Definition
tileset.h:45
TilesetDBEntry::collPtr
var16 collPtr
Collision pointer.
Definition
tileset.h:62
TilesetDBEntry::nameAlias
QString nameAlias
Friendly name.
Definition
tileset.h:51
TilesetDBEntry::typeAlias
QString typeAlias
Friendly type label.
Definition
tileset.h:52
TilesetDBEntry::typeAsEnum
TilesetType typeAsEnum() const
type parsed to the TilesetType enum.
Definition
tileset.cpp:49
TilesetDBEntry::type
QString type
Behaviour type as a string.
Definition
tileset.h:50
TilesetDBEntry::toMaps
QVector< MapDBEntry * > toMaps
Maps using this tileset (back-ref).
Definition
tileset.h:64
TilesetDBEntry::talk
var8 talk[3]
Talk-over tile ids.
Definition
tileset.h:57
TilesetDBEntry::TilesetDBEntry
TilesetDBEntry()
Empty entry.
Definition
tileset.cpp:29
TilesetDBEntry::blockPtr
var16 blockPtr
Blocks pointer.
Definition
tileset.h:60
TilesetDBEntry::bank
var8 bank
Bank holding GFX + blocks.
Definition
tileset.h:59
TilesetDBEntry::grass
var8 grass
Grass tile id.
Definition
tileset.h:58
TilesetDBEntry::ind
var8 ind
Tileset index.
Definition
tileset.h:56
TilesetDBEntry::gfxPtr
var16 gfxPtr
Graphics pointer.
Definition
tileset.h:61
TilesetDBEntry::name
QString name
Internal tileset name (key).
Definition
tileset.h:49
talkCount
constexpr var8 talkCount
Number of "talk-over" tile slots per tileset.
Definition
tileset.h:33
TilesetType
TilesetType
The three tileset behaviour categories.
Definition
tileset.h:31
TilesetType::INDOOR
@ INDOOR
Definition
tileset.h:31
TilesetType::CAVE
@ CAVE
Definition
tileset.h:31
TilesetType::OUTDOOR
@ OUTDOOR
Definition
tileset.h:31
projects
db
src
pse-db
tileset.h
Generated by
1.17.0