Chat Interface Revision (#3840)

Co-authored-by: Anders Jenbo <anders@jenbo.dk>
This commit is contained in:
KPhoenix 2021-12-25 05:11:42 -05:00 committed by GitHub
commit a08026097a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 105 additions and 118 deletions

View file

@ -283,18 +283,10 @@ bool ContainsSmallFontTallCodepoints(string_view text)
return false;
}
int GetLineHeight(string_view text, unsigned fontIndex)
{
if (fontIndex == 0 && IsSmallFontTall() && ContainsSmallFontTallCodepoints(text)) {
return SmallFontTallLineHeight;
}
return LineHeights[fontIndex];
}
int GetLineHeight(string_view fmt, DrawStringFormatArg *args, std::size_t argsLen, unsigned fontIndex)
int GetLineHeight(string_view fmt, DrawStringFormatArg *args, std::size_t argsLen, GameFontTables fontIndex)
{
constexpr std::array<int, 6> LineHeights = { 12, 26, 38, 42, 50, 22 };
if (fontIndex == 0 && IsSmallFontTall()) {
if (fontIndex == GameFont12 && IsSmallFontTall()) {
char32_t prev = U'\0';
char32_t next;
FmtArgParser fmtArgParser { fmt, args, argsLen };
@ -307,7 +299,7 @@ int GetLineHeight(string_view fmt, DrawStringFormatArg *args, std::size_t argsLe
const std::optional<std::size_t> fmtArgPos = fmtArgParser(rest);
if (fmtArgPos) {
if (ContainsSmallFontTallCodepoints(args[*fmtArgPos].GetFormatted()))
return true;
return SmallFontTallLineHeight;
prev = U'\0';
continue;
}
@ -484,6 +476,14 @@ int GetLineWidth(string_view fmt, DrawStringFormatArg *args, std::size_t argsLen
return lineWidth != 0 ? (lineWidth - spacing) : 0;
}
int GetLineHeight(string_view text, GameFontTables fontIndex)
{
if (fontIndex == GameFont12 && IsSmallFontTall() && ContainsSmallFontTallCodepoints(text)) {
return SmallFontTallLineHeight;
}
return LineHeights[fontIndex];
}
int AdjustSpacingToFitHorizontally(int &lineWidth, int maxSpacing, int charactersInLine, int availableWidth)
{
if (lineWidth <= availableWidth || charactersInLine < 2)