From 0ccd04b848aad6d6b454d869dcda5c92b0653997 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Sat, 23 Apr 2011 23:17:35 -0400 Subject: [PATCH] More decoration improvements. still TODO: text boxes that will change current color, as well as display current color. A menu with some basic color swatches. --- src/interface.c | 41 +++++++++++++++++++++++++++++++++-------- src/main.c | 9 ++++----- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/interface.c b/src/interface.c index 748d31336..41df2d4a4 100644 --- a/src/interface.c +++ b/src/interface.c @@ -4339,11 +4339,11 @@ void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy) mx /= sdl_scale; my /= sdl_scale; - memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); + memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE); draw_decorations(vid_buf,decorations); - ui_edit_process(mx, my, b, &box_R); - ui_edit_process(mx, my, b, &box_G); - ui_edit_process(mx, my, b, &box_B); + //ui_edit_process(mx, my, b, &box_R); + //ui_edit_process(mx, my, b, &box_G); + //ui_edit_process(mx, my, b, &box_B); //HSV_to_RGB(h,s,v,&cr,&cg,&cb); //if(cr != atoi(box_R.str)) //RGB_to_HSV(atoi(box_R.str),cg,cb,&h,&s,&v); @@ -4365,14 +4365,22 @@ void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy) box_G.x = XRES - 254 + 40; box_B.x = XRES - 254 + 75; } + render_cursor(vid_buf, mx, my, PT_DUST, *bsx, *bsy); + + drawrect(vid_buf, -1, -1, XRES+1, YRES+1, 220, 220, 220, 255); + drawrect(vid_buf, -1, -1, XRES+2, YRES+2, 70, 70, 70, 255); + clearrect(vid_buf, window_offset_x, window_offset_y, 2+255+4+10+5, 2+255+20); drawrect(vid_buf, window_offset_x, window_offset_y, 2+255+4+10+5, 2+255+20, 255, 255, 255, 255);//window around whole thing + drawrect(vid_buf, window_offset_x + onleft_button_offset_x +1, window_offset_y +255+6, 12, 12, 255, 255, 255, 255); + drawrect(vid_buf, window_offset_x + 230, window_offset_y +255+6, 26, 12, 255, 255, 255, 255); + drawtext(vid_buf, window_offset_x + 232, window_offset_y +255+9, "Clear", 255, 255, 255, 255); + drawtext(vid_buf, 2, 388, "Welcome to the decoration editor v.1 (by cracker64) \nThis space should be used for basic color swatches to click on, and maybe some other tool buttons.\nPro tip: click the current color to move the selector to the other side. ", 255, 255, 255, 255); ui_edit_draw(vid_buf, &box_R); ui_edit_draw(vid_buf, &box_G); ui_edit_draw(vid_buf, &box_B); - render_cursor(vid_buf, mx, my, PT_DUST, *bsx, *bsy); for(int ss=0; ss<=255; ss++) for(int hh=0;hh<=255;hh++) { @@ -4430,11 +4438,22 @@ void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy) sprintf(box_G.str,"%d",cg); sprintf(box_B.str,"%d",cb); } - if(b && mx >= window_offset_x + onleft_button_offset_x && my >= window_offset_y +255+4 && mx <= window_offset_x + onleft_button_offset_x +13 && my <= window_offset_y +255+4 +13) + if(b && mx >= window_offset_x + onleft_button_offset_x +1 && my >= window_offset_y +255+6 && mx <= window_offset_x + onleft_button_offset_x +13 && my <= window_offset_y +255+5 +13) + { on_left = !on_left; + lb = 3;//prevent immediate drawing after clicking + } + if(b && mx >= window_offset_x + 230 && my >= window_offset_y +255+6 && mx <= window_offset_x + 230 +26 && my <= window_offset_y +255+5 +13) + memset(decorations, 0,(XRES+BARSIZE)*YRES*PIXELSIZE); } else if (b)//there is a click, outside window { + if (!(b&1)) + { + cr = 0; + cg = 0; + cb = 0; + } if (lb)//mouse is held down { if (lm == 1)//line tool @@ -4448,7 +4467,7 @@ void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy) xor_line(mx, my, mx, ly, vid_buf); xor_line(mx, ly, lx, ly, vid_buf); } - else//while mouse is held down, it draws lines between previous and current positions + 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); lx = mx; @@ -4484,6 +4503,12 @@ void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy) } else { + if (!(lb&1)) + { + cr = 0; + cg = 0; + cb = 0; + } if (lb && lm) //lm is box/line tool { if (lm == 1)//line @@ -4540,7 +4565,7 @@ void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy) }*/ } } - if(sdl_key=='b') + if(sdl_key=='b' || sdl_key==SDLK_ESCAPE) { free(old_buf); return; diff --git a/src/main.c b/src/main.c index c435d3b63..e0aee473d 100644 --- a/src/main.c +++ b/src/main.c @@ -3281,7 +3281,10 @@ int main(int argc, char *argv[]) //hud_enable = !console_mode; } if (sdl_key=='b') + { decorations_ui(vid_buf,decorations,&bsx,&bsy);//decoration_mode = !decoration_mode; + sys_pause=1; + } if (sdl_key=='g') { if (sdl_mod & (KMOD_SHIFT)) @@ -3924,11 +3927,7 @@ int main(int argc, char *argv[]) ISSPAWN1 = 0; ISSPAWN2 = 0; - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); - memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); + memset(decorations, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); } if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) {