mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-28 10:56:38 -05:00
Add opacity to scripting overlay
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user