diff --git a/launcher/lobby/lobby_moc.cpp b/launcher/lobby/lobby_moc.cpp index 727cbcab1..d145b5240 100644 --- a/launcher/lobby/lobby_moc.cpp +++ b/launcher/lobby/lobby_moc.cpp @@ -41,10 +41,12 @@ Lobby::Lobby(QWidget *parent) : QString hostString("%1:%2"); hostString = hostString.arg(QString::fromStdString(settings["launcher"]["lobbyUrl"].String())); hostString = hostString.arg(settings["launcher"]["lobbyPort"].Integer()); - + namesCompleter.setModel(ui->listUsers->model()); + namesCompleter.setCompletionMode(QCompleter::InlineCompletion); ui->serverEdit->setText(hostString); ui->userEdit->setText(QString::fromStdString(settings["launcher"]["lobbyUsername"].String())); ui->kickButton->setVisible(false); + ui->messageEdit->setCompleter(&namesCompleter); } void Lobby::changeEvent(QEvent *event) @@ -151,6 +153,7 @@ void Lobby::serverCommand(const ServerCommand & command) try case JOINED: case KICKED: protocolAssert(args.size() == 2); + session = ""; joinStr = (command.command == JOINED ? "%1 joined to the session %2" : "%1 left session %2"); if(args[1] == username) @@ -261,7 +264,7 @@ void Lobby::serverCommand(const ServerCommand & command) try ui->listUsers->clear(); for(int i = 0; i < amount; ++i) { - ui->listUsers->addItem(new QListWidgetItem(args[i + 1])); + ui->listUsers->addItem(new QListWidgetItem("@" + args[i + 1])); } break; } @@ -322,6 +325,7 @@ catch(const ProtocolError & e) void Lobby::onDisconnected() { authentificationStatus = AuthStatus::AUTH_NONE; + session = ""; ui->stackedWidget->setCurrentWidget(ui->sessionsPage); ui->connectButton->setChecked(false); ui->serverEdit->setEnabled(true); @@ -342,7 +346,12 @@ void Lobby::chatMessage(QString title, QString body, bool isSystem) curs.movePosition(QTextCursor::End); curs.insertText(title + ": ", fmtTitle); curs.insertText(body + "\n", fmtBody); - ui->chat->ensureCursorVisible(); + + if(ui->chat->verticalScrollBar()->maximum() - ui->chat->verticalScrollBar()->value() > 32) + { + ui->chat->ensureCursorVisible(); + ui->chat->verticalScrollBar()->setValue(ui->chat->verticalScrollBar()->maximum()); + } } void Lobby::sysMessage(QString body) @@ -564,3 +573,9 @@ void Lobby::on_optLoadGame_toggled(bool checked) } } + +void Lobby::on_chatSwither_clicked() +{ + isGlobalChat = session.isEmpty() ? true : !isGlobalChat; + ui->chatSwither->setText(isGlobalChat ? tr("Global chat") : tr("Room chat")); +} diff --git a/launcher/lobby/lobby_moc.h b/launcher/lobby/lobby_moc.h index c372b6204..9ec5b26cc 100644 --- a/launcher/lobby/lobby_moc.h +++ b/launcher/lobby/lobby_moc.h @@ -64,6 +64,8 @@ private slots: void on_optLoadGame_toggled(bool checked); + void on_chatSwither_clicked(); + private: QString serverUrl; int serverPort; @@ -76,6 +78,7 @@ private: QString username; QStringList gameArgs; QMap hostModsMap; + QCompleter namesCompleter; enum AuthStatus { @@ -83,6 +86,9 @@ private: }; AuthStatus authentificationStatus = AUTH_NONE; + + bool isGlobalChat = true; + std::chrono::time_point lastTimePointScrollBar; private: QMap buildModsMap() const; diff --git a/launcher/lobby/lobby_moc.ui b/launcher/lobby/lobby_moc.ui index 8001d3c8a..23574507c 100644 --- a/launcher/lobby/lobby_moc.ui +++ b/launcher/lobby/lobby_moc.ui @@ -71,11 +71,25 @@ 0 - - - Players in lobby + + + 0 - + + + + Users in chat + + + + + + + Global chat + + + + @@ -109,22 +123,18 @@ - + + + + - Lobby chat + + + + type you message - - - - true - - - - - -