diff options
-rw-r--r-- | engines/wintermute/Base/BFontTT.cpp | 17 | ||||
-rw-r--r-- | engines/wintermute/Base/BRenderSDL.cpp | 4 | ||||
-rw-r--r-- | engines/wintermute/Base/BRenderSDL.h | 2 | ||||
-rw-r--r-- | engines/wintermute/Base/BSurface.h | 4 | ||||
-rw-r--r-- | engines/wintermute/Base/BSurfaceSDL.h | 12 |
5 files changed, 30 insertions, 9 deletions
diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index d1fad44c64..a183254f52 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -162,10 +162,10 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, warning("Draw text: %s", Text);
if (Text == NULL || strcmp((char *)Text, "") == 0) return;
- WideString text;
+ WideString text = (char*)Text;
// TODO: Why do we still insist on Widestrings everywhere?
- /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text);
+/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text);
else text = StringUtil::AnsiToWide((char *)Text);*/
if (MaxLength >= 0 && text.size() > MaxLength)
@@ -244,11 +244,20 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, //////////////////////////////////////////////////////////////////////////
CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) {
TextLineList lines;
- WrapText(text, width, maxHeight, lines);
+ // TODO
+ //WrapText(text, width, maxHeight, lines);
TextLineList::iterator it;
warning("CBFontTT::RenderTextToTexture - Not ported yet");
+// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const;
+ Graphics::Surface *surface = new Graphics::Surface();
+ surface->create(width, _fontHeight, Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 5, 1, 0));
+ _fallbackFont->drawString(surface, text, 0, 0, width, 255);
+ CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game);
+ retSurface->PutSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0)));
+ delete surface;
+ return retSurface;
#if 0 //TODO
int textHeight = lines.size() * (_maxCharHeight + _ascender);
SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
@@ -620,7 +629,7 @@ HRESULT CBFontTT::InitFont() { }
warning("I guess we got a file");
if (file) {
- //_font = Graphics::loadTTFFont(*file->getMemStream(), 12);
+ //_font = Graphics::loadTTFFont(*file->getMemStream(), _fontHeight);
} else {
_fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
warning("BFontTT::InitFont - Couldn't load %s", _fontFile);
diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index d8a27f67d7..066e89e83c 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -282,9 +282,9 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { }
// Replacement for SDL2's SDL_RenderCopy
-void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) {
+void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a) {
TransparentSurface src(*surf, false);
- src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(255, 255, 255, 255), dstRect->width(), dstRect->height() );
+ src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(r, g, b, a), dstRect->width(), dstRect->height() );
}
//////////////////////////////////////////////////////////////////////////
HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) {
diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 73dc88d4be..299eec3f0b 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -58,7 +58,7 @@ public: CBImage *TakeScreenshot();
- void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest);
+ void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255);
HRESULT SetViewport(int left, int top, int right, int bottom);
diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 046041ac6a..9da7db6a61 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -76,10 +76,10 @@ public: int _referenceCount;
char *_filename;
- int GetWidth() {
+ virtual int GetWidth() {
return _width;
}
- int GetHeight() {
+ virtual int GetHeight() {
return _height;
}
//void SetWidth(int Width){ _width = Width; }
diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 767db0fa74..4b43bd3467 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -62,6 +62,18 @@ public: /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin);
static long DLL_CALLCONV TellProc(fi_handle handle);*/
+ virtual int GetWidth() {
+ if (_surface) {
+ return _surface->w;
+ }
+ return _width;
+ }
+ virtual int GetHeight() {
+ if (_surface) {
+ return _surface->h;
+ }
+ return _height;
+ }
private:
// SDL_Texture *_texture;
|