1#include "sessionview.h"
2#include "ui_sessionview.h"
4SessionView::SessionView(QWidget *parent)
7 connect(ui->roleComboBox, SIGNAL(currentIndexChanged(
int)),
this,
8 SLOT(repeaterCurrentIndexChanged(
int)));
11SessionView::~SessionView() {
15void SessionView::repeaterCurrentIndexChanged(
int index) {
16 if (index == -1 || ui->roleComboBox->itemData(index).toInt() == ourRole) {
21 qDebug() <<
"Got new role index: "
22 << ui->roleComboBox->itemData(index).toInt();
23 emit newRoleChosen(ui->roleComboBox->itemData(index).toInt());
26void SessionView::updateStatus(CreatingGameStatus newStatus) {
27 ui->statusLabel->setText(STATUS.at(newStatus));
28 ui->currentPlayersHLabel->setHidden(newStatus != CreatingGameStatus::DONE);
29 ui->playersListWidget->setHidden(newStatus != CreatingGameStatus::DONE);
32void SessionView::updateSessionInfo(
const SessionInfo &sessionInfo) {
33 ui->playersListWidget->clear();
34 for (
const auto &player : sessionInfo.players) {
35 ui->playersListWidget->addItem(player.user.display_name);
37 if (sessionInfo.isHost) {
42 if (sessionInfo.status == SessionInfo::Status::RUNNING) {
44 emit joinedCreatedGame();
48void SessionView::updateValidationResult(
50 ui->startGameButton->setEnabled(validationResult.success);
51 ui->joinErrorLabel->setText(validationResult.message);
54void SessionView::on_startGameButton_clicked() {
58void SessionView::clear() {
59 ui->currentPlayersHLabel->hide();
60 ui->playersListWidget->hide();
62 ui->gameNameLabel->setText(
"Unknown");
65void SessionView::on_backButton_clicked() {
68 qDebug() <<
"Pressed Back From Session";
72void SessionView::updateGameName(
const QString &gameName) {
73 ui->gameNameLabel->setText(gameName);
75void SessionView::gotRolesListUpdate(
const std::vector<Role> &newRolesList) {
79 ourRole = newRolesList.front().id;
80 ui->roleComboBox->clear();
81 for (
const auto &roleIdAndName : newRolesList) {
82 ui->roleComboBox->addItem(roleIdAndName.name, roleIdAndName.id);
84 if (ui->roleComboBox->count() > 0) {
85 ui->roleComboBox->setCurrentIndex(0);
87 ui->roleComboBox->setCurrentIndex(-1);
90void SessionView::show_as_host() {
91 ui->waitForHostLabel->hide();
92 ui->joinErrorLabel->show();
93 ui->startGameButton->show();
95void SessionView::show_as_guest() {
96 ui->waitForHostLabel->show();
97 ui->joinErrorLabel->hide();
98 ui->startGameButton->hide();