[Scummvm-git-logs] scummvm master -> c0511db8daecf387cd50fa88fd83e193f1dc2af6

sev- noreply at scummvm.org
Mon Sep 25 21:32:25 UTC 2023


This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
494f6389b5 GRAPHICS: MACGUI: Improved debug output for Markdown
5a706831c2 GRAPHICS: MACGUI: Pass Markdown tables to MacText
1a1161f1d9 GRAPHICS: MACGUI: Added Table structs to MacText
a5a96f5cfd GRAPHICS: MACTEXT: Revert long word processing in MacText
6de2d6c8d2 GRAPHICS: MACGUI: Fix headre rendering in Markdown
358bbe93cc GRAPHICS: MACGUI: More work on digesting tables in MacText
c0511db8da GUI: Fix warning and remove leftover code


Commit: 494f6389b5937b59e4d9a73f81fcc116aa403132
    https://github.com/scummvm/scummvm/commit/494f6389b5937b59e4d9a73f81fcc116aa403132
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-09-25T23:30:32+02:00

Commit Message:
GRAPHICS: MACGUI: Improved debug output for Markdown

Changed paths:
    graphics/macgui/mactext-md.cpp


diff --git a/graphics/macgui/mactext-md.cpp b/graphics/macgui/mactext-md.cpp
index b29bc494014..ab0da44f546 100644
--- a/graphics/macgui/mactext-md.cpp
+++ b/graphics/macgui/mactext-md.cpp
@@ -25,7 +25,7 @@
 
 namespace Graphics {
 
-#define PR(x) ((x && x->data) ? Common::String((const char *)(x)->data , (x)->size).c_str() : "(null)")
+#define PR(x) ((x && x->data) ? Common::toPrintable(Common::String((const char *)(x)->data , (x)->size)).c_str() : "(null)")
 
 struct MDState {
 	Common::List<int> listNum;


Commit: 5a706831c2fc6ffafff0d16d8f82e82a53e8494b
    https://github.com/scummvm/scummvm/commit/5a706831c2fc6ffafff0d16d8f82e82a53e8494b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-09-25T23:30:38+02:00

Commit Message:
GRAPHICS: MACGUI: Pass Markdown tables to MacText

Changed paths:
    graphics/macgui/mactext-md.cpp
    graphics/macgui/mactext.cpp
    graphics/macgui/macwindowmanager.cpp


diff --git a/graphics/macgui/mactext-md.cpp b/graphics/macgui/mactext-md.cpp
index ab0da44f546..9399b5bd1d1 100644
--- a/graphics/macgui/mactext-md.cpp
+++ b/graphics/macgui/mactext-md.cpp
@@ -133,21 +133,33 @@ void render_table(Common::SDDataBuffer *ob, const Common::SDDataBuffer *header,
 	if (!body)
 		return;
 
-	warning("STUB: render_table(%s, %s)", PR(header), PR(body));
+	Common::String res = Common::String::format("\016Th" "%s\n" "\001\016Tb" "%s\n" "\016TB\n",
+			Common::String((const char *)header->data , header->size).c_str(), Common::String((const char *)body->data , body->size).c_str());
+
+	sd_bufput(ob, res.c_str(), res.size());
+
+	debug(1, "render_table(%s, %s)", PR(header), PR(body));
 }
 
 void render_table_row(Common::SDDataBuffer *ob, const Common::SDDataBuffer *text, void *opaque) {
 	if (!text)
 		return;
 
-	warning("STUB: render_table_row(%s)", PR(text));
+	Common::String res = Common::String::format("\001\016Tr" "%s\n", Common::String((const char *)text->data , text->size).c_str());
+	sd_bufput(ob, res.c_str(), res.size());
+
+	debug(1, "render_table_row(%s)", PR(text));
 }
 
 void render_table_cell(Common::SDDataBuffer *ob, const Common::SDDataBuffer *text, int flags, void *opaque) {
 	if (!text)
 		return;
 
-	warning("STUB: render_table_cell(%s)", PR(text));
+	Common::String res = Common::String::format("\001\016Tc%02x" "%s" "\001\016TC", flags, Common::String((const char *)text->data , text->size).c_str());
+
+	sd_bufput(ob, res.c_str(), res.size());
+
+	debug(1, "render_table_cell(%s), flags: %d", PR(text), flags);
 }
 
 int render_autolink(Common::SDDataBuffer *ob, const Common::SDDataBuffer *link, Common::MKDAutolink type, void *opaque) {
@@ -327,7 +339,7 @@ void MacText::setMarkdownText(const Common::U32String &str) {
 	mdState.linkg = 0;
 	mdState.linkb = 0xff;
 
-	Common::SDMarkdown md(0, 16, &cb, &mdState);
+	Common::SDMarkdown md(Common::MKDEXT_TABLES, 16, &cb, &mdState);
 	Common::String rendered = md.render((const byte *)input.c_str(), input.size());
 
 	setText(rendered);
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index ed7dca64583..8b61a3abb67 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -851,6 +851,25 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 					break;
 					}
 
+				case 'T': { // \016T -- table
+					s++;
+
+					char cmd = *s++;
+
+					if (cmd == 'h') { // Header, beginning of the table
+					} else if (cmd == 'b') { // Body start
+					} else if (cmd == 'B') { // Body end
+					} else if (cmd == 'r') { // Row
+					} else if (cmd == 'c') { // Cell start
+						uint16 flags;
+						s = readHex(&flags, s, 2);
+					} else if (cmd == 'C') { // Cell end
+					} else {
+						error("MacText: Unknown table subcommand (%c)", cmd);
+					}
+					break;
+					}
+
 				default: {
 					uint16 fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3;
 
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 3145dea6fe9..910d2965b75 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -618,6 +618,14 @@ Common::U32String stripFormat(const Common::U32String &str) {
 					uint16 len;
 					s = readHex(&len, s, 2);
 					s += len;
+				} else if (*s == 'T') { // table
+					s++;
+					char cmd = *s;
+
+					if (cmd == 'h' || cmd == 'b' || cmd == 'B' || cmd == 'r' || cmd == 'C')
+						s++;
+					else if (cmd == 'c') // cell
+						s += 3;
 				} else
 					s += 22;
 			} else {


Commit: 1a1161f1d9401ce2f7b92b6aea5fa662bef4feaf
    https://github.com/scummvm/scummvm/commit/1a1161f1d9401ce2f7b92b6aea5fa662bef4feaf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-09-25T23:30:38+02:00

Commit Message:
GRAPHICS: MACGUI: Added Table structs to MacText

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 8b61a3abb67..b83ccd44b7d 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -857,12 +857,23 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 					char cmd = *s++;
 
 					if (cmd == 'h') { // Header, beginning of the table
+						if (_inTable)
+							error("MacText: Nested tables are not supported");
+
+						_inTable = true;
+
+						_textLines[curLine].table = new Common::Array<MacTextTableRow>();
 					} else if (cmd == 'b') { // Body start
 					} else if (cmd == 'B') { // Body end
+						_inTable = false;
 					} else if (cmd == 'r') { // Row
+						_textLines[curLine].table->push_back(MacTextTableRow());
 					} else if (cmd == 'c') { // Cell start
 						uint16 flags;
 						s = readHex(&flags, s, 2);
+
+						_textLines[curLine].table->back().cells.push_back(MacTextTableCell());
+						_textLines[curLine].table->back().cells.back().flags = flags;
 					} else if (cmd == 'C') { // Cell end
 					} else {
 						error("MacText: Unknown table subcommand (%c)", cmd);
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 8ac847fecc2..48c4bc84896 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -117,6 +117,20 @@ struct MacFontRun {
 	Common::String getEncodedText();
 };
 
+struct MacTextLine;
+
+struct MacTextTableCell {
+	Common::Array<MacTextLine> text;
+	uint16 flags = 0;
+	ManagedSurface surf;
+	int textWidth = -1;
+};
+
+struct MacTextTableRow {
+	Common::Array<MacTextTableCell> cells;
+	int heght = -1;
+};
+
 struct MacTextLine {
 	int width = -1;
 	int height = -1;
@@ -128,6 +142,7 @@ struct MacTextLine {
 	Common::String picfname;
 	Common::U32String picalt, pictitle;
 	uint16 picpercent = 50;
+	Common::Array<MacTextTableRow> *table = nullptr;
 
 	Common::Array<MacFontRun> chunks;
 
@@ -384,6 +399,8 @@ protected:
 
 	bool _macFontMode;
 
+	bool _inTable = false;
+
 private:
 	ManagedSurface *_cursorSurface;
 	ManagedSurface *_cursorSurface2;


Commit: a5a96f5cfddfcbae6af54daa16e6a9784db7fe0f
    https://github.com/scummvm/scummvm/commit/a5a96f5cfddfcbae6af54daa16e6a9784db7fe0f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-09-25T23:30:38+02:00

Commit Message:
GRAPHICS: MACTEXT: Revert long word processing in MacText

This effectively reverts 2b6754e187c9182122cdf9b7535613d644e16be3

I have no idea why I merged it as is, but the changes in that PR #2865
were all non-sensible and hacky

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index b83ccd44b7d..2fdab51419e 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -632,31 +632,26 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 	D(9, "** splitString(\"%s\")", toPrintable(str.encode()).c_str());
 
-	// TODO::code is not elegant, we need to figure out a way which include all situations
-	if (curLine == -1)
-		curLine = _textLines.size();
-
 	if (_textLines.empty()) {
 		_textLines.resize(1);
 		_textLines[0].chunks.push_back(_defaultFormatting);
 		D(9, "** splitString, added default formatting");
 	} else {
-		_textLines.insert_at(curLine, MacTextLine());
 		D(9, "** splitString, continuing, %d lines", _textLines.size());
 	}
 
-	if (curLine == -1)
-		curLine = _textLines.size() - 1;
-
 	if (str.empty()) {
-		_textLines[curLine].chunks.push_back(_defaultFormatting);
 		debug(9,"** splitString, empty line");
 		return;
 	}
 
 	Common::U32String paragraph, tmp;
 
-	MacFontRun current_format = _defaultFormatting;
+	if (curLine == -1)
+		curLine = _textLines.size() - 1;
+
+	int curChunk = _textLines[curLine].chunks.size() - 1;
+	MacFontRun chunk = _textLines[curLine].chunks[curChunk];
 	int indentSize = 0;
 	int firstLineIndent = 0;
 
@@ -687,16 +682,39 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 		firstLineIndent = 0;
 
+		tmp.clear();
+
 		while (*s) {
-			tmp.clear();
+			// Scan till next font change or end of line
+			while (*s && *s != '\001') {
+				tmp += *s;
 
-			// Skip \001
-			if (*s == '\001') {
 				s++;
-				if (*s == '\001') {
-					tmp += *s;
-					s++;
-				}
+			}
+
+			if (*s)	// If it was \001, skip it
+				s++;
+
+			if (*s == '\001') { // \001\001 -> \001
+				tmp += *s++;
+
+				if (*s)	// Check we reached end of line
+					continue;
+			}
+
+			D(9, "** splitString, chunk: \"%s\"", Common::toPrintable(tmp.encode()).c_str());
+
+			// Okay, now we are either at the end of the line, or in the next
+			// chunk definition. That means, that we have to store the previous chunk
+			chopChunk(tmp, &curLine);
+
+			tmp.clear();
+
+			// If it is end of the line, we're done
+			if (!*s) {
+				D(9, "** splitString, end of line");
+
+				break;
 			}
 
 			// get format (sync with stripFormat() )
@@ -711,21 +729,21 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 					s = readHex(&textSlant, s, 2);
 
-					current_format.textSlant |= textSlant; // Setting the specified bit
+					chunk.textSlant |= textSlant; // Setting the specified bit
 
 					s = readHex(&headSize, s, 1);
 					if (headSize >= 1 && headSize <= 6) { // set
 						const float sizes[] = { 1, 2.0f, 1.41f, 1.155f, 1.0f, .894f, .816f };
-						current_format.fontSize = _defaultFormatting.fontSize * sizes[headSize];
+						chunk.fontSize = _defaultFormatting.fontSize * sizes[headSize];
 					}
 
 					s = readHex(&indent, s, 1);
 
 					if (s)
-						indentSize += indent * current_format.fontSize * 2;
+						indentSize += indent * chunk.fontSize * 2;
 
 					D(9, "** splitString+: fontId: %d, textSlant: %d, fontSize: %d, indent: %d",
-							current_format.fontId, current_format.textSlant, current_format.fontSize,
+							chunk.fontId, chunk.textSlant, chunk.fontSize,
 							indent);
 
 					break;
@@ -736,19 +754,19 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 					s = readHex(&textSlant, s, 2);
 
-					current_format.textSlant &= ~textSlant; // Clearing the specified bit
+					chunk.textSlant &= ~textSlant; // Clearing the specified bit
 
 					s = readHex(&headSize, s, 1);
 					if (headSize == 0xf) // reset
-						current_format.fontSize = _defaultFormatting.fontSize;
+						chunk.fontSize = _defaultFormatting.fontSize;
 
 					s = readHex(&indent, s, 1);
 
 					if (s)
-						indentSize -= indent * current_format.fontSize * 2;
+						indentSize -= indent * chunk.fontSize * 2;
 
 					D(9, "** splitString-: fontId: %d, textSlant: %d, fontSize: %d, indent: %d",
-							current_format.fontId, current_format.textSlant, current_format.fontSize,
+							chunk.fontId, chunk.textSlant, chunk.fontSize,
 							indent);
 					break;
 					}
@@ -761,10 +779,10 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 					s = readHex(&palinfo2, s, 4);
 					s = readHex(&palinfo3, s, 4);
 
-					current_format.palinfo1 = palinfo1;
-					current_format.palinfo2 = palinfo2;
-					current_format.palinfo3 = palinfo3;
-					current_format.fgcolor  = _wm->findBestColor(palinfo1 & 0xff, palinfo2 & 0xff, palinfo3 & 0xff);
+					chunk.palinfo1 = palinfo1;
+					chunk.palinfo2 = palinfo2;
+					chunk.palinfo3 = palinfo3;
+					chunk.fgcolor  = _wm->findBestColor(palinfo1 & 0xff, palinfo2 & 0xff, palinfo3 & 0xff);
 
 					D(9, "** splitString[: %08x", fgcolor);
 					break;
@@ -773,12 +791,12 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 				case ']': { // \016]  -- setting default color
 					s++;
 
-					current_format.palinfo1 = _defaultFormatting.palinfo1;
-					current_format.palinfo2 = _defaultFormatting.palinfo2;
-					current_format.palinfo3 = _defaultFormatting.palinfo3;
-					current_format.fgcolor = _defaultFormatting.fgcolor;
+					chunk.palinfo1 = _defaultFormatting.palinfo1;
+					chunk.palinfo2 = _defaultFormatting.palinfo2;
+					chunk.palinfo3 = _defaultFormatting.palinfo3;
+					chunk.fgcolor = _defaultFormatting.fgcolor;
 
-					D(9, "** splitString]: %08x", current_format.fgcolor);
+					D(9, "** splitString]: %08x", chunk.fgcolor);
 					break;
 					}
 
@@ -793,7 +811,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 					s += len;
 
-					firstLineIndent = -current_format.getFont()->getStringWidth(bullet);
+					firstLineIndent = -chunk.getFont()->getStringWidth(bullet);
 
 					D(9, "** splitString*: %02x '%s' (%d)", len, bullet.encode().c_str(), firstLineIndent);
 					break;
@@ -834,7 +852,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 					s = readHex(&fontId, s, 4);
 
-					current_format.fontId = fontId == 0xffff ? _defaultFormatting.fontId : fontId;
+					chunk.fontId = fontId == 0xffff ? _defaultFormatting.fontId : fontId;
 
 					D(9, "** splitString[t]: fontId: %d", fontId);
 					break;
@@ -846,7 +864,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 					uint16 len;
 
 					s = readHex(&len, s, 2);
-					current_format.link = Common::U32String(s, len);
+					chunk.link = Common::U32String(s, len);
 					s += len;
 					break;
 					}
@@ -891,129 +909,24 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 					s = readHex(&palinfo2, s, 4);
 					s = readHex(&palinfo3, s, 4);
 
-					current_format.setValues(_wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
+					chunk.setValues(_wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
 
 					D(9, "** splitString: fontId: %d, textSlant: %d, fontSize: %d, fg: %04x",
-							fontId, textSlant, fontSize, current_format.fgcolor);
+							fontId, textSlant, fontSize, chunk.fgcolor);
 
 					// So far, we enforce single font here, though in the future, font size could be altered
 					if (!_macFontMode)
-						current_format.font = _defaultFormatting.font;
+						chunk.font = _defaultFormatting.font;
 					}
 				}
 			}
 
-			while (*s && *s != ' ' && *s != '\001') {
-				tmp += *s;
-				s++;
-			}
-			// meaning there is a word with multifont
-			if (*s == '\001') {
-				_textLines[curLine].chunks.push_back(current_format);
-				_textLines[curLine].lastChunk().wordContinuation = true;
-				_textLines[curLine].lastChunk().text = tmp;
-				continue;
-			}
 
 			_textLines[curLine].indent = indentSize;
 			_textLines[curLine].firstLineIndent = firstLineIndent;
 
-			// calc word_width, the trick we define here is we don`t count the space
-			int word_width = _textLines[curLine].indent + getStringWidth(current_format, tmp) + firstLineIndent;
-			// add all spaces left
-			while (*s == ' ') {
-				tmp += *s;
-				s++;
-			}
-
-			// now let`s try to split
-			// first we have to try to get the whole word
-			Common::Array<MacFontRun> word;
-			word.push_back(current_format);
-			word[0].text = tmp;
-
-			while (!_textLines[curLine].chunks.empty() && _textLines[curLine].lastChunk().wordContinuation) {
-				word.push_back(_textLines[curLine].lastChunk());
-				_textLines[curLine].chunks.pop_back();
-			}
-
-			for (int i = 1; i < (int)word.size(); i++) {
-				word_width += getStringWidth(word[i], word[i].text);
-				D(9, "** word \"%s\" textslant [%d]", Common::toPrintable(word[i].text.encode()).c_str(), word[i].textSlant);
-			}
-
-			int cur_width = getLineWidth(curLine, true);
-
-			D(9, "curWidth %d word_width %d", cur_width, word_width);
-			// if cur_width == 0 but there`s chunks, meaning there must be empty string here
-			// if cur_width == 0, then you don`t have to add a newline for it
-			if (cur_width + word_width >= _maxWidth && cur_width != 0) {
-				++curLine;
-				_textLines.insert_at(curLine, MacTextLine());
-				_textLines[curLine].indent = indentSize;
-				_textLines[curLine].firstLineIndent = 0;
-				firstLineIndent = 0;
-			}
-
-			// deal with the super long word situation
-			if (word_width > _maxWidth) {
-				for (int i = word.size() - 1; i >= 0; i--) {
-					cur_width = getLineWidth(curLine, true);
-					// count the size without space
-					// because you don`t want to split a word just for space
-					// actually i think this part can be optimized because only word[0] have space
-					// we just need to deal it specially
-
-					// meaning you have to split this word;
-					int tmp_width = _textLines[curLine].indent;
-					_textLines[curLine].chunks.push_back(word[i]);
-					// empty the string
-					_textLines[curLine].lastChunk().text = Common::U32String();
-					for (Common::U32String::const_iterator it = word[i].text.begin(); it != word[i].text.end(); it++) {
-						Common::U32String::unsigned_type c = *it;
-						if (c == ' ') {
-							// add the space left
-							while (it != word[i].text.end()) {
-								c = *it;
-								_textLines[curLine].lastChunk().text += c;
-								it++;
-							}
-							break;
-						}
-
-						// here, if we are in the plainByteMode, then we need to get the original text width, because current font may not resolve that u32string
-						int char_width = 0;
-						if (word[i].plainByteMode()) {
-							char_width = word[i].getFont()->getCharWidth(Common::convertFromU32String(Common::U32String(it, 1), word[i].getEncoding())[0]);
-						} else {
-							char_width = word[i].getFont()->getCharWidth(c);
-						}
-						if (char_width + tmp_width + cur_width >= _maxWidth) {
-							++curLine;
-							_textLines.insert_at(curLine, MacTextLine());
-							_textLines[curLine].chunks.push_back(word[i]);
-							_textLines[curLine].lastChunk().text = Common::U32String();
-							_textLines[curLine].firstLineIndent = 0;
-							firstLineIndent = 0;
-							tmp_width = _textLines[curLine].indent;
-							cur_width = _textLines[curLine].indent;
-						}
-						tmp_width += char_width;
-						_textLines[curLine].lastChunk().text += c;
-					}
-				}
-			} else {
-				for (int i = word.size() - 1; i >= 0; i--) {
-					_textLines[curLine].chunks.push_back(word[i]);
-				}
-			}
-
-			// If it is end of the line, we're done
-			if (!*s) {
-				_textLines[curLine].paragraphEnd = true;
-				D(9, "** splitString, end of line");
-				break;
-			}
+			// Push new formatting
+			_textLines[curLine].chunks.push_back(chunk);
 		}
 
 		if (!*l) { // If this is end of the string, we're done here
@@ -1032,6 +945,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 		curLine++;
 		_textLines.insert_at(curLine, MacTextLine());
+		_textLines[curLine].chunks.push_back(chunk);
 	}
 
 #if DEBUG


Commit: 6de2d6c8d29a37f63c2443ebbf8ca440227a005a
    https://github.com/scummvm/scummvm/commit/6de2d6c8d29a37f63c2443ebbf8ca440227a005a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-09-25T23:30:38+02:00

Commit Message:
GRAPHICS: MACGUI: Fix headre rendering in Markdown

Changed paths:
    graphics/macgui/mactext-md.cpp


diff --git a/graphics/macgui/mactext-md.cpp b/graphics/macgui/mactext-md.cpp
index 9399b5bd1d1..e8198f5297b 100644
--- a/graphics/macgui/mactext-md.cpp
+++ b/graphics/macgui/mactext-md.cpp
@@ -64,7 +64,7 @@ void render_header(Common::SDDataBuffer *ob, const Common::SDDataBuffer *text, i
 
 	debug(1, "render_header(%s)", PR(text));
 
-	Common::String res = Common::String::format("\016+00%01x0" "%s" "\001\016-00f0\n", level, Common::String((const char *)text->data , text->size).c_str());
+	Common::String res = Common::String::format("\001\016+00%01x0" "%s" "\001\016-00f0\n", level, Common::String((const char *)text->data , text->size).c_str());
 
 	sd_bufput(ob, res.c_str(), res.size());
 }


Commit: 358bbe93cc78e906dba3d07219d7cab193104b75
    https://github.com/scummvm/scummvm/commit/358bbe93cc78e906dba3d07219d7cab193104b75
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-09-25T23:30:38+02:00

Commit Message:
GRAPHICS: MACGUI: More work on digesting tables in MacText

Changed paths:
    graphics/macgui/mactext-md.cpp
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext-md.cpp b/graphics/macgui/mactext-md.cpp
index e8198f5297b..ace5af4f012 100644
--- a/graphics/macgui/mactext-md.cpp
+++ b/graphics/macgui/mactext-md.cpp
@@ -133,7 +133,7 @@ void render_table(Common::SDDataBuffer *ob, const Common::SDDataBuffer *header,
 	if (!body)
 		return;
 
-	Common::String res = Common::String::format("\016Th" "%s\n" "\001\016Tb" "%s\n" "\016TB\n",
+	Common::String res = Common::String::format("\001\016Th" "%s" "\001\016Tb" "%s" "\001\016TB",
 			Common::String((const char *)header->data , header->size).c_str(), Common::String((const char *)body->data , body->size).c_str());
 
 	sd_bufput(ob, res.c_str(), res.size());
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 2fdab51419e..ba9a10a1530 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -568,8 +568,16 @@ void MacText::setDefaultFormatting(uint16 fontId, byte textSlant, uint16 fontSiz
 // formatting
 void MacText::chopChunk(const Common::U32String &str, int *curLinePtr) {
 	int curLine = *curLinePtr;
-	int curChunk = _textLines[curLine].chunks.size() - 1;
-	MacFontRun *chunk = &_textLines[curLine].chunks[curChunk];
+	int curChunk;
+	MacFontRun *chunk;
+
+	if (!_inTable) {
+		curChunk = _textLines[curLine].chunks.size() - 1;
+		chunk = &_textLines[curLine].chunks[curChunk];
+	} else {
+		curChunk = _textLines[curLine].table->back().cells.back().text.back().chunks.size() - 1;
+		chunk = &_textLines[curLine].table->back().cells.back().text.back().chunks[curChunk];
+	}
 
 	// Check if there is nothing to add, then remove the last chunk
 	// This happens when the previous run is finished only with
@@ -617,9 +625,14 @@ void MacText::chopChunk(const Common::U32String &str, int *curLinePtr) {
 	for (uint i = 1; i < text.size(); i++) {
 		newchunk.text = text[i];
 
-		curLine++;
-		_textLines.insert_at(curLine, MacTextLine());
-		_textLines[curLine].chunks.push_back(newchunk);
+		if (!_inTable) {
+			curLine++;
+			_textLines.insert_at(curLine, MacTextLine());
+			_textLines[curLine].chunks.push_back(newchunk);
+		} else {
+			_textLines[curLine].table->back().cells.back().text.push_back(MacTextLine());
+			_textLines[curLine].table->back().cells.back().text.back().chunks.push_back(newchunk);
+		}
 
 		D(9, "** chopChunk, added line: \"%s\"", toPrintable(text[i].encode()).c_str());
 	}
@@ -684,6 +697,8 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 		tmp.clear();
 
+		MacTextLine *curTextLine = &_textLines[curLine];
+
 		while (*s) {
 			// Scan till next font change or end of line
 			while (*s && *s != '\001') {
@@ -708,6 +723,8 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 			// chunk definition. That means, that we have to store the previous chunk
 			chopChunk(tmp, &curLine);
 
+			curTextLine = &_textLines[curLine];
+
 			tmp.clear();
 
 			// If it is end of the line, we're done
@@ -880,18 +897,24 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 						_inTable = true;
 
-						_textLines[curLine].table = new Common::Array<MacTextTableRow>();
+						curTextLine->table = new Common::Array<MacTextTableRow>();
 					} else if (cmd == 'b') { // Body start
 					} else if (cmd == 'B') { // Body end
 						_inTable = false;
+
+						curTextLine = &_textLines[curLine];
 					} else if (cmd == 'r') { // Row
-						_textLines[curLine].table->push_back(MacTextTableRow());
+						curTextLine->table->push_back(MacTextTableRow());
 					} else if (cmd == 'c') { // Cell start
 						uint16 flags;
 						s = readHex(&flags, s, 2);
 
-						_textLines[curLine].table->back().cells.push_back(MacTextTableCell());
-						_textLines[curLine].table->back().cells.back().flags = flags;
+						curTextLine->table->back().cells.push_back(MacTextTableCell());
+						curTextLine->table->back().cells.back().flags = flags;
+
+						curTextLine->table->back().cells.back().text.resize(1);
+						curTextLine = &curTextLine->table->back().cells.back().text[0];
+						curTextLine->chunks.push_back(_defaultFormatting);
 					} else if (cmd == 'C') { // Cell end
 					} else {
 						error("MacText: Unknown table subcommand (%c)", cmd);
@@ -922,11 +945,11 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 			}
 
 
-			_textLines[curLine].indent = indentSize;
-			_textLines[curLine].firstLineIndent = firstLineIndent;
+			curTextLine->indent = indentSize;
+			curTextLine->firstLineIndent = firstLineIndent;
 
 			// Push new formatting
-			_textLines[curLine].chunks.push_back(chunk);
+			curTextLine->chunks.push_back(chunk);
 		}
 
 		if (!*l) { // If this is end of the string, we're done here
@@ -936,16 +959,20 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 		// Add new line
 		D(9, "** splitString: new line");
 
-		_textLines[curLine].paragraphEnd = true;
+		curTextLine->paragraphEnd = true;
 		// if the chunks is empty, which means the line will not be rendered properly
 		// so we add a empty string here
-		if (_textLines[curLine].chunks.empty()) {
-			_textLines[curLine].chunks.push_back(_defaultFormatting);
+		if (curTextLine->chunks.empty()) {
+			curTextLine->chunks.push_back(_defaultFormatting);
 		}
 
-		curLine++;
-		_textLines.insert_at(curLine, MacTextLine());
-		_textLines[curLine].chunks.push_back(chunk);
+		if (!_inTable) {
+			curLine++;
+			_textLines.insert_at(curLine, MacTextLine());
+			_textLines[curLine].chunks.push_back(chunk);
+
+			curTextLine = &_textLines[curLine];
+		}
 	}
 
 #if DEBUG


Commit: c0511db8daecf387cd50fa88fd83e193f1dc2af6
    https://github.com/scummvm/scummvm/commit/c0511db8daecf387cd50fa88fd83e193f1dc2af6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-09-25T23:32:05+02:00

Commit Message:
GUI: Fix warning and remove leftover code

Changed paths:
    gui/launcher.cpp


diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 43712840fa5..ff891613ee5 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -258,8 +258,7 @@ void LauncherDialog::build() {
 #endif
 		new StaticTextWidget(this, _title + ".Version", Common::U32String(gScummVMFullVersion));
 
-	//if (g_system->hasFeature(OSystem::kFeatureHelpDialog))
-		new ButtonWidget(this, _title + ".HelpButton", Common::U32String("?"), _("Help"), kHelpCmd);
+	new ButtonWidget(this, _title + ".HelpButton", Common::U32String("?"), _("Help"), kHelpCmd);
 
 	if (!g_system->hasFeature(OSystem::kFeatureNoQuit)) {
 		// I18N: Button Quit ScummVM program. Q is the shortcut, Ctrl+Q, put it in parens for non-latin (~Q~)




More information about the Scummvm-git-logs mailing list