summaryrefslogtreecommitdiff
path: root/src/interface.c
diff options
context:
space:
mode:
authorCracker64 <cracker642@gmail.com>2011-03-02 20:43:20 (GMT)
committer Cracker64 <cracker642@gmail.com>2011-03-02 20:43:20 (GMT)
commit9fffbb88da1062911c42146f4e9022a045177f75 (patch)
tree27009a59552c944a934ea1edf796472d6c937d04 /src/interface.c
parent13e90886c1d4ae571707c8f31a7702fce7b2ec74 (diff)
downloadpowder-9fffbb88da1062911c42146f4e9022a045177f75.zip
powder-9fffbb88da1062911c42146f4e9022a045177f75.tar.gz
console things, set commands use keywords for arguments.
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/src/interface.c b/src/interface.c
index 5e8eed4..07355a4 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -3839,13 +3839,15 @@ 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 = 210;
+ ed.y = 207;
ed.w = XRES;
ed.nx = 1;
ed.def = "";
@@ -3854,9 +3856,19 @@ 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);
-
+ currentcommand2 = malloc(sizeof(command_history));
+ memset(currentcommand2, 0, sizeof(command_history));
+ currentcommand2->prev_command = last_command2;
+ currentcommand2->command = mystrdup(error);
+ last_command2 = currentcommand2;
+ cc = 0;
+ while(cc < 80){
+ fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2));
+ cc++;
+ }
while (!sdl_poll())
{
b = SDL_GetMouseState(&mx, &my);
@@ -3866,11 +3878,10 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
//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.3 (by cracker64)\n"
- "Current commands are quit, set, reset, load, create, file, kill, sound\n" //TODO: help command
- ,255, 187, 187, 255);
-
+ 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
+ ,255, 255, 255, 255);
+
cc = 0;
currentcommand = last_command;
while(cc < 10)
@@ -3893,9 +3904,36 @@ 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)
- drawtext(vid_buf, 15, 190, error,255, 187, 187, 255);
+ //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);
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));