From 3a226954ba6b9bd70892ef7247226eaf30d216a4 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Wed, 13 Mar 2024 01:20:34 -0400 Subject: Stop rendering its label once a slot has a map. --- mapman/src/painter.cpp | 6 ++++++ mapman/src/painter.hpp | 2 ++ 2 files changed, 8 insertions(+) (limited to 'mapman/src') diff --git a/mapman/src/painter.cpp b/mapman/src/painter.cpp index 876184e..5b3ad3b 100644 --- a/mapman/src/painter.cpp +++ b/mapman/src/painter.cpp @@ -72,6 +72,8 @@ void map_painter::set_dimension(int h, int v) s->clear(); slices.clear(); slices.resize(hc * vc, nullptr); + bgspr.clear(); + bgspr.resize(hc * vc, {nullptr, nullptr}); for (int i = 0; i < vc; ++i) for (int j = 0; j < hc; ++j) { @@ -79,6 +81,7 @@ void map_painter::set_dimension(int h, int v) t->setPos(j * 128 + 64 - t->boundingRect().width() / 2, i * 128 + 64 - t->boundingRect().height() / 2); auto r = new drop_rect(i * hc + j, this); s->addItem(r); + bgspr[i * hc + j] = {t, r}; r->setPos(j * 128, i * 128); } } @@ -92,6 +95,7 @@ void map_painter::set_map_id(int pos, bool populated, int id, bool user_input) delete slices[pos]; slices[pos] = nullptr; } + auto [t, r] = bgspr[pos]; if (populated) { QPixmap pm; @@ -105,6 +109,8 @@ void map_painter::set_map_id(int pos, bool populated, int id, bool user_input) int y = pos % hc; p->setPos(y * 128, x * 128); slices[pos] = p; + static_cast(t)->setPen(QColor(Qt::GlobalColor::transparent)); + static_cast(r)->setPen(QColor(Qt::GlobalColor::transparent)); } if (user_input) emit map_id_changed(pos, populated, id); diff --git a/mapman/src/painter.hpp b/mapman/src/painter.hpp index 489a87b..f7822a9 100644 --- a/mapman/src/painter.hpp +++ b/mapman/src/painter.hpp @@ -1,6 +1,7 @@ #ifndef MAPPAINTER_HPP #define MAPPAINTER_HPP +#include #include #include @@ -29,6 +30,7 @@ private: int hc; int vc; std::vector slices; + std::vector> bgspr; }; #endif -- cgit v1.2.3