Add resizing code for networking lobby

This commit is contained in:
CodingJellyfish 2024-04-28 13:25:20 +08:00
parent f6949972b3
commit 18094c505a
3 changed files with 31 additions and 1 deletions

View File

@ -117,7 +117,8 @@ namespace GUIEngine
void setScrollSpeed(float speed); void setScrollSpeed(float speed);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
float getScrollSpeed() const { return m_scroll_speed; }
// --------------------------------------------------------------------
/** /**
* \brief Check if the current has been fully scrolled * \brief Check if the current has been fully scrolled
* \return true if the text has completely scrolled off * \return true if the text has completely scrolled off

View File

@ -422,6 +422,34 @@ break_glyph_layouts:
#endif #endif
} // addMoreServerInfo } // 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() void NetworkingLobby::updateServerInfos()
{ {

View File

@ -149,6 +149,7 @@ public:
void reloadServerInfos() { m_reload_server_info = true; } void reloadServerInfos() { m_reload_server_info = true; }
void setHeader(const core::stringw& header) { m_header_text = header; } void setHeader(const core::stringw& header) { m_header_text = header; }
void setAssignedPlayers(bool val) { m_assigned_players = val; } void setAssignedPlayers(bool val) { m_assigned_players = val; }
virtual void onResize() OVERRIDE;
}; // class NetworkingLobby }; // class NetworkingLobby
#endif #endif