Skip to content

Commit c58b3a5

Browse files
author
rueter37
committed
Database: Fix actor stat curve display
The lower section of the actor stat curves was cut off, you could notice it if the stat was about 50 or less on that level. This is fixed now.
1 parent db36fd8 commit c58b3a5

File tree

3 files changed

+41
-24
lines changed

3 files changed

+41
-24
lines changed

src/ui/database/actor_widget.cpp

+25-23
Original file line numberDiff line numberDiff line change
@@ -51,38 +51,37 @@ ActorWidget::ActorWidget(ProjectData& project, QWidget *parent) :
5151
m_dummyCurve.push_back(0);
5252
m_hpItem = new CurveItem(Qt::red, m_dummyCurve);
5353
m_hpItem->setMaxValue(kMaxHp);
54+
m_hpItem->setMaxLevel(kMaxLevel);
5455
m_mpItem = new CurveItem(Qt::magenta, m_dummyCurve);
56+
m_mpItem->setMaxLevel(kMaxLevel);
5557
m_attItem = new CurveItem(Qt::yellow, m_dummyCurve);
58+
m_attItem->setMaxLevel(kMaxLevel);
5659
m_defItem = new CurveItem(Qt::green, m_dummyCurve);
60+
m_defItem->setMaxLevel(kMaxLevel);
5761
m_intItem = new CurveItem(Qt::darkBlue, m_dummyCurve);
62+
m_intItem->setMaxLevel(kMaxLevel);
5863
m_agyItem = new CurveItem(Qt::blue, m_dummyCurve);
64+
m_agyItem->setMaxLevel(kMaxLevel);
5965

6066
ui->graphicsBattleset->setScene(new QGraphicsScene(this));
6167
ui->graphicsBattleset->scene()->addItem(m_battlerItem);
6268
ui->graphicsBattleset->scene()->setSceneRect(0,0,48,48);
6369

64-
ui->graphicsHp->setScene(new QGraphicsScene(this));
65-
ui->graphicsHp->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsHp->size()));
70+
for (auto& uis : {
71+
ui->graphicsHp,
72+
ui->graphicsMp,
73+
ui->graphicsAtt,
74+
ui->graphicsDef,
75+
ui->graphicsInt,
76+
ui->graphicsAgy }) {
77+
uis->setScene(new QGraphicsScene(this));
78+
uis->scene()->setSceneRect(QRectF(QPointF(0, 0), QSize(uis->size().width() - 4, uis->size().height() - 4)));
79+
}
6680
ui->graphicsHp->scene()->addItem(m_hpItem);
67-
68-
ui->graphicsMp->setScene(new QGraphicsScene(this));
69-
ui->graphicsMp->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsMp->size()));
7081
ui->graphicsMp->scene()->addItem(m_mpItem);
71-
72-
ui->graphicsAtt->setScene(new QGraphicsScene(this));
73-
ui->graphicsAtt->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsAtt->size()));
7482
ui->graphicsAtt->scene()->addItem(m_attItem);
75-
76-
ui->graphicsDef->setScene(new QGraphicsScene(this));
77-
ui->graphicsDef->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsDef->size()));
7883
ui->graphicsDef->scene()->addItem(m_defItem);
79-
80-
ui->graphicsInt->setScene(new QGraphicsScene(this));
81-
ui->graphicsInt->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsInt->size()));
8284
ui->graphicsInt->scene()->addItem(m_intItem);
83-
84-
ui->graphicsAgy->setScene(new QGraphicsScene(this));
85-
ui->graphicsAgy->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsAgy->size()));
8685
ui->graphicsAgy->scene()->addItem(m_agyItem);
8786

8887
UpdateModels();
@@ -344,12 +343,15 @@ void ActorWidget::on_pushApplyProfession_clicked()
344343
void ActorWidget::resizeEvent(QResizeEvent *event)
345344
{
346345
Q_UNUSED(event)
347-
ui->graphicsHp->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsHp->size()));
348-
ui->graphicsMp->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsMp->size()));
349-
ui->graphicsAtt->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsAtt->size()));
350-
ui->graphicsDef->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsDef->size()));
351-
ui->graphicsInt->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsInt->size()));
352-
ui->graphicsAgy->scene()->setSceneRect(QRectF(QPointF(0,0),ui->graphicsAgy->size()));
346+
for (auto& uis : {
347+
ui->graphicsHp,
348+
ui->graphicsMp,
349+
ui->graphicsAtt,
350+
ui->graphicsDef,
351+
ui->graphicsInt,
352+
ui->graphicsAgy }) {
353+
uis->scene()->setSceneRect(QRectF(QPointF(0, 0), QSize(uis->size().width() - 4, uis->size().height() - 4)));
354+
}
353355
}
354356

355357
void ActorWidget::faceSetClicked() {

src/ui/viewer/stat_curve_graphics_item.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ CurveItem::CurveItem(QColor color, std::vector<int16_t> &data, QGraphicsItem *pa
2424
{
2525
m_color = color;
2626
m_maxValue = 999.0;
27+
m_maxLevel = 50.0;
2728
}
2829

2930
QRectF CurveItem::boundingRect() const
@@ -46,7 +47,7 @@ void CurveItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
4647
QVector<QPointF> p;
4748
p.append(r.bottomLeft());
4849
for (size_t i = 0; i < m_data.size(); i++)
49-
p.append(QPointF((static_cast<qreal>(i)*r.width())/99.0,
50+
p.append(QPointF((static_cast<qreal>(i)*r.width())/(m_maxLevel - 1.0),
5051
r.height()-r.height()*static_cast<qreal>(m_data[i])/m_maxValue));
5152
p.append(r.bottomRight());
5253

@@ -72,5 +73,15 @@ void CurveItem::setMaxValue(const qreal &maxValue)
7273
m_maxValue = maxValue;
7374
}
7475

76+
qreal CurveItem::maxLevel() const
77+
{
78+
return m_maxLevel;
79+
}
80+
81+
void CurveItem::setMaxLevel(const qreal &maxLevel)
82+
{
83+
m_maxLevel = maxLevel;
84+
}
85+
7586

7687

src/ui/viewer/stat_curve_graphics_item.h

+4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ class CurveItem : public QGraphicsItem
3535
qreal maxValue() const;
3636
void setMaxValue(const qreal &maxValue);
3737

38+
qreal maxLevel() const;
39+
void setMaxLevel(const qreal &maxLevel);
40+
3841
private:
3942
std::vector<int16_t> m_data;
4043
QColor m_color;
4144
qreal m_maxValue;
45+
qreal m_maxLevel;
4246
};
4347

0 commit comments

Comments
 (0)