diff --git a/includes/interface.h b/includes/interface.h index 0fa6e4087..986d5e4a5 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -224,7 +224,7 @@ void open_link(char *uri); int report_ui(pixel *vid_buf, char *save_id); -char *console_ui(pixel *vid_buf); +char *console_ui(pixel *vid_buf, char error[255]); #endif diff --git a/src/interface.c b/src/interface.c index bbb7c2d82..6f3f0bc4f 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3789,7 +3789,7 @@ void open_link(char *uri) { printf("Cannot open browser\n"); #endif } -char *console_ui(pixel *vid_buf) { //TODO: error messages, show previous commands +char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands int mx,my,b,bq; ui_edit ed; ed.x = 15; @@ -3814,11 +3814,14 @@ char *console_ui(pixel *vid_buf) { //TODO: error messages, show previous command clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE); drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.1 (by cracker64)\n" - "Current commands are quit, set, reset\n" + "Current commands are quit, set, reset, load\n" "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n" "You can also use 'all' instead of a particle number to do it to everything\n" - "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')" + "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n" + "To load a save use load saveID (ex. load 1337)" ,255, 187, 187, 255); + if(error) + drawtext(vid_buf, 15, 190, error,255, 187, 187, 255); 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)); diff --git a/src/main.c b/src/main.c index 37a4ce98b..6f7ee7b4a 100644 --- a/src/main.c +++ b/src/main.c @@ -1117,6 +1117,7 @@ int main(int argc, char *argv[]) pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE); void *http_ver_check; char *ver_data=NULL, *tmp; + char error[255]; int i, j, bq, fire_fc=0, do_check=0, old_version=0, http_ret=0, major, minor, old_ver_len; #ifdef INTERNAL int vs = 0; @@ -1699,8 +1700,10 @@ int main(int argc, char *argv[]) char *console3; char *console4; char *console5; + //char error[255] = "error!"; sys_pause = 1; - console = console_ui(vid_buf); + console = console_ui(vid_buf,error); + strcpy(error,""); if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0) { console2 = strtok(console, " "); @@ -1711,6 +1714,15 @@ int main(int argc, char *argv[]) { break; } + else if(strcmp(console2, "load")==0 && console3) + { + j = atoi(console3); + if(j) + { + open_ui(vid_buf, console3, NULL); + console_mode = 0; + } + } else if(strcmp(console2, "reset")==0 && console3) { if(strcmp(console3, "pressure")==0) @@ -1936,6 +1948,8 @@ int main(int argc, char *argv[]) } } } + else + sprintf(error, "Invalid Command", console2); } if(!console_mode) hud_enable = 1;