mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Merge pull request #3948 from IvanSavenko/lobby_ui_fix
[1.5.1] Fixes for lobby UI
This commit is contained in:
commit
c898d16458
@ -144,6 +144,9 @@ void GlobalLobbyClient::receiveChatHistory(const JsonNode & json)
|
||||
if(lobbyWindowPtr && lobbyWindowPtr->isChannelOpen(channelType, channelName))
|
||||
lobbyWindowPtr->onGameChatMessage(message.displayName, message.messageText, message.timeFormatted, channelType, channelName);
|
||||
}
|
||||
|
||||
if(lobbyWindowPtr && lobbyWindowPtr->isChannelOpen(channelType, channelName))
|
||||
lobbyWindowPtr->refreshChatText();
|
||||
}
|
||||
|
||||
void GlobalLobbyClient::receiveChatMessage(const JsonNode & json)
|
||||
@ -163,9 +166,13 @@ void GlobalLobbyClient::receiveChatMessage(const JsonNode & json)
|
||||
|
||||
auto lobbyWindowPtr = lobbyWindow.lock();
|
||||
if(lobbyWindowPtr)
|
||||
{
|
||||
lobbyWindowPtr->onGameChatMessage(message.displayName, message.messageText, message.timeFormatted, channelType, channelName);
|
||||
lobbyWindowPtr->refreshChatText();
|
||||
|
||||
CCS->soundh->playSound(AudioPath::builtin("CHAT"));
|
||||
if(channelType == "player" || lobbyWindowPtr->isChannelOpen(channelType, channelName))
|
||||
CCS->soundh->playSound(AudioPath::builtin("CHAT"));
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalLobbyClient::receiveActiveAccounts(const JsonNode & json)
|
||||
@ -270,6 +277,7 @@ void GlobalLobbyClient::receiveInviteReceived(const JsonNode & json)
|
||||
|
||||
lobbyWindowPtr->onGameChatMessage("System", message, time, "player", accountID);
|
||||
lobbyWindowPtr->onInviteReceived(gameRoomID);
|
||||
lobbyWindowPtr->refreshChatText();
|
||||
}
|
||||
|
||||
CCS->soundh->playSound(AudioPath::builtin("CHAT"));
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../gui/WindowHandler.h"
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "../widgets/Slider.h"
|
||||
#include "../widgets/ObjectLists.h"
|
||||
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
#include "../../lib/Languages.h"
|
||||
#include "../../lib/MetaString.h"
|
||||
#include "../../lib/TextOperations.h"
|
||||
@ -51,13 +51,14 @@ void GlobalLobbyWindow::doOpenChannel(const std::string & channelType, const std
|
||||
currentChannelName = channelName;
|
||||
chatHistory.clear();
|
||||
unreadChannels.erase(channelType + "_" + channelName);
|
||||
widget->getGameChat()->setText("");
|
||||
|
||||
auto history = CSH->getGlobalLobby().getChannelHistory(channelType, channelName);
|
||||
|
||||
for(const auto & entry : history)
|
||||
onGameChatMessage(entry.displayName, entry.messageText, entry.timeFormatted, channelType, channelName);
|
||||
|
||||
refreshChatText();
|
||||
|
||||
MetaString text;
|
||||
text.appendTextID("vcmi.lobby.header.chat." + channelType);
|
||||
text.replaceRawString(roomDescription);
|
||||
@ -133,8 +134,12 @@ void GlobalLobbyWindow::onGameChatMessage(const std::string & sender, const std:
|
||||
chatMessageFormatted.replaceRawString(message);
|
||||
|
||||
chatHistory += chatMessageFormatted.toString();
|
||||
|
||||
}
|
||||
void GlobalLobbyWindow::refreshChatText()
|
||||
{
|
||||
widget->getGameChat()->setText(chatHistory);
|
||||
if (widget->getGameChat()->slider)
|
||||
widget->getGameChat()->slider->scrollToMax();
|
||||
}
|
||||
|
||||
bool GlobalLobbyWindow::isChannelUnread(const std::string & channelType, const std::string & channelName) const
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
// Callbacks for network packs
|
||||
|
||||
void onGameChatMessage(const std::string & sender, const std::string & message, const std::string & when, const std::string & channelType, const std::string & channelName);
|
||||
void refreshChatText();
|
||||
void onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts);
|
||||
void onActiveRooms(const std::vector<GlobalLobbyRoom> & rooms);
|
||||
void onMatchesHistory(const std::vector<GlobalLobbyRoom> & history);
|
||||
|
@ -409,6 +409,7 @@ void CTextBox::setText(const std::string & text)
|
||||
{
|
||||
// slider is no longer needed
|
||||
slider.reset();
|
||||
label->scrollTextTo(0);
|
||||
}
|
||||
else if(slider)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user