2019-11-11 07:19:06 -05:00
|
|
|
/****************************************
|
|
|
|
*
|
|
|
|
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
|
|
|
* Copyright (C) 2019 Victor Tran
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* *************************************/
|
|
|
|
#include "onlinemenuscreen.h"
|
|
|
|
#include "ui_onlinemenuscreen.h"
|
|
|
|
|
2019-11-12 01:51:58 -05:00
|
|
|
#include <QJsonObject>
|
|
|
|
#include "onlinecontroller.h"
|
2019-11-11 07:19:06 -05:00
|
|
|
#include <online/friendsdialog.h>
|
2019-11-14 07:44:34 -05:00
|
|
|
#include <online/accountdialog.h>
|
2019-11-11 07:19:06 -05:00
|
|
|
|
|
|
|
OnlineMenuScreen::OnlineMenuScreen(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::OnlineMenuScreen)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
this->setFocusProxy(ui->createLobby);
|
|
|
|
|
2019-11-14 07:44:34 -05:00
|
|
|
ui->exitButton->setProperty("type", "destructive");
|
|
|
|
|
2019-11-11 07:19:06 -05:00
|
|
|
ui->gamepadHud->setButtonText(QGamepadManager::ButtonA, tr("Select"));
|
|
|
|
ui->gamepadHud->setButtonText(QGamepadManager::ButtonB, tr("Main Menu"));
|
|
|
|
|
|
|
|
ui->gamepadHud->setButtonAction(QGamepadManager::ButtonA, GamepadHud::standardAction(GamepadHud::SelectAction));
|
|
|
|
ui->gamepadHud->setButtonAction(QGamepadManager::ButtonB, [=] {
|
|
|
|
ui->exitButton->click();
|
|
|
|
});
|
|
|
|
|
|
|
|
ui->focusBarrierTop->setBounceWidget(ui->createLobby);
|
|
|
|
ui->focusBarrierBottom->setBounceWidget(ui->exitButton);
|
2019-11-12 09:56:48 -05:00
|
|
|
|
|
|
|
QPalette pal = ui->stackedWidget->palette();
|
|
|
|
pal.setColor(QPalette::Window, Qt::transparent);
|
|
|
|
ui->stackedWidget->setPalette(pal);
|
2019-11-11 07:19:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
OnlineMenuScreen::~OnlineMenuScreen()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnlineMenuScreen::on_exitButton_clicked()
|
|
|
|
{
|
|
|
|
emit quitOnline();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnlineMenuScreen::on_friendsButton_clicked()
|
|
|
|
{
|
|
|
|
FriendsDialog* d = new FriendsDialog(this);
|
|
|
|
connect(d, &FriendsDialog::done, d, &FriendsDialog::deleteLater);
|
|
|
|
}
|
2019-11-12 01:51:58 -05:00
|
|
|
|
|
|
|
void OnlineMenuScreen::on_createLobby_clicked()
|
|
|
|
{
|
|
|
|
//Request to join a new room
|
|
|
|
OnlineController::instance()->sendJsonO({
|
|
|
|
{"type", "createRoom"}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnlineMenuScreen::on_joinLobby_clicked()
|
|
|
|
{
|
|
|
|
//Request the list of available rooms
|
|
|
|
OnlineController::instance()->sendJsonO({
|
|
|
|
{"type", "availableRooms"}
|
|
|
|
});
|
|
|
|
}
|
2019-11-14 07:44:34 -05:00
|
|
|
|
|
|
|
void OnlineMenuScreen::on_accountButton_clicked()
|
|
|
|
{
|
|
|
|
AccountDialog* d = new AccountDialog(this);
|
|
|
|
connect(d, &AccountDialog::done, d, &AccountDialog::deleteLater);
|
|
|
|
}
|