From a2c171fbf91e024767ecb8a800a3d7ec13e5d611 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sat, 28 May 2011 21:24:07 +0100 Subject: [PATCH] Remove remaining references to old decorations buffer --- includes/defines.h | 1 + includes/graphics.h | 2 -- includes/interface.h | 2 +- src/graphics.c | 33 +++++++++++---------------------- src/interface.c | 18 +++++++++++------- src/main.c | 8 ++------ 6 files changed, 26 insertions(+), 38 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index 2194159a1..953ef3ded 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -126,6 +126,7 @@ extern int legacy_enable; extern int ngrav_enable; //Newtonian gravity extern int sound_enable; extern int kiosk_enable; +extern int decorations_enable; extern int sys_pause; extern int framerender; diff --git a/includes/graphics.h b/includes/graphics.h index fe13d2b98..380b82846 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -122,8 +122,6 @@ void draw_parts(pixel *vid); void draw_walls(pixel *vid); -void draw_decorations(pixel *vid_buf,pixel *decorations); - void draw_wavelengths(pixel *vid, int x, int y, int h, int wl); void render_signs(pixel *vid_buf); diff --git a/includes/interface.h b/includes/interface.h index dd45fb7de..7834bb36d 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -240,6 +240,6 @@ char *console_ui(pixel *vid_buf, char error[255],char console_more); void simulation_ui(pixel *vid_buf); -unsigned int decorations_ui(pixel *vid_buf, pixel *decorations, int *bsx, int *bsy, unsigned int savedColor); +unsigned int decorations_ui(pixel *vid_buf, int *bsx, int *bsy, unsigned int savedColor); #endif diff --git a/src/graphics.c b/src/graphics.c index 7192de9d4..df94f788d 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3070,7 +3070,8 @@ void draw_parts(pixel *vid) blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); } - blendpixel(vid, nx, ny, (parts[i].dcolour>>16)&0xFF, (parts[i].dcolour>>8)&0xFF, (parts[i].dcolour)&0xFF, (parts[i].dcolour>>24)&0xFF); + if (decorations_enable) + blendpixel(vid, nx, ny, (parts[i].dcolour>>16)&0xFF, (parts[i].dcolour>>8)&0xFF, (parts[i].dcolour)&0xFF, (parts[i].dcolour>>24)&0xFF); } #endif } @@ -3249,19 +3250,7 @@ void draw_walls(pixel *vid) } } -void draw_decorations(pixel *vid_buf,pixel *decorations) -{ - /*int i,r,g,b; - for (i=0; i<(XRES+BARSIZE)*YRES; i++) - { - r = (decorations[i]&0xFF0000)>>16; - g = (decorations[i]&0x00FF00)>>8; - b = decorations[i]&0x0000FF; - if (r>0 || g>0 || b>0) - vid_buf[i] = PIXRGB(r,g,b); - }*/ -} -void create_decorations(pixel *decorations,int x, int y, int rx, int ry, int r, int g, int b) +void create_decorations(int x, int y, int rx, int ry, int r, int g, int b) { int i,j,rp; if (rx==0 && ry==0) @@ -3269,7 +3258,7 @@ void create_decorations(pixel *decorations,int x, int y, int rx, int ry, int r, rp = pmap[y][x]; if ((rp>>8)>=NPART || !rp) return; - parts[rp>>8].dcolour = ((255<<24)|(r<<16)|(g<<8)|b);//decorations[(y)*(XRES+BARSIZE)+(x)] = PIXRGB(r, g, b); + parts[rp>>8].dcolour = ((255<<24)|(r<<16)|(g<<8)|b); return; } for (j=-ry; j<=ry; j++) @@ -3282,7 +3271,7 @@ void create_decorations(pixel *decorations,int x, int y, int rx, int ry, int r, parts[rp>>8].dcolour = ((255<<24)|(r<<16)|(g<<8)|b); } } -void line_decorations(pixel *decorations,int x1, int y1, int x2, int y2, int rx, int ry, int r, int g, int b) +void line_decorations(int x1, int y1, int x2, int y2, int rx, int ry, int r, int g, int b) { int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; float e, de; @@ -3316,9 +3305,9 @@ void line_decorations(pixel *decorations,int x1, int y1, int x2, int y2, int rx, for (x=x1; x<=x2; x++) { if (cp) - create_decorations(decorations,y, x, rx, ry, r, g, b); + create_decorations(y, x, rx, ry, r, g, b); else - create_decorations(decorations,x, y, rx, ry, r, g, b); + create_decorations(x, y, rx, ry, r, g, b); e += de; if (e >= 0.5f) { @@ -3326,15 +3315,15 @@ void line_decorations(pixel *decorations,int x1, int y1, int x2, int y2, int rx, if (!(rx+ry)) { if (cp) - create_decorations(decorations,y, x, rx, ry, r, g, b); + create_decorations(y, x, rx, ry, r, g, b); else - create_decorations(decorations,x, y, rx, ry, r, g, b); + create_decorations(x, y, rx, ry, r, g, b); } e -= 1.0f; } } } -void box_decorations(pixel *decorations,int x1, int y1, int x2, int y2, int r, int g, int b) +void box_decorations(int x1, int y1, int x2, int y2, int r, int g, int b) { int i, j; if (x1>x2) @@ -3351,7 +3340,7 @@ void box_decorations(pixel *decorations,int x1, int y1, int x2, int y2, int r, i } for (j=y1; j<=y2; j++) for (i=x1; i<=x2; i++) - create_decorations(decorations,i, j, 0, 0, r, g, b); + create_decorations(i, j, 0, 0, r, g, b); } //draws the photon colors in the HUD diff --git a/src/interface.c b/src/interface.c index c501dddaf..f274dc547 100644 --- a/src/interface.c +++ b/src/interface.c @@ -4334,7 +4334,7 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) { return NULL; } -unsigned int decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy, unsigned int savedColor) +unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int savedColor) {//TODO: have the text boxes be editable and update the color. Maybe use 0-360 for H in hsv to fix minor inaccuracies (rgb of 0,0,255 , comes back as 0,3,255) int i,ss,hh,vv,cr=127,cg=0,cb=0,b = 0,mx,my,bq = 0,j, lb=0,lx=0,ly=0,lm=0,hidden=0; int window_offset_x_left = 2; @@ -4401,7 +4401,7 @@ unsigned int decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy, my /= sdl_scale; memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE); - draw_parts(vid_buf);//draw_decorations(vid_buf,decorations); + draw_parts(vid_buf); //ui_edit_process(mx, my, b, &box_R); //ui_edit_process(mx, my, b, &box_G); //ui_edit_process(mx, my, b, &box_B); @@ -4536,7 +4536,11 @@ unsigned int decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy, } if(b && !bq && mx >= window_offset_x + 230 && my >= window_offset_y +255+6 && mx <= window_offset_x + 230 +26 && my <= window_offset_y +255+5 +13) if (confirm_ui(vid_buf, "Reset Decoration Layer", "Do you really want to erase everything?", "Erase") ) - memset(decorations, 0,(XRES+BARSIZE)*YRES*PIXELSIZE); + { + int i; + for (i=0;i XRES || my > YRES) { @@ -4584,7 +4588,7 @@ unsigned int decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy, } else if(lb!=3)//while mouse is held down, it draws lines between previous and current positions { - line_decorations(decorations,lx, ly, mx, my, *bsx, *bsy, cr, cg, cb); + line_decorations(lx, ly, mx, my, *bsx, *bsy, cr, cg, cb); lx = mx; ly = my; } @@ -4625,7 +4629,7 @@ unsigned int decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy, } else //normal click, draw deco { - create_decorations(decorations,mx,my,*bsx,*bsy,cr,cg,cb); + create_decorations(mx,my,*bsx,*bsy,cr,cg,cb); lx = mx; ly = my; lb = b; @@ -4644,9 +4648,9 @@ unsigned int decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy, if (lb && lm) //lm is box/line tool { if (lm == 1)//line - line_decorations(decorations,lx, ly, mx, my, *bsx, *bsy, cr, cg, cb); + line_decorations(lx, ly, mx, my, *bsx, *bsy, cr, cg, cb); else//box - box_decorations(decorations,lx, ly, mx, my, cr, cg, cb); + box_decorations(lx, ly, mx, my, cr, cg, cb); lm = 0; } lb = 0; diff --git a/src/main.c b/src/main.c index 446f1670b..e53c6ae75 100644 --- a/src/main.c +++ b/src/main.c @@ -1437,8 +1437,7 @@ int main(int argc, char *argv[]) parts[i].life = i+1; parts[NPART-1].life = -1; pfree = 0; - - decorations = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); + pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); fire_bg = calloc(XRES*YRES, PIXELSIZE); @@ -2173,7 +2172,7 @@ int main(int argc, char *argv[]) } else { - hsvSave = decorations_ui(vid_buf,decorations,&bsx,&bsy,hsvSave);//decoration_mode = !decoration_mode; + hsvSave = decorations_ui(vid_buf,&bsx,&bsy,hsvSave);//decoration_mode = !decoration_mode; decorations_enable = 1; sys_pause=1; } @@ -2470,7 +2469,6 @@ int main(int argc, char *argv[]) } } menu_ui_v3(vid_buf, active_menu, &sl, &sr, &dae, b, bq, x, y); //draw the elements in the current menu - if (decorations_enable) draw_decorations(vid_buf,decorations); if (zoom_en && x>=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy //change mouse position while it is in a zoom window && x=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) {