[Scummvm-cvs-logs] scummvm master -> 22097018bb348b4c29def9f1d2de4d802661a6b0
csnover
csnover at users.noreply.github.com
Fri Mar 11 03:08:22 CET 2016
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
22097018bb SCI32: Implement GfxText32::getTextCount
Commit: 22097018bb348b4c29def9f1d2de4d802661a6b0
https://github.com/scummvm/scummvm/commit/22097018bb348b4c29def9f1d2de4d802661a6b0
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-03-10T20:07:36-06:00
Commit Message:
SCI32: Implement GfxText32::getTextCount
Changed paths:
engines/sci/graphics/text32.cpp
engines/sci/graphics/text32.h
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index fa19047..99ffc6e 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -625,4 +625,33 @@ int16 GfxText32::getStringWidth(const Common::String &text) {
return getTextWidth(text, 0, 10000);
}
+int16 GfxText32::getTextCount(const Common::String &text, const uint index, const Common::Rect &textRect, const bool doScaling) {
+ const int16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth;
+ const int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight;
+
+ Common::Rect scaledRect(textRect);
+ if (doScaling) {
+ mulinc(scaledRect, Ratio(_scaledWidth, scriptWidth), Ratio(_scaledHeight, scriptHeight));
+ }
+
+ Common::String oldText = _text;
+ _text = text;
+
+ uint charIndex = index;
+ int16 maxWidth = scaledRect.width();
+ int16 lineCount = (scaledRect.height() - 2) / _font->getHeight();
+ while (lineCount--) {
+ getLongest(&charIndex, maxWidth);
+ }
+
+ _text = oldText;
+ return charIndex - index;
+}
+
+int16 GfxText32::getTextCount(const Common::String &text, const uint index, const GuiResourceId fontId, const Common::Rect &textRect, const bool doScaling) {
+ setFont(fontId);
+ return getTextCount(text, index, textRect, doScaling);
+}
+
+
} // End of namespace Sci
diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h
index 472d5e0..5768ea0 100644
--- a/engines/sci/graphics/text32.h
+++ b/engines/sci/graphics/text32.h
@@ -458,6 +458,20 @@ public:
* Retrieves the width of a line of text.
*/
int16 getStringWidth(const Common::String &text);
+
+ /**
+ * Gets the number of characters of `text`, starting
+ * from `index`, that can be safely rendered into
+ * `textRect`.
+ */
+ int16 getTextCount(const Common::String &text, const uint index, const Common::Rect &textRect, const bool doScaling);
+
+ /**
+ * Gets the number of characters of `text`, starting
+ * from `index`, that can be safely rendered into
+ * `textRect` using the given font.
+ */
+ int16 getTextCount(const Common::String &text, const uint index, const GuiResourceId fontId, const Common::Rect &textRect, const bool doScaling);
};
} // End of namespace Sci
More information about the Scummvm-git-logs
mailing list