diff --git a/includes/interface.h b/includes/interface.h index 0f4dd3fd6..f12d25bff 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -202,7 +202,7 @@ void execute_save(pixel *vid_buf); int execute_delete(pixel *vid_buf, char *id); -int execute_report(pixel *vid_buf, char *id); +int execute_report(pixel *vid_buf, char *id, char *reason); void execute_submit(pixel *vid_buf, char *id, char *message); @@ -212,5 +212,7 @@ int execute_vote(pixel *vid_buf, char *id, char *action); void open_link(char *uri); +int report_ui(pixel *vid_buf, char *save_id); + #endif diff --git a/src/interface.c b/src/interface.c index 94b0e8a7c..10e272cf3 100644 --- a/src/interface.c +++ b/src/interface.c @@ -33,6 +33,7 @@ int svf_myvote = 0; int svf_publish = 0; char svf_id[16] = ""; char svf_name[64] = ""; +char svf_description[255] = ""; char svf_tags[256] = ""; void *svf_last = NULL; int svf_lsize; @@ -1124,9 +1125,10 @@ finish: int save_name_ui(pixel *vid_buf) { - int x0=(XRES-192)/2,y0=(YRES-68-YRES/4)/2,b=1,bq,mx,my,ths,nd=0; + int x0=(XRES-400)/2,y0=(YRES-68-YRES/4)/2,b=1,bq,mx,my,ths,nd=0; void *th; ui_edit ed; + ui_edit ed2; ui_checkbox cb; th = build_thumb(&ths, 0); @@ -1148,6 +1150,18 @@ int save_name_ui(pixel *vid_buf) ed.cursor = strlen(svf_name); ed.multiline = 0; strcpy(ed.str, svf_name); + + ed2.x = x0+13; + ed2.y = y0+45; + ed2.w = 166; + ed2.h = 85; + ed2.nx = 1; + ed2.def = "[simulation description]"; + ed2.focus = 0; + ed2.hide = 0; + ed2.cursor = strlen(svf_description); + ed2.multiline = 1; + strcpy(ed2.str, svf_description); cb.x = x0+10; cb.y = y0+53+YRES/4; @@ -1162,16 +1176,19 @@ int save_name_ui(pixel *vid_buf) mx /= sdl_scale; my /= sdl_scale; - drawrect(vid_buf, x0, y0, 192, 90+YRES/4, 192, 192, 192, 255); - clearrect(vid_buf, x0, y0, 192, 90+YRES/4); + drawrect(vid_buf, x0, y0, 400, 90+YRES/4, 192, 192, 192, 255); + clearrect(vid_buf, x0, y0, 400, 90+YRES/4); drawtext(vid_buf, x0+8, y0+8, "New simulation name:", 255, 255, 255, 255); drawtext(vid_buf, x0+10, y0+23, "\x82", 192, 192, 192, 255); drawrect(vid_buf, x0+8, y0+20, 176, 16, 192, 192, 192, 255); + + drawrect(vid_buf, x0+8, y0+40, 176, 95, 192, 192, 192, 255); ui_edit_draw(vid_buf, &ed); + ui_edit_draw(vid_buf, &ed2); - drawrect(vid_buf, x0+(192-XRES/4)/2-2, y0+42, XRES/4+3, YRES/4+3, 128, 128, 128, 255); - render_thumb(th, ths, 0, vid_buf, x0+(192-XRES/4)/2, y0+44, 4); + drawrect(vid_buf, x0+(192-XRES/3)/2-2+200, y0+34, XRES/3+3, YRES/3+3, 128, 128, 128, 255); + render_thumb(th, ths, 0, vid_buf, x0+(200-XRES/3)/2+200, y0+36, 3); ui_checkbox_draw(vid_buf, &cb); drawtext(vid_buf, x0+34, y0+50+YRES/4, "Publish? (Do not publish others'\nworks without permission)", 192, 192, 192, 255); @@ -1182,6 +1199,7 @@ int save_name_ui(pixel *vid_buf) sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); ui_edit_process(mx, my, b, &ed); + ui_edit_process(mx, my, b, &ed2); ui_checkbox_process(mx, my, b, bq, &cb); if(b && !bq && ((mx>=x0+9 && mx=y0+22 && my(XRES+BARSIZE-400)+150 && my>(YRES+MENUSIZE-150)-18 && mx<(XRES+BARSIZE-400)+200 && my<(YRES+MENUSIZE-150)){ + fillrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40); + if(b){ + if(execute_report(vid_buf, save_id, ed.str)){ + info_ui(vid_buf, "Success", "This save has been reported"); + return 1; + } else { + return 0; + } + } + } + if(mx>200 && my>(YRES+MENUSIZE-150)-18 && mx<250 && my<(YRES+MENUSIZE-150)){ + fillrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40); + if(b) + return 0; + } + ui_edit_draw(vid_buf, &ed); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + ui_edit_process(mx, my, b, &ed); + } + return 0; +} + int open_ui(pixel *vid_buf, char *save_id, char *save_date) { int b=1,bq,mx,my,ca=0,thumb_w,thumb_h,active=0,active_2=0,cc=0,ccy=0,cix=0,hasdrawninfo=0,hasdrawnthumb=0,authoritah=0,myown=0,queue_open=0,data_size=0,retval=0,bc=255,openable=1; @@ -2709,53 +2794,6 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) drawtext(vid_buf, XRES+BARSIZE-90, YRES+MENUSIZE-63, "Submit", 255, 255, 255, 255); } - if(queue_open) { - if(info_ready && data_ready) { - // Do Open! - status = parse_save(data, data_size, 1, 0, 0); - if(!status) { - //if(svf_last) - //free(svf_last); - svf_last = data; - svf_lsize = data_size; - - svf_open = 1; - svf_own = svf_login && !strcmp(info->author, svf_user); - svf_publish = info->publish && svf_login && !strcmp(info->author, svf_user); - - strcpy(svf_id, save_id); - strcpy(svf_name, info->name); - if(info->tags) - { - strncpy(svf_tags, info->tags, 255); - svf_tags[255] = 0; - } else { - svf_tags[0] = 0; - } - svf_myvote = info->myvote; - retval = 1; - break; - } else { - queue_open = 0; - - svf_open = 0; - svf_publish = 0; - svf_own = 0; - svf_myvote = 0; - svf_id[0] = 0; - svf_name[0] = 0; - svf_tags[0] = 0; - if(svf_last) - free(svf_last); - svf_last = NULL; - error_ui(vid_buf, 0, "An Error Occurred"); - } - } else { - fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 190); - drawtext(vid_buf, XRES+BARSIZE/2, XRES+MENUSIZE, "Loading...", 0, 0, 0, 200); - } - } - //Open Button bc = openable?255:150; drawrect(vid_buf, 50, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); @@ -2808,14 +2846,9 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) fillrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); if(b && !bq) { //Button Clicked - if(confirm_ui(vid_buf, "Are you sure?", "Are you sure you wish to report this save?", "Report")){ - fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); - info_box(vid_buf, "Reporting..."); - if(execute_report(vid_buf, save_id)){ - info_ui(vid_buf, "Success", "This save has been reported"); - retval = 0; - break; - } + if(report_ui(vid_buf, save_id)){ + retval = 0; + break; } } } @@ -2870,17 +2903,69 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) } if(!(mx>50 && my>50 && mxauthor, svf_user); + svf_publish = info->publish && svf_login && !strcmp(info->author, svf_user); + + strcpy(svf_id, save_id); + strcpy(svf_name, info->name); + strcpy(svf_description, info->description); + if(info->tags) + { + strncpy(svf_tags, info->tags, 255); + svf_tags[255] = 0; + } else { + svf_tags[0] = 0; + } + svf_myvote = info->myvote; + retval = 1; + break; + } else { + queue_open = 0; + + svf_open = 0; + svf_publish = 0; + svf_own = 0; + svf_myvote = 0; + svf_id[0] = 0; + svf_name[0] = 0; + svf_description[0] = 0; + svf_tags[0] = 0; + if(svf_last) + free(svf_last); + svf_last = NULL; + error_ui(vid_buf, 0, "An Error Occurred"); + } + } else { + fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 190); + drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128); + } + } + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); if(info_ready && svf_login){ ui_edit_process(mx, my, b, &ed); } - if(sdl_key==SDLK_ESCAPE) + if(sdl_key==SDLK_ESCAPE){ + retval = 0; break; + } if(lasttime