Changeset - r1323:29249e0649f7
[Not reviewed]
master
0 15 0
tron - 19 years ago 2005-02-06 18:30:45
tron@openttd.org
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
15 files changed with 34 insertions and 32 deletions:
0 comments (0 inline, 0 general)
aircraft_gui.c
Show inline comments
 
@@ -151,7 +151,7 @@ static void NewAircraftWndProc(Window *w
 
		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 @@ change_int:
 
		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);
gfx.c
Show inline comments
 
@@ -291,12 +291,12 @@ void DrawStringCenterUnderline(int x, in
 
	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 @@ void DrawStringMultiCenter(int x, int y,
 
{
 
	uint32 tmp;
 
	int num, w, mt, t;
 
	byte *src;
 
	const char *src;
 
	byte c;
 

	
 
	GetString(str_buffr, str);
 
@@ -382,7 +382,7 @@ void DrawStringMultiCenter(int x, int y,
 
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 @@ void DrawStringMultiLine(int x, int y, u
 
	}
 
}
 

	
 
int GetStringWidth(const byte *str) {
 
int GetStringWidth(const char *str)
 
{
 
	int w = -1;
 
	byte c;
 
	int base = _stringwidth_base;
 
@@ -475,7 +476,8 @@ void DrawFrameRect(int left, int top, in
 
	}
 
}
 

	
 
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 @@ skip_cont:;
 
			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}
gfx.h
Show inline comments
 
@@ -45,14 +45,14 @@ void GfxScroll(int left, int top, int wi
 
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);
main_gui.c
Show inline comments
 
@@ -61,7 +61,7 @@ void HandleOnEditTextCancel(void)
 
}
 

	
 
void HandleOnEditText(WindowEvent *e) {
 
	byte *b = e->edittext.str;
 
	const char *b = e->edittext.str;
 
	int id;
 
	memcpy(_decode_parameters, b, 32);
 

	
misc_gui.c
Show inline comments
 
@@ -901,7 +901,7 @@ press_ok:;
 
					!_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 @@ static const WindowDesc _query_string_de
 
	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)
 
{
network_gui.c
Show inline comments
 
@@ -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 @@ static void NetworkStartServerWindowWndP
 
		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 @@ press_ok:;
 
			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;
player_gui.c
Show inline comments
 
@@ -639,7 +639,7 @@ static void PlayerCompanyWndProc(Window 
 
		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;
roadveh_gui.c
Show inline comments
 
@@ -160,7 +160,7 @@ change_int:
 
		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 @@ static void NewRoadVehWndProc(Window *w,
 
		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);
settings_gui.c
Show inline comments
 
@@ -1465,7 +1465,7 @@ static void CustCurrencyWndProc(Window *
 

	
 
	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);
ship_gui.c
Show inline comments
 
@@ -280,7 +280,7 @@ change_int:
 
		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 @@ static void NewShipWndProc(Window *w, Wi
 
		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);
station_gui.c
Show inline comments
 
@@ -509,7 +509,7 @@ static void StationViewWndProc(Window *w
 

	
 
	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);
town_gui.c
Show inline comments
 
@@ -273,7 +273,7 @@ static void TownViewWndProc(Window *w, W
 
		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);
train_gui.c
Show inline comments
 
@@ -219,7 +219,7 @@ static void NewRailVehicleWndProc(Window
 
		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 @@ do_change_service_int:
 
		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);
variables.h
Show inline comments
 
@@ -431,7 +431,7 @@ extern const byte _airport_size_x[5];
 
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];
window.h
Show inline comments
 
@@ -91,7 +91,7 @@ union WindowEvent {
 

	
 
	struct {
 
		byte event;
 
		byte *str;
 
		char *str;
 
	} edittext;
 

	
 
	struct {
 
@@ -228,7 +228,7 @@ typedef struct {
 
	WindowClass wnd_class;
 
	WindowNumber wnd_num;
 
	uint16 maxlen, maxwidth;
 
	byte *buf;
 
	char *buf;
 
} querystr_d;
 

	
 
#define WP(ptr,str) (*(str*)(ptr)->custom)
0 comments (0 inline, 0 general)