mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-22 16:46:45 -05:00
some code cleanup
This commit is contained in:
@@ -22,9 +22,9 @@ enum CommandId {
|
||||
ID_PaintCollision,
|
||||
ID_BucketFillCollision,
|
||||
ID_MagicFillCollision,
|
||||
ID_ResizeMap,
|
||||
ID_ResizeLayout,
|
||||
ID_PaintBorder,
|
||||
ID_ScriptEditMap,
|
||||
ID_ScriptEditLayout,
|
||||
ID_EventMove,
|
||||
ID_EventShift,
|
||||
ID_EventCreate,
|
||||
@@ -194,9 +194,9 @@ private:
|
||||
|
||||
|
||||
/// Implements a command to commit a map or border resize action.
|
||||
class ResizeMap : public QUndoCommand {
|
||||
class ResizeLayout : public QUndoCommand {
|
||||
public:
|
||||
ResizeMap(Layout *layout, QSize oldMapDimensions, QSize newMapDimensions,
|
||||
ResizeLayout(Layout *layout, QSize oldLayoutDimensions, QSize newLayoutDimensions,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QSize oldBorderDimensions, QSize newBorderDimensions,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
@@ -206,15 +206,15 @@ public:
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *) override { return false; }
|
||||
int id() const override { return CommandId::ID_ResizeMap; }
|
||||
int id() const override { return CommandId::ID_ResizeLayout; }
|
||||
|
||||
private:
|
||||
Layout *layout = nullptr;
|
||||
|
||||
int oldMapWidth;
|
||||
int oldMapHeight;
|
||||
int newMapWidth;
|
||||
int newMapHeight;
|
||||
int oldLayoutWidth;
|
||||
int oldLayoutHeight;
|
||||
int newLayoutWidth;
|
||||
int newLayoutHeight;
|
||||
|
||||
int oldBorderWidth;
|
||||
int oldBorderHeight;
|
||||
@@ -342,13 +342,12 @@ public:
|
||||
|
||||
|
||||
|
||||
// !TODO: rename map vars to layout
|
||||
/// Implements a command to commit map edits from the scripting API.
|
||||
/// The scripting api can edit map/border blocks and dimensions.
|
||||
class ScriptEditMap : public QUndoCommand {
|
||||
class ScriptEditLayout : public QUndoCommand {
|
||||
public:
|
||||
ScriptEditMap(Layout *layout,
|
||||
QSize oldMapDimensions, QSize newMapDimensions,
|
||||
ScriptEditLayout(Layout *layout,
|
||||
QSize oldLayoutDimensions, QSize newLayoutDimensions,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QSize oldBorderDimensions, QSize newBorderDimensions,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
@@ -358,7 +357,7 @@ public:
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *) override { return false; }
|
||||
int id() const override { return CommandId::ID_ScriptEditMap; }
|
||||
int id() const override { return CommandId::ID_ScriptEditLayout; }
|
||||
|
||||
private:
|
||||
Layout *layout = nullptr;
|
||||
@@ -369,10 +368,10 @@ private:
|
||||
Blockdata newBorder;
|
||||
Blockdata oldBorder;
|
||||
|
||||
int oldMapWidth;
|
||||
int oldMapHeight;
|
||||
int newMapWidth;
|
||||
int newMapHeight;
|
||||
int oldLayoutWidth;
|
||||
int oldLayoutHeight;
|
||||
int newLayoutWidth;
|
||||
int newLayoutHeight;
|
||||
|
||||
int oldBorderWidth;
|
||||
int oldBorderHeight;
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
Blockdata cached_border;
|
||||
struct {
|
||||
Blockdata blocks;
|
||||
QSize mapDimensions;
|
||||
QSize layoutDimensions;
|
||||
Blockdata border;
|
||||
QSize borderDimensions;
|
||||
} lastCommitBlocks; // to track map changes
|
||||
|
||||
@@ -64,9 +64,9 @@ private:
|
||||
|
||||
|
||||
/// Edit Layout Dimensions
|
||||
class ResizeLayout : public QUndoCommand {
|
||||
class ResizeRMLayout : public QUndoCommand {
|
||||
public:
|
||||
ResizeLayout(RegionMap *map, int oldWidth, int oldHeight, int newWidth, int newHeight,
|
||||
ResizeRMLayout(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;
|
||||
|
||||
@@ -46,8 +46,8 @@ public:
|
||||
QObject *parent = nullptr;
|
||||
|
||||
Project *project = nullptr;
|
||||
QPointer<Map> map = nullptr; // !TODO: since removed onMapCacheCleared, make sure this works as intended
|
||||
QPointer<Layout> layout = nullptr; /* NEW */
|
||||
QPointer<Map> map = nullptr;
|
||||
QPointer<Layout> layout = nullptr;
|
||||
|
||||
QUndoGroup editGroup; // Manages the undo history for each map
|
||||
|
||||
@@ -118,8 +118,6 @@ public:
|
||||
void updateCursorRectPos(int x, int y);
|
||||
void setCursorRectVisible(bool visible);
|
||||
|
||||
|
||||
|
||||
QGraphicsScene *scene = nullptr;
|
||||
QGraphicsPixmapItem *current_view = nullptr;
|
||||
LayoutPixmapItem *map_item = nullptr;
|
||||
@@ -154,15 +152,18 @@ public:
|
||||
EditAction mapEditAction = EditAction::Paint;
|
||||
EditAction objectEditAction = EditAction::Select;
|
||||
|
||||
/// !TODO this
|
||||
enum class EditMode { None, Disabled, Map, Layout, Objects, Connections, Encounters };
|
||||
EditMode editMode = EditMode::Map;
|
||||
enum class EditMode { None, Disabled, Metatiles, Collision, Header, Events, Connections, Encounters };
|
||||
EditMode editMode = EditMode::None;
|
||||
void setEditMode(EditMode mode) { this->editMode = mode; }
|
||||
EditMode getEditMode() { return this->editMode; }
|
||||
|
||||
void setEditingMap();
|
||||
bool getEditingLayout();
|
||||
|
||||
void setEditorView();
|
||||
|
||||
void setEditingMetatiles();
|
||||
void setEditingCollision();
|
||||
void setEditingLayout();
|
||||
void setEditingHeader();
|
||||
void setEditingObjects();
|
||||
void setEditingConnections();
|
||||
void setEditingEncounters();
|
||||
|
||||
@@ -14,25 +14,16 @@ private:
|
||||
using QGraphicsPixmapItem::paint;
|
||||
|
||||
public:
|
||||
enum class PaintMode {
|
||||
Disabled,
|
||||
Metatiles,
|
||||
EventObjects
|
||||
};
|
||||
|
||||
LayoutPixmapItem(Layout *layout, MetatileSelector *metatileSelector, Settings *settings) {
|
||||
this->layout = layout;
|
||||
// this->map->setMapItem(this);
|
||||
this->metatileSelector = metatileSelector;
|
||||
this->settings = settings;
|
||||
this->paintingMode = PaintMode::Metatiles;
|
||||
this->lockedAxis = LayoutPixmapItem::Axis::None;
|
||||
this->prevStraightPathState = false;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
LayoutPixmapItem::PaintMode paintingMode;
|
||||
|
||||
Layout *layout;
|
||||
|
||||
MetatileSelector *metatileSelector;
|
||||
@@ -95,12 +86,17 @@ public:
|
||||
void lockNondominantAxis(QGraphicsSceneMouseEvent *event);
|
||||
QPoint adjustCoords(QPoint pos);
|
||||
|
||||
void setEditsEnabled(bool enabled) { this->editsEnabled = enabled; }
|
||||
bool getEditsEnabled() { return this->editsEnabled; }
|
||||
|
||||
private:
|
||||
void paintSmartPath(int x, int y, bool fromScriptCall = false);
|
||||
static QList<int> smartPathTable;
|
||||
|
||||
unsigned actionId_ = 0;
|
||||
|
||||
bool editsEnabled = true;
|
||||
|
||||
signals:
|
||||
void startPaint(QGraphicsSceneMouseEvent *, LayoutPixmapItem *);
|
||||
void endPaint(QGraphicsSceneMouseEvent *, LayoutPixmapItem *);
|
||||
|
||||
Reference in New Issue
Block a user