(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
authortron
Sun, 06 Feb 2005 18:30:45 +0000
changeset 1323 41397685320a
parent 1322 8697b73baa64
child 1324 ff8b7799b44f
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
aircraft_gui.c
gfx.c
gfx.h
main_gui.c
misc_gui.c
network_gui.c
player_gui.c
roadveh_gui.c
settings_gui.c
ship_gui.c
station_gui.c
town_gui.c
train_gui.c
variables.h
window.h
--- a/aircraft_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/aircraft_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -151,7 +151,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
@@ -506,7 +506,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
--- a/gfx.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/gfx.c	Sun Feb 06 18:30:45 2005 +0000
@@ -291,12 +291,12 @@
 	GfxFillRect(x-(w>>1), y+10, x-(w>>1)+w, y+10, _string_colorremap[1]);
 }
 
-static uint32 FormatStringLinebreaks(byte *str, int maxw)
+static uint32 FormatStringLinebreaks(char *str, int maxw)
 {
 	int num = 0;
 	int base = _stringwidth_base;
 	int w;
-	byte *last_space;
+	char *last_space;
 	byte c;
 
 	for(;;) {
@@ -336,7 +336,7 @@
 {
 	uint32 tmp;
 	int num, w, mt, t;
-	byte *src;
+	const char *src;
 	byte c;
 
 	GetString(str_buffr, str);
@@ -382,7 +382,7 @@
 void DrawStringMultiLine(int x, int y, uint16 str, int maxw) {
 	uint32 tmp;
 	int num, w, mt, t;
-	byte *src;
+	const char *src;
 	byte c;
 
 	GetString(str_buffr, str);
@@ -422,7 +422,8 @@
 	}
 }
 
-int GetStringWidth(const byte *str) {
+int GetStringWidth(const char *str)
+{
 	int w = -1;
 	byte c;
 	int base = _stringwidth_base;
@@ -475,7 +476,8 @@
 	}
 }
 
-int DoDrawString(const byte *string, int x, int y, uint16 real_color) {
+int DoDrawString(const char *string, int x, int y, uint16 real_color)
+{
 	DrawPixelInfo *dpi = _cur_dpi;
 	int base = _stringwidth_base;
 	byte c;
@@ -539,10 +541,10 @@
 			color = (byte)(c - ASCII_COLORSTART);
 			goto switch_color;
 		} else if (c == ASCII_SETX) { // {SETX}
-			x = xo + *string++;
+			x = xo + (byte)*string++;
 		} else if (c == ASCII_SETXY) {// {SETXY}
-			x = xo + *string++;
-			y = yo + *string++;
+			x = xo + (byte)*string++;
+			y = yo + (byte)*string++;
 		} else if (c == ASCII_TINYFONT) { // {TINYFONT}
 			base = 0xE0;
 		} else if (c == ASCII_BIGFONT) { // {BIGFONT}
--- a/gfx.h	Sun Feb 06 18:28:35 2005 +0000
+++ b/gfx.h	Sun Feb 06 18:30:45 2005 +0000
@@ -45,14 +45,14 @@
 int DrawStringCentered(int x, int y, uint16 str, uint16 color);
 int DrawString(int x, int y, uint16 str, uint16 color);
 void DrawStringCenterUnderline(int x, int y, uint16 str, uint16 color);
-int DoDrawString(const byte *string, int x, int y, uint16 color);
+int DoDrawString(const char *string, int x, int y, uint16 color);
 void DrawStringRightAligned(int x, int y, uint16 str, uint16 color);
 void GfxFillRect(int left, int top, int right, int bottom, int color);
 void GfxDrawLine(int left, int top, int right, int bottom, int color);
 void DrawFrameRect(int left, int top, int right, int bottom, int color, int flags);
 uint16 GetDrawStringPlayerColor(byte player);
 
-int GetStringWidth(const byte *str);
+int GetStringWidth(const char *str);
 void LoadStringWidthTable(void);
 void DrawStringMultiCenter(int x, int y, uint16 str, int maxw);
 void DrawStringMultiLine(int x, int y, uint16 str, int maxw);
--- a/main_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/main_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -61,7 +61,7 @@
 }
 
 void HandleOnEditText(WindowEvent *e) {
-	byte *b = e->edittext.str;
+	const char *b = e->edittext.str;
 	int id;
 	memcpy(_decode_parameters, b, 32);
 
--- a/misc_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/misc_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -901,7 +901,7 @@
 					!_do_edit_on_text_even_when_no_change_to_edit_box) {
 				DeleteWindow(w);
 			} else {
-				byte *buf = WP(w,querystr_d).buf;
+				char *buf = WP(w,querystr_d).buf;
 				WindowClass wnd_class = WP(w,querystr_d).wnd_class;
 				WindowNumber wnd_num = WP(w,querystr_d).wnd_num;
 				Window *parent;
@@ -978,7 +978,7 @@
 	QueryStringWndProc
 };
 
-static byte _edit_str_buf[MAX_QUERYSTR_LEN*2];
+static char _edit_str_buf[MAX_QUERYSTR_LEN*2];
 
 void ShowQueryString(StringID str, StringID caption, int maxlen, int maxwidth, byte window_class, uint16 window_number)
 {
--- a/network_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/network_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -24,7 +24,7 @@
 #define BGC 5
 #define BTC 15
 #define MAX_QUERYSTR_LEN 64
-static byte _edit_str_buf[MAX_QUERYSTR_LEN*2];
+static char _edit_str_buf[MAX_QUERYSTR_LEN*2];
 static void ShowNetworkStartServerWindow(void);
 static void ShowNetworkLobbyWindow(void);
 
@@ -611,7 +611,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		ttd_strlcpy(_network_server_password, b, sizeof(_network_server_password));
 		if (_network_server_password[0] == '\0') {
 			_network_game_info.use_password = 0;
@@ -1373,7 +1373,7 @@
 			if (strcmp(WP(w,querystr_d).buf, WP(w,querystr_d).buf + MAX_QUERYSTR_LEN) == 0) {
 				DeleteWindow(w);
 			} else {
-				byte *buf = WP(w,querystr_d).buf;
+				char *buf = WP(w,querystr_d).buf;
 				WindowClass wnd_class = WP(w,querystr_d).wnd_class;
 				WindowNumber wnd_num = WP(w,querystr_d).wnd_num;
 				Window *parent;
--- a/player_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/player_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -639,7 +639,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		char *b = (char*)e->edittext.str;
+		char *b = e->edittext.str;
 
 		if (*b == 0 && WP(w,def_d).byte_1 != 2) // empty string is allowed for password
 			return;
--- a/roadveh_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/roadveh_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -160,7 +160,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
@@ -431,7 +431,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
--- a/settings_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/settings_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -1465,7 +1465,7 @@
 
 	case WE_ON_EDIT_TEXT: {
 			int val;
-			byte *b = e->edittext.str;
+			const char *b = e->edittext.str;
 			switch (WP(w,def_d).data_2) {
 				case 0:
 					val = atoi(b);
--- a/ship_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/ship_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -280,7 +280,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
@@ -422,7 +422,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
--- a/station_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/station_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -509,7 +509,7 @@
 
 	case WE_ON_EDIT_TEXT: {
 		Station *st;
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
--- a/town_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/town_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -273,7 +273,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
--- a/train_gui.c	Sun Feb 06 18:28:35 2005 +0000
+++ b/train_gui.c	Sun Feb 06 18:30:45 2005 +0000
@@ -219,7 +219,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 
@@ -1180,7 +1180,7 @@
 		break;
 
 	case WE_ON_EDIT_TEXT: {
-		byte *b = e->edittext.str;
+		const char *b = e->edittext.str;
 		if (*b == 0)
 			return;
 		memcpy(_decode_parameters, b, 32);
--- a/variables.h	Sun Feb 06 18:28:35 2005 +0000
+++ b/variables.h	Sun Feb 06 18:30:45 2005 +0000
@@ -431,7 +431,7 @@
 extern const byte _airport_size_y[5];
 
 /* misc */
-VARDEF byte str_buffr[512];
+VARDEF char str_buffr[512];
 VARDEF char _screenshot_name[128];
 #define USERSTRING_LEN 128
 VARDEF char _userstring[USERSTRING_LEN];
--- a/window.h	Sun Feb 06 18:28:35 2005 +0000
+++ b/window.h	Sun Feb 06 18:30:45 2005 +0000
@@ -91,7 +91,7 @@
 
 	struct {
 		byte event;
-		byte *str;
+		char *str;
 	} edittext;
 
 	struct {
@@ -228,7 +228,7 @@
 	WindowClass wnd_class;
 	WindowNumber wnd_num;
 	uint16 maxlen, maxwidth;
-	byte *buf;
+	char *buf;
 } querystr_d;
 
 #define WP(ptr,str) (*(str*)(ptr)->custom)