summaryrefslogtreecommitdiff
path: root/src/interface.c
diff options
context:
space:
mode:
authorLieuwe <lieuwemo@gmail.com>2011-03-03 18:38:06 (GMT)
committer Lieuwe <lieuwemo@gmail.com>2011-03-03 18:38:06 (GMT)
commit9f8811159cc80eed0cf30408fdca139a6604fffe (patch)
treeee9469afc173814ecfdffedac2dc3c474a8f0935 /src/interface.c
parent021f2a6c55e67b9223e21ed819285c51e467a90d (diff)
parent9e8b7440ba464f4f84c0058095f4546e1d4da9de (diff)
downloadpowder-9f8811159cc80eed0cf30408fdca139a6604fffe.zip
powder-9f8811159cc80eed0cf30408fdca139a6604fffe.tar.gz
pulled some code by cracker which makes output even more awesome :P
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/interface.c b/src/interface.c
index f529d54..d453a10 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -3839,10 +3839,12 @@ struct command_history {
};
typedef struct command_history command_history;
command_history *last_command = NULL;
+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;
@@ -3856,7 +3858,13 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
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);
+ fillrect(old_buf, -1, -1, XRES+1, 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));
@@ -3869,6 +3877,7 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
my /= sdl_scale;
ed.focus = 1;
+ //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, 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, python by Doxin)" //TODO: help command
@@ -3896,9 +3905,31 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
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);
+ //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
@@ -3915,12 +3946,14 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
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)
@@ -3957,6 +3990,7 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
}
console_mode = 0;
free(old_buf);
+ SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
return NULL;
}