mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
Better line wrapping for multiplayer chat messages
git-svn-id: https://svn.eduke32.com/eduke32@867 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
2b85433e4f
commit
f98227d6f3
5 changed files with 59 additions and 32 deletions
|
@ -119,6 +119,11 @@ const char *stripcolorcodes(const char *t)
|
|||
t++;
|
||||
continue;
|
||||
}
|
||||
if (*t == '^' && (Btoupper(*(t+1)) == 'S'||Btoupper(*(t+1)) == 'O'))
|
||||
{
|
||||
t += 2;
|
||||
continue;
|
||||
}
|
||||
colstrip[i] = *t;
|
||||
i++,t++;
|
||||
}
|
||||
|
@ -1340,6 +1345,12 @@ void OSD_Printf(const char *fmt, ...)
|
|||
if (isdigit(*(++chp)))
|
||||
s = *chp;
|
||||
}
|
||||
else if (*chp == '^' && Btoupper(*(chp+1)) == 'O')
|
||||
{
|
||||
chp++;
|
||||
p = osdtextpal;
|
||||
s = osdtextshade;
|
||||
}
|
||||
else if (*chp == '\r') osdpos=0;
|
||||
else if (*chp == '\n')
|
||||
{
|
||||
|
|
|
@ -151,6 +151,9 @@ static char recbuf[180];
|
|||
|
||||
extern void computergetinput(int snum, input *syn);
|
||||
|
||||
#define USERQUOTE_LEFTOFFSET 5
|
||||
#define USERQUOTE_RIGHTOFFSET 14
|
||||
|
||||
enum
|
||||
{
|
||||
T_EOF = -2,
|
||||
|
@ -275,8 +278,6 @@ void setgamepalette(player_struct *player, char *pal, int set)
|
|||
player->palette = pal;
|
||||
}
|
||||
|
||||
#define TEXTWRAPLEN (scale(39,ud.config.ScreenWidth,320))
|
||||
|
||||
int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,int orientation,int x1, int y1, int x2, int y2, int z)
|
||||
{
|
||||
int ac,newx,oldx=x;
|
||||
|
@ -342,7 +343,7 @@ int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,i
|
|||
}
|
||||
if (*t == 32)
|
||||
{
|
||||
x+=8*z/65536;
|
||||
x+=5*z/65536;
|
||||
t++;
|
||||
continue;
|
||||
}
|
||||
|
@ -356,13 +357,42 @@ int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,i
|
|||
if ((*t >= '0' && *t <= '9'))
|
||||
x += 8*z/65536;
|
||||
else x += tilesizx[ac]*z/65536;//(tilesizx[ac]>>small);
|
||||
if (t-oldt >= (signed)TEXTWRAPLEN-!small) oldt = (char *)t, x = oldx, y+=8*z/65536;
|
||||
if (x > (ud.config.ScreenWidth - 14)) oldt = (char *)t, x = oldx, y+=8*z/65536;
|
||||
t++;
|
||||
}
|
||||
|
||||
return (x);
|
||||
}
|
||||
|
||||
int gametextlen(int x,const char *t)
|
||||
{
|
||||
int ac;
|
||||
|
||||
if (t == NULL)
|
||||
return -1;
|
||||
|
||||
while (*t)
|
||||
{
|
||||
if (*t == 32)
|
||||
{
|
||||
x+=5;
|
||||
t++;
|
||||
continue;
|
||||
}
|
||||
else ac = *t - '!' + STARTALPHANUM;
|
||||
|
||||
if (ac < STARTALPHANUM || ac > (STARTALPHANUM + 93))
|
||||
break;
|
||||
|
||||
if ((*t >= '0' && *t <= '9'))
|
||||
x += 8;
|
||||
else x += tilesizx[ac];
|
||||
t++;
|
||||
}
|
||||
|
||||
return (x);
|
||||
}
|
||||
|
||||
inline int gametext(int x,int y,const char *t,int s,int dabits)
|
||||
{
|
||||
return(gametext_z(0,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536));
|
||||
|
@ -2404,10 +2434,10 @@ static void operatefta(void)
|
|||
{
|
||||
if (user_quote_time[i] <= 0) break;
|
||||
k = user_quote_time[i];
|
||||
l = Bstrlen(user_quote[i]);
|
||||
while (l > TEXTWRAPLEN)
|
||||
l = gametextlen(USERQUOTE_LEFTOFFSET,stripcolorcodes(user_quote[i]));
|
||||
while (l > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET))
|
||||
{
|
||||
l -= TEXTWRAPLEN;
|
||||
l -= (ud.config.ScreenWidth-USERQUOTE_RIGHTOFFSET);
|
||||
j -= 8;
|
||||
}
|
||||
if (k > 4)
|
||||
|
@ -2446,18 +2476,6 @@ static void operatefta(void)
|
|||
if (g_player[screenpeek].ps->ftq == 115 || g_player[screenpeek].ps->ftq == 116 || g_player[screenpeek].ps->ftq == 117)
|
||||
{
|
||||
k = quotebot-8-4;
|
||||
/* for(i=0;i<MAXUSERQUOTES;i++)
|
||||
{
|
||||
if (user_quote_time[i] <= 0) break;
|
||||
k -= 8;
|
||||
l = Bstrlen(user_quote[i]);
|
||||
while(l > TEXTWRAPLEN)
|
||||
{
|
||||
l -= TEXTWRAPLEN;
|
||||
k -= 8;
|
||||
}
|
||||
}
|
||||
k -= 4; */
|
||||
}
|
||||
|
||||
j = g_player[screenpeek].ps->fta;
|
||||
|
@ -2676,10 +2694,10 @@ static int strget_(int small,int x,int y,char *t,int dalen,int c)
|
|||
}
|
||||
c = 4-(sintable[(totalclock<<4)&2047]>>11);
|
||||
|
||||
i = Bstrlen(t);
|
||||
while (i > TEXTWRAPLEN-!small)
|
||||
i = gametextlen(USERQUOTE_LEFTOFFSET,stripcolorcodes(t));
|
||||
while (i > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET))
|
||||
{
|
||||
i -= TEXTWRAPLEN-!small;
|
||||
i -= (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET);
|
||||
y += 8;
|
||||
}
|
||||
|
||||
|
@ -2754,10 +2772,10 @@ static void typemode(void)
|
|||
}
|
||||
adduserquote(recbuf);
|
||||
quotebot += 8;
|
||||
l = Bstrlen(recbuf);
|
||||
while (l > TEXTWRAPLEN)
|
||||
l = gametextlen(USERQUOTE_LEFTOFFSET,stripcolorcodes(recbuf));
|
||||
while (l > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET))
|
||||
{
|
||||
l -= TEXTWRAPLEN;
|
||||
l -= (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET);
|
||||
quotebot += 8;
|
||||
}
|
||||
quotebotgoal = quotebot;
|
||||
|
|
|
@ -2734,7 +2734,7 @@ cheat_for_port_credits:
|
|||
"Parental lock",
|
||||
"-",
|
||||
"Game messages",
|
||||
"HUD weapon",
|
||||
"HUD weapon display",
|
||||
"FPS counter",
|
||||
"-",
|
||||
"Automatic voting",
|
||||
|
@ -2812,7 +2812,7 @@ cheat_for_port_credits:
|
|||
}
|
||||
modval(0,2,(int *)&ud.drawweapon,1,probey==io);
|
||||
{
|
||||
char *s[] = { "Off", "On", "Icon" };
|
||||
char *s[] = { "Disabled", "Normal", "Item" };
|
||||
gametextpal(d,yy, s[ud.drawweapon], MENUHIGHLIGHT(io), 0);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "duke3d.h"
|
||||
#include "build.h"
|
||||
#include "namesdyn.h"
|
||||
#include "osdfuncs.h"
|
||||
|
||||
void GAME_drawosdchar(int x, int y, char ch, int shade, int pal)
|
||||
{
|
||||
|
@ -13,16 +14,11 @@ void GAME_drawosdchar(int x, int y, char ch, int shade, int pal)
|
|||
rotatesprite(((x<<3)+x)<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16, 0, 0, xdim-1, ydim-1);
|
||||
}
|
||||
|
||||
#define OSDCHAR_WIDTH 8
|
||||
|
||||
void GAME_drawosdstr(int x, int y, char *ch, int len, int shade, int pal)
|
||||
{
|
||||
short ac;
|
||||
char *ptr = OSD_GetTextPtr();
|
||||
|
||||
UNREFERENCED_PARAMETER(shade);
|
||||
UNREFERENCED_PARAMETER(pal);
|
||||
|
||||
for (x = (x<<3)+x; len>0; len--, ch++, x++)
|
||||
{
|
||||
if (*ch == 32)
|
||||
|
|
|
@ -5,3 +5,5 @@ int GAME_getcolumnwidth(int w);
|
|||
int GAME_getrowheight(int w);
|
||||
void GAME_clearbackground(int c, int r);
|
||||
void GAME_onshowosd(int shown);
|
||||
|
||||
#define OSDCHAR_WIDTH 8
|
Loading…
Reference in a new issue