From 2030a427633d9262bf205b0c97c9c01bbcc562c9 Mon Sep 17 00:00:00 2001 From: terminx Date: Fri, 8 Aug 2008 01:54:43 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@941 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/config.c | 30 ++++++++++++ polymer/eduke32/source/funct.h | 3 ++ polymer/eduke32/source/game.c | 83 ++++++++++++++++++-------------- polymer/eduke32/source/osdcmds.c | 6 +-- polymer/eduke32/source/premap.c | 7 ++- 5 files changed, 85 insertions(+), 44 deletions(-) diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 763fb09b1..cda6efdf9 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -592,6 +592,8 @@ void CONFIG_SetupJoystick(void) */ extern char *duke3dgrp; extern void check_valid_color(int *color,int prev_color); +extern palette_t crosshair_colors; +extern palette_t default_crosshair_colors; int32 CONFIG_ReadSetup(void) { @@ -727,6 +729,7 @@ int32 CONFIG_ReadSetup(void) SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup",&ud.config.ForceSetup); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "RunMode",&ud.config.RunMode); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Crosshairs",&ud.crosshair); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "CrosshairScale",&ud.crosshairscale); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",&ud.levelstats); @@ -807,6 +810,30 @@ int32 CONFIG_ReadSetup(void) windowy = -1; SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32 *)&windowy); #endif + tempbuf[0] = 0; + SCRIPT_GetString(ud.config.scripthandle, "Misc", "CrosshairColor",&tempbuf[0]); + if (tempbuf[0]) + { + char *ptr = strtok(tempbuf,","); + palette_t temppal; + if (ptr != NULL) + { + temppal.r = atoi(ptr); + ptr = strtok(NULL,","); + if (ptr != NULL) + { + temppal.g = atoi(ptr); + ptr = strtok(NULL,","); + if (ptr != NULL) + { + temppal.b = atoi(ptr); + ptr = strtok(NULL,","); + Bmemcpy(&crosshair_colors,&temppal,sizeof(palette_t)); + default_crosshair_colors.f = 1; + } + } + } + } } CONFIG_ReadKeys(); @@ -986,6 +1013,9 @@ void CONFIG_WriteSetup(void) SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, false, false); #endif + Bsprintf(tempbuf,"%d,%d,%d",crosshair_colors.r,crosshair_colors.g,crosshair_colors.b); + SCRIPT_PutString(ud.config.scripthandle, "Misc", "CrosshairColor",tempbuf); + // JBF 20031211 for (dummy=0;dummycurr_weapon; altdigitalnumber(-20,-(200-22),p->ammo_amount[i],-16,10+16); - o = 100; + o = 102; permbit = 0; if (p->inven_icon) @@ -3363,39 +3363,29 @@ static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) } } -extern int getclosestcol(int r, int g, int b); -int crosshair_red = 255; -int crosshair_green = 255; -int crosshair_blue = 0; -static int crosshair_red_default = -1; -static int crosshair_green_default = -1; -static int crosshair_blue_default = -1; #define CROSSHAIR_PAL (MAXPALOOKUPS>>1) -void SetCrosshairColor(int r, int g, int b) +extern int getclosestcol(int r, int g, int b); +palette_t crosshair_colors = { 255, 255, 255, 0 }; +palette_t default_crosshair_colors = { 0, 0, 0, 0 }; + +void GetCrosshairColor(void) { - /* TODO: turn this into something useful */ - char *ptr = (char *)waloff[CROSSHAIR]; - int i, ii; - static int sum; - - if (sum == r+(g<<1)+(b<<2)) return; - sum = r+(g<<1)+(b<<2); - crosshair_red = r; - crosshair_green = g; - crosshair_blue = b; - - if (waloff[CROSSHAIR] == 0) - { - loadtile(CROSSHAIR); - ptr = (char *)waloff[CROSSHAIR]; - } - - if (crosshair_red_default == -1) + if (default_crosshair_colors.f == 0) { // use the brightest color in the original 8-bit tile - int bri = 0, j = 0; + int bri = 0, j = 0, i; + int ii; + char *ptr = (char *)waloff[CROSSHAIR]; + + if (waloff[CROSSHAIR] == 0) + { + loadtile(CROSSHAIR); + ptr = (char *)waloff[CROSSHAIR]; + } + ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; + while (ii > 0) { if (*ptr != 255) @@ -3406,12 +3396,33 @@ void SetCrosshairColor(int r, int g, int b) ptr++; ii--; } - crosshair_red_default = crosshair_red = curpalette[bri].r; - crosshair_green_default = crosshair_green = curpalette[bri].g; - crosshair_blue_default = crosshair_blue = curpalette[bri].b; + + default_crosshair_colors.r = crosshair_colors.r = curpalette[bri].r; + default_crosshair_colors.g = crosshair_colors.g = curpalette[bri].g; + default_crosshair_colors.b = crosshair_colors.b = curpalette[bri].b; + default_crosshair_colors.f = 1; + } +} + +void SetCrosshairColor(int r, int g, int b) +{ + char *ptr = (char *)waloff[CROSSHAIR]; + int i, ii; + static int sum; + + if (default_crosshair_colors.f == 0 || sum == r+(g<<1)+(b<<2)) return; + sum = r+(g<<1)+(b<<2); + crosshair_colors.r = r; + crosshair_colors.g = g; + crosshair_colors.b = b; + + if (waloff[CROSSHAIR] == 0) + { + loadtile(CROSSHAIR); + ptr = (char *)waloff[CROSSHAIR]; } - i = getclosestcol(crosshair_red>>2, crosshair_green>>2, crosshair_blue>>2); + i = getclosestcol(crosshair_colors.r>>2, crosshair_colors.g>>2, crosshair_colors.b>>2); ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; while (ii > 0) { @@ -3422,11 +3433,11 @@ void SetCrosshairColor(int r, int g, int b) } for (i = 0; i < 256; i++) tempbuf[i] = i; - makepalookup(CROSSHAIR_PAL,tempbuf,crosshair_red>>2, crosshair_green>>2, crosshair_blue>>2,1); + makepalookup(CROSSHAIR_PAL,tempbuf,crosshair_colors.r>>2, crosshair_colors.g>>2, crosshair_colors.b>>2,1); - hictinting[CROSSHAIR_PAL].r = crosshair_red; - hictinting[CROSSHAIR_PAL].g = crosshair_green; - hictinting[CROSSHAIR_PAL].b = crosshair_blue; + hictinting[CROSSHAIR_PAL].r = crosshair_colors.r; + hictinting[CROSSHAIR_PAL].g = crosshair_colors.g; + hictinting[CROSSHAIR_PAL].b = crosshair_colors.b; hictinting[CROSSHAIR_PAL].f = 1; invalidatetile(CROSSHAIR, -1, -1); } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index cf777b552..b04f9872b 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -1321,9 +1321,7 @@ static int osdcmd_setcrosshairscale(const osdfuncparm_t *parm) } extern void SetCrosshairColor(int r, int g, int b); -extern int crosshair_red; -extern int crosshair_green; -extern int crosshair_blue; +extern palette_t crosshair_colors; static int osdcmd_crosshaircolor(const osdfuncparm_t *parm) { @@ -1331,7 +1329,7 @@ static int osdcmd_crosshaircolor(const osdfuncparm_t *parm) if (parm->numparms != 3) { - OSD_Printf("\"crosshaircolor\" : r:%d g:%d b:%d\n",crosshair_red,crosshair_green,crosshair_blue); + OSD_Printf("\"crosshaircolor\" : r:%d g:%d b:%d\n",crosshair_colors.r,crosshair_colors.g,crosshair_colors.b); return OSDCMD_SHOWHELP; } r = atol(parm->parms[0]); diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 0ae076d43..0f29f7f85 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -400,9 +400,7 @@ 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; +extern palette_t crosshair_colors; void cacheit(void) { @@ -559,7 +557,8 @@ void vscrn(void) setview(x1,y1,x2-1,y2-1); - SetCrosshairColor(crosshair_red, crosshair_green, crosshair_blue); + GetCrosshairColor(); + SetCrosshairColor(crosshair_colors.r, crosshair_colors.g, crosshair_colors.b); pub = NUMPAGES; pus = NUMPAGES;