aboutsummaryrefslogtreecommitdiff
path: root/engines
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
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')
-rw-r--r--engines/sci/engine/kernel32.cpp2
-rw-r--r--engines/sci/engine/selector.cpp2
-rw-r--r--engines/sci/engine/vm.h3
-rw-r--r--engines/sci/graphics/frameout.cpp27
4 files changed, 33 insertions, 1 deletions
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp
index 44a6a04b23..917637a7c1 100644
--- a/engines/sci/engine/kernel32.cpp
+++ b/engines/sci/engine/kernel32.cpp
@@ -778,7 +778,7 @@ reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) {
// TODO: argument 0 is usually 0, and arguments 1 and 2 are usually 1
reg_t object = argv[3];
Common::String text = s->_segMan->getString(GET_SEL32(s->_segMan, object, text));
- debug("%s", text.c_str());
+ debug("kCreateTextBitmap: %s", text.c_str());
return NULL_REG;
}
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 8e3f57e547..c2bc7de2ac 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -165,6 +165,8 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(plane);
FIND_SELECTOR(top);
FIND_SELECTOR(left);
+ FIND_SELECTOR(dimmed);
+ FIND_SELECTOR(fore);
#endif
}
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 6da1868805..85ece64d7a 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -204,6 +204,9 @@ struct SelectorCache {
Selector plane;
Selector top;
Selector left;
+
+ Selector fore;
+ Selector dimmed;
#endif
};
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++;
}