diff options
Diffstat (limited to 'src/interface.c')
| -rw-r--r-- | src/interface.c | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/src/interface.c b/src/interface.c index fa45b70..8220c62 100644 --- a/src/interface.c +++ b/src/interface.c @@ -15,6 +15,8 @@ #include <interface.h> #include <misc.h> + +//char pyready=1; SDLMod sdl_mod; int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0; @@ -3839,21 +3841,16 @@ void open_link(char *uri) { #ifdef WIN32 ShellExecute(0, "OPEN", uri, NULL, NULL, 0); #elif MACOSX - //char *cmd[] = { "open", uri, (char *)0 }; - //execvp("open", cmd); - //LSOpenCFURLRef(CFURLCreateWithString(NULL, CFStringCreateWithCString(NULL, uri, 0) ,NULL), NULL); //TODO: Get this crap working char *cmd = malloc(7+strlen(uri)); strcpy(cmd, "open "); strappend(cmd, uri); system(cmd); #elif LIN32 - //execlp("xdg-open", "xdg-open", uri, (char *)0); char *cmd = malloc(11+strlen(uri)); strcpy(cmd, "xdg-open "); strappend(cmd, uri); system(cmd); #elif LIN64 - //execlp("xdg-open", "xdg-open", uri, (char *)0); char *cmd = malloc(11+strlen(uri)); strcpy(cmd, "xdg-open "); strappend(cmd, uri); @@ -3868,10 +3865,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 - int mx,my,b,cc,ci = -1; +command_history *last_command2 = NULL; +char *console_ui(pixel *vid_buf,char error[255],char console_more) { + int mx,my,b,cc,ci = -1,i; 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 +3884,16 @@ 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,9 +3908,14 @@ 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 - ,255, 255, 255, 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); cc = 0; currentcommand = last_command; @@ -3926,11 +3939,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 +3980,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 +4024,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; } |
