57 const float buttonWidth = 180.0f;
58 const float buttonHeight = 45.0f;
59 const float bottomMargin = 120.0f;
62 createRoomPtr->SetSize(buttonWidth, buttonHeight);
64 createRoomPtr->ApplyAlignment();
67 createRoomPtr->GetPosition(x, y);
69 createRoomPtr->SetPosition(x, screenHeight - bottomMargin);
71 createRoomPtr->SetText(
"Create Room");
72 createRoomPtr->SetBackgroundColor(0xFF4CAF50);
73 createRoomPtr->SetHoverColor(0xFF66BB6A);
74 createRoomPtr->SetTextColor(0xFFFFFFFF);
81 const float leftMargin = 20.0f;
83 backPtr->SetSize(150.0f, 45.0f);
84 backPtr->SetPosition(leftMargin, screenHeight - bottomMargin);
85 backPtr->SetText(
"Back");
86 backPtr->SetBackgroundColor(0xFF424242);
87 backPtr->SetHoverColor(0xFF616161);
88 backPtr->SetTextColor(0xFFFFFFFF);
108 const char *title =
"Select a Room";
110 int titleFontSize = 32;
111 int titleWidth =
static_cast<int>(strlen(title) * titleFontSize * 0.5f);
112 int titleX = (screenWidth - titleWidth) / 2;
116 std::string countText =
"Available Rooms: " + std::to_string(
_rooms.size());
117 int countFontSize = 18;
118 int countWidth =
static_cast<int>(countText.length() * countFontSize * 0.5f);
119 int countX = (screenWidth - countWidth) / 2;
137 const auto &room =
_rooms[i];
143 buttonPtr->ApplyAlignment();
146 buttonPtr->GetPosition(x, y);
147 buttonPtr->SetPosition(x, currentY);
150 std::ostringstream oss;
151 oss << room.roomName <<
" [" << room.playerCount <<
"/" << room.maxPlayers <<
"]";
152 if (room.isPrivate) {
157 const char *stateText =
" - WAITING";
159 stateText =
" - STARTING";
160 else if (room.state == 2)
161 stateText =
" - IN PROGRESS";
162 else if (room.state == 3)
163 stateText =
" - FINISHED";
166 buttonPtr->SetText(oss.str());
169 if (room.state == 0) {
170 buttonPtr->SetBackgroundColor(0xFF4CAF50);
171 buttonPtr->SetHoverColor(0xFF66BB6A);
172 }
else if (room.state == 1) {
173 buttonPtr->SetBackgroundColor(0xFFFFA726);
174 buttonPtr->SetHoverColor(0xFFFFB74D);
175 }
else if (room.state == 2) {
176 buttonPtr->SetBackgroundColor(0xFF2196F3);
177 buttonPtr->SetHoverColor(0xFF64B5F6);
179 buttonPtr->SetBackgroundColor(0xFF9E9E9E);
180 buttonPtr->SetHoverColor(0xFF9E9E9E);
183 buttonPtr->SetTextColor(0xFFFFFFFF);
184 buttonPtr->SetTextSize(16);
189 if (room.state <= 2) {
193 []() {
LOG_INFO(
"[RoomListMenu] Cannot join this room - game finished"); }));
196 std::shared_ptr<UI::IButton> button = std::move(buttonPtr);
198 _menu->AddButton(button);
virtual void DrawText(int fontHandle, const char *text, int x, int y, int fontSize, unsigned int color)=0
Draw text using a loaded font.