Add opacity to scripting overlay

This commit is contained in:
GriffinR
2021-12-31 16:12:04 -05:00
committed by huderlem
parent 98f4bae728
commit fd88184b47
6 changed files with 46 additions and 0 deletions

View File

@@ -353,6 +353,26 @@ void MainWindow::moveOverlays(int deltaX, int deltaY) {
this->ui->graphicsView_Map->scene()->update();
}
int MainWindow::getOverlayOpacity(int layer) {
if (!this->ui || !this->ui->graphicsView_Map)
return 0;
return this->ui->graphicsView_Map->getOverlay(layer)->getOpacity();
}
void MainWindow::setOverlayOpacity(int opacity, int layer) {
if (!this->ui || !this->ui->graphicsView_Map)
return;
this->ui->graphicsView_Map->getOverlay(layer)->setOpacity(opacity);
this->ui->graphicsView_Map->scene()->update();
}
void MainWindow::setOverlaysOpacity(int opacity) {
if (!this->ui || !this->ui->graphicsView_Map)
return;
this->ui->graphicsView_Map->setOverlaysOpacity(opacity);
this->ui->graphicsView_Map->scene()->update();
}
void MainWindow::addText(QString text, int x, int y, QString color, int fontSize, int layer) {
if (!this->ui || !this->ui->graphicsView_Map)
return;

View File

@@ -69,6 +69,11 @@ void MapView::setOverlaysPosition(int x, int y) {
overlay->setPosition(x, y);
}
void MapView::setOverlaysOpacity(int opacity) {
foreach (Overlay * overlay, this->overlayMap)
overlay->setOpacity(opacity);
}
void MapView::moveOverlays(int deltaX, int deltaY) {
foreach (Overlay * overlay, this->overlayMap)
overlay->move(deltaX, deltaY);

View File

@@ -26,6 +26,7 @@ void OverlayImage::render(QPainter *painter, int x, int y) {
void Overlay::renderItems(QPainter *painter) {
if (this->hidden) return;
painter->setOpacity(this->opacity);
for (auto item : this->items)
item->render(painter, this->x, this->y);
}
@@ -49,6 +50,18 @@ void Overlay::setHidden(bool hidden) {
this->hidden = hidden;
}
int Overlay::getOpacity() {
return this->opacity * 100;
}
void Overlay::setOpacity(int opacity) {
if (opacity < 0 || opacity > 100) {
logError(QString("Invalid overlay opacity '%1'").arg(opacity));
return;
}
this->opacity = static_cast<qreal>(opacity) / 100;
}
int Overlay::getX() {
return this->x;
}