Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
tilesetengine.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 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#include <QObject>
18#include <QImage>
19#include <QPixmap>
20#include <QColor>
21#include <QString>
22#include <QCache>
23
35class TilesetEngine : public QObject
36{
37 Q_OBJECT
38
39public:
41 static QImage getTileset(QString name);
42
43 // Flower overlay
44 // Frame can be any number, a full frame cycle is 4 frames so keep it
45 // divisible by 4 for smooth animation
46 static QImage getFlower(int frame);
47
48 // Font overlay frame
49 static QImage getFont();
50
51 // <tileset>/<type>/<font>/<frame>
52 // * <tileset> is the tileset, case-insensitive and spaces converted to
53 // underscores
54 // * <type> is the type, specifically "outdoor" or not is used here
55 // * <font> is whether to load fonts and white out certain tiles,
56 // specifically "font" or not is used here
57 // * <frame> can be any positive number, a full frame cycle completes in 8
58 // frames though so it's suggested to use multiple of 8 for smooth
59 // animation
60 static QPixmap buildTilesetFullDebug(QString id); // Not cached, very slow, debug only
61 static QVector<QPixmap> buildTileset(QString id);
62
63 // Convert image to tiles
64 static QVector<QPixmap> getTiles(QImage tilemap);
65
66 // Empty transparent image
67 static QImage blankImage();
68
69 // Post process the wave effect in one increment
70 // postProcessWave calls this x number of times depending on frame index to
71 // simulate waves back and forth
72 static QImage postProcessWaveOnce(QImage tile);
73
74 // Post process the wave effect on a given tile image
75 // Frame can be any number, a full frame cycle is 8 frames so keep it
76 // divisible by 8 for smooth animation
77 static QImage postProcessWave(QImage tile, int frame);
78
79 static constexpr int width = 128;
80 static constexpr int height = 128;
81 static constexpr int tileWidth = 8;
82 static constexpr int tileHeight = 8;
83 static constexpr int tileWater = 0x14;
84
85 // flower has 4 frames, water has 8 frames
86 // A full frame count would be one where everything completes
87 static constexpr int fullFrameCount = 8;
88};
Static helpers that build Game Boy tileset graphics (tiles, flowers, waves).
static constexpr int width
Tileset image width (px).
static QImage blankImage()
A blank transparent tile-sized image.
static QImage postProcessWaveOnce(QImage tile)
One increment of the water-wave shift.
static QImage postProcessWave(QImage tile, int frame)
Apply the wave effect for frame (see note).
static constexpr int height
Tileset image height (px).
static QVector< QPixmap > buildTileset(QString id)
Build the per-tile pixmaps for id (format above).
static constexpr int tileWidth
Tile width (px).
static constexpr int tileWater
Tile id of the animated water tile.
static QPixmap buildTilesetFullDebug(QString id)
static QImage getFont()
The font overlay image.
static QImage getFlower(int frame)
The animated flower overlay for frame (see note).
static QVector< QPixmap > getTiles(QImage tilemap)
Slice a tilemap image into per-tile pixmaps.
static constexpr int tileHeight
Tile height (px).
static constexpr int fullFrameCount
Frames for a full animation cycle.
static QImage getTileset(QString name)
Load a tileset image by name (case-insensitive; spaces -> underscores).