mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
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
This commit is contained in:
parent
09046947d4
commit
887ca3145e
@ -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;
|
||||
}
|
||||
|
@ -165,6 +165,8 @@ void Kernel::mapSelectors() {
|
||||
FIND_SELECTOR(plane);
|
||||
FIND_SELECTOR(top);
|
||||
FIND_SELECTOR(left);
|
||||
FIND_SELECTOR(dimmed);
|
||||
FIND_SELECTOR(fore);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -204,6 +204,9 @@ struct SelectorCache {
|
||||
Selector plane;
|
||||
Selector top;
|
||||
Selector left;
|
||||
|
||||
Selector fore;
|
||||
Selector dimmed;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -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++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user