summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-30 22:31:39 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-30 22:36:15 (GMT)
commitf97990fedd034e013d27bfb83a6196ab0d4c9a66 (patch)
treea3550252ba2f47f62e48f6f3ac82fe13f7a63fb1 /src/main.c
parent5d34cae2e48938aaeebb44786e164bc3c7d94a43 (diff)
parentbcbcb0063b1f3451b4e329b69d275bcabadc788a (diff)
downloadpowder-f97990fedd034e013d27bfb83a6196ab0d4c9a66.zip
powder-f97990fedd034e013d27bfb83a6196ab0d4c9a66.tar.gz
Merge branch 'upstream' into dev
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c272
1 files changed, 270 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index aa2e190..d20fb35 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1121,6 +1121,7 @@ int main(int argc, char *argv[])
pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
void *http_ver_check;
char *ver_data=NULL, *tmp;
+ char error[255];
int i, j, bq, fire_fc=0, do_check=0, old_version=0, http_ret=0, major, minor, old_ver_len;
#ifdef INTERNAL
int vs = 0;
@@ -1487,8 +1488,13 @@ int main(int argc, char *argv[])
}
if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
active_menu = 11;
- if (sdl_key==SDLK_INSERT || sdl_key==SDLK_BACKQUOTE)
+ if (sdl_key==SDLK_INSERT)// || sdl_key==SDLK_BACKQUOTE)
REPLACE_MODE = !REPLACE_MODE;
+ if (sdl_key==SDLK_BACKQUOTE)
+ {
+ console_mode = !console_mode;
+ hud_enable = !console_mode;
+ }
if (sdl_key=='g')
{
if (sdl_mod & (KMOD_SHIFT))
@@ -1690,6 +1696,268 @@ int main(int argc, char *argv[])
}*/
}
}
+ if(console_mode)
+ {
+ int nx,ny;
+ char *console;
+ char *console2;
+ char *console3;
+ char *console4;
+ char *console5;
+ //char error[255] = "error!";
+ sys_pause = 1;
+ console = console_ui(vid_buf,error);
+ strcpy(error,"");
+ if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
+ {
+ console2 = strtok(console, " ");
+ console3 = strtok(NULL, " ");
+ console4 = strtok(NULL, " ");
+ console5 = strtok(NULL, " ");
+ if(strcmp(console2, "quit")==0)
+ {
+ break;
+ }
+ else if(strcmp(console2, "load")==0 && console3)
+ {
+ j = atoi(console3);
+ if(j)
+ {
+ open_ui(vid_buf, console3, NULL);
+ console_mode = 0;
+ }
+ }
+ else if(strcmp(console2, "reset")==0 && console3)
+ {
+ if(strcmp(console3, "pressure")==0)
+ {
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = 0;
+ }
+
+ }
+ else if(strcmp(console3, "velocity")==0)
+ {
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ vx[ny][nx] = 0;
+ vy[ny][nx] = 0;
+ }
+ }
+ else if(strcmp(console3, "sparks")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type==PT_SPRK)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 4;
+ }
+ }
+ }
+ else if(strcmp(console3, "temp")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ {
+ parts[i].temp = ptypes[parts[i].type].heat;
+ }
+ }
+ }
+ }
+ else if(strcmp(console2, "set")==0 && console3 && console4 && console5)
+ {
+ if(strcmp(console3, "life")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].life = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].life = j;
+ }
+ }
+ }
+ if(strcmp(console3, "type")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].type = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].type = j;
+ }
+ }
+ }
+ if(strcmp(console3, "temp")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].temp = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].temp = j;
+ }
+ }
+ }
+ if(strcmp(console3, "tmp")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].tmp = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].tmp = j;
+ }
+ }
+ }
+ if(strcmp(console3, "x")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].x = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].x = j;
+ }
+ }
+ }
+ if(strcmp(console3, "y")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].y = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].y = j;
+ }
+ }
+ }
+ if(strcmp(console3, "ctype")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].ctype = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].ctype = j;
+ }
+ }
+ }
+ if(strcmp(console3, "vx")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].vx = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].vx = j;
+ }
+ }
+ }
+ if(strcmp(console3, "vy")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].vy = j;
+ }
+ } else
+ {
+ i = atoi(console4);
+ if(parts[i].type)
+ {
+ j = atoi(console5);
+ parts[i].vy = j;
+ }
+ }
+ }
+ }
+ else
+ sprintf(error, "Invalid Command", console2);
+ }
+ if(!console_mode)
+ hud_enable = 1;
+ }
bq = b;
b = SDL_GetMouseState(&x, &y);
@@ -1741,7 +2009,7 @@ int main(int argc, char *argv[])
int tctype = parts[cr>>8].ctype;
if (tctype>=PT_NUM)
tctype = 0;
- sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
+ sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life ,cr>>8);
//sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
} else {
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);