diff --git a/defines.h b/defines.h index 6f0dab383..bbce8b243 100644 --- a/defines.h +++ b/defines.h @@ -1,6 +1,12 @@ #ifndef DEFINE_H #define DEFINE_H +#ifdef WIN32 +#define PATH_SEP "\\" +#else +#define PATH_SEP "/" +#endif + #define SERVER "powdertoy.co.uk" #undef PLOSS @@ -28,6 +34,22 @@ static unsigned char ZSIZE = ZSIZE_D; #define VLOSS 0.999f #define PLOSS 0.9999f +#define GRID_X 5 +#define GRID_Y 4 +#define GRID_P 3 +#define GRID_S 6 +#define GRID_Z 3 + +#define STAMP_X 4 +#define STAMP_Y 4 +#define STAMP_MAX 120 + +#ifdef PIX16 +typedef unsigned short pixel; +#else +typedef unsigned int pixel; +#endif + typedef unsigned char uint8; extern int legacy_enable; @@ -45,6 +67,18 @@ struct sign }; typedef struct sign sign; +struct stamp +{ + char name[11]; + pixel *thumb; + int thumb_w, thumb_h, dodelete; +}; +typedef struct stamp stamp; + extern sign signs[MAXSIGNS]; +extern stamp stamps[STAMP_MAX]; +extern int stamp_count; +extern int itc; +extern char itc_msg[64]; #endif \ No newline at end of file diff --git a/graphics.c b/graphics.c index 226a98465..8f5c6aeb6 100644 --- a/graphics.c +++ b/graphics.c @@ -1,5 +1,6 @@ #include #include +#include #include "defines.h" #include "air.h" #include "powder.h" @@ -16,6 +17,9 @@ unsigned char fire_r[YRES/CELL][XRES/CELL]; unsigned char fire_g[YRES/CELL][XRES/CELL]; unsigned char fire_b[YRES/CELL][XRES/CELL]; +unsigned int fire_alpha[CELL*3][CELL*3]; +pixel *fire_bg; + pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f) { int i,j,x,y,w,h,r,g,b,c; @@ -1769,4 +1773,124 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-1, ny+1, R, G, B, 112); } } -} \ No newline at end of file +} + +void render_signs(pixel *vid_buf) +{ + int i, j, x, y, w, h, dx, dy; + char buff[30]; //Buffer + for(i=0; i>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)>8].temp); //...tempirature + else + sprintf(buff, "Temp: 0.00"); //...tempirature + drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); + } + + //Usual text + if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}")) + drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); + x = signs[i].x; + y = signs[i].y; + dx = 1 - signs[i].ju; + dy = (signs[i].y > 18) ? -1 : 1; + for(j=0; j<4; j++) + { + drawpixel(vid_buf, x, y, 192, 192, 192, 255); + x+=dx; + y+=dy; + } + } +} + +void render_fire(pixel *dst) +{ + int i,j,x,y,r,g,b; + for(j=0; j=0 && j+y>=0 && i+x4 ? r-4 : 0; + fire_g[j][i] = g>4 ? g-4 : 0; + fire_b[j][i] = b>4 ? b-4 : 0; + } +} + +void prepare_alpha(void) +{ + int x,y,i,j; + float temp[CELL*3][CELL*3]; + memset(temp, 0, sizeof(temp)); + for(x=0; x>8)&0xF800)|(((x)>>5)&0x07E0)|(((x)>>3)&0x001F)) #define PIXRGB(r,g,b) ((((r)<<8)&0xF800)|(((g)<<3)&0x07E0)|(((b)>>3)&0x001F)) #define PIXR(x) (((x)>>8)&0xF8) @@ -14,7 +13,6 @@ typedef unsigned short pixel; #define PIXB(x) (((x)<<3)&0xF8) #else #define PIXELSIZE 4 -typedef unsigned int pixel; #ifdef PIX32BGR #define PIXPACK(x) ((((x)>>16)&0x0000FF)|((x)&0x00FF00)|(((x)<<16)&0xFF0000)) #define PIXRGB(r,g,b) (((b)<<16)|((g)<<8)|((r)))// (((b)<<16)|((g)<<8)|(r)) @@ -46,6 +44,9 @@ extern unsigned char fire_r[YRES/CELL][XRES/CELL]; extern unsigned char fire_g[YRES/CELL][XRES/CELL]; extern unsigned char fire_b[YRES/CELL][XRES/CELL]; +extern unsigned int fire_alpha[CELL*3][CELL*3]; +extern pixel *fire_bg; + pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f); void sdl_blit_1(int x, int y, int w, int h, pixel *src, int pitch); @@ -114,4 +115,10 @@ void xor_rect(pixel *vid, int x, int y, int w, int h); void draw_parts(pixel *vid); +void render_signs(pixel *vid_buf); + +void render_fire(pixel *dst); + +void prepare_alpha(void); + #endif \ No newline at end of file diff --git a/interface.c b/interface.c index cb61054a0..f40fadc85 100644 --- a/interface.c +++ b/interface.c @@ -1,6 +1,7 @@ #include #include #include +#include "font.h" #include "defines.h" #include "powder.h" #include "interface.h" @@ -41,6 +42,24 @@ void menu_count(void) } +void get_sign_pos(int i, int *x0, int *y0, int *w, int *h) +{ + //Changing width if sign have special content + if(strcmp(signs[i].text, "{p}")==0) + *w = textwidth("Pressure: -000.00"); + + if(strcmp(signs[i].text, "{t}")==0) + *w = textwidth("Temp: 0000.00"); + + //Ususal width + if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}")) + *w = textwidth(signs[i].text) + 5; + *h = 14; + *x0 = (signs[i].ju == 2) ? signs[i].x - *w : + (signs[i].ju == 1) ? signs[i].x - *w/2 : signs[i].x; + *y0 = (signs[i].y > 18) ? signs[i].y - 18 : signs[i].y + 4; +} + void add_sign_ui(pixel *vid_buf, int mx, int my) { int i, w, h, x, y, nm=0, ju; @@ -767,6 +786,735 @@ fail: svf_mod = 0; } +int stamp_ui(pixel *vid_buf) +{ + int b=1,bq,mx,my,d=-1,i,j,k,x,gx,gy,y,w,h,r=-1,stamp_page=0,per_page=STAMP_X*STAMP_Y,page_count; + char page_info[64]; + page_count = ceil((float)stamp_count/(float)per_page); + + while(!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if(!b) + break; + } + + while(!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; + + clearrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE+1); + k = stamp_page*per_page;//0; + r = -1; + d = -1; + for(j=0; j=gx+XRES/GRID_S-4 && mx<(gx+XRES/GRID_S)+6 && my>=gy-6 && my=gx && mx=gy && my=1 && mx<=17 && my>=YRES+MENUSIZE-18 && my0) + { + if(stamp_page) + { + stamp_page --; + } + sdl_wheel = 0; + } + if((b && !bq && mx>=XRES-18 && mx<=XRES-1 && my>=YRES+MENUSIZE-18 && my=x0+18 && mx=y-2 && my=x0+d+18 && mx=y-2 && my=x0+d+32 && mx=y-2 && my=x0 && mx<=x0+192 && my>=y0+240 && my=x0+9 && mx=y0+218 && my=x0+9 && mx=y0+22 && my=x0 && mx=y0+74+YRES/4 && my=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else if(i==SC_SPECIAL) + { + for(n = 122; n<122+UI_WALLCOUNT; n++) + { + if(n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) + { + if(x-26<=60) + { + x = XRES-BARSIZE-26; + y += 19; + } + x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; + if(mx>=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + for(n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else + { + for(n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + + if(h==-1) + { + drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy+height+10, (char *)msections[i].name, 255, 255, 255, 255); + } + else if(i==SC_WALL||(i==SC_SPECIAL&&h>=122)) + { + drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy+height+10, (char *)mwalls[h-122].descs, 255, 255, 255, 255); + } + else + { + drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy+height+10, (char *)ptypes[h].descs, 255, 255, 255, 255); + } + + + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); + if(!(mx>=(XRES-BARSIZE-width)-7 && my>=sy-10 && my=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else if(i==SC_SPECIAL) + { + for(n = 122; n<122+UI_WALLCOUNT; n++) + { + if(n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) + { + if(x-26<=20) + { + x = XRES-BARSIZE-26; + y += 19; + } + x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; + if(!bq && mx>=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + for(n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else + { + for(n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if(n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if(n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + + if(h==-1) + { + drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy-10, (char *)msections[i].name, 255, 255, 255, 255); + } + else if(i==SC_WALL||(i==SC_SPECIAL&&h>=122)) + { + drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy-10, (char *)mwalls[h-122].descs, 255, 255, 255, 255); + } + else + { + drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy-10, (char *)ptypes[h].descs, 255, 255, 255, 255); + } + + if(b==1&&h!=-1) + { + *sl = h; + } + if(b==4&&h!=-1) + { + *sr = h; + } +} + int sdl_poll(void) { SDL_Event event; @@ -844,4 +1592,44 @@ int sdl_poll(void) } sdl_mod = SDL_GetModState(); return 0; +} + +void set_cmode(int cm) +{ + cmode = cm; + itc = 51; + if(cmode==4) + { + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + strcpy(itc_msg, "Blob Display"); + } + else if(cmode==5) + { + strcpy(itc_msg, "Heat Display"); + } + else if(cmode==6) + { + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + strcpy(itc_msg, "Fancy Display"); + } + else if(cmode==3) + { + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + strcpy(itc_msg, "Fire Display"); + } + else if(cmode==2) + { + memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + strcpy(itc_msg, "Persistent Display"); + } + else if(cmode==1) + strcpy(itc_msg, "Pressure Display"); + else + strcpy(itc_msg, "Velocity Display"); } \ No newline at end of file diff --git a/interface.h b/interface.h index 4d97f6be2..14ae878a1 100644 --- a/interface.h +++ b/interface.h @@ -102,6 +102,8 @@ extern int Z_keysym; void menu_count(void); +void get_sign_pos(int i, int *x0, int *y0, int *w, int *h); + void add_sign_ui(pixel *vid_buf, int mx, int my); void ui_edit_draw(pixel *vid_buf, ui_edit *ed); @@ -124,5 +126,17 @@ int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn); void login_ui(pixel *vid_buf); +int stamp_ui(pixel *vid_buf); + +void tag_list_ui(pixel *vid_buf); + +int save_name_ui(pixel *vid_buf); + +void menu_ui(pixel *vid_buf, int i, int *sl, int *sr); + +void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, int my); + int sdl_poll(void); + +void set_cmode(int cm); #endif \ No newline at end of file diff --git a/main.c b/main.c index ce1d6347b..88b712c35 100644 --- a/main.c +++ b/main.c @@ -927,50 +927,9 @@ corrupt: return NULL; } -/* NO, I DON'T THINK SO - #include "fbi.h" - - pixel *render_packed_rgb(void *image, int width, int height, int cmp_size) - { - unsigned char *tmp; - pixel *res; - int i; - - tmp = malloc(width*height*3); - if(!tmp) - return NULL; - res = malloc(width*height*PIXELSIZE); - if(!res) { - free(tmp); - return NULL; - } - - i = width*height*3; - if(BZ2_bzBuffToBuffDecompress((char *)tmp, (unsigned *)&i, (char *)image, cmp_size, 0, 0)) { - free(res); - free(tmp); - return NULL; - } - - for(i=0; i0) { - memcpy(&tmp, stamps+i, sizeof(struct stamp_info)); - memmove(stamps+1, stamps, sizeof(struct stamp_info)*i); - memcpy(stamps, &tmp, sizeof(struct stamp_info)); + memcpy(&tmp, stamps+i, sizeof(struct stamp)); + memmove(stamps+1, stamps, sizeof(struct stamp)*i); + memcpy(stamps, &tmp, sizeof(struct stamp)); stamp_update(); } @@ -1172,637 +1119,6 @@ void del_stamp(int d) stamp_init(); } -void menu_ui(pixel *vid_buf, int i, int *sl, int *sr) -{ - int b=1,bq,mx,my,h,x,y,n=0,height,width,sy,rows=0; - pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); - fillrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE, 0, 0, 0, 192); - memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; - rows = ceil((float)msections[i].itemcount/16.0f); - height = (ceil((float)msections[i].itemcount/16.0f)*18); - width = restrict_flt(msections[i].itemcount*31, 0, 16*31); - //clearrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE+1); - h = -1; - x = XRES-BARSIZE-26; - y = (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-(height/2)+(FONT_H/2)+1; - sy = y; - //clearrect(vid_buf, (XRES-BARSIZE-width)+1, y-4, width+4, height+4+rows); - fillrect(vid_buf, (XRES-BARSIZE-width)-7, y-10, width+16, height+16+rows, 0, 0, 0, 100); - drawrect(vid_buf, (XRES-BARSIZE-width)-7, y-10, width+16, height+16+rows, 255, 255, 255, 255); - fillrect(vid_buf, (XRES-BARSIZE)+11, (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-2, 15, FONT_H+3, 0, 0, 0, 100); - drawrect(vid_buf, (XRES-BARSIZE)+10, (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-2, 16, FONT_H+3, 255, 255, 255, 255); - drawrect(vid_buf, (XRES-BARSIZE)+9, (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-1, 1, FONT_H+1, 0, 0, 0, 255); - if(i==SC_WALL) - { - for(n = 122; n<122+UI_WALLCOUNT; n++) - { - if(n!=SPC_AIR&&n!=SPC_HEAT&&n!=SPC_COOL&&n!=SPC_VACUUM) - { - if(x-26<=60) - { - x = XRES-BARSIZE-26; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; - if(mx>=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else if(i==SC_SPECIAL) - { - for(n = 122; n<122+UI_WALLCOUNT; n++) - { - if(n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) - { - if(x-26<=60) - { - x = XRES-BARSIZE-26; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; - if(mx>=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else - { - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - - if(h==-1) - { - drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy+height+10, (char *)msections[i].name, 255, 255, 255, 255); - } - else if(i==SC_WALL||(i==SC_SPECIAL&&h>=122)) - { - drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy+height+10, (char *)mwalls[h-122].descs, 255, 255, 255, 255); - } - else - { - drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy+height+10, (char *)ptypes[h].descs, 255, 255, 255, 255); - } - - - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - if(!(mx>=(XRES-BARSIZE-width)-7 && my>=sy-10 && my=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else if(i==SC_SPECIAL) - { - for(n = 122; n<122+UI_WALLCOUNT; n++) - { - if(n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) - { - if(x-26<=20) - { - x = XRES-BARSIZE-26; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; - if(!bq && mx>=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else - { - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - - if(h==-1) - { - drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy-10, (char *)msections[i].name, 255, 255, 255, 255); - } - else if(i==SC_WALL||(i==SC_SPECIAL&&h>=122)) - { - drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy-10, (char *)mwalls[h-122].descs, 255, 255, 255, 255); - } - else - { - drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy-10, (char *)ptypes[h].descs, 255, 255, 255, 255); - } - - if(b==1&&h!=-1) - { - *sl = h; - } - if(b==4&&h!=-1) - { - *sr = h; - } -} - -int create_parts(int x, int y, int r, int c) -{ - int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0; //n; - - if(c == 125) - { - i = x / CELL; - j = y / CELL; - for(v=-1; v<2; v++) - for(u=-1; u<2; u++) - if(i+u>=0 && i+u=0 && j+v=0&&ox=0&&oyabs(x2-x1), x, y, dx, dy, sy; - float e, de; - if(cp) - { - y = x1; - x1 = y1; - y1 = y; - y = x2; - x2 = y2; - y2 = y; - } - if(x1 > x2) - { - y = x1; - x1 = x2; - x2 = y; - y = y1; - y1 = y2; - y2 = y; - } - dx = x2 - x1; - dy = abs(y2 - y1); - e = 0.0f; - if(dx) - de = dy/(float)dx; - else - de = 0.0f; - y = y1; - sy = (y1= 0.5f) - { - y += sy; - if(c==135 || c==140 || c==134 || c==133 || c==132 || c==131 || c==129 || c==128 || c==127 || c==125 || c==124 || c==123 || c==122 || !r) - { - if(cp) - create_parts(y, x, r, c); - else - create_parts(x, y, r, c); - } - e -= 1.0f; - } - } -} - -void create_box(int x1, int y1, int x2, int y2, int c) -{ - int i, j; - if(x1>x2) - { - i = x2; - x2 = x1; - x1 = i; - } - if(y1>y2) - { - j = y2; - y2 = y1; - y1 = j; - } - for(j=y1; j<=y2; j++) - for(i=x1; i<=x2; i++) - create_parts(i, j, 1, c); -} - -int flood_parts(int x, int y, int c, int cm, int bm) -{ - int x1, x2, dy = (c=122&&c<=122+UI_WALLCOUNT) - { - c = c-100; - } - if(cm==-1) - { - if(c==0) - { - cm = pmap[y][x]&0xFF; - if(!cm) - return 0; - } - else - cm = 0; - } - if(bm==-1) - { - if(c==30) - { - bm = bmap[y/CELL][x/CELL]; - if(!bm) - return 0; - if(bm==1) - cm = 0xFF; - } - else - bm = 0; - } - - if((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm) - return 1; - - // go left as far as possible - x1 = x2 = x; - while(x1>=CELL) - { - if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm) - break; - x1--; - } - while(x2=CELL+dy) - for(x=x1; x<=x2; x++) - if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm) - if(!flood_parts(x, y-dy, co, cm, bm)) - return 0; - if(y=x0+18 && mx=y-2 && my=x0+d+18 && mx=y-2 && my=x0+d+32 && mx=y-2 && my=x0 && mx<=x0+192 && my>=y0+240 && my=x0+9 && mx=y0+218 && my=x0+9 && mx=y0+22 && my=x0 && mx=y0+74+YRES/4 && my=gx+XRES/GRID_S-4 && mx<(gx+XRES/GRID_S)+6 && my>=gy-6 && my=gx && mx=gy && my=1 && mx<=17 && my>=YRES+MENUSIZE-18 && my0) - { - if(stamp_page) - { - stamp_page --; - } - sdl_wheel = 0; - } - if((b && !bq && mx>=XRES-18 && mx<=XRES-1 && my>=YRES+MENUSIZE-18 && my 18) ? signs[i].y - 18 : signs[i].y + 4; -} - -void render_signs(pixel *vid_buf) -{ - int i, j, x, y, w, h, dx, dy; - char buff[30]; //Buffer - for(i=0; i>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)>8].temp); //...tempirature - else - sprintf(buff, "Temp: 0.00"); //...tempirature - drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); - } - - //Usual text - if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}")) - drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); - x = signs[i].x; - y = signs[i].y; - dx = 1 - signs[i].ju; - dy = (signs[i].y > 18) ? -1 : 1; - for(j=0; j<4; j++) - { - drawpixel(vid_buf, x, y, 192, 192, 192, 255); - x+=dx; - y+=dy; - } - } -} - /*********************************************************** * CONFIG FILE * ***********************************************************/ @@ -3624,52 +2489,6 @@ void dim_copy(pixel *dst, pixel *src) } } -unsigned int fire_alpha[CELL*3][CELL*3]; -void prepare_alpha(void) -{ - int x,y,i,j; - float temp[CELL*3][CELL*3]; - memset(temp, 0, sizeof(temp)); - for(x=0; x=0 && j+y>=0 && i+x4 ? r-4 : 0; - fire_g[j][i] = g>4 ? g-4 : 0; - fire_b[j][i] = b>4 ? b-4 : 0; - } -} - int zoom_en = 0; int zoom_x=(XRES-ZSIZE_D)/2, zoom_y=(YRES-ZSIZE_D)/2; int zoom_wx=0, zoom_wy=0; @@ -3798,47 +2617,6 @@ char *tag = "(c) 2008-9 Stanislaw Skowronek"; int itc = 0; char itc_msg[64] = "[?]"; -pixel *fire_bg; -void set_cmode(int cm) -{ - cmode = cm; - itc = 51; - if(cmode==4) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Blob Display"); - } - else if(cmode==5) - { - strcpy(itc_msg, "Heat Display"); - } - else if(cmode==6) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Fancy Display"); - } - else if(cmode==3) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Fire Display"); - } - else if(cmode==2) - { - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); - strcpy(itc_msg, "Persistent Display"); - } - else if(cmode==1) - strcpy(itc_msg, "Pressure Display"); - else - strcpy(itc_msg, "Velocity Display"); -} - char my_uri[] = "http://" SERVER "/Update.api?Action=Download&Architecture=" #if defined WIN32 "Windows32" @@ -3955,20 +2733,6 @@ corrupt: return NULL; } -void clear_area(int area_x, int area_y, int area_w, int area_h) -{ - int cx = 0; - int cy = 0; - for(cy=0; cyx2) + { + i = x2; + x2 = x1; + x1 = i; + } + if(y1>y2) + { + j = y2; + y2 = y1; + y1 = j; + } + for(j=y1; j<=y2; j++) + for(i=x1; i<=x2; i++) + create_parts(i, j, 1, c); +} + +int flood_parts(int x, int y, int c, int cm, int bm) +{ + int x1, x2, dy = (c=122&&c<=122+UI_WALLCOUNT) + { + c = c-100; + } + if(cm==-1) + { + if(c==0) + { + cm = pmap[y][x]&0xFF; + if(!cm) + return 0; + } + else + cm = 0; + } + if(bm==-1) + { + if(c==30) + { + bm = bmap[y/CELL][x/CELL]; + if(!bm) + return 0; + if(bm==1) + cm = 0xFF; + } + else + bm = 0; + } + + if((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm) + return 1; + + // go left as far as possible + x1 = x2 = x; + while(x1>=CELL) + { + if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm) + break; + x1--; + } + while(x2=CELL+dy) + for(x=x1; x<=x2; x++) + if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm) + if(!flood_parts(x, y-dy, co, cm, bm)) + return 0; + if(y=0 && i+u=0 && j+v=0&&ox=0&&oyabs(x2-x1), x, y, dx, dy, sy; + float e, de; + if(cp) + { + y = x1; + x1 = y1; + y1 = y; + y = x2; + x2 = y2; + y2 = y; + } + if(x1 > x2) + { + y = x1; + x1 = x2; + x2 = y; + y = y1; + y1 = y2; + y2 = y; + } + dx = x2 - x1; + dy = abs(y2 - y1); + e = 0.0f; + if(dx) + de = dy/(float)dx; + else + de = 0.0f; + y = y1; + sy = (y1= 0.5f) + { + y += sy; + if(c==135 || c==140 || c==134 || c==133 || c==132 || c==131 || c==129 || c==128 || c==127 || c==125 || c==124 || c==123 || c==122 || !r) + { + if(cp) + create_parts(y, x, r, c); + else + create_parts(x, y, r, c); + } + e -= 1.0f; + } + } } \ No newline at end of file diff --git a/powder.h b/powder.h index fa7543502..a12c37a84 100644 --- a/powder.h +++ b/powder.h @@ -456,4 +456,14 @@ void update_particles_i(pixel *vid, int start, int inc); void update_particles(pixel *vid); +void clear_area(int area_x, int area_y, int area_w, int area_h); + +void create_box(int x1, int y1, int x2, int y2, int c); + +int flood_parts(int x, int y, int c, int cm, int bm); + +int create_parts(int x, int y, int r, int c); + +void create_line(int x1, int y1, int x2, int y2, int r, int c); + #endif \ No newline at end of file