diff options
| author | Simon <simon@hardwired.org.uk> | 2011-03-22 17:25:29 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2011-03-22 17:25:29 (GMT) |
| commit | c096b2b14a200a0cc0a08cfea839c9e7f4edf22e (patch) | |
| tree | 6aaca470697115e62c8f5f4c612847499233dac7 /src/interface.c | |
| parent | 7d56b3358969164deccb7cc837aa5dd3b59ea4f3 (diff) | |
| parent | ffc3e0a5ee780c05abe5ff53432583c40ed62032 (diff) | |
| download | powder-c096b2b14a200a0cc0a08cfea839c9e7f4edf22e.zip powder-c096b2b14a200a0cc0a08cfea839c9e7f4edf22e.tar.gz | |
More cracker fixes
Diffstat (limited to 'src/interface.c')
| -rw-r--r-- | src/interface.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/src/interface.c b/src/interface.c index 8ba00a5..d230980 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3868,10 +3868,12 @@ struct command_history { }; 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 +command_history *last_command2 = NULL; +char *console_ui(pixel *vid_buf,char error[255],char console_more) { int mx,my,b,cc,ci = -1; pixel *old_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); command_history *currentcommand; + command_history *currentcommand2; ui_edit ed; ed.x = 15; ed.y = 207; @@ -3885,7 +3887,17 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show 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); + + 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); + cc = 0; while(cc < 80){ fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2)); @@ -3900,8 +3912,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); draw_line(vid_buf, 0, 219, XRES+BARSIZE-1, 219, 228, 228, 228, XRES+BARSIZE); - drawtext(vid_buf, 15, 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 + drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)" //TODO: help command ,255, 255, 255, 255); cc = 0; @@ -3926,11 +3937,35 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show break; } } + cc = 0; + currentcommand2 = last_command2; + while(cc < 10) + { + if(currentcommand2==NULL) + break; + drawtext(vid_buf, 215, 175-(cc*12), currentcommand2->command, 255, 225, 225, 255); + if(currentcommand2->prev_command!=NULL) + { + if(cc<9) { + currentcommand2 = currentcommand2->prev_command; + } else if(currentcommand2->prev_command!=NULL) { + free(currentcommand2->prev_command); + currentcommand2->prev_command = NULL; + } + cc++; + } + else + { + break; + } + } - if(error && ed.str[0]=='\0') - drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200); - - drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240); + //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); ui_edit_draw(vid_buf, &ed); ui_edit_process(mx, my, b, &ed); @@ -3943,12 +3978,14 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show currentcommand->command = mystrdup(ed.str); last_command = currentcommand; free(old_buf); + SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); return currentcommand->command; } if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE) { console_mode = 0; free(old_buf); + SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); return NULL; } if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN) @@ -3985,6 +4022,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show } console_mode = 0; free(old_buf); + SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); return NULL; } |
