mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-28 11:36:26 -05:00
Add new metatile image export window
This commit is contained in:
@@ -12,8 +12,10 @@ QImage getCollisionMetatileImage(Block);
|
||||
QImage getCollisionMetatileImage(int, int);
|
||||
QImage getMetatileImage(uint16_t, Layout*, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(Metatile*, Layout*, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(uint16_t, Tileset*, Tileset*, const QList<int>&, const QList<float>&, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(Metatile*, Tileset*, Tileset*, const QList<int>&, const QList<float>&, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(uint16_t, Tileset*, Tileset*, const QList<int>&, const QList<float>& = {}, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(Metatile*, Tileset*, Tileset*, const QList<int>&, const QList<float>& = {}, bool useTruePalettes = false);
|
||||
QImage getMetatileSheetImage(Layout *, int, bool useTruePalettes = false);
|
||||
QImage getMetatileSheetImage(Tileset *, Tileset *, uint16_t, int, int, const QList<int> &, const QList<float> & = {}, const QSize &size = Metatile::pixelSize(), bool useTruePalettes = false);
|
||||
QImage getTileImage(uint16_t, Tileset*, Tileset*);
|
||||
QImage getPalettedTileImage(uint16_t, Tileset*, Tileset*, int, bool useTruePalettes = false);
|
||||
QImage getGreyscaleTileImage(uint16_t tile, Tileset *primaryTileset, Tileset *secondaryTileset);
|
||||
|
||||
101
include/ui/metatileimageexporter.h
Normal file
101
include/ui/metatileimageexporter.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef METATILEIMAGEEXPORTER_H
|
||||
#define METATILEIMAGEEXPORTER_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QGraphicsScene>
|
||||
#include <QShowEvent>
|
||||
#include <QCloseEvent>
|
||||
#include <QListWidget>
|
||||
#include <QDropEvent>
|
||||
#include <QRadioButton>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
class Tileset;
|
||||
|
||||
namespace Ui {
|
||||
class MetatileImageExporter;
|
||||
}
|
||||
|
||||
class ReorderableListWidget : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ReorderableListWidget(QWidget *parent = nullptr) : QListWidget(parent) {
|
||||
setDragEnabled(true);
|
||||
setDragDropMode(QAbstractItemView::InternalMove);
|
||||
setDefaultDropAction(Qt::MoveAction);
|
||||
};
|
||||
|
||||
signals:
|
||||
void reordered();
|
||||
|
||||
protected:
|
||||
virtual void dropEvent(QDropEvent *event) override {
|
||||
QListWidget::dropEvent(event);
|
||||
if (event->isAccepted()) {
|
||||
emit reordered();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class MetatileImageExporter : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct Settings {
|
||||
OrderedMap<int,bool> layerOrder = {
|
||||
{2, true},
|
||||
{1, true},
|
||||
{0, true},
|
||||
};
|
||||
uint16_t metatileStart = 0;
|
||||
uint16_t metatileEnd = 0xFFFF;
|
||||
uint16_t numMetatilesWide = 8;
|
||||
bool usePrimaryTileset = true;
|
||||
bool useSecondaryTileset = false;
|
||||
bool renderPlaceholders = false;
|
||||
int transparencyMode = 0;
|
||||
};
|
||||
|
||||
explicit MetatileImageExporter(QWidget *parent, Tileset *primaryTileset, Tileset *secondaryTileset, Settings *savedSettings = nullptr);
|
||||
~MetatileImageExporter();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *) override;
|
||||
virtual void closeEvent(QCloseEvent *) override;
|
||||
|
||||
private:
|
||||
Ui::MetatileImageExporter *ui;
|
||||
|
||||
Tileset *m_primaryTileset;
|
||||
Tileset *m_secondaryTileset;
|
||||
Settings *m_savedSettings;
|
||||
|
||||
QGraphicsScene *m_scene = nullptr;
|
||||
QGraphicsPixmapItem *m_preview = nullptr;
|
||||
bool m_previewUpdateQueued = false;
|
||||
QList<int> m_layerOrder;
|
||||
ProjectConfig m_savedConfig;
|
||||
QList<QRadioButton*> m_transparencyButtons;
|
||||
|
||||
void applySettings(const Settings &settings);
|
||||
void updatePreview();
|
||||
void tryUpdatePreview();
|
||||
void queuePreviewUpdate();
|
||||
void updateTilesetUI();
|
||||
void syncPixelWidth();
|
||||
void syncMetatileWidth();
|
||||
void validateMetatileStart();
|
||||
void validateMetatileEnd();
|
||||
uint16_t getExpectedMetatileStart();
|
||||
uint16_t getExpectedMetatileEnd();
|
||||
void updateMetatileRange();
|
||||
void copyRenderSettings();
|
||||
void restoreRenderSettings();
|
||||
void saveImage();
|
||||
void reset();
|
||||
};
|
||||
|
||||
#endif // METATILEIMAGEEXPORTER_H
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "tileseteditormetatileselector.h"
|
||||
#include "tileseteditortileselector.h"
|
||||
#include "metatilelayersitem.h"
|
||||
#include "metatileimageexporter.h"
|
||||
|
||||
class NoScrollComboBox;
|
||||
class Layout;
|
||||
@@ -71,10 +72,6 @@ private slots:
|
||||
|
||||
void on_spinBox_paletteSelector_valueChanged(int arg1);
|
||||
|
||||
void on_actionImport_Primary_Tiles_triggered();
|
||||
|
||||
void on_actionImport_Secondary_Tiles_triggered();
|
||||
|
||||
void on_actionChange_Metatiles_Count_triggered();
|
||||
|
||||
void on_actionChange_Palettes_triggered();
|
||||
@@ -91,14 +88,6 @@ private slots:
|
||||
|
||||
void on_lineEdit_metatileLabel_editingFinished();
|
||||
|
||||
void on_actionExport_Primary_Tiles_Image_triggered();
|
||||
void on_actionExport_Secondary_Tiles_Image_triggered();
|
||||
void on_actionExport_Primary_Metatiles_Image_triggered();
|
||||
void on_actionExport_Secondary_Metatiles_Image_triggered();
|
||||
|
||||
void on_actionImport_Primary_Metatiles_triggered();
|
||||
void on_actionImport_Secondary_Metatiles_triggered();
|
||||
|
||||
void on_copyButton_metatileLabel_clicked();
|
||||
|
||||
void on_actionCut_triggered();
|
||||
@@ -122,8 +111,10 @@ private:
|
||||
void drawSelectedTiles();
|
||||
void redrawTileSelector();
|
||||
void redrawMetatileSelector();
|
||||
void importTilesetTiles(Tileset*, bool);
|
||||
void importTilesetMetatiles(Tileset*, bool);
|
||||
void importTilesetTiles(Tileset*);
|
||||
void importAdvanceMapMetatiles(Tileset*);
|
||||
void exportTilesImage(Tileset*);
|
||||
void exportMetatilesImage();
|
||||
void refresh();
|
||||
void commitMetatileLabel();
|
||||
void closeEvent(QCloseEvent*);
|
||||
@@ -170,6 +161,7 @@ private:
|
||||
QGraphicsScene *metatileLayersScene = nullptr;
|
||||
bool lockSelection = false;
|
||||
QSet<uint16_t> metatileReloadQueue;
|
||||
MetatileImageExporter::Settings *metatileImageExportSettings = nullptr;
|
||||
|
||||
bool save();
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ public:
|
||||
uint16_t getSelectedMetatileId();
|
||||
void updateSelectedMetatile();
|
||||
QPoint getMetatileIdCoordsOnWidget(uint16_t metatileId);
|
||||
QImage buildPrimaryMetatilesImage();
|
||||
QImage buildSecondaryMetatilesImage();
|
||||
|
||||
QVector<uint16_t> usedMetatiles;
|
||||
bool selectorShowUnused = false;
|
||||
@@ -56,8 +54,6 @@ private:
|
||||
void drawFilters();
|
||||
void drawUnused();
|
||||
void drawCounts();
|
||||
QImage buildAllMetatilesImage();
|
||||
QImage buildImage(int metatileIdStart, int numMetatiles);
|
||||
int numPrimaryMetatilesRounded() const;
|
||||
|
||||
signals:
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
uint32_t value() const { return m_value; }
|
||||
uint32_t minimum() const { return m_minimum; }
|
||||
uint32_t maximum() const { return m_maximum; }
|
||||
uint32_t singleStep() const { return m_singleStep; }
|
||||
QString prefix() const { return m_prefix; }
|
||||
int displayIntegerBase() const { return m_displayIntegerBase; }
|
||||
bool hasPadding() const { return m_hasPadding; }
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
void setMinimum(uint32_t min);
|
||||
void setMaximum(uint32_t max);
|
||||
void setRange(uint32_t min, uint32_t max);
|
||||
void setSingleStep(uint32_t val);
|
||||
void setPrefix(const QString &prefix);
|
||||
void setDisplayIntegerBase(int base);
|
||||
void setHasPadding(bool enabled);
|
||||
@@ -36,6 +38,7 @@ private:
|
||||
uint32_t m_minimum;
|
||||
uint32_t m_maximum;
|
||||
uint32_t m_value;
|
||||
uint32_t m_singleStep;
|
||||
QString m_prefix;
|
||||
int m_displayIntegerBase;
|
||||
bool m_hasPadding;
|
||||
|
||||
Reference in New Issue
Block a user