Skip to content

Commit

Permalink
Add resizing code for networking lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingJellyfish committed Apr 28, 2024
1 parent f694997 commit 18094c5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/guiengine/widgets/label_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ namespace GUIEngine
void setScrollSpeed(float speed);

// --------------------------------------------------------------------

float getScrollSpeed() const { return m_scroll_speed; }
// --------------------------------------------------------------------
/**
* \brief Check if the current has been fully scrolled
* \return true if the text has completely scrolled off
Expand Down
28 changes: 28 additions & 0 deletions src/states_screens/online/networking_lobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,34 @@ void NetworkingLobby::addMoreServerInfo(core::stringw info)
#endif
} // addMoreServerInfo

// ----------------------------------------------------------------------------
void NetworkingLobby::onResize()
{
Screen::onResize();
const unsigned box_width = m_text_bubble->getDimension().Width;
const float box_height = m_text_bubble->getDimension().Height;
gui::IGUIFont* font = GUIEngine::getFont();
gui::breakGlyphLayouts(m_server_info, box_width,
font->getInverseShaping(), font->getScale());
gui::eraseTopLargerThan(m_server_info, font->getHeightPerLine(),
box_height);
updateServerInfos();

int header_text_width =
GUIEngine::getTitleFont()->getDimension(m_header_text.c_str()).Width;
if ((m_header->m_w < header_text_width && m_header->getScrollSpeed() == 0.0f) ||
(m_header->m_w >= header_text_width && m_header->getScrollSpeed() != 0.0f))
{
m_header->getIrrlichtElement()->remove();
GUIEngine::getGUIEnv()->setChildEnd(m_back_widget->getIrrlichtElement());
m_header->setScrollSpeed(m_header->m_w < header_text_width ? 0.5f: 0.0f);
m_header->add();
m_header->setText(m_header_text, true);
GUIEngine::getGUIEnv()->setChildEnd(NULL);
}
m_header_text_width = header_text_width;
} // onResize

// ----------------------------------------------------------------------------
void NetworkingLobby::updateServerInfos()
{
Expand Down
1 change: 1 addition & 0 deletions src/states_screens/online/networking_lobby.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class NetworkingLobby : public GUIEngine::Screen,
void reloadServerInfos() { m_reload_server_info = true; }
void setHeader(const core::stringw& header) { m_header_text = header; }
void setAssignedPlayers(bool val) { m_assigned_players = val; }
virtual void onResize() OVERRIDE;
}; // class NetworkingLobby

#endif

0 comments on commit 18094c5

Please sign in to comment.