mirror of https://github.com/OpenTTD/OpenTTD
(svn r17391) -Codechange: Add string box calculation routine for multi-line strings.
parent
3375627552
commit
a3ddb8a235
10
src/gfx.cpp
10
src/gfx.cpp
|
@ -729,6 +729,16 @@ int GetStringHeight(StringID str, int maxw)
|
||||||
return GetMultilineStringHeight(buffer, GB(tmp, 0, 16));
|
return GetMultilineStringHeight(buffer, GB(tmp, 0, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Calculate string bounding box for multi-line strings.
|
||||||
|
* @param str String to check.
|
||||||
|
* @param suggestion Suggested bounding box.
|
||||||
|
* @return Bounding box for the multi-line string, may be bigger than \a suggestion.
|
||||||
|
*/
|
||||||
|
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
|
||||||
|
{
|
||||||
|
Dimension box = {suggestion.width, GetStringHeight(str, suggestion.width)};
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw string, possibly over multiple lines.
|
* Draw string, possibly over multiple lines.
|
||||||
|
|
|
@ -117,6 +117,7 @@ Dimension GetStringBoundingBox(const char *str);
|
||||||
Dimension GetStringBoundingBox(StringID strid);
|
Dimension GetStringBoundingBox(StringID strid);
|
||||||
uint32 FormatStringLinebreaks(char *str, int maxw);
|
uint32 FormatStringLinebreaks(char *str, int maxw);
|
||||||
int GetStringHeight(StringID str, int maxw);
|
int GetStringHeight(StringID str, int maxw);
|
||||||
|
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
|
||||||
void LoadStringWidthTable();
|
void LoadStringWidthTable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue