Do ansi colours in sdl builds too.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5449 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
1c26738095
commit
cb346bc1db
5 changed files with 156 additions and 26 deletions
|
@ -975,7 +975,7 @@ MINGL_EXE_NAME=../$(EXE_NAME)-mingl$(FTE_FULLTARGET)
|
|||
MB_DIR=m_$(FTE_FULLTARGET)
|
||||
M_EXE_NAME=../$(EXE_NAME)-$(FTE_FULLTARGET)
|
||||
MCL_OBJS=$(D3DGL_OBJS) $(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(BOTLIB_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o
|
||||
M_CFLAGS=-DFTE_SDL $(GLCFLAGS) `$(SDLCONFIG) --cflags`
|
||||
M_CFLAGS=-DFTE_SDL $(VKCFLAGS) $(GLCFLAGS) `$(SDLCONFIG) --cflags`
|
||||
|
||||
QCC_DIR=qcc$(BITS)
|
||||
|
||||
|
@ -2099,7 +2099,7 @@ web-dbg:
|
|||
|
||||
#makes an ant project for us
|
||||
droid/build.xml:
|
||||
-cd droid && PATH=$$PATH:$(realpath $(ANDROID_HOME)/tools):$(realpath $(ANDROID_NDK_ROOT)) $(ANDROID_SCRIPT) update project -t android-8 -p . -n FTEDroid
|
||||
-cd droid && PATH=$$PATH:$(realpath $(ANDROID_HOME)/tools):$(realpath $(ANDROID_NDK_ROOT)) $(ANDROID_SCRIPT) update project -t android-9 -p . -n FTEDroid
|
||||
|
||||
#build FTE as a library, then build the java+package (release)
|
||||
droid/ftekeystore:
|
||||
|
|
|
@ -53,9 +53,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
# define NO_X11
|
||||
# endif
|
||||
#endif
|
||||
#ifdef MULTITHREAD
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#define USE_LIBTOOL
|
||||
|
@ -104,29 +101,28 @@ qboolean isDedicated;
|
|||
|
||||
#if 1
|
||||
static int ansiremap[8] = {0, 4, 2, 6, 1, 5, 3, 7};
|
||||
static void ApplyColour(unsigned int chr)
|
||||
static void ApplyColour(unsigned int chrflags)
|
||||
{
|
||||
static int oldchar = CON_WHITEMASK;
|
||||
static int oldflags = CON_WHITEMASK;
|
||||
int bg, fg;
|
||||
chr &= CON_FLAGSMASK;
|
||||
|
||||
if (oldchar == chr)
|
||||
if (oldflags == chrflags)
|
||||
return;
|
||||
oldchar = chr;
|
||||
oldflags = chrflags;
|
||||
|
||||
printf("\e[0;"); // reset
|
||||
|
||||
if (chr & CON_BLINKTEXT)
|
||||
if (chrflags & CON_BLINKTEXT)
|
||||
printf("5;"); // set blink
|
||||
|
||||
bg = (chr & CON_BGMASK) >> CON_BGSHIFT;
|
||||
fg = (chr & CON_FGMASK) >> CON_FGSHIFT;
|
||||
bg = (chrflags & CON_BGMASK) >> CON_BGSHIFT;
|
||||
fg = (chrflags & CON_FGMASK) >> CON_FGSHIFT;
|
||||
|
||||
// don't handle intensive bit for background
|
||||
// as terminals differ too much in displaying \e[1;7;3?m
|
||||
bg &= 0x7;
|
||||
|
||||
if (chr & CON_NONCLEARBG)
|
||||
if (chrflags & CON_NONCLEARBG)
|
||||
{
|
||||
if (fg & 0x8) // intensive bit set for foreground
|
||||
{
|
||||
|
@ -172,6 +168,7 @@ void Sys_Printf (char *fmt, ...)
|
|||
conchar_t ctext[2048];
|
||||
conchar_t *c, *e;
|
||||
wchar_t w;
|
||||
unsigned int codeflags, codepoint;
|
||||
|
||||
if (nostdout)
|
||||
return;
|
||||
|
@ -185,13 +182,16 @@ void Sys_Printf (char *fmt, ...)
|
|||
|
||||
e = COM_ParseFunString(CON_WHITEMASK, text, ctext, sizeof(ctext), false);
|
||||
|
||||
for (c = ctext; c < e; c++)
|
||||
for (c = ctext; c < e; )
|
||||
{
|
||||
if (*c & CON_HIDDEN)
|
||||
c = Font_Decode(c, &codeflags, &codepoint);
|
||||
if (codeflags & CON_HIDDEN)
|
||||
continue;
|
||||
|
||||
ApplyColour(*c);
|
||||
w = *c & 0x0ffff;
|
||||
if (codepoint == '\n' && (codeflags&CON_NONCLEARBG))
|
||||
codeflags &= CON_WHITEMASK; //make sure we don't get annoying backgrounds on other lines.
|
||||
ApplyColour(codeflags);
|
||||
w = codepoint;
|
||||
if (w >= 0xe000 && w < 0xe100)
|
||||
{
|
||||
/*not all quake chars are ascii compatible, so map those control chars to safe ones so we don't mess up anyone's xterm*/
|
||||
|
|
|
@ -63,14 +63,140 @@ qboolean Sys_RandomBytes(qbyte *string, int len)
|
|||
return false;
|
||||
}
|
||||
|
||||
//print into stdout
|
||||
static void ApplyColour(unsigned int chrflags)
|
||||
{
|
||||
//on win32, SDL usually redirected stdout to a file (as it won't get printed anyway.
|
||||
//win32 doesn't do ascii escapes, and text editors like to show the gibberish too, so just don't bother emitting any.
|
||||
#ifndef _WIN32
|
||||
static const int ansiremap[8] = {0, 4, 2, 6, 1, 5, 3, 7};
|
||||
static int oldflags = CON_WHITEMASK;
|
||||
int bg, fg;
|
||||
|
||||
if (oldflags == chrflags)
|
||||
return;
|
||||
oldflags = chrflags;
|
||||
|
||||
printf("\e[0;"); // reset
|
||||
|
||||
if (chrflags & CON_BLINKTEXT)
|
||||
printf("5;"); // set blink
|
||||
|
||||
bg = (chrflags & CON_BGMASK) >> CON_BGSHIFT;
|
||||
fg = (chrflags & CON_FGMASK) >> CON_FGSHIFT;
|
||||
|
||||
// don't handle intensive bit for background
|
||||
// as terminals differ too much in displaying \e[1;7;3?m
|
||||
bg &= 0x7;
|
||||
|
||||
if (chrflags & CON_NONCLEARBG)
|
||||
{
|
||||
if (fg & 0x8) // intensive bit set for foreground
|
||||
{
|
||||
printf("1;"); // set bold/intensity ansi flag
|
||||
fg &= 0x7; // strip intensive bit
|
||||
}
|
||||
|
||||
// set foreground and background colors
|
||||
printf("3%i;4%im", ansiremap[fg], ansiremap[bg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(fg)
|
||||
{
|
||||
//to get around wierd defaults (like a white background) we have these special hacks for colours 0 and 7
|
||||
case COLOR_BLACK:
|
||||
printf("7m"); // set inverse
|
||||
break;
|
||||
case COLOR_GREY:
|
||||
printf("1;30m"); // treat as dark grey
|
||||
break;
|
||||
case COLOR_WHITE:
|
||||
printf("m"); // set nothing else
|
||||
break;
|
||||
default:
|
||||
if (fg & 0x8) // intensive bit set for foreground
|
||||
{
|
||||
printf("1;"); // set bold/intensity ansi flag
|
||||
fg &= 0x7; // strip intensive bit
|
||||
}
|
||||
|
||||
printf("3%im", ansiremap[fg]); // set foreground
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//#include <wchar.h>
|
||||
void Sys_Printf (char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_list argptr;
|
||||
char text[2048];
|
||||
conchar_t ctext[2048];
|
||||
conchar_t *c, *e;
|
||||
wchar_t w;
|
||||
unsigned int codeflags, codepoint;
|
||||
|
||||
// if (nostdout)
|
||||
// return;
|
||||
|
||||
va_start (argptr,fmt);
|
||||
vprintf (fmt,argptr);
|
||||
vsnprintf (text,sizeof(text)-1, fmt,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
if (strlen(text) > sizeof(text))
|
||||
Sys_Error("memory overwrite in Sys_Printf");
|
||||
|
||||
e = COM_ParseFunString(CON_WHITEMASK, text, ctext, sizeof(ctext), false);
|
||||
|
||||
for (c = ctext; c < e; )
|
||||
{
|
||||
c = Font_Decode(c, &codeflags, &codepoint);
|
||||
if (codeflags & CON_HIDDEN)
|
||||
continue;
|
||||
|
||||
if (codepoint == '\n' && (codeflags&CON_NONCLEARBG))
|
||||
codeflags &= CON_WHITEMASK;
|
||||
ApplyColour(codeflags);
|
||||
w = codepoint;
|
||||
if (w >= 0xe000 && w < 0xe100)
|
||||
{
|
||||
/*not all quake chars are ascii compatible, so map those control chars to safe ones so we don't mess up anyone's xterm*/
|
||||
if ((w & 0x7f) > 0x20)
|
||||
putc(w&0x7f, stdout);
|
||||
else if (w & 0x80)
|
||||
{
|
||||
static char tab[32] = "---#@.@@@@ # >.." "[]0123456789.---";
|
||||
putc(tab[w&31], stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
static char tab[32] = ".####.#### # >.." "[]0123456789.---";
|
||||
putc(tab[w&31], stdout);
|
||||
}
|
||||
}
|
||||
else if (w < ' ' && w != '\t' && w != '\r' && w != '\n')
|
||||
putc('?', stdout); //don't let anyone print escape codes or other things that could crash an xterm.
|
||||
else
|
||||
{
|
||||
/*putwc doesn't like me. force it in utf8*/
|
||||
if (w >= 0x80)
|
||||
{
|
||||
if (w > 0x800)
|
||||
{
|
||||
putc(0xe0 | ((w>>12)&0x0f), stdout);
|
||||
putc(0x80 | ((w>>6)&0x3f), stdout);
|
||||
}
|
||||
else
|
||||
putc(0xc0 | ((w>>6)&0x1f), stdout);
|
||||
putc(0x80 | (w&0x3f), stdout);
|
||||
}
|
||||
else
|
||||
putc(w, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
ApplyColour(CON_WHITEMASK);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
unsigned int Sys_Milliseconds(void)
|
||||
|
|
|
@ -1098,7 +1098,7 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name))
|
|||
(strstr(gl_renderer, " Mesa ") || strstr(gl_version, " Mesa ")) && Cvar_Get("gl_blacklist_mesa_invariant", "1", CVAR_VIDEOLATCH, "gl blacklists")->ival)
|
||||
{
|
||||
gl_config.blacklist_invariant = true;
|
||||
Con_Printf(CON_NOTICE "Mesa detected, disabling the use of glsl's invariant keyword. This will result in z-fighting. Use '+set gl_blacklist_mesa_invariant 0' on the commandline to reenable it (but you will probably get glsl compilation errors from your driver).\n");
|
||||
Con_Printf(CON_NOTICE "Mesa detected, disabling the use of glsl's invariant keyword."CON_DEFAULT" This will result in z-fighting. Use '+set gl_blacklist_mesa_invariant 0' on the commandline to reenable it (but you will probably get glsl compilation errors from your driver).\n");
|
||||
}
|
||||
|
||||
if (gl_config.arb_shader_objects)
|
||||
|
|
|
@ -340,14 +340,18 @@ void Sys_Printf (char *fmt, ...)
|
|||
wchar_t w;
|
||||
conchar_t *e, *c;
|
||||
conchar_t ctext[MAXPRINTMSG];
|
||||
unsigned int codeflags, codepoint;
|
||||
e = COM_ParseFunString(CON_WHITEMASK, msg, ctext, sizeof(ctext), false);
|
||||
for (c = ctext; c < e; c++)
|
||||
for (c = ctext; c < e; )
|
||||
{
|
||||
if (*c & CON_HIDDEN)
|
||||
c = Font_Decode(c, &codeflags, &codepoint);
|
||||
if (codeflags & CON_HIDDEN)
|
||||
continue;
|
||||
|
||||
if (codepoint == '\n' && (codeflags&CON_NONCLEARBG))
|
||||
codeflags &= CON_WHITEMASK; //make sure we don't get annoying backgrounds on other lines.
|
||||
ApplyColour(*c);
|
||||
w = *c & 0x0ffff;
|
||||
w = codepoint;
|
||||
if (w >= 0xe000 && w < 0xe100)
|
||||
{
|
||||
/*not all quake chars are ascii compatible, so map those control chars to safe ones so we don't mess up anyone's xterm*/
|
||||
|
|
Loading…
Reference in a new issue