mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 12:02:40 +02:00
Pretty transparent console
This commit is contained in:
@@ -3841,10 +3841,11 @@ typedef struct command_history command_history;
|
|||||||
command_history *last_command = NULL;
|
command_history *last_command = NULL;
|
||||||
char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands
|
char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands
|
||||||
int mx,my,b,cc,ci = -1;
|
int mx,my,b,cc,ci = -1;
|
||||||
|
pixel *old_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
||||||
command_history *currentcommand;
|
command_history *currentcommand;
|
||||||
ui_edit ed;
|
ui_edit ed;
|
||||||
ed.x = 15;
|
ed.x = 15;
|
||||||
ed.y = 210;
|
ed.y = 207;
|
||||||
ed.w = XRES;
|
ed.w = XRES;
|
||||||
ed.nx = 1;
|
ed.nx = 1;
|
||||||
ed.def = "";
|
ed.def = "";
|
||||||
@@ -3854,6 +3855,13 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
|||||||
ed.multiline = 0;
|
ed.multiline = 0;
|
||||||
ed.cursor = 0;
|
ed.cursor = 0;
|
||||||
//fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190);
|
//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);
|
||||||
|
cc = 0;
|
||||||
|
while(cc < 80){
|
||||||
|
fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2));
|
||||||
|
cc++;
|
||||||
|
}
|
||||||
while (!sdl_poll())
|
while (!sdl_poll())
|
||||||
{
|
{
|
||||||
b = SDL_GetMouseState(&mx, &my);
|
b = SDL_GetMouseState(&mx, &my);
|
||||||
@@ -3861,20 +3869,11 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
|||||||
my /= sdl_scale;
|
my /= sdl_scale;
|
||||||
ed.focus = 1;
|
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, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE);
|
draw_line(vid_buf, 0, 219, XRES+BARSIZE-1, 219, 228, 228, 228, XRES+BARSIZE);
|
||||||
drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.2 (by cracker64)\n"
|
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"
|
"Current commands are quit, set, reset, load, create, file, kill, sound\n" //TODO: help command
|
||||||
"You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n"
|
,255, 255, 255, 255);
|
||||||
"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)"
|
|
||||||
,255, 187, 187, 255);
|
|
||||||
|
|
||||||
cc = 0;
|
cc = 0;
|
||||||
currentcommand = last_command;
|
currentcommand = last_command;
|
||||||
@@ -3899,8 +3898,11 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(error)
|
if(error && ed.str[0]=='\0')
|
||||||
drawtext(vid_buf, 15, 190, error,255, 187, 187, 255);
|
drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200);
|
||||||
|
|
||||||
|
drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240);
|
||||||
|
|
||||||
ui_edit_draw(vid_buf, &ed);
|
ui_edit_draw(vid_buf, &ed);
|
||||||
ui_edit_process(mx, my, b, &ed);
|
ui_edit_process(mx, my, b, &ed);
|
||||||
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
|
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
|
||||||
@@ -3911,11 +3913,13 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
|||||||
currentcommand->prev_command = last_command;
|
currentcommand->prev_command = last_command;
|
||||||
currentcommand->command = mystrdup(ed.str);
|
currentcommand->command = mystrdup(ed.str);
|
||||||
last_command = currentcommand;
|
last_command = currentcommand;
|
||||||
|
free(old_buf);
|
||||||
return currentcommand->command;
|
return currentcommand->command;
|
||||||
}
|
}
|
||||||
if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE)
|
if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE)
|
||||||
{
|
{
|
||||||
console_mode = 0;
|
console_mode = 0;
|
||||||
|
free(old_buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN)
|
if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN)
|
||||||
@@ -3951,6 +3955,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
console_mode = 0;
|
console_mode = 0;
|
||||||
|
free(old_buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
40
src/main.c
40
src/main.c
@@ -1677,7 +1677,7 @@ int main(int argc, char *argv[])
|
|||||||
if (sdl_key==SDLK_BACKQUOTE)
|
if (sdl_key==SDLK_BACKQUOTE)
|
||||||
{
|
{
|
||||||
console_mode = !console_mode;
|
console_mode = !console_mode;
|
||||||
hud_enable = !console_mode;
|
//hud_enable = !console_mode;
|
||||||
}
|
}
|
||||||
if (sdl_key=='g')
|
if (sdl_key=='g')
|
||||||
{
|
{
|
||||||
@@ -1906,23 +1906,6 @@ int main(int argc, char *argv[])
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(console_mode)
|
|
||||||
{
|
|
||||||
char *console;
|
|
||||||
//char error[255] = "error!";
|
|
||||||
sys_pause = 1;
|
|
||||||
console = console_ui(vid_buf,console_error);
|
|
||||||
console = mystrdup(console);
|
|
||||||
strcpy(console_error,"");
|
|
||||||
if(process_command(vid_buf,console,&console_error)==-1)
|
|
||||||
{
|
|
||||||
free(console);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free(console);
|
|
||||||
if(!console_mode)
|
|
||||||
hud_enable = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bq = b;
|
bq = b;
|
||||||
b = SDL_GetMouseState(&x, &y);
|
b = SDL_GetMouseState(&x, &y);
|
||||||
@@ -1982,6 +1965,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mx = x;
|
mx = x;
|
||||||
my = y;
|
my = y;
|
||||||
if (update_flag)
|
if (update_flag)
|
||||||
@@ -2743,7 +2727,27 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
|
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
|
||||||
drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, 200);
|
drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(console_mode)
|
||||||
|
{
|
||||||
|
char *console;
|
||||||
|
//char error[255] = "error!";
|
||||||
|
sys_pause = 1;
|
||||||
|
console = console_ui(vid_buf,console_error);
|
||||||
|
console = mystrdup(console);
|
||||||
|
strcpy(console_error,"");
|
||||||
|
if(process_command(vid_buf,console,&console_error)==-1)
|
||||||
|
{
|
||||||
|
free(console);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(console);
|
||||||
|
if(!console_mode)
|
||||||
|
hud_enable = 1;
|
||||||
|
}
|
||||||
|
|
||||||
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
|
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
|
||||||
|
|
||||||
//Setting an element for the stick man
|
//Setting an element for the stick man
|
||||||
|
Reference in New Issue
Block a user