mirror of
https://github.com/huderlem/porymap.git
synced 2026-03-21 17:45:44 -05:00
Replace QPoint where QSize was meant
This commit is contained in:
parent
6eaeee5f57
commit
9ce865a9c1
|
|
@ -43,7 +43,8 @@ public:
|
|||
bool getSingleTileMode() const { return m_singleTileMode; }
|
||||
|
||||
void updateLocation(int x, int y);
|
||||
void updateSelectionSize(int width, int height);
|
||||
void updateSelectionSize(const QSize &size);
|
||||
void updateSelectionSize(int width, int height) { updateSelectionSize(QSize(width, height)); }
|
||||
|
||||
private:
|
||||
const QSize m_tileSize;
|
||||
|
|
|
|||
|
|
@ -61,17 +61,17 @@ public:
|
|||
void magicFill(
|
||||
int initialX,
|
||||
int initialY,
|
||||
QPoint selectionDimensions,
|
||||
QList<MetatileSelectionItem> selectedMetatiles,
|
||||
QList<CollisionSelectionItem> selectedCollisions,
|
||||
const QSize &selectionDimensions,
|
||||
const QList <MetatileSelectionItem> &selectedMetatiles,
|
||||
const QList <CollisionSelectionItem> &selectedCollisions,
|
||||
bool fromScriptCall = false);
|
||||
void floodFill(int x, int y, bool fromScriptCall = false);
|
||||
void floodFill(int x, int y, uint16_t metatileId, bool fromScriptCall = false);
|
||||
void floodFill(int initialX,
|
||||
int initialY,
|
||||
QPoint selectionDimensions,
|
||||
QList<MetatileSelectionItem> selectedMetatiles,
|
||||
QList<CollisionSelectionItem> selectedCollisions,
|
||||
const QSize &selectionDimensions,
|
||||
const QList<MetatileSelectionItem> &selectedMetatiles,
|
||||
const QList<CollisionSelectionItem> &selectedCollisions,
|
||||
bool fromScriptCall = false);
|
||||
void floodFillSmartPath(int initialX, int initialY, bool fromScriptCall = false);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ struct CollisionSelectionItem
|
|||
|
||||
struct MetatileSelection
|
||||
{
|
||||
QPoint dimensions;
|
||||
QSize dimensions;
|
||||
bool hasCollision;
|
||||
QList<MetatileSelectionItem> metatileItems;
|
||||
QList<CollisionSelectionItem> collisionItems;
|
||||
|
|
@ -43,7 +43,7 @@ public:
|
|||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
QPoint getSelectionDimensions() const override;
|
||||
QSize getSelectionDimensions() const override;
|
||||
void draw() override;
|
||||
void refresh();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
selectionOffsetX(0),
|
||||
selectionOffsetY(0)
|
||||
{}
|
||||
virtual QPoint getSelectionDimensions() const;
|
||||
virtual QSize getSelectionDimensions() const;
|
||||
virtual void draw() = 0;
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public:
|
|||
this->paletteChanged = false;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
QPoint getSelectionDimensions() const override;
|
||||
QSize getSelectionDimensions() const override;
|
||||
void draw() override;
|
||||
void select(uint16_t metatileId);
|
||||
void highlight(uint16_t metatileId);
|
||||
|
|
|
|||
|
|
@ -1120,8 +1120,7 @@ void Editor::onHoveredMetatileSelectionCleared() {
|
|||
}
|
||||
|
||||
void Editor::onSelectedMetatilesChanged() {
|
||||
QPoint size = this->metatile_selector_item->getSelectionDimensions();
|
||||
this->cursorMapTileRect->updateSelectionSize(size.x(), size.y());
|
||||
this->cursorMapTileRect->updateSelectionSize(this->metatile_selector_item->getSelectionDimensions());
|
||||
this->redrawCurrentMetatilesSelection();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1787,7 +1787,7 @@ void MainWindow::redrawMetatileSelection() {
|
|||
|
||||
void MainWindow::scrollMetatileSelectorToSelection() {
|
||||
// Internal selections or 1x1 external selections can be scrolled to
|
||||
if (!editor->metatile_selector_item->isInternalSelection() && editor->metatile_selector_item->getSelectionDimensions() != QPoint(1, 1))
|
||||
if (!editor->metatile_selector_item->isInternalSelection() && editor->metatile_selector_item->getSelectionDimensions() != QSize(1, 1))
|
||||
return;
|
||||
|
||||
MetatileSelection selection = editor->metatile_selector_item->getMetatileSelection();
|
||||
|
|
@ -1795,8 +1795,8 @@ void MainWindow::scrollMetatileSelectorToSelection() {
|
|||
return;
|
||||
|
||||
QPoint pos = editor->metatile_selector_item->getMetatileIdCoordsOnWidget(selection.metatileItems.first().metatileId);
|
||||
QPoint size = editor->metatile_selector_item->getSelectionDimensions();
|
||||
pos += QPoint((size.x() - 1) * Metatile::pixelWidth(), (size.y() - 1) * Metatile::pixelHeight()) / 2; // We want to focus on the center of the whole selection
|
||||
QSize size = editor->metatile_selector_item->getSelectionDimensions();
|
||||
pos += QPoint((size.width() - 1) * Metatile::pixelWidth(), (size.height() - 1) * Metatile::pixelHeight()) / 2; // We want to focus on the center of the whole selection
|
||||
pos *= getMetatilesZoomScale();
|
||||
|
||||
auto viewport = ui->scrollArea_MetatileSelector->viewport();
|
||||
|
|
@ -1970,8 +1970,8 @@ void MainWindow::copy() {
|
|||
}
|
||||
copyObject["metatile_selection"] = metatiles;
|
||||
copyObject["collision_selection"] = collisions;
|
||||
copyObject["width"] = editor->metatile_selector_item->getSelectionDimensions().x();
|
||||
copyObject["height"] = editor->metatile_selector_item->getSelectionDimensions().y();
|
||||
copyObject["width"] = editor->metatile_selector_item->getSelectionDimensions().width();
|
||||
copyObject["height"] = editor->metatile_selector_item->getSelectionDimensions().height();
|
||||
setClipboardData(copyObject);
|
||||
logInfo("Copied metatile selection to clipboard");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
Blockdata oldBorder = layout->border;
|
||||
|
||||
for (int i = 0; i < selection.dimensions.x() && (i + pos.x()) < width; i++) {
|
||||
for (int j = 0; j < selection.dimensions.y() && (j + pos.y()) < height; j++) {
|
||||
MetatileSelectionItem item = selection.metatileItems.at(j * selection.dimensions.x() + i);
|
||||
for (int i = 0; i < selection.dimensions.width() && (i + pos.x()) < width; i++) {
|
||||
for (int j = 0; j < selection.dimensions.height() && (j + pos.y()) < height; j++) {
|
||||
MetatileSelectionItem item = selection.metatileItems.at(j * selection.dimensions.width() + i);
|
||||
layout->setBorderMetatileId(pos.x() + i, pos.y() + j, item.metatileId, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
#include <QPainter>
|
||||
|
||||
QPixmap drawMetatileSelection(MetatileSelection selection, Layout *layout) {
|
||||
int width = selection.dimensions.x() * Metatile::pixelWidth();
|
||||
int height = selection.dimensions.y() * Metatile::pixelHeight();
|
||||
int width = selection.dimensions.width() * Metatile::pixelWidth();
|
||||
int height = selection.dimensions.height() * Metatile::pixelHeight();
|
||||
QImage image(width, height, QImage::Format_RGBA8888);
|
||||
image.fill(QColor(0, 0, 0, 0));
|
||||
QPainter painter(&image);
|
||||
|
||||
for (int i = 0; i < selection.dimensions.x(); i++) {
|
||||
for (int j = 0; j < selection.dimensions.y(); j++) {
|
||||
for (int i = 0; i < selection.dimensions.width(); i++) {
|
||||
for (int j = 0; j < selection.dimensions.height(); j++) {
|
||||
int x = i * Metatile::pixelWidth();
|
||||
int y = j * Metatile::pixelHeight();
|
||||
QPoint metatile_origin = QPoint(x, y);
|
||||
int index = j * selection.dimensions.x() + i;
|
||||
int index = j * selection.dimensions.width() + i;
|
||||
MetatileSelectionItem item = selection.metatileItems.at(index);
|
||||
if (item.enabled) {
|
||||
QImage metatile_image = getMetatileImage(item.metatileId, layout);
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ void CursorTileRect::stopRightClickSelectionAnchor() {
|
|||
m_rightClickSelectionAnchored = false;
|
||||
}
|
||||
|
||||
void CursorTileRect::updateSelectionSize(int width, int height) {
|
||||
m_selectionSize = QSize(width, height).expandedTo(QSize(1,1));
|
||||
void CursorTileRect::updateSelectionSize(const QSize &size) {
|
||||
m_selectionSize = size.expandedTo(QSize(1,1)); // Enforce minimum of 1x1 cell
|
||||
prepareGeometryChange();
|
||||
update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,15 +25,15 @@ void LayoutPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
|||
|
||||
// Paint onto the map.
|
||||
bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
|
||||
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
|
||||
QSize selectionDimensions = this->metatileSelector->getSelectionDimensions();
|
||||
if (settings->smartPathsEnabled) {
|
||||
if (!shiftPressed && selectionDimensions.x() == 3 && selectionDimensions.y() == 3) {
|
||||
if (!shiftPressed && selectionDimensions == QSize(3,3)) {
|
||||
paintSmartPath(pos.x(), pos.y());
|
||||
} else {
|
||||
paintNormal(pos.x(), pos.y());
|
||||
}
|
||||
} else {
|
||||
if (shiftPressed && selectionDimensions.x() == 3 && selectionDimensions.y() == 3) {
|
||||
if (shiftPressed && selectionDimensions == QSize(3,3)) {
|
||||
paintSmartPath(pos.x(), pos.y());
|
||||
} else {
|
||||
paintNormal(pos.x(), pos.y());
|
||||
|
|
@ -110,22 +110,22 @@ void LayoutPixmapItem::paintNormal(int x, int y, bool fromScriptCall) {
|
|||
// This allows painting via dragging the mouse to tile the painted region.
|
||||
int xDiff = x - initialX;
|
||||
int yDiff = y - initialY;
|
||||
if (xDiff < 0 && xDiff % selection.dimensions.x() != 0) xDiff -= selection.dimensions.x();
|
||||
if (yDiff < 0 && yDiff % selection.dimensions.y() != 0) yDiff -= selection.dimensions.y();
|
||||
if (xDiff < 0 && xDiff % selection.dimensions.width() != 0) xDiff -= selection.dimensions.width();
|
||||
if (yDiff < 0 && yDiff % selection.dimensions.height() != 0) yDiff -= selection.dimensions.height();
|
||||
|
||||
x = initialX + (xDiff / selection.dimensions.x()) * selection.dimensions.x();
|
||||
y = initialY + (yDiff / selection.dimensions.y()) * selection.dimensions.y();
|
||||
x = initialX + (xDiff / selection.dimensions.width()) * selection.dimensions.width();
|
||||
y = initialY + (yDiff / selection.dimensions.height()) * selection.dimensions.height();
|
||||
|
||||
// for edit history
|
||||
Blockdata oldMetatiles = !fromScriptCall ? this->layout->blockdata : Blockdata();
|
||||
|
||||
for (int i = 0; i < selection.dimensions.x() && i + x < this->layout->getWidth(); i++)
|
||||
for (int j = 0; j < selection.dimensions.y() && j + y < this->layout->getHeight(); j++) {
|
||||
for (int i = 0; i < selection.dimensions.width() && i + x < this->layout->getWidth(); i++)
|
||||
for (int j = 0; j < selection.dimensions.height() && j + y < this->layout->getHeight(); j++) {
|
||||
int actualX = i + x;
|
||||
int actualY = j + y;
|
||||
Block block;
|
||||
if (this->layout->getBlock(actualX, actualY, &block)) {
|
||||
int index = j * selection.dimensions.x() + i;
|
||||
int index = j * selection.dimensions.width() + i;
|
||||
MetatileSelectionItem item = selection.metatileItems.at(index);
|
||||
if (!item.enabled)
|
||||
continue;
|
||||
|
|
@ -178,7 +178,7 @@ bool isSmartPathTile(QList<MetatileSelectionItem> metatileItems, uint16_t metati
|
|||
}
|
||||
|
||||
bool isValidSmartPathSelection(MetatileSelection selection) {
|
||||
if (selection.dimensions.x() != 3 || selection.dimensions.y() != 3)
|
||||
if (selection.dimensions != QSize(3,3))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < selection.metatileItems.length(); i++) {
|
||||
|
|
@ -377,7 +377,7 @@ void LayoutPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
|||
int metatileId = selection.metatileItems.first().metatileId;
|
||||
if (selection.metatileItems.count() > 1 || (this->layout->getBlock(pos.x(), pos.y(), &block) && block.metatileId() != metatileId)) {
|
||||
bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier;
|
||||
if ((this->settings->smartPathsEnabled || smartPathsEnabled) && selection.dimensions.x() == 3 && selection.dimensions.y() == 3)
|
||||
if ((this->settings->smartPathsEnabled || smartPathsEnabled) && selection.dimensions == QSize(3,3))
|
||||
this->floodFillSmartPath(pos.x(), pos.y());
|
||||
else
|
||||
this->floodFill(pos.x(), pos.y());
|
||||
|
|
@ -398,7 +398,7 @@ void LayoutPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
|||
}
|
||||
|
||||
void LayoutPixmapItem::magicFill(int x, int y, uint16_t metatileId, bool fromScriptCall) {
|
||||
QPoint selectionDimensions(1, 1);
|
||||
QSize selectionDimensions(1, 1);
|
||||
QList<MetatileSelectionItem> selectedMetatiles = QList<MetatileSelectionItem>({MetatileSelectionItem{ true, metatileId }});
|
||||
this->magicFill(x, y, selectionDimensions, selectedMetatiles, QList<CollisionSelectionItem>(), fromScriptCall);
|
||||
}
|
||||
|
|
@ -411,9 +411,9 @@ void LayoutPixmapItem::magicFill(int x, int y, bool fromScriptCall) {
|
|||
void LayoutPixmapItem::magicFill(
|
||||
int initialX,
|
||||
int initialY,
|
||||
QPoint selectionDimensions,
|
||||
QList<MetatileSelectionItem> selectedMetatiles,
|
||||
QList<CollisionSelectionItem> selectedCollisions,
|
||||
const QSize &selectionDimensions,
|
||||
const QList<MetatileSelectionItem> &selectedMetatiles,
|
||||
const QList<CollisionSelectionItem> &selectedCollisions,
|
||||
bool fromScriptCall) {
|
||||
Block block;
|
||||
if (this->layout->getBlock(initialX, initialY, &block)) {
|
||||
|
|
@ -430,11 +430,11 @@ void LayoutPixmapItem::magicFill(
|
|||
if (this->layout->getBlock(x, y, &block) && block.metatileId() == metatileId) {
|
||||
int xDiff = x - initialX;
|
||||
int yDiff = y - initialY;
|
||||
int i = xDiff % selectionDimensions.x();
|
||||
int j = yDiff % selectionDimensions.y();
|
||||
if (i < 0) i = selectionDimensions.x() + i;
|
||||
if (j < 0) j = selectionDimensions.y() + j;
|
||||
int index = j * selectionDimensions.x() + i;
|
||||
int i = xDiff % selectionDimensions.width();
|
||||
int j = yDiff % selectionDimensions.height();
|
||||
if (i < 0) i = selectionDimensions.width() + i;
|
||||
if (j < 0) j = selectionDimensions.height() + j;
|
||||
int index = j * selectionDimensions.width() + i;
|
||||
if (selectedMetatiles.at(index).enabled) {
|
||||
block.setMetatileId(selectedMetatiles.at(index).metatileId);
|
||||
if (setCollisions) {
|
||||
|
|
@ -460,7 +460,7 @@ void LayoutPixmapItem::floodFill(int initialX, int initialY, bool fromScriptCall
|
|||
}
|
||||
|
||||
void LayoutPixmapItem::floodFill(int initialX, int initialY, uint16_t metatileId, bool fromScriptCall) {
|
||||
QPoint selectionDimensions(1, 1);
|
||||
QSize selectionDimensions(1, 1);
|
||||
QList<MetatileSelectionItem> selectedMetatiles = QList<MetatileSelectionItem>({MetatileSelectionItem{true, metatileId}});
|
||||
this->floodFill(initialX, initialY, selectionDimensions, selectedMetatiles, QList<CollisionSelectionItem>(), fromScriptCall);
|
||||
}
|
||||
|
|
@ -468,9 +468,9 @@ void LayoutPixmapItem::floodFill(int initialX, int initialY, uint16_t metatileId
|
|||
void LayoutPixmapItem::floodFill(
|
||||
int initialX,
|
||||
int initialY,
|
||||
QPoint selectionDimensions,
|
||||
QList<MetatileSelectionItem> selectedMetatiles,
|
||||
QList<CollisionSelectionItem> selectedCollisions,
|
||||
const QSize &selectionDimensions,
|
||||
const QList<MetatileSelectionItem> &selectedMetatiles,
|
||||
const QList<CollisionSelectionItem> &selectedCollisions,
|
||||
bool fromScriptCall) {
|
||||
bool setCollisions = selectedCollisions.length() == selectedMetatiles.length();
|
||||
Blockdata oldMetatiles = !fromScriptCall ? this->layout->blockdata : Blockdata();
|
||||
|
|
@ -490,11 +490,11 @@ void LayoutPixmapItem::floodFill(
|
|||
visited.insert(x + y * this->layout->getWidth());
|
||||
int xDiff = x - initialX;
|
||||
int yDiff = y - initialY;
|
||||
int i = xDiff % selectionDimensions.x();
|
||||
int j = yDiff % selectionDimensions.y();
|
||||
if (i < 0) i = selectionDimensions.x() + i;
|
||||
if (j < 0) j = selectionDimensions.y() + j;
|
||||
int index = j * selectionDimensions.x() + i;
|
||||
int i = xDiff % selectionDimensions.width();
|
||||
int j = yDiff % selectionDimensions.height();
|
||||
if (i < 0) i = selectionDimensions.width() + i;
|
||||
if (j < 0) j = selectionDimensions.height() + j;
|
||||
int index = j * selectionDimensions.width() + i;
|
||||
uint16_t metatileId = selectedMetatiles.at(index).metatileId;
|
||||
uint16_t old_metatileId = block.metatileId();
|
||||
if (selectedMetatiles.at(index).enabled && (selectedMetatiles.count() != 1 || old_metatileId != metatileId)) {
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ void MetatileLayersItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
|||
if (event->buttons() & Qt::RightButton) {
|
||||
SelectablePixmapItem::mousePressEvent(event);
|
||||
QPoint selectionOrigin = this->getSelectionStart();
|
||||
QPoint dimensions = this->getSelectionDimensions();
|
||||
emit this->selectedTilesChanged(selectionOrigin, dimensions.x(), dimensions.y());
|
||||
QSize dimensions = this->getSelectionDimensions();
|
||||
emit this->selectedTilesChanged(selectionOrigin, dimensions.width(), dimensions.height());
|
||||
this->drawSelection();
|
||||
} else {
|
||||
const QPoint pos = this->getBoundedPos(event->pos());
|
||||
|
|
@ -95,8 +95,8 @@ void MetatileLayersItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
|||
if (event->buttons() & Qt::RightButton) {
|
||||
SelectablePixmapItem::mouseMoveEvent(event);
|
||||
QPoint selectionOrigin = this->getSelectionStart();
|
||||
QPoint dimensions = this->getSelectionDimensions();
|
||||
emit this->selectedTilesChanged(selectionOrigin, dimensions.x(), dimensions.y());
|
||||
QSize dimensions = this->getSelectionDimensions();
|
||||
emit this->selectedTilesChanged(selectionOrigin, dimensions.width(), dimensions.height());
|
||||
this->drawSelection();
|
||||
} else {
|
||||
const QPoint pos = this->getBoundedPos(event->pos());
|
||||
|
|
@ -112,8 +112,8 @@ void MetatileLayersItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
|||
if (event->buttons() & Qt::RightButton) {
|
||||
SelectablePixmapItem::mouseReleaseEvent(event);
|
||||
QPoint selectionOrigin = this->getSelectionStart();
|
||||
QPoint dimensions = this->getSelectionDimensions();
|
||||
emit this->selectedTilesChanged(selectionOrigin, dimensions.x(), dimensions.y());
|
||||
QSize dimensions = this->getSelectionDimensions();
|
||||
emit this->selectedTilesChanged(selectionOrigin, dimensions.width(), dimensions.height());
|
||||
}
|
||||
|
||||
this->draw();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "project.h"
|
||||
#include <QPainter>
|
||||
|
||||
QPoint MetatileSelector::getSelectionDimensions() const {
|
||||
QSize MetatileSelector::getSelectionDimensions() const {
|
||||
if (this->prefabSelection || this->externalSelection)
|
||||
return selection.dimensions;
|
||||
return SelectablePixmapItem::getSelectionDimensions();
|
||||
|
|
@ -41,7 +41,7 @@ bool MetatileSelector::select(uint16_t metatileId) {
|
|||
this->externalSelection = false;
|
||||
this->prefabSelection = false;
|
||||
this->selection = MetatileSelection{
|
||||
QPoint(1, 1),
|
||||
QSize(1, 1),
|
||||
false,
|
||||
QList<MetatileSelectionItem>({MetatileSelectionItem{true, metatileId}}),
|
||||
QList<CollisionSelectionItem>(),
|
||||
|
|
@ -80,7 +80,7 @@ void MetatileSelector::setExternalSelection(int width, int height, const QList<u
|
|||
this->selection.metatileItems.clear();
|
||||
this->selection.collisionItems.clear();
|
||||
this->selection.hasCollision = true;
|
||||
this->selection.dimensions = QPoint(width, height);
|
||||
this->selection.dimensions = QSize(width, height);
|
||||
for (int i = 0; i < qMin(metatiles.length(), collisions.length()); i++) {
|
||||
uint16_t metatileId = metatiles.at(i);
|
||||
uint16_t collision = collisions.at(i).first;
|
||||
|
|
@ -175,8 +175,8 @@ void MetatileSelector::updateSelectedMetatiles() {
|
|||
this->selection.hasCollision = false;
|
||||
this->selection.dimensions = this->getSelectionDimensions();
|
||||
QPoint origin = this->getSelectionStart();
|
||||
for (int j = 0; j < this->selection.dimensions.y(); j++) {
|
||||
for (int i = 0; i < this->selection.dimensions.x(); i++) {
|
||||
for (int j = 0; j < this->selection.dimensions.height(); j++) {
|
||||
for (int i = 0; i < this->selection.dimensions.width(); i++) {
|
||||
uint16_t metatileId = posToMetatileId(origin.x() + i, origin.y() + j);
|
||||
this->selection.metatileItems.append(MetatileSelectionItem{true, metatileId});
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ void MetatileSelector::updateSelectedMetatiles() {
|
|||
|
||||
void MetatileSelector::updateExternalSelectedMetatiles() {
|
||||
this->selection.metatileItems.clear();
|
||||
this->selection.dimensions = QPoint(this->externalSelectionWidth, this->externalSelectionHeight);
|
||||
this->selection.dimensions = QSize(this->externalSelectionWidth, this->externalSelectionHeight);
|
||||
for (int i = 0; i < this->externalSelectedMetatiles.count(); ++i) {
|
||||
uint16_t metatileId = this->externalSelectedMetatiles.at(i);
|
||||
if (!this->layout->metatileIsValid(metatileId))
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void Prefab::loadPrefabs() {
|
|||
QString secondaryTileset = ParseUtil::jsonToQString(prefabObj["secondary_tileset"]);
|
||||
|
||||
MetatileSelection selection;
|
||||
selection.dimensions = QPoint(width, height);
|
||||
selection.dimensions = QSize(width, height);
|
||||
selection.hasCollision = true;
|
||||
for (int j = 0; j < width * height; j++) {
|
||||
selection.metatileItems.append(MetatileSelectionItem{false, 0});
|
||||
|
|
@ -112,14 +112,14 @@ void Prefab::savePrefabs() {
|
|||
for (auto item : this->items) {
|
||||
OrderedJson::object prefabObj;
|
||||
prefabObj["name"] = item.name;
|
||||
prefabObj["width"] = item.selection.dimensions.x();
|
||||
prefabObj["height"] = item.selection.dimensions.y();
|
||||
prefabObj["width"] = item.selection.dimensions.width();
|
||||
prefabObj["height"] = item.selection.dimensions.height();
|
||||
prefabObj["primary_tileset"] = item.primaryTileset;
|
||||
prefabObj["secondary_tileset"] = item.secondaryTileset;
|
||||
OrderedJson::array metatiles;
|
||||
for (int y = 0; y < item.selection.dimensions.y(); y++) {
|
||||
for (int x = 0; x < item.selection.dimensions.x(); x++) {
|
||||
int index = y * item.selection.dimensions.x() + x;
|
||||
for (int y = 0; y < item.selection.dimensions.height(); y++) {
|
||||
for (int x = 0; x < item.selection.dimensions.width(); x++) {
|
||||
int index = y * item.selection.dimensions.width() + x;
|
||||
auto metatileItem = item.selection.metatileItems.at(index);
|
||||
if (metatileItem.enabled) {
|
||||
OrderedJson::object metatileObj;
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ PrefabCreationDialog::PrefabCreationDialog(QWidget *parent, MetatileSelector *me
|
|||
|
||||
QObject::connect(this->ui->graphicsView_Prefab, &ClickableGraphicsView::clicked, [=](QMouseEvent *event){
|
||||
auto pos = event->pos();
|
||||
int selectionWidth = this->selection.dimensions.x() * Metatile::pixelWidth();
|
||||
int selectionHeight = this->selection.dimensions.y() * Metatile::pixelHeight();
|
||||
int selectionWidth = this->selection.dimensions.width() * Metatile::pixelWidth();
|
||||
int selectionHeight = this->selection.dimensions.height() * Metatile::pixelHeight();
|
||||
if (pos.x() < 0 || pos.x() >= selectionWidth || pos.y() < 0 || pos.y() >= selectionHeight)
|
||||
return;
|
||||
int metatileX = pos.x() / Metatile::pixelWidth();
|
||||
int metatileY = pos.y() / Metatile::pixelHeight();
|
||||
int index = metatileY * this->selection.dimensions.x() + metatileX;
|
||||
int index = metatileY * this->selection.dimensions.width() + metatileX;
|
||||
bool toggledState = !this->selection.metatileItems[index].enabled;
|
||||
this->selection.metatileItems[index].enabled = toggledState;
|
||||
if (this->selection.hasCollision) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "selectablepixmapitem.h"
|
||||
#include <QPainter>
|
||||
|
||||
QPoint SelectablePixmapItem::getSelectionDimensions() const
|
||||
QSize SelectablePixmapItem::getSelectionDimensions() const
|
||||
{
|
||||
return QPoint(abs(this->selectionOffsetX) + 1, abs(this->selectionOffsetY) + 1);
|
||||
return QSize(abs(this->selectionOffsetX) + 1, abs(this->selectionOffsetY) + 1);
|
||||
}
|
||||
|
||||
QPoint SelectablePixmapItem::getSelectionStart()
|
||||
|
|
@ -93,8 +93,8 @@ QPoint SelectablePixmapItem::getCellPos(QPointF pos)
|
|||
void SelectablePixmapItem::drawSelection()
|
||||
{
|
||||
QPoint origin = this->getSelectionStart();
|
||||
QPoint dimensions = this->getSelectionDimensions();
|
||||
QRect selectionRect(origin.x() * this->cellWidth, origin.y() * this->cellHeight, dimensions.x() * this->cellWidth, dimensions.y() * this->cellHeight);
|
||||
QSize dimensions = this->getSelectionDimensions();
|
||||
QRect selectionRect(origin.x() * this->cellWidth, origin.y() * this->cellHeight, dimensions.width() * this->cellWidth, dimensions.height() * this->cellHeight);
|
||||
|
||||
// If a selection is fully outside the bounds of the selectable area, don't draw anything.
|
||||
// This prevents the border of the selection rectangle potentially being visible on an otherwise invisible selection.
|
||||
|
|
|
|||
|
|
@ -392,12 +392,12 @@ void TilesetEditor::drawSelectedTiles() {
|
|||
const int imgTileHeight = 16;
|
||||
this->selectedTileScene->clear();
|
||||
QList<Tile> tiles = this->tileSelector->getSelectedTiles();
|
||||
QPoint dimensions = this->tileSelector->getSelectionDimensions();
|
||||
QImage selectionImage(imgTileWidth * dimensions.x(), imgTileHeight * dimensions.y(), QImage::Format_RGBA8888);
|
||||
QSize dimensions = this->tileSelector->getSelectionDimensions();
|
||||
QImage selectionImage(imgTileWidth * dimensions.width(), imgTileHeight * dimensions.height(), QImage::Format_RGBA8888);
|
||||
QPainter painter(&selectionImage);
|
||||
int tileIndex = 0;
|
||||
for (int j = 0; j < dimensions.y(); j++) {
|
||||
for (int i = 0; i < dimensions.x(); i++) {
|
||||
for (int j = 0; j < dimensions.height(); j++) {
|
||||
for (int i = 0; i < dimensions.width(); i++) {
|
||||
auto tile = tiles.at(tileIndex);
|
||||
QImage tileImage = getPalettedTileImage(tile.tileId, this->primaryTileset, this->secondaryTileset, tile.palette, true).scaled(imgTileWidth, imgTileHeight);
|
||||
tile.flip(&tileImage);
|
||||
|
|
@ -486,12 +486,12 @@ void TilesetEditor::onMetatileLayerTileChanged(int x, int y) {
|
|||
QPoint(5, 1),
|
||||
};
|
||||
Metatile *prevMetatile = new Metatile(*this->metatile);
|
||||
QPoint dimensions = this->tileSelector->getSelectionDimensions();
|
||||
QSize dimensions = this->tileSelector->getSelectionDimensions();
|
||||
QList<Tile> tiles = this->tileSelector->getSelectedTiles();
|
||||
int selectedTileIndex = 0;
|
||||
int maxTileIndex = projectConfig.getNumTilesInMetatile();
|
||||
for (int j = 0; j < dimensions.y(); j++) {
|
||||
for (int i = 0; i < dimensions.x(); i++) {
|
||||
for (int j = 0; j < dimensions.height(); j++) {
|
||||
for (int i = 0; i < dimensions.width(); i++) {
|
||||
int tileIndex = ((x + i) / 2 * 4) + ((y + j) * 2) + ((x + i) % 2);
|
||||
if (tileIndex < maxTileIndex
|
||||
&& tileCoords.at(tileIndex).x() >= x
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
#include <QPainter>
|
||||
#include <QVector>
|
||||
|
||||
QPoint TilesetEditorTileSelector::getSelectionDimensions() const {
|
||||
QSize TilesetEditorTileSelector::getSelectionDimensions() const {
|
||||
if (this->externalSelection) {
|
||||
return QPoint(this->externalSelectionWidth, this->externalSelectionHeight);
|
||||
return QSize(this->externalSelectionWidth, this->externalSelectionHeight);
|
||||
} else {
|
||||
return SelectablePixmapItem::getSelectionDimensions();
|
||||
}
|
||||
|
|
@ -90,9 +90,9 @@ void TilesetEditorTileSelector::updateSelectedTiles() {
|
|||
this->externalSelection = false;
|
||||
this->selectedTiles.clear();
|
||||
QPoint origin = this->getSelectionStart();
|
||||
QPoint dimensions = this->getSelectionDimensions();
|
||||
for (int j = 0; j < dimensions.y(); j++) {
|
||||
for (int i = 0; i < dimensions.x(); i++) {
|
||||
QSize dimensions = this->getSelectionDimensions();
|
||||
for (int j = 0; j < dimensions.height(); j++) {
|
||||
for (int i = 0; i < dimensions.width(); i++) {
|
||||
uint16_t metatileId = this->getTileId(origin.x() + i, origin.y() + j);
|
||||
this->selectedTiles.append(metatileId);
|
||||
}
|
||||
|
|
@ -103,13 +103,13 @@ QList<Tile> TilesetEditorTileSelector::getSelectedTiles() {
|
|||
if (this->externalSelection) {
|
||||
return buildSelectedTiles(this->externalSelectionWidth, this->externalSelectionHeight, this->externalSelectedTiles);
|
||||
} else {
|
||||
QPoint dimensions = this->getSelectionDimensions();
|
||||
QSize dimensions = this->getSelectionDimensions();
|
||||
QList<Tile> tiles;
|
||||
for (int i = 0; i < this->selectedTiles.length(); i++) {
|
||||
uint16_t tile = this->selectedTiles.at(i);
|
||||
tiles.append(Tile(tile, false, false, this->paletteId));
|
||||
}
|
||||
return buildSelectedTiles(dimensions.x(), dimensions.y(), tiles);
|
||||
return buildSelectedTiles(dimensions.width(), dimensions.height(), tiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user