porymap/include/ui/tileseteditor.h

173 lines
5.3 KiB
C
Raw Normal View History

2018-09-29 20:13:07 +01:00
#ifndef TILESETEDITOR_H
#define TILESETEDITOR_H
#include <QMainWindow>
#include "project.h"
#include "history.h"
2018-10-03 01:01:41 +01:00
#include "paletteeditor.h"
#include "tileseteditormetatileselector.h"
#include "tileseteditortileselector.h"
2018-09-30 22:15:04 +01:00
#include "metatilelayersitem.h"
#include "map.h"
2018-09-29 20:13:07 +01:00
namespace Ui {
class TilesetEditor;
}
class MetatileHistoryItem {
public:
MetatileHistoryItem(uint16_t metatileId, Metatile *prevMetatile, Metatile *newMetatile, QString prevLabel, QString newLabel) {
this->metatileId = metatileId;
this->prevMetatile = prevMetatile;
this->newMetatile = newMetatile;
this->prevLabel = prevLabel;
this->newLabel = newLabel;
}
~MetatileHistoryItem() {
delete this->prevMetatile;
delete this->newMetatile;
}
uint16_t metatileId;
Metatile *prevMetatile;
Metatile *newMetatile;
QString prevLabel;
QString newLabel;
};
2018-09-29 20:13:07 +01:00
class TilesetEditor : public QMainWindow
{
Q_OBJECT
public:
explicit TilesetEditor(Project*, Map*, QWidget *parent = nullptr);
2018-09-29 20:13:07 +01:00
~TilesetEditor();
void update(Map *map, QString primaryTilsetLabel, QString secondaryTilesetLabel);
void updateMap(Map *map);
void updateTilesets(QString primaryTilsetLabel, QString secondaryTilesetLabel);
bool selectMetatile(uint16_t metatileId);
2022-03-30 23:03:13 +01:00
uint16_t getSelectedMetatileId();
2021-11-23 17:58:04 +00:00
void setMetatileLabel(QString label);
2018-09-29 20:13:07 +01:00
QObjectList shortcutableObjects() const;
public slots:
void applyUserShortcuts();
private slots:
void onHoveredMetatileChanged(uint16_t);
void onHoveredMetatileCleared();
void onSelectedMetatileChanged(uint16_t);
void onHoveredTileChanged(uint16_t);
void onHoveredTileCleared();
void onSelectedTilesChanged();
void onMetatileLayerTileChanged(int, int);
void onMetatileLayerSelectionChanged(QPoint, int, int);
2018-10-03 01:01:41 +01:00
void onPaletteEditorChangedPaletteColor();
void onPaletteEditorChangedPalette(int);
void on_spinBox_paletteSelector_valueChanged(int arg1);
void on_checkBox_xFlip_stateChanged(int arg1);
void on_checkBox_yFlip_stateChanged(int arg1);
void on_actionSave_Tileset_triggered();
2018-10-03 01:01:24 +01:00
void on_actionImport_Primary_Tiles_triggered();
void on_actionImport_Secondary_Tiles_triggered();
void on_actionChange_Metatiles_Count_triggered();
2018-10-03 01:01:41 +01:00
void on_actionChange_Palettes_triggered();
void on_actionShow_Unused_toggled(bool checked);
void on_actionShow_Counts_toggled(bool checked);
2021-07-21 23:55:33 +01:00
void on_actionShow_UnusedTiles_toggled(bool checked);
void on_actionUndo_triggered();
void on_actionRedo_triggered();
void on_comboBox_metatileBehaviors_currentTextChanged(const QString &arg1);
void on_lineEdit_metatileLabel_editingFinished();
void on_comboBox_layerType_activated(int arg1);
void on_comboBox_encounterType_activated(int arg1);
void on_comboBox_terrainType_activated(int arg1);
void on_actionExport_Primary_Tiles_Image_triggered();
void on_actionExport_Secondary_Tiles_Image_triggered();
2022-10-05 13:54:04 +01:00
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();
2022-02-10 14:53:04 +00:00
void on_copyButton_metatileLabel_clicked();
2022-10-04 02:03:43 +01:00
void on_actionCut_triggered();
2022-03-30 23:03:13 +01:00
void on_actionCopy_triggered();
void on_actionPaste_triggered();
2018-09-29 20:13:07 +01:00
private:
2020-09-25 13:20:51 +01:00
void initUi();
void setAttributesUi();
2020-09-25 13:20:51 +01:00
void setMetatileLabelValidator();
void initMetatileSelector();
void initTileSelector();
void initSelectedTileItem();
2018-09-30 22:15:04 +01:00
void initMetatileLayersItem();
void initShortcuts();
void initExtraShortcuts();
void restoreWindowState();
2020-09-25 13:20:51 +01:00
void initMetatileHistory();
void setTilesets(QString primaryTilesetLabel, QString secondaryTilesetLabel);
void reset();
void drawSelectedTiles();
2018-10-03 01:01:24 +01:00
void importTilesetTiles(Tileset*, bool);
void importTilesetMetatiles(Tileset*, bool);
2018-10-03 01:01:24 +01:00
void refresh();
2023-02-14 19:10:05 +00:00
void commitMetatileLabel();
2020-09-25 13:20:51 +01:00
void closeEvent(QCloseEvent*);
void countMetatileUsage();
2021-07-21 23:55:33 +01:00
void countTileUsage();
2022-10-04 02:03:43 +01:00
void copyMetatile(bool cut);
void pasteMetatile(const Metatile * toPaste, QString label);
bool replaceMetatile(uint16_t metatileId, const Metatile * src, QString label);
void commitMetatileChange(Metatile * prevMetatile);
void commitMetatileAndLabelChange(Metatile * prevMetatile, QString prevLabel);
2018-09-29 20:13:07 +01:00
Ui::TilesetEditor *ui;
History<MetatileHistoryItem*> metatileHistory;
2018-09-30 22:15:04 +01:00
TilesetEditorMetatileSelector *metatileSelector = nullptr;
TilesetEditorTileSelector *tileSelector = nullptr;
MetatileLayersItem *metatileLayersItem = nullptr;
2018-10-03 01:01:41 +01:00
PaletteEditor *paletteEditor = nullptr;
Project *project = nullptr;
Map *map = nullptr;
Metatile *metatile = nullptr;
2022-03-30 23:03:13 +01:00
Metatile *copiedMetatile = nullptr;
2023-02-14 19:10:05 +00:00
QString copiedMetatileLabel;
int paletteId;
bool tileXFlip;
bool tileYFlip;
bool hasUnsavedChanges;
Tileset *primaryTileset = nullptr;
Tileset *secondaryTileset = nullptr;
QGraphicsScene *metatilesScene = nullptr;
QGraphicsScene *tilesScene = nullptr;
QGraphicsScene *selectedTileScene = nullptr;
QGraphicsPixmapItem *selectedTilePixmapItem = nullptr;
2018-09-30 22:15:04 +01:00
QGraphicsScene *metatileLayersScene = nullptr;
bool lockSelection = false;
2018-10-03 01:01:15 +01:00
signals:
void tilesetsSaved(QString, QString);
2018-09-29 20:13:07 +01:00
};
#endif // TILESETEDITOR_H