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