(svn r14051) -Codechange: enumify the DrawString buffer length.

This commit is contained in:
rubidium 2008-08-12 11:21:37 +00:00
parent 61007078b6
commit a3910ced70
3 changed files with 17 additions and 10 deletions

View File

@ -320,7 +320,7 @@ static inline int TruncateStringID(StringID src, char *dest, int maxw, const cha
*/ */
int DrawString(int x, int y, StringID str, uint16 color) int DrawString(int x, int y, StringID str, uint16 color)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
GetString(buffer, str, lastof(buffer)); GetString(buffer, str, lastof(buffer));
return DoDrawString(buffer, x, y, color); return DoDrawString(buffer, x, y, color);
@ -339,7 +339,7 @@ int DrawString(int x, int y, StringID str, uint16 color)
*/ */
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw) int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
TruncateStringID(str, buffer, maxw, lastof(buffer)); TruncateStringID(str, buffer, maxw, lastof(buffer));
return DoDrawString(buffer, x, y, color); return DoDrawString(buffer, x, y, color);
} }
@ -356,7 +356,7 @@ int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw)
*/ */
int DrawStringRightAligned(int x, int y, StringID str, uint16 color) int DrawStringRightAligned(int x, int y, StringID str, uint16 color)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
int w; int w;
GetString(buffer, str, lastof(buffer)); GetString(buffer, str, lastof(buffer));
@ -377,7 +377,7 @@ int DrawStringRightAligned(int x, int y, StringID str, uint16 color)
*/ */
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw) void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
TruncateStringID(str, buffer, maxw, lastof(buffer)); TruncateStringID(str, buffer, maxw, lastof(buffer));
DoDrawString(buffer, x - GetStringBoundingBox(buffer).width, y, color); DoDrawString(buffer, x - GetStringBoundingBox(buffer).width, y, color);
@ -409,7 +409,7 @@ void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color)
*/ */
int DrawStringCentered(int x, int y, StringID str, uint16 color) int DrawStringCentered(int x, int y, StringID str, uint16 color)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
int w; int w;
GetString(buffer, str, lastof(buffer)); GetString(buffer, str, lastof(buffer));
@ -433,7 +433,7 @@ int DrawStringCentered(int x, int y, StringID str, uint16 color)
*/ */
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color) int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
int w = TruncateStringID(str, buffer, xr - xl, lastof(buffer)); int w = TruncateStringID(str, buffer, xr - xl, lastof(buffer));
return DoDrawString(buffer, (xl + xr - w) / 2, y, color); return DoDrawString(buffer, (xl + xr - w) / 2, y, color);
} }
@ -595,7 +595,7 @@ static int GetMultilineStringHeight(const char *src, int num)
*/ */
int GetStringHeight(StringID str, int maxw) int GetStringHeight(StringID str, int maxw)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
GetString(buffer, str, lastof(buffer)); GetString(buffer, str, lastof(buffer));
@ -612,7 +612,7 @@ int GetStringHeight(StringID str, int maxw)
* @param maxw Maximum width the string can have before it is wrapped */ * @param maxw Maximum width the string can have before it is wrapped */
void DrawStringMultiCenter(int x, int y, StringID str, int maxw) void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
uint32 tmp; uint32 tmp;
int num, w, mt; int num, w, mt;
const char *src; const char *src;
@ -655,7 +655,7 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh) uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
uint32 tmp; uint32 tmp;
int num, mt; int num, mt;
uint total_height; uint total_height;
@ -878,7 +878,7 @@ skip_cont:;
*/ */
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw) int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw)
{ {
char buffer[512]; char buffer[DRAW_STRING_BUFFER];
ttd_strlcpy(buffer, str, sizeof(buffer)); ttd_strlcpy(buffer, str, sizeof(buffer));
TruncateString(buffer, maxw); TruncateString(buffer, maxw);
return DoDrawString(buffer, x, y, color); return DoDrawString(buffer, x, y, color);

View File

@ -75,6 +75,11 @@ void ScreenSizeChanged();
void GameSizeChanged(); void GameSizeChanged();
void UndrawMouseCursor(); void UndrawMouseCursor();
enum {
/* Size of the buffer used for drawing strings. */
DRAW_STRING_BUFFER = 1024,
};
void RedrawScreenRect(int left, int top, int right, int bottom); void RedrawScreenRect(int left, int top, int right, int bottom);
void GfxScroll(int left, int top, int width, int height, int xo, int yo); void GfxScroll(int left, int top, int width, int height, int xo, int yo);

View File

@ -26,6 +26,8 @@
#include "table/strings.h" #include "table/strings.h"
assert_compile((int)DRAW_STRING_BUFFER >= (int)NETWORK_CHAT_LENGTH);
enum { enum {
MAX_CHAT_MESSAGES = 10, MAX_CHAT_MESSAGES = 10,
}; };