diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-08-28 11:57:29 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-08-28 16:46:44 +0000 |
commit | e2fb719501c41356f632e6f8838c91d888239037 (patch) | |
tree | 435b6586af9e2c007f9fd92efee51b56809a7411 | |
parent | 4180d647fdfedca0e2ef64fe8e07cb358b11cbf9 (diff) | |
download | mana-e2fb719501c41356f632e6f8838c91d888239037.tar.gz mana-e2fb719501c41356f632e6f8838c91d888239037.tar.bz2 mana-e2fb719501c41356f632e6f8838c91d888239037.tar.xz mana-e2fb719501c41356f632e6f8838c91d888239037.zip |
Fixed handling of consecutive text formatting markers
If a text contained for example "##3##B", expected behavior was to
switch to blue color and bold font. Instead, due to there being no
actual text in between the markers, the layouting code was aborting
prematurely here:
if (mMode == AUTO_WRAP && partWidth == 0)
break;
As far as I could judge, this check is actually not necessary anyway,
but I've kept it for now since the wrapping code looks so problematic.
Instead, a while loop now makes sure we process all consecutive
formatting markers.
Closes #75
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 18 |
2 files changed, 8 insertions, 11 deletions
@@ -45,6 +45,7 @@ - Fixed being popup getting stuck under the mouse - Fixed item links with empty item name to look up name from Item DB - Fixed spaces getting added to chat every 50 characters +- Fixed handling of consecutive text formatting markers - Fixed empty Equipment window on freshly created character - Fixed choosing default world when using -D command-line parameter - Updated to tmwAthena protocol changes diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 64b494db..7b77721c 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -336,17 +336,13 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context) wrapped = false; } - // "Tokenize" the string at control sequences - if (mUseLinksAndUserColors) - end = row.text.find("##", start + 1); - - if (mUseLinksAndUserColors || - (!mUseLinksAndUserColors && (start == 0))) + if (mUseLinksAndUserColors || start == 0) { // Check for color or font change in format "##x", x = [<,>,B,p,0..9] - if (row.text.find("##", start) == start && row.text.size() > start + 2) + while (row.text.size() > start + 2 && row.text.find("##", start) == start) { const char c = row.text.at(start + 2); + start += 3; bool valid; const gcn::Color &col = Theme::getThemeColor(c, valid); @@ -401,16 +397,16 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context) linkIndex++; } - start += 3; - - if (start == row.text.size()) - break; } } if (start >= row.text.length()) break; + // "Tokenize" the string at control sequences + if (mUseLinksAndUserColors) + end = row.text.find("##", start + 1); + std::string::size_type len = end == std::string::npos ? end : end - start; |