70 lblCaption->setWordWrap(true); |
71 lblCaption->setWordWrap(true); |
71 lblDescription = new QLabel(); |
72 lblDescription = new QLabel(); |
72 lblDescription->setMinimumWidth(360); |
73 lblDescription->setMinimumWidth(360); |
73 lblDescription->setAlignment(Qt::AlignHCenter | Qt::AlignTop); |
74 lblDescription->setAlignment(Qt::AlignHCenter | Qt::AlignTop); |
74 lblDescription->setWordWrap(true); |
75 lblDescription->setWordWrap(true); |
|
76 lblHighscores = new QLabel(); |
|
77 lblHighscores->setMinimumWidth(360); |
|
78 lblHighscores->setAlignment(Qt::AlignHCenter | Qt::AlignTop); |
75 |
79 |
76 infoTextLayout->addWidget(lblCaption); |
80 infoTextLayout->addWidget(lblCaption); |
77 infoTextLayout->addWidget(lblDescription); |
81 infoTextLayout->addWidget(lblDescription); |
|
82 infoTextLayout->addWidget(lblHighscores); |
78 |
83 |
79 infoLayout->addWidget(infoTextWidget); |
84 infoLayout->addWidget(infoTextWidget); |
80 |
85 |
81 pageLayout->addWidget(infoWidget, 0, 1, 1, 2); // span 2 columns |
86 pageLayout->addWidget(infoWidget, 0, 1, 1, 2); // span 2 columns |
82 pageLayout->setAlignment(infoTextWidget, Qt::AlignLeft); |
87 pageLayout->setAlignment(infoTextWidget, Qt::AlignLeft); |
86 tbw = new QTabWidget(this); |
91 tbw = new QTabWidget(this); |
87 pageLayout->addWidget(tbw, 1, 0, 1, 4); // span 4 columns |
92 pageLayout->addWidget(tbw, 1, 0, 1, 4); // span 4 columns |
88 // let's not make the tab widget use more space than needed |
93 // let's not make the tab widget use more space than needed |
89 tbw->setFixedWidth(400); |
94 tbw->setFixedWidth(400); |
90 pageLayout->setAlignment(tbw, Qt::AlignHCenter); |
95 pageLayout->setAlignment(tbw, Qt::AlignHCenter); |
91 |
96 |
92 tbw->setStyleSheet("QListWidget { border-style: none; padding-top: 6px; }"); |
97 tbw->setStyleSheet("QListWidget { border-style: none; padding-top: 6px; }"); |
93 |
98 |
94 // training/challenge/scenario lists |
99 // training/challenge/scenario lists |
95 lstTrainings = new QListWidget(this); |
100 lstTrainings = new QListWidget(this); |
96 lstTrainings ->setWhatsThis(tr("Pick the training to play")); |
101 lstTrainings ->setWhatsThis(tr("Pick the training to play")); |
312 QListWidget *list; |
317 QListWidget *list; |
313 subFolder = getSubFolderOfSelected(); |
318 subFolder = getSubFolderOfSelected(); |
314 list = (QListWidget*) tbw->currentWidget(); |
319 list = (QListWidget*) tbw->currentWidget(); |
315 if (list->currentItem()) |
320 if (list->currentItem()) |
316 { |
321 { |
|
322 QString missionName = list->currentItem()->data(Qt::UserRole).toString(); |
317 QString thumbFile = "physfs://Graphics/Missions/" + |
323 QString thumbFile = "physfs://Graphics/Missions/" + |
318 subFolder + "/" + |
324 subFolder + "/" + |
319 list->currentItem()->data(Qt::UserRole).toString() + |
325 missionName + |
320 "@2x.png"; |
326 "@2x.png"; |
321 |
327 |
322 if (QFile::exists(thumbFile)) |
328 if (QFile::exists(thumbFile)) |
323 btnPreview->setIcon(QIcon(thumbFile)); |
329 btnPreview->setIcon(QIcon(thumbFile)); |
324 else if (tbw->currentWidget() == lstChallenges) |
330 else if (tbw->currentWidget() == lstChallenges) |
329 else |
335 else |
330 btnPreview->setIcon(QIcon(":/res/Trainings.png")); |
336 btnPreview->setIcon(QIcon(":/res/Trainings.png")); |
331 |
337 |
332 btnPreview->setWhatsThis(tr("Start fighting")); |
338 btnPreview->setWhatsThis(tr("Start fighting")); |
333 |
339 |
334 QString realName = list->currentItem()->data( |
340 QString caption = m_info->value(missionName + ".name", |
335 Qt::UserRole).toString(); |
|
336 |
|
337 QString caption = m_info->value(realName + ".name", |
|
338 list->currentItem()->text()).toString(); |
341 list->currentItem()->text()).toString(); |
339 |
342 |
340 QString description = m_info->value(realName + ".desc", |
343 QString description = m_info->value(missionName + ".desc", |
341 tr("No description available")).toString(); |
344 tr("No description available")).toString(); |
342 |
345 |
343 lblCaption->setText("<h2>" + caption +"</h2>"); |
346 lblCaption->setText("<h2>" + caption +"</h2>"); |
344 lblDescription->setText(description); |
347 lblDescription->setText(description); |
|
348 |
|
349 // Challenge highscores |
|
350 QString highscoreText = QString(""); |
|
351 QString teamName = CBTeam->currentText(); |
|
352 if (missionValueExists(missionName, teamName, "Highscore")) |
|
353 //: Highest score of a team |
|
354 highscoreText = highscoreText + tr("Team highscore: %1").arg(getMissionValue(missionName, teamName, "Highscore").toString()) + "\n"; |
|
355 if (missionValueExists(missionName, teamName, "Lowscore")) |
|
356 //: Lowest score of a team |
|
357 highscoreText = highscoreText + tr("Team lowscore: %1").arg(getMissionValue(missionName, teamName, "Lowscore").toString()) + "\n"; |
|
358 if (missionValueExists(missionName, teamName, "TimeRecord")) |
|
359 { |
|
360 double time = ((double) getMissionValue(missionName, teamName, "TimeRecord").toInt()) / 1000.0; |
|
361 highscoreText = highscoreText + tr("Team's best time: %L1 s").arg(time, 0, 'f', 3) + "\n"; |
|
362 } |
|
363 if (missionValueExists(missionName, teamName, "TimeRecordHigh")) |
|
364 { |
|
365 double time = ((double) getMissionValue(missionName, teamName, "TimeRecordHigh").toInt()) / 1000.0; |
|
366 highscoreText = highscoreText + tr("Team's longest time: %L1 s").arg(time, 0, 'f', 3) + "\n"; |
|
367 } |
|
368 |
|
369 lblHighscores->setText(highscoreText); |
345 } |
370 } |
346 else |
371 else |
347 { |
372 { |
348 btnPreview->setIcon(QIcon(":/res/Trainings.png")); |
373 btnPreview->setIcon(QIcon(":/res/Trainings.png")); |
349 lblCaption->setText(tr("Select a mission!")); |
374 lblCaption->setText(tr("Select a mission!")); |
350 // TODO better text and tr() |
|
351 lblDescription->setText(""); |
375 lblDescription->setText(""); |
|
376 lblHighscores->setText(""); |
352 } |
377 } |
353 } |
378 } |
354 } |
379 } |