mirror of
https://github.com/huderlem/porymap.git
synced 2026-04-25 15:27:53 -05:00
Fix some issues with player view rectangle visibility
This commit is contained in:
parent
c3bb051fd5
commit
046f942f41
|
|
@ -20,7 +20,7 @@ public:
|
|||
}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override {
|
||||
if (!(*enabled)) return;
|
||||
if (!isVisible()) return;
|
||||
painter->setPen(this->color);
|
||||
painter->drawRect(this->rect() + QMargins(1,1,1,1)); // Fill
|
||||
painter->setPen(Qt::black);
|
||||
|
|
@ -28,11 +28,17 @@ public:
|
|||
painter->drawRect(this->rect()); // Inner border
|
||||
}
|
||||
void updateLocation(int x, int y);
|
||||
bool *enabled;
|
||||
|
||||
void setActive(bool active);
|
||||
bool getActive() const { return this->active; }
|
||||
|
||||
protected:
|
||||
bool *enabled = nullptr;
|
||||
bool active = true;
|
||||
QRectF baseRect;
|
||||
QRgb color;
|
||||
|
||||
void updateVisibility();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ void Editor::setEditMode(EditMode editMode) {
|
|||
}
|
||||
this->cursorMapTileRect->setSingleTileMode();
|
||||
this->cursorMapTileRect->setActive(editingLayout);
|
||||
this->playerViewRect->setActive(editingLayout);
|
||||
this->editGroup.setActiveStack(editStack);
|
||||
setMapEditingButtonsEnabled(editingLayout);
|
||||
|
||||
|
|
@ -1111,6 +1112,7 @@ void Editor::scaleMapView(int s) {
|
|||
void Editor::setPlayerViewRect(const QRectF &rect) {
|
||||
delete this->playerViewRect;
|
||||
this->playerViewRect = new MovableRect(&this->settings->playerViewRectEnabled, rect, qRgb(255, 255, 255));
|
||||
this->playerViewRect->setActive(getEditingLayout());
|
||||
if (ui->graphicsView_Map->scene())
|
||||
ui->graphicsView_Map->scene()->update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1961,7 +1961,7 @@ void MainWindow::on_actionPlayer_View_Rectangle_triggered()
|
|||
this->editor->settings->playerViewRectEnabled = enabled;
|
||||
if ((this->editor->map_item && this->editor->map_item->has_mouse)
|
||||
|| (this->editor->collision_item && this->editor->collision_item->has_mouse)) {
|
||||
this->editor->playerViewRect->setVisible(enabled);
|
||||
this->editor->playerViewRect->setVisible(enabled && this->editor->playerViewRect->getActive());
|
||||
ui->graphicsView_Map->scene()->update();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,25 @@ MovableRect::MovableRect(bool *enabled, const QRectF &rect, const QRgb &color)
|
|||
baseRect(rect),
|
||||
color(color)
|
||||
{
|
||||
this->setVisible(*enabled);
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
/// Center rect on grid position (x, y)
|
||||
void MovableRect::updateLocation(int x, int y) {
|
||||
this->setRect(this->baseRect.x() + (x * 16),
|
||||
this->baseRect.y() + (y * 16),
|
||||
this->baseRect.width(),
|
||||
this->baseRect.height());
|
||||
this->setVisible(*this->enabled);
|
||||
setRect(this->baseRect.x() + (x * 16),
|
||||
this->baseRect.y() + (y * 16),
|
||||
this->baseRect.width(),
|
||||
this->baseRect.height());
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
void MovableRect::setActive(bool active) {
|
||||
this->active = active;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
void MovableRect::updateVisibility() {
|
||||
setVisible(*this->enabled && this->active);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user