Display photon wavelengths in HUD
This commit is contained in:
parent
72a4490bb5
commit
db91bd37f0
@ -121,7 +121,7 @@ void xor_line(int x1, int y1, int x2, int y2, pixel *vid);
|
|||||||
void xor_rect(pixel *vid, int x, int y, int w, int h);
|
void xor_rect(pixel *vid, int x, int y, int w, int h);
|
||||||
|
|
||||||
void draw_parts(pixel *vid);
|
void draw_parts(pixel *vid);
|
||||||
|
void draw_wavelengths(pixel *vid, int x, int y, int h, int wl);
|
||||||
void render_signs(pixel *vid_buf);
|
void render_signs(pixel *vid_buf);
|
||||||
|
|
||||||
void render_fire(pixel *dst);
|
void render_fire(pixel *dst);
|
||||||
|
@ -2925,6 +2925,36 @@ void draw_parts(pixel *vid)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_wavelengths(pixel *vid, int x, int y, int h, int wl)
|
||||||
|
{
|
||||||
|
fillrect(vid,x-1,y-1,30+1,h+1,64,64,64,255); // coords -1 size +1 to work around bug in fillrect - TODO: fix fillrect
|
||||||
|
int i,cr,cg,cb,j;
|
||||||
|
int tmp;
|
||||||
|
for (i=0;i<30;i++)
|
||||||
|
{
|
||||||
|
if ((wl>>i)&1)
|
||||||
|
{
|
||||||
|
// Need a spread of wavelengths to get a smooth spectrum, 5 bits seems to work reasonably well
|
||||||
|
if (i>2) tmp = 0x1F << (i-2);
|
||||||
|
else tmp = 0x1F >> (2-i);
|
||||||
|
cg = 0;
|
||||||
|
cb = 0;
|
||||||
|
cr = 0;
|
||||||
|
for (j=0; j<12; j++) {
|
||||||
|
cr += (tmp >> (j+18)) & 1;
|
||||||
|
cb += (tmp >> j) & 1;
|
||||||
|
}
|
||||||
|
for (j=0; j<14; j++)
|
||||||
|
cg += (tmp >> (j+9)) & 1;
|
||||||
|
tmp = 624/(cr+cg+cb+1);
|
||||||
|
cr *= tmp;
|
||||||
|
cg *= tmp;
|
||||||
|
cb *= tmp;
|
||||||
|
for (j=0;j<h;j++) blendpixel(vid,x+29-i,y+j,cr>255?255:cr,cg>255?255:cg,cb>255?255:cb,255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void render_signs(pixel *vid_buf)
|
void render_signs(pixel *vid_buf)
|
||||||
{
|
{
|
||||||
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
|
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
|
||||||
|
11
src/main.c
11
src/main.c
@ -1204,6 +1204,7 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef INTERNAL
|
#ifdef INTERNAL
|
||||||
int vs = 0;
|
int vs = 0;
|
||||||
#endif
|
#endif
|
||||||
|
int wavelength_gfx = 0;
|
||||||
int x, y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty;
|
int x, y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty;
|
||||||
int da = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2;
|
int da = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2;
|
||||||
float nfvx, nfvy;
|
float nfvx, nfvy;
|
||||||
@ -1954,7 +1955,7 @@ int main(int argc, char *argv[])
|
|||||||
if (DEBUG_MODE)
|
if (DEBUG_MODE)
|
||||||
{
|
{
|
||||||
int tctype = parts[cr>>8].ctype;
|
int tctype = parts[cr>>8].ctype;
|
||||||
if (tctype>=PT_NUM)
|
if (tctype>=PT_NUM || (cr&0xFF)==PT_PHOT)
|
||||||
tctype = 0;
|
tctype = 0;
|
||||||
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
|
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
|
||||||
sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale);
|
sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale);
|
||||||
@ -1965,6 +1966,7 @@ int main(int argc, char *argv[])
|
|||||||
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
|
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if ((cr&0xFF)==PT_PHOT) wavelength_gfx = parts[cr>>8].ctype;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2692,6 +2694,8 @@ int main(int argc, char *argv[])
|
|||||||
fillrect(vid_buf, XRES-20-textwidth(coordtext), 280, textwidth(coordtext)+8, 13, 0, 0, 0, 140);
|
fillrect(vid_buf, XRES-20-textwidth(coordtext), 280, textwidth(coordtext)+8, 13, 0, 0, 0, 140);
|
||||||
drawtext(vid_buf, XRES-16-textwidth(coordtext), 282, coordtext, 255, 255, 255, 200);
|
drawtext(vid_buf, XRES-16-textwidth(coordtext), 282, coordtext, 255, 255, 255, 200);
|
||||||
}
|
}
|
||||||
|
if (wavelength_gfx)
|
||||||
|
draw_wavelengths(vid_buf,XRES-20-textwidth(heattext),265,2,wavelength_gfx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2702,6 +2706,8 @@ int main(int argc, char *argv[])
|
|||||||
fillrect(vid_buf, 12, 280, textwidth(coordtext)+8, 13, 0, 0, 0, 140);
|
fillrect(vid_buf, 12, 280, textwidth(coordtext)+8, 13, 0, 0, 0, 140);
|
||||||
drawtext(vid_buf, 16, 282, coordtext, 255, 255, 255, 200);
|
drawtext(vid_buf, 16, 282, coordtext, 255, 255, 255, 200);
|
||||||
}
|
}
|
||||||
|
if (wavelength_gfx)
|
||||||
|
draw_wavelengths(vid_buf,12,265,2,wavelength_gfx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2713,7 +2719,10 @@ int main(int argc, char *argv[])
|
|||||||
fillrect(vid_buf, XRES-20-textwidth(coordtext), 26, textwidth(coordtext)+8, 11, 0, 0, 0, 140);
|
fillrect(vid_buf, XRES-20-textwidth(coordtext), 26, textwidth(coordtext)+8, 11, 0, 0, 0, 140);
|
||||||
drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, 200);
|
drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, 200);
|
||||||
}
|
}
|
||||||
|
if (wavelength_gfx)
|
||||||
|
draw_wavelengths(vid_buf,XRES-20-textwidth(heattext),11,2,wavelength_gfx);
|
||||||
}
|
}
|
||||||
|
wavelength_gfx = 0;
|
||||||
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
|
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
|
||||||
drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, 200);
|
drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, 200);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user