mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-13 22:06:58 +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/GlobalLobbyLoginWindow.h
|
||||||
globalLobby/GlobalLobbyRoomWindow.h
|
globalLobby/GlobalLobbyRoomWindow.h
|
||||||
globalLobby/GlobalLobbyServerSetup.h
|
globalLobby/GlobalLobbyServerSetup.h
|
||||||
|
globalLobby/GlobalLobbyObserver.h
|
||||||
globalLobby/GlobalLobbyWidget.h
|
globalLobby/GlobalLobbyWidget.h
|
||||||
globalLobby/GlobalLobbyWindow.h
|
globalLobby/GlobalLobbyWindow.h
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "GlobalLobbyInviteWindow.h"
|
#include "GlobalLobbyInviteWindow.h"
|
||||||
#include "GlobalLobbyLoginWindow.h"
|
#include "GlobalLobbyLoginWindow.h"
|
||||||
|
#include "GlobalLobbyObserver.h"
|
||||||
#include "GlobalLobbyWindow.h"
|
#include "GlobalLobbyWindow.h"
|
||||||
|
|
||||||
#include "../CGameInfo.h"
|
#include "../CGameInfo.h"
|
||||||
@ -193,6 +194,9 @@ void GlobalLobbyClient::receiveActiveAccounts(const JsonNode & json)
|
|||||||
auto lobbyWindowPtr = lobbyWindow.lock();
|
auto lobbyWindowPtr = lobbyWindow.lock();
|
||||||
if(lobbyWindowPtr)
|
if(lobbyWindowPtr)
|
||||||
lobbyWindowPtr->onActiveAccounts(activeAccounts);
|
lobbyWindowPtr->onActiveAccounts(activeAccounts);
|
||||||
|
|
||||||
|
for (auto const & window : GH.windows().findWindows<GlobalLobbyObserver>())
|
||||||
|
window->onActiveAccounts(activeAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalLobbyClient::receiveActiveGameRooms(const JsonNode & json)
|
void GlobalLobbyClient::receiveActiveGameRooms(const JsonNode & json)
|
||||||
@ -236,7 +240,10 @@ void GlobalLobbyClient::receiveActiveGameRooms(const JsonNode & json)
|
|||||||
|
|
||||||
auto lobbyWindowPtr = lobbyWindow.lock();
|
auto lobbyWindowPtr = lobbyWindow.lock();
|
||||||
if(lobbyWindowPtr)
|
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)
|
void GlobalLobbyClient::receiveMatchesHistory(const JsonNode & json)
|
||||||
|
@ -99,3 +99,18 @@ GlobalLobbyInviteWindow::GlobalLobbyInviteWindow()
|
|||||||
|
|
||||||
center();
|
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
|
#pragma once
|
||||||
|
|
||||||
|
#include "GlobalLobbyObserver.h"
|
||||||
|
|
||||||
#include "../windows/CWindowObject.h"
|
#include "../windows/CWindowObject.h"
|
||||||
|
|
||||||
class CLabel;
|
class CLabel;
|
||||||
@ -18,7 +20,7 @@ class CListBox;
|
|||||||
class CButton;
|
class CButton;
|
||||||
struct GlobalLobbyAccount;
|
struct GlobalLobbyAccount;
|
||||||
|
|
||||||
class GlobalLobbyInviteWindow : public CWindowObject
|
class GlobalLobbyInviteWindow final : public CWindowObject, public GlobalLobbyObserver
|
||||||
{
|
{
|
||||||
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
|
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
|
||||||
std::shared_ptr<CLabel> labelTitle;
|
std::shared_ptr<CLabel> labelTitle;
|
||||||
@ -26,6 +28,9 @@ class GlobalLobbyInviteWindow : public CWindowObject
|
|||||||
std::shared_ptr<TransparentFilledRectangle> listBackground;
|
std::shared_ptr<TransparentFilledRectangle> listBackground;
|
||||||
std::shared_ptr<CButton> buttonClose;
|
std::shared_ptr<CButton> buttonClose;
|
||||||
|
|
||||||
|
void onActiveGameRooms(const std::vector<GlobalLobbyRoom> & rooms) override;
|
||||||
|
void onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlobalLobbyInviteWindow();
|
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());
|
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())
|
if (rooms.size() == widget->getRoomList()->size())
|
||||||
widget->getRoomList()->reset();
|
widget->getRoomList()->reset();
|
||||||
|
@ -9,13 +9,14 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "GlobalLobbyObserver.h"
|
||||||
#include "../windows/CWindowObject.h"
|
#include "../windows/CWindowObject.h"
|
||||||
|
|
||||||
class GlobalLobbyWidget;
|
class GlobalLobbyWidget;
|
||||||
struct GlobalLobbyAccount;
|
struct GlobalLobbyAccount;
|
||||||
struct GlobalLobbyRoom;
|
struct GlobalLobbyRoom;
|
||||||
|
|
||||||
class GlobalLobbyWindow : public CWindowObject
|
class GlobalLobbyWindow final : public CWindowObject, public GlobalLobbyObserver
|
||||||
{
|
{
|
||||||
std::string chatHistory;
|
std::string chatHistory;
|
||||||
std::string currentChannelType;
|
std::string currentChannelType;
|
||||||
@ -37,14 +38,15 @@ public:
|
|||||||
|
|
||||||
/// Returns true if provided chat channel is the one that is currently open in UI
|
/// 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;
|
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;
|
bool isChannelUnread(const std::string & channelType, const std::string & channelName) const;
|
||||||
|
|
||||||
// Callbacks for network packs
|
// 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 onGameChatMessage(const std::string & sender, const std::string & message, const std::string & when, const std::string & channelType, const std::string & channelName);
|
||||||
void refreshChatText();
|
void refreshChatText();
|
||||||
void onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts);
|
void onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts) override;
|
||||||
void onActiveRooms(const std::vector<GlobalLobbyRoom> & rooms);
|
void onActiveGameRooms(const std::vector<GlobalLobbyRoom> & rooms) override;
|
||||||
void onMatchesHistory(const std::vector<GlobalLobbyRoom> & history);
|
void onMatchesHistory(const std::vector<GlobalLobbyRoom> & history);
|
||||||
void onInviteReceived(const std::string & invitedRoomID);
|
void onInviteReceived(const std::string & invitedRoomID);
|
||||||
void onJoinedRoom();
|
void onJoinedRoom();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user