diff options
| author | Simon <simon@hardwired.org.uk> | 2011-04-08 10:09:42 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2011-04-08 10:09:42 (GMT) |
| commit | 767d73c5fc51647dcb5da4ed8349da2186c5060c (patch) | |
| tree | e9cb3540858927af4887553068fd348a95195092 /src/interface.c | |
| parent | 1bdf72be1a306ac07641211adb2ec1539e3d0a48 (diff) | |
| download | powder-767d73c5fc51647dcb5da4ed8349da2186c5060c.zip powder-767d73c5fc51647dcb5da4ed8349da2186c5060c.tar.gz | |
astyle
Diffstat (limited to 'src/interface.c')
| -rw-r--r-- | src/interface.c | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/src/interface.c b/src/interface.c index 98db488..e28cc33 100644 --- a/src/interface.c +++ b/src/interface.c @@ -89,16 +89,16 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h) if (strcmp(signs[i].text, "{t}")==0) *w = textwidth("Temp: 0000.00"); - if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0) + if (sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0) { int sldr, startm; char buff[256]; memset(buff, 0, sizeof(buff)); - for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) + for (sldr=3; signs[i].text[sldr-1] != '|'; sldr++) startm = sldr + 1; sldr = startm; - while(signs[i].text[sldr] != '}') + while (signs[i].text[sldr] != '}') { buff[sldr - startm] = signs[i].text[sldr]; sldr++; @@ -462,7 +462,7 @@ void ui_checkbox_draw(pixel *vid_buf, ui_checkbox *ed) void ui_checkbox_process(int mx, int my, int mb, int mbq, ui_checkbox *ed) { int w = 12; - + if (mb && !mbq) { if (mx>=ed->x && mx<=ed->x+w && my>=ed->y && my<=ed->y+w) @@ -486,8 +486,8 @@ void ui_checkbox_process(int mx, int my, int mb, int mbq, ui_checkbox *ed) void ui_copytext_draw(pixel *vid_buf, ui_copytext *ed) { int g = 180, i = 0; - if(!ed->state){ - if(ed->hover){ + if (!ed->state) { + if (ed->hover) { i = 0; } else { i = 100; @@ -499,7 +499,7 @@ void ui_copytext_draw(pixel *vid_buf, ui_copytext *ed) drawtext(vid_buf, (ed->x+(ed->width/2))-(textwidth("Copied!")/2), ed->y-12, "Copied!", 255, 255, 255, 255-i); g = 190; } - + drawrect(vid_buf, ed->x, ed->y, ed->width, ed->height, g, 255, g, 255-i); drawrect(vid_buf, ed->x+1, ed->y+1, ed->width-2, ed->height-2, g, 255, g, 100-i); drawtext(vid_buf, ed->x+6, ed->y+5, ed->text, g, 255, g, 230-i); @@ -507,8 +507,8 @@ void ui_copytext_draw(pixel *vid_buf, ui_copytext *ed) void ui_copytext_process(int mx, int my, int mb, int mbq, ui_copytext *ed) { - if(my>=ed->y && my<=ed->y+ed->height && mx>=ed->x && mx<=ed->x+ed->width && !ed->state){ - if(mb && !mbq){ + if (my>=ed->y && my<=ed->y+ed->height && mx>=ed->x && mx<=ed->x+ed->width && !ed->state) { + if (mb && !mbq) { clipboard_push_text(ed->text); ed->state = 1; } @@ -521,14 +521,14 @@ void ui_copytext_process(int mx, int my, int mb, int mbq, ui_copytext *ed) void draw_svf_ui(pixel *vid_buf)// all the buttons at the bottom { int c; - + //the open browser button - drawtext(vid_buf, 4, YRES+(MENUSIZE-14), "\x81", 255, 255, 255, 255); + drawtext(vid_buf, 4, YRES+(MENUSIZE-14), "\x81", 255, 255, 255, 255); drawrect(vid_buf, 1, YRES+(MENUSIZE-16), 16, 14, 255, 255, 255, 255); // the reload button c = svf_open ? 255 : 128; - drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255); + drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255); drawrect(vid_buf, 19, YRES+(MENUSIZE-16), 16, 14, c, c, c, 255); // the save sim button @@ -790,12 +790,12 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt) int buttonwidth = 0; int buttonheight = 0; ui_copytext ed; - + buttonwidth = textwidth(copytxt)+12; buttonheight = 10+8; buttony = y0+50; buttonx = x0+(xsize/2)-(buttonwidth/2); - + ed.x = buttonx; ed.y = buttony; ed.width = buttonwidth; @@ -803,43 +803,43 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt) ed.hover = 0; ed.state = 0; strcpy(ed.text, copytxt); - + 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, x0-2, y0-2, xsize+4, ysize+4); drawrect(vid_buf, x0, y0, xsize, ysize, 192, 192, 192, 255); drawtext(vid_buf, x0+8, y0+8, top, 160, 160, 255, 255); drawtext(vid_buf, x0+8, y0+26, txt, 255, 255, 255, 255); - + ui_copytext_draw(vid_buf, &ed); ui_copytext_process(mx, my, b, bq, &ed); - + drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255); drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255); - + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - + if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize) break; - + if (sdl_key==SDLK_RETURN) break; if (sdl_key==SDLK_ESCAPE) break; } - + while (!sdl_poll()) { b = SDL_GetMouseState(&mx, &my); @@ -1382,7 +1382,7 @@ int save_name_ui(pixel *vid_buf) ed2.cursor = strlen(svf_description); ed2.multiline = 1; strcpy(ed2.str, svf_description); - + ctb.x = 0; ctb.y = YRES+MENUSIZE-20; ctb.width = textwidth(svf_id)+12; @@ -1390,7 +1390,7 @@ int save_name_ui(pixel *vid_buf) ctb.hover = 0; ctb.state = 0; strcpy(ctb.text, svf_id); - + cb.x = x0+10; cb.y = y0+53+YRES/4; @@ -1399,7 +1399,7 @@ int save_name_ui(pixel *vid_buf) fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - + while (!sdl_poll()) { bq = b; @@ -1428,7 +1428,7 @@ int save_name_ui(pixel *vid_buf) drawrect(vid_buf, x0, y0+74+YRES/4, 192, 16, 192, 192, 192, 255); draw_line(vid_buf, x0+192, y0, x0+192, y0+90+YRES/4, 150, 150, 150, XRES+BARSIZE); - + if (svf_id[0]) { //Save ID text and copybox @@ -1436,13 +1436,13 @@ int save_name_ui(pixel *vid_buf) idtxtwidth += ctb.width; ctb.x = textwidth("Current save ID: ")+(XRES+BARSIZE-idtxtwidth)/2; drawtext(vid_buf, (XRES+BARSIZE-idtxtwidth)/2, YRES+MENUSIZE-15, "Current save ID: ", 255, 255, 255, 255); - + ui_copytext_draw(vid_buf, &ctb); ui_copytext_process(mx, my, b, bq, &ctb); } sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - + memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); ui_edit_process(mx, my, b, &ed); @@ -1823,7 +1823,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, } else //all other menus { - if (fwidth > XRES-BARSIZE){ //fancy scrolling + if (fwidth > XRES-BARSIZE) { //fancy scrolling float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE))); xoff = (int)(overflow / location); } @@ -2930,7 +2930,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) ed.multiline = 1; ed.cursor = 0; strcpy(ed.str, ""); - + ctb.x = 100; ctb.y = YRES+MENUSIZE-20; ctb.width = textwidth(save_id)+12; @@ -3114,12 +3114,12 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) drawrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 255); drawtext(vid_buf, XRES+BARSIZE-90, YRES+MENUSIZE-63, "Submit", 255, 255, 255, 255); } - + //Save ID text and copybox cix = textwidth("Save ID: "); cix += ctb.width; ctb.x = textwidth("Save ID: ")+(XRES+BARSIZE-cix)/2; - //ctb.x = + //ctb.x = drawtext(vid_buf, (XRES+BARSIZE-cix)/2, YRES+MENUSIZE-15, "Save ID: ", 255, 255, 255, 255); ui_copytext_draw(vid_buf, &ctb); ui_copytext_process(mx, my, b, bq, &ctb); @@ -4054,16 +4054,16 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) { memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); fillrect(old_buf, -1, -1, XRES, 220, 0, 0, 0, 190); - + currentcommand2 = malloc(sizeof(command_history)); memset(currentcommand2, 0, sizeof(command_history)); currentcommand2->prev_command = last_command2; currentcommand2->command = mystrdup(error); last_command2 = currentcommand2; - + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);//enable keyrepeat for console (is disabled on console close later) cc = 0; - while(cc < 80){ + while (cc < 80) { fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2)); cc++; } @@ -4077,30 +4077,30 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) { memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); draw_line(vid_buf, 0, 219, XRES+BARSIZE-1, 219, 228, 228, 228, XRES+BARSIZE); #ifdef PYCONSOLE - if(pygood) - i=255; - else - i=0; - if(pyready) - drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)", 255, i, i, 255); - else - drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, i, i, 255); + if (pygood) + i=255; + else + i=0; + if (pyready) + drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)", 255, i, i, 255); + else + drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, i, i, 255); #else drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, 255, 255, 255); #endif - + cc = 0; currentcommand = last_command; - while(cc < 10) + while (cc < 10) { - if(currentcommand==NULL) + if (currentcommand==NULL) break; drawtext(vid_buf, 15, 175-(cc*12), currentcommand->command, 255, 255, 255, 255); - if(currentcommand->prev_command!=NULL) + if (currentcommand->prev_command!=NULL) { - if(cc<9) { + if (cc<9) { currentcommand = currentcommand->prev_command; - } else if(currentcommand->prev_command!=NULL) { + } else if (currentcommand->prev_command!=NULL) { free(currentcommand->prev_command); currentcommand->prev_command = NULL; } @@ -4113,16 +4113,16 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) { } cc = 0; currentcommand2 = last_command2; - while(cc < 10) + while (cc < 10) { - if(currentcommand2==NULL) + if (currentcommand2==NULL) break; drawtext(vid_buf, 215, 175-(cc*12), currentcommand2->command, 255, 225, 225, 255); - if(currentcommand2->prev_command!=NULL) + if (currentcommand2->prev_command!=NULL) { - if(cc<9) { + if (cc<9) { currentcommand2 = currentcommand2->prev_command; - } else if(currentcommand2->prev_command!=NULL) { + } else if (currentcommand2->prev_command!=NULL) { free(currentcommand2->prev_command); currentcommand2->prev_command = NULL; } @@ -4135,12 +4135,12 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) { } //if(error && ed.str[0]=='\0') - //drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200); - if(console_more==0) - drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240); - else - drawtext(vid_buf, 5, 207, "...", 255, 255, 255, 240); - + //drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200); + if (console_more==0) + drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240); + else + drawtext(vid_buf, 5, 207, "...", 255, 255, 255, 240); + ui_edit_draw(vid_buf, &ed); ui_edit_process(mx, my, b, &ed); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); @@ -4162,22 +4162,22 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) { SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); return NULL; } - if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN) + if (sdl_key==SDLK_UP || sdl_key==SDLK_DOWN) { ci += sdl_key==SDLK_UP?1:-1; - if(ci<-1) + if (ci<-1) ci = -1; - if(ci==-1) + if (ci==-1) { strcpy(ed.str, ""); ed.cursor = strlen(ed.str); } else { - if(last_command!=NULL) { + if (last_command!=NULL) { currentcommand = last_command; for (cc = 0; cc<ci; cc++) { - if(currentcommand->prev_command==NULL) + if (currentcommand->prev_command==NULL) ci = cc; else currentcommand = currentcommand->prev_command; |
