From 0de664d0a886bcda45a0cd05551b6896c5c46ed0 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Sat, 14 Feb 2015 12:00:00 +0100 Subject: Import icculus.org release (2015-02-14) --- src/menus.c | 55 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'src/menus.c') diff --git a/src/menus.c b/src/menus.c index 25e98ae..1679d00 100644 --- a/src/menus.c +++ b/src/menus.c @@ -115,13 +115,6 @@ AVPMENUGFX AvPMenuGfxStorage[MAX_NO_OF_AVPMENUGFXS] = #endif }; -int CreateIMGSurface(D3DTexture *tex, unsigned char *buf) -{ - tex->id = 0; - - return 0; -} - static void DrawAvPMenuGlowyBar(int topleftX, int topleftY, int alpha, int length) { enum AVPMENUGFX_ID menuGfxID = AVPMENUGFX_GLOWY_MIDDLE; @@ -449,17 +442,25 @@ int RenderMenuText(const char *textPtr, int sx, int sy, int alpha, enum AVPMENUF char c = *textPtr++; if (c>=' ') { - int topLeftU = 1; - int topLeftV = 1+(c-32)*33; - int x, y; - int width = IntroFont_Light.FontWidth[(unsigned int) c]; - + unsigned int topLeftU = 0; + unsigned int topLeftV = 1+(c-32)*33; + unsigned int x, y; + unsigned int width = IntroFont_Light.FontWidth[(unsigned int) c]; + unsigned int remainder = 0; + unsigned int stride = width; + + if (image->w > width) { + remainder = image->w - width; + } else { + stride = image->w; + } + srcPtr = &image->buf[(topLeftU+topLeftV*image->w)*4]; - + for (y=sy; y<33+sy; y++) { destPtr = (unsigned short *)(((unsigned char *)surface->pixels)+y*surface->pitch) + sx; - for (x=width; x>0; x--) { + for (x=stride; x>0; x--) { if (srcPtr[0] || srcPtr[1] || srcPtr[2]) { unsigned int destR, destG, destB; @@ -484,7 +485,7 @@ int RenderMenuText(const char *textPtr, int sx, int sy, int alpha, enum AVPMENUF srcPtr += 4; destPtr++; } - srcPtr += (image->w - width) * 4; + srcPtr += remainder * 4; } sx += width; } @@ -546,18 +547,26 @@ int RenderMenuText_Clipped(char *textPtr, int sx, int sy, int alpha, enum AVPMEN char c = *textPtr++; if (c>=' ') { - int topLeftU = 1; - int topLeftV = 1+(c-32)*33; - int x, y; - int width = IntroFont_Light.FontWidth[(unsigned int) c]; - + unsigned int topLeftU = 0; + unsigned int topLeftV = 1+(c-32)*33; + unsigned int x, y; + unsigned int width = IntroFont_Light.FontWidth[(unsigned int) c]; + unsigned int remainder = 0; + unsigned int stride = width; + + if (image->w > width) { + remainder = image->w - width; + } else { + stride = image->w; + } + srcPtr = &image->buf[(topLeftU+topLeftV*image->w)*4]; - + for (y=sy; y<33+sy; y++) { if(y>=topY && y<=bottomY) { destPtr = (unsigned short *)(((unsigned char *)surface->pixels)+y*surface->pitch) + sx; - for (x=width; x>0; x--) { + for (x=stride; x>0; x--) { if (srcPtr[0] || srcPtr[1] || srcPtr[2]) { unsigned int destR, destG, destB; @@ -582,7 +591,7 @@ int RenderMenuText_Clipped(char *textPtr, int sx, int sy, int alpha, enum AVPMEN srcPtr += 4; destPtr++; } - srcPtr += (image->w - width) * 4; + srcPtr += remainder * 4; } else { srcPtr += image->w * 4; } -- cgit v1.3