diff options
author | tron <tron@openttd.org> | 2005-02-06 18:30:45 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-02-06 18:30:45 +0000 |
commit | c644e6b742eb14185fec50fa5a8918e6d4cc41a0 (patch) | |
tree | bd9ddff4e0a96d3d0b9feb95bcb7667184e63060 | |
parent | 85dc9fb637ffb4c4b476f1ca15a5b0461078dd82 (diff) | |
download | openttd-c644e6b742eb14185fec50fa5a8918e6d4cc41a0.tar.xz |
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
-rw-r--r-- | aircraft_gui.c | 4 | ||||
-rw-r--r-- | gfx.c | 20 | ||||
-rw-r--r-- | gfx.h | 4 | ||||
-rw-r--r-- | main_gui.c | 2 | ||||
-rw-r--r-- | misc_gui.c | 4 | ||||
-rw-r--r-- | network_gui.c | 6 | ||||
-rw-r--r-- | player_gui.c | 2 | ||||
-rw-r--r-- | roadveh_gui.c | 4 | ||||
-rw-r--r-- | settings_gui.c | 2 | ||||
-rw-r--r-- | ship_gui.c | 4 | ||||
-rw-r--r-- | station_gui.c | 2 | ||||
-rw-r--r-- | town_gui.c | 2 | ||||
-rw-r--r-- | train_gui.c | 4 | ||||
-rw-r--r-- | variables.h | 2 | ||||
-rw-r--r-- | window.h | 4 |
15 files changed, 34 insertions, 32 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c index 0a8191b01..192aa1903 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -151,7 +151,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e) 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); @@ -291,12 +291,12 @@ void DrawStringCenterUnderline(int x, int y, uint16 str, uint16 color) 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, uint16 str, int maxw) { 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, uint16 str, int maxw) 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, uint16 str, int maxw) { } } -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, int right, int bottom, int ctab, int flags } } -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} @@ -45,14 +45,14 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo); 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); diff --git a/main_gui.c b/main_gui.c index 680e04f41..6089fc3d8 100644 --- a/main_gui.c +++ b/main_gui.c @@ -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); diff --git a/misc_gui.c b/misc_gui.c index 882e21d5c..6db7b61d7 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -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_desc = { 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) { diff --git a/network_gui.c b/network_gui.c index afa515b44..d12088d7a 100644 --- a/network_gui.c +++ b/network_gui.c @@ -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 NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) 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; diff --git a/player_gui.c b/player_gui.c index 4e2b85466..dbe25ea34 100644 --- a/player_gui.c +++ b/player_gui.c @@ -639,7 +639,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) 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; diff --git a/roadveh_gui.c b/roadveh_gui.c index 4a8128d4e..d5b5d28da 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -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, WindowEvent *e) 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); diff --git a/settings_gui.c b/settings_gui.c index 73690d579..2aee5f886 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -1465,7 +1465,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) 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); diff --git a/ship_gui.c b/ship_gui.c index 0e786aa93..2da8378f5 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -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, WindowEvent *e) 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); diff --git a/station_gui.c b/station_gui.c index d628211df..df1b419ba 100644 --- a/station_gui.c +++ b/station_gui.c @@ -509,7 +509,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e) 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); diff --git a/town_gui.c b/town_gui.c index a5441bbb4..8b4cb6f1b 100644 --- a/town_gui.c +++ b/town_gui.c @@ -273,7 +273,7 @@ static void TownViewWndProc(Window *w, WindowEvent *e) 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); diff --git a/train_gui.c b/train_gui.c index 85a5e8ee0..91db42a52 100644 --- a/train_gui.c +++ b/train_gui.c @@ -219,7 +219,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e) 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); diff --git a/variables.h b/variables.h index 9ac5800ef..99800f905 100644 --- a/variables.h +++ b/variables.h @@ -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]; @@ -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) |