1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Provide correct size to room and account lists

This commit is contained in:
Ivan Savenko 2024-03-11 17:51:11 +02:00
parent 2d37180fe2
commit 4f34c07f22
3 changed files with 21 additions and 12 deletions

View File

@ -24,6 +24,7 @@
#include "../widgets/TextControls.h"
#include "../../lib/MetaString.h"
GlobalLobbyWidget::GlobalLobbyWidget(GlobalLobbyWindow * window)
: window(window)
{
@ -53,12 +54,12 @@ std::shared_ptr<CIntObject> GlobalLobbyWidget::buildAccountList(const JsonNode &
auto itemOffset = readPosition(config["itemOffset"]);
auto sliderPosition = readPosition(config["sliderPosition"]);
auto sliderSize = readPosition(config["sliderSize"]);
size_t visibleSize = 4; // FIXME: how many items can fit into UI?
size_t totalSize = 4; //FIXME: how many items are there in total
size_t visibleAmount = config["visibleAmount"].Integer();
size_t totalAmount = 0; // Will be set later, on server netpack
int sliderMode = 1 | 4; // present, vertical, blue
int initialPos = 0;
return std::make_shared<CListBox>(createCallback, position, itemOffset, visibleSize, totalSize, initialPos, sliderMode, Rect(sliderPosition, sliderSize) );
return std::make_shared<CListBox>(createCallback, position, itemOffset, visibleAmount, totalAmount, initialPos, sliderMode, Rect(sliderPosition, sliderSize));
}
std::shared_ptr<CIntObject> GlobalLobbyWidget::buildRoomList(const JsonNode & config) const
@ -76,12 +77,12 @@ std::shared_ptr<CIntObject> GlobalLobbyWidget::buildRoomList(const JsonNode & co
auto itemOffset = readPosition(config["itemOffset"]);
auto sliderPosition = readPosition(config["sliderPosition"]);
auto sliderSize = readPosition(config["sliderSize"]);
size_t visibleSize = 4; // FIXME: how many items can fit into UI?
size_t totalSize = 4; //FIXME: how many items are there in total
size_t visibleAmount = config["visibleAmount"].Integer();
size_t totalAmount = 0; // Will be set later, on server netpack
int sliderMode = 1 | 4; // present, vertical, blue
int initialPos = 0;
return std::make_shared<CListBox>(createCallback, position, itemOffset, visibleSize, totalSize, initialPos, sliderMode, Rect(sliderPosition, sliderSize) );
return std::make_shared<CListBox>(createCallback, position, itemOffset, visibleAmount, totalAmount, initialPos, sliderMode, Rect(sliderPosition, sliderSize));
}
std::shared_ptr<CLabel> GlobalLobbyWidget::getAccountNameLabel()

View File

@ -86,12 +86,18 @@ void GlobalLobbyWindow::onGameChatMessage(const std::string & sender, const std:
void GlobalLobbyWindow::onActiveAccounts(const std::vector<GlobalLobbyAccount> & accounts)
{
widget->getAccountList()->reset();
if (accounts.size() == widget->getAccountList()->size())
widget->getAccountList()->reset();
else
widget->getAccountList()->resize(accounts.size());
}
void GlobalLobbyWindow::onActiveRooms(const std::vector<GlobalLobbyRoom> & rooms)
{
widget->getRoomList()->reset();
if (rooms.size() == widget->getAccountList()->size())
widget->getRoomList()->reset();
else
widget->getRoomList()->resize(rooms.size());
}
void GlobalLobbyWindow::onJoinedRoom()

View File

@ -58,10 +58,11 @@
{
"type" : "roomList",
"name" : "roomList",
"position" : { "x" : 7, "y" : 69 },
"position" : { "x" : 7, "y" : 68 },
"itemOffset" : { "x" : 0, "y" : 40 },
"sliderPosition" : { "x" : 230, "y" : 0 },
"sliderSize" : { "x" : 450, "y" : 450 }
"sliderSize" : { "x" : 480, "y" : 480 },
"visibleAmount" : 12
},
{
@ -116,10 +117,11 @@
{
"type" : "accountList",
"name" : "accountList",
"position" : { "x" : 872, "y" : 69 },
"position" : { "x" : 872, "y" : 68 },
"itemOffset" : { "x" : 0, "y" : 40 },
"sliderPosition" : { "x" : 130, "y" : 0 },
"sliderSize" : { "x" : 520, "y" : 520 }
"sliderSize" : { "x" : 520, "y" : 520 },
"visibleAmount" : 12
},
// {