diff --git a/src/interface.c b/src/interface.c index a762b39d7..5e8eed45f 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3841,6 +3841,7 @@ typedef struct command_history command_history; command_history *last_command = NULL; char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands int mx,my,b,cc,ci = -1; + pixel *old_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); command_history *currentcommand; ui_edit ed; ed.x = 15; @@ -3853,7 +3854,9 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show ed.hide = 0; ed.multiline = 0; ed.cursor = 0; - //fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190); + memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); + fillrect(old_buf, -1, -1, XRES, 220, 0, 0, 0, 190); + while (!sdl_poll()) { b = SDL_GetMouseState(&mx, &my); @@ -3861,19 +3864,11 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show my /= sdl_scale; ed.focus = 1; - clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? + //clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? + memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE); - drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.2 (by cracker64)\n" - "Current commands are quit, set, reset, load, create, file, kill, sound\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" - "You can now use particle names (ex. set type all deut)\n" - "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n" - "To load a save use load saveID (ex. load 1337)\n" - "Create particles with 'create deut x,y' where x and y are the coords\n" - "Run scripts from file 'file filename'\n" - "You can delete/kill a particle with 'kill x,y'" - "Play a sound with (sound blah.wav)" + drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.3 (by cracker64)\n" + "Current commands are quit, set, reset, load, create, file, kill, sound\n" //TODO: help command ,255, 187, 187, 255); cc = 0; @@ -3911,11 +3906,13 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show currentcommand->prev_command = last_command; currentcommand->command = mystrdup(ed.str); last_command = currentcommand; + free(old_buf); return currentcommand->command; } if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE) { console_mode = 0; + free(old_buf); return NULL; } if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN) @@ -3951,6 +3948,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show } } console_mode = 0; + free(old_buf); return NULL; }