aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2024-03-13 01:20:34 -0400
committerGravatar Chris Xiong <chirs241097@gmail.com> 2024-03-13 01:20:34 -0400
commit3a226954ba6b9bd70892ef7247226eaf30d216a4 (patch)
tree87aa051bc6cdf0a2c3031b201cb51701ab60a586
parent34835275649b78c80a8e69b71fb9b990fe654d43 (diff)
downloadmeteor-trashy-addon-3a226954ba6b9bd70892ef7247226eaf30d216a4.tar.xz
Stop rendering its label once a slot has a map.
-rw-r--r--mapman/src/painter.cpp6
-rw-r--r--mapman/src/painter.hpp2
2 files changed, 8 insertions, 0 deletions
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<QAbstractGraphicsShapeItem*>(t)->setPen(QColor(Qt::GlobalColor::transparent));
+ static_cast<QAbstractGraphicsShapeItem*>(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 <utility>
#include <vector>
#include <QObject>
@@ -29,6 +30,7 @@ private:
int hc;
int vc;
std::vector<QGraphicsItem*> slices;
+ std::vector<std::tuple<QGraphicsItem*, QGraphicsItem*>> bgspr;
};
#endif