aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorFilippos Karapetis2010-02-03 01:36:53 +0000
committerFilippos Karapetis2010-02-03 01:36:53 +0000
commit887ca3145ebfce7c54d2cffeffb3d40de3fbe272 (patch)
tree347bb5bb687bcd0654493d3ca96210727786f59c /engines/sci/graphics
parent09046947d4885dea20321c5ca1166e980b169517 (diff)
downloadscummvm-rg350-887ca3145ebfce7c54d2cffeffb3d40de3fbe272.tar.gz
scummvm-rg350-887ca3145ebfce7c54d2cffeffb3d40de3fbe272.tar.bz2
scummvm-rg350-887ca3145ebfce7c54d2cffeffb3d40de3fbe272.zip
Initial implementation of text drawing for SCI2 (it's a hack for now, done the "SCI0-SCI11" way, and text splitting is wrong...)
svn-id: r47838
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/frameout.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 9cd4c6d7f5..741501744c 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -32,6 +32,7 @@
#include "sci/engine/selector.h"
#include "sci/engine/vm.h"
#include "sci/graphics/cache.h"
+#include "sci/graphics/font.h"
#include "sci/graphics/view.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/picture.h"
@@ -149,6 +150,7 @@ void GfxFrameout::kernelFrameout() {
itemEntry->priority = GET_SEL32V(_segMan, itemObject, priority);
itemEntry->scaleX = GET_SEL32V(_segMan, itemObject, scaleX);
itemEntry->scaleY = GET_SEL32V(_segMan, itemObject, scaleY);
+ itemEntry->object = itemObject;
itemEntry->x += planeLeft;
itemEntry->y += planeTop;
@@ -198,6 +200,31 @@ void GfxFrameout::kernelFrameout() {
view->draw(itemEntry->celRect, itemEntry->celRect, itemEntry->celRect, itemEntry->loopNo, itemEntry->celNo, 255, 0, false);
else
view->drawScaled(itemEntry->celRect, itemEntry->celRect, itemEntry->celRect, itemEntry->loopNo, itemEntry->celNo, 255, itemEntry->scaleX, itemEntry->scaleY);
+ } else {
+ // Most likely a text entry
+ // This draws text the "SCI0-SCI11" way. In SCI2, text is prerendered in kCreateTextBitmap
+ // TODO: rewrite this the "SCI2" way (i.e. implement the text buffer to draw inside kCreateTextBitmap)
+ Kernel *kernel = ((SciEngine *)g_engine)->getKernel();
+ if (lookup_selector(_segMan, itemEntry->object, kernel->_selectorCache.text, NULL, NULL) == kSelectorVariable) {
+ Common::String text = _segMan->getString(GET_SEL32(_segMan, itemEntry->object, text));
+ int16 fontRes = GET_SEL32V(_segMan, itemEntry->object, font);
+ Font *font = new Font(_resMan, _screen, fontRes);
+ bool dimmed = GET_SEL32V(_segMan, itemEntry->object, dimmed);
+ uint16 foreColor = GET_SEL32V(_segMan, itemEntry->object, fore);
+ uint16 curX = itemEntry->x;
+ uint16 curY = itemEntry->y;
+ for (uint32 i = 0; i < text.size(); i++) {
+ // TODO: proper text splitting... this is a hack
+ if ((text[i] == ' ' && i > 0 && text[i - i] == ' ') || text[i] == '\n' ||
+ (curX + font->getCharWidth(text[i]) > _screen->getWidth())) {
+ curY += font->getCharHeight('A');
+ curX = itemEntry->x;
+ }
+ font->draw(text[i], curY, curX, foreColor, dimmed);
+ curX += font->getCharWidth(text[i]);
+ }
+ delete font;
+ }
}
listIterator++;
}