diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 6e8ebdd7e..f114535e5 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1053,11 +1053,17 @@ void CPlayerInterface::showInfoDialog(EInfoWindowMode type, const std::string &t { return; } - std::vector> intComps; - for (auto & component : components) - intComps.push_back(std::make_shared(component)); - showInfoDialog(text,intComps,soundID); - + std::vector vect = components; //I do not know currently how to avoid copy here + do + { + std::vector sender = {vect.begin(), vect.begin() + std::min(vect.size(), static_cast(8))}; + std::vector> intComps; + for (auto & component : sender) + intComps.push_back(std::make_shared(component)); + showInfoDialog(text,intComps,soundID); + vect.erase(vect.begin(), vect.begin() + std::min(vect.size(), static_cast(8))); + } + while(!vect.empty()); } void CPlayerInterface::showInfoDialog(const std::string & text, std::shared_ptr component) diff --git a/client/adventureMap/CInfoBar.cpp b/client/adventureMap/CInfoBar.cpp index f50599890..582199a9f 100644 --- a/client/adventureMap/CInfoBar.cpp +++ b/client/adventureMap/CInfoBar.cpp @@ -217,17 +217,6 @@ CInfoBar::VisibleComponentInfo::VisibleComponentInfo(const std::vector(message, textRect, 0, font, ETextAlignment::CENTER, Colors::WHITE); } -int CInfoBar::getEstimatedComponentHeight(int numComps) const -{ - if (numComps > 8) //Bigger than 8 components - return invalid value - return std::numeric_limits::max(); - else if (numComps > 2) - return 160; // 32px * 1 row + 20 to offset - else if (numComps) - return 118; // 118 px to offset - return 0; -} - void CInfoBar::playNewDaySound() { if(LOCPLINT->cb->getDate(Date::DAY_OF_WEEK) != 1) // not first day of the week @@ -402,7 +391,7 @@ void CInfoBar::pushComponents(const std::vector & components, std::st void CInfoBar::prepareComponents(const std::vector & components, std::string message, int timer) { - auto imageH = getEstimatedComponentHeight(components.size()) + (components.empty() ? 0 : 2 * CInfoBar::offset); + auto imageH = CMessage::getEstimatedComponentHeight(components.size()) + (components.empty() ? 0 : 2 * CInfoBar::offset); auto textH = CMessage::guessHeight(message,CInfoBar::data_width - 2 * CInfoBar::offset, FONT_SMALL); auto tinyH = CMessage::guessHeight(message,CInfoBar::data_width - 2 * CInfoBar::offset, FONT_TINY); auto header = CMessage::guessHeader(message); diff --git a/client/adventureMap/CInfoBar.h b/client/adventureMap/CInfoBar.h index fa6e4cd6e..df7d1b2ef 100644 --- a/client/adventureMap/CInfoBar.h +++ b/client/adventureMap/CInfoBar.h @@ -189,8 +189,5 @@ public: /// check if infobar is showed something about pickups bool showingComponents(); - - /// get estimated component height for InfoBar - int getEstimatedComponentHeight(int numComps) const; }; diff --git a/client/windows/CMessage.cpp b/client/windows/CMessage.cpp index fcd7cc559..9438f4de7 100644 --- a/client/windows/CMessage.cpp +++ b/client/windows/CMessage.cpp @@ -221,6 +221,17 @@ int CMessage::guessHeight(const std::string & txt, int width, EFonts font) return lineHeight * (int)lines.size(); } +int CMessage::getEstimatedComponentHeight(int numComps) +{ + if (numComps > 8) //Bigger than 8 components - return invalid value + return std::numeric_limits::max(); + else if (numComps > 2) + return 160; // 32px * 1 row + 20 to offset + else if (numComps) + return 118; // 118 px to offset + return 0; +} + void CMessage::drawIWindow(CInfoWindow * ret, std::string text, PlayerColor player) { bool blitOr = false; diff --git a/client/windows/CMessage.h b/client/windows/CMessage.h index 4ad5e36a1..84c6fa29d 100644 --- a/client/windows/CMessage.h +++ b/client/windows/CMessage.h @@ -38,6 +38,7 @@ public: /// For convenience static int guessHeight(const std::string & string, int width, EFonts fnt); + static int getEstimatedComponentHeight(int numComps); /// constructor static void init(); /// destructor