Add support for color codes to gametext_() and in various places in supporting code and increase quote length to 128

git-svn-id: https://svn.eduke32.com/eduke32@151 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-05-05 07:10:36 +00:00
parent 1409799e0e
commit d6530ed294
7 changed files with 142 additions and 77 deletions

View file

@ -569,8 +569,12 @@ void CONFIG_ReadSetup( void )
SCRIPT_GetString( scripthandle, "Comm Setup","PlayerName",&myname[0]);
if(Bstrlen(myname) > 9)
myname[10] = 0;
if(Bstrlen(strip_color_codes(myname)) > 9)
{
Bstrcpy(tempbuf,myname);
Bstrncpy(myname,strip_color_codes(tempbuf),9);
myname[10] = '\0';
}
SCRIPT_GetString( scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
@ -703,7 +707,7 @@ void CONFIG_WriteSetup( void )
SCRIPT_PutNumber( scripthandle, "Controls","AimingFlag",(long) myaimmode,false,false);
SCRIPT_PutNumber( scripthandle, "Controls","AutoAim",AutoAim,false,false);
// SCRIPT_PutNumber( scripthandle, "Controls","GameMouseAiming",(int32) ps[myconnectindex].aim_mode,false,false);
// SCRIPT_PutNumber( scripthandle, "Controls","GameMouseAiming",(int32) ps[myconnectindex].aim_mode,false,false);
SCRIPT_PutNumber( scripthandle, "Controls", "MouseAimingFlipped",ud.mouseflip,false,false);
SCRIPT_PutNumber( scripthandle, "Controls","MouseAiming",ud.mouseaiming,false,false);
SCRIPT_PutNumber( scripthandle, "Controls","RunKeyBehaviour",ud.runkey_mode,false,false);

View file

@ -435,7 +435,7 @@ extern short int global_random;
extern long scaredfallz;
extern char buf[1024]; //My own generic input buffer
#define MAXQUOTELEN 64
#define MAXQUOTELEN 128
extern char *fta_quotes[MAXQUOTES],*redefined_quotes[MAXQUOTES];
extern char scantoasc[128],ready2send;

View file

@ -315,7 +315,7 @@ extern void setgamepalette(struct player_struct *player, char *pal, int set);
extern void fadepal(int r, int g, int b, int start, int end, int step);
extern int minitextshade(int x,int y,char *t,char s,char p,short sb);
extern int txgametext(int starttile, int x,int y,char *t,char s,char p,short orientation,long x1, long y1, long x2, long y2);
extern int gametext_(int small, int starttile, int x,int y,char *t,char s,char p,short orientation,long x1, long y1, long x2, long y2);
extern void txdigitalnumber(short starttile, long x,long y,long n,char s,char pal,char cs,long x1, long y1, long x2, long y2);
extern long txdist(spritetype *s1,spritetype *s2);
extern void myosx(long x,long y,short tilenum,signed char shade,char orientation);
@ -356,5 +356,6 @@ extern void sendboardname(void);
extern void sendquit(void);
extern void adduserquote(char *daquote);
extern char *strip_color_codes(char *t);
#endif // __funct_h__

View file

@ -166,7 +166,29 @@ void setgamepalette(struct player_struct *player, char *pal, int set)
#define TEXTWRAPLEN (scale(35,ScreenWidth,320))
int txgametext_(int small, int starttile, int x,int y,char *t,char s,char p,short orientation,long x1, long y1, long x2, long y2)
char colstrip[1024];
char *strip_color_codes(char *t)
{
int i = 0;
while(*t)
{
if(*t == '^' && isdigit(*(t+1)))
{
t += 2;
if(isdigit(*t))
t++;
if(!(*t)) continue;
}
colstrip[i] = *t;
i++,t++;
}
colstrip[i] = '\0';
return(colstrip);
}
int gametext_(int small, int starttile, int x,int y,char *t,char s,char p,short orientation,long x1, long y1, long x2, long y2)
{
short ac,newx,oldx=x;
char centre, *oldt;
@ -182,7 +204,13 @@ int txgametext_(int small, int starttile, int x,int y,char *t,char s,char p,shor
{
while(*t)
{
if(*t == 32) {newx+=5;t++;continue;}
if(*t == '^' && isdigit(*(t+1)))
{
t += 2;
if(isdigit(*t)) t++;
if(!(*t)) continue;
}
if(*t == 32) {newx+=5;t++;continue;}
else ac = *t - '!' + starttile;
if( ac < starttile || ac > (starttile + 93) ) break;
@ -199,7 +227,24 @@ int txgametext_(int small, int starttile, int x,int y,char *t,char s,char p,shor
while(*t)
{
if(*t == 32) {x+=5;t++;continue;}
if(*t == '^' && isdigit(*(t+1)))
{
char smallbuf[3];
t += 1;
if(isdigit(*(t+1)))
{
smallbuf[0] = *(t++);
smallbuf[1] = *(t++);
smallbuf[2] = '\0';
p = atol(smallbuf);
} else {
smallbuf[0] = *(t++);
smallbuf[1] = '\0';
p = atol(smallbuf);
}
if(!(*t)) continue;
}
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + starttile;
if( ac < starttile || ac > (starttile + 93) )
@ -216,34 +261,24 @@ int txgametext_(int small, int starttile, int x,int y,char *t,char s,char p,shor
return (x);
}
inline int txgametext(int starttile, int x,int y,char *t,char s,char p,short dabits,long x1, long y1, long x2, long y2)
{
return(txgametext_(0,starttile, x,y,t,s,p,dabits,x1, y1, x2, y2));
}
inline int txgametextsm(int starttile, int x,int y,char *t,char s,char p,short dabits,long x1, long y1, long x2, long y2)
{
return(txgametext_(1,starttile, x,y,t,s,p,dabits,x1, y1, x2, y2));
}
inline int gametext(int x,int y,char *t,char s,short dabits)
{
return(txgametext_(0,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
return(gametext_(0,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
}
inline int gametextpal(int x,int y,char *t,char s,char p)
{
return(gametext_(0,STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1));
}
inline int mpgametext(int y,char *t,char s,short dabits)
{
if(xdim >= 640 && ydim >= 480)
return(txgametextsm(STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
else return(txgametext(STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
return(gametext_(1,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
else return(gametext_(0,STARTALPHANUM, 5,y,t,s,0,dabits,0, 0, xdim-1, ydim-1));
}
inline int gametextpal(int x,int y,char *t,char s,char p)
{
return(txgametext(STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1));
}
int minitextshade(int x,int y,char *t,char s,char p,short sb)
int minitext_(int x,int y,char *t,char s,char p,short sb)
{
short ac;
char ch,cmode;
@ -266,9 +301,14 @@ int minitextshade(int x,int y,char *t,char s,char p,short sb)
return (x);
}
inline int minitextshade(int x,int y,char *t,char s,char p,short sb)
{
return (minitext_(x,y,(char *)strip_color_codes(t),s,p,sb));
}
inline int minitext(int x,int y,char *t,char p,short sb)
{
return (minitextshade(x,y,t,0,p,sb));
return (minitext_(x,y,(char *)strip_color_codes(t),0,p,sb));
}
void gamenumber(long x,long y,long n,char s)
@ -321,7 +361,7 @@ void adduserquote(char *daquote)
user_quote_time[i] = user_quote_time[i-1];
}
strcpy(user_quote[0],daquote);
OSD_Printf("%s\n", daquote);
OSD_Printf("%s\n",strip_color_codes(daquote));
user_quote_time[0] = ud.msgdisptime;
pub = NUMPAGES;
@ -2227,7 +2267,7 @@ else if(ud.recstat == 2) { if (frecfilep) fclose(frecfilep); } // JBF: fixes cr
exit(0);
}
short inputloc = 0;
char inputloc = 0;
short strget_(int small,short x,short y,char *t,short dalen,short c)
{
@ -2332,7 +2372,7 @@ void typemode(void)
sendmessagecommand = 2;
strcat(recbuf,ud.user_name[myconnectindex]);
strcat(recbuf,": ");
strcat(recbuf,":^0 ");
strcat(recbuf,typebuf);
j = strlen(recbuf);
recbuf[j] = 0;
@ -8413,8 +8453,8 @@ void Startup(void)
if (CommandName)
{
Bstrncpy(myname, CommandName, 10);
myname[10] = 0;
Bstrncpy(myname, CommandName, 9);
myname[10] = '\0';
}
if (CommandMap) {

View file

@ -4675,7 +4675,7 @@ SKIPJIBS:
y2=GetGameVarID(*insptr++,g_i,g_p);
}
if (tw == CON_MINITEXT && fta_quotes[q] != NULL) minitextshade(x,y,fta_quotes[q],shade,pal,26);
else if (tw == CON_GAMETEXT && fta_quotes[q] != NULL) txgametext(tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2);
else if (tw == CON_GAMETEXT && fta_quotes[q] != NULL) gametext_(0,tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2);
else if (tw == CON_DIGITALNUMBER) txdigitalnumber(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2);
if((tw == CON_MINITEXT || tw == CON_GAMETEXT) && fta_quotes[q] == NULL)
OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,q);

View file

@ -703,10 +703,22 @@ void menus(void)
break;
}
} else {
x = strget(200,50-9,buf,10,0);
x = strget(200,50-9,buf,30,0);
while(Bstrlen(strip_color_codes(buf)) > 9)
{
buf[Bstrlen(buf)-1] = '\0';
inputloc--;
}
if (x) {
if (x == 1) {
if(buf[0]) {
if(Bstrlen(strip_color_codes(buf)) > 9)
{
Bstrncpy(buf,strip_color_codes(buf),9);
buf[10] = '\0';
}
Bstrcpy(myname,buf);
}
// send name update

View file

@ -3448,6 +3448,41 @@ void processinput(short snum)
{
if(p->frag_ps != snum)
{
char *s[] = {
"%^2%s WAS KICKED TO THE CURB BY %s",
"%^2%s WAS PICKED OFF BY %s",
"%^2%s TOOK %s'S SHOT TO THE FACE",
"%^2%s DANCED THE CHAINGUN CHA-CHA WITH %s",
"%^2%s TRIED TO MAKE A BONG OUT OF %s'S ROCKET",
"%^2%s EXPLODED. BLAME %s!",
"%^2%s FELT THE EFFECTS OF %s'S CORPORATE DOWNSIZING",
"%^2%s WAS TOO COOL FOR %s",
"%^2%s EXPANDED HIS HORIZONS WITH HELP FROM %s",
"%^2%s THINKS %s SHOULD CHECK HIS GLASSES",
"%^2%s TOOK %s'S BOOT TO THE HEAD",
"%^2%s FELL VICTIM TO %s's MAGIC AUTOAIMING PISTOL",
"%^2%s WAS CHASED OFF OF %s'S PORCH",
"%^2%s COULDN'T DANCE FAST ENOUGH FOR %s",
"%^2%s TRIED TO OUTRUN %s'S ROCKET",
"%^2%s FINALLY FOUND %s'S HIDDEN WMDS",
"%^2%s SHOULDN'T HAVE DELETED ALL THE VIAGRA SPAM FROM %s",
"%^2%s HAD TO SIT AND LISTEN TO %s QUOTE TERMINATOR 2 AGAIN",
"%^2%s INFLATED FASTER THAN GASOLINE PRICES AND %s POCKETED THE PROFIT",
"%^2%s WISHES %s HAD PRACTICED BEFORE PLAYING",
"%^2%s WAS WALKED ALL OVER BY %s",
"%^2%s WAS PICKED OFF BY %s",
"%^2%s MASQUERADED AS QUAIL FOR VICE PRESIDENT %s",
"%^2%s HELPED %s RE-ENACT SCARFACE",
"%^2%s BECAME THE SALSA FOR %s'S CHIPS",
"%^2%s WONDERS WHY %s HATES FREEDOM",
"%^2%s'S HEIGHT DROPPED FASTER THAN %s'S ENRON STOCK",
"%^2%s WENT TO PIECES. %s, HOW COULD YOU?",
"%^2%s EXPANDED HIS HORIZONS WITH HELP FROM %s",
"%^2%s WONDERS IF %s WILL EVER KILL ENEMIES, NOT TEAMMATES",
};
ps[p->frag_ps].frag++;
frags[p->frag_ps][snum]++;
@ -3461,40 +3496,6 @@ void processinput(short snum)
Bsprintf(fta_quotes[116],"KILLED %s",&ud.user_name[snum][0]);
FTA(116,&ps[p->frag_ps]);
}
char *s[] = {
"%s WAS KICKED TO THE CURB BY %s",
"%s WAS PICKED OFF BY %s",
"%s TOOK %s'S SHOT TO THE FACE",
"%s DANCED THE CHAINGUN CHA-CHA WITH %s",
"%s TRIED TO MAKE A BONG OUT OF %s'S ROCKET",
"%s EXPLODED. BLAME %s!",
"%s FELT THE EFFECTS OF %s'S CORPORATE DOWNSIZING",
"%s WAS TOO COOL FOR %s",
"%s EXPANDED HIS HORIZONS WITH HELP FROM %s",
"%s THINKS %s SHOULD CHECK HIS GLASSES",
"%s TOOK %s'S BOOT TO THE HEAD",
"%s FELL VICTIM TO %s's MAGIC AUTOAIMING PISTOL",
"%s WAS CHASED OFF OF %s'S PORCH",
"%s COULDN'T DANCE FAST ENOUGH FOR %s",
"%s TRIED TO OUTRUN %s'S ROCKET",
"%s FINALLY FOUND %s'S HIDDEN WMDS",
"%s SHOULDN'T HAVE DELETED ALL THE VIAGRA SPAM FROM %s",
"%s HAD TO SIT AND LISTEN TO %s QUOTE TERMINATOR 2 AGAIN",
"%s INFLATED FASTER THAN GASOLINE PRICES AND %s POCKETED THE PROFIT",
"%s WISHES %s HAD PRACTICED BEFORE PLAYING",
"%s WAS WALKED ALL OVER BY %s",
"%s WAS PICKED OFF BY %s",
"%s MASQUERADED AS QUAIL FOR VICE PRESIDENT %s",
"%s HELPED %s RE-ENACT SCARFACE",
"%s BECAME THE SALSA FOR %s'S CHIPS",
"%s WONDERS WHY %s HATES FREEDOM",
"%s'S HEIGHT DROPPED FASTER THAN %s'S ENRON STOCK",
"%s WENT TO PIECES. %s, HOW COULD YOU?",
"%s EXPANDED HIS HORIZONS WITH HELP FROM %s",
"%s WONDERS IF %s WILL EVER KILL ENEMIES, NOT TEAMMATES",
};
if(gametype_flags[ud.coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY)
i = 9;
@ -3528,17 +3529,24 @@ void processinput(short snum)
default: i = 0; break;
}
}
Bsprintf(tempbuf,s[i+(mulscale(krand(), 3, 16)*10)],&ud.user_name[snum][0],&ud.user_name[p->frag_ps][0]);
if(ScreenWidth >= 640)
adduserquote(tempbuf);
else OSD_Printf("%s\n",tempbuf);
{
char name1[32],name2[32];
Bstrcpy(name1,strip_color_codes(&ud.user_name[snum][0]));
Bstrcpy(name2,strip_color_codes(&ud.user_name[p->frag_ps][0]));
Bsprintf(tempbuf,s[i+(mulscale(krand(), 3, 16)*10)],name1,name2);
if(ScreenWidth >= 640)
adduserquote(tempbuf);
else OSD_Printf("%s\n",strip_color_codes(tempbuf));
}
}
else
{
char *s[] = {
"%s KILLED HIMSELF. WHAT A TOOL!",
"%s TRIED TO LEAVE",
"%s GOT FRAGGED BY A MONSTER. IT WAS PROBABLY A LIZTROOP."
"%^2%s KILLED HIMSELF. WHAT A TOOL!",
"%^2%s TRIED TO LEAVE",
"%^2%s GOT FRAGGED BY A MONSTER. IT WAS PROBABLY A LIZTROOP."
};
p->fraggedself++;
@ -3549,7 +3557,7 @@ void processinput(short snum)
i = 1;
else i = 0;
Bsprintf(tempbuf,s[i],&ud.user_name[snum][0]);
Bsprintf(tempbuf,s[i],strip_color_codes(&ud.user_name[snum][0]));
adduserquote(tempbuf);
}