File indexing completed on 2024-02-18 04:03:23

0001 /*
0002     SPDX-FileCopyrightText: 2009 Mathias Kraus <k.hias@gmx.de>
0003     SPDX-FileCopyrightText: 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
0004     SPDX-FileCopyrightText: 2007-2008 Pierre-BenoƮt Besse <besse.pb@gmail.com>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #include "arenaitem.h"
0010 #include "granatierglobals.h"
0011 
0012 #include <QGraphicsView>
0013 #include <KGameRenderer>
0014 
0015 ArenaItem::ArenaItem(qreal p_x, qreal p_y, KGameRenderer* renderer, const QString& spriteKey) : KGameRenderedItem(renderer, spriteKey)
0016 {
0017     // Init the view coordinates
0018     setPos(p_x, p_y);
0019 }
0020 
0021 ArenaItem::~ArenaItem()
0022 = default;
0023 
0024 void ArenaItem::updateGraphics(qreal svgScaleFactor)
0025 {
0026     if(scene()->views().isEmpty())
0027     {
0028         return;
0029     }
0030 
0031     QPoint topLeft = scene()->views().first()->mapFromScene(0, 0);
0032     QPoint bottomRight = scene()->views().first()->mapFromScene(Granatier::CellSize, Granatier::CellSize);
0033 
0034     int width = bottomRight.x() - topLeft.x();
0035     int height = bottomRight.y() - topLeft.y();
0036 
0037     setRenderSize(QSize(width, height));
0038     setScale(svgScaleFactor);
0039 }
0040 
0041 #include "moc_arenaitem.cpp"