40 |
40 |
41 QLayout * PageGameStats::bodyLayoutDefinition() |
41 QLayout * PageGameStats::bodyLayoutDefinition() |
42 { |
42 { |
43 kindOfPoints = QString(""); |
43 kindOfPoints = QString(""); |
44 defaultGraphTitle = true; |
44 defaultGraphTitle = true; |
45 QGridLayout * pageLayout = new QGridLayout(); |
45 pageLayout = new QGridLayout(); |
46 pageLayout->setSpacing(20); |
|
47 pageLayout->setColumnStretch(0, 1); |
|
48 pageLayout->setColumnStretch(1, 1); |
|
49 pageLayout->setRowStretch(0, 1); |
46 pageLayout->setRowStretch(0, 1); |
50 pageLayout->setRowStretch(1, 20); |
47 pageLayout->setRowStretch(1, 20); |
51 //pageLayout->setRowStretch(1, -1); this should work but there is unnecessary empty space betwin lines if used |
48 pageLayout->setVerticalSpacing(20); |
52 pageLayout->setContentsMargins(7, 7, 7, 0); |
49 pageLayout->setContentsMargins(7, 7, 7, 0); |
53 |
50 |
54 QGroupBox * gb = new QGroupBox(this); |
51 gbDetails = new QGroupBox(this); |
|
52 gbDetails->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
55 QVBoxLayout * gbl = new QVBoxLayout; |
53 QVBoxLayout * gbl = new QVBoxLayout; |
56 |
54 |
57 // details |
55 // details |
58 labelGameStats = new QLabel(this); |
56 labelGameStats = new QLabel(this); |
59 QLabel * l = new QLabel(this); |
57 labelDetails = new QLabel(this); |
60 l->setTextFormat(Qt::RichText); |
58 labelDetails->setTextFormat(Qt::RichText); |
61 l->setText("<h1><img src=\":/res/StatsD.png\"> " + PageGameStats::tr("Details").toHtmlEscaped() + "</h1>"); |
59 labelDetails->setText("<h1><img src=\":/res/StatsD.png\"> " + PageGameStats::tr("Details").toHtmlEscaped() + "</h1>"); |
62 l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
60 labelDetails->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
63 labelGameStats->setTextFormat(Qt::RichText); |
61 labelGameStats->setTextFormat(Qt::RichText); |
64 labelGameStats->setAlignment(Qt::AlignTop); |
62 labelGameStats->setAlignment(Qt::AlignTop); |
65 labelGameStats->setWordWrap(true); |
63 labelGameStats->setWordWrap(true); |
66 gbl->addWidget(l); |
64 gbl->addWidget(labelDetails); |
67 gbl->addWidget(labelGameStats); |
65 gbl->addWidget(labelGameStats); |
68 gb->setLayout(gbl); |
66 gbDetails->setLayout(gbl); |
69 pageLayout->addWidget(gb, 1, 1); |
67 pageLayout->addWidget(gbDetails, 1, 1); |
70 |
68 |
71 // graph |
69 // graph |
72 graphic = new FitGraphicsView(gb); |
70 graphic = new FitGraphicsView(gbDetails); |
73 graphic->setObjectName("gameStatsView"); |
71 graphic->setObjectName("gameStatsView"); |
74 labelGraphTitle = new QLabel(this); |
72 labelGraphTitle = new QLabel(this); |
75 labelGraphTitle->setTextFormat(Qt::RichText); |
73 labelGraphTitle->setTextFormat(Qt::RichText); |
76 labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph").toHtmlEscaped() + "</h1>"); |
74 labelGraphTitle->setText("<h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph").toHtmlEscaped() + "</h1>"); |
77 labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
75 labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
78 gbl->addWidget(labelGraphTitle); |
76 gbl->addWidget(labelGraphTitle); |
79 gbl->addWidget(graphic); |
77 gbl->addWidget(graphic); |
80 graphic->scale(1.0, -1.0); |
78 graphic->scale(1.0, -1.0); |
81 graphic->setBackgroundBrush(QBrush(Qt::black)); |
79 graphic->setBackgroundBrush(QBrush(Qt::black)); |
84 labelGameWin = new QLabel(this); |
82 labelGameWin = new QLabel(this); |
85 labelGameWin->setTextFormat(Qt::RichText); |
83 labelGameWin->setTextFormat(Qt::RichText); |
86 pageLayout->addWidget(labelGameWin, 0, 0, 1, 2); |
84 pageLayout->addWidget(labelGameWin, 0, 0, 1, 2); |
87 |
85 |
88 // ranking box |
86 // ranking box |
89 gb = new QGroupBox(this); |
87 gbRanks = new QGroupBox(this); |
|
88 gbRanks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
90 gbl = new QVBoxLayout; |
89 gbl = new QVBoxLayout; |
91 labelGameRank = new QLabel(gb); |
90 labelGameRank = new QLabel(gbRanks); |
92 l = new QLabel(this); |
91 QLabel* l = new QLabel(this); |
93 l->setTextFormat(Qt::RichText); |
92 l->setTextFormat(Qt::RichText); |
94 l->setText("<h1><img src=\":/res/StatsR.png\"> " + PageGameStats::tr("Ranking").toHtmlEscaped() + "</h1>"); |
93 l->setText("<h1><img src=\":/res/StatsR.png\"> " + PageGameStats::tr("Ranking").toHtmlEscaped() + "</h1>"); |
95 l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
94 l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
96 gbl->addWidget(l); |
95 gbl->addWidget(l); |
97 gbl->addWidget(labelGameRank); |
96 gbl->addWidget(labelGameRank); |
98 gb->setLayout(gbl); |
97 gbRanks->setLayout(gbl); |
99 |
98 |
100 labelGameRank->setTextFormat(Qt::RichText); |
99 labelGameRank->setTextFormat(Qt::RichText); |
101 labelGameRank->setAlignment(Qt::AlignTop); |
100 labelGameRank->setAlignment(Qt::AlignTop); |
102 pageLayout->addWidget(gb, 1, 0); |
101 pageLayout->addWidget(gbRanks, 1, 0); |
103 |
102 |
104 return pageLayout; |
103 return pageLayout; |
105 } |
104 } |
106 |
105 |
107 //TODO button placement, image etc |
106 //TODO button placement, image etc |
152 labelGameRank->setText(""); |
154 labelGameRank->setText(""); |
153 labelGameWin->setText(""); |
155 labelGameWin->setText(""); |
154 playerPosition = 0; |
156 playerPosition = 0; |
155 scriptPlayerPosition = 0; |
157 scriptPlayerPosition = 0; |
156 lastColor = 0; |
158 lastColor = 0; |
|
159 graphic->hide(); |
|
160 labelDetails->hide(); |
|
161 labelGameStats->hide(); |
|
162 gbDetails->hide(); |
|
163 gbRanks->hide(); |
|
164 pageLayout->setColumnStretch(0, 0); |
|
165 pageLayout->setColumnStretch(1, 0); |
|
166 pageLayout->setHorizontalSpacing(0); |
157 } |
167 } |
158 |
168 |
159 void PageGameStats::restartBtnVisible(bool visible) |
169 void PageGameStats::restartBtnVisible(bool visible) |
160 { |
170 { |
161 btnRestart->setVisible(visible); |
171 btnRestart->setVisible(visible); |
162 } |
172 } |
163 |
173 |
164 void PageGameStats::renderStats() |
174 void PageGameStats::renderStats() |
165 { |
175 { |
166 if(defaultGraphTitle) { |
176 if(defaultGraphTitle) { |
167 labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph").toHtmlEscaped() + "</h1>"); |
177 labelGraphTitle->setText("<h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph").toHtmlEscaped() + "</h1>"); |
168 } else { |
178 } else { |
169 defaultGraphTitle = true; |
179 defaultGraphTitle = true; |
170 } |
180 } |
171 // if not health data sent |
181 // if not health data sent |
172 if(healthPoints.size() == 0) { |
182 if(healthPoints.size() == 0) { |
173 labelGraphTitle->hide(); |
183 labelGraphTitle->hide(); |
174 graphic->hide(); |
184 graphic->hide(); |
175 } else { |
185 } else { |
176 graphic->setScene(Q_NULLPTR); |
186 graphic->setScene(Q_NULLPTR); |
|
187 gbDetails->show(); |
177 m_scene.reset(new QGraphicsScene(this)); |
188 m_scene.reset(new QGraphicsScene(this)); |
178 |
189 |
179 // min and max value across the entire chart |
190 // min and max value across the entire chart |
180 qint32 minValue = 0; |
191 qint32 minValue = 0; |
181 qint32 maxValue = 0; |
192 qint32 maxValue = 0; |