From abc0aeb07c4ba931dee0c50738566bca9cc1ba32 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 7 Aug 2008 13:23:08 +0000 Subject: [PATCH] Crosshair color support... not done yet git-svn-id: https://svn.eduke32.com/eduke32@938 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 40 ++++++++++++++++++++++++++++---- polymer/eduke32/source/osdcmds.c | 22 ++++++++++++++++++ polymer/eduke32/source/premap.c | 8 +++++++ 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index a532c434e..d8b6cb950 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -3363,6 +3363,40 @@ static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) } } +int crosshair_red = 255; +int crosshair_green = 255; +int crosshair_blue = 0; +#define CROSSHAIR_PAL (MAXPALOOKUPS>>1) + +void SetCrosshairColor(int r, int g, int b) +{ + /* TODO: turn this into something useful */ + char *ptr = (char *)waloff[CROSSHAIR]; + int i, ii; + extern int getclosestcol(int r, int g, int b); + + hictinting[CROSSHAIR_PAL].r = crosshair_red = r; + hictinting[CROSSHAIR_PAL].g = crosshair_green = g; + hictinting[CROSSHAIR_PAL].b = crosshair_blue = b; + hictinting[CROSSHAIR_PAL].f = 0; + invalidatetile(CROSSHAIR, -1, -1); + + if (waloff[CROSSHAIR] == 0) return; + + ii = 0; + i = getclosestcol(crosshair_red>>2, crosshair_green>>2, crosshair_blue>>2); + while (ii < tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]) + { + if (*ptr != 255) + *ptr = i; + ptr++; + ii++; + } + for (i = 0; i < 256; i++) + tempbuf[i] = i; + makepalookup(CROSSHAIR_PAL,tempbuf,crosshair_red>>2, crosshair_green>>2, crosshair_blue>>2,1); +} + void palto(int r,int g,int b,int e) { int tc; @@ -3646,7 +3680,7 @@ void displayrest(int smoothratio) SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, -1); if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - rotatesprite((160L-(g_player[myconnectindex].ps->look_ang>>1))<<16,100L<<16,scale(65536,ud.crosshairscale,100),0,CROSSHAIR,0,0,2+1,windowx1,windowy1,windowx2,windowy2); + rotatesprite((160L-(g_player[myconnectindex].ps->look_ang>>1))<<16,100L<<16,scale(65536,ud.crosshairscale,100),0,CROSSHAIR,0,CROSSHAIR_PAL,2+1,windowx1,windowy1,windowx2,windowy2); } #if 0 if (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) @@ -8024,11 +8058,7 @@ static void nonsharedkeys(void) CONTROL_ClearButton(gamefunc_Toggle_Crosshair); ud.crosshair = !ud.crosshair; if (ud.crosshair) - { -// Bsprintf(fta_quotes[122],"%s [%d%%]",fta_quotes[20],size[ud.crosshair-1]); -// FTA(122,g_player[screenpeek].ps); FTA(20,g_player[screenpeek].ps); - } else FTA(21,g_player[screenpeek].ps); } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 64131a4e9..1a0638c59 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -1320,6 +1320,27 @@ static int osdcmd_setcrosshairscale(const osdfuncparm_t *parm) return OSDCMD_OK; } +extern void SetCrosshairColor(int r, int g, int b); +extern int crosshair_red; +extern int crosshair_green; +extern int crosshair_blue; + +static int osdcmd_crosshaircolor(const osdfuncparm_t *parm) +{ + int r, g, b; + + if (parm->numparms != 3) + { + OSD_Printf("\"crosshaircolor\" : r:%d g:%d b:%d\n",crosshair_red,crosshair_green,crosshair_blue); + return OSDCMD_SHOWHELP; + } + r = atol(parm->parms[0]); + g = atol(parm->parms[1]); + b = atol(parm->parms[2]); + SetCrosshairColor(r,g,b); + return OSDCMD_OK; +} + static int osdcmd_visibility(const osdfuncparm_t *parm) { float f; @@ -1361,6 +1382,7 @@ int registerosdcommands(void) OSD_RegisterFunction("cl_statusbarscale","cl_statusbarscale: changes the status bar scale", osdcmd_setstatusbarscale); OSD_RegisterFunction("cl_crosshairscale","cl_crosshairscale: changes the crosshair scale", osdcmd_setcrosshairscale); + OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes crosshair color", osdcmd_crosshaircolor); OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); OSD_RegisterFunction("echo","echo [text]: echoes text to the console", osdcmd_echo); diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index b2fa45cc6..45132a789 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -399,6 +399,11 @@ static void dofrontscreens(char *statustext) } } +extern void SetCrosshairColor(int r, int g, int b); +extern int crosshair_red; +extern int crosshair_green; +extern int crosshair_blue; + void cacheit(void) { int i,j,pc=0; @@ -497,6 +502,9 @@ void cacheit(void) } } + loadtile(CROSSHAIR); + SetCrosshairColor(crosshair_red, crosshair_green, crosshair_blue); + clearbufbyte(gotpic,sizeof(gotpic),0L); endtime = getticks();