mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
This commit is contained in:
parent
eb28e8b322
commit
2fb453a4a5
@ -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);
|
||||
|
20
gfx.c
20
gfx.c
@ -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}
|
||||
|
4
gfx.h
4
gfx.h
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
4
window.h
4
window.h
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user