mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Update list of player in invite window on new player or new invite
This commit is contained in:
parent
7188849aa4
commit
2bb96018b8
@ -293,6 +293,7 @@ set(client_HEADERS
|
||||
globalLobby/GlobalLobbyLoginWindow.h
|
||||
globalLobby/GlobalLobbyRoomWindow.h
|
||||
globalLobby/GlobalLobbyServerSetup.h
|
||||
globalLobby/GlobalLobbyObserver.h
|
||||
globalLobby/GlobalLobbyWidget.h
|
||||
globalLobby/GlobalLobbyWindow.h
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "GlobalLobbyInviteWindow.h"
|
||||
#include "GlobalLobbyLoginWindow.h"
|
||||
#include "GlobalLobbyObserver.h"
|
||||
#include "GlobalLobbyWindow.h"
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
@ -193,6 +194,9 @@ void GlobalLobbyClient::receiveActiveAccounts(const JsonNode & json)
|
||||
auto lobbyWindowPtr = lobbyWindow.lock();
|
||||
if(lobbyWindowPtr)
|
||||
lobbyWindowPtr->onActiveAccounts(activeAccounts);
|
||||
|
||||
for (auto const & window : GH.windows().findWindows<GlobalLobbyObserver>())
|
||||
window->onActiveAccounts(activeAccounts);
|
||||
}
|
||||
|
||||
void GlobalLobbyClient::receiveActiveGameRooms(const JsonNode & json)
|
||||
@ -236,7 +240,10 @@ void GlobalLobbyClient::receiveActiveGameRooms(const JsonNode & json)
|
||||
|
||||
auto lobbyWindowPtr = lobbyWindow.lock();
|
||||
if(lobbyWindowPtr)
|
||||
lobbyWindowPtr->onActiveRooms(activeRooms);
|
||||
lobbyWindowPtr->onActiveGameRooms(activeRooms);
|
||||
|
||||
for (auto const & window : GH.windows().findWindows<GlobalLobbyObserver>())
|
||||
window->onActiveGameRooms(activeRooms);
|
||||
}
|
||||
|
||||
void GlobalLobbyClient::receiveMatchesHistory(const JsonNode & json)
|
||||
|
@ -99,3 +99,18 @@ GlobalLobbyInviteWindow::GlobalLobbyInviteWindow()
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void GlobalLobbyInviteWindow::onActiveGameRooms(const std::vector<GlobalLobbyRoom> & rooms)
|
||||
{
|
||||
accountList->reset();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void GlobalLobbyInviteWindow::onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts)
|
||||
{
|
||||
if (accountList->size() == accounts.size())
|
||||
accountList->reset();
|
||||
else
|
||||
accountList->resize(accounts.size());
|
||||
redraw();
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GlobalLobbyObserver.h"
|
||||
|
||||
#include "../windows/CWindowObject.h"
|
||||
|
||||
class CLabel;
|
||||
@ -18,7 +20,7 @@ class CListBox;
|
||||
class CButton;
|
||||
struct GlobalLobbyAccount;
|
||||
|
||||
class GlobalLobbyInviteWindow : public CWindowObject
|
||||
class GlobalLobbyInviteWindow final : public CWindowObject, public GlobalLobbyObserver
|
||||
{
|
||||
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
|
||||
std::shared_ptr<CLabel> labelTitle;
|
||||
@ -26,6 +28,9 @@ class GlobalLobbyInviteWindow : public CWindowObject
|
||||
std::shared_ptr<TransparentFilledRectangle> listBackground;
|
||||
std::shared_ptr<CButton> buttonClose;
|
||||
|
||||
void onActiveGameRooms(const std::vector<GlobalLobbyRoom> & rooms) override;
|
||||
void onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts) override;
|
||||
|
||||
public:
|
||||
GlobalLobbyInviteWindow();
|
||||
};
|
||||
|
23
client/globalLobby/GlobalLobbyObserver.h
Normal file
23
client/globalLobby/GlobalLobbyObserver.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* GlobalLobbyObserver.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
struct GlobalLobbyAccount;
|
||||
struct GlobalLobbyRoom;
|
||||
|
||||
/// Interface for windows that want to receive updates whenever state of global lobby changes
|
||||
class GlobalLobbyObserver
|
||||
{
|
||||
public:
|
||||
virtual void onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts) {}
|
||||
virtual void onActiveGameRooms(const std::vector<GlobalLobbyRoom> & rooms) {}
|
||||
|
||||
virtual ~GlobalLobbyObserver() = default;
|
||||
};
|
@ -157,7 +157,7 @@ void GlobalLobbyWindow::onActiveAccounts(const std::vector<GlobalLobbyAccount> &
|
||||
widget->getAccountListHeader()->setText(text.toString());
|
||||
}
|
||||
|
||||
void GlobalLobbyWindow::onActiveRooms(const std::vector<GlobalLobbyRoom> & rooms)
|
||||
void GlobalLobbyWindow::onActiveGameRooms(const std::vector<GlobalLobbyRoom> & rooms)
|
||||
{
|
||||
if (rooms.size() == widget->getRoomList()->size())
|
||||
widget->getRoomList()->reset();
|
||||
|
@ -9,13 +9,14 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GlobalLobbyObserver.h"
|
||||
#include "../windows/CWindowObject.h"
|
||||
|
||||
class GlobalLobbyWidget;
|
||||
struct GlobalLobbyAccount;
|
||||
struct GlobalLobbyRoom;
|
||||
|
||||
class GlobalLobbyWindow : public CWindowObject
|
||||
class GlobalLobbyWindow final : public CWindowObject, public GlobalLobbyObserver
|
||||
{
|
||||
std::string chatHistory;
|
||||
std::string currentChannelType;
|
||||
@ -37,14 +38,15 @@ public:
|
||||
|
||||
/// Returns true if provided chat channel is the one that is currently open in UI
|
||||
bool isChannelOpen(const std::string & channelType, const std::string & channelName) const;
|
||||
/// Returns true if provided channel has unread messages (only messages that were received after login)
|
||||
bool isChannelUnread(const std::string & channelType, const std::string & channelName) const;
|
||||
|
||||
// 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 onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts) override;
|
||||
void onActiveGameRooms(const std::vector<GlobalLobbyRoom> & rooms) override;
|
||||
void onMatchesHistory(const std::vector<GlobalLobbyRoom> & history);
|
||||
void onInviteReceived(const std::string & invitedRoomID);
|
||||
void onJoinedRoom();
|
||||
|
Loading…
Reference in New Issue
Block a user