mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
Merge branch 'master' into label-copy
This commit is contained in:
@@ -11,6 +11,7 @@ public:
|
||||
explicit NewEventToolButton(QWidget *parent = nullptr);
|
||||
QString getSelectedEventType();
|
||||
QAction *newObjectAction;
|
||||
QAction *newCloneObjectAction;
|
||||
QAction *newWarpAction;
|
||||
QAction *newHealLocationAction;
|
||||
QAction *newTriggerAction;
|
||||
@@ -20,6 +21,7 @@ public:
|
||||
QAction *newSecretBaseAction;
|
||||
public slots:
|
||||
void newObject();
|
||||
void newCloneObject();
|
||||
void newWarp();
|
||||
void newHealLocation();
|
||||
void newTrigger();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "regionmaplayoutpixmapitem.h"
|
||||
#include "regionmapentriespixmapitem.h"
|
||||
#include "regionmap.h"
|
||||
#include "orderedjson.h"
|
||||
#include "project.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
@@ -24,14 +26,9 @@ public:
|
||||
explicit RegionMapEditor(QWidget *parent = 0, Project *pro = nullptr);
|
||||
~RegionMapEditor();
|
||||
|
||||
RegionMap *region_map;
|
||||
|
||||
bool loadRegionMapData();
|
||||
bool loadCityMaps();
|
||||
void setCurrentSquareOptions();
|
||||
bool load();
|
||||
|
||||
void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
|
||||
void onCityMapTileSelectorSelectedTileChanged(unsigned id);
|
||||
void onRegionMapTileSelectorHoveredTileChanged(unsigned id);
|
||||
void onRegionMapTileSelectorHoveredTileCleared();
|
||||
|
||||
@@ -42,10 +39,7 @@ public:
|
||||
void onRegionMapEntriesSelectedTileChanged(QString) {};
|
||||
void onRegionMapEntryDragged(int, int);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void resize(int width, int height);
|
||||
void resizeTilemap(int width, int height);
|
||||
|
||||
QObjectList shortcutableObjects() const;
|
||||
|
||||
@@ -56,14 +50,19 @@ private:
|
||||
Ui::RegionMapEditor *ui;
|
||||
Project *project;
|
||||
|
||||
History<RegionMapHistoryItem*> history;
|
||||
RegionMap *region_map = nullptr;
|
||||
tsl::ordered_map<QString, RegionMap *> region_maps;
|
||||
|
||||
int currIndex;
|
||||
unsigned selectedCityTile;
|
||||
unsigned selectedImageTile;
|
||||
poryjson::Json rmConfigJson;
|
||||
|
||||
bool configSaved = false;
|
||||
|
||||
QUndoGroup history;
|
||||
|
||||
int currIndex = 0;
|
||||
unsigned selectedImageTile = 0;
|
||||
QString activeEntry;
|
||||
|
||||
bool hasUnsavedChanges = false;
|
||||
bool cityMapFirstDraw = true;
|
||||
bool regionMapFirstDraw = true;
|
||||
bool entriesFirstDraw = true;
|
||||
@@ -72,19 +71,32 @@ private:
|
||||
double initialScale = 30.0;
|
||||
|
||||
QGraphicsScene *scene_region_map_image = nullptr;
|
||||
QGraphicsScene *scene_city_map_image = nullptr;
|
||||
QGraphicsScene *scene_region_map_layout = nullptr;
|
||||
QGraphicsScene *scene_region_map_entries = nullptr;
|
||||
QGraphicsScene *scene_region_map_tiles = nullptr;
|
||||
QGraphicsScene *scene_city_map_tiles = nullptr;
|
||||
|
||||
TilemapTileSelector *mapsquare_selector_item = nullptr;
|
||||
TilemapTileSelector *city_map_selector_item = nullptr;
|
||||
|
||||
RegionMapEntriesPixmapItem *region_map_entries_item = nullptr;
|
||||
RegionMapLayoutPixmapItem *region_map_layout_item = nullptr;
|
||||
RegionMapPixmapItem *region_map_item = nullptr;
|
||||
CityMapPixmapItem *city_map_item = nullptr;
|
||||
|
||||
bool reload();
|
||||
bool setup();
|
||||
void clear();
|
||||
|
||||
bool saveRegionMap(RegionMap *map);
|
||||
void saveConfig();
|
||||
bool loadRegionMapEntries();
|
||||
bool saveRegionMapEntries();
|
||||
tsl::ordered_map<QString, MapSectionEntry> region_map_entries;
|
||||
|
||||
bool buildConfigDialog();
|
||||
poryjson::Json configRegionMapDialog();
|
||||
poryjson::Json buildDefaultJson();
|
||||
bool verifyConfig(poryjson::Json cfg);
|
||||
|
||||
bool modified();
|
||||
|
||||
void initShortcuts();
|
||||
void displayRegionMap();
|
||||
@@ -94,47 +106,46 @@ private:
|
||||
void displayRegionMapLayoutOptions();
|
||||
void updateRegionMapLayoutOptions(int index);
|
||||
void displayRegionMapTileSelector();
|
||||
void displayCityMapTileSelector();
|
||||
void displayCityMap(QString name);
|
||||
void updateLayerDisplayed();
|
||||
void displayRegionMapEntryOptions();
|
||||
void updateRegionMapEntryOptions(QString);
|
||||
void importTileImage(bool city = false);
|
||||
|
||||
bool createCityMap(QString name);
|
||||
bool tryInsertNewMapEntry(QString);
|
||||
void setRegionMap(RegionMap *map);
|
||||
|
||||
void restoreWindowState();
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
private slots:
|
||||
void on_action_RegionMap_Save_triggered();
|
||||
void on_action_RegionMap_Undo_triggered();
|
||||
void on_action_RegionMap_Redo_triggered();
|
||||
void on_actionSave_All_triggered();
|
||||
void on_action_RegionMap_Resize_triggered();
|
||||
void on_action_RegionMap_ClearImage_triggered();
|
||||
void on_action_RegionMap_ClearLayout_triggered();
|
||||
void on_action_RegionMap_ClearEntries_triggered();
|
||||
void on_action_Swap_triggered();
|
||||
void on_action_Import_RegionMap_ImageTiles_triggered();
|
||||
void on_action_Import_CityMap_ImageTiles_triggered();
|
||||
void on_action_Replace_triggered();
|
||||
void on_action_Configure_triggered();
|
||||
void on_tabWidget_Region_Map_currentChanged(int);
|
||||
void on_pushButton_RM_Options_delete_clicked();
|
||||
void on_comboBox_RM_ConnectedMap_textActivated(const QString &);
|
||||
void on_comboBox_RM_Entry_MapSection_textActivated(const QString &);
|
||||
void on_comboBox_regionSelector_textActivated(const QString &);
|
||||
void on_comboBox_layoutLayer_textActivated(const QString &);
|
||||
void on_spinBox_RM_Entry_x_valueChanged(int);
|
||||
void on_spinBox_RM_Entry_y_valueChanged(int);
|
||||
void on_spinBox_RM_Entry_width_valueChanged(int);
|
||||
void on_spinBox_RM_Entry_height_valueChanged(int);
|
||||
void on_pushButton_CityMap_add_clicked();
|
||||
void on_pushButton_entryActivate_clicked();
|
||||
void on_spinBox_RM_LayoutWidth_valueChanged(int);
|
||||
void on_spinBox_RM_LayoutHeight_valueChanged(int);
|
||||
void on_spinBox_tilePalette_valueChanged(int);
|
||||
void on_checkBox_tileHFlip_stateChanged(int);
|
||||
void on_checkBox_tileVFlip_stateChanged(int);
|
||||
void on_verticalSlider_Zoom_Map_Image_valueChanged(int);
|
||||
void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int);
|
||||
void on_verticalSlider_Zoom_City_Map_valueChanged(int);
|
||||
void on_verticalSlider_Zoom_City_Tiles_valueChanged(int);
|
||||
void on_comboBox_CityMap_picker_currentTextChanged(const QString &);
|
||||
void on_lineEdit_RM_MapName_textEdited(const QString &);
|
||||
void onHoveredRegionMapTileChanged(int x, int y);
|
||||
void onHoveredRegionMapTileCleared();
|
||||
void mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item);
|
||||
void mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityMapPixmapItem *item);
|
||||
};
|
||||
|
||||
#endif // REGIONMAPEDITOR_H
|
||||
|
||||
@@ -17,12 +17,14 @@ public:
|
||||
this->tile_selector = tile_selector;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
RegionMap *region_map;
|
||||
RegionMap *region_map = nullptr;
|
||||
TilemapTileSelector *tile_selector;
|
||||
|
||||
virtual void paint(QGraphicsSceneMouseEvent *);
|
||||
virtual void fill(QGraphicsSceneMouseEvent *);
|
||||
virtual void select(QGraphicsSceneMouseEvent *);
|
||||
virtual void draw();
|
||||
void floodFill(int x, int y, std::shared_ptr<TilemapTile> oldTile, std::shared_ptr<TilemapTile> newTile);
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, RegionMapPixmapItem *);
|
||||
|
||||
47
include/ui/regionmappropertiesdialog.h
Normal file
47
include/ui/regionmappropertiesdialog.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef REGIONMAPPROPERTIESDIALOG_H
|
||||
#define REGIONMAPPROPERTIESDIALOG_H
|
||||
|
||||
#include "orderedjson.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFileDialog>
|
||||
|
||||
class Project;
|
||||
|
||||
namespace Ui {
|
||||
class RegionMapPropertiesDialog;
|
||||
}
|
||||
|
||||
class RegionMapPropertiesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RegionMapPropertiesDialog(QWidget *parent = nullptr);
|
||||
~RegionMapPropertiesDialog();
|
||||
|
||||
void setProject(Project *project) { this->project = project; }
|
||||
|
||||
void setProperties(poryjson::Json object);
|
||||
poryjson::Json saveToJson();
|
||||
|
||||
virtual void accept() override;
|
||||
|
||||
private:
|
||||
Ui::RegionMapPropertiesDialog *ui;
|
||||
Project *project = nullptr;
|
||||
|
||||
void hideMessages();
|
||||
|
||||
QString browse(QString filter, QFileDialog::FileMode mode);
|
||||
|
||||
private slots:
|
||||
void on_browse_tilesetImagePath_clicked();
|
||||
void on_browse_tilemapBinPath_clicked();
|
||||
void on_browse_tilemapPalettePath_clicked();
|
||||
void on_browse_layoutPath_clicked();
|
||||
|
||||
//void on_buttonBox_accepted();
|
||||
};
|
||||
|
||||
#endif // REGIONMAPPROPERTIESDIALOG_H
|
||||
@@ -1,29 +1,165 @@
|
||||
#pragma once
|
||||
#ifndef TILEMAPTILESELECTOR_H
|
||||
#define TILEMAPTILESELECTOR_H
|
||||
|
||||
#include "selectablepixmapitem.h"
|
||||
#include "paletteutil.h"
|
||||
|
||||
#include <memory>
|
||||
using std::shared_ptr;
|
||||
|
||||
enum class TilemapFormat { Plain, BPP_4, BPP_8 };
|
||||
|
||||
class TilemapTile {
|
||||
unsigned raw_ = 0;
|
||||
unsigned id_ = 0;
|
||||
bool hFlip_ = false;
|
||||
bool vFlip_ = false;
|
||||
int palette_ = 0;
|
||||
|
||||
protected:
|
||||
TilemapTile(unsigned raw, unsigned id, bool hFlip, bool vFlip, int palette) : raw_(raw), id_(id), hFlip_(hFlip), vFlip_(vFlip), palette_(palette) {}
|
||||
virtual ~TilemapTile() {}
|
||||
|
||||
public:
|
||||
TilemapTile()=default;
|
||||
|
||||
TilemapTile(TilemapTile &other) {
|
||||
this->raw_ = other.raw();
|
||||
this->id_ = other.id();
|
||||
this->hFlip_ = other.hFlip();
|
||||
this->vFlip_ = other.vFlip();
|
||||
this->palette_ = other.palette();
|
||||
}
|
||||
|
||||
TilemapTile &operator=(const TilemapTile &other) {
|
||||
this->raw_ = other.raw();
|
||||
this->id_ = other.id();
|
||||
this->hFlip_ = other.hFlip();
|
||||
this->vFlip_ = other.vFlip();
|
||||
this->palette_ = other.palette();
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual void copy(TilemapTile &other) {
|
||||
this->raw_ = other.raw();
|
||||
this->id_ = other.id();
|
||||
this->hFlip_ = other.hFlip();
|
||||
this->vFlip_ = other.vFlip();
|
||||
this->palette_ = other.palette();
|
||||
}
|
||||
|
||||
virtual unsigned raw() const { return this->raw_; }
|
||||
virtual unsigned id() const { return this->id_; }
|
||||
virtual bool hFlip() const { return this->hFlip_; }
|
||||
virtual bool vFlip() const { return this->vFlip_; }
|
||||
virtual int palette() const { return this->palette_; }
|
||||
|
||||
virtual void setId(unsigned id) { this->id_ = id; }
|
||||
virtual void setHFlip(bool hFlip) { this->hFlip_ = hFlip; }
|
||||
virtual void setVFlip(bool vFlip) { this->vFlip_ = vFlip; }
|
||||
virtual void setPalette(int palette) { this->palette_ = palette; }
|
||||
|
||||
bool operator==(const TilemapTile& other) {
|
||||
return (this->raw() == other.raw());
|
||||
}
|
||||
|
||||
virtual QString info() const {
|
||||
return QString("Tile: 0x") + QString("%1 ").arg(this->id(), 4, 16, QChar('0')).toUpper();
|
||||
}
|
||||
};
|
||||
|
||||
class PlainTile : public TilemapTile {
|
||||
public:
|
||||
PlainTile(unsigned raw) : TilemapTile(raw, raw, false, false, 0) {}
|
||||
|
||||
~PlainTile() {}
|
||||
|
||||
virtual unsigned raw () const override { return id(); }
|
||||
};
|
||||
|
||||
class BPP4Tile : public TilemapTile {
|
||||
public:
|
||||
BPP4Tile(unsigned raw) : TilemapTile(
|
||||
raw,
|
||||
raw & 0x3ff, // tileId
|
||||
!!(raw & 0x0400), // hFlip
|
||||
!!(raw & 0x0800), // vFlip
|
||||
(raw & 0xf000) >> 12 // palette
|
||||
) {}
|
||||
|
||||
~BPP4Tile() {}
|
||||
|
||||
virtual unsigned raw () const override {
|
||||
return (id()) | (hFlip() << 10) | (vFlip() << 11) | (palette() << 12);
|
||||
}
|
||||
|
||||
virtual QString info() const override {
|
||||
return TilemapTile::info() + QString("hFlip: %1 vFlip: %2 palette: %3").arg(this->hFlip()).arg(this->vFlip()).arg(this->palette());
|
||||
}
|
||||
};
|
||||
|
||||
class BPP8Tile : public TilemapTile {
|
||||
public:
|
||||
BPP8Tile(unsigned raw) : TilemapTile(
|
||||
raw,
|
||||
raw & 0x3ff, // tileId
|
||||
!!(raw & 0x0400), // hFlip
|
||||
!!(raw & 0x0800), // vFlip
|
||||
0 // palette
|
||||
) {}
|
||||
|
||||
~BPP8Tile() {}
|
||||
|
||||
virtual unsigned raw () const override {
|
||||
return (id()) | (hFlip() << 10) | (vFlip() << 11);
|
||||
}
|
||||
|
||||
virtual QString info() const override {
|
||||
return TilemapTile::info() + QString("hFlip: %1 vFlip: %2").arg(this->hFlip()).arg(this->vFlip());
|
||||
}
|
||||
};
|
||||
|
||||
class TilemapTileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilemapTileSelector(QPixmap pixmap_): SelectablePixmapItem(8, 8, 1, 1) {
|
||||
this->tilemap = pixmap_;
|
||||
this->setPixmap(this->tilemap);
|
||||
this->numTilesWide = tilemap.width() / 8;
|
||||
TilemapTileSelector(QString tilesetFilepath, TilemapFormat format, QString palFilepath): SelectablePixmapItem(8, 8, 1, 1) {
|
||||
this->tileset = QImage(tilesetFilepath);
|
||||
this->format = format;
|
||||
bool err;
|
||||
if (!palFilepath.isEmpty()) {
|
||||
this->palette = PaletteUtil::parse(palFilepath, &err);
|
||||
}
|
||||
this->setPixmap(QPixmap::fromImage(this->tileset));
|
||||
this->numTilesWide = this->tileset.width() / 8;
|
||||
this->selectedTile = 0x00;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
void draw();
|
||||
void select(unsigned tileId);
|
||||
unsigned getSelectedTile();
|
||||
QImage setPalette(int index);
|
||||
|
||||
int pixelWidth;
|
||||
int pixelHeight;
|
||||
|
||||
void select(unsigned tileId);
|
||||
unsigned selectedTile = 0;
|
||||
|
||||
QPixmap tilemap;
|
||||
QImage tileImg(unsigned tileId);
|
||||
void selectVFlip(bool hFlip) { this->tile_hFlip = hFlip; }
|
||||
bool tile_hFlip = false;
|
||||
|
||||
void selectHFlip(bool vFlip) { this->tile_vFlip = vFlip; }
|
||||
bool tile_vFlip = false;
|
||||
|
||||
void selectPalette(int palette) {
|
||||
this->tile_palette = palette;
|
||||
this->draw();
|
||||
}
|
||||
int tile_palette = 0;
|
||||
|
||||
QImage tileset;
|
||||
TilemapFormat format = TilemapFormat::Plain;
|
||||
QList<QRgb> palette;
|
||||
QImage tileImg(shared_ptr<TilemapTile> tile);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
void updateMap(Map *map);
|
||||
void updateTilesets(QString primaryTilsetLabel, QString secondaryTilesetLabel);
|
||||
bool selectMetatile(uint16_t metatileId);
|
||||
uint16_t getSelectedMetatile();
|
||||
uint16_t getSelectedMetatileId();
|
||||
void setMetatileLabel(QString label);
|
||||
|
||||
QObjectList shortcutableObjects() const;
|
||||
@@ -105,6 +105,10 @@ private slots:
|
||||
|
||||
void on_copyButton_metatileLabel_clicked();
|
||||
|
||||
void on_actionCopy_triggered();
|
||||
|
||||
void on_actionPaste_triggered();
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
void setMetatileBehaviors();
|
||||
@@ -129,6 +133,7 @@ private:
|
||||
void closeEvent(QCloseEvent*);
|
||||
void countMetatileUsage();
|
||||
void countTileUsage();
|
||||
bool replaceMetatile(uint16_t metatileId, Metatile * src);
|
||||
|
||||
Ui::TilesetEditor *ui;
|
||||
History<MetatileHistoryItem*> metatileHistory;
|
||||
@@ -139,6 +144,7 @@ private:
|
||||
Project *project = nullptr;
|
||||
Map *map = nullptr;
|
||||
Metatile *metatile = nullptr;
|
||||
Metatile *copiedMetatile = nullptr;
|
||||
int paletteId;
|
||||
bool tileXFlip;
|
||||
bool tileYFlip;
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
void draw();
|
||||
bool select(uint16_t metatileId);
|
||||
void setTilesets(Tileset*, Tileset*, bool draw = true);
|
||||
uint16_t getSelectedMetatile();
|
||||
uint16_t getSelectedMetatileId();
|
||||
void updateSelectedMetatile();
|
||||
QPoint getMetatileIdCoordsOnWidget(uint16_t metatileId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user