git-svn-id: https://svn.eduke32.com/eduke32@941 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-08-08 01:54:43 +00:00
parent 31b05a433c
commit 2030a42763
5 changed files with 85 additions and 44 deletions

View file

@ -592,6 +592,8 @@ void CONFIG_SetupJoystick(void)
*/ */
extern char *duke3dgrp; extern char *duke3dgrp;
extern void check_valid_color(int *color,int prev_color); 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) 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, "Setup", "ForceSetup",&ud.config.ForceSetup);
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "RunMode",&ud.config.RunMode); 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", "Crosshairs",&ud.crosshair);
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "CrosshairScale",&ud.crosshairscale); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "CrosshairScale",&ud.crosshairscale);
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale);
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",&ud.levelstats); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",&ud.levelstats);
@ -807,6 +810,30 @@ int32 CONFIG_ReadSetup(void)
windowy = -1; windowy = -1;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32 *)&windowy); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32 *)&windowy);
#endif #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(); CONFIG_ReadKeys();
@ -986,6 +1013,9 @@ void CONFIG_WriteSetup(void)
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, false, false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, false, false);
#endif #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 // JBF 20031211
for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++) for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++)
{ {

View file

@ -255,4 +255,7 @@ extern void se40code(int x,int y,int z,int a,int h, int smoothratio);
extern void FreeMapState(int mapnum); extern void FreeMapState(int mapnum);
extern void getlevelfromfilename(const char *fn, char *volume, char *level); extern void getlevelfromfilename(const char *fn, char *volume, char *level);
extern void GetCrosshairColor(void);
extern void SetCrosshairColor(int r, int g, int b);
#endif // __funct_h__ #endif // __funct_h__

View file

@ -2048,7 +2048,7 @@ static void coolgaugetext(int snum)
else i = p->curr_weapon; else i = p->curr_weapon;
altdigitalnumber(-20,-(200-22),p->ammo_amount[i],-16,10+16); altdigitalnumber(-20,-(200-22),p->ammo_amount[i],-16,10+16);
o = 100; o = 102;
permbit = 0; permbit = 0;
if (p->inven_icon) if (p->inven_icon)
@ -3363,27 +3363,20 @@ 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) #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 };
/* TODO: turn this into something useful */ palette_t default_crosshair_colors = { 0, 0, 0, 0 };
char *ptr = (char *)waloff[CROSSHAIR];
int i, ii;
static int sum;
if (sum == r+(g<<1)+(b<<2)) return; void GetCrosshairColor(void)
sum = r+(g<<1)+(b<<2); {
crosshair_red = r; if (default_crosshair_colors.f == 0)
crosshair_green = g; {
crosshair_blue = b; // use the brightest color in the original 8-bit tile
int bri = 0, j = 0, i;
int ii;
char *ptr = (char *)waloff[CROSSHAIR];
if (waloff[CROSSHAIR] == 0) if (waloff[CROSSHAIR] == 0)
{ {
@ -3391,11 +3384,8 @@ void SetCrosshairColor(int r, int g, int b)
ptr = (char *)waloff[CROSSHAIR]; ptr = (char *)waloff[CROSSHAIR];
} }
if (crosshair_red_default == -1)
{
// use the brightest color in the original 8-bit tile
int bri = 0, j = 0;
ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR];
while (ii > 0) while (ii > 0)
{ {
if (*ptr != 255) if (*ptr != 255)
@ -3406,12 +3396,33 @@ void SetCrosshairColor(int r, int g, int b)
ptr++; ptr++;
ii--; ii--;
} }
crosshair_red_default = crosshair_red = curpalette[bri].r;
crosshair_green_default = crosshair_green = curpalette[bri].g; default_crosshair_colors.r = crosshair_colors.r = curpalette[bri].r;
crosshair_blue_default = crosshair_blue = curpalette[bri].b; 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;
}
} }
i = getclosestcol(crosshair_red>>2, crosshair_green>>2, crosshair_blue>>2); 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_colors.r>>2, crosshair_colors.g>>2, crosshair_colors.b>>2);
ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR];
while (ii > 0) while (ii > 0)
{ {
@ -3422,11 +3433,11 @@ void SetCrosshairColor(int r, int g, int b)
} }
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
tempbuf[i] = 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].r = crosshair_colors.r;
hictinting[CROSSHAIR_PAL].g = crosshair_green; hictinting[CROSSHAIR_PAL].g = crosshair_colors.g;
hictinting[CROSSHAIR_PAL].b = crosshair_blue; hictinting[CROSSHAIR_PAL].b = crosshair_colors.b;
hictinting[CROSSHAIR_PAL].f = 1; hictinting[CROSSHAIR_PAL].f = 1;
invalidatetile(CROSSHAIR, -1, -1); invalidatetile(CROSSHAIR, -1, -1);
} }

View file

@ -1321,9 +1321,7 @@ static int osdcmd_setcrosshairscale(const osdfuncparm_t *parm)
} }
extern void SetCrosshairColor(int r, int g, int b); extern void SetCrosshairColor(int r, int g, int b);
extern int crosshair_red; extern palette_t crosshair_colors;
extern int crosshair_green;
extern int crosshair_blue;
static int osdcmd_crosshaircolor(const osdfuncparm_t *parm) static int osdcmd_crosshaircolor(const osdfuncparm_t *parm)
{ {
@ -1331,7 +1329,7 @@ static int osdcmd_crosshaircolor(const osdfuncparm_t *parm)
if (parm->numparms != 3) 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; return OSDCMD_SHOWHELP;
} }
r = atol(parm->parms[0]); r = atol(parm->parms[0]);

View file

@ -400,9 +400,7 @@ static void dofrontscreens(char *statustext)
} }
extern void SetCrosshairColor(int r, int g, int b); extern void SetCrosshairColor(int r, int g, int b);
extern int crosshair_red; extern palette_t crosshair_colors;
extern int crosshair_green;
extern int crosshair_blue;
void cacheit(void) void cacheit(void)
{ {
@ -559,7 +557,8 @@ void vscrn(void)
setview(x1,y1,x2-1,y2-1); 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; pub = NUMPAGES;
pus = NUMPAGES; pus = NUMPAGES;