mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
vcmi: move getEstimatedComponentHeight
This commit is contained in:
parent
b4940ee247
commit
18200d1d98
@ -216,17 +216,6 @@ CInfoBar::VisibleComponentInfo::VisibleComponentInfo(const std::vector<Component
|
||||
text = std::make_shared<CTextBox>(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<int>::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
|
||||
@ -401,7 +390,7 @@ void CInfoBar::pushComponents(const std::vector<Component> & components, std::st
|
||||
|
||||
void CInfoBar::prepareComponents(const std::vector<Component> & 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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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<int>::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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user