some code cleanup

This commit is contained in:
garak
2023-04-07 21:50:46 -04:00
parent 2d2b7f723b
commit f4cd57c988
16 changed files with 187 additions and 213 deletions

View File

@@ -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;

View File

@@ -55,7 +55,7 @@ public:
Blockdata cached_border;
struct {
Blockdata blocks;
QSize mapDimensions;
QSize layoutDimensions;
Blockdata border;
QSize borderDimensions;
} lastCommitBlocks; // to track map changes

View File

@@ -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;