mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
add/remove map section entry in region map editor
This commit is contained in:
@@ -56,6 +56,7 @@ public:
|
||||
void setEntries(tsl::ordered_map<QString, MapSectionEntry> *entries) { this->region_map_entries = entries; }
|
||||
MapSectionEntry getEntry(QString section);
|
||||
void setEntry(QString section, MapSectionEntry entry);
|
||||
void removeEntry(QString section);
|
||||
|
||||
void save();
|
||||
void saveTilemap();
|
||||
|
||||
129
include/core/regionmapeditcommands.h
Normal file
129
include/core/regionmapeditcommands.h
Normal file
@@ -0,0 +1,129 @@
|
||||
#pragma once
|
||||
#ifndef REGIONMAPEDITCOMMANDS_H
|
||||
#define REGIONMAPEDITCOMMANDS_H
|
||||
|
||||
#include "regionmap.h"
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QList>
|
||||
|
||||
class RegionMap;
|
||||
|
||||
enum RMCommandId {
|
||||
ID_EditTilemap = 0,
|
||||
ID_EditLayout,
|
||||
ID_ResizeLayout,
|
||||
ID_EditEntry,
|
||||
};
|
||||
|
||||
|
||||
/// Implements a command to commit tilemap paint actions
|
||||
class EditTilemap : public QUndoCommand {
|
||||
public:
|
||||
EditTilemap(RegionMap *map, QByteArray oldTilemap, QByteArray newTilemap, unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_EditTilemap; }
|
||||
|
||||
private:
|
||||
RegionMap *map;
|
||||
|
||||
QByteArray oldTilemap;
|
||||
QByteArray newTilemap;
|
||||
|
||||
unsigned actionId;
|
||||
};
|
||||
|
||||
|
||||
/// Edit region map section layout
|
||||
class EditLayout : public QUndoCommand {
|
||||
public:
|
||||
EditLayout(RegionMap *map, QString layer, int index, QList<LayoutSquare> oldLayout, QList<LayoutSquare> newLayout, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_EditLayout; }
|
||||
|
||||
private:
|
||||
RegionMap *map;
|
||||
|
||||
int index;
|
||||
QString layer;
|
||||
QList<LayoutSquare> oldLayout;
|
||||
QList<LayoutSquare> newLayout;
|
||||
};
|
||||
|
||||
|
||||
/// Edit Layout Dimensions
|
||||
class ResizeLayout : public QUndoCommand {
|
||||
public:
|
||||
ResizeLayout(RegionMap *map, int oldWidth, int oldHeight, int newWidth, int newHeight,
|
||||
QMap<QString, QList<LayoutSquare>> oldLayouts, QMap<QString, QList<LayoutSquare>> newLayouts, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_ResizeLayout; }
|
||||
|
||||
private:
|
||||
RegionMap *map;
|
||||
|
||||
int oldWidth;
|
||||
int oldHeight;
|
||||
int newWidth;
|
||||
int newHeight;
|
||||
QMap<QString, QList<LayoutSquare>> oldLayouts;
|
||||
QMap<QString, QList<LayoutSquare>> newLayouts;
|
||||
};
|
||||
|
||||
|
||||
/// Edit Entry Value
|
||||
class EditEntry : public QUndoCommand {
|
||||
public:
|
||||
EditEntry(RegionMap *map, QString section, MapSectionEntry oldEntry, MapSectionEntry newEntry, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_EditEntry; }
|
||||
|
||||
protected:
|
||||
RegionMap *map;
|
||||
|
||||
QString section;
|
||||
MapSectionEntry oldEntry;
|
||||
MapSectionEntry newEntry;
|
||||
};
|
||||
|
||||
|
||||
/// Remove Entry
|
||||
class RemoveEntry : public EditEntry {
|
||||
public:
|
||||
RemoveEntry(RegionMap *map, QString section, MapSectionEntry oldEntry, MapSectionEntry newEntry, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
};
|
||||
|
||||
|
||||
/// Add Entry
|
||||
class AddEntry : public EditEntry {
|
||||
public:
|
||||
AddEntry(RegionMap *map, QString section, MapSectionEntry oldEntry, MapSectionEntry newEntry, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
};
|
||||
|
||||
// ResizeTilemap
|
||||
|
||||
// ResizeMap
|
||||
|
||||
#endif // REGIONMAPEDITCOMMANDS_H
|
||||
@@ -136,6 +136,7 @@ private slots:
|
||||
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_entryActivate_clicked();
|
||||
void on_spinBox_RM_LayoutWidth_valueChanged(int);
|
||||
void on_spinBox_RM_LayoutHeight_valueChanged(int);
|
||||
void on_spinBox_tilePalette_valueChanged(int);
|
||||
|
||||
Reference in New Issue
Block a user